exception in thread "main" java.util.nosuchelementException at java.base / java.util.scanner.throwfor (scanner.java:937) at java.base / java.util.scanner.next (scanner.java:1594) at java.base / java.util.scanner.nextint (scanner.java:2258) at java.base / java.util.scanner.nextint (scanner.java:22) at main.main (main.java:10)
paiza.io Streaming is specified immediately, in advance, and does not request to the user with each reading.
You need to specify all the input data in advance in the input field, then your program will work.
And do not forget at the end of the program to add
sc.close () so that the process does not eat memory. Good tone rule.
Hope your problem was precisely in this (your program read empty input)