Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = [int(x) for x in input().split()]
l.sort(reverse=True)
 
ans = 0
 
for i in range(n-2):
  j = i + 1
  k = n - 1
  while j < k:
    if l[i] < l[j] + l[k]:
    	ans += k - j
    	j += 1
  	else:
  		k -= 1
print(ans)

Fixed submission:
N = int(input())
l = [int(x) for x in input().split()]
l.sort(reverse=True)
 
ans = 0
 
for i in range(N-2):
  j = i + 1
  k = N - 1
  while j < k:
    if l[i] < l[j] + l[k]:
      ans += k - j
      j += 1
    else:
      k -= 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
l = [int(x) for x in input().split()]
l.sort(reverse=True)

ans = 0

for i in range(n-2):
  j = i + 1
  k = n - 1
  if l[i] < l[j] + l[k]:
    ans += k - j
    j += 1
  else:
    k -= 1
print(ans)

Fixed submission:
N = int(input())
l = [int(x) for x in input().split()]
l.sort(reverse=True)
 
ans = 0
 
for i in range(N-2):
  j = i + 1
  k = N - 1
  while j < k:
    if l[i] < l[j] + l[k]:
      ans += k - j
      j += 1
    else:
      k -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = [int(x) for x in input().split()]

L = sorted(l,reverse=True)
a = 0

for x in range(0,N-2):
  for y in range(x+1,N-1):
	   for i in range(y+1,N):
	       if L[i] > L[x] - L[y]:
	           a += 1
print(a)

Fixed submission:
N = int(input())
l = [int(x) for x in input().split()]
l.sort(reverse=True)
 
ans = 0
 
for i in range(N-2):
  j = i + 1
  k = N - 1
  while j < k:
    if l[i] < l[j] + l[k]:
      ans += k - j
      j += 1
    else:
      k -= 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
l = [int(x) for x in input().split()]

L = sorted(l,reverse=True)
a = 0

for x in range(0,N-3):
  for y in range(x+1,N-2):
	for i in range(y+1,N-1):
	  if L[i] > L[x] - L[y]:
		a += 1
print(a)

Fixed submission:
N = int(input())
l = [int(x) for x in input().split()]
l.sort(reverse=True)
 
ans = 0
 
for i in range(N-2):
  j = i + 1
  k = N - 1
  while j < k:
    if l[i] < l[j] + l[k]:
      ans += k - j
      j += 1
    else:
      k -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
print(len([x for x in h if x >= k])

Fixed submission:
N = float(input())
if N % 2 == 0:
  print(1/2)
else:
  print((N+1)/(2*N))

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
a = 0
for index, x in enumerate(h):
  if x == k:
    a += index
    break
print(n - a)

Fixed submission:
N = float(input())
if N % 2 == 0:
  print(1/2)
else:
  print((N+1)/(2*N))

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
for index, x in enumerate(h):
  if x == k:
    print(n - index)
    break

Fixed submission:
N = float(input())
if N % 2 == 0:
  print(1/2)
else:
  print((N+1)/(2*N))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
A = []
for index, i in enumerate(a):
  A[i -1] = index + 1
print(' '.join(A))

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

ans=[0]*n

for i, x in enumerate(a):
  ans[x-1] = str(i+1)
print(' '.join(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
A = []
for index, i in enumerate(a):
  A[i] = index + 1
print(A)

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

ans=[0]*n

for i, x in enumerate(a):
  ans[x-1] = str(i+1)
print(' '.join(ans))
Buggy python submission (verdict: Runtime Error):
now = input()
weather = ["Sunny","Cloudy","Rainy"]
print(weather[weather.index(now)+1 % 3])

Fixed submission:
now = input()
weather = ["Sunny","Cloudy","Rainy"]
print(weather[(weather.index(now)+1) % 3])
Buggy python submission (verdict: Runtime Error):
a, b=map(int, input().split())
puls = a + b
m = a - b
x = a * b
print(max(plus,m,x))

Fixed submission:
a, b= map (int, input().split())
plus = a + b
m = a - b
x = a * b
print(max(plus,m,x))

Buggy python submission (verdict: Runtime Error):
a, b=map(int, input().split())
int puls = a + b
int m = a - b
int x = a * b
print(max(plus,m,x))

Fixed submission:
a, b= map (int, input().split())
plus = a + b
m = a - b
x = a * b
print(max(plus,m,x))

Buggy python submission (verdict: Runtime Error):
input int=a, int=b
int puls = a + b
int m = a - b
int x = a * b
print(max(plus,m,x))

Fixed submission:
a, b= map (int, input().split())
plus = a + b
m = a - b
x = a * b
print(max(plus,m,x))
Buggy python submission (verdict: Runtime Error):
print('YES' if len(set(input())==2 else 'NO')

Fixed submission:
print("Yes" if len(set(input()))==2 else "No")

Buggy python submission (verdict: Runtime Error):
S = sorted(list(input()))
if S[1]==S[2] and S[3]==S[4] and len(S[1])==2
print
	("YES")
else
  	print("NO")

Fixed submission:
print("Yes" if len(set(input()))==2 else "No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
int count = 0
p[] = map(int,input(),split())
for (i=0; i < n-2; i++){
  if p[i] < p[i+1] < p[i+2]: count ++;}
print(count)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
ans = sum(1 for i in range(n-2) if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2])
print(ans)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))
D = 0
ans = 1

for i in range(N):
    D += L[i]
    if D <= X:
        ans += 1

print(ans)


Fixed submission:
x, a = map(int, input().split())
if x < a:
  print(0)
else:
  print(10)

Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
ans = 1

for i in range(n):
  d += l[i]
  if d < x:
    ans += 1
  else:
    break
    
print(ans)


Fixed submission:
x, a = map(int, input().split())
if x < a:
  print(0)
else:
  print(10)

Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
ans = 1

for i in range(n):
  d += l[i]
  if d < x:
    ans ++;
  else:
    break
    
print(ans)

Fixed submission:
x, a = map(int, input().split())
if x < a:
  print(0)
else:
  print(10)

Buggy python submission (verdict: Runtime Error):
a, x = int(input().split())
print("0" if x < a else "10") 

Fixed submission:
x, a = map(int, input().split())
if x < a:
  print(0)
else:
  print(10)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

int d = 0;
for i in range(n):
  if d < x:
    d += l[i]
  else:
    break
    
print(i)
  

Fixed submission:
N, X = list(map(int, input().split()))
L = list(map(int, input().split()))
D = 0
ans = 1

for i in range(N):
    D += L[i]
    if D <= X:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
print("ABC" if int input() < 1200 else "ARC")

Fixed submission:
n = int(input())
print("ABC" if 0 <= n < 1200 else "ARC")
Buggy python submission (verdict: Runtime Error):
n = A.pop(0)
while True:
  if n == 'a':
    if A == []:
      print('A')
      break
    n = A.pop(0)
  elif n == 'b':
    if B == []:
      print('B')
      break
    n = B.pop(0)
  else:
    if C == []:
      print('C')
      break
    n = C.pop(0)

Fixed submission:
A = list(input())
B = list(input())
C = list(input())

n = A.pop(0)
while True:
  if n == 'a':
    if A == []:
      print('A')
      break
    n = A.pop(0)
  elif n == 'b':
    if B == []:
      print('B')
      break
    n = B.pop(0)
  else:
    if C == []:
      print('C')
      break
    n = C.pop(0)
Buggy python submission (verdict: Runtime Error):
s = input()
ans = ''
a_s = s[::-1]
b = 0
for index, x in enumerate(a_s):
  if x == 'B':
    b += 1
  elif b == 0:
	ans.append(x)
  else:
    b -= 1
print(ans[::-1])
  

Fixed submission:
s = input()
ans = ''
for x in s:
  if x != 'B':
    ans += x
  elif x == 'B' and x != '':
    ans = ans[:-1]
  else:
    continue
print(ans)
Buggy python submission (verdict: Runtime Error):
s = map(int, input().split())
return (s[0] == s[1] == 5 and s[2] == 7 or s[2] == s[1] == 5 and s[0] == 7 or s[0] == s[2] == 5 and s[1] == 7)



Fixed submission:
a, b, c = map(int, input().split())
if (a==b == 5 and c ==7) or (a==c == 5 and b ==7) or (c== b == 5 and a ==7):
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
s = map(int, input().split())
return (s[0] == s[1] == 5 and s[2] == 7 or s[2] == s[1] == 5 and s[0] == 7 s[0] == s[2] == 5 and s[1] == 7)



Fixed submission:
a, b, c = map(int, input().split())
if (a==b == 5 and c ==7) or (a==c == 5 and b ==7) or (c== b == 5 and a ==7):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
S = []
for i in range(n):
  S[i] = input()
ans = ''.jion(sorted(S))
print(ans)

Fixed submission:
n, l = map(int, input().split())
k = [input() for x in range(n)]
print(''.join(sorted(k)))

Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
S = []
for i in n:
  S[i] = input()
ans = ''.jion(sorted(S))
print(ans)

Fixed submission:
n, l = map(int, input().split())
k = [input() for x in range(n)]
print(''.join(sorted(k)))
Buggy python submission (verdict: Runtime Error):
from itertools import combinations
N, M = map(int, input().split())

a = list(combinations(range(N), 2))
b = list(combinations(range(M), 2))
print(len(a)+len(b))

Fixed submission:
S = str(input())
N = len(S)
num = (N-1)/2
num1 = (N+2)/2
if(S[:int(num)]==S[int(num1):]):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
inp = input().split(" ")
N = int(inp[0])
R = int(inp[1])
if N >= 10:
    iner_r = R
else:
    iner_r  = R + 100*(10-N)
return iner_r

Fixed submission:
n,r= map(int,input().split())
if n >= 10:
    print(r)
else:
    r  = r + 100*(10-n)
    print(r)
Buggy python submission (verdict: Runtime Error):
a =  map(int,intpu().split())
if len(set(a)) == 2:
  print("Yes")
else:
  print("No")

Fixed submission:
a = map(int,input().split())
if len(set(a)) == 2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
A1,A2,A3 = int(input().split(""))
result = A1+A2+A3
if result>= 22:
  print("bust")
else:
  print("win")

Fixed submission:
inp = input()
inpLi = inp.split()
A1 = int(inpLi[0])
A2 = int(inpLi[1])
A3 = int(inpLi[2])

if (A1+A2+A3) >= 22:
  print("bust")
else:
  print("win")

Buggy python submission (verdict: Runtime Error):
inp = input()
inpLi = inp.split("")
A1 = int(inpLi[0])
A2 = int(inpLi[1])
A3 = int(inpLi[2])
result = A1+A2+A3
if result >= 22:
  print("bust")
else:
  print("win")


Fixed submission:
inp = input()
inpLi = inp.split()
A1 = int(inpLi[0])
A2 = int(inpLi[1])
A3 = int(inpLi[2])

if (A1+A2+A3) >= 22:
  print("bust")
else:
  print("win")

Buggy python submission (verdict: Runtime Error):
h = int(input())
a1,a2,a3 = h.split()
result = a1+a2+a3
if result>22 or result == 22:
  print("bust")
else:
  print("win")


Fixed submission:
inp = input()
inpLi = inp.split()
A1 = int(inpLi[0])
A2 = int(inpLi[1])
A3 = int(inpLi[2])

if (A1+A2+A3) >= 22:
  print("bust")
else:
  print("win")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import combinations
def main():
    n, *a = map(int, read().split())
    large_p = 10 ** 9 + 7
    a2 = [i % large_p for i in a]
    com = tuple(combinations(a2, 2))
    r = 0
    for come in com:
        r += (come[0] * come[1]) % large_p
        r = r % large_p
    print(r)


if __name__ == '__main__':
    main()

Fixed submission:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import accumulate
def main():
    n, *a = map(int, read().split())
    large_p = 10 ** 9 + 7
    aac = tuple(accumulate(a))
    r = 0
    for i1 in range(n):
        t1 = aac[-1] - aac[i1]
        r += (t1 * a[i1]) % large_p
    r = r % large_p
    print(r)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import combinations
def main():
    n, *a = map(int, read().split())
    large_p = 10 ** 9 + 7

    com = tuple(combinations(a, 2))
    r = 0
    for come in com:
        r += (come[0] * come[1]) % large_p
        r = r % large_p

    print(r)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import accumulate
def main():
    n, *a = map(int, read().split())
    large_p = 10 ** 9 + 7
    aac = tuple(accumulate(a))
    r = 0
    for i1 in range(n):
        t1 = aac[-1] - aac[i1]
        r += (t1 * a[i1]) % large_p
    r = r % large_p
    print(r)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, *a = map(int, read().split())
    #a2 = a[::-1]
    r = 0

    for i1 in range(1, n):
        if max(a[:i1]) > a[i1]:
            r += max(a[:i1]) - a[i1]
    print(r)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(10**7)
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *a = map(int, read().split())
    r = 0
    st = a[0]
    for ae in a[1:]:
        if st > ae:
            r += st - ae
        else:
            st = ae
    print(r)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n = int(input())
    a = input()
    if not 'WR' in a:
        print(0)
        sys.exit()
    a = list(a)
    r = 0
    rnum = a.count('R')
    while True:
        if 'W' in a[:rnum]:
            t1 = a[:rnum].index('W')
            t2 = a[rnum:].index('R')
            a[t1] = 'R'
            a[t2+rnum] = 'W'
            r += 1
        else:
            break
    print(r)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
read = sys.stdin.read
def main():
    n = int(input())
    a = input()
    if not 'WR' in a:
        print(0)
        sys.exit()
    a = list(a)
    rnum = a.count('R')
    r = 0
    for i1 in range(rnum):
        r += a[i1] == 'W'
    for j1 in range(n - rnum):
        r += a[rnum + j1] == 'R'
    r = r // 2
    print(r)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
read = sys.stdin.read
from collections import deque
def main():
    n = int(input())
    a = input()
    if not 'WR' in a:
        print(0)
        sys.exit()
    a = list(a)
    rnum = a.count('R')
    r = 0
    for i1 in range(rnum):
        r += a[i1] == 'W'
    for j1 in range(n - rnum):
        r += a[rnum + j1] == 'R'

    r = r // 2
    print(r)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.read
def main():
    n = int(input())
    a = input()
    if not 'WR' in a:
        print(0)
        sys.exit()
    a = list(a)
    rnum = a.count('R')
    r = 0
    for i1 in range(rnum):
        r += a[i1] == 'W'
    for j1 in range(n - rnum):
        r += a[rnum + j1] == 'R'
    r = r // 2
    print(r)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
from heapq import heapify,heappop,heappush
def main():
    n, k, *a = map(int, read().split())
    minusa = [-ae for ae in a]

    heapify(minusa)
    while k > 0:
        maxa = heappop(minusa)
        heappush(minusa, maxa/2)
        k -= 1
        print(minusa)
    r = heappop(minusa)
    r *= -1
    r = ceil(r)
    print(r)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, k, *a = map(int, read().split())
    def isOK(x):
        kaisu = 0
        for ae in a:
            kaisu += ceil(ae / x) - 1
        if kaisu <= k:
            return True
        else:
            return False
    ng = 0
    ok = max(a)
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid
    print(ok)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n, *a = map(int, read().split())
    r = 0
    for i1, ae in enumerate(a):
        if (i1+1)&1 and ae&1:
            r += 1
    print(r)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from copy import deepcopy

def main():
    n, *a = map(int, read().split())
    if n == 1:
        if a[0] % 2 == 1:
            print(1)
        else:
            print(0)
        sys.exit()
    r = 0
    for i1 in range(0,n,2):
        r += a[i1] % 2 == 1
    print(r)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from collections import defaultdict
def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())

    ac = Counter(a)
    acl = defaultdict(int)
    for ae in ac:
        acl[ae] = ac[ae]

    for _ in range(q):
        b, c = map(int, input().split())
        rmed = acl[b]
        acl[c] += rmed
        acl[b] = 0
        r = sum([i * v for i, v in acl.items()])
        print(r)

if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter
from collections import defaultdict
def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())
    asum = sum(a)
    ac = Counter(a)
    acl = defaultdict(int)
    for ae in ac:
        acl[ae] = ac[ae]

    for _ in range(q):
        b, c = map(int, input().split())
        rmed = acl[b]
        acl[c] += rmed
        acl[b] = 0
        asum -= b * rmed
        asum += c * rmed
        print(asum)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from collections import defaultdict
def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())

    ac = Counter(a)
    acl = defaultdict(int)
    for ae in ac:
        acl[ae] = ac[ae]

    for _ in range(q):
        b, c = map(int, input().split())
        rmed = acl[b]
        acl[c] += rmed
        acl[b] = 0
        r = 0
        for acle in acl:
            r += acle * acl[acle]
        print(r)


if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter
from collections import defaultdict
def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())
    asum = sum(a)
    ac = Counter(a)
    acl = defaultdict(int)
    for ae in ac:
        acl[ae] = ac[ae]

    for _ in range(q):
        b, c = map(int, input().split())
        rmed = acl[b]
        acl[c] += rmed
        acl[b] = 0
        asum -= b * rmed
        asum += c * rmed
        print(asum)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())
    for _ in range(q):
        b, c = map(int, input().split())
        ichi = [x for x, i in enumerate(a) if i == b]
        for ie in ichi:
            a[ie] = c
        print(sum(a))

if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter
from collections import defaultdict
def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())
    asum = sum(a)
    ac = Counter(a)
    acl = defaultdict(int)
    for ae in ac:
        acl[ae] = ac[ae]

    for _ in range(q):
        b, c = map(int, input().split())
        rmed = acl[b]
        acl[c] += rmed
        acl[b] = 0
        asum -= b * rmed
        asum += c * rmed
        print(asum)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
largenum = 10**18
from functools import reduce
from operator import mul
def main():
    n = int(input())
    a = list(map(int, input().split()))

    r = reduce(mul, a)
    if r > largenum:
        print(-1)
    else:
        print(r)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
largenum = 10**18
from functools import reduce
from operator import mul
def main():
    n = int(input())
    a = list(map(int, input().split()))

    if 0 in a:
        print(0)
        sys.exit()
    r = 1
    for i1 in range(n):
        r *= a[i1]
        if r > largenum:
            print(-1)
            sys.exit()
    print(r)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
largenum = 10**18
def main():
    n = int(input())
    a = list(map(int, input().split()))

    r = 1
    for i1 in range(n):
        r *= a[i1]
    if r > largenum:
        print('-1')
        sys.exit()
    else:
        print(r)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
largenum = 10**18
from functools import reduce
from operator import mul
def main():
    n = int(input())
    a = list(map(int, input().split()))

    if 0 in a:
        print(0)
        sys.exit()
    r = 1
    for i1 in range(n):
        r *= a[i1]
        if r > largenum:
            print(-1)
            sys.exit()
    print(r)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
largenum = 10**18
def main():
    n = int(input())
    a = list(map(int, input().split()))

    r = a[0]
    for i1 in range(1, n):
        if r > largenum:
            print(-1)
            sys.exit()
        else:
            r *= a[i1]
    print(r)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
largenum = 10**18
from functools import reduce
from operator import mul
def main():
    n = int(input())
    a = list(map(int, input().split()))

    if 0 in a:
        print(0)
        sys.exit()
    r = 1
    for i1 in range(n):
        r *= a[i1]
        if r > largenum:
            print(-1)
            sys.exit()
    print(r)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import mul
largenum = 10**18
def main():
    n = int(input())
    a = list(map(int, input().split()))
    r = int(reduce(mul, a))
    if r > largenum:
        r = -1
    print(r)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
largenum = 10**18
from functools import reduce
from operator import mul
def main():
    n = int(input())
    a = list(map(int, input().split()))

    if 0 in a:
        print(0)
        sys.exit()
    r = 1
    for i1 in range(n):
        r *= a[i1]
        if r > largenum:
            print(-1)
            sys.exit()
    print(r)


if __name__ == '__main__':
    main()