NAME2:Getting WA

In this code i am getting wrong answer even though i am getting correct output.Why i am getting WA?

question- NAME2 Problem - CodeChef

solution- CodeChef: Practical coding for everyone