why am i getting wrong answer despite correct output?

https://www.codechef.com/viewsolution/21985729
this is my solution for the following question https://www.codechef.com/problems/NOMATCH
I am getting the correct output on dry run of the code but it gives me a wrong answer error on submission.
What is wrong in my code, then ?

Hint : your program will give right answer for only 1st Test Case… (look on some variables)

take a look at this https://www.codechef.com/viewsolution/21986835 and it still isn’t working. Please tell me what changes are required!

Just put initialization of s (s=0) in main function inside the while loop so it can initialized for each test case

Great, thanks. It worked.