Unable to find out the reason behind "Wrong Answer"

Hi,

I am getting “Wrong Answer” for every submission (https://www.codechef.com/viewsolution/29943142).

I have tested my code with several inputs and output was correct. Please help me locate my mistake.

Thanks.