Correct answer in my code editor, WA on website

The link to my submission - Solution: 58832621 | CodeChef

Can someone help me with finding the inputs for which it shows wrong answer or finding the flaw in the logic of this program?

Here,
1
5 5
Here your code gives the output ‘5’, but the correct answer will be 2, as the dog can call 3 people, they will take 1 coins each, leaving 2 coins for the dog.