I would like to know the time constraints about this problem. I have an algorithm which takes
where N is ((10power6) + 3).
Subtask-3 is getting TLE. Does the solution needs more improvement then that? I’m really exhausted optimizing it. I may have reached the atomic state of optimization.