Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
yon = 0
for i in range(N):
    yon = K + A.count(i+1) - Q
    if yon > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
n = [K - Q] * N
for i in range(Q):
    n[A[i]-1] += 1
for i in range(N):
    if n[i] > 0:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
p = [K] * N
for i in range(N):
    p[i] += A.count(i+1) - Q
    if p[i] > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
n = [K - Q] * N
for i in range(Q):
    n[A[i]-1] += 1
for i in range(N):
    if n[i] > 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

for i in range(M):
    A[N-1] //= 2
    A.sort()

print(sum(A))

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
# ヒープキューを使用するために、符号を反転
a = list(map(lambda x: x*(-1), A))
heapq.heapify(a)

tmp = 0
for i in range(M):
    # 商を求める際に一旦、正の数に変換
    tmp = (heapq.heappop(a)*(-1)) // 2
    # 負の数に変換して元に戻す
    heapq.heappush(a, -tmp)

print(sum(a)*(-1))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
h = list(map(int, input().split()))
h.append(1000000001)
max_n = 0
for i in range(N-1):
    add = 0
    count = 0
    while h[i+add] >= h[i+add+1]:
        count += 1
        add += 1
    max_n = max(max_n, count)
print(max_n)

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
h.append(1000000001)
max_n = 0
counter = 0
while counter < N-1:
    add = 0
    count = 0
    while h[counter+add] >= h[counter+add+1]:
        count += 1
        add += 1
    counter += add +1
    max_n = max(max_n, count)
print(max_n)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
sum = 0
for i in range(1, N):
    sum += i
print(sum)

Fixed submission:
N = int(input())
print((N-1)*N//2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for _ in range(n)]
ss = [''.join(sorted(s_tmp)) for s_tmp in s]
count = 0
for i in range(n-1):
    k = 1
    while i+k <= n-1:
        if ss[i] == ss[i+k]:
            count += 1
        k += 1
print(count)

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
ss = [''.join(sorted(s_tmp)) for s_tmp in s]
ss.sort()
count = 1
ans = 0
for i in range(n-1):
    if ss[i] == ss[i+1]:
        count += 1
    else:
        ans += int((count*(count-1))/2)
        count = 1
ans += int((count*(count-1))/2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    s.append(list(input()))
    s[i].sort()
sa = []
for i in range(n):
    s[i].sort()
    tmp = ''
    for j in range(10):
        tmp += s[i][j]
    sa.append(tmp)
count = 0
for i in range(n-1):
    k = 1
    while i+k <= n-1:
        if sa[i] == sa[i+k]:
            count += 1
        k += 1
print(count)

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
ss = [''.join(sorted(s_tmp)) for s_tmp in s]
ss.sort()
count = 1
ans = 0
for i in range(n-1):
    if ss[i] == ss[i+1]:
        count += 1
    else:
        ans += int((count*(count-1))/2)
        count = 1
ans += int((count*(count-1))/2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))
tmp = 0
idx = 0
while idx < N:
    tmp, a[idx] = a[idx], tmp
    print(max(a))
    tmp, a[idx] = a[idx], tmp
    idx += 1


Fixed submission:
N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))
a_sorted = sorted(a)
max_a = a_sorted.pop()
second_a = a_sorted.pop()
if max_a == second_a:
    for _ in range(N):
        print(max_a)
else:
    idx = 0
    while idx < N:
        if a[idx] == max_a:
            print(second_a)
        else:
            print(max_a)
        idx += 1
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (N + 1)
for i in range(N, N//2, -1):
    b[i] = a[i]
for i in range(N//2, 0, -1):
    sum = 0
    for j in range(i+i, N, i):
        sum += b[j]
    b[i] = (a[i] + sum)%2
b = np.array(b)
if len(np.where(b==1)) != 0:
    print(len(np.where(b==1)[0]))
    ans = ' '.join(map(str, np.where(b == 1)[0]))
    print(ans)
else:
    print(0)

Fixed submission:
N = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (N + 1)
c = []
for i in range(N, 0, -1):
    sum_i = 0
    for j in range(i+i, N+1, i):
        sum_i += b[j]
    b[i] = (a[i] + sum_i)%2
print(sum(b))
for k in range(N+1):
    if b[k] == 1:
        c.append(k)
if c != []:
    print(' '.join(map(str, c)))
Buggy python submission (verdict: Runtime Error):
import math

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

def P(n, k):
    return math.factorial(n)//math.factorial(n-k)

def C(n, k):
    return P(n, k)//math.factorial(k)

for i in range(1, K+1):
    print(((C(N-K+1, i)%mod)*(C(K-1, i-1)%mod))%mod)


Fixed submission:
import math

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

# 順列(Permutation)を求める関数
def P(n, k):
    return math.factorial(n)//math.factorial(n-k)
    
# 組合せ(Combination)を求める関数
def C(n, k):
    return P(n, k)//math.factorial(k)
   
for i in range(1, K+1):
    if (N-K+1 < i) or (K-1 < i-1):
        print(0)
    else:
        print(((C(N-K+1, i)%mod)*(C(K-1, i-1)%mod))%mod)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
lr = [[0, 0] for _ in range(Q)]
for i in range(Q):
    l, r = map(int, input().split())
    lr[i][0] = l-1
    lr[i][1] = r-1

for i in range(Q):
    ans = 0
    for j in range(lr[i][0], lr[i][1]):
        if S[j] == 'A' and S[j+1] == 'C':
            ans += 1
    print(ans)

Fixed submission:
N, Q = map(int, input().split())
S = input()
Si = [0]*(N+1)
for i in range(1, N):
    if S[i-1] == 'A' and S[i] == 'C':
        Si[i+1] = Si[i] + 1
    else:
        Si[i+1] = Si[i]
for _ in range(Q):
    l, r = map(int, input().split())
    print(Si[r]-Si[l])
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
N = int(input())
a = list(map(int, input().split()))
print(reduce(math.gcd, a))

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

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)


if N == 1:
    print(x[0])
else:
    num = gcd(x[0], x[1])
    if N == 2:
        print(num)
    else:
        for i in range(2, N):
            num = gcd(num, x[i])
        print(num)
Buggy python submission (verdict: Runtime Error):
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]

for i in range(101):  # x座標
    for j in range(101):  # y座標
        tmp_h = abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
        cnt = 0
        for k in range(N):
            if xyh[k][2] == max(0,tmp_h-abs(xyh[k][0]-i)-abs(xyh[k][1]-j)):
                cnt += 1
        if cnt == N:
            ans_x = i
            ans_y = j
            ans_h = tmp_h
            break
print(ans_x, ans_y, ans_h)

Fixed submission:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]

for i in range(N):
    if xyh[i][2] != 0:
        x = xyh[i][0]
        y = xyh[i][1]
        h = xyh[i][2]

for i in range(101):  # x座標
    for j in range(101):  # y座標
        tmp_h = abs(x-i)+abs(y-j)+h
        cnt = 0
        for k in range(N):
            if xyh[k][2] == max(0,tmp_h-abs(xyh[k][0]-i)-abs(xyh[k][1]-j)):
                cnt += 1
        if cnt == N:
            ans_x = i
            ans_y = j
            ans_h = tmp_h
            break
print(ans_x, ans_y, ans_h)

Buggy python submission (verdict: Runtime Error):
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]

for i in range(101):  # x座標
    for j in range(101):  # y座標
        tmp_h = abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
        cnt = 0
        for k in range(N):
            if tmp_h == abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]:
                cnt += 1
        if cnt == N:
            ans_x = i
            ans_y = j
            ans_h = tmp_h
            break
print(ans_x, ans_y, ans_h)
            

Fixed submission:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]

for i in range(N):
    if xyh[i][2] != 0:
        x = xyh[i][0]
        y = xyh[i][1]
        h = xyh[i][2]

for i in range(101):  # x座標
    for j in range(101):  # y座標
        tmp_h = abs(x-i)+abs(y-j)+h
        cnt = 0
        for k in range(N):
            if xyh[k][2] == max(0,tmp_h-abs(xyh[k][0]-i)-abs(xyh[k][1]-j)):
                cnt += 1
        if cnt == N:
            ans_x = i
            ans_y = j
            ans_h = tmp_h
            break
print(ans_x, ans_y, ans_h)
Buggy python submission (verdict: Runtime Error):
N = int(input())
t0, x0, y0 = map(int, input().split())
flag = True
if (x0+y0)%2 != t0%2 or x0+y0 > t0:
    flag = False
else:
    for _ in range(N-1):
        t1, x1, y1 = map(int, input().split())
        if (x1+y1-x0-y0)%2 != (t1-t0)%2 or (x1+y1-x0-y0) > t1-t0:
            flag = False
            brake
        else:
            t0, x0, y0 = t1, x1, y1
if flag:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())
t0, x0, y0 = map(int, input().split())
flag = True
if (x0+y0)%2 != t0%2 or x0+y0 > t0:
    flag = False
for _ in range(N-1):
    t1, x1, y1 = map(int, input().split())
    if (x1+y1-x0-y0)%2 != (t1-t0)%2 or (x1+y1-x0-y0) > t1-t0:
        flag = False
    t0, x0, y0 = t1, x1, y1
if flag:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
T = [int(input()) for _ in range(N)]

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)


def lcm(a, b):
    return a * b // gcd(a, b)

ans = T[1]
for i in range(N):
    ans = lcm(ans, T[i])
print(ans)

Fixed submission:
N = int(input())
if N == 1:
    T = [int(input())]
else:
    T = [int(input()) for _ in range(N)]

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)


def lcm(a, b):
    return a * b // gcd(a, b)

ans = T[0]
for i in range(N):
    ans = lcm(ans, T[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N = int(input())
edge = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    edge[a].append([b, c])
    edge[b].append([a, c])


def BFS(x, y):
    visited = [False for _ in range(N+1)]
    next_N = [False for _ in range(N+1)]
    INF = float('inf')
    dest = [INF for _ in range(N+1)]
    d = deque()
    visited[x] = True
    dest[x] = 0
    for B, C in edge[x]:
        d.append([B, C])
        next_N[B] = True
        dest[B] = dest[x] + C
    while d:
        now = d.popleft()
        visited[now[0]] = True
        for B, C in edge[now[0]]:
            if visited[B] == False and next_N[B] == False:
                d.append([B, C])
                next_N[B] = True
                dest[B] = dest[now[0]] + C
    return dest[y]

Q, K = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(Q)]
for X, Y in xy:
    print(BFS(X, K) + BFS(K, Y))


Fixed submission:
from collections import deque
N = int(input())
edge = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    edge[a].append([b, c])
    edge[b].append([a, c])


def BFS(x):
    visited = [False for _ in range(N+1)]
    next_N = [False for _ in range(N+1)]
    INF = float('inf')
    dest = [INF for _ in range(N+1)]
    d = deque()
    visited[x] = True
    dest[x] = 0
    for B, C in edge[x]:
        d.append([B, C])
        next_N[B] = True
        dest[B] = dest[x] + C
    while d:
        now = d.popleft()
        visited[now[0]] = True
        for B, C in edge[now[0]]:
            if visited[B] == False and next_N[B] == False:
                d.append([B, C])
                next_N[B] = True
                dest[B] = dest[now[0]] + C
    return dest

Q, K = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(Q)]
DEST = BFS(K)
for X, Y in xy:
    print(DEST[X] + DEST[Y])
Buggy python submission (verdict: Runtime Error):
N = int(input())
T, A = map(int, input().split())
for i in range(N-1):
    t, a = map(int, input().split())
    n = max(-(-T//t), -(-A//a))
    T, A = n * t, n, * a
print(T+A)

Fixed submission:
N = int(input())
T, A = map(int, input().split())
for i in range(N-1):
    t, a = map(int, input().split())
    n = max(-(-T//t), -(-A//a))
    T, A = n * t, n * a
print(T+A)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
d = list(map(int, input().split()))
a = []
for i in range(10):
    if d.count(i) == 0:
        a.append(i)
ans = []
def dfs(s):
    if int(s) >= N or len(s) > len(str(N)):
        return s
    for i in a:
        S = dfs(s + str(i))
        if int(S) >= N:
            ans.append(int(S))
    return s
    
dfs('0')
print(min(ans))

Fixed submission:
N, K = map(int, input().split())
d = list(map(int, input().split()))
a = []
for i in range(10):
    if d.count(i) == 0:
        a.append(i)
ans = []
def dfs(s):
    if int(s) >= N or len(s) > 6:
        return s
    for i in a:
        S = dfs(s + str(i))
        if int(S) >= N:
            ans.append(int(S))
    return s
    
dfs('0')
print(min(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt=0
for _ in range(n):
    a,b=map(int,input()split())
    if a==b:
        cnt+=1
        if cnt>=3:
            break
    else:
        cnt=0
if cnt>=3:
    print("Yes")
else:
    print("No")

Fixed submission:
n = int(input())
cnt=0
for _ in range(n):
    a,b=map(int,input().split())
    if a==b:
        cnt+=1
        if cnt>=3:
            break
    else:
        cnt=0
if cnt>=3:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans=0
for i in range(1,n):
    ans+=int(cnt-1)
print(ans)

Fixed submission:
n = int(input())
ans=0
for i in range(1,n):
    ans+=int((n-1)/i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())
ans=0
for i in range(1,n):
    ans+=len(make_divisors(n-i))
print(ans)

Fixed submission:
n = int(input())
ans=0
for i in range(1,n):
    ans+=int((n-1)/i)
print(ans)

Buggy python submission (verdict: Runtime Error):
import sympy

Fixed submission:
n = int(input())
ans=0
for i in range(1,n):
    ans+=int((n-1)/i)
print(ans)

Buggy python submission (verdict: Runtime Error):
import sympy
n = int(input())
ans=0
for i in range(1,n):
    ans+=len(sympy.divisors(n-i))
print(ans)

Fixed submission:
n = int(input())
ans=0
for i in range(1,n):
    ans+=int((n-1)/i)
print(ans)
Buggy python submission (verdict: Runtime Error):
d,t.s = map(int,input().split())
a = d/s
if t>=a:
    print("Yes")
else:
    print("No")

Fixed submission:
d,t,s = map(int,input().split())
a = d/s
if t>=a:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
import itertools
ans = 0
for i in itertools.combinations(a, 2):
    ans += i[0]*i[1]
    ans%=10**9+7
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
gou = sum(a)
ans = 0
for i in range(n):
    gou-=a[i]
    ans+=a[i]*(gou)
ans%=10**9+7
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=1
for i in range(k):
    s*=a[i]
for i in range(n-k):
    ns=(s/a[i])*a[i+k]
    if ns>s:
        print("Yes")
    else:
        print("No")
    s=ns

Fixed submission:
import numpy as np
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(0,n-k):
    if a[i]<a[i+k]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a[0:k])
for i in range(1,n-k+1):
    ns=sum(a[i:k+i])
    if ns>s:
        print("Yes")
    else:
        print("No")
    s=ns

Fixed submission:
import numpy as np
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(0,n-k):
    if a[i]<a[i+k]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
print((n//1000+1)*1000-n))

Fixed submission:
n = int(input())
if n%1000==0:
    print(0)
else:
    print((n//1000+1)*1000-n)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import sympy
n=int(input())
a=[(sympy.divisor_count(i)*i) for i in range(1,n+1)]
print(np.sum(a))

Fixed submission:
n = int(input())
ans=0
for i in range(1,n+1):
    a=n//i
    ans+=i*a*(a+1)/2
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
A = list(map(int,input().split()))
q = int(input())
B = []
C = []
for _ in range(q):
    b,c = map(int,input().split())
    A = [c if a == b else a for a in A]
    print(np.sum(A))

Fixed submission:
import numpy as np
n = int(input())
A = list(map(int,input().split()))
q = int(input())
ar = np.zeros(10**5+1)
for i in A:
    ar[i] += 1
ans = np.sum(A) 
for _ in range(q):
    b,c = map(int,input().split())
    ans = ans+ar[b]*(c-b)
    ar[c] += ar[b]
    ar[b] = 0
    print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
A = list(map(int,input().split()))
q = int(input())
B = []
C = []
for _ in range(q):
    b,c = map(int,input().split())
    A = [c if a == b else a for a in A]
    print(sum(A))

Fixed submission:
import numpy as np
n = int(input())
A = list(map(int,input().split()))
q = int(input())
ar = np.zeros(10**5+1)
for i in A:
    ar[i] += 1
ans = np.sum(A) 
for _ in range(q):
    b,c = map(int,input().split())
    ans = ans+ar[b]*(c-b)
    ar[c] += ar[b]
    ar[b] = 0
    print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
A = list(map(int,input().split()))
q = int(input())
B = []
C = []
for _ in range(q):
    b,c = map(int,input().split())
    B.append(b)
    C.append(c)
B = np.array(B)
C = np.array(C)
for i in range(q):
    A = [C[i] if a == B[i] else a for a in A]
    print(sum(A))

Fixed submission:
import numpy as np
n = int(input())
A = list(map(int,input().split()))
q = int(input())
ar = np.zeros(10**5+1)
for i in A:
    ar[i] += 1
ans = np.sum(A) 
for _ in range(q):
    b,c = map(int,input().split())
    ans = ans+ar[b]*(c-b)
    ar[c] += ar[b]
    ar[b] = 0
    print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
A = list(map(int,input().split()))
q = int(input())
B = []
C = []
for _ in range(q):
    b,c = map(int,input().split())
    B.append(b)
    C.append(c)

for i in range(q):
    A = [C[i] if a == B[i] else a for a in A]
    print(sum(A))
    

Fixed submission:
import numpy as np
n = int(input())
A = list(map(int,input().split()))
q = int(input())
ar = np.zeros(10**5+1)
for i in A:
    ar[i] += 1
ans = np.sum(A) 
for _ in range(q):
    b,c = map(int,input().split())
    ans = ans+ar[b]*(c-b)
    ar[c] += ar[b]
    ar[b] = 0
    print(int(ans))
Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
ans=10000

for i in range(1,101):
    if (i in p):
        continue
    else:
        tmp=(x-i)**2
        if tmp<ans:
            ans=tmp
            c=i
print(c)

Fixed submission:
x,n=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
ans=10001

for i in range(0,102):
    if (i in p):
        continue
    else:
        tmp=(x-i)**2
        if tmp<ans:
            ans=tmp
            c=i
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    ans=ans*a[i]
if ans<=(10**18):
    print(ans)
else:
    print(-1)

Fixed submission:
n= int(input())
a=list(map(int,input().split()))
a.sort()
ans=1
for i in a:
    ans=ans*i
    if ans>(10**18):
        print(-1)
        break
    elif ans==0:
        print(ans)
        break
if ans<=(10**18)and ans!=0:
    print(ans)

Buggy python submission (verdict: Runtime Error):
n= int(input())
a=list(map(int,input().split()))
a=np.array(a)
ans=1
for i in range(n):
    ans=ans*a[i]
if ans<=(10**18):
    print(ans)
else:
    print(-1)

Fixed submission:
n= int(input())
a=list(map(int,input().split()))
a.sort()
ans=1
for i in a:
    ans=ans*i
    if ans>(10**18):
        print(-1)
        break
    elif ans==0:
        print(ans)
        break
if ans<=(10**18)and ans!=0:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a=[]
n= int(input())
a=list(map(int,input().split()))
ans=1
for i in (a):
    ans=ans*i

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

Fixed submission:
n= int(input())
a=list(map(int,input().split()))
a.sort()
ans=1
for i in a:
    ans=ans*i
    if ans>(10**18):
        print(-1)
        break
    elif ans==0:
        print(ans)
        break
if ans<=(10**18)and ans!=0:
    print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=input().split()
a=int(a)
b=int(100*b)
print((a*b)/100)

Fixed submission:
a,b=input().split()
a=int(a)
b=(100*float(b)+0.05)
print(a*int(b)//100)
Buggy python submission (verdict: Runtime Error):
s=input()
if s==ABC:
  print("ARC")
else:
  print("ABC")
   

Fixed submission:
s=input()
if s=="ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = []
cnt = 0
for i in range(n):
    s = input()
    if not s in ans:
        ans.append(s)
        cnt+=1
print(cnt)

Fixed submission:
n = int(input())
ans = []
cnt = 1
for i in range(n):
    s = input()
    ans.append(s)
ans.sort()
for i in range(n-1):
    if ans[i]!=ans[i+1]:
        cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
s = n*[0]
for i in a:
    s[i]+=1
for i in range(0,n):
    s[a[i]]-=1
    ans=max(s)*(max(s)-1)/2
    s[a[i]]+=1
    print(int(ans))

Fixed submission:
import numpy as np
n = int(input())
a = list(map(int,input().split()))
s = np.zeros(n+1)
for i in a:
    s[i]+=1
al = sum((s*(s-1))/2)
for i in range(n):
    ans=al-(s[a[i]]-1)
    print(int(ans))
Buggy python submission (verdict: Runtime Error):
import numpy as np
import copy
n,k=map(int,input().split())
p=list(map(int,input().split()))
p = np.array(p)
s = copy.deepcopy(p)
P = np.empty((k-1, n))
for i in range(k-1):
    P[i] = np.roll(p,(-i-1))
    s = s+P[i]
    s[-i-1] = 0
s.sort()
ans = (s[-1]/2)+0.5*k
print(ans)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
s=[(i+1)/2 for i in p]
cans=sum(s[:k])
ans=cans
for i in range(n-k):
    cans=cans-s[i]+s[i+k]
    ans=max(ans,cans)
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()

print(t+s)

Fixed submission:
s,t=input().split()

print(t+s)