alexjercan/bugnet huggingface dataset:
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
# = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
answer = A[0]

if A.count(0) > 0:
    print(0)
    exit()

for i in range(1, N):
    answer = answer * A[i]
    if answer > 10**18:
        print(-1)
        exit()
else:
    print(answer)


Error: TLE

Fixed submission:

N = int(input())
# = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
answer = A[0]

for i in range(1, N):
    answer *= A[i]

if answer > 10**18:
    print(-1)
else:
    print(answer)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys

n = int(input())
a = list(map(int, input().split()))
ans = 1
flag = True
if 0 in a:
    print(0)
    sys.exit()

for i in a:
    ans *= i
    if ans > 1000000000000000000:
        flag = False
        break

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


Error: TLE

Fixed submission:

n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
    ans *= i

if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

num = int(input())

k = input().split()

for i in range(len(k)):
    k[i] = int(k[i])

k.sort()

mul = 1

for i in range(num):
    mul *= int(k[i])
    if mul > 10**18:
        break

if mul > 10**18:
    print(-1)

else:
    print(mul)


Error: TLE

Fixed submission:

num = int(input())

k = input().split()

mul = 1

for i in range(num):
    mul *= int(k[i])

if mul > 10**18:
    print(-1)

else:
    print(mul)
Problem p02658 (Python) — buggy submission, verdict: Runtime Error

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


Error: TypeError: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02658/Python/s150876238.py", line 6, in <module>
    ans = ans * li[i]
TypeError: 'NoneType' object is not subscriptable


Fixed submission:

n = int(input())
mod = 10**18
li = list(map(int, input().split())).sort()
ans = 1
for i in range(n):
    ans = ans * li[i]
    if ans > mod:
        ans = -1
        break
print(ans)
Problem p02658 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
A = list(map(int, input().split()))
result = 1
flag = 0
zero_flag = 0
for a in A:
    if a == 0:
        zero_flag = 1
        result = 0
        break
    else:
        result = result * a
        if result > pow(10, 18):
            flag = 1
            result = 0
if flag == 1 and zero_flag != 1:
    print(-1)
else:
    print(result)


Error: 0

Fixed submission:

N = int(input())
A = list(map(int, input().split()))
result = 1
flag = 0
for a in A:
    if a == 0:
        zero_flag = 1
        result = 0
        break
    else:
        result = result * a
        if result > pow(10, 18):
            flag = 1
            result = 0
if flag == 1 and zero_flag != 1:
    print(-1)
else:
    print(result)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

def main():
    if A.count(0) >= 1:
        print(0)
        return
    ans = 1
    for a in A:
        ans *= a
        if ans > L:
            print(-1)
            return
    print(ans)


if __name__ == "__main__":
    N = int(input())
    A = [int(a) for a in input().split()]
    L = 10**18
    main()


Error: TLE

Fixed submission:

def main():
    ans = 1
    for a in A:
        ans *= a
    if ans > L:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    N = int(input())
    A = [int(a) for a in input().split()]
    L = 10**18
    main()
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
an = list(map(int, input().split()))
ans = 1
if 0 in an:
    ans = 0
else:
    for a in an:
        ans *= a
        if ans > 10**18:
            ans = -1
            break
print(ans)


Error: TLE

Fixed submission:

N = int(input())
an = list(map(int, input().split()))
ans = 1
for a in an:
    if 0 in an:
        ans = 0
        break
    ans *= a
    if ans > 10**18:
        ans = -1
        break
print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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)


Error: TLE

Fixed submission:

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

ans = 1

for a in A:
    ans *= a
if ans > pow(10, 18):
    ans = -1
print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
ret = 1
a = sorted(list(map(int, input().split())))
for ai in a:
    ret *= ai
    if ret > 1000000000000000000:
        print(-1)
        exit(0)
print(ret)


Error: TLE

Fixed submission:

n = int(input())
ret = 1
a = list(map(int, input().split()))
for ai in a:
    ret *= ai
if ret > 1000000000000000000:
    print(-1)
else:
    print(ret)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

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

ans = 1
a_li = [a for a in a_li if a != 1 and a != 0]
a_li.append(1)
for a in a_li:
    ans *= a
    if ans > 1000000000000000000:
        print(-1)
        exit()
print(ans)


Error: TLE

Fixed submission:

from functools import reduce
from operator import mul

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

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

a_li = [a for a in a_li if a != 1 and a != 0]
a_li.append(1)
ans = reduce(mul, a_li)

if ans > 1000000000000000000:
    print(-1)
    exit()
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

A.sort()

sum = 1
for i in A:
    sum *= i
    if sum > 10**18:
        sum = -1
        break

ans = sum

print(ans)


Error: TLE

Fixed submission:

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

sum = 1
for i in A:
    sum *= i

ans = -1

if sum <= 10**18:
    ans = sum

print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

# print(A)

A.sort()
# print(A)

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

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


Error: TLE

Fixed submission:

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

mul = 1
for i in range(N):
    mul *= A[i]

if mul > 10**18:
    print("-1")

else:
    print(mul)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
A = list(map(int, input().split()))
ans = 1
flag = 0
zeroflag = 0
for a in A:
    if a == 0:
        print(0)
        exit()
for a in A:
    ans *= a
    if ans > pow(10, 18):
        print(-1)
        exit()
print(ans)


Error: TLE

Fixed submission:

n = int(input())
A = list(map(int, input().split()))
ans = 1
flag = 0
zeroflag = 0
for a in A:
    ans *= a
    if ans > pow(10, 18):
        flag = 1
    if a == 0:
        zeroflag = 1
if flag:
    ans = -1
if zeroflag:
    ans = 0
print(ans if ans <= pow(10, 18) else -1)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

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


Error: TLE

Fixed submission:

# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

ans = 1
for i in range(n):
    ans *= a[i]
if ans > pow(10, 18):
    print(-1)
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

import collections
import sys


def pow2(x, n):
    ret = 1
    while n > 0:
        if n & 1:
            ret *= x
        x *= x
        n = n >> 1
    return ret


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

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

c = collections.Counter(a)

l = sorted(list(c.keys()))

ans = 1
for num in l:
    ans *= pow2(num, c[num])
    if ans > 1000000000000000000:
        print(-1)
        sys.exit(0)
print(ans)


Error: TLE

Fixed submission:

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

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

ans = 1
for num in a:
    ans = ans * num

if ans > 10**18:
    print(-1)
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

t = int(input())
arr = [int(x) for x in input().split()]
n = 1
flag = True
if 0 in arr:
    print(0)
else:
    for i in range(t):
        n *= arr[i]
        if n > 10**18:
            flag = False
            break
    if flag:
        print(n)
    else:
        print(-1)


Error: TLE

Fixed submission:

t = int(input())
arr = [int(x) for x in input().split()]
n = 1
flag = True
for i in range(t):
    n *= arr[i]
    if n > 10**18:
        flag = False
    else:
        flag = True
if flag:
    print(n)
else:
    print(-1)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())

a = [*map(int, input().split())]
for e in a:
    if e == 0:
        print(0)
        exit(0)

ans = 1
for e in a:
    ans *= e
    if ans > 10**18:
        print(-1)
        exit(0)

print(ans)


Error: TLE

Fixed submission:

n = int(input())

ans = 1

for e in map(int, input().split()):
    ans *= e

if ans > 10**18:
    print(-1)
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys

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

ans = 1

for a in A:
    if a == 0:
        print(0)
        sys.exit()

for a in sorted(A, reverse=True):
    ans *= a
    if 10**18 < ans:
        print(-1)
        sys.exit()


print(ans)


Error: TLE

Fixed submission:

import sys

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

ans = 1


for a in A:
    if a == 0:
        print(0)
        sys.exit()
    ans *= a

if 10**18 < ans:
    print(-1)
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
A = input().split()
S = 1
if "0" in A:
    print(0)
else:
    for i in range(N):
        S *= int(A[i])
        if S > 10**18:
            break
    if S > 10**18:
        print(-1)
    else:
        print(S)


Error: TLE

Fixed submission:

N = int(input())
A = input().split()
i = 0
S = 1
for i in range(N):
    S *= int(A[i])
if S > 10**18:
    print(-1)
else:
    print(S)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

ans = 1
flag = 0
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        flag = 1
        break

if flag == 1 and (0 not in a):
    ans = -1
if 0 in a:
    ans = 0

print(ans)


Error: TLE

Fixed submission:

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

ans = 1
flag = 0
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        flag = 1

if flag == 1 and ans != 0:
    ans = -1

print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

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

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

print(ans)


Error: TLE

Fixed submission:

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

ans = 1
for i in a:
    ans *= i

if ans > 10**18:
    print(-1)
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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)


Error: TLE

Fixed submission:

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
print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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()
print(ans)


Error: TLE

Fixed submission:

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)
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

ans = 1

a.sort(reverse=True)

if 0 not in a:
    for x in range(n):
        ans *= a[x]

        if ans > 10**18:
            ans = -1
            break
else:
    ans = 0

print(ans)


Error: TLE

Fixed submission:

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

ans = 1

for x in range(n):
    if 0 in a:
        ans = 0
        break

    ans *= a[x]

    if ans > 10**18:
        ans = -1
        break


print(ans)
Problem p02658 (Python) — buggy submission, verdict: Runtime Error

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

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


Error: TypeError: 'list' object cannot be interpreted as an integer
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02658/Python/s912887919.py", line 8, in <module>
    for i in range(A):
TypeError: 'list' object cannot be interpreted as an integer


Fixed submission:

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

if 0 in A:
    print(0)
else:
    ans = 1
    for i in range(A):
        ans += A[i]
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

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

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


Error: TLE

Fixed submission:

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

ans = A[0]
for i in range(1, N):
    ans *= A[i]
if ans > 10**18:
    print(-1)
    exit()
print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys
import numpy as np

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

if len(np.where(np.array(A) == 0)[0]) != 0:
    print(0)
    sys.exit(0)

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

print(ans)


Error: TLE

Fixed submission:

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

ans = 1
for a in A:
    ans *= a

if ans > 10**18:
    print(-1)
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())

ans = 1
flag = True
a = list(map(int, input().split()))

a.sort()

if a[0] == 0:
    print(0)
    exit(0)

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

print(ans)


Error: TLE

Fixed submission:

n = int(input())

ans = 1
flag = True
a = list(map(int, input().split()))
for i in a:
    ans *= i
    if ans > 1000000000000000000:
        flag = False

if ans == 0:
    flag = True

if flag:
    print(ans)
else:
    print(-1)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
A = [int(x) for x in input().split()]
if 0 in A:
    print(0)
    exit()
ans = 1
for x in A:
    ans *= x
    if ans > 10**18:
        print(-1)
        exit()
print(ans)


Error: TLE

Fixed submission:

N = int(input())
A = [int(x) for x in input().split()]
ans = 1
for x in A:
    ans *= x
if ans > 10**18:
    print(-1)
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

n = int(readline())
a = list(map(int, readline().split()))

t = 1

for i in range(n):
    if a[i] == 0:
        print("0")
        exit()

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

print(t)


Error: TLE

Fixed submission:

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

n = int(readline())
a = list(map(int, readline().split()))

t = 1

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

if t > 10**18:
    print("-1")
else:
    print(t)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

x = 1
for i in a:
    x *= i
    if x > 10**18:
        break

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


Error: TLE

Fixed submission:

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

x = 1
for i in a:
    x *= i

ans = x
if ans > 10**18:
    ans = -1
print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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


Error: TLE

Fixed submission:

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)
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

product = 1
flag = 0

if 0 in A:
    print(0)
else:
    for i in range(N):
        product *= A[i]
        if product > 1000000000000000000:
            flag += 1
            break
    if flag == 0:
        print(product)
    else:
        print(-1)


Error: TLE

Fixed submission:

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

product = 1

for i in range(N):
    product *= A[i]

if product > 1000000000000000000:
    print(-1)
else:
    print(product)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

res = 1

A = int(input())
N = sorted([int(x) for x in input().split()])

for x in N:
    res *= x
    if res > pow(10, 18):
        res = -1
        break

print(res)


Error: TLE

Fixed submission:

from functools import reduce

A = int(input())
lst = [int(x) for x in input().split()]
res = reduce(lambda a, b: a * b, lst)
print(res if res <= pow(10, 18) else -1)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

print(ans)


Error: TLE

Fixed submission:

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

ans = 1
for i in range(N):
    ans *= A[i]

if ans <= 10**18:
    print(ans)
else:
    print(-1)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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)


Error: TLE

Fixed submission:

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

ans = 1
for a in A:
    ans *= a

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

print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = [int(v) for v in input().split()]
limit = 1000000000000000000
if 0 in a:
    print(0)
else:
    ans = 1
    num = 1
    for i in a:
        num *= i
        if num > limit:
            num = -1
            break
    ans = num
    print(ans)


Error: TLE

Fixed submission:

n = int(input())
a = [int(v) for v in input().split()]
ans = 1
num = 1
limit = 1000000000000000000
for i in a:
    if i == 0:
        num = 0
        break
    if i >= limit:
        num = -1
        break
    else:
        num *= i
if num > limit:
    num = -1
ans = num
print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

for i in range(len(A)):
    if len(str(answer)) + len(str(A[i])) <= 20:
        answer *= A[i]
    else:
        print(-1)
        exit()

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


Error: TLE

Fixed submission:

N = int(input())
A = list(map(int, input().split()))
answer = 1
for i in range(len(A)):
    answer *= A[i]

if answer <= 1000000000000000000:
    print(answer)
else:
    print(-1)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

for i in a:
    if i == 0:
        print(0)
        exit()

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

print(ans)


Error: TLE

Fixed submission:

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)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

ans = 1

for e in num_list:
    if e == 0:
        ans = 0

for e in num_list:
    ans *= e
    if ans > 1000000000000000000:
        ans = -1
        break
    if ans == 0:
        break

print(ans)


Error: TLE

Fixed submission:

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

ans = 1

for e in num_list:
    ans *= e

if ans > 1000000000000000000:
    print("-1")
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 1000000000000000000:
        print(-1)
        exit(0)
print(ans)


Error: TLE

Fixed submission:

n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys

n = int(input())

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

ans = 1

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

for i in a:
    ans *= i

    if ans > 10**18:
        print(-1)
        sys.exit()

print(ans)


Error: TLE

Fixed submission:

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

print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = list(map(int, input().split()))
ans = 1
a.sort()
if a[0] == 0:
    print(0)
    exit()

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


Error: TLE

Fixed submission:

n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
if ans > pow(10, 18):
    print("-1")
else:
    print(ans)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

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

res = 1
for i in lis:
    if res > 10**18:
        print(-1)
        exit()
    else:
        res *= i
print(res if res <= 10**18 else -1)


Error: TLE

Fixed submission:

n = int(input())
lis = list(map(int, input().split()))
res = 1
for i in lis:
    res *= i
print(res if res <= 10**18 else -1)
Problem p02658 (Python) — buggy submission, verdict: Time Limit Exceeded

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

t = 10**18
if 0 in A:
    print(0)
else:
    sum = A[0]
    flag = True
    for i in range(1, N):
        sum = sum * A[i]
        if sum > t:
            flag = False
            break
    if flag:
        print(sum)
    else:
        print(-1)


Error: TLE

Fixed submission:

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

sum = A[0]
for i in range(1, N):
    sum = sum * A[i]
if sum <= 10**18:
    print(sum)
else:
    print(-1)