What is wrong with my code?

Problem: https://www.codechef.com/problems/FR11
My Solution: https://www.codechef.com/viewsolution/24901364

I’m getting the message ‘wrong answer’ even though my code is perfectly right. When I run my code using ‘custom input’ option with the specified test inputs, I am getting the required output. Then why am I facing a issue while submitting it?

Please tell me what’s wrong.

Thanks in advance.