Payingup:practice problem(easy)

My code link is attached below. When I run this it is showing “SIGABRT” error but if run this with custom input and enter the inputs given in question and it is showing correct outputs.
What change should I make in the problem to resolve this error?
https://www.codechef.com/viewsolution/22535110

//