×

# Why do I get an NZEC?

 1 5 Why m i getting NZEC (Non Zero Exit Code) for my program? asked 20 Mar '13, 17:37 560●10●19●24 accept rate: 42%

 6 This might help. answered 30 Mar '16, 18:39 4★sahil_g 298●1●4 accept rate: 16%
 4 NZEC stands for Non Zero Exit Code. For C users, this will be generated if your main method does not have a return 0; statement. Other languages like Java/C++ could generate this error if they throw an exception. answered 20 Mar '13, 17:38 0★admin ♦♦ 19.8k●350●498●541 accept rate: 36%
 1 Why am i getting this error in python??? answered 21 Apr '13, 00:22 2★sonuk7 12●2 accept rate: 0% It might be because you have referred to out of bound index array (that ie, referring to index > len(array). I also got this error on first try :p (28 Jan '18, 09:16)
 1 how to resolve this If I am using Python?? answered 13 Nov '14, 23:27 2★anupam02 11 accept rate: 0% It might be because you have referred to out of bound index array (that ie, referring to index > len(array). I also got this error on first try :p (28 Jan '18, 09:17)
 1 Why I am getting NZEC error while using BufferedReader Input in JAVA for my solution??(while scanner type input is accepted) link This answer is marked "community wiki". answered 02 Jan '15, 02:08 1 accept rate: 0%
 1 Can anyone check why am I getting NZEC in java.. I have done everything possible after searching this whole Forum.. https://www.codechef.com/viewsolution/13196898 answered 02 Apr '17, 15:10 11 accept rate: 0%
 1 I was getting same for a question in Python 2, try switching to input() and submit in Python 3. It worked for me. answered 15 Jun '17, 10:34 61 accept rate: 0%
 0 Try using raw_input() to take input instead of input() because sometimes it happens that a space is left at the end of input which results in RunTimeerror. answered 14 Nov '14, 11:14 28●4 accept rate: 6% It might be because you have referred to out of bound index array (that ie, referring to index > len(array). I also got this error on first try :p (28 Jan '18, 09:18)
 0 I tried using raw_input() but still I'm new to these coding contests, bear me. answered 13 Dec '14, 13:29 1 accept rate: 0% It might be because you have referred to out of bound index array (that ie, referring to index > len(array). I also got this error on first try :p (28 Jan '18, 09:18)
 0 getting NZEC for my java code, anyone any suggestions on how to make it work ? answered 28 Dec '14, 12:13 1★sknash 1 accept rate: 0% check for run time exceptions (12 Oct '16, 16:02) smsubham3★
 0 If you are using raw_input().split(' ') it may cause nzec because in test cases, there are usually extra spaces at the end. try raw_input().split() and nzec will not come. answered 28 Dec '14, 13:59 156●1●5●11 accept rate: 0%
 0 t=float(raw_input()) s=float(raw_input()) if(t%5!=0 or t>s-0.5): print s else: print s-t-0.5 why am i getting one in this?? answered 30 Dec '14, 00:32 1 accept rate: 0%
 0 @code_aholic seems code is for problem ATM.. One thing to note: Input: 30 120.00 Output: 89.50  In input two values are on same line and the way your code receives input is wrong, it will work only for newline input. So if you want to take multiple input from single line use map(). Here is an example: Replace these two lines t=float(raw_input()) s=float(raw_input())  with t,s=map(float, raw_input().split())  And your code will be able to receive multiple input from single line..!! :) answered 30 Dec '14, 00:42 1.9k●1●12●43 accept rate: 14%
 0 Can Any one tell me why i am always getting NZEC for my java code ?? http://www.codechef.com/viewsolution/5673178 Thanks in advance answered 31 Dec '14, 12:59 1 accept rate: 0%
 0 @the_darklord I am not familiar with JAVA but when i run your code on ideone on giving test cases, your code returns stderr Exception in thread "main" java.lang.NumberFormatException: For input string: "3 6" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:492) at java.lang.Short.parseShort(Short.java:117) at java.lang.Short.parseShort(Short.java:143) at ClosingTweet.main(Main.java:14)  Link : http://ideone.com/g1HO2W answered 31 Dec '14, 15:27 1.9k●1●12●43 accept rate: 14%
 0 i have used raw_input().split() method but still getting a nzec.why?? can anyone help me answered 31 Dec '14, 18:35 1 accept rate: 0% It might be because you have referred to out of bound index array (that ie, referring to index > len(array). I also got this error on first try :p (28 Jan '18, 09:19)
 0 hi, i keep getting NZEC and would like to know if there is a way i can get the inputs used for testing my code. this is my code http://www.codechef.com/viewsolution/5778355 thanks Sivan answered 06 Jan '15, 15:10 0★sstuff 12 accept rate: 0% It might be because you have referred to out of bound index array (that ie, referring to index > len(array). I also got this error on first try :p (28 Jan '18, 09:19)
 0 I've searched through forums and similar code but I'm still getting NZEC. I suspect it could be something with input/output or an index going out of bounds on an array. Any suggestions? http://www.codechef.com/viewsolution/5973516 answered 24 Jan '15, 11:39 1 accept rate: 0% Not a logic problem as I tested it on a file with all possible input values. Tried commenting out all algorithmic functions (just read input and print out 1). Still getting NZEC. (25 Jan '15, 11:53) Found it. It didn't like the first line: "package MISINTER;" (25 Jan '15, 12:06)
 0 http://www.codechef.com/viewsolution/6345015 why NZEC in java code ??? any help please answered 24 Feb '15, 16:23 1 accept rate: 0%
 0 My python code is encountering the NZEC error. How will my code be able to receive multiple input from single line, if those inputs are in the form of an array. Please tell me what to change in this piece of code, to be able to accept an array of inputs from the user. pies=[] for j in range(0,np): pies.append(int(raw_input()))  This is the code to receive input if they are printed on consecutive lines. The problem is that all the inputs are being entered on the same line, but how do i receive the array of inputs from the same line? answered 28 May '15, 04:21 1 accept rate: 0% How do i use the map function to accept array of integers entered on the same line??? (28 May '15, 04:24) It might be because you have referred to out of bound index array (that ie, referring to index > len(array). I also got this error on first try :p (28 Jan '18, 09:20) map(int,raw_input().split()) or map(int,raw_input().split(' ')) Both are correct :p (28 Jan '18, 09:21)
 0 why i m getting NZEC in C code i have written the statement return 0; answered 05 Jun '15, 12:51 0★riya0303 1 accept rate: 0%
 0 My all programs give NZEC error when submitting when using C#. All the programs work perfectly with IDE. Any help ? It's a shame there's no support for this problem. answered 19 Jul '15, 00:00 1 accept rate: 0%
 0 can you please specify which language. answered 07 Sep '15, 15:48 0★u_besra 1 accept rate: 0%
 0 Using Python here. I have used raw_input(), split() , etc. and all that has been suggested here. Still, I am getting this error. Any ideas why ? I am on the Alien Chefs problem. answered 11 Sep '15, 15:13 0★borodor 11●1 accept rate: 0%
 0 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. answered 28 Sep '15, 04:02 1 accept rate: 0%
 0 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? answered 10 Jan '16, 13:54 2 accept rate: 0% this is CHEFSQ problem (10 Jan '16, 13:58) It might be because you have referred to out of bound index array (that ie, referring to index > len(array). I also got this error on first try :p (28 Jan '18, 09:22)
 0 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? answered 28 Jan '16, 09:21 0★sanad 1 accept rate: 0%
 0 I am getting this error in JAVA. The code works fine on my local IDE(BlueJ). For this problem: https://www.codechef.com/problems/RRCOPY My solution: https://www.codechef.com/viewsolution/9327929 answered 06 Feb '16, 23:03 2.4k●7●23 accept rate: 20%
 0 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  answered 13 Feb '16, 02:22 1★sunil_t 1 accept rate: 0%
 0 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 answered 28 Feb '16, 10:15 187●2●9 accept rate: 0%
 0 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
 0 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)); } }  } answered 08 Mar '16, 19:07 1 accept rate: 0%
 0 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.!!!!! answered 20 Mar '16, 14:36 1 accept rate: 0%
 0 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, answered 11 Apr '16, 21:18 1 accept rate: 0%
 0 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?? answered 12 Apr '16, 02:05 0★vihit22 1 accept rate: 0%
 0 I'm getting NZEC for the following code. Plz help me. Problem statement https://www.codechef.com/problems/DDISH 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
 0 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. link This answer is marked "community wiki". answered 03 May '16, 11:52 0★sprajosh 1 accept rate: 0%
 0 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. answered 01 Jun '16, 23:32 1 accept rate: 0%
 0 In Python3.4 I used input().rstrip().split(' ') but still I am getting this error answered 01 Jul '16, 18:45 1 accept rate: 0%
 0 i am getting NZEC error in a java code .but how can i fix it answered 24 Jul '16, 14:16 2★kr6244 1 accept rate: 0%

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; }

1
accept rate: 0%

 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]) answered 13 Aug '16, 17:51 0★dr_doom 1 accept rate: 0%
 0 I am getting this error. I have tried this code for many sample input. However, it is showing NZEC error when i try submitting the code. MY CODE : https://www.codechef.com/viewsolution/11288574 answered 01 Sep '16, 00:04 2★pratyk 1 accept rate: 0%
 0 I also think there is a problem with the IDE Practice Problem, Submitting solutions that have previously worked with AC are now returning a NZEC (I have been testing out the August Long Competition). If anyone can confirm for other problems or the same set, that would be nice. Admins, please clarify the problem! answered 01 Sep '16, 20:09 4★prone 1 accept rate: 0%
 0 just look around at any problem all the latest java submission at any problem get NZEC I even copy pasted my earlier successful submission for a problem and it got NZEC. answered 01 Sep '16, 20:37 1 accept rate: 0%
 0 Why my karma is -1 i am not able ask question,this is serious matter please notify to codechef getting dissapointed after getting nzec answered 01 Sep '16, 21:30 2★vivek96 533●2●21 accept rate: 8%
 0 for this problem https://www.codechef.com/problems/TEST I am getting runtime error and here is my program python l=[] t = "" s = "" while True: num=raw_input() if num.strip()==s: break l.append(int(num)) for x in l: if x==42: break print x answered 20 Oct '16, 00:31 1 accept rate: 0%
 0 use this to put in arrays array= [int(i) for i in input().split()] answered 29 Oct '16, 13:42 1 accept rate: 0%
 0 I always get a runtimr error(NZEC). I don't know why ? please help. answered 31 Dec '16, 23:27 1 accept rate: 0%
 0 I'm getting NZEC for the simplest C# code as well? Any suggestions? answered 26 Jan '17, 21:44 0★enigma_ 1 accept rate: 0%
 0 @enigma_ If you can show us your code, we might help better! But still, for basics, try and read codechef guidelines and FAQ in case they have some sort of syntax for your language. Check if your code has a return 0 or not. Its actually tough to tell the reason of error w/o seeing code for me, but I hope the above helps :) answered 26 Jan '17, 22:37 15.5k●1●20●66 accept rate: 18%
 0 I am using python and am getting the same errors, NZEC. I tried using custom input on the editor and it works fine(even if I add extra spaces or something on the end of the lines), but when I uncheck it, it returns to the NZEC error. I think the error may be within the input given by the server and not on the codes. I wish that some admins can check for errors on it. As, if this error occurs upon multiple languages, then it is a grave one. answered 31 Jan '17, 08:18 11●1 accept rate: 0%
 0 I just also had an NZEC at XENTASK using python 3. I used python 3's input(), selecting pypy as programming language and #! python3 as first code line. This worked before at other tasks, but seems to be the problem at XENTASK. Solved it by simply selecting py 3 as programming language, and it worked fine. So if you use python 3, that might do the trick. answered 03 Mar '17, 17:11 2★ouioui 1 accept rate: 0%
 0 I am getting NZEC error for this code: / package whatever; // 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 Ideone { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); int t,n ; t = sc.nextInt();  int i; while(t-->0) { n = sc.nextInt(); int c = 1; while(n!=1){ for(i=n-1;i>=1;i--) { if(n%i==0) { c++; n = n - i; break; } } } if(c%2==0){ System.out.println("ROHIT"); } else{ System.out.println("VISHAL"); } } }  } how do i solve this? it works fine on ideone but while submitting on codechef i get this runtime error... Please help me.. answered 19 Mar '17, 10:16 1 accept rate: 0% 1 provide link to the question also (19 Mar '17, 10:27)
 0 I am getting NZEC error pleaSE help me . import java.util.Scanner; public class Main { public static void main(String[] args) { int c=calculate(); System.out.println(c); } public static int calculate() { int count=0; Scanner inp=new Scanner(System.in); System.out.println("Enter No. of time input take:\t "); int n=inp.nextByte(); int a[]=new int[n]; System.out.println("All input must be divisible \t "); //k<10pow7 int k=inp.nextByte(); System.out.println("Enter values:"); for(int i=0;i
 0 I was solving this problem SUMTRIAN( https://www.codechef.com/problems/SUMTRIAN ) and was getting this error with Python. I was getting input using raw_input() which was coupled with split(' ') to get a list. This is how I was taking input and converting it into a list of integers : lst = map(int, list(raw_input().split(' '))) Solution to this error: Change the code to : lst = map(int, list(raw_input().strip().split(' '))) strip() removes any unnecessary blank spaces in the input and this removed the NZEC error. answered 20 Apr '17, 23:09 1 accept rate: 0%
 0 guys, please upvote me. i am new here. nad not able to ask question answered 21 Apr '17, 03:07 68●3 accept rate: 0%
 0 you should probably return a 0 value by taking int main() as the function in c answered 26 Apr '17, 23:54 4★ricksr 16●2 accept rate: 6%
 0 For the python users, you can refer to this discussion http://stackoverflow.com/questions/9444503/nzec-error-in-python.. Hope it helps..! :) answered 27 Apr '17, 10:51 1 accept rate: 0%
 0 For python use the following link. https://www.quora.com/How-do-I-take-input-from-STDIN-in-Python/answer/Pratiush-Prasunn answered 08 May '17, 12:15 1 accept rate: 0%
 0 Some python specific debugging NZEC: If the issue is due to leading or trailing spaces any of the below should work for Python:- input().strip().split() input().strip().split(' ') raw_input().strip().split() raw_input().strip().split(' ') If not there might be some other issue - https://discuss.codechef.com/questions/81068/discussion-on-elaborate-list-of-reasons-for-nzec-error-in-python https://discuss.codechef.com/questions/72153/tutorial-how-to-debug-an-nzec-error Common exceptions are LookupError (IndexError, KeyError) ArithmeticError (FloatingPointError, OverflowError, ZeroDivisionError) The last thread is not python specific but the idea is great. I faced the issue currently in python so added these for common good. answered 18 May '17, 08:55 1 accept rate: 0%
 0 My code is executing fine on my laptop but give NZEC error on codechef .Please can anyone tell me what's wrong with it. import java.util.Scanner; public class Main { static int max, p; public static void main(String[] args) { Scanner inp = new Scanner(System.in); long n = inp.nextInt(); int A[] = new int[1000]; int B[] = new int[1000]; int i, j; int lead; for (i = 0; i < n; i++) { A[i] = inp.nextInt(); B[i] = inp.nextInt(); } for (i = 0; i < n; i++) { if (A[i] > B[i]) { lead = A[i] - B[i]; if (lead > max) { max= lead; p = 1; } } else { lead = B[i] - A[i]; if (lead > max) { max = lead; p = 2; } } } System.out.println(p+ " " + max); }  } answered 15 Aug '17, 00:23 1 accept rate: 0%
 0 my code is running fine in my laptop but getting nzec in codechef . iam using java and i have used bufferedreader class and scanner class both but iam still getting nzec in both cases answered 05 Sep '17, 10:47 2★doda19 1 accept rate: 0%
 0 @codehardy can you please mention for which question you have write this code as you have created array A and B of size 1000 elements , which may be insufficient according to the constraints of the question. answered 05 Sep '17, 11:09 25●1●1●4 accept rate: 0%
 0 @doda19 can you please show the code, error must be somewhere else. answered 05 Sep '17, 11:11 25●1●1●4 accept rate: 0%
 0 link for the solution can someone tell why i am getting NZEC error ? answered 14 Sep '17, 00:22 0★vg11 1 accept rate: 0%
 0 Hello please, I am struggling with it too package bytelandian; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; class Bytelandian { Map alreadyComputed = new HashMap<>(); Long compute(Long n) { if (n < 12) { return n; } if (alreadyComputed.containsKey(n)) { return alreadyComputed.get(n); } Long tmp = compute(n / 2) + compute(n / 3) + compute(n / 4); if (tmp < n) { tmp = n; } alreadyComputed.put(n, tmp); // System.out.println(alreadyComputed + ""); return tmp; } public static void main(String[] args) throws Exception { Bytelandian b1 = new Bytelandian(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; while (!(line = br.readLine()).equals("")) { System.out.println(b1.compute(Long.parseLong(line))); } } }  example submission: https://www.codechef.com/viewsolution/17182239  it says 4468M mem, but it seems impossible to me please help, I would like to complete challenges, but error after error occurs when I would like to check my work answered 28 Jan '18, 02:59 0★andylaci 1 accept rate: 0%
 0 If you are using java then remove the package declaration to fix the NZEC error. answered 21 Mar '18, 14:59 1 accept rate: 0%
 0 why i am getting nzec error while i am using javascript answered 15 Oct '18, 11:55 1 accept rate: 0%
 0 https://www.codechef.com/viewsolution/20963272 This is solution of a question ,it is running perfectly on my laptop but giving an NZEC error on codechef. Anyone please help.Help me in knowing my mistakes. answered 18 Oct '18, 23:35 1●1 accept rate: 0%

# include<stdio.h>

void main() { int i,t,X,Y,Z,x,y,z; scanf("%d\n",&t); scanf("%d%d%d",&X,&Y,&Z); for(i=0;i<t;i++) {="" x="X-Y;" y="Y-Z;" z="Z-X;" if(x="">y && y>z && z>x) printf("yes"); else printf("no"); } }

1
accept rate: 0%

 0 I am getting the same error as I am using python while taking the input only answered 01 Feb, 18:29 1 accept rate: 0%

using

while(t!=0):

# code

t=t-1

will give NZEC

2★aishwy
-1
accept rate: 0%

 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×435
×214

question asked: 20 Mar '13, 17:37

question was seen: 77,343 times

last updated: 01 Feb, 18:29