Optimal game strategy II

what is wrong in my code?

Sanchit, your code is working fine, pls try to submit it again…

I am getting Memory limit error on this question.