LENTMO Corner Test Case

I am trying this problem for some days now but not able to solve it accurately. Just getting 10pts.
I cant understand which test case am I failing. please check my solution and see if you could help me as I am stuck for a long time.

https://www.codechef.com/viewsolution/24876163

check my submission
its concise and has simple 20lines code
also its self explanatory

Thanks for your reply, i was doing a silly mistake, now my code has been accepted
saw your code too, it was great.