/* 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
{
BufferedReader p = new BufferedReader(new InputStreamReader(System.in));
int queries= Integer.parseInt(p.readLine());
int big,small;
for (int i =0;i<=queries;i++)
{
int a= Integer.parseInt(p.readLine());
int b= Integer.parseInt(p.readLine());
if(a>b)
{
big=a;
small=b;
}
else
{
big=b;
small=a;
}
if(a%2!=0 && b%2!=0)
{
if(a+2==b || a-2==b)
System.out.println("Yes");
}
else if (a%2==0 && b%2==0)
{
if(a+2==b || a-2==b)
System.out.println("Yes");
}
else if (big-small==1 && big%2==0)
System.out.println("Yes");
else
System.out.println("No");
}
/* 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);
int x=sc.nextInt();
int y=sc.nextInt();
if (y>x)
{
double b=(y-x)-0.50;
System.out.println(b);
why does the following code give NZEC error ?
T = input()
N = [0 for i in range (0,T)]
P = [0 for i in range(T)]
res = [“no” for i in range(T)]
p = [0 for i in range(500)]
cc = [0 for i in range(500)]
ch = [0 for i in range(500)]
for i in range(0,T):
N[i] = input()
P[i] = input()
for j in range (0, N[i]):
p[j] = input()
if (p[j]>=(P[i]/2)):
cc[i] = cc[i]+1
elif (p[j]<=(P[i]/10)):
ch[i] = ch[i]+1
if((cc[i] == 1) and (ch[i] == 2)):
res[i] = “yes”
for i in range(0,T):
print res[i]
import java.io.;
import java.lang.;
public class sum
{
public static void main (String[] args)throws Exception
{
java.io.BufferedReader r = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));
System.out.println(“Enter the number”);
int i=Integer.parseInt(r.readLine());
int sum=0;
for(int j=1;j<i;j++)
{
if(i%j==0)
{
sum+=j;
} }
System.out.println(sum);
}
}
When i encountered NZEC problem, I found that I am using arraylist and adding values in it on basis of some condition and when condition is not fulfilled no value will be added in arraylist and in my next statements i was trying to access elements from empty arraylist which result into NZEC error, So while tracing your code keep in mind these things they may help you.