Why do I get an NZEC?

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 :stuck_out_tongue:

CodeChef is officially broken!.
They can’t fix there own mess! :sneezing_face::sneezing_face:

and btw, raw_input() doesnt work in python3 its for python2!

i keep on getting nzec error in all my programs i do copied a right solution but i am still getting same error, So please help me , Thankyou in advance.
here is the link of my code
https://www.codechef.com/submit/HMAPPY2

I am facing the same issue for the python program.
The Question link is: https://www.codechef.com/problems/CSUB
Please help me on how to solve this error.

t=input()
t=int(t)
i,counter,l,v=0,0,list(range(0,t)),list(range(0,t))
for i in range(0,t):
    l[i]=int(input())
    v[i]=int(input())

for i in range(0,t):
    counter=0
    while(v[i]>0):
        if v[i]%10==1:
            counter+=1
        v[i]=v[i]//10
        #print(v[i])
    ans= ((counter*(counter+1))//2)        
    print (ans)

Error I am getting

Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
EOFError: EOF when reading a line
1 Like

https://www.codechef.com/viewsolution/24356597 here is my code in python showing nzec error while submission . but it runs successfully with custom inputs ,why so?

1 Like

Dont know the reason but appently many python programmers are facing this issue
I would suggest switch to c++ or java

You need to come up with a better approach to solve it. The constraints on L and R are 1018. So recursion won’t work be it Python, C++ or Java.

For python 3 do I need to use raw_input() as well ?

NZEC error still unresolved. and the biggest problem is that you can’t check the output of your submission. I changed all reference of ‘input()’ (Python 3.6 code) to ‘sys.stdin.readline()’ but still the code is not working properly after submission. Works just fine for custom input. https://www.codechef.com/viewsolution/25205676

No , python 3 doesn’t even support that.
and don’t worry about white spaces as int(input()) will take care of that.

The thing is always assign your variable in global by assigning None to them. (this was my case once)

But still on clicking the submit button it shows nzec error

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: