Oscar and Eric play the following game. First, they agree on a positive integer , and they begin by writing its binary representation on a blackboard. They then take turns, with Oscar going first, to write a number on the blackboard in binary representation, such that the sum of all written numbers does not exceed .
The game ends when there are no valid moves left. Oscar wins if the number of s on the blackboard is odd, and Eric wins if it is even.
Let be the sum of all for which Eric can guarantee winning, assuming optimal play.
For example, the first few values of for which Eric can guarantee winning are . Hence .
You are also given that and .
Find . Give your answer modulo .
Write-up coming later
The complete problem is available here. An approach, code, and answer will be added later.