qyliang/CodeNanoFix huggingface dataset:
Buggy code:
def main():
    from sys import setrecursionlimit, stdin
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor, gcd
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**9+10

    N = II()
    A = LMIIS()
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            return
    print(ans)
    
main()

Fixed code:
def main():
    from sys import setrecursionlimit, stdin
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor, gcd
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**9+10

    N = II()
    A = LMIIS()
    A.sort()
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            return
    print(ans)
    
main()
Buggy code:
N=input()
ls=[int(s) for s in input().split()]
ans=1
flag=1
for e in ls:
  ans*=e
  if ans>10**18:
    flag=0
    break
if flag==1:
  print(ans)
else:
  print(-1)

Fixed code:
N=input()
ls=[int(s) for s in input().split()]
ans=1
flag=1
for e in ls:
  ans*=e
  if ans>10**18:
    flag=0
    break
zeroflag=1
for e in ls:
  if e==0:
    zeroflag=0
if flag==1:
  print(ans)
else:
  print(-1*zeroflag)
Buggy code:
import sys
n=int(input())
As = list(map(int, input().split()))
ans=1
for val in As:
    if val==0:
        ans=0
        break
    ans=val*ans
    if 10**18<ans:
        ans=-1
        break

print(ans)

Fixed code:
import sys
n=int(input())
As = list(map(int, input().split()))
ans=1
for val in As:
    if val==0:
        ans=0
        break
for val in As:
    if ans==0:
        break
    if val==0:
        ans=0
        break
    ans=val*ans
    if 10**18<ans:
        ans=-1
        break

print(ans)
Buggy code:
n = int(input())
sum = 1
noFlag = False
a = list(map(int, input().split()))
for i in range(n):
  sum = sum*a[i]
  if sum > 10 ** 18:
    noFlag = True
    break  
if noFlag == True:
  print(-1)
else:
  print(sum)

Fixed code:
n = int(input())
sum = 1
noFlag = False
zeroFlag = False
a = list(map(int, input().split()))
for i in range(n):
  if a[i] == 0:
    zeroFlag = True
if zeroFlag == False:
  for i in range(n):
    sum = sum*a[i]
    if sum > 10 ** 18:
      noFlag = True
      break  
  if noFlag == True and zeroFlag == False:
    print(-1)
  else:
    print(sum)
else:
  print(0)
Buggy code:
a=int(input())
b=list(map(int,input().split()))
for i in range(a):
  c=c*b[i]
  if c>1000000000000000000:
    print(-1)
    break
print(c)

Fixed code:
a=int(input())
b=list(map(int,input().split()))
c=1
b.sort()
if b[0]==0:
  print(0)
else:
  for i in range(a):
    c=c*b[-i]
    if c>1000000000000000000:
      break
  if c>1000000000000000000:
    print(-1)
  else:
    print(c)
Buggy code:
n = input()
A = list(map(int,input().split()))
ans = 1
 
for i in range(n):
	ans = ans*A[i]
if ans >= 10**18
	ans = -1
print(ans)

Fixed code:
n = int(input())
A = list(map(int,input().split()))
ans = 1

if 0 in A:
  ans = 0
else:
  for i in range(n):
    ans = ans*A[i]
    if ans > 10**18:
        ans = -1
        break
 
print(ans)
Buggy code:
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
print(A)

ans = 1
u = 10 ** 18
if A[-1] == 0:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > u:
            ans = -1
            break
print(ans)

Fixed code:
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)

ans = 1
u = 10 ** 18
if A[-1] == 0:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > u:
            ans = -1
            break
print(ans)
Buggy code:
N = int(input())
A = input().split(" ")
result = 1
for i in range(N):
  result *= int(A[i])
  if result > 10**18:
    print(-1)
    exit()
print(result)

Fixed code:
N = int(input())
A = input().split(" ")
result = 1
if "0" in A:
  print(0)
  exit()
else:
  for i in range(N):
    result *= int(A[i])
    if result > 10**18:
      print(-1)
      exit()
print(result)
Buggy code:
N = int(input())
A = list(map(int, input().split()))

ans = 1

for i in range(N):
  ans *= A[i]
  if ans == 0:
    break
  elif ans > 10**18:
    ans = -1
    break
print(ans)

Fixed code:
N = int(input())
A = list(map(int, input().split()))
ans = 1

if 0 in A:
  ans = 0
else:
  for i in range(N):
    ans *= A[i]
    if ans > 10**18:
      ans = -1
      break
print(ans)
Buggy code:
N = int(input())

P = list(map(int, input().split()))

out_range = 10**18

ans=1
for i in range(N):
    tmp = P[i]
    if tmp == 0:
        print(0)
        exit()
    ans *= tmp
    if  ans > out_range:
        print(-1)
        exit()

print(ans)


Fixed code:
N = int(input())

P = list(map(int, input().split()))

out_range = 10**18

ans=1
if  0 in P:
    print(0)
    exit()

for i in range(N):
    tmp = P[i]
    ans *= tmp
    if  ans > out_range:
        print(-1)
        exit()

print(ans)
Buggy code:
def main():
    n = int(input())
    As = list(map(int, input().split()))

    ans = 1
    if 0 in As:
        print(0)
        exit()

    for i in range(n):
        ans *= As[i]
        if ans > 10**18:
            ans = -1
        break

    print(ans)


if __name__ == "__main__":
    main()


Fixed code:
def main():
    n = int(input())
    As = list(map(int, input().split()))

    ans = 1
    if 0 in As:
        print(0)
        exit()

    for i in range(n):
        ans *= As[i]
        if ans > 10**18:
            ans = -1
            break

    print(ans)


if __name__ == "__main__":
    main()
Buggy code:
import sys
n = int(input())
arr = list(map(int, input().split()))

ans = 1
for i in arr:
    if i == 0:
        print(0)
        sys.exit()
    ans *= i
    if ans > 10**18:
        print(-1)
        sys.exit()

else:
    print(ans)

Fixed code:
import sys
n = int(input())
arr = list(map(int, input().split()))

if 0 in arr:
    print(0)
    sys.exit()

ans = 1
for i in arr:
    ans *= i
    if ans > 10**18:
        print(-1)
        sys.exit()

else:
    print(ans)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
res = 1
for i in range(n):
    res *= a[i]
    if res > (10**18):
        print(-1)
        exit()
print(res)


Fixed code:
n = int(input())
a = list(map(int, input().split()))
s = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
  s *= a[i]
  if s>10**18:
      print(-1)
      exit()
print(s)
Buggy code:
n = int(input())

l = list(map(int,input().split()))

l.sort(reverse = True)
ans = 1
for i in range(n):
    ans *= l[i]
    if ans > 10**18:
      ans = -1
      break
    elif ans == 0:
      break


print(ans)


Fixed code:
n = int(input())
l = list(map(int,input().split()))

l.sort(reverse = True)
ans = l[-1]
for i in range(n-1):
    ans *= l[i]
    if ans > 10**18:
      ans = -1
      break
    elif ans == 0:
      ans = 0
      break

print(ans)
Buggy code:
n=int(input())
list=[int(i) for i in input().split()]
k=1
list.sort()
x=list[0]
while k<n:
  y=x*list[k]
  x=y
  if y<1000000000000000000:
    k=k+1
  else:
    k=n+1
    y=-1
print(y)

Fixed code:
n=int(input())
list=[int(i) for i in input().split()]
k=1
list.sort()
x=list[0]
while k<n:
  y=x*list[k]
  x=y
  if y<=1000000000000000000:
    k=k+1
  else:
    k=n+1
    y=-1
print(y)
Buggy code:
n = int(input())
a = list(map(int, input().split()))

ans = 1
for i in range(n):
    if ans > 10**18:
        print(-1)
        exit()
    ans *= a[i]

print(ans)


Fixed code:
n = int(input())
a = list(map(int, input().split()))

if 0 in a:
    print(0)
    exit()

limit = 10**18
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > limit:
        print(-1)
        exit()

print(ans)
Buggy code:
num = int(input())

list = list(map(int,input().split()))
list.sort

a = 1

for i in list:
  a *= i
  if a > 10**18:
    a = -1
    break
  
print(a)


Fixed code:
num = int(input())

list = list(map(int,input().split()))
list.sort()

a = 1

for i in list:
  a = a * i
  if a > 10**18:
    a = -1
    break
  
print(a)
Buggy code:
n = int(input())

a = list(map(int,input().split()))

ans = 1
for _ in range(n):
    if ans >= 10 ** 18:
        print(-1)
        exit()
    ans = ans * a[i]

print(ans)

Fixed code:
n = int(input())

a = list(map(int,input().split()))

if 0 in a:
    print(0)
    exit()

ans = 1
for i in range(n):
    ans = ans * a[i]

    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)
Buggy code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(N):
    ans = ans * A[i]
    if ans > 10**18:
        print(-1)
        break
else:
    print(ans)       


Fixed code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        ans = ans * A[i]
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)
Buggy code:
n = int(input())
a = list(map(int, input().split()))

x =1

if min(a) ==0:
    ans =0
else:
    order =0
    for i in a:
        order = order+len(str(i))-1

    if order >=18:
        ans = -1
    else:
        ans =1
        for i in a:
                ans = ans*i
        if ans >10**18:
            ans=-1
print (ans)

Fixed code:
n = int(input())
a = list(map(int, input().split()))

x =1

if min(a) ==0:
    ans =0
else:
    order =0
    for i in a:
        order = order+len(str(i))-1

    if order >18:
        ans = -1
    else:
        ans =1
        for i in a:
                ans = ans*i
        if ans >10**18:
            ans=-1
print (ans)
Buggy code:
n=int(input())
a=list(map(int,input().split()))

def f(x):
  x.sort()
  if x[0]==0:
    return 0

  x.sort(reversed=True)
  
  ans=1
  
  for i in a:
    ans=ans*i

    if ans>10**18:
      return -1
      
    if n==0:
      return ans
  


print(f(a))

Fixed code:
n=int(input())
a=list(map(int,input().split()))

def f(x):
  x.sort()
  if x[0]==0:
    return 0

  x.sort(reverse=True)
  
  ans=1
  
  for i in a:
    ans=ans*i

    if ans>10**18:
      return -1
      
  return ans
  


print(f(a))
Buggy code:
import sys

n = int(input())
a_list = list(map(int,input().split()))

if 0 in a_list:
    print(0)
    sys.exit()
else:
    cul = 1
    for a in a_list:
        cul *= a
        if cul > 10 ** 18:
            print(-1)
            break
    print(cul)


Fixed code:
import sys

n = int(input())
a_list = list(map(int,input().split()))

if 0 in a_list:
    print(0)
    sys.exit()
else:
    cul = 1
    for a in a_list:
        cul *= a
        if cul > 10 ** 18:
            print(-1)
            sys.exit()
    print(cul)
Buggy code:
import sys
#sys.stdin=open('input.txt','r')
#sys.stdout=open('output.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
n=ii1()
arr=iia()
max=10**18
res,flag=1,0
for i in range(n):
    res*=arr[i]
    if res>max:
        flag=1
        break
if flag==1:
    print(-1)
else:
    print(res)

Fixed code:
import sys
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
n=ii1()
arr=iia()
max=10**18
res,flag=1,0
if 0 in arr:
    print(0)
else:
    for i in range(n):
        res*=arr[i]
        if res>max:
            flag=1
            break
    if flag==1:
        print(-1)
    else:
        print(res)
Buggy code:
N = int(input())
A = list(map(int, input().split()))
num = 1
for i in range(0,N):
    if A[i]==0:
      	num=0
      	break
    else:
  		num *= A[i]
  
if num>10**18:
    print(-1)
else:
    print(num)

Fixed code:
N = int(input())
A = list(map(int, input().split()))
num = 1
for i in range(0,N):
    if A[i]==0:
      	num=0
      	break
for i in range(0,N):
    if num>10**18:
        break
    else:
        num *=A[i]
if num>10**18:
    print(-1)
else:
    print(num)
Buggy code:
n = int(input())
a = list(map(int,input().split()))
v = 1
for i in range(n):
  v *= a[i]
  if v>1000000000000000000:
    print(-1)
    exit()
if v > 1000000000000000000:
  print(-1)
else:
  print(v)

Fixed code:
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
  print(0)
  exit()
v = 1
for i in range(n):
  v *= a[i]
  if v>1000000000000000000:
    print(-1)
    exit()
if v > 1000000000000000000:
  print(-1)
else:
  print(v)
Buggy code:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

ans = 1
ma = 1e18

for a in A:
    if a == 0:
        print(0)
        break
    elif a > ma:
        print(-1)
        break
    ans *= a
    if ans > ma:
        print(-1)
        break
else:
    print(ans)

Fixed code:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

ans = 1
ma = 1e18


if 0 in A:
    print(0)
else:
    for a in A:
        ans *= a
        if ans > ma:
            print(-1)
            break
    else:
        print(ans)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
for i in range(n):
    ans*=a[i]
    if ans>10**18:
        print(-1)
        break
else:
    print(ans)

Fixed code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=1
for i in range(n):
    ans*=a[i]
    if ans>10**18:
        print(-1)
        break
else:
    print(ans)
Buggy code:
n = int(input())
a = map(int, input().split())

ans = 1

for x in a:
    ans *= x
    if ans > 1000000000000000000:
        break

if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)


Fixed code:
n = int(input())
a = map(int, input().split())

ans = 1

for x in a:
    ans *= x
    if ans > 1000000000000000000:
        break

for x in a:
    if x == 0:
        ans = x

if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)
Buggy code:
N = int(input())
A = map(int,input().split())
ret = 1
if 0 in A:
    print(0)
    exit()
for i in A:
    ret *= i
    if ret > 10**18:
        ret = -1
        break
print(ret)


Fixed code:
N = int(input())
A = list(map(int,input().split()))
ret = 1
if 0 in A:
    print(0)
    exit()

for i in A:
    ret *= i
    if ret > 10**18:
        ret = -1
        break
print(ret)
Buggy code:
N = int(input())
A = list(map(int,input().split()))
list.sort(A)
ans = 1
for a in A:
    ans *= a
    if ans > 1e18:
        ans = -1
        exit()
print(ans)


Fixed code:
N = int(input())
A = list(map(int,input().split()))
list.sort(A)
ans = 1
for a in A:
    ans *= a
    if ans > 1e18:
        print(-1)
        exit()
print(ans)
Buggy code:
import sys
def input():
    return sys.stdin.readline().strip()

def main():
    n = int(input())
    A = list(map(int, input().split()))
    x = 1
    for i in A:
        x *= i
        if x > pow(10,18):
            print(-1)
            return
    print(x)

main()

Fixed code:
import sys
def input():
    return sys.stdin.readline().strip()

def main():
    n = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        print(0)
        return
    x = 1
    for i in A:
        x *= i
        if x > pow(10,18):
            print(-1)
            return
    print(x)

main()
Buggy code:
N, A = map(int, open(0).read().split())
if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        break
else:
    print(ans)


Fixed code:
N, *A = map(int, open(0).read().split())
if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        break
else:
    print(ans)
Buggy code:
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
        print(-1):
            return
    print(prod)
main ()


Fixed code:
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main ()
Buggy code:
n = input()
lines = input()
line = [int(i) for i in lines.split(' ')]
sum = 1
for i in line:
  if sum > 1.0 * 10^18:
    sum = -1
    break
   else:
    sum = sum * i
print(sum)


Fixed code:
n = input()
lines = input()
lines = [int(i) for i in lines.split(' ')]
sum = 1
if 0 in lines:
	print(0)
else:
	for i in lines:
		sum = sum * i
		if sum > 10**18:
			sum = -1
			break
	print(sum)
Buggy code:
N=int(input())
A=[map(int,input().split())]
sorted(A)
if A[0] == 0:
  print(0)
  exit(0)

ans = 1
for i in range(N):
  ans*=A[i]
  if(ans>1000000000000000000):
    print(-1)
    exit(0)
print(ans)

Fixed code:
N=int(input())
A=list(map(int, input().split()))
A=sorted(A)
if A[0] == 0:
  print(0)
  exit(0)

ans = 1
for i in range(N):
  ans*=A[i]
  if(ans>1000000000000000000):
    print(-1)
    exit(0)
print(ans)
Buggy code:
import sys
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
  ans *= a[i]
  if(ans > 10**18):
    print(-1)
    sys.exit(0)

print(ans)

Fixed code:
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))

ans = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()
else:
    print(ans)
Buggy code:
n = int(input())

a = list(int(i) for i in input().split(" "))

prod = 1

for i in a:
  prod *= i
  if prod > (10 ** 18):
  	prod = -1
    break


print(prod)


Fixed code:
n = int(input())

a = list(int(i) for i in input().split(" "))

prod = 1

if 0 in a:
  prod = 0
else:
  for i in a:
    prod *= i
    if prod > (10 ** 18):
      prod = -1
      break


print(prod)
Buggy code:
def b169(n, alist):

    ans = 1
    for i in alist:
        ans *= i
        if ans > 10**18:
            return -1

    return ans

def main():
    n = int(input())
    alist = list(map(int, input().split()))
    print(b169(n, alist))

if __name__ == '__main__':
    main()

Fixed code:
def b169(n, alist):

    ans = 1
    for i in alist:
        if i == 0:
            return 0

    for i in alist:
        ans *= i
        if ans > 10**18:
            return -1

    return ans

def main():
    n = int(input())
    alist = list(map(int, input().split()))
    print(b169(n, alist))

if __name__ == '__main__':
    main()
Buggy code:
import sys
n = int(input())
a = list(map(int,input().split()))
f = False;
for i in range(n):
  if a[i] == 0:
    f = True
if f:
  print(n)
  sys.exit(0)
ans = 1
for i in range(n):
  ans *= a[i]
  if ans > 1e18:
    print(-1)
    sys.exit(0)
print(ans)

Fixed code:
import sys
n = int(input())
a = list(map(int,input().split()))
f = False;
for i in range(n):
  if a[i] == 0:
    f = True
if f:
  print(0)
  sys.exit(0)
ans = 1
for i in range(n):
  ans *= a[i]
  if ans > 1e18:
    print(-1)
    sys.exit(0)
print(ans)
Buggy code:
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))
b = np.sqrt(a)

lim = 10**9
ans_1 = np.prod(b)
ans = np.prod(a)

if ans_1 > lim:
  ans = -1
elif ans_1 < 0:
  ans = -1
    
print(ans)

Fixed code:
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))
b = np.sqrt(a)

lim = 10**9
lim_1 = 10**18
ans_1 = np.prod(b)
ans = np.prod(a)

if ans_1 > lim:
  ans = -1
elif ans_1 < 0:
  ans = -1
    
if ans > lim_1:
  ans = -1
elif ans < 0:
  ans = -1
  
print(ans)
Buggy code:
N = int(input())
A = map(int, input().split())

ans = 1
if 0 in A:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > 10**18:
            ans = -1
            break

print(ans)


Fixed code:
N = int(input())
A = list(map(int, input().split()))

ans = 1
if 0 in A:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > 10**18:
            ans = -1
            break

print(ans)
Buggy code:
N = int(input())
A = list(map(int, input().split()))

ans = 1
max_limit = 10 ** 18
for i in range(N):
  ans *= A[i]
  if ans > max_limit:
    ans = -1
    break

print(str(ans))

Fixed code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 1
max_limit = 10 ** 18
for i in range(N):
  ans *= A[i]
  if ans > max_limit:
    ans = -1
    break

if ans > max_limit:
  print(str(-1))
else:
  print(str(ans))
Buggy code:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    if 0 in a:
        print(0)
        return
    ans=1
    for i in a:
        pro=pro*i
        if pro>1000000000000000000:
            print(-1)
            return    
    print(ans)
    return
main()            

Fixed code:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    if 0 in a:
        print(0)
        return
    ans=1
    for i in a:
        ans=ans*i
        if ans>1000000000000000000:
            print(-1)
            return    
    print(ans)
    return
main()
Buggy code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(N):
  ans  *= A[i]
  if ans > 10**18:
    ans = -1
    break
print(ans)
  

Fixed code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(N):
  ans  *= A[i]
  if ans > 10**18:
      if not 0 in A:
          ans = -1
          break
      else:
          ans = 0
          break
print(ans)
Buggy code:
n = int(input())

a = set(map(int, input().split()))

result = 1
if 0 in a:
    result = 0
else:
    for i in a:
        result = result * i
        if result > 10**18:
            result = -1
            break
        

print(result)

Fixed code:
n = int(input())

a = list(map(int, input().split()))

result = 1
if 0 in a:
    result = 0
else:
    for i in a:
        result = result * i
        if result > 10**18:
            result = -1
            break
        

print(result)
Buggy code:
import sys
input()
A = list(map(int, input().split()))
ans = 1

if 0 in A:
    print(0)
    sys.exit()

else
    for a in map(int, input().split()):
        ans *= a
        if ans > 10**18
        print(-1)
        sys.exit()
    print(ans)

Fixed code:
import sys
input()
A = list(map(int, input().split()))
ans = 1

if 0 in A:
    print(0)
    sys.exit()

else:
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            sys.exit()
    print(ans)
Buggy code:
N = int(input())
A = list(input().split())
for i in range(N):
    A[i] = int(A[i])
sum = 1

for i in range(N):
    if sum <= 10**18:
        sum = sum * A[i]
    else:
        break:

if sum <= 10**18:
    print(sum)
else:
    print(-1)

Fixed code:
N = int(input())
A = list(input().split())
flag = 0
for i in range(N):
    A[i] = int(A[i])
    if A[i] == 0:
        flag = -1
sum = 1

for i in range(N):
    if sum <= 10**18:
        sum = sum * A[i]
    else:
        break


if sum <= 10**18:
    print(sum)
else:
    if flag == -1:
        print(0)
    else:
        print(-1)