NullPointerException NoSuchElementException

/* 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
{
    BufferedInputStream bf = new BufferedInputStream(System.in);
    BufferedReader r = new BufferedReader( new InputStreamReader( bf ) );
	int test = Integer.parseInt( r.readLine() );
	String[] temp = r.readLine().split("\\s");
	int N = Integer.parseInt( temp[0] );
	int K = Integer.parseInt( temp[1] );
	for(int i = 0; i<test; i++)
	{
	    int val = (N-K)+K*(K+1)/2;
	    System.out.println(val);
	}
}

}
This code Works fine againts custom inputs but completly fails NZEC NumberFormatException null
even if i use Scanner it gives NoSuchElementException There must be somthing seriously wrong with COdeChefs backEnd

//