Why do I get an NZEC?

getting NZEC for my code ,in python`https://www.codechef.com/submit/FLOW001]

This might be helpful to someone. I used Java and it gave me NZEC. Even after removing all the functions and just taking input, it was giving me the same error. Finally, I decided to just comment all lines and add one line at a time to check which line was giving me error.

It was: int[][] arr = new int[n][n]

Here, n can go up to 314159.

When I gave the same number in my local system and executed, it gave me:
Exception in thread “main” java.lang.OutOfMemoryError: Java heap space

I was trying to allocate memory for a very big matrix(n^2). This was a mistake I never thought I would make. This is so basic and might help who are struggling with it.

1 Like

It’s still not working for me !
here’s my code :

T=int(input())
n=int(input())
for z in range(T) :
b=[]
a=list(input().split())
a=list(map(lambda x:int(x),a))
#print(a)
for i in range(len(a)) :
count=0
for m in range(0,i) :
if int(a[m]) % int(a[i])==0 :
count+=1
b.append(count)
print(max(b),)
it shows NZEC error in the first line itself

If you’re using Codechef IDE, you need to provide a custom input, or it won’t work. To submit the code, switch to non-IDE mode and then Submit.

1 Like

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

Why am I getting this error on python3.6?

1 Like

For python…

  1. if input demands accepting more than 1 input in a single line.

Then this won’t work…
p = int(input())
q = int(input())

Instead try,
p,q = map(int, input().strip().split())

  1. If code runs on your computer and problem is just while submitting.

Provide custom input in codechef ide or directly submit. Then it wont show NZEC.

import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int cases=Integer.parseInt(br.readLine());
		for(int i=1;i<=cases;i++){
		    int n=Integer.parseInt(br.readLine());
		    if(n<1||n>100000){
		        continue;
		    }
		    int[] series=new int[n];
		    series[1]=1;
		    for(int j=2;j<n;j++){
		        series[j]=series[j-1]+series[j-2];
		    }
		    for(int j=0;j<n;j++){
		        series[j]%=10;
		    }
		    
		    while(series.length>1){
		        int[] derived=new int[series.length/2];
		        int c=0;
		        for(int k=1;k<series.length;k+=2){
		            derived[c++]=series[k];
		        }
		        series=new int[derived.length];
		        System.arraycopy(derived, 0, series, 0, derived.length);
		    }
		    System.out.println(series[0]);
		}
	}
}

When I am running this code, it runs absolutely fine. But, it shows a NZEC while submitting. Why?

What Problem are you trying to solve? :slight_smile:

I am trying to solve this FIBEASY Problem - CodeChef

1 Like

T=input()
T=int(T)
dict1={}
for i in range(T):
n=input()
n=int(n)
for j in range(n):
a,b=map(str,input.split())
if(a not in dict1.keys()):
dict1[a]={‘0’:0,‘1’:0}
dict1[a][b]+=1
for j in dict1:
count+=max(dict1[j][‘0’],dict1[j][‘1’])
print(count)

i am getting nrez error in this python 3 code

I get this error while trying to work with the input in NodeJS. Do not see any NodeJS solutions either.

I got stuck with NZEC error for hours until I realized that RUN button doesn’t give any arguments which was the reason of the error… Try to SUBMIT to see if it still persists. Also give custom inputs if you want to use RUN button.

I also have the mysterious NZEC error with Python 3, for example with such a submission:

https://www.codechef.com/viewsolution/30718239

The code runs perfectly fine on my own computer and I am quite certain it is correct. I must say this very general error message of NZEC is totally useless for debugging. I understand why it’s there for competitions, but for simply practicing – would it be so wrong to give a bit more explanatory message, saying what exactly went wrong, which line caused the problem, etc?

I am making a bold statement here that CodeChef submission feature is buggy and I am challenging CodeChef admins to prove me otherwise.

2 Likes

Buddy, did you got answer for this query… I am also running through same problem

I agree to your statement Janwil. The code submission platform in buggy. I am too getting NZEC error

Same here

I was getting this because i didnt apply the line for i in range(int(input()):

Apply this and get corrected

in python 3 also getting NZEC

this error message:

  File "./prog.py", line 39, in do_job
EOFError: EOF when reading a line

line 39 on my code is: T = int(input().strip())

cannot participate in contest

I just ran your code and the answer was right. I think you ran your code using ‘Run’ button without giving any custom input which might have caused the NZEC error as the same happened with me too. Try running it with custom input and see if it works.

1 Like