qyliang/CodeNanoFix huggingface dataset:
Buggy code:
#!/usr/bin/env python3


LIMIT = 10 ** 18


def prod(xs):
    res = 1
    for x in xs:
        res *= x
        if res > LIMIT:
            return None
    return res


def main():
    n = int(input())
    bs = [int(z) for z in input().split()]
    res = prod(bs)
    if res is None:
        print(-1)
    else:
        print(res)


if __name__ == '__main__':
    main()

Fixed code:
#!/usr/bin/env python3


LIMIT = 10 ** 18


def prod(xs):
    xs.sort()
    res = 1
    if 0 in xs:
        return 0
    for x in xs:
        res *= x
        if res > LIMIT:
            return None
    return res


def main():
    n = int(input())
    bs = [int(z) for z in input().split()]
    res = prod(bs)
    if res is None:
        print(-1)
    else:
        print(res)


if __name__ == '__main__':
    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:
        print(-1)
        exit(0)
print(ans)


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

result = 1
for i in range(len(a)):
  result = result*a[i]
  if result == 0 or result > 1000000000000000000:
    break

if result <= 1000000000000000000:
  print(result)
else:
  print(-1)

Fixed code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
result = 1
for i in range(len(a)):
  result = result*a[i]
  if result == 0:
    break
  elif result > 1000000000000000000:
    break

if result <= 1000000000000000000:
  print(result)
else:
  print(-1)
Buggy code:
n = int(input())
a = list(map(int,input.split()))
a = sorted(a)
prod = 1
for x in a:
  prod *= x
  if prod > 10**18:
    prod = -1
    break
print(prod)

Fixed code:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
prod = 1
for x in a:
	prod *= x
	if prod > 10**18:
		prod = -1
		break
print(prod)
Buggy code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        exit()
print(ans)


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

if 0 in A:
  print (0)
  exit()
ans = 1
for a in A:
  ans *= a
  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 *= A[i]
    if ans > 10 ** 18:
        ans = -1
        break

print(ans)

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

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

    print(ans)
Buggy code:
n = int(input())
arr = map(int, input().split())
arr.sort()

ans = 1
for x in arr:
	ans *= x
    if ans > 10**18:
    	ans = 10**19

if ans == 10**19:
  print(-1)
else:
  print(ans)

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

ans = 1
for x in arr:
    ans *= x
    if ans > 10**18:
        ans = 10**19

if ans == 10**19:
  print(-1)
else:
  print(ans)
Buggy code:
n=int(input())
a=list(map(int, input().split()))

ans=1
i=0
while ans<=10**18:
    ans*=a[i]
    i+=1
    
if ans>10**18:
    print("-1")
else:
    print(ans)

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


if 0 in a:
    print(0)
else:
    ans=1
    i=0
    while ans<=10**18 and i<n:
        ans*=a[i]
        i+=1

    if ans>10**18:
        print("-1")
    else:
        print(ans)
Buggy code:
N = int(input())
A = list(map(int, input().split()))
MAX = 10**18

ans = 1
for i in range(N):
    ans = ans*A[i]
    if ans > MAX:
        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:
        ans = -1
        break
if 0 in A:
    ans = 0
print(ans)
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):
        print(-1)
        exit()
print(ans)

Fixed code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(N):
    if(A[i]==0):
        print(0)
        exit()
for i in range(N):
    ans *= A[i]
    if(ans > 10**18):
        print(-1)
        exit()
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 > pow(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 > pow(10, 18):
            ans = -1
            break
print(ans)
Buggy code:
import sys
N = int(input())
A = list(map(int,input().split()))

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

if res > 10**18:
    print(-1)
else:
    print(res)

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

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

if res > 10**18:
    print(-1)
else:
    print(res)
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:
        print(-1)
        exit()
        
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 *= 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 aa in a:
  ans *= aa
  if(ans > 1000000000000000000):
    ans = -1
    break

print(ans)

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

ans = 1
for aa in a:
  if aa == 0:
    ans = 0
    break

for aa in a:
  ans *= aa
  if(ans > 1000000000000000000):
    ans = -1
    break

print(ans)
Buggy code:
n=input()
l=list(map(int,input().split()))
p=1;t=0
for i in l:
    if(p*i > 10**18):
        t=1
        break
    p=p*i
if(t):
    print(-1)
else:
    print(p)

Fixed code:
n=input()
l=list(map(int,input().split()))
p=1;t=0
if 0 in l:
  print(0)
else:
    for i in l:
        if( p*i > 10**18 ):
        	t=1
        	break
        p=p*i
    if(t):
    	print(-1)
    else:
    	print(p)
Buggy code:
N=int(input())
AS = list(map(int,input().split()))
if 0 in AS:
  print(0)
  exit()
s = 0
sum = 1
l=len(AS)
for i in range(l):
  A=AS[i]
  if A==0:
    s=1
    break
  sum = sum * A
  if sum > 10**18:
    s=2
    break
if s==1:
  print(0)
elif s==2:
  print(-1)
else:
  if sum > 10**18:
    print(-1)
  else:
    print(sum)
print(s)

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

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


Fixed code:
n = int(input())
a = [int(i) for i in input().split(' ')]
a = sorted(a)
if a[0] == 0:
    print(0)
else:
    x = 1
    for i in a:
        x = x * i
        if x > 10**18:
            print(-1)
            break
    else:
        print(x)
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:
    ans = -1
    break

print(ans)

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

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



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

ans = 1

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

if ans == 0:
    print(ans)
else:
    for x in arr:
        ans *= x
        if ans > 1000000000000000000:
            break
    if ans > 1000000000000000000:
        print(-1)
    else:
        print(ans)
Buggy code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()

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

Fixed code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
if 0 in a:
    print(0)
    quit()
ans = 1
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        quit()
print(ans)
Buggy code:
N = input()
A = [a for a in input().split()]

ans = 1

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

print(ans)

Fixed code:
N = input()
A = [int(a) for a in input().split()]

ans = 1

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

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


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

Fixed code:
n=int(input())
arr=list(map(int,input().split()))
ans=int(1)
temp=int(0)
for i in range(n):
  if(ans>(10**18)):
    ans=-1
  if(ans!=-1):
  	ans*=arr[i]
  if(arr[i]==0):
    temp=int(1)
if(ans>(10**18)):
  ans=-1
if(temp==1):
  ans=0
print(int(ans))
Buggy code:
from functools import reduce
from operator import mul
l = int(input())
x = list(map(int, input().split()))
# print(x)
# result = reduce(mul, x)
result = 1
limit = 10 ** 18
for i in x:
  if result < limit and i != 0:
    result = result * i
if limit < result:
  result = -1
print(result)


Fixed code:
from functools import reduce
from operator import mul
l = int(input())
x = list(map(int, input().split()))
# print(x)
# result = reduce(mul, x)
result = 1
limit = 10 ** 18
for i in x:
  if result < limit or i == 0:
    result = result * i
if limit < result:
  result = -1
print(result)
Buggy code:
N = int(input())
A = list(map(int, input().split()))

sums=1
for i in A:
    sums=sums*i
    if sums>1000000000000000000:
        sums=-1
        break
    
if sums==-1:
    print(-1)
else:
    print(sums)

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

sums=1
for i in A:
    sums=sums*i
    if sums>1000000000000000000:
        sums=-1
        break
    
if 0 in A:
    print(0)
else:
    print(sums)
Buggy code:
import sys

N = int(input())
A = list(map(int, input().split()))
a = 1

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

for i in range(N):
    a = a*A[i]
        if a > 10**18 :
        print(-1)    
        sys.exit()

else : print(a)



Fixed code:
import sys

N = int(input())
A = list(map(int, input().split()))
a = 1

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

for i in range(N):
    a = a*A[i]
    if a > 10**18 :
        print(-1)    
        sys.exit()

else : print(a)
Buggy code:
def f(A):
    x = 1

    for a in A:
        x *= a
        if x > 10**18:
            return -1

    return x

N = int(input())
A = list(map(int, input().split()))
print(f(A))



Fixed code:
def f(A):
    if 0 in A:
        return 0

    x = 1

    for a in A:
        x *= a
        if x > 10**18:
            return -1

    return x

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

n = int(input())
A = map(int,input().split())
 
ans = 1
for num in A:
    ans*=num
    if (ans >= 10**18):
        ans = -1
        break
 
print(ans)

Fixed code:
n = int(input())
A = map(int,input().split())
 
ans = 1
for num in A:
    ans*=num
    if (ans > 10**18):
        ans = -1
        break
if (0 in A):
    ans = 0;
print(ans)
Buggy code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in A:
    ans *= 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
for i in A:
    ans *= i
    if ans > 10**18:
        ans = -1
        break
print(ans)
Buggy code:
n = int(input())
l = map(int, input().split())
ans = 1
for a in l:
    if ans * a > 1e18:
        ans = -1
    elif ans != -1:
        ans *= a

print(ans)

Fixed code:
n = int(input())
l = map(int, input().split())
ans = 1
for a in l:
    if ans * a > 1e18:
        ans = -1
    elif ans != -1 or a == 0:
        ans *= a

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

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

ans = 1

for item in A:
    ans *= item

    ans = min(ans, 10**18)

if ans == 10**18:
    print(-1)
    exit()

print(ans)

Fixed code:
N = int(input())

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

ans = 1

for item in A:
    ans *= item

    ans = min(ans, 10**18 + 1)

if ans == 10**18 + 1:
    print(-1)
    exit()

print(ans)
Buggy code:
n = int(input())
mx = 10**18
a = list(map(int, input().split()))
for x in a:
    if x == 0:
        print(0)
        exit(0)
ans = 1
for x in a:
    ans *= a
    if ans > mx:
        print(-1)
        exit(0)
print(ans)

Fixed code:
n = int(input())
mx = 10**18
a = list(map(int, input().split()))
for x in a:
    if x == 0:
        print(0)
        exit(0)
ans = 1
for x in a:
    ans *= x
    if ans > mx:
        print(-1)
        exit(0)
print(ans)
Buggy code:
def main():
N=int(input())
A=list(map(int,input().split()))
if A is 0:
  print(0)
  return
p=1
for i in A:
  p=p*i
  if p>1000000000000000000:
    print(-1)
    return
print(p)  
main()  
  


Fixed code:
def main():
    N=int(input())
    A=list(map(int,input().split()))
    if 0 in A:
      print('0')
      return
    p=1
    for i in A:
      p=p*i
      if p>1000000000000000000:
        print(-1)
        return
    print(p)    
main()
Buggy code:
MAX = 10**18
def main():
    N = map(int,input())
    A = list(map(int,input().split(' ')))
    ans = 1
    for a in A:
        if ans > MAX:
            print(-1)
            exit(0)
        if ans == 0:
            print(0)
            exit(0)
        ans *= a

    print(ans)

if __name__ == "__main__":
    main()


Fixed code:
MAX = 10**18
def main():
    N = map(int,input())
    A = list(map(int,input().split(' ')))
    ans = 1
    if 0 in A:
        print(0)
        exit(0)
    for a in A:
        ans *= a
        if ans > MAX:
            print(-1)
            exit(0)

    print(ans)

if __name__ == "__main__":
    main()
Buggy code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
big = 10**18
for a in A:
  ans *= a
  if ans > big:
    ans = -1
    break

print(ans)

Fixed code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
big = 10**18
for a in A:
  if a == 0:
    ans = 0
    break
  if ans == -1:
    continue
  ans *= a
  if ans > big:
    ans = -1

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

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

def solve():
  n=int(input())
  a=list(map(int,input().split()))
  if 0 in a:
    print(0)
  f=1  
  for i in a:
    f*=i
    if f>100000000000000000:
      print(-1)
      return 
  print(f)
solve()  
    

Fixed code:
def solve():
    n=int(input())
    a=list(map(int,input().split()))
    f=1
    if 0 in a:
        f=0
    for i in a:
        f*=i
        if f>1000000000000000000:
            print(-1)
            return 
    print(f)
solve()
Buggy code:
N = int(input())
A = list(map(int, input().split()))
MAX = 10 ** 18

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

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

if flag == 1:
  print(-1)
else:
  print(ans)

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

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

if flag == 1:
    print(-1)
elif flag == -1:
    print(0)
else:
    print(ans)
Buggy code:
N=int(input())
a=input().split()
A=[int(b) for b in a]
answer=1
for a in A:
    answer*=a
    if answer>pow(10,18):
        answer=-1
        break
print(answer)


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

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

if 0 in A:
  s=0
else:
  for a in A:
    s*=a
    if s>10**18:
      s=-1
      break
print(s)
Buggy code:

N=int(input(""))

ar=[]
total=1
big=False
lion = False
A=N-1
ar = list(map(int, input().strip().split(' ')))
      
while big == False and lion == False:
      for i in range (0,N):
            total=ar[i]*total
            if i == A:
                  lion = True
            if total>(1000000000000000000):
                  big=True
                  lion=True
                  break

if big == False and lion == True:
      print(total)

if big == True and lion == True:
      print("-1")

Fixed code:
N=int(input(""))

ar=[]
total=1
big=False
lion = False
A=N-1
ar = list(map(int, input().strip().split(' ')))

if 0 in ar:
      print("0")
      big=True
      lion=False
      
while big == False and lion == False:
      for i in range (0,N):
            total=ar[i]*total
            if i == A:
                  lion = True
            if total>(1000000000000000000):
                  big=True
                  lion=True
                  break

if big == False and lion == True:
      print(total)

if big == True and lion == True:
      print("-1")
Buggy code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in A:
  ans *= i
  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:
  print(0)
  exit()
for i in A:
  ans *= i
  if ans > 10**18:
    ans = -1
    break
print(ans)
Buggy code:
N=int(input())
A=list(map(int,input().split()))
c=1
for i in range(N):
  c=c*A[i]
  if c>10**18:
    c=-1
    break
    
print(c)

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


Fixed code:
n=int(input())
a=list(map(int,input().split()))
ans=1
su=0
count=0
for j in a:
    if j==0:
        su+=1
        break
if su>0:
    print(0)
else:
    for i in a:
        ans*=i
        if ans>1000000000000000000:
            print(-1)
            count+=1
            break
    if count!=1:
        if ans>1000000000000000000:
            print(-1)
        else:
            print(ans)
Buggy code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = [int(v) for v in input().split()]

    over = False
    ans = 1
    for a in A:
        ans *= a
        if ans > 1e18:
            over = True
            break
    
    if over:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    main()

Fixed code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = sorted([int(v) for v in input().split()])

    over = False
    ans = 1
    for a in A:
        ans *= a
        if ans > 1e18:
            over = True
            break
    
    if over:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    main()
Buggy code:
ans = 1
n = int(input())
arr = list(map(int , input().split()))
f  = 1
for i in range(n):
	ans*=arr[i]
	if ans > 10**18:
		f = 0
		break

if f: print(ans)
else: print(-1)

Fixed code:
ans = 1
n = int(input())
arr = sorted(list(map(int , input().split())))
f  = 1
for i in range(n):
	ans*=arr[i]
	#print(ans)
	if ans > 10**18:
		f = 0
		break
#print(ans)
if f: print(ans)
else: print(-1)
Buggy code:
n = int(raw_input())
lst = list(map(int, raw_input().strip().split()))[:n]
mx = 1000000000000000000
if 0 in lst:
    print(0)
else:
    cur = lst[0]
    for x in lst[1:]:
        cur = cur * x
        if cur > mx:
            cur = -1
            break
    print(cur)


Fixed code:
n = int(input())
lst = list(map(int, input().strip().split()))[:n]
mx = 1000000000000000000
if 0 in lst:
    print(0)
else:
    cur = lst[0]
    for x in lst[1:]:
        cur = cur * x
        if cur > mx:
            cur = -1
            break
    print(cur)
Buggy code:
n = int(input())
ans = 1
for a in list(map(int, input().split())):
    if ans * a > 10**18:
        print(-1)
        exit()
    else:
        ans *= a
print(ans)

Fixed code:
n = int(input())
ans = 1
arr = sorted(list(map(int, input().split())))
for a in arr:
    if ans * a > 10**18:
        print(-1)
        exit()
    else:
        ans *= a
print(ans)
Buggy code:
n = int(input())
ans = 1
arr = [int(x) for x in input().split()]
for each in arr:
    ans *= each
    if (ans > 1e18):
        print(-1)
        exit(0)
print(ans)


Fixed code:
n = int(input())
ans = 1
arr = [int(x) for x in input().split()]
arr.sort()
for each in arr:
    ans *= each
    if (ans > 1e18):
        print(-1)
        exit(0)
print(ans)
Buggy code:
##169

##B
N = int(input())
A = list(map(int,input().split()))
ans = 1
i=0
if 0 in A:
  print(0)
else:
  while N > i:
    if ans <= 10**18:
        ans *= A[i]
        i += 1
    else:
        ans = -1
        break
  print(ans)

Fixed code:
##169

##B
N = int(input())
A = list(map(int,input().split()))
ans = 1
i=0
if 0 in A:
  print(0)
else:
  while N > i:
    if ans <= 10**18:
        ans *= A[i]
        i += 1
    else:
        ans = -1
        break
  
  if ans > 10**18:
        print(-1)
  else:
    print(ans)