Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

S = input()
ans = 0
N = len(S)
mod = 2019
dp = defaultdict(int)
cur = 0
for i in range(N, -1, -1):
    if i == N:
        dp[0] += 1
    else:
        cur += ((10 ** (N - i - 1)) * int(S[i])) % mod
        cur %= mod
        dp[cur] += 1
for v in dp.values():
    if v > 1:
        ans += v * (v - 1) // 2
print(ans)


Fixed submission:
from collections import defaultdict


def solve(input_s: str):
    ans = 0
    n = len(input_s)
    mod = 2019
    dp = defaultdict(int)
    cur = 0
    for i in range(n, -1, -1):
        if i == n:
            dp[0] += 1
        else:
            # cur += ((10 ** (n - i - 1)) * int(input_s[i])) % mod これはnがでかくなるとめちゃめちゃ遅い
            cur += pow(10, n - i - 1, 2019) * int(input_s[i]) % mod
            cur %= mod
            dp[cur] += 1
    for v in dp.values():
        if v > 1:
            ans += v * (v - 1) // 2
    return ans


if __name__ == '__main__':
    S = input()
    print(solve(S))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

S = input()
ans = 0
# i + 1文字目以降の数字列を2019で割った余りをdp[i]とするとdp[i - 1] == dp[j](mod 2019)の時(i, j)が条件を満たす
N = len(S)
mod = 2019
dp = [0] * (N + 1)
for i in range(N, -1, -1):
    if i == N:
        dp[i] = 0
    else:
        dp[i] = (dp[i + 1] + (10 ** (N - i - 1)) * int(S[i])) % mod

count = Counter(dp).most_common()
for k, v in count:
    if v > 1:
        ans += v * (v - 1) // 2
print(ans)

Fixed submission:
from collections import defaultdict


def solve(input_s: str):
    ans = 0
    n = len(input_s)
    mod = 2019
    dp = defaultdict(int)
    cur = 0
    for i in range(n, -1, -1):
        if i == n:
            dp[0] += 1
        else:
            # cur += ((10 ** (n - i - 1)) * int(input_s[i])) % mod これはnがでかくなるとめちゃめちゃ遅い
            cur += pow(10, n - i - 1, 2019) * int(input_s[i]) % mod
            cur %= mod
            dp[cur] += 1
    for v in dp.values():
        if v > 1:
            ans += v * (v - 1) // 2
    return ans


if __name__ == '__main__':
    S = input()
    print(solve(S))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
count = 0
for i in range(4, len(S) + 1):
    for j in range(0, len(S) - i + 1):
        if int(S[j:j + i]) % 2019 == 0:
            count += 1
print(count)

Fixed submission:
from collections import defaultdict


def solve(input_s: str):
    ans = 0
    n = len(input_s)
    mod = 2019
    dp = defaultdict(int)
    cur = 0
    for i in range(n, -1, -1):
        if i == n:
            dp[0] += 1
        else:
            # cur += ((10 ** (n - i - 1)) * int(input_s[i])) % mod これはnがでかくなるとめちゃめちゃ遅い
            cur += pow(10, n - i - 1, 2019) * int(input_s[i]) % mod
            cur %= mod
            dp[cur] += 1
    for v in dp.values():
        if v > 1:
            ans += v * (v - 1) // 2
    return ans


if __name__ == '__main__':
    S = input()
    print(solve(S))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
a = list(map(int,input().split()))
a = np.array(a)
a = np.sort(a)[::-1]
MAX = np.abs(np.prod(a))
#print (MAX)
Flag = True
q = 0
add = a[0]
sum = 0
max = np.sum(a)-len(a)
n = a[0]*q+a[0]-1
while True:
    st = np.sum(n%a)
    if sum < st:
        sum = st
    if sum == max:
        break
    ind = np.where(a - n%a == 1)[0]
    #print (ind)
    c = a[ind]
    n += np.prod(c)
    if n > MAX:
        break
    #print (sum)
print (sum)


Fixed submission:
import numpy as np
a = list(map(int,input().split()))
a = np.array(a)
a = np.sort(a)[::-1]
sum = a[0]-a[2]
print (sum)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
a = list(map(int,input().split()))
a = np.array(a)
a = np.sort(a)[::-1]
MAX = np.abs(np.prod(a))
#print (MAX)
Flag = True
q = 0
add = a[0]
sum = 0
max = np.sum(a)-len(a)
n = a[0]*q+a[0]-1
while True:
    st = np.sum(n%a)
    if sum < st:
        sum = st
    if sum == max:
        break
    ind = np.where(a - n%a == 1)[0]
    #print (ind)
    c = a[ind]
    n += np.prod(c)
    if n > MAX:
        break
    #print (sum)
print (sum)


Fixed submission:
import numpy as np
a = list(map(int,input().split()))
a = np.array(a)
a = np.sort(a)[::-1]
sum = a[0]-a[2]
print (sum)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
a = list(map(int,input().split()))
a = np.array(a)
a = np.sort(a)[::-1]
Flag = True
q = 0
add = a[0]
sum = 0
max = np.sum(a)-len(a)
n = a[0]*q+a[0]-1
while True:
    st = np.sum(n%a)
    if st == max:
        sum = st
        break
    ind = np.where(a - n%a == 1)[0]
    c = a[ind]
    n += np.prod(c)
print (sum)

Fixed submission:
import numpy as np
N = int(input())
a = list(map(int,input().split()))
print (np.sum(a)-len(a))

Buggy python submission (verdict: Runtime Error):
import numpy as np
from math import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
N = int(input())
a = list(map(int,input().split()))
a = np.array(a)
a = np.sort(a)[::-1]
MAX = lcm_list(a)
#print (MAX)
Flag = True
q = 0
add = a[0]
sum = 0
max = np.sum(a)-len(a)
#print (max)
n = a[0]*q+a[0]-1
while True:
    st = np.sum(n%a)
    if st == max:
        sum = st
        break
    if st > MAX:
        break
    ind = np.where(a - n%a == 1)[0]
    #print (ind)
    c = a[ind]
    n += np.prod(c)
    #print (sum)
print (sum)


Fixed submission:
import numpy as np
N = int(input())
a = list(map(int,input().split()))
print (np.sum(a)-len(a))
Buggy python submission (verdict: Runtime Error):
N, Y = input().split()

for x in range(1, N):
    for y in range(1, N):
        if (N - x - y < 0) and (10000 * x + 5000 * y + 1000(N - x - y)) == Y:
            print(x, y, N - x - y)


Fixed submission:
N, Y = map(int, input().split())
for x in range(N + 1):
    for y in range(N + 1):
        if (N - x - y >= 0) and (10000 * x + 5000 * y + 1000 * (N - x - y) == Y):
            print(x, y, N - x - y)
            break
    else:
        if x == N and y == N:
            print(-1, -1, -1)
        continue
    break
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
a = [int(_) for _ in input().split()]
a = np.array(a)
a = np.sort(a)
min = 0
max = 0
m = 0

for i in range(8):
    set_1 = set(np.where(i*400<=a)[0])
    set_2 = set(np.where(a<(i+1)*400)[0])
    match = list(set_1 & set_2)
    if len(match)>0:
        min+=1
if min=0:
    min=1
    if N>8:
	max = 8
    else:
	max = N
else:
    if len(np.where(a>=3200)[0])==0:
        max = min
    else:
        max = min + len(np.where(a>=3200)[0])
    	if max>8:
            max = 8
print (min, max)

Fixed submission:
import numpy as np
N = int(input())
a = [int(_) for _ in input().split()]
a = np.array(a)
a = np.sort(a)
min = 0
max = 100

for i in range(8):
    set_1 = set(np.where(i*400<=a)[0])
    set_2 = set(np.where(a<(i+1)*400)[0])
    match = list(set_1 & set_2)
    if len(match)>0:
        min+=1
if min==0:
    min=1
    max = N
else:
    if len(np.where(a>=3200)[0])==0:
        max = min
    else:
        max = min + len(np.where(a>=3200)[0])
print (min, max)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
a = [int(_) for _ in input().split()]
a = np.array(a)
a = np.sort(a)
min = 0
max = 0
m = 0

for i in range(8):
    set_1 = set(np.where(i*400<=a)[0])
    set_2 = set(np.where(a<(i+1)*400)[0])
    match = list(set_1 & set_2)
    if len(match)>0:
        min+=1
if min=0:
    min=1
    if N>8:
	max = 8
    else:
	max = N
else:
    if len(np.where(a>=3200)[0])==0:
        max = min
    else:
        max = min + len(np.where(a>=3200)[0])
    	if max>8:
            max = 8
print (min, max)


Fixed submission:
import numpy as np
N = int(input())
a = [int(_) for _ in input().split()]
a = np.array(a)
a = np.sort(a)
min = 0
max = 100

for i in range(8):
    set_1 = set(np.where(i*400<=a)[0])
    set_2 = set(np.where(a<(i+1)*400)[0])
    match = list(set_1 & set_2)
    if len(match)>0:
        min+=1
if min==0:
    min=1
    max = N
else:
    if len(np.where(a>=3200)[0])==0:
        max = min
    else:
        max = min + len(np.where(a>=3200)[0])
print (min, max)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,K = list(map(int,input().split()))

a = []
array = []
for i in range(N):
    a = list(map(int,input().split()))
    for j in range(a[1]):
        array.append(a[0])
#print (array)
array = np.sort(array)
node = 1

print (int(array[K-1]))

Fixed submission:
import numpy as np

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

a = []
for i in range(N):
    a.append(list(map(int,input().split())))
a = sorted(a,key = lambda i:i[0])
sum = 0
b = 0
#print (a)
for i in range(N):
    sum += a[i][1]
    b = a[i][0]
    if sum >= K:
        break

print (b)

Buggy python submission (verdict: Runtime Error):
mport numpy as np

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

a = []
array = np.array([])
for i in range(N):
    a = list(map(int,input().split()))
    array = np.concatenate((array,a[0]*np.ones(a[1])))
print (array)
array = np.sort(array)

print (int(array[K-1]))

Fixed submission:
import numpy as np

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

a = []
for i in range(N):
    a.append(list(map(int,input().split())))
a = sorted(a,key = lambda i:i[0])
sum = 0
b = 0
#print (a)
for i in range(N):
    sum += a[i][1]
    b = a[i][0]
    if sum >= K:
        break

print (b)
Buggy python submission (verdict: Runtime Error):
mport numpy as np

n = input()
s = []
for i in range(n):
    s.append(raw_input())
for i in range(n):
    s[i] = list(s[i])
    s[i].sort()
print s
#print s[0][1] in s[1]
#print len(s[0])
#print s[0][1]
#print s[2]
count = 0
answer = []
for j in range(len(s[0])):
    for k in range(1,n):
        if ''.join(s[k]).find(s[0][j]) != -1:
            count += 1
    if count == n-1:
        answer.append(s[0][j])
    print count
    count = 0
print ''.join(answer)

Fixed submission:
a,b,c = map(int, raw_input().split())

if b-a == c-b:
    print 'YES'
else:
    print 'NO'
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int , raw_input().split())
x = map(int, raw_input().split())
y = map(int, raw_input().split())

sum = 0

for i in range(n):
    for j in range(n):
            if i>j:
                for p in range(m):
                    for q in range(m):
                            if p > q:
                                sum += (x[i]-x[j])*(y[p]-y[q])
print sum % (10**9+7)

Fixed submission:
import numpy as np
n,m = map(int , raw_input().split())
x = map(int, raw_input().split())
y = map(int, raw_input().split())

sum_x = 0
sum_y = 0

for i in range(n):
    sum_x += i*x[i]-(n-i-1)*x[i]
for i in range(m):
    sum_y += i*y[i]-(m-i-1)*y[i]
print (sum_x*sum_y) % (10**9+7)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int , raw_input().split())
x = map(int, raw_input().split())
y = map(int, raw_input().split())

sum = 0

for i in range(n-1):
    for j in range(n):
        for k in range(n):
            if j-k == i+1:
                for p in range(m-1):
                    for q in range(m):
                        for r in range(m):
                            if q-r == p+1:
                                sum += (x[j]-x[k])*(y[q]-y[r])
print sum % (10**9+7)

Fixed submission:
import numpy as np
n,m = map(int , raw_input().split())
x = map(int, raw_input().split())
y = map(int, raw_input().split())

sum_x = 0
sum_y = 0

for i in range(n):
    sum_x += i*x[i]-(n-i-1)*x[i]
for i in range(m):
    sum_y += i*y[i]-(m-i-1)*y[i]
print (sum_x*sum_y) % (10**9+7)
Buggy python submission (verdict: Runtime Error):
mport numpy as np
N,M = map(int,raw_input().split())
a = []
c = []
for i in range(N):
    a.append(map(int,raw_input().split()))
#print a
for j in range(M):
    c.append(map(int,raw_input().split()))
a = np.array(a)
c = np.array(c)
#print a.shape
#print c.shape
min = 100
index = np.zeros(N)
for i in range(N):
    for j in range(M):
        if min > np.abs(a[i][0]-c[j][0])+np.abs(a[i][1]-c[j][1]):
            min = np.abs(a[i][0]-c[j][0])+np.abs(a[i][1]-c[j][1])
            index[i] = j
        elif min == np.abs(a[i][0]-c[j][0])+np.abs(a[i][1]-c[j][1]):
            if j < index[i]:
                index[i] = j
index = index.astype(np.int32)
for i in range(N):
    print index[i]+1

Fixed submission:
import numpy as np

def manhattan(x,y):
    return np.abs(x[0]-y[0]) + np.abs(x[1]-y[1])

N,M = map(int,raw_input().split())
students = np.zeros((N,2))
checkpoints = np.zeros((M,2))
for i in range(N):
    students[i][0],students[i][1] = map(int,raw_input().split())
#print a
for j in range(M):
    checkpoints[j][0],checkpoints[j][1] = map(int,raw_input().split())

index = np.zeros(N)
for i in range(N):
    min = 200000000
    for j in range(M):
        d = manhattan(students[i],checkpoints[j])
        if min > d:
            min = d
            index[i] = j
    print (index[i]+1).astype(np.int32)

Buggy python submission (verdict: Runtime Error):
mport numpy as np
N,M = map(int,raw_input().split())
a = []
c = []
for i in range(N):
    a.append(map(int,raw_input().split()))
#print a
for j in range(M):
    c.append(map(int,raw_input().split()))
a = np.array(a)
c = np.array(c)
#print a.shape
#print c.shape
min = 100
index = np.zeros(N)
for i in range(N):
    for j in range(M):
        if min > np.abs(a[i][0]-c[j][0])+np.abs(a[i][1]-c[j][1]):
            min = np.abs(a[i][0]-c[j][0])+np.abs(a[i][1]-c[j][1])
            index[i] = j
        if min == np.abs(a[i][0]-c[j][0])+np.abs(a[i][1]-c[j][1]):
            if j < index[i]:
                index[i] = j
index = index.astype(np.int32)
for i in range(N):
    print index[i]+1

Fixed submission:
import numpy as np

def manhattan(x,y):
    return np.abs(x[0]-y[0]) + np.abs(x[1]-y[1])

N,M = map(int,raw_input().split())
students = np.zeros((N,2))
checkpoints = np.zeros((M,2))
for i in range(N):
    students[i][0],students[i][1] = map(int,raw_input().split())
#print a
for j in range(M):
    checkpoints[j][0],checkpoints[j][1] = map(int,raw_input().split())

index = np.zeros(N)
for i in range(N):
    min = 200000000
    for j in range(M):
        d = manhattan(students[i],checkpoints[j])
        if min > d:
            min = d
            index[i] = j
    print (index[i]+1).astype(np.int32)
Buggy python submission (verdict: Runtime Error):
mport numpy as np
def F(x,y):
    count = 1
    if x<=y:
        while y >= 10:
            y = y/10
            count += 1
    if x>y:
        while x >= 10:
            x = x/10
            count += 1
    return count
#print F(1,13)
N = input()
min = 10**10
for i in range(np.sqrt(N).astype(np.int32)):
    if N%(i+1) == 0:
       if min > F(i+1,N/(i+1)):
           min = F(i+1,N/(i+1))
       print i+1

print min

Fixed submission:
import numpy as np
def F(x,y):
    count = 1
    if x<=y:
        while y >= 10:
            y = y/10
            count += 1
        return count
    else :
        while x >= 10:
            x = x/10
            count += 1
        return count
#print F(1,13)
N = input()
min = 10**10
index = np.zeros(2)
for i in range(np.sqrt(N).astype(np.int32)):
    if N%(i+1) == 0:
       if min > F(i+1,N/(i+1)):
           min = F(i+1,N/(i+1))
           index[0] = i+1
           index[1] = N/(i+1)
       #print i+1, N/(i+1),F(i+1,N/(i+1)), min

print min
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

K, S = map(int, input().split())
count = 0
for v in itertools.combinations(range(S + 2), 2):
    x = v[0]
    y = v[1] - v[0] - 1
    if max(x, y, S - x - y) <= K:
        count += 1
print(count)

Fixed submission:
K, S = map(int, input().split())
count = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
import math

N = input()
xs = [int(i) for i in input().split()]
p = round(sum(xs)/len(xs))

print(sum(math.pow(x-p) for x in xs))

Fixed submission:
import math

N = input()
xs = [int(i) for i in input().split()]
p = round(sum(xs)/len(xs))

print(int(sum(math.pow(x-p, 2) for x in xs)))
Buggy python submission (verdict: Runtime Error):
a, b = [int(i) for i in input().split()]
if b == 1:
    print(0)
    return
n = (b-2) / (a-1)
print(n+1)

Fixed submission:
a, b = [int(i) for i in input().split()]
if b == 1:
    print(0)
    exit()
n = int((b-2) / (a-1))
print(n+1)
Buggy python submission (verdict: Runtime Error):
b = input().strip()

if b == 'A':
  return 'T'
elif b == 'T':
  return 'A'
elif b == 'C':
  return 'G'
else:
  return 'C'

Fixed submission:
b = input().strip()
 
if b == 'A':
  print('T')
elif b == 'T':
  print('A')
elif b == 'C':
  print('G')
else:
  print('C')
Buggy python submission (verdict: Runtime Error):
s = input().strip()
enki = set('ATCG')
count = 0
maxlen = 0
for i in range(len(s)):
    if s[i] in enki:
        count += 1
    else:
        maxlen = max(maxlen, count)
        count = 0

return maxlen

Fixed submission:
S = input()
 
len = 0
ans = 0
for ch in S:
    if ch in 'ACGT':
        len += 1
        ans = max(ans, len)
    else:
        len = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    a, b = map(int, input().split())
    print(a * b)
    

if __name__ == '__main__':
    main()
                                          ￿

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    a, b = map(int, input().split())
    print(a * b)
    

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import defaultdict


def main():
    n = int(input().strip())

    diff_a = defaultdict(int)
    diff_b = defaultdict(int)
    for _ in range(n):
        a, b = map(int, input().split())
        diff_a[a] += 1
        diff_b[b] += 1

    cur = 0
    for i in sorted(diff_a):
        cur += diff_a[i]
        if cur == n // 2 + 1:
            b1 = i
            break
    cur = 0
    for i in sorted(diff_b, reverse=True):
        cur += diff_b[i]
        if cur == n // 2 + 1:
            e1 = i
            break

    if n % 2 == 1:
        print(e1 - b1 + 1)
        return

    cur = 0
    for i in sorted(diff_a):
        cur += diff_a[i]
        if cur == n // 2:
            b2 = i
            break
    cur = 0
    for i in sorted(diff_b, reverse=True):
        cur += diff_b[i]
        if cur == n // 2:
            e2 = i
            break
    ans = e2 + e1 - (b1 + b2) + 1
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import defaultdict


def main():
    n = int(input().strip())

    diff_a = defaultdict(int)
    diff_b = defaultdict(int)
    for _ in range(n):
        a, b = map(int, input().split())
        diff_a[a] += 1
        diff_b[b] += 1

    cur = 0
    for i in sorted(diff_a):
        cur += diff_a[i]
        if cur >= n // 2 + 1:
            b1 = i
            break
    cur = 0
    for i in sorted(diff_b, reverse=True):
        cur += diff_b[i]
        if cur >= n // 2 + 1:
            e1 = i
            break

    if n % 2 == 1:
        print(e1 - b1 + 1)
        return

    cur = 0
    for i in sorted(diff_a):
        cur += diff_a[i]
        if cur >= n // 2:
            b2 = i
            break
    cur = 0
    for i in sorted(diff_b, reverse=True):
        cur += diff_b[i]
        if cur >= n // 2:
            e2 = i
            break
    ans = e2 + e1 - (b1 + b2) + 1
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n = int(input().strip())
    a_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

    print(a_list[n])


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n = int(input().strip())
    a_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

    print(a_list[n - 1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    s = input().strip()
    q = int(input().strip())

    for i in range(q):
        query = input().strip()
        if query[0] == "1":
            s = s[::-1]
        else:
            _, f, c = query.split()
            if f == "1":
                s = c + s
            else:
                s = s + c

    print(s)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    s = input().strip()
    q = int(input().strip())

    rev_count = 0
    s_prev = ""
    s_suffix = ""
    for i in range(q):
        query = input().strip()
        if query[0] == "1":
            rev_count += 1
        else:
            _, f, c = query.split()
            if (f == "1" and rev_count % 2 == 0) or (f == "2" and rev_count % 2 == 1):
                s_prev += c
            else:
                s_suffix += c

    if rev_count % 2 == 0:
        print(s_prev[::-1] + s + s_suffix)
    else:
        print(s_suffix[::-1] + s[::-1] + s_prev)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
a_list = list(map(int, input().split()))
 
ans=1
for i in range(n):
  ans=ans*a_list[i]
  if ans==0:
    break
  
if ans>1000000000000000000:
  ans=-1
  
print(ans)

Fixed submission:
n= int(input())
a_list = list(map(int, input().split()))
 
a_list = [n for n in a_list if n!=1]  
#print(a_list)
ans=1

if 0 in a_list:
  ans=0
elif len(a_list)>56:
  ans=-1
else:
  for i in a_list:
    ans=ans*i
  if ans>1000000000000000000:
      ans=-1
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
a_list = list(map(int, input().split()))
 
ans=1
for i in range(n):
  ans=ans*a_list[i]
  if ans==0:
    break
  
if ans>1000000000000000000:
  ans=-1
  
print(ans)

Fixed submission:
n= int(input())
a_list = list(map(int, input().split()))
 
a_list = [n for n in a_list if n!=1]  
#print(a_list)
ans=1

if 0 in a_list:
  ans=0
elif len(a_list)>56:
  ans=-1
else:
  for i in a_list:
    ans=ans*i
  if ans>1000000000000000000:
      ans=-1
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
a_list = list(map(int, input().split()))
 
ans=1
for i in a_list:
  ans=ans*i
  if ans==0:
    break
  
if ans>1000000000000000000:
  ans=-1

print(ans)

Fixed submission:
n= int(input())
a_list = list(map(int, input().split()))
 
a_list = [n for n in a_list if n!=1]  
#print(a_list)
ans=1

if 0 in a_list:
  ans=0
elif len(a_list)>56:
  ans=-1
else:
  for i in a_list:
    ans=ans*i
  if ans>1000000000000000000:
      ans=-1
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n= map(int, input().split())
a_list = list(map(int, input().split()))

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

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


Fixed submission:
n= int(input())
a_list = list(map(int, input().split()))
 
a_list = [n for n in a_list if n!=1]  
#print(a_list)
ans=1

if 0 in a_list:
  ans=0
elif len(a_list)>56:
  ans=-1
else:
  for i in a_list:
    ans=ans*i
  if ans>1000000000000000000:
      ans=-1
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a_list=[]
for i in range(n):
  a = int(input())
  a_list.append(a)

for i in range(n):
  print(max(a_list[:i]+a_list[i+1:]))



Fixed submission:
n = int(input())

a_list=[]
for i in range(n):
  a = int(input())
  a_list.append(a)

saidai1=max(a_list)
saidai1_index=a_list.index(saidai1)
saidai2=max(a_list[:saidai1_index]+a_list[saidai1_index+1:])

for i in range(n):
  if a_list[i]==saidai1:
    print(saidai2)
  else:
    print(saidai1)