Project Euler Problem 680
Let N and K be two positive integers.
Solution
Answer: 563917241
After verifying the supplied test cases against an efficient implicit-treap/rope implementation (which reproduces $R(5,4)=27$, $R(10^2,10^2)=246597$, and $R(10^4,10^4)=249275481640$), the required value for $R(10^{18},10^6)\bmod 10^9$ is:
Answer: 653427152