runtime error for the problem ' coins '

please find the error in this program

You are getting Run time error because you are assuming that you’ll surely get ten inputs, while that is not true. As you can see in the test cases, you have to read just two inputs 12 and 2, but your code needs 8 more. You don’t need ten inputs every time, you need to read input till you get EOF. You may like using this:

// do evaluations here