Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
words = [input() for _ in range(N)]

for i, w in enumerate(words):
    if words.count(w) > 1:
        print('No')
        break
    if w[0] != words[i - 1][-1]:
        print('No')
        break
else:
    print('Yes')

Fixed submission:
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
for i in range(X+1, Y+1):
    if i > max(x) and i <= min(y):
        print('No War')
        break
else:
    print('War')
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
for c in range(1, 4):
    if (a * b * c) % 2 != 0:
        print('Yes')
        break
else:
    print('No')


Fixed submission:
a, b = map(int, input().split())
for c in range(1, 4):
    if (a * b * c) % 2 != 0:
        print('Yes')
        break
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
A, B = mpa(int, input(),.split())
for c in range(1, 4):
    if (a * b * c) % 2 != 0:
        print('Yes')
        break
else:
    print('No')

Fixed submission:
a, b = map(int, input().split())
for c in range(1, 4):
    if (a * b * c) % 2 != 0:
        print('Yes')
        break
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = input()

n = int(N)
sn = sum(list(N))

if n % sn == 0:
    print('Yes') 
else:
    print('No')

Fixed submission:
N = input()

n = int(N)
sn = sum(list(map(int, list(N))))

print('Yes' if n % sn == 0 else 'No')

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

n = int(N)
sn = sum(list(N))

print('Yes') if n % sn == 0 else print('No')

Fixed submission:
N = input()

n = int(N)
sn = sum(list(map(int, list(N))))

print('Yes' if n % sn == 0 else 'No')

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

n = int(N)
sn = sum(list(N))

print('Yes' if n % sn == 0 else 'No')

Fixed submission:
N = input()

n = int(N)
sn = sum(list(map(int, list(N))))

print('Yes' if n % sn == 0 else 'No')
Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())
if N = 100:
    N = 101
if D == 0:
    print(N)
elif D == 1:
    print(N * 100)
else:
    print(N * (100 ** 2))

Fixed submission:
D, N = map(int, input().split())
if N == 100:
    N = 101
if D == 0:
    print(N)
elif D == 1:
    print(N * 100)
else:
    print(N * (100 ** 2))
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())

ans = 1
for b in range(1, X + 1):
    for p in range(2, X + 1):
        if b ** p <= X:
            ans = max(ans, b ** p)

print(ans)


Fixed submission:
X = int(input())
b = 1
p = 2
ans = 0
for b in range(1, X + 1):
    for p in range(2, 10):
        if b ** p <= X:
            ans = max(ans, b ** p)

print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
K = int(input())

biggest = max([A, B, C])
print(biggest * 2 ** K + sum(A, B, C) - biggest)

Fixed submission:
A, B, C = map(int, input().split())
K = int(input())

biggest = max(A, B, C)
print(biggest * 2 ** K + sum([A, B, C]) - biggest)

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
K = int(input())

biggest = max(A, B, C)
print(biggest * 2 ** K + sum(A, B, C) - biggest)

Fixed submission:
A, B, C = map(int, input().split())
K = int(input())

biggest = max(A, B, C)
print(biggest * 2 ** K + sum([A, B, C]) - biggest)
Buggy python submission (verdict: Runtime Error):
d = min(m)
print(N + (X - sum(m)) // d)

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


d = min(m)
print(N + (X - sum(m)) // d)
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
L = list(range(A, B + 1))
if len(L) - 2 <= 2 * K:
    for l in L:
        print(l)
else:
    ans = []
    for i in range(K):
        ans.append(L[i])
        ans.append(L[-i - 1])
    for a in sorted(ans):
        print(a)

Fixed submission:
A, B, K = map(int, input().split())
L = []

for i in range(K):
    if A + i > B - i:
        break
    else:
        L.append(A + i)
        L.append(B - i)

L = set(L)
L = sorted(L)

for l in L:
    print(l)

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
L = list(range(A, B + 1))
if len(L) <= 2 * K:
    for l in L:
        print(l)
else:
    ans = []
    for i in range(K):
        ans.append(L[i])
        ans.append(L[-i - 1])
    for a in sorted(ans):
        print(a)

Fixed submission:
A, B, K = map(int, input().split())
L = []

for i in range(K):
    if A + i > B - i:
        break
    else:
        L.append(A + i)
        L.append(B - i)

L = set(L)
L = sorted(L)

for l in L:
    print(l)

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
L = list(range(A, B + 1))
if len(L) <= 2 * K:
    for l in L:
        print(l)
else:
    ans = []
    for i in range(K):
        ans.append(L[i])
        ans.append(L[-i])
    for a in ans:
        print(a)


Fixed submission:
A, B, K = map(int, input().split())
L = []

for i in range(K):
    if A + i > B - i:
        break
    else:
        L.append(A + i)
        L.append(B - i)

L = set(L)
L = sorted(L)

for l in L:
    print(l)

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
L = []
for i in range(A, A + K):
    L.append(i)

for j in range(B - k + 1, B + 1):
    L.append(i)

L = sorted(L, reverse=True)

for l in L:
    print(l)

Fixed submission:
A, B, K = map(int, input().split())
L = []

for i in range(K):
    if A + i > B - i:
        break
    else:
        L.append(A + i)
        L.append(B - i)

L = set(L)
L = sorted(L)

for l in L:
    print(l)
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
print(min(A, B) + min(C, D))


Fixed submission:
A, B, C, D = [int(input()) for _ in range(4)]
print(min(A, B) + min(C, D))
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for _ in range(N)]
M = int(input())
t = [int(input()) for _ in range(M)]

ans = 0
for word in set(s):
    given = s.count(word) - t.count(word)
    ans = max(ans, given)
    
print(ans)

Fixed submission:
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]

ans = 0
for word in set(s):
    given = s.count(word) - t.count(word)
    ans = max(ans, given)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(map(int, input().split()))

if 'Y' in S:
    print('Four')
else:
    print('Three')

Fixed submission:
N = int(input())
S = list(input().split())

if 'Y' in S:
    print('Four')
else:
    print('Three')
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for a in range(A + 1):
    for b in range(b + 1):
        for c in range(c + 1):
            if 500 * a + 100 * b + 50 * c == X:
                ans += 1

print(ans)

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

ans = 0

for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if 500 * a + 100 * b + 50 * c == X:
                ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a*b % 2 == 0:
  return 'Even'
else:
  return 'Odd'


Fixed submission:
a, b = map(int, input().split())
if a*b % 2 == 0:
  print('Even')
else:
  print('Odd')
Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
 
#10000:a, 5000:b, 1000:c
for a in range(N+1):
    for b in range(N+1-a):
        c = N - a - b
        if 10000 * a + 5000 * b + 1000 * c == Y:
            print(a, b, c)
            exit()
print(-1, -1, -1)

Fixed submission:
S = input()

print(S.replace('2017', '2018'))

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
 
#10000:a, 5000:b, 1000:c
for a in range(N+1):
    for b in range(N+1-a):
        c = N - a - b
        if 10000 * a + 5000 * b + 1000 * c == Y:
            print(a, b, c)
            break
print(-1, -1, -1)
N, Y = map(int, input().split())
 
#10000:a, 5000:b, 1000:c
for a in range(N+1):
    for b in range(N+1-a):
        c = N - a - b
        if 10000 * a + 5000 * b + 1000 * c == Y:
            print(a, b, c)
            exit()
print(-1, -1, -1)


Fixed submission:
S = input()

print(S.replace('2017', '2018'))

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
 
#10000:a, 5000:b, 1000:c
for a in range(N+1):
    for b in range(N+1-a):
        c = N - a - b
        if 10000 * a + 5000 * b + 1000 * c == Y:
            print(a, b, c)
            break
print(-1, -1, -1)

Fixed submission:
S = input()

print(S.replace('2017', '2018'))
Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
 
#10000:a, 5000:b, 1000:c
for a in range(N+1):
    for b in range(N+1-a):
        c = N - a - b
        if 10000 * a + 5000 * b + 1000 * c == Y:
            print(a, b, c)
            exit()
print(-1, -1, -1)
N, Y = map(int, input().split())
 
#10000:a, 5000:b, 1000:c
for a in range(N+1):
    for b in range(N+1-a):
        c = N - a - b
        if 10000 * a + 5000 * b + 1000 * c == Y:
            print(a, b, c)
            exit()
print(-1, -1, -1)


Fixed submission:
N, Y = map(int, input().split())
 
#10000:a, 5000:b, 1000:c
for a in range(N+1):
    for b in range(N+1-a):
        c = N - a - b
        if 10000 * a + 5000 * b + 1000 * c == Y:
            print(a, b, c)
            exit()
print(-1, -1, -1)
Buggy python submission (verdict: Runtime Error):
N = input()
if len(set(list(str(N))) <= 2:
    print('Yes')
else:
    print('No')

Fixed submission:
N = input()
if (N[0] == N[1] and N[1] == N[2]) or (N[1] == N[2] and N[2] == N[3]):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = [int(x) for x in input()]
#+,-が入る可能性があるのは間だけ
op_cnt = len(n) - 1
for i in range(2 ** op_cnt):
    op = ['-'] * op_cnt
    for j in range(op_cnt):
        if (i >> j) & 1:
            op[j] = '+'
            
    formula = ''
    for a, b in zip(n, op + ['']):
        formula += (a + b)
    if eval(formula) == 7:
        print(formula + '=7')
        break


Fixed submission:
n = input()
#+,-が入る可能性があるのは間だけ
op_cnt = len(n) - 1
for i in range(2 ** op_cnt):
    op = ['-'] * op_cnt
    for j in range(op_cnt):
        if (i >> j) & 1:
            op[j] = '+'
            
    formula = ''
    for a, b in zip(n, op + ['']):
        formula += (a + b)
    if eval(formula) == 7:
        print(formula + '=7')
        break
Buggy python submission (verdict: Runtime Error):
c11, c12, c13 = map(int, list(input()))
c21, c22, c23 = map(int, list(input()))
if c11 == c23 and c12 == c21 and c13 == c21:
    print('YES')
else:
    print('NO')

Fixed submission:
c11, c12, c13 = list(input())
c21, c22, c23 = list(input())
if c11 == c23 and c12 == c22 and c13 == c21:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
import copy

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
ans = copy.deepcopy(S)

dx = [1, 1, 0, -1, -1, -1, 0, 1]
dy = [0, -1, -1, -1, 0, 1, 1, 1]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            cnt = 0
            for dir in range(8):
                try:
                    cnt += (S[i + dx[dir]][j + dy[dir]] == "#")
                except:
                    pass
            ans[i][j] = cnt
for h in range(H):
    print("".join(ans[h]))

Fixed submission:
import copy

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
ans = copy.deepcopy(S)

dx = [1, 1, 0, -1, -1, -1, 0, 1]
dy = [0, 1, 1, 1, 0, -1, -1, -1]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            cnt = 0
            for dir in range(8):
                if 0 <= i + dy[dir] < H and 0 <= j + dx[dir] < W:
                    cnt += (S[i + dy[dir]][j + dx[dir]] == "#")
                
            ans[i][j] = str(cnt)
for h in range(H):
    print("".join(ans[h]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
x = list(map(int, input().split()))
ans = 0
for i in range(N):
    if abs(K - x[i]) > abs(x[i]):
        ans += 2 * x[i]
    else:
        ans += 2 * (k - x[i])
print(ans)

Fixed submission:
N = int(input())
K = int(input())
x = list(map(int, input().split()))
ans = 0
for i in range(N):
    if abs(K - x[i]) > abs(x[i]):
        ans += 2 * x[i]
    else:
        ans += 2 * (K - x[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
x = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans.append(min(abs(0 - x[i]), abs(K - x[i])))
print(ans)

Fixed submission:
N = int(input())
K = int(input())
x = list(map(int, input().split()))
ans = 0
for i in range(N):
    if abs(K - x[i]) > abs(x[i]):
        ans += 2 * x[i]
    else:
        ans += 2 * (K - x[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 0
for i in range(N):
    l, r = input().split()
    ans += (r - l) + 1
print(ans)

Fixed submission:
N = int(input())
ans = 0
for i in range(N):
    l, r = map(int, input().split())
    ans += (r - l) + 1
print(ans)
Buggy python submission (verdict: Runtime Error):
if max(A, C) < min(B, D):
    print(min(B, D) - max(A, C))
else:
    print(0)

Fixed submission:
A, B, C, D = map(int, input().split())
if A < C and B < D:
    print(max(0, B - C))
elif C <= A and B < D:
    print(max(0, B - A))
elif A < C and D <= B:
    print(max(0, D - C))
else:
    print(max(0, D - A))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

total = sum(A)

ans = float("inf")
for i in range(1, N):
    cand = abs(2*sum(A[:i]) - total)
    ans = min(ans, cand)
print(ans)

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

cumsum = [0] * (N+1)
for i in range(N):
    cumsum[i+1] = cumsum[i] + A[i]

ans = float("inf")
for i in range(1, N):
    cand = abs(cumsum[i] - (cumsum[-1] - cumsum[i]))
    ans = min(ans, cand)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]

cnt = 0
pos = 0

while True:
    if pos == 1:
        print(cnt)
    if cnt >= N:
        print(-1)

    pos = A[pos] - 1
    cnt += 1

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

ans = 0

for i in range(N):
    if i == 0:
        ans += 1
        next_pos = A[i]
        if next_pos == 2:
            break
        else:
            continue
        
    ans += 1
    next_pos = A[next_pos-1]

    if next_pos == 2:
        break
    else:
        continue

if ans < N:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
cnt = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S:
                cnt += 1
print(cnt)

Fixed submission:
K, S = map(int, input().split())
cnt = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if z >= 0 and z <= K:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N, K = [int(x) for x in input().split()]

if N == 0:
    print(0)
elif K == 0:
    print(N)

t1 = abs(N - K)
t2 = K // t1

if t2 > N:
    print(N)
else:
    print(t2)

Fixed submission:
def main():
    N, K = list(map(int, input().split()))
    m = N % K
    m = min(m, abs(K-m))
    print(m)
 
if __name__ == '__main__':
    main()

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

t1 = abs(N - K)
t2 = K // t1

if t2 > N:
    print(N)
else:
    print(t2)

Fixed submission:
def main():
    N, K = list(map(int, input().split()))
    m = N % K
    m = min(m, abs(K-m))
    print(m)
 
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
    
ans = 0
if B / A == 1:
    ans = 1
else:
    ans = 1 + -(-(B - A) // (A - 1))
print(ans)

Fixed submission:
S = input()
T = input()

ret = 0
for i in range(3):
    if S[i] == T[i]:
        ret += 1
print(ret)

Buggy python submission (verdict: Runtime Error):
    A,B = map(int,input().split())
     
    ans = 0
    if B / A == 1:
        ans = 1
    else:
        ans = 1 + -(-(B - A) // (A - 1))
    print(ans)

Fixed submission:
S = input()
T = input()

ret = 0
for i in range(3):
    if S[i] == T[i]:
        ret += 1
print(ret)
Buggy python submission (verdict: Runtime Error):
N = int(input())
dic = {}
for i in range(1, N + 1):
    dic[i] = int(input())

routedDic = []

def NextRoute(i):
    x = dic[i]
    if x in routedDic:
        return -1
    
    routedDic.append(x)

    if x == 2:
        return len(routedDic)
    else:
        return NextRoute(x)

print(NextRoute(1))

Fixed submission:
N = int(input())
lst = [int(input()) for _ in range(N)]

cnt = 0
idx = 0

while True :
    x = lst[idx]
    cnt += 1
    if x == 2:
        print(cnt)
        exit()
    idx = x - 1
    if cnt > N:
        print(-1)
        exit()
Buggy python submission (verdict: Runtime Error):
for i in range(1, K+1):
    if(i > N-K+1):
        print(0)
    else:
        print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))

Fixed submission:
from math import factorial

def comb(n, k):
    return factorial(n)//factorial(k)//factorial(n-k)

inp = input().split()

N = int(inp[0])
K = int(inp[1])

for i in range(1, K+1):
    if(i > N-K+1):
        print(0)
    else:
        print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))

Buggy python submission (verdict: Runtime Error):
from math import factorial

def comb(n, k):
    return factorial(n)//factorial(k)//factorial(n-k)

inp = input().split()

N = int(inp[0])
K = int(inp[1])

for i in range(1, K+1):
    print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))

Fixed submission:
from math import factorial

def comb(n, k):
    return factorial(n)//factorial(k)//factorial(n-k)

inp = input().split()

N = int(inp[0])
K = int(inp[1])

for i in range(1, K+1):
    if(i > N-K+1):
        print(0)
    else:
        print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

inp = input().split()

N = int(inp[0])
K = int(inp[1])

for i in range(1, K+1):
    print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))

Fixed submission:
from math import factorial

def comb(n, k):
    return factorial(n)//factorial(k)//factorial(n-k)

inp = input().split()

N = int(inp[0])
K = int(inp[1])

for i in range(1, K+1):
    if(i > N-K+1):
        print(0)
    else:
        print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

N = int(input())
K = int(input())

for i in range(1, K+1):
    print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))

Fixed submission:
from math import factorial

def comb(n, k):
    return factorial(n)//factorial(k)//factorial(n-k)

inp = input().split()

N = int(inp[0])
K = int(inp[1])

for i in range(1, K+1):
    if(i > N-K+1):
        print(0)
    else:
        print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))
Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
  n, k, q = list(map(int, input().split()))
  A = [k-q]*n
  for _ in range(n):
    a = int(input())
    A[a-1] += 1

  for i in range(n):
    print("Yes\n" if A[i]>0 else "No\n")

Fixed submission:
if __name__ == "__main__":
  n, k, q = list(map(int, input().split()))
  A = [k-q]*n
  for _ in range(q):
    a = int(input())
    A[a-1] += 1

  for i in range(n):
    print("Yes\n" if A[i]>0 else "No\n")
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
if __name__ == "__main__":
  n, m = list(map(int, input().split())) 
  A = list(map(int, input().split()))
  A = np.array(A)

  for i in range(m):
    a = np.argmax(A)
    A[a] = A[a] // 2

  print(np.sum(A))

Fixed submission:
import heapq
if __name__ == "__main__":
  n, m = list(map(int, input().split()))
  A = list(map(int, input().split()))
  A_inv = [-a for a in A]
  heapq.heapify(A_inv)
  for i in range(m):
    max_inv = heapq.heappop(A_inv)
    heapq.heappush(A_inv, -(-max_inv//2))
  print(-sum(A_inv))
Buggy python submission (verdict: Runtime Error):
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    String s = sc.next();

    if(a>=3200){
      System.out.println(s);
    }
    else{
      System.out.println("red");
    }
  }
} 

Fixed submission:
n = int(input())
s = input()

if n >= 3200:
  print(s)
else:
  print("red")
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))

ans = v[0]
for n in range(1, n):
  ans = (ans + v[i]) / 2.0
  
print(ans)

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

v.sort()
ans = v[0]

for i in range(1, n):
  ans = (ans + v[i]) / 2.0
print(ans)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = iny(input())
h = int(input())

print((a + b)*h/2)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())

print(int((a + b) * h / 2))
Buggy python submission (verdict: Time Limit Exceeded):
def gud(a,b):
  if a%b==0:
    return b
  else:
    return gud(b,a%b)
a=int(input())
ans=0
for i in range(a):
  for j in range(a):
    n=gud(i+1,j+1)
    for k in range(a):
      ans+=gud(n,k+1)
print(ans)

Fixed submission:
import math
def gud(a,b):
  if a%b==0:
    return b
  else:
    return gud(b,a%b)
a=int(input())
ans=0
for i in range(1,a+1):
  for j in range(1,a+1):
    n=math.gcd(i,j)
    for k in range(1,a+1):
      ans+=math.gcd(n,k)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def gud(a,b):
  if a%b==0:
    return b
  else:
    return gud(b,a%b)
a=int(input())
ans=0
for i in range(a):
  for j in range(a):
    for k in range(a):
      n=gud(i+1,j+1)
      ans+=gud(n,k+1)
print(ans)

Fixed submission:
import math
def gud(a,b):
  if a%b==0:
    return b
  else:
    return gud(b,a%b)
a=int(input())
ans=0
for i in range(1,a+1):
  for j in range(1,a+1):
    n=math.gcd(i,j)
    for k in range(1,a+1):
      ans+=math.gcd(n,k)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
lis=list(map(int,input().split()))
bef=0
bbef=0
ans=0
while lis[0]>=0:
  bbef=bef
  bef=lis[0]
  lis[0]=abs(lis[0]-lis[1])
  if bbef==lis[0]:
    if bef>=lis[0]:
      print(lis[0])
      break
    else:
      print(bef)
      break


Fixed submission:
lis=list(map(int,input().split()))
if lis[0]%lis[1]<=lis[1]/2:
  print(lis[0]%lis[1])
else:
  print(lis[1]-lis[0]%lis[1])
Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split()))
def cud(a,b):
  if a%b==0:
    return a/b
  else:
    cud(b,a%b)
print(a*b/cud(a[0],a[1]))

Fixed submission:
a=list(map(int,input().split()))
def cud(a,b):
  if a%b==0:
    return b
  else:
    return cud(b,a%b)
print(int(a[0]*a[1]/cud(a[0],a[1])))
Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
lis=list(map(int,input().split()))
suu=0
ans=0
while len(lis)>0:
  if lis[0]==suu+1:
    suu+=1
  else:
    ans+=1
  del lis[0]
if ans==a:
  print(-1)
else:
  print(ans)

Fixed submission:
a=int(input())
lis=list(map(int,input().split()))
suu=0
ans=0
x=0
while len(lis)>x:
  if lis[x]==suu+1:
    suu+=1
  else:
    ans+=1
  x+=1
if ans==a:
  print(-1)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=list(map(int, input().split()))
cou,ju=0,0
ans=[]
while cou<a:
  i=1
  su=0
  while i*(cou+1)<a:
    su+=b[i*(cou+1)]
    i+=1
  if su%2!=b[cou]:
    ans+=[cou+1]
  cou+=1
if ans==[]:
  print("0")
else:
  s=""
  for i in ans:
    s+=str(i)+" "
  print(s)

Fixed submission:
a=int(input())
b=[int(input()) for i in range(a)]
sr=list(reversed(sorted(b)))
if sr[1]==sr[0]:
  for i in range(a):
    print(sr[0])
else:
  for i in b:
    if i==sr[0]:
      print(sr[1])
    else:
      print(sr[0])