You are calling nextInt() without checking that there is an int to read.
Probably that online test feeds non numbers to your program.
You should call hasNextInt() before.
0
solved Why am I getting run time error for the following code when I submit on an online judge? [closed]