One can determine the Gray code by its number
using a very simple function: G(x) = x xor (x div 2), where xor stands for bitwise exclusive OR (bitwise modulo
2 addition), and div means integer division. It is interesting to note
that function G(x) is invertible, which means it is always
possible to uniquely restore x given the value of G(x).
Write a program to restore number x
from the given value of G(x).
Limitations
0 <= x, y
<= 109.
Input
The input file contains an integer number y, the value of G(x).
Output
The output file should contain a single integer x such that G(x) = y.
Example
All Rybinsk-2012 problems (in PDF)