#P15889. [COCI 2025/2026 #6] Džeparac

[COCI 2025/2026 #6] Džeparac

Description

Mother Antonija has earned NN euros and must spend all of it as soon as possible. She may keep a portion of the money for herself, but the remaining amount must be equally distributed to her two sons over several days.

First, she chooses a non-negative integer kk (0kN0 \le k \le N) to keep for herself. The remaining amount of NkN - k euros is then distributed to the sons over dd days. Mother Antonija may also choose not to distribute anything to her sons, which corresponds to the case when N=kN = k and d=0d = 0.

If the money is distributed, it is done so that each day both sons receive the same amount of money. If one son receives xx euros on a given day, the other son also receives xx euros, where xx must be a positive integer. In total, each son must receive the same total amount of money.

Two distributions are considered different if at least one of the following holds:

  • the chosen amount kk is different
  • the number of days dd is different
  • there exists at least one day on which the amounts received by the sons differ (i.e., the sequence of daily payments is not identical).

Your task is to determine the number of different ways in which the mother can distribute the money. Since the number of ways can be very large, output the result modulo 109+710^9 + 7.

Input Format

The first line contains a natural number nn (1n10181 \le n \le 10^{18}), the number from the problem statement.

Output Format

Print a single number - the number of ways in which mother Antonija can distribute the money.

4
4
5
4
793
137435472

Hint

Clarification of the first example: We consider all possible values of the number kk:

k=4k = 4 \to the mother keeps all the money, so the only distribution is the one where the sons receive no money.

k=22k = 2 \to 2 euros remain to be distributed to the sons. The only valid distribution is d=1d = 1, where each son receives 11 euro.

k=04k = 0 \to 4 euros remain to be distributed to the sons. There are two valid distributions:

d=1\quad d = 1 \to each son receives 22 euros

d=2\quad d = 2 \to each day, each son receives 11 euro

k=1k = 1 and k=3k = 3 \to there is no way to divide the remaining amount so that both sons receive the same positive integer amount each day.

In total, there are 1+1+2=41 + 1 + 2 = 4 different ways of distribution.

Scoring

Subtask Points Constraints
1 12 n10n \le 10
2 17 n1000n \le 1000
3 36 n106n \le 10^6
4 5 No additional constraints.