You are not logged in. Please login at www.codechef.com to post your questions!

×

Why do I get an NZEC?

1
3

Why m i getting NZEC (Non Zero Exit Code) for my program?

asked 20 Mar '13, 17:37

tojochacko's gravatar image

1★tojochacko ♦
560101924
accept rate: 42%


This might help.

link

answered 30 Mar '16, 18:39

sahil_g's gravatar image

4★sahil_g
28614
accept rate: 16%

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.

link

answered 20 Mar '13, 17:38

admin's gravatar image

0★admin ♦♦
14.9k347484503
accept rate: 36%

Why am i getting this error in python???

link

answered 21 Apr '13, 00:22

sonuk7's gravatar image

2★sonuk7
112
accept rate: 0%

how to resolve this If I am using Python??

link

answered 13 Nov '14, 23:27

anupam02's gravatar image

2★anupam02
11
accept rate: 0%

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

the_darklord's gravatar image

3★the_darklord
1
accept rate: 0%

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

link

answered 02 Apr, 15:10

lightyaer's gravatar image

0★lightyaer
11
accept rate: 0%

I was getting same for a question in Python 2, try switching to input() and submit in Python 3. It worked for me.

link

answered 15 Jun, 10:34

aashutosh001's gravatar image

3★aashutosh001
41
accept rate: 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.

link

answered 14 Nov '14, 11:14

shubham_coder's gravatar image

3★shubham_coder
284
accept rate: 7%

I tried using raw_input() but still alt text

I'm new to these coding contests, bear me.

link

answered 13 Dec '14, 13:29

karnikamit's gravatar image

1★karnikamit
1
accept rate: 0%

edited 13 Dec '14, 13:30

getting NZEC for my java code, anyone any suggestions on how to make it work ?

link

answered 28 Dec '14, 12:13

sknash's gravatar image

1★sknash
1
accept rate: 0%

check for run time exceptions

(12 Oct '16, 16:02) smsubham3★

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.

link

answered 28 Dec '14, 13:59

brobear1995's gravatar image

2★brobear1995
1561511
accept rate: 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??

link

answered 30 Dec '14, 00:32

code_aholic's gravatar image

1★code_aholic
1
accept rate: 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..!!

:)

link

answered 30 Dec '14, 00:42

rishabhprsd7's gravatar image

2★rishabhprsd7
1.9k11036
accept rate: 14%

edited 30 Dec '14, 00:43

Can Any one tell me why i am always getting NZEC for my java code ?? http://www.codechef.com/viewsolution/5673178

Thanks in advance

link

answered 31 Dec '14, 12:59

the_darklord's gravatar image

3★the_darklord
1
accept rate: 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

link

answered 31 Dec '14, 15:27

rishabhprsd7's gravatar image

2★rishabhprsd7
1.9k11036
accept rate: 14%

i have used raw_input().split() method but still getting a nzec.why?? can anyone help me

link

answered 31 Dec '14, 18:35

lucifer961's gravatar image

0★lucifer961
1
accept rate: 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

link

answered 06 Jan '15, 15:10

sstuff's gravatar image

0★sstuff
11
accept rate: 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

link

answered 24 Jan '15, 11:39

shortyfin's gravatar image

0★shortyfin
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) shortyfin0★

Found it. It didn't like the first line: "package MISINTER;"

(25 Jan '15, 12:06) shortyfin0★

http://www.codechef.com/viewsolution/6345015 why NZEC in java code ??? any help please

link

answered 24 Feb '15, 16:23

figure_it_out's gravatar image

2★figure_it_out
1
accept rate: 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?

link

answered 28 May '15, 04:21

sheetal1296's gravatar image

2★sheetal1296
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) sheetal12962★

why i m getting NZEC in C code i have written the statement return 0;

link

answered 05 Jun '15, 12:51

riya0303's gravatar image

0★riya0303
1
accept rate: 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.

link

answered 19 Jul '15, 00:00

kartikgola's gravatar image

0★kartikgola
1
accept rate: 0%

can you please specify which language.

link

answered 07 Sep '15, 15:48

u_besra's gravatar image

0★u_besra
1
accept rate: 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.

link

answered 11 Sep '15, 15:13

borodor's gravatar image

0★borodor
111
accept rate: 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.

link

answered 28 Sep '15, 04:02

mrugami19's gravatar image

0★mrugami19
1
accept rate: 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?

link

answered 10 Jan '16, 13:54

kaushikmehul's gravatar image

2★kaushikmehul
1
accept rate: 0%

this is CHEFSQ problem

(10 Jan '16, 13:58) kaushikmehul2★

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?

link

answered 28 Jan '16, 09:21

sanad's gravatar image

0★sanad
1
accept rate: 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

link

answered 06 Feb '16, 23:03

ista2000's gravatar image

5★ista2000
1266
accept rate: 12%

edited 06 Feb '16, 23:05

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
link

answered 13 Feb '16, 02:22

sunil_t's gravatar image

1★sunil_t
1
accept rate: 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

link

answered 28 Feb '16, 10:15

vishveshcoder's gravatar image

4★vishveshcoder
18715
accept rate: 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<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);

    }
}

}

link

answered 29 Feb '16, 02:32

divyanshu18's gravatar image

2★divyanshu18
1
accept rate: 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)); }

}

}

link

answered 08 Mar '16, 19:07

engy_mostafa's gravatar image

0★engy_mostafa
1
accept rate: 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.!!!!!

link

answered 20 Mar '16, 14:36

kshitiz_leo's gravatar image

2★kshitiz_leo
1
accept rate: 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,

link

answered 11 Apr '16, 21:18

totallyred99's gravatar image

0★totallyred99
1
accept rate: 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??

link

answered 12 Apr '16, 02:05

vihit22's gravatar image

0★vihit22
1
accept rate: 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<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);
    }

}

}

link

answered 19 Apr '16, 16:35

hashmeet_singh's gravatar image

3★hashmeet_singh
1
accept rate: 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

sprajosh's gravatar image

0★sprajosh
1
accept rate: 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.

link

answered 01 Jun '16, 23:32

mithun_ghose's gravatar image

0★mithun_ghose
1
accept rate: 0%

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

link

answered 01 Jul '16, 18:45

e_galois16's gravatar image

2★e_galois16
1
accept rate: 0%

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

link

answered 24 Jul '16, 14:16

kr6244's gravatar image

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

link

answered 12 Aug '16, 01:27

kaviverma05's gravatar image

0★kaviverma05
1
accept rate: 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])

link

answered 13 Aug '16, 17:51

dr_doom's gravatar image

0★dr_doom
1
accept rate: 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

link

answered 01 Sep '16, 00:04

pratyk's gravatar image

2★pratyk
1
accept rate: 0%

Same here, i think server issue? Please help admin,everyone got nzec for every code

link

answered 01 Sep '16, 18:19

vivek96's gravatar image

3★vivek96
51717
accept rate: 8%

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!

link

answered 01 Sep '16, 20:09

prone's gravatar image

3★prone
1
accept rate: 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.

link

answered 01 Sep '16, 20:37

NitinKhare_13's gravatar image

2★NitinKhare_13
1
accept rate: 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

link

answered 01 Sep '16, 21:30

vivek96's gravatar image

3★vivek96
51717
accept rate: 8%

edited 01 Sep '16, 21:40

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

link

answered 20 Oct '16, 00:31

roansgupta's gravatar image

0★roansgupta
1
accept rate: 0%

use this to put in arrays

array= [int(i) for i in input().split()]

link

answered 29 Oct '16, 13:42

nateshmbhat's gravatar image

0★nateshmbhat
1
accept rate: 0%

I always get a runtimr error(NZEC). I don't know why ? please help.

problem: https://www.codechef.com/problems/MARBLEGF

code: https://www.codechef.com/viewsolution/12382690

link

answered 31 Dec '16, 23:27

blackbird_'s gravatar image

0★blackbird_
1
accept rate: 0%

I'm getting NZEC for the simplest C# code as well? Any suggestions?

link

answered 26 Jan, 21:44

enigma_'s gravatar image

0★enigma_
1
accept rate: 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 :)

link

answered 26 Jan, 22:37

vijju123's gravatar image

3★vijju123
5.1k211
accept rate: 17%

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.

link

answered 31 Jan, 08:18

seraph_wedd18's gravatar image

0★seraph_wedd18
111
accept rate: 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.

link

answered 03 Mar, 17:11

ouioui's gravatar image

2★ouioui
1
accept rate: 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..

link

answered 19 Mar, 10:16

swapnil_2210's gravatar image

2★swapnil_2210
1
accept rate: 0%

1

provide link to the question also

(19 Mar, 10:27) tushkitripathi0★

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<n;i++) {
                 a[i] = inp.nextInt();
if (a[i] % k == 0)
                    count++;
            }
            return count;
}

}

link
This answer is marked "community wiki".

answered 07 Apr, 07:50

codehardy's gravatar image

0★codehardy
1
accept rate: 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.

link

answered 20 Apr, 23:09

shal8mani's gravatar image

2★shal8mani
1
accept rate: 0%

edited 20 Apr, 23:12

guys, please upvote me. i am new here. nad not able to ask question

link

answered 21 Apr, 03:07

thinkinfinit's gravatar image

1★thinkinfinit
672
accept rate: 0%

you should probably return a 0 value by taking int main() as the function in c

link

answered 26 Apr, 23:54

ricksr's gravatar image

1★ricksr
1
accept rate: 0%

For the python users, you can refer to this discussion http://stackoverflow.com/questions/9444503/nzec-error-in-python.. Hope it helps..! :)

link

answered 27 Apr, 10:51

baani_leen's gravatar image

3★baani_leen
1
accept rate: 0%

link

answered 08 May, 12:15

pratiush309's gravatar image

2★pratiush309
1
accept rate: 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.

link

answered 18 May, 08:55

adityaguru149's gravatar image

3★adityaguru149
1
accept rate: 0%

-2

using

while(t!=0):

code

t=t-1

will give NZEC

link

answered 09 Jul '16, 20:30

aishwy's gravatar image

2★aishwy
-1
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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

Tags:

×270
×166

Asked: 20 Mar '13, 17:37

Seen: 45,212 times

Last updated: 15 Jun, 10:34