Why do I get an NZEC?

public class SumOfDigits{
public static void main(String args[]){
Scanner sc= new Scanner(System.in);
System.out.println(“Enter a number”);
int number = sc.nextInt();
int sum = 0;
int input = number;
while(input!=0){
int x = number%10;
sum+=x;
input=number/10;
}
System.out.println(sum);
sc.close();
}
}

What is wrong with my code? It shows NZEC runtime error.

for z in range(int(raw_input())):

na = raw_input()

seq = str(raw_input())

na = raw_input()

seqf = str(raw_input())

flag = 'Yes'

for i in seqf:

    if i not in seq:

        flag = 'No'

print (flag) 

why am I getting NZEC error in this one?

what is error in this code :

m=n=k=t=0
res=[]
inp = ""


t=int(input())
while t:
	inp=raw_input()
	m=int(inp[0])
	n=int(inp[2])
	k=int(inp[4])
	while k:
		if m>n :
			n+=1
			k-=1
		elif n>m:
			m+=1
			k-=1
		else:
			break
	res.append(abs(m-n))
	t-=1

for out in res:
	print out

for the chef with fruits problem?

I am getting this error in JAVA. The code works fine on my local IDE(BlueJ).
For this problem: RRCOPY Problem - CodeChef
My solution: CodeChef: Practical coding for everyone

My python code is running good in my laptop but when submitted in codechef it is throwing run time NZEC error. My code is:

n = int(raw_input())
a = []
while n>0:
	p,q = map(int, raw_input().split())
	c = max(p,q)
	a.append(c**2)
	n = n-1
d = sum(a)
e = int(d**(.5))
print e
3 Likes

Getting an NZEC error for a java code.
Here is the link to it, please check to see where i am makinga mistake.
Thanks
https://www.codechef.com/viewsolution/9505127

getting NZEC for this code.Can anyone will help me?

import java.util.*;
class BUY1GET1
{
public static void main(String args[])
{
int t;
Scanner s = new Scanner(System.in);
t=s.nextInt();
s.nextLine();
while(t–>0)
{
String j = s.nextLine();
//System.out.println(j+“”);
int sum=0,l=j.length();
int a[]=new int[26];
for(int i=0;i<l;i++)
{
a[(int)j.charAt(i)-97]++;
}
for(int i=0;i<26;i++)
{
//System.out.println(a[i]);
if(a[i]%2==0)
sum =sum + a[i]/2;
else
sum= sum + (a[i]+1)/2;
}
System.out.println(sum);

	}
}

}

1 Like

Here is my java code.
Why do I get an NZEC?

import java.util.Scanner;

public class Main{
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
String lines = reader.nextLine();
String[] strs = lines.trim().split("\s+");
int a[] = new int[50];
for (int i = 0; i < 2; i++) {
a[i] = Integer.parseInt(strs[i]);
}
if ((a[0] > a[1] - 0.5) || (a[0] % 5 != 0)) {
System.out.println(a[1]);
} else {
System.out.println(a[1] - (a[0] + 0.5));
}

}

}

I just started doing code chef and am quite new to competitive coding.
i tried 8 questions back to back using Java , which were working good in Netbeans in my laptop.
none of them got successful submision.
each had same problem.
NZEC Error!!!
This is confidence loosening.
PLEASE SOMEONE HELPPPPPP.!!!

2 Likes

This might help.

6 Likes

In my case in java code, multiple things were there:

-the code had an error which was causing arrayOutOfBoundException for certain test cases, which were not given in the sample test cases. Removing that bug did half the work;

-BUT MORE IMPORTANTLY, I was using eclipse, which recommends giving package name, so my code looked like:

	package main;
	
	import java.io.IOException;
	
	public class Main {
             --actual implementation
   }

here the problem is with the first line, you can not use package name. So removing the first line i.e. package main; line caused the code to run successfully.

-in general NZEC is a very common error, if you have any bug in your code, then NZEC error could be thrown,

I’m using input() in python3, pretty sure raw_input() was decprated in python3 so does that means I’m always gonna get NZEC on codechef??

I’m getting NZEC for the following code. Plz help me.
Problem statement DDISH Problem - CodeChef
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Dishes {

public static void main(String[] args) throws Exception {
	BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
	int test= Integer.parseInt(br.readLine());
	
	while(test-->0)
	{
		int flag=1;
		int count= 0;
		String[] LR= br.readLine().split(" ");
		int l= Integer.parseInt(LR[0]);
		int r= Integer.parseInt(LR[1]);
		for (int i=l;i<=r;i++)
		{
			flag=1;
			String s= Integer.toString(i);
			
			for(int m=0;m<s.length(); m++)
				for(int k=m+1;k<s.length(); k++)
				{
					if(s.charAt(m)==s.charAt(k))
					flag= 0;
				}
				if(flag==1)
					count++;
		}
		System.out.print(count);
	}
	
}	

}

t = input()
while(t):
n = input()
k = input()
a = [input() for _ in range(n)]
while(k):
a.remove(max(a))
a.remove(min(a))
k-=1
print ‘%.f’ %float(sum(a)/len(a))
t-=1

Can anybody help me with this code? I’m getting NZEC runtime error.

I have tried scanner.in as well as BufferedReader but still I am getting this NZEC. The code is executing nicely on my local PC. I am not getting the point of this error. What could be the reason. I am really frustrated.

2 Likes

In Python3.4 I used input().rstrip().split(’ ') but still I am getting this error

using

while(t!=0):
#code
t=t-1

will give NZEC

i am getting NZEC error in a java code .but how can i fix it

Dear friends i am new to c programming, i am face the problem for (Add Two Numbers Program) kindly tell me where i did the mistake?

#include <stdio.h>
void main()
{
int a,b,res;
printf(“Enter any 2 number”);
scanf("%d%d",&a,&b);
res=a+b;
printf(“You are Enter %d\n , %d\n the result is %d=”,a,b,res);
return 0;
}

I get the same error in my add two numbers program.The below program is very correct but I get NZSEC error.Please help me and will solve others problem too.

t=int(input())
c=[]
if t>=1 and t<=1000:
for i in range(t):
a=int(input())
b=int(input())
if a>=1 and b>=1:
if a<=10000 and b<=10000:
c.append(a+b)
for i in range(t):
print(c[i])