H. Pseudo-Random Number Generator
06:54 12 Nov 2025

time limit per test: 0.3 seconds

memory limit per test: 256 megabytes

Donald loves nature. Being a programmer, Donald writes programs to simulate the growth of trees or to build realistic 3D landscapes. For this purpose, Donald needs a good pseudo-random number generator. He devises the following method to produce an infinite sequence of 40-bit unsigned integers (the lines in green are comments).

m := 1 << 40 // = 2^40 = 1 099 511 627 776
S(0) := 0x600DCAFE // = 1 611 516 670
S(n + 1) := (S(n) + (S(n) >> 20) + 12345) % m

On the last line, x >> 20 denotes the quotient of the Euclidean division of x by 2^20 and x % m denotes the remainder of the Euclidean division of x by m.

As a very first test to decide if this is indeed a good pseudo-random number generator, Donald wishes to count the number of even values produced by this sequence, in order to check whether this is close enough to 50%. Your help will be welcome.

Input

One integer n (0 ≤ n < 2^63).

Output

The output should contain a single line with a single integer corresponding to the number of even values in the sequence S(0), S(1), ..., S(n - 1).

Link: https://codeforces.com/gym/102501/problem/H
Some one pls help me, im tired of WA on test 6.

c++ icc