Please Help!

When I run this code it gives correct answer but while submitting the code it give run time error
how is this even possible if the coded executed correctly but giving run time error??
Question:
https://www.codechef.com/problems/CONFLIP
solution:
https://www.codechef.com/viewsolution/57478069
Please help me I am stuck in this question !!