No Such Element Exception - https://www.codechef.com/problems/CHEFEZQ

Running the code gives ouput - java.util.NoSuchElementException. But in the case of custom input, it works fine. Where am I wrong? Can anyone help me?

Chef and Easy Queries

/* package codechef; // don’t place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    try 
	    {
	        Scanner scan = new Scanner(System.in);
	        int tc = scan.nextInt();
	        
		    for (int i = 0; i < tc; i++)
		    {
		        int n;
		        long qpd;
		        long day = 0;
		        long q = 0;
		        boolean flag = false;
		        
		        n = scan.nextInt();
		        qpd = scan.nextLong();
		        
		        long[] qpdl = new long[n];
		        
		        for (int j = 0; j < n; j++) qpdl[j] = scan.nextLong();
		    
	    	    for (int j = 0; j < n; j++)
		        {
			        day++;	
			        qpdl[j] = qpdl[j] + q;
			        if (qpdl[j] < qpd)
			        {
			            System.out.println(day);
			            flag = true;
			            break;
			        }
			        else q = qpdl[j] - qpd;
		        }
		        if (!flag)
		        {
		            day += (q / qpd) + 1;
		            System.out.println(day);
		        }
		    }
	    }
	    catch(Exception e)
	    {
	        System.out.println(e);
	    }
	}
}

The code ran successfully when clicked button “Submit” and fetched total points. But always gives the same exception when clicked button “Run”. Can anyone explain this?

Codechef IDE does not automatically get the testcases. You need to explicitly provide the testcases. NoSuchElementException means that no input was given at all (in this case)

Thanks.
Actually I practiced on Hackerrank before CodeChef. That’s why I didn’t know about it.
Thank you for the reply.