Sigtstp error java when input is long : MULTHREE

/* 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
{
Scanner sc = new Scanner(System.in);
sc.nextInt();
while(sc.hasNext())
{
long k = sc.nextLong();
long d0 = sc.nextLong();
long d1 = sc.nextLong();
long n=d0+d1, r=0;
long sum, i=2;
sum = (d0
10) + d1;
while(i<k)
{
r = n%10;
sum = (sum*10) + r;
n=n+r;
i++;
}
if(sum%3==0)
System.out.println(“YES”);
else
System.out.println(“NO”);
}
}
}

I guess the variable sum is going to overflow for K around 20 or more. That should be causing the \text{\red{SIGTSTP}} error.

FYI: sigtstp error