Java Error

This code was running well in custom input output but producing this error please help!

Error:
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:13)

My Code:

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

/* Name of the class has to be “Main” only if the class is public. */
public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner inp = new Scanner(System.in);
int t;
t=inp.nextInt();
while(t!=0){
t = t-1;
int c;
if(inp.hasNextInt()){
c=inp.nextInt();

        }else{
            c=1;
        }
        List<Integer> li = new ArrayList<Integer>();
        for(int i=1;i<=c;i++)
        li.add(i);
        if(li.size()==1){
            System.out.println(li.get(0));
        }
        else{
        while(li.size()!=1){
            int x,y;
            x=li.get(0);
            y=li.get(li.size()-1);
            li.remove(0);
            li.set(li.size()-1,x+y+(x*y));
        }
        }
        System.out.println(li.get(0));
        
    }
    inp.close();
    
    // your code goes here
}

}

Please if anyone one knows the problem please help

As you have not mentioned the specific question, I can only guess that you are either reading more or less values than required. One simple way of dealing with this could be to print the values you input every time (Can create another program that generates random input based on question’s constraints and use it to stress test your code).

I would also suggest that once you are comfortable with cp, start using fast io. Scanners and System.out are slow.

are you providing the inputs in custom input text area prior running the program?
here you cannot give inputs while your program is running (as when you do in command prompt). Your program will take inputs from custom inputs directly. Also make sure that checkbox of custom input is ticked and your program gave some output.

If thats not the case then it has to be the reason stated by @kukreja_vlk