Why do I get an NZEC?

Why my karma is -1 i am not able ask question,this is serious matter please notify to codechef getting dissapointed after getting nzec

for this problem TEST Problem - CodeChef
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

use this to put in arrays

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

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

problem: MARBLEGF Problem - CodeChef

code: CodeChef: Practical coding for everyone

1 Like

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

@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 :slight_smile:

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.

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.

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…

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

1 Like

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

}

I was solving this problem SUMTRIAN( SUMTRIAN Problem - CodeChef ) 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.

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

1 Like

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

For the python users, you can refer to this discussion NZEC error in Python - Stack Overflow
Hope it helps…! :slight_smile:

For python use the following link.

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.

1 Like

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

1 Like

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


}

}

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

1 Like