Cannot get input

Please check my code:
import java.util.Scanner;
public class Main {
public static void main(String args[]) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    int val = 1;
	int nsy = 2;
	int row = 1;

	while(row <= n) {
		if(row == 1)
			System.out.print("1");
		else {
			for(int csy = 1; csy <= nsy; csy++) {
				if(csy == 1 || csy == nsy)
					System.out.print(val);
				else
					System.out.print("0");
			}
		}
		System.out.println();
		val++;
		nsy++;
		row++;
	}
}

}

I am getting errors as follows:
Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Main.main(Main.java:6)