CHEF COMP QUERY

https://www.codechef.com/viewsolution/36804789
Can anyone tell me why this code gives runtime error for 2cases?