Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
list_S = list(input())
k = int(input())
set_ANS = set()
list_Alph = list(set(list_S))
list_Alph.sort()
cnt = 0

for c in list_Alph:
    q = [i for i, x in enumerate(list_S) if x == c]
    for j in range(1, len(list_S)+1):
        for i in q:
            if i + j <= len(list_S):
                l = "".join(list_S[i:i+j])
                if l not in set_ANS:
                    set_ANS.add(l)
                    cnt += 1
    if cnt >= k:
        list_ANS = list(set_ANS)
        list_ANS.sort()
        print(list_ANS[k-1])
        exit()

Fixed submission:
list_S = list(input())
k = int(input())
set_ANS = set()
list_Alph = list(set(list_S))
cnt = 0
list_Alph.sort()

for c in list_Alph:
    q = [i for i, x in enumerate(list_S) if x == c]
    list_M = []
    for i in q:
        l = "".join(list_S[i:])
        list_M.append(l)
    list_M.sort()
    for s in list_M:
        m = list(s)
        for j in range(1,len(m)+1):
            b = "".join(m[:j])
            if b not in set_ANS:
                set_ANS.add(b)
                cnt += 1
                if cnt == k:
                    print(b)
                    exit()

Buggy python submission (verdict: Time Limit Exceeded):
list_S = list(input())
k = int(input())
set_ANS = set(list_S)

for i in range(len(list_S)-1):
    c = list_S[i]
    for j in range(i+1, len(list_S)):
        c += list_S[j]
        set_ANS.add(c)

list_ANS = list(set_ANS)
list_ANS.sort()

print(list_ANS[k-1])

Fixed submission:
list_S = list(input())
k = int(input())
set_ANS = set()
list_Alph = list(set(list_S))
cnt = 0
list_Alph.sort()

for c in list_Alph:
    q = [i for i, x in enumerate(list_S) if x == c]
    list_M = []
    for i in q:
        l = "".join(list_S[i:])
        list_M.append(l)
    list_M.sort()
    for s in list_M:
        m = list(s)
        for j in range(1,len(m)+1):
            b = "".join(m[:j])
            if b not in set_ANS:
                set_ANS.add(b)
                cnt += 1
                if cnt == k:
                    print(b)
                    exit()

Buggy python submission (verdict: Time Limit Exceeded):
list_S = list(input())
k = int(input())
set_ANS = set()

for i in range(len(list_S)):
    for j in range(i, len(list_S)+1):
        set_ANS.add(''.join(list_S[i:j]))

list_ANS = list(set_ANS)
list_ANS.sort()

print(list_ANS[k])

Fixed submission:
list_S = list(input())
k = int(input())
set_ANS = set()
list_Alph = list(set(list_S))
cnt = 0
list_Alph.sort()

for c in list_Alph:
    q = [i for i, x in enumerate(list_S) if x == c]
    list_M = []
    for i in q:
        l = "".join(list_S[i:])
        list_M.append(l)
    list_M.sort()
    for s in list_M:
        m = list(s)
        for j in range(1,len(m)+1):
            b = "".join(m[:j])
            if b not in set_ANS:
                set_ANS.add(b)
                cnt += 1
                if cnt == k:
                    print(b)
                    exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list_A = list(map(int, input().split()))
list_A.sort()
max_value = max(list_A)
cnt = 0
hight = 1
hight_num = max_value
low = 1
low_num = 1
cnt = 0
ans = 0
b = 0
num = 1
for i in range(max_value):
    hight = hight_num - i
    low = low_num + i
    num = num*hight//low
    if list_A[cnt] == low_num + i:
        ans = max(ans, num)
        cnt += 1
        if ans == num:
            b = low_num + i

print(max_value, b)

Fixed submission:
n = int(input())
list_A = list(map(int, input().split()))
list_A.sort()
max_value = max(list_A)
a = max_value/2
b = pow(10, 10)
c = 0
for num in list_A:
    if abs(a-num) < b:
        b = abs(a-num)
        c = num

print(max_value, c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list_A = list(map(int, input().split()))
list_A.sort()
max_value = max(list_A)
cnt = 0
hight = 1
hight_num = max_value
low = 1
low_num = 1
cnt = 0
ans = 0
b = 0
for i in range(max_value):
    hight *= hight_num - i
    low *= low_num + i
    if list_A[cnt] == low_num + i:
        ans = max(ans, hight//low)
        cnt += 1
        if ans == hight//low:
            b = low_num + i

print(max_value, b)

Fixed submission:
n = int(input())
list_A = list(map(int, input().split()))
list_A.sort()
max_value = max(list_A)
a = max_value/2
b = pow(10, 10)
c = 0
for num in list_A:
    if abs(a-num) < b:
        b = abs(a-num)
        c = num

print(max_value, c)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
list_A = list(map(int, input().split()))
max_value = max(list_A)
ans = 0
a = 0
for i in list_A:
    c = cmb(max_value, i)
    ans = max(ans, c)
    if ans == c:
        a = i

print(max_value, a)

Fixed submission:
n = int(input())
list_A = list(map(int, input().split()))
list_A.sort()
max_value = max(list_A)
a = max_value/2
b = pow(10, 10)
c = 0
for num in list_A:
    if abs(a-num) < b:
        b = abs(a-num)
        c = num

print(max_value, c)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
list_ANS = [i for i in range(a, b+1)]

for _ in range(k):
    if len(list_ANS) != 0:
        a = list_ANS.pop(0)
        print(a)
    else:
        break
list_A = []
for _ in range(k):
    if len(list_ANS) != 0:
        b = list_ANS.pop(-1)
        list_A.append(b)

    else:
        break
if len(list_A) != 0:
    list_A.reverse()
    for i in list_A:
        print(i)

Fixed submission:
a, b, k = map(int, input().split())
if b-a > pow(10, 5):
    list_ANS = [i for i in range(a, a+pow(10, 5))] + [i for i in range(b - pow(10, 5), b+1)]
else:
    list_ANS = [i for i in range(a, b+1)]

for _ in range(k):
    if len(list_ANS) != 0:
        a = list_ANS.pop(0)
        print(a)
    else:
        break
list_A = []
for _ in range(k):
    if len(list_ANS) != 0:
        b = list_ANS.pop(-1)
        list_A.append(b)

    else:
        break
if len(list_A) != 0:
    list_A.reverse()
    for i in list_A:
        print(i)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
list_ANS = [i for i in range(a, b+1)]

for _ in range(k):
    if len(list_ANS) != 0:
        a = list_ANS.pop(0)
        print(a)
    else:
        break
list_A = []
for _ in range(k):
    if len(list_ANS) != 0:
        b = list_ANS.pop(-1)
        list_A.append(b)
    else:
        break

list_A.reverse()
for i in list_A:
    print(i)

Fixed submission:
a, b, k = map(int, input().split())
if b-a > pow(10, 5):
    list_ANS = [i for i in range(a, a+pow(10, 5))] + [i for i in range(b - pow(10, 5), b+1)]
else:
    list_ANS = [i for i in range(a, b+1)]

for _ in range(k):
    if len(list_ANS) != 0:
        a = list_ANS.pop(0)
        print(a)
    else:
        break
list_A = []
for _ in range(k):
    if len(list_ANS) != 0:
        b = list_ANS.pop(-1)
        list_A.append(b)

    else:
        break
if len(list_A) != 0:
    list_A.reverse()
    for i in list_A:
        print(i)
Buggy python submission (verdict: Runtime Error):
n = int(input())
list_N = [input() for _ in range(n)]
list_N = list(set(list_N))
cnt = [0 for _ in range(5)]

for i in range(len(list_N)):
    l = list(list_N[i])
    if l[0] in "M":
        cnt[0] += 1
    elif l[0] in "A":
        cnt[1] += 1
    elif l[0] in "R":
        cnt[2] += 1
    elif l[0] in "C":
        cnt[3] += 1
    elif l[0] in "H":
        cnt[4] += 1

ans = 0
l  = []
if cnt.count(0) == 2:
    for num in cnt:
        if num != 0:
            l.append(num)
    ans += l[0]*l[1]*l[2]
if cnt.count(0) == 1:
    for num in cnt:
        if num != 0:
            l.append(num)
    ans += l[0] * l[1] * l[2]
    ans += l[0] * l[1] * l[3]
    ans += l[0] * l[2] * l[3]
    ans += l[2] * l[1] * l[3]
if cnt.count(0) == 0:
    ans += l[0] * l[1] * l[2]
    ans += l[0] * l[1] * l[3]
    ans += l[0] * l[1] * l[4]
    ans += l[0] * l[2] * l[3]
    ans += l[0] * l[2] * l[4]
    ans += l[0] * l[3] * l[4]
    ans += l[1] * l[2] * l[3]
    ans += l[1] * l[2] * l[4]
    ans += l[1] * l[3] * l[4]
    ans += l[2] * l[3] * l[4]

if cnt.count(0) > 2:
    print(0)
else:
    print(ans)

Fixed submission:
n = int(input())
list_N = [input() for _ in range(n)]
list_N = list(set(list_N))
cnt = [0 for _ in range(5)]

for i in range(len(list_N)):
    l = list(list_N[i])
    if l[0] in "M":
        cnt[0] += 1
    elif l[0] in "A":
        cnt[1] += 1
    elif l[0] in "R":
        cnt[2] += 1
    elif l[0] in "C":
        cnt[3] += 1
    elif l[0] in "H":
        cnt[4] += 1

ans = 0
l  = []
if cnt.count(0) == 2:
    for num in cnt:
        if num != 0:
            l.append(num)
    ans += l[0]*l[1]*l[2]
if cnt.count(0) == 1:
    for num in cnt:
        if num != 0:
            l.append(num)
    ans += l[0] * l[1] * l[2]
    ans += l[0] * l[1] * l[3]
    ans += l[0] * l[2] * l[3]
    ans += l[2] * l[1] * l[3]
if cnt.count(0) == 0:
    l = cnt
    ans += l[0] * l[1] * l[2]
    ans += l[0] * l[1] * l[3]
    ans += l[0] * l[1] * l[4]
    ans += l[0] * l[2] * l[3]
    ans += l[0] * l[2] * l[4]
    ans += l[0] * l[3] * l[4]
    ans += l[1] * l[2] * l[3]
    ans += l[1] * l[2] * l[4]
    ans += l[1] * l[3] * l[4]
    ans += l[2] * l[3] * l[4]

if cnt.count(0) > 2:
    print(0)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

q = int(input())
list_Q = [ list(map(int,input().split(" "))) for i in range(q)]

num = pow(10,5)
list_PRE = [0]*(2*num+10)
list_PRE[2] = 1
for i in range(1, 2*num+10, 2):
    if len(prime_factorize(i)) == 1:
        list_PRE[i] = 1

list_2017 = [0]*(2*num+10)
for i in range(1, num+1, 2):
    if list_PRE[i] == 1 and list_PRE[(i+1)//2] == 1:
        list_2017[i] = 1

for i, j in list_Q:
    print(sum(list_2017[i:j+1]))

Fixed submission:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

q = int(input())
list_Q = [ list(map(int,input().split(" "))) for i in range(q)]

num = pow(10, 5)
list_PRE = [0]*(2*num+10)
list_PRE[2] = 1
for i in range(1, 2*num+10, 2):
    if len(prime_factorize(i)) == 1:
        list_PRE[i] = 1

list_2017 = [0]*(2*num+10)
for i in range(1, num+1, 2):
    if list_PRE[i] == 1 and list_PRE[(i+1)//2] == 1:
        list_2017[i] = 1

list_ANS = []
cnt = 0
for i in list_2017:
    if i == 1:
        cnt += 1
        list_ANS.append(cnt)
    else:
        list_ANS.append(cnt)

for i, j in list_Q:
    print(list_ANS[j]-list_ANS[i-1])
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
list_A = list(map(int, input().split()))
list_B = list(map(int, input().split()))
list_C = list(map(int, input().split()))
list_A.sort()
list_B.sort()
list_C.sort()
ans = 0
list_U = []
list_D = []

for i in range(n):
    b = list_B[i]
    index = bisect.bisect_left(list_A, b)
    list_U.append(index)

for i in range(n):
    c = list_C[i]
    index = bisect.bisect_left(list_B, c)
    list_D.append(index)

for i in range(n):
    j = list_D[i]
    for k in range(j):
        ans += list_U[k]

print(ans)

Fixed submission:
n = int(input())
list_A = list(map(int, input().split()))
list_B = list(map(int, input().split()))
list_C = list(map(int, input().split()))
list_A.sort()
list_B.sort()
list_C.sort()
b = 0
list_UP = []
for i in range(n):
    while True:
        if b > n-1 or list_A[i] < list_B[b]:
            break
        b += 1
    list_UP.append(n-b)


c = 0
list_DOWN = []
for i in range(n):
    while True:
        if c > n-1 or list_B[i] < list_C[c]:
            break
        c += 1
    list_DOWN.append(n-c)


ans = 0
num = 0
sum_value = sum(list_DOWN)
for i in list_UP:
    while True:
        if num == n-i:
            break
        sum_value -= list_DOWN[num]
        num += 1
    ans += sum_value

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
list_A = list(map(int, input().split()))
list_B = list(map(int, input().split()))
list_C = list(map(int, input().split()))
list_A.append(pow(10, 18))
list_B.append(pow(10, 18))
list_A.sort()
list_B.sort()
list_C.sort()
ans = 0

for i in range(n):
    c = list_C[i]
    j = bisect.bisect_left(list_B, c)
    for k in range(j):
        b = list_B[k]
        ans += bisect.bisect_left(list_A, b)

print(ans)

Fixed submission:
n = int(input())
list_A = list(map(int, input().split()))
list_B = list(map(int, input().split()))
list_C = list(map(int, input().split()))
list_A.sort()
list_B.sort()
list_C.sort()
b = 0
list_UP = []
for i in range(n):
    while True:
        if b > n-1 or list_A[i] < list_B[b]:
            break
        b += 1
    list_UP.append(n-b)


c = 0
list_DOWN = []
for i in range(n):
    while True:
        if c > n-1 or list_B[i] < list_C[c]:
            break
        c += 1
    list_DOWN.append(n-c)


ans = 0
num = 0
sum_value = sum(list_DOWN)
for i in list_UP:
    while True:
        if num == n-i:
            break
        sum_value -= list_DOWN[num]
        num += 1
    ans += sum_value

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list_N = [int(input()) for _ in range(n)]
ans = []
for num in list_N:
    if num in ans:
        ans.remove(num)
    else:
        ans.append(num)
print(len(ans))

Fixed submission:
from collections import Counter
n = int(input())
list_N = [int(input()) for _ in range(n)]
l = Counter(list_N)
k = l.values()
ans = 0
for num in k:
    if num % 2 == 1:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
list_T = [int(input()) for _ in range(n)]

print(lcm_list(list_T))


Fixed submission:
from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
list_T = [int(input()) for _ in range(n)]

print(lcm_list(list_T))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
list_AB = [ list(map(int,input().split(" "))) for i in range(m)]
list_MAP = [0]*(n+1)

for l in list_AB:
    l.sort()
    if l[0] == 1:
        list_MAP[l[1]] += 1
    if l[1] == n:
        list_MAP[l[0]] += 1

ans = "IMPOSSIBLE"

for num in list_MAP:
    if num > 1:
        ans = "POSSIBLE"

print(ans)

Fixed submission:
n = int(input())
list_A = list(map(int, input().split()))
list_C = [0, 0, 0]

for num in list_A:
    if num % 4 == 0:
        list_C[2] += 1
    elif num % 2 == 0:
        list_C[1] += 1
    else:
        list_C[0] += 1

ans = "Yes"

if list_C[1] == 0:
    if list_C[2] == 0:
        if list_C[0] != 0:
            ans = "No"
    if list_C[2] == 1:
        if list_C[0] > 2:
            ans = "No"
    if list_C[2] > 1:
        if list_C[0] > list_C[2] + 1:
            ans = "No"
else:
    if list_C[0] > list_C[2]:
        ans = "No"

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n = int(input())
list_A = list(map(int, input().split()))
ans = deque()
for i in range(n):
    if i % 2 == 0:
        ans.append(list_A[i])
    else:
        ans.insert(0, list_A[i])

if n % 2 == 1:
    ans.reverse()
print(*ans)

Fixed submission:
from collections import deque
n = int(input())
list_A = list(map(int, input().split()))
ans = deque([])
for i in range(n):
    if i % 2 == 0:
        ans.append(list_A[i])
    else:
        ans.appendleft(list_A[i])

if n % 2 == 1:
    ans.reverse()
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list_A = list(map(int, input().split()))
ans = []
for i in range(n):
    if i % 2 == 0:
        ans.append(list_A[i])
    else:
        ans.insert(0, list_A[i])

if n % 2 == 1:
    ans.reverse()
print(*ans)

Fixed submission:
from collections import deque
n = int(input())
list_A = list(map(int, input().split()))
ans = deque([])
for i in range(n):
    if i % 2 == 0:
        ans.append(list_A[i])
    else:
        ans.appendleft(list_A[i])

if n % 2 == 1:
    ans.reverse()
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list_A = list(map(int, input().split()))
ans = []
for i in range(n):
    ans.append(list_A[i])
    ans.reverse()

print(*ans)

Fixed submission:
from collections import deque
n = int(input())
list_A = list(map(int, input().split()))
ans = deque([])
for i in range(n):
    if i % 2 == 0:
        ans.append(list_A[i])
    else:
        ans.appendleft(list_A[i])

if n % 2 == 1:
    ans.reverse()
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ans = -1
mod = pow(10, 9) + 7

if abs(n-m) > 1:
    ans = 0
else:
    if abs(n-m) == 0:
        a = 1
        for i in range(1, n+1):
            a *= i
        ans = a*a*2
    if abs(n-m) == 1:
        a = 1
        for i in range(1, min(n, m)+1):
            a *= i
        b = a * max(n, m)
        ans = a * b

print(ans%mod)


Fixed submission:
import math
n, m = map(int, input().split())
ans = -1
mod = pow(10, 9) + 7

if abs(n-m) > 1:
    ans = 0
else:
    if abs(n-m) == 0:
        a = math.factorial(n)
        ans = a*a*2
    if abs(n-m) == 1:
        a = math.factorial(min(n, m))
        b = a * max(n, m)
        ans = a * b

print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
mod = pow(10, 9) + 7
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
l = [i for i in range(1, n+1)]
print(prod(l)%mod)

Fixed submission:
n = int(input())
mod = pow(10, 9) + 7
ans = 1
for i in range(1, n+1):
    ans *= i
    ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
mod = pow(10, 9) + 7
ans = 1
for i in range(1, n+1):
    ans *= i
print(ans%mod)

Fixed submission:
n = int(input())
mod = pow(10, 9) + 7
ans = 1
for i in range(1, n+1):
    ans *= i
    ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
mod = pow(10, 9) + 7
ans = 1
for i in range(1, n+1):
    ans *= i
print(ans%mod)

Fixed submission:
n = int(input())
mod = pow(10, 9) + 7
ans = 1
for i in range(1, n+1):
    ans *= i
    ans %= mod

print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(S: str, T: str):
    return len(T) - max(sum(s == t for s, t in zip(S[i:], T)) for i in range(len(S) - len(T)))


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    print(f'{solve(S, T)}')


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(S: str, T: str):
    return len(T) - max(sum(s == t for s, t in zip(S[i:], T)) for i in range(len(S) - len(T) + 1))


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    print(f'{solve(S, T)}')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(N: int, A: "List[int]"):
    return sum(max(A[:i+1]) for i in range(N)) - sum(A)


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(f'{solve(N, A)}')


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(N: int, A: "List[int]"):
    ans = 0
    m = A[0]
    for a in A[1:]:
        ans += max(0, m - a)
        m = max(m, a)
    return ans


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(f'{solve(N, A)}')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys

INF = float('inf')


def solve(N: int, A: "List[int]"):
    ans = 1
    for a in A:
        ans *= a
    return -1 if ans > 10**18 else ans


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, A))


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys

INF = float('inf')


def solve(N: int, A: "List[int]"):
    if min(A) == 0:
        return 0
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            return -1
    return ans


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, A))


if __name__ == '__main__':
    main()