how to solve nzec error. the code works fine on codechef ide but faces problem on other ides.
import java.io.;
import java.util.;
class Pattern
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
int i,j,k,p;
for( i=1;i<=n;i++)
{
for( j=1;j<=(n-i);j++)
System.out.print(" ");
int num=i;
for( k=1;k<=i;k++)
{
System.out.print(num);
num++;
}
int num1;
num1=2*i-2;
for(p=1;p<=(i-1);p++)
{
System.out.print(num1);
num1++;
}
System.out.println("");
}
}
}