March Cook-Off 2020 Division 2 » Find Your Gift

The output of this code right, but CodeChef shows the wrong answer. Anyone suggests the corrections in the given code.

https://www.codechef.com/viewsolution/30664817