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

# (sx, sy) から (gx, gy) への最短距離を求める
# 辿り着けないと INF
def bfs(sx, gx, sy, gy):
    # すべての点を INF で初期化
    d = [[float("inf")] * m for i in range(n)]

    # 移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    # スタート地点をキューに入れ、その点の距離を0にする
    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    # キューが空になるまでループ
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # 取り出してきた状態がゴールなら探索をやめる
        if p[0] == gx and p[1] == gy:
            break
        # 移動4方向をループ
        for i in range(4):
            # 移動した後の点を (nx, ny) とする
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            # 移動が可能かの判定とすでに訪れたことがあるかの判定
            # d[nx][ny] != INF なら訪れたことがある
            if 0 <= nx < n and 0 <= ny < m and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                # 移動できるならキューに入れ、その点の距離を p からの距離 +1 で確定する
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1

    return d[gx][gy]

n, m = map(int, input().split())
maze = [list(input()) for i in range(n)]
ans = 1

for x in range(n):
    for y in range(m):
        sx = x
        sy = y
        for i in range(n):
            for j in range(m):
                gx = i
                gy = j
                if sx == gx and sy == gy:
                    continue
                if maze[sx][sy] == "#" or maze[gx][gy] == "#":
                    continue
                A = bfs(sx, gx, sy, gy)
                ans = max(A, ans)
print(ans)

Fixed submission:
from collections import deque
import numpy as np

# (sx, sy) から (gx, gy) への最短距離を求める
# 辿り着けないと INF
def bfs(sx, sy):
    # すべての点を INF で初期化
    d = [[float("-inf")] * m for i in range(n)]

    # 移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    # スタート地点をキューに入れ、その点の距離を0にする
    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    # キューが空になるまでループ
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # 取り出してきた状態がゴールなら探索をやめる
        #if p[0] == gx and p[1] == gy:
        #    break
        # 移動4方向をループ
        for i in range(4):
            # 移動した後の点を (nx, ny) とする
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            # 移動が可能かの判定とすでに訪れたことがあるかの判定
            # d[nx][ny] != INF なら訪れたことがある
            if 0 <= nx < n and 0 <= ny < m and maze[nx][ny] != "#" and d[nx][ny] == float("-inf"):
                # 移動できるならキューに入れ、その点の距離を p からの距離 +1 で確定する
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1

    a = np.max(d) 
    return a

n, m = map(int, input().split())
maze = [list(input()) for i in range(n)]
ans = 1

for x in range(n):
    for y in range(m):
        sx = x
        sy = y
        if maze[sx][sy] == "#":
            continue
        A = bfs(sx, sy)
        ans = max(A, ans)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(A,B))

Fixed submission:
A = int(input())
B = int(input())

if (A == 1 and B == 2) or (A == 2 and B == 1):
    print(3)

if (A == 1 and B == 3) or (A == 3 and B == 1):
    print(2)

if (A == 3 and B == 2) or (A == 2 and B == 3):
    print(1)
Buggy python submission (verdict: Runtime Error):
import math

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

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

print(lcm(A,B))

Fixed submission:
import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(A,B))
Buggy python submission (verdict: Runtime Error):
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    table = sorted(table)
    return table

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

A_list = set(divisor(A))
B_list = set(divisor(B))

list = A_list & B_list

cnt = 1

for i in list:
    if is_prime(i):
        cnt += 1

print(cnt)

Fixed submission:
import numpy as np

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    table = sorted(table)
    return table

def make_prime(U):
    is_prime = np.zeros(U,np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5)+1
    for p in range(3,M,2):
        if is_prime[p]:
            is_prime[p*p::p+p] = 0
    return is_prime, is_prime.nonzero()[0]
A, B = map(int, input().split())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

A_list = set(divisor(A))
B_list = set(divisor(B))

list = A_list & B_list

#_, primes = make_prime(10**8)

cnt = 1

for i in list:
    if is_prime(i):
        cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    table = sorted(table)
    return table

def make_prime(U):
    is_prime = np.zeros(U,np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5)+1
    for p in range(3,M,2):
        if is_prime[p]:
            is_prime[p*p::p+p] = 0
    return is_prime, is_prime.nonzero()[0]
A, B = map(int, input().split())

A_list = set(divisor(A))
B_list = set(divisor(B))

list = A_list & B_list

_, primes = make_prime(10**9)

cnt = 1

for i in list:
    if i in primes:
        cnt += 1

print(cnt)

Fixed submission:
import numpy as np

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    table = sorted(table)
    return table

def make_prime(U):
    is_prime = np.zeros(U,np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5)+1
    for p in range(3,M,2):
        if is_prime[p]:
            is_prime[p*p::p+p] = 0
    return is_prime, is_prime.nonzero()[0]
A, B = map(int, input().split())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

A_list = set(divisor(A))
B_list = set(divisor(B))

list = A_list & B_list

#_, primes = make_prime(10**8)

cnt = 1

for i in list:
    if is_prime(i):
        cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
r = 10 ** 9 + 7
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0] * (N+1)
a = sorted(set(a))

if 1 in a:
    dp[1] = 0
    del a[0]
else:
    dp[1] = 1

if 2 in a:
    dp[2] = 0
    del a[0]
else:
    dp[2] = dp[1] + 1

if N == 1 or N == 2:
    print(dp[N])
    exit()

for i in range(1,N-1):
    if a == [] :
        dp[i+2] = (dp[i] + dp[i+1]) % r
    elif i+2 == a[0]:
        dp[i+2] = 0
        del a[0]
    else:
        dp[i+2] = (dp[i] + dp[i+1]) % r

print(dp[N])

Fixed submission:
r = 10 ** 9 + 7
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0] * (N+1)
a = sorted(set(a))

if 1 in a:
    dp[1] = 0
    del a[0]
else:
    dp[1] = 1

if N == 1:
    print(dp[1])
    exit()

if 2 in a:
    dp[2] = 0
    del a[0]
else:
    dp[2] = dp[1] + 1

if N == 2:
    print(dp[2])
    exit()

for i in range(1,N-1):
    if a == [] :
        dp[i+2] = (dp[i] + dp[i+1]) % r
    elif i+2 == a[0]:
        dp[i+2] = 0
        del a[0]
    else:
        dp[i+2] = (dp[i] + dp[i+1]) % r

print(dp[N])

Buggy python submission (verdict: Runtime Error):
r = 10 ** 9 + 7
N, M = map(int, input().split())
a = [input() for _ in range(M)]
dp = [0] * (N+1)

if str(1) in a:
    dp[1] = 0
else:
    dp[1] = 1

if str(2) in a:
    dp[2] = 0
else:
    dp[2] = dp[1] + 1

for i in range(1,N-1):
    if str(i+2) in a:
        dp[i+2] = 0
    else:
        dp[i+2] = (dp[i] + dp[i+1]) % r

print(dp[N])

Fixed submission:
r = 10 ** 9 + 7
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0] * (N+1)
a = sorted(set(a))

if 1 in a:
    dp[1] = 0
    del a[0]
else:
    dp[1] = 1

if N == 1:
    print(dp[1])
    exit()

if 2 in a:
    dp[2] = 0
    del a[0]
else:
    dp[2] = dp[1] + 1

if N == 2:
    print(dp[2])
    exit()

for i in range(1,N-1):
    if a == [] :
        dp[i+2] = (dp[i] + dp[i+1]) % r
    elif i+2 == a[0]:
        dp[i+2] = 0
        del a[0]
    else:
        dp[i+2] = (dp[i] + dp[i+1]) % r

print(dp[N])
Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())

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

print(-1,-1,-1)

Fixed submission:
S = input()
S_2 = S.replace("2017","2018")
print(S_2)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
li = []
ans = 0

B = set(A)

cnt = len(B)

for x in B:
    a = A.count(x)
    li.append(a)

li = sorted(li)

if cnt - K > 0:
    for x in range(cnt - K):
        ans += li[x]
    print(ans)

else :
    print(ans)

Fixed submission:
s = list(input())

#print(s)

x = s.count("1")

print(x)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
li = []
ans = 0

B = set(A)

cnt = len(B)

for x in B:
    a = A.count(x)
    li.append(a)

li = sorted(li)

if cnt - K > 0:
    for x in range(cnt - K):
        ans += li[x]
    print(ans)

else :
    print(ans)

Fixed submission:
import sys
import collections

input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
li = []
ans = 0

B = set(A)

cnt = len(B)

#for x in B:
#    a = A.count(x)
#    li.append(a)

li = list(collections.Counter(A).values())
li = sorted(li)

if cnt - K > 0:
    for x in range(cnt - K):
        ans += li[x]
    print(ans)

else :
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
li = []
ans = 0

B = set(A)

cnt = len(B)

for x in B:
    a = A.count(x)
    li.append(a)

li = sorted(li)

if cnt - K > 0:
    for x in range(cnt - K):
        ans += li[x]
    print(ans)

else :
    print(ans)

Fixed submission:
import sys
import collections

input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
li = []
ans = 0

B = set(A)

cnt = len(B)

#for x in B:
#    a = A.count(x)
#    li.append(a)

li = list(collections.Counter(A).values())
li = sorted(li)

if cnt - K > 0:
    for x in range(cnt - K):
        ans += li[x]
    print(ans)

else :
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
li = []
ans = 0

B = set(A)

cnt = len(B)

for x in B:
    a = A.count(x)
    li.append(a)

li = sorted(li)

if cnt - K > 0:
    for x in range(cnt - K):
        ans += li[x]
    print(ans)

else :
    print(0)

Fixed submission:
import sys
import collections

input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
li = []
ans = 0

B = set(A)

cnt = len(B)

#for x in B:
#    a = A.count(x)
#    li.append(a)

li = list(collections.Counter(A).values())
li = sorted(li)

if cnt - K > 0:
    for x in range(cnt - K):
        ans += li[x]
    print(ans)

else :
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
li = []
ans = 0

B = set(A)

cnt = len(B)

for x in B:
    a = A.count(x)
    li.append(a)

li = sorted(li)

if cnt - K > 0:
    for x in range(cnt - K):
        ans += li[x]
    print(ans)

else :
    print(0)

Fixed submission:
import sys
import collections

input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
li = []
ans = 0

B = set(A)

cnt = len(B)

#for x in B:
#    a = A.count(x)
#    li.append(a)

li = list(collections.Counter(A).values())
li = sorted(li)

if cnt - K > 0:
    for x in range(cnt - K):
        ans += li[x]
    print(ans)

else :
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

ans = 0

for X in range(K+1):
    for Y in range(K+1):
        for Z in range(K+1):
            if X + Y + Z == S:
                ans += 1

print(ans)  

Fixed submission:
K, S = map(int, input().split())

ans = 0

for X in range(K+1):
    for Y in range(K+1):
        Z = S - (X + Y)
        if 0 <= Z <= K:
            ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

ans = 0

for X in range(K+1):
    for Y in range(K+1):
        for Z in range(K+1):
            if X + Y + Z == S:
                ans += 1

print(ans)  

Fixed submission:
K, S = map(int, input().split())

ans = 0

for X in range(K+1):
    for Y in range(K+1):
        Z = S - (X + Y)
        if 0 <= Z <= K:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

a_res = a + (v*t)
b_res = b + (w*t)

if a_res > b_res:

  print("YES")
else:
  print("NO")
  
  


Fixed submission:
name = input()

print(name[:3])
Buggy python submission (verdict: Runtime Error):
input math
a, b = map(float, input().split())
a *= b
print(math.floor(a))

Fixed submission:
from decimal import Decimal
import math
a, b = input().split()
res = Decimal(a) * Decimal(b)
print(math.floor(res))
Buggy python submission (verdict: Runtime Error):
print(input() * 2 * 3.14)

Fixed submission:
import math
print(int(input())*2 * math.pi)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n):
    a[i] = a[i] * a[i-1]
if a[n-1] > 10**18:
    print(-1)
else:
    print(a[n-1])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = 0
for i in range(1, n):
    a[i] = a[i] * a[i-1]
    if a[i] > 10**18:
        b += 1
        break
if 0 in a:
    print(0)
elif b == 1:
    print(-1)
else:
    print(a[n-1])
Buggy python submission (verdict: Runtime Error):
print(N)

S = [input() for i in range(N)]
print(S)

ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    if S[i] == 'AC':
        ac += 1
    elif S[i] == 'WA':
        wa += 1
    elif S[i] == 'TLE':
        tle += 1
    elif S[i] == 'RE':
        re += 1

print('AC x' , ac)
print('WA x' ,wa)
print('TLE x' ,tle)
print('RE x' , re)  

Fixed submission:
N = int(input())
#print(N)

S = [input() for i in range(N)]
#print(S)

ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    if S[i] == 'AC':
        ac += 1
    elif S[i] == 'WA':
        wa += 1
    elif S[i] == 'TLE':
        tle += 1
    elif S[i] == 'RE':
        re += 1

print('AC x' , ac)
print('WA x' ,wa)
print('TLE x' ,tle)
print('RE x' , re)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

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

ans = []
for v in itertools.combinations(p,K):
    ans.append(sum(v))
    
print(min(ans))

Fixed submission:
N,K = map(int,input().split())

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

s = sorted(p)

ans = 0 
for i in range(N):
    ans += s[i]
    if i == K-1:
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
X = input()

ans = []
for i in range(len(X)):
    if X[i] == '?' and X[i-1] != 'P' and X[i+1] != 'P':
        ans.append('P')
    elif X[i] == '?':
        ans.append('D')
    else:
        ans.append(X[i])

for i in ans:
    print(i, end = "")

Fixed submission:
X = input()
ans = []

for i in range(len(X)):
    if X[i] == '?':
        ans.append('D')
    else:
        ans.append(X[i])

for i in ans:
    print(i, end = "")

Buggy python submission (verdict: Runtime Error):
X = input()

ans = []
for i in range(len(X)):
    if X[i] == '?' and X[i-1] != 'P' and X[i+1] != 'P':
        ans.append('P')
    elif X[i] == '?':
        ans.append('D')
    else:
        ans.append(X[i])

print(ans)

for i in ans:
    print(i, end = "")

Fixed submission:
X = input()
ans = []

for i in range(len(X)):
    if X[i] == '?':
        ans.append('D')
    else:
        ans.append(X[i])

for i in ans:
    print(i, end = "")
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
K,N = map(int,(input().split()))
A = list(map(int,(input().split())))

ans = []
for i in range(N):
    if i < N-1:
        ans.append(A[i+1]-A[i])

ans.append(K-A[N-1])

fin = []
for i in itertools.combinations(ans,N-1):
    fin.append(sum(i))
print(min(fin))

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

ans = []
for i in range(N-1):
    ans.append(A[i+1]-A[i])

ans.append(K-A[N-1]+A[0])
print(K-(max(ans)))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
K,N = map(int,(input().split()))
A = list(map(int,(input().split())))

ans = []
for i in range(N):
    if i < N-1:
        ans.append(A[i+1]-A[i])
ans.append(K-A[N-1])

c = list(itertools.combinations(ans,N-1))

a = []
for i in range(len(c)):
    a.append(sum(c[i]))
print(min(a))

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

ans = []
for i in range(N-1):
    ans.append(A[i+1]-A[i])

ans.append(K-A[N-1]+A[0])
print(K-(max(ans)))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
S = [input() for i in range(N)]

#重複チェック
dup = [x for x in set(S) if S.count(x) > 1]
l = len(dup)

if not dup:
    ans = sorted(S)
    for i in ans:
        print(i)
else:
    c = collections.Counter(S)
    value,count = zip(*c.most_common(l))

    if len(set(count)) == 1:
        s = sorted(value)
        for i in s:
            print(i)
    else:
        for i in value:
            print(i)
            exit()

Fixed submission:
import collections
N = int(input())
S = [input() for i in range(N)]

c = collections.Counter(S)
value,count = zip(*c.most_common())

s = sorted(value)
ans = []
if len(set(count)) == 1 :
    for i in s:
        print(i)
else: 
    for i in range(len(value)):
        ans.append(value[i])
        if count[i] > count[i+1]:
            [print(i) for i in sorted(ans)]
            exit()
Buggy python submission (verdict: Runtime Error):
N = int(input())
#print(N)

S = input()

count = 0
for i in range(N):
    #print(S[i] , i)
    if i == 0:
        if S[i+1] != S[i]:
            count += 1
    elif i == N-1:
        if S[i-1] != S[i]:
            count += 1
    else:
        if S[i+1] != S[i]:
            count += 1

if count == 0:
    print(1)
else:
    print(count)

Fixed submission:
N = int(input())
#print(N)

S = input()

count = 0
for i in range(N):
    #print(S[i] , i)
    if i == N-1:
        break
    else:
        if S[i+1] != S[i]:
            count += 1

if count == 0:
    print(1)
else:
    print(count+1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
tmp = [tuple(map(int,input().split())) for i in range(N)]

ct = 0
cx = 0
cy = 0
for t,x,y in tmp:
    dst = abs(cx - x) + abs(cy - y)
    if dst > t-ct or dst%2 != (t-ct)%2:
        print('No')
        exit()
    ct,cx,cy = t,x,y

print('Yes')

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

if (a*b)%2 == 0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in xrange(1, n + 1):
        for j in xrange(i, n + 1, i):
            table[j] += 1
    
    return table
  
n = int(input())  
a =  num_divisors_table(n)
ans = 0
for i in range(n+1):
  ans += i*a[i]
print(ans)  

Fixed submission:
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in xrange(1, n + 1):
        for j in xrange(i, n + 1, i):
            table[j] += 1
    
    return table
  
n = int(input())  
a =  num_divisors_table(n)
ans = 0
for i in range(n+1):
  ans += i*a[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(float,input().split()))


for i in range(N):
 if(i == 0): ans = A[i]
 else: ans = ans*A[i]
  
ans = '{:.19g}'.format(ans)  
if((len(ans)>=2)and(ans[1] == 'e')):
  print('-1')
else:
  print(ans)
    

Fixed submission:
a,b = map(int,input().split())
print(a*b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

ans = 1
j = 0
for a in A:
  ans = ans*a
  if(a == 0):
    j -= 100 
    break
  if(ans > 10**18):
    j = 1
    
if(j <= 0):
  print(ans)
else:
  print(-1)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
         
if(0 in A):
  ans = 0 
else:
  ans = 1       
  for a in A:
    ans *= a
    if(ans > 10**18):
      ans = -1
      break
    if(len(str(ans))>=2):
     if(str(ans)[1] == 'e'):
      ans = -1
      break
         
print(ans)

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

ans = 1
j = 0
for a in A:
  ans = ans*a
  if(ans > 10**18):
    j = 1
    
if((j == 0)or(ans == 0)):
  print(ans)
else:
  print(-1)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
         
if(0 in A):
  ans = 0 
else:
  ans = 1       
  for a in A:
    ans *= a
    if(ans > 10**18):
      ans = -1
      break
    if(len(str(ans))>=2):
     if(str(ans)[1] == 'e'):
      ans = -1
      break
         
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(float,input().split()))


for i in range(N):
 if(i == 0): ans = A[i]
 else: ans = ans*A[i]
  
ans = '{:.19g}'.format(ans)  
if(ans[1] == 'e'):
  print('-1')
else:
  print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
         
if(0 in A):
  ans = 0 
else:
  ans = 1       
  for a in A:
    ans *= a
    if(ans > 10**18):
      ans = -1
      break
    if(len(str(ans))>=2):
     if(str(ans)[1] == 'e'):
      ans = -1
      break
         
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
if(s=='ARC'):
  print('ABC')
else:
  print('ARC')

Fixed submission:
s = input()
if(s=='ARC'):
  print('ABC')
else:
  print('ARC')
Buggy python submission (verdict: Runtime Error):
X = int(input())

for A in range(-10,100+1):
  for B in range(-10,100+1):
    if(A**5 - B**5 == X):
      ans = [A,B] 
      
print(ans[0],ans[1])    

Fixed submission:
X = int(input())

for A in range(0,10**3):
 for B in range(0,10**3):
  A1,A2,B1,B2 = A,-A,B,-B
  if(A1**5-B1**5 == X):
    ans = [A1,B1]
    break
  elif(A1**5-B2**5 == X):
    ans = [A1,B2]
    break
  elif(A2**5-B1**5 == X):
    ans = [A2,B1]
    break  
  elif(A2**5-B2**5 == X):
    ans = [A2,B2]
    break    
            
print(ans[0],ans[1])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N,M,Q = map(int,input().split())

num_all = [i+1 for i in range(M)]
#print(num_all)
Comb = list(itertools.combinations_with_replacement(num_all,N))

num_l = []         
for i in range(Q):
  a,b,c,d = map(int,input().split())
  num_l.append([a,b,c,d])
#print(num_l)  
  
#print(len(Comb))
d_sum_max = 0  
for A in Comb:
  d_sum = 0
  #print(A)
  #print()
  
  for i in range(Q):
    a,b,c,d = num_l[i][0],num_l[i][1],num_l[i][2],num_l[i][3]
    #print(a,b,c,d)
    #print(A[b-1],A[a-1],':',A[b-1]-A[a-1],c)
    if(A[b-1]-A[a-1] == c):
      d_sum += d
      
  #print(A,d_sum)
  d_sum_max = max(d_sum_max,d_sum)

print(d_sum_max)    

Fixed submission:
import itertools
N,M,Q = map(int,input().split())

num_all = [i+1 for i in range(M)]
#print(num_all)
Comb = list(itertools.combinations_with_replacement(num_all,N))

num_l = []         
for i in range(Q):
  a,b,c,d = map(int,input().split())
  num_l.append([a,b,c,d])
#print(num_l)  
  
#print(len(Comb))
d_sum_max = 0  
for A in Comb:
  d_sum = 0
  #print(A)
  #print()
  
  for x in num_l:
    a,b,c,d = x[0],x[1],x[2],x[3]
    #print(a,b,c,d)
    #print(A[b-1],A[a-1],':',A[b-1]-A[a-1],c)
    if(A[b-1]-A[a-1] == c):
      d_sum += d
      
  #print(A,d_sum)
  d_sum_max = max(d_sum_max,d_sum)

print(d_sum_max)