This code runs fine with custom input, but error on submitting and with custom input turned off.
CodeChef: Practical coding for everyone.
Earlier it showed this error:
Exception in thread “main” java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Scanner.java:1540)
at Codechef.main(Main.java:16)
I tried to solve this by adding if(sc.hasNextLine())
, but the problems kept increasing, and I ended up with the current solution.