ADAGAME - SPOJ Solution

Hello guys…
I was trying to do this problem from SPOJ - https://www.spoj.com/problems/ADAGAME/

This is my solution - https://ideone.com/PqM7Hk

Could anyone tell what edge case am I missing ( I think it passes till 8th test case). Thank you so much :slight_smile: