Help me in solving KSUM problem

My issue

Exception in thread “main” java.util.NoSuchElementException
at java.base/java.util.Scanner.throwFor(Scanner.java:945)
at java.base/java.util.Scanner.next(Scanner.java:1602)
at java.base/java.util.Scanner.nextInt(Scanner.java:2267)
at java.base/java.util.Scanner.nextInt(Scanner.java:2221)
at Codechef.main(Main.java:10) i am getting this error how to run the code

My code

import java.lang.*;
import java.util.*;
import java.io.*;

@SuppressWarnings("unused")

class Codechef {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        int max = Integer.MIN_VALUE;
        int sum = 0;
        for (int i = 0; i < K; i++) {
            sum += arr[i];
        }
        max = sum;
        for (int i = K; i < N; i++) {
            sum = sum - arr[i - K] + arr[i];
            max = Math.max(max, sum);
        }
        System.out.println(max);
        sc.close();
    }
}

Learning course: 2000 to 2500 difficulty problems
Problem Link: Maximum K Sums Practice Problem in 2000 to 2500 difficulty problems