Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(int, input().split()))
b = []
for i in range(N):
  if (i + N) % 2 == 0:
    b.append(S[i])
  else:
    b = [S[i]] + b[:]
for i in range(N - 1):
  print(b[i], end = ' ')
print(b[N - 1])


Fixed submission:
N = int(input())
S = list(map(int, input().split()))
b = [0 for i in range(N)]
if N % 2 == 0:
  for i in range(N):
    if i % 2 == 0:
      b[(N + i) // 2] = S[i]
    else:
      b[(N - i) // 2] = S[i]
else:
  b[N // 2] = S[0]
  for i in range(1, N):
    if i % 2 == 1:
      b[(N + i) // 2] = S[i]
    else:
      b[(N - i) // 2] = S[i]
for i in range(N - 1):
  print(b[i], end = ' ')
print(b[N - 1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(int, input().split()))
b = []
for i in range(N):
  if (i + N) % 2 == 0:
    b.append(S[i])
  else:
    b.insert(0, S[i])
for i in range(N - 1):
  print(b[i], end = ' ')
print(b[N - 1])

Fixed submission:
N = int(input())
S = list(map(int, input().split()))
b = [0 for i in range(N)]
if N % 2 == 0:
  for i in range(N):
    if i % 2 == 0:
      b[(N + i) // 2] = S[i]
    else:
      b[(N - i) // 2] = S[i]
else:
  b[N // 2] = S[0]
  for i in range(1, N):
    if i % 2 == 1:
      b[(N + i) // 2] = S[i]
    else:
      b[(N - i) // 2] = S[i]
for i in range(N - 1):
  print(b[i], end = ' ')
print(b[N - 1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(int, input().split()))
b = []
for i in range(N):
  if (i + N) % 2 == 0:
    b.append(S[0])
  else:
    b.insert(0, S[0])
  del S[0]
for i in range(N - 1):
  print(b[i], end = ' ')
print(b[N - 1])

Fixed submission:
N = int(input())
S = list(map(int, input().split()))
b = [0 for i in range(N)]
if N % 2 == 0:
  for i in range(N):
    if i % 2 == 0:
      b[(N + i) // 2] = S[i]
    else:
      b[(N - i) // 2] = S[i]
else:
  b[N // 2] = S[0]
  for i in range(1, N):
    if i % 2 == 1:
      b[(N + i) // 2] = S[i]
    else:
      b[(N - i) // 2] = S[i]
for i in range(N - 1):
  print(b[i], end = ' ')
print(b[N - 1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [0 for i in range(9)]
S = list(map(int, input().split()))
for i in range(N):
  L[S[i] // 400] += 1
Z, M, m = 0, 0, 0
for i in range(8):
  if L[i] == 0:
    Z += 1
  else:
    M += 1
    m += 1
M += min(Z, L[8])
print(m, M)

Fixed submission:
N = int(input())
L = [0 for i in range(9)]
S = list(map(int, input().split()))
for i in range(N):
  p = S[i] // 400
  if p <= 7:
    L[p] += 1
  else:
    L[8] += 1
Z, M, m = 0, 0, 0
for i in range(8):
  if L[i] == 0:
    Z += 1
  else:
    M += 1
    m += 1
M += L[8]
if m == 0 and L[8] != 0:
  m = 1
print(m, M)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
D = {i: 0 for i in range(1, N + 1)}
for i in range(M):
  a, b = map(int, input().split())
  D[a], D[b] += 1
p = 0
for i in D:
  if i % 2 == 1:
    p = 1
if p == 0:
  print("YES")
else:
  print("NO")

Fixed submission:
N, M = map(int, input().split())
D = {i: 0 for i in range(1, N + 1)}
for i in range(M):
  a, b = map(int, input().split())
  D[a] += 1
  D[b] += 1
p = 0
for i in D:
  if D[i] % 2 == 1:
    p = 1
if p == 0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
if a[0] != 0:
  print(0)
else:
  print(a[n+4])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
L = [0 for _ in range(n)]
L[0] = a[0]
for i in range(1, n):
  L[i] = L[i-1] + a[i]
delay = 0
all_over = 0
anti_delay = 0
anti_all_over = 0
if a[0] != 0:
  antiL = L[:]
  sign = (a[0] > 0) - (a[0] < 0)
  for i in range(1, n):
    L[i] += delay
    if L[i] <= 0 and sign == -1:
      delay += 1 - L[i]
      all_over += 1 - L[i]
      L[i] = 1
    elif L[i] >= 0 and sign == 1:
      delay -= L[i] + 1
      all_over += L[i] + 1
      L[i] = -1
    sign *= -1
  if antiL[0] < 0:
    sign = 1
    anti_delay = 1 - antiL[0]
    anti_all_over = 1 - antiL[0]
  else:
    sign = -1
    anti_delay = -(antiL[0] + 1)
    anti_all_over = antiL[0] + 1
  for i in range(1, n):
    antiL[i] += anti_delay
    if antiL[i] <= 0 and sign == -1:
      anti_delay += 1 - antiL[i]
      anti_all_over += 1 - antiL[i]
      antiL[i] = 1
    elif antiL[i] >= 0 and sign == 1:
      anti_delay -= antiL[i] + 1
      anti_all_over += antiL[i] + 1
      antiL[i] = -1
    sign *= -1
  print(min(anti_all_over, all_over))
else:
  posL = L[:]
  negL = L[:]
  pos_delay, neg_delay = 1, -1
  pos_all_over, neg_all_over = 1, 1
  sign = 1
  for i in range(1, n):
    posL[i] += pos_delay
    if posL[i] <= 0 and sign == -1:
      pos_delay += 1 - posL[i]
      pos_all_over += 1 - posL[i]
      posL[i] = 1
    elif posL[i] >= 0 and sign == 1:
      pos_delay -= posL[i] + 1
      pos_all_over += posL[i] + 1
      posL[i] = -1
    sign *= -1
  sign = -1
  for i in range(1, n):
    negL[i] += neg_delay
    if negL[i] <= 0 and sign == -1:
      neg_delay += 1 - negL[i]
      neg_all_over += 1 - negL[i]
      negL[i] = 1
    elif negL[i] >= 0 and sign == 1:
      neg_delay -= negL[i] + 1
      neg_all_over += negL[i] + 1
      negL[i] = -1
    sign *= -1
  print(min(pos_all_over, neg_all_over))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
if 2 * N > M:
  print(M // 2)
else:
  C = M // 2
  n = (C - N) // 2
  print(max(min(S+n-1, C-n+1), min(S+n, C-n), min(S+n+1, C-n-1)))

Fixed submission:
N, M = map(int, input().split())
if 2 * N > M:
  print(M // 2)
else:
  C = M // 2
  n = (C - N) // 2
  print(max(min(N+n-1, C-n+1), min(N+n, C-n), min(N+n+1, C-n-1)))
Buggy python submission (verdict: Runtime Error):
A = list(map(int, input().split()))
S = A[1]
S += (A[0] // 2) * 2
T = S
  if A[4] > 0 and A[5] > 0 and A[0] % 2 == 1:
    S += (A[4] // 2) * 2 + (A[5] // 2) * 2
    A[4] -= 1
    A[5] -= 1
    T += 3
  T += (A[4] // 2) * 2 + (A[5] // 2) * 2
print(max(S, T))


Fixed submission:
A = list(map(int, input().split()))
S = A[1]
S += (A[0] // 2) * 2 + (A[3] // 2) * 2 + (A[4] // 2) * 2
if A[3] % 2 == 1 and A[4] % 2 == 1 and A[0] % 2 == 1:
  S += 3
elif A[3] % 2 == 1 and A[4] % 2 == 1 and A[0] % 2 == 0 and A[0] != 0:
  S += 1
elif A[3] % 2 == 0 and A[4] % 2 == 1 and A[0] % 2 == 1 and A[3] != 0:
  S += 1
elif A[3] % 2 == 1 and A[4] % 2 == 0 and A[0] % 2 == 1 and A[4] != 0:
  S += 1
print(S)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
S = [list(map(int, input().split())) for _ in range(H)]
for i in range(H):
  for j in range(W):
    if S[i][j] == "snuke":
      print("{}{}".format(alpha[j], i+1))

Fixed submission:
H, W = map(int, input().split())
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
S = [list(map(str, input().split())) for _ in range(H)]
for i in range(H):
  for j in range(W):
    if S[i][j] == "snuke":
      print("{}{}".format(alpha[j], i+1))
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
pos = [[0, 0]]
S = [input() for i in range(H)]
p = 1
def whiteout(Map, h, w):
  y = 0
  for i in range(h):
    for j in range(w):
      if Map[i][j] == '#':
        y += 1
  return y == 0

while pos != [H-1, W-1]:
  cnt = 0
  x, y = pos[0], pos[1]
  S[x] = S[x][:y] + '.' + S[x][y+1:]
  if x < H-1:
    if S[x+1][y] == '#':
      cnt += 1
      pos = [x+1, y]
  if y < W-1:
    if S[x][y+1] == '#':
      cnt += 1
      pos = [x, y+1]
  if cnt != 1:
    p = 0
    break
S[H-1] = S[H-1][:W-1] + '.'
if p == 1 and whiteout(S, H, W):
  print("Possible")
else:
  print("Impossible")


Fixed submission:
H, W = map(int, input().split())
pos = [0, 0]
S = [input() for i in range(H)]
p = 1
def whiteout(Map, h, w):
  y = 0
  for i in range(h):
    for j in range(w):
      if Map[i][j] == '#':
        y += 1
  return y == 0

while pos != [H-1, W-1]:
  cnt = 0
  x, y = pos[0], pos[1]
  S[x] = S[x][:y] + '.' + S[x][y+1:]
  if x < H-1:
    if S[x+1][y] == '#':
      cnt += 1
      pos = [x+1, y]
  if y < W-1:
    if S[x][y+1] == '#':
      cnt += 1
      pos = [x, y+1]
  if cnt != 1:
    p = 0
    break
S[H-1] = S[H-1][:W-1] + '.'
if p == 1 and whiteout(S, H, W):
  print("Possible")
else:
  print("Impossible")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p = list(map(int, input().split()))
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
X = [0 for _ in range(N)]
S = N
A[0] = 1
for i in range(N - 1):
  S += abs(p[i] - p[i-1])
for i in range(N):
  X[p[i]-1] = S + i
B[0] = X[0] - 1
for i in range(1, N):
  s = A[i-1] + 1
  while X[i] - s >= B[i-1]:
    s += 1
  A[i] = s
  B[i] = X[i] - s
for i in range(N):
  if i != N - 1:
    print(A[i], end = ' ')
  else:
    print(A[i])
for i in range(N):
  if i != N - 1:
    print(B[i], end = ' ')
  else:
    print(B[i])

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

A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
X = [0 for _ in range(N)]
S = N
A[0] = 1
for i in range(N - 1):
  S += abs(p[i] - p[i-1])
for i in range(N):
  X[p[i]-1] = S + i
B[0] = X[0] - 1
for i in range(1, N):
  s = max(A[i-1] + 1, X[i] - B[i-1] + 1)
  A[i] = s
  B[i] = X[i] - s
if min(min(A), min(B)) <= 0:
  m = -min(min(A), min(B)) + 1
  for i in range(N):
    A[i] += m
    B[i] += m
for i in range(N):
  if i != N - 1:
    print(A[i], end = ' ')
  else:
    print(A[i])
for i in range(N):
  if i != N - 1:
    print(B[i], end = ' ')
  else:
    print(B[i])
Buggy python submission (verdict: Time Limit Exceeded):
N, L = map(int, input().split())
A = list(map(int, input().split()))
d = [A[i] + A[i+1] for i in range(N-1)]
if max(d) < L:
  print("Impossible")
else:
  print("Possible")
  j = 0
  while d[j] != max(d):
    j += 1
  for i in range(j):
    print(i+1)
  for i in range(j, N-1):
    print(N-i+j-1)

Fixed submission:
N, L = map(int, input().split())
A = list(map(int, input().split()))
d = [A[i] + A[i+1] for i in range(N-1)]
if max(d) < L:
  print("Impossible")
else:
  print("Possible")
  j = 0
  while d[j] < L:
    j += 1
  for i in range(j):
    print(i+1)
  for i in range(j, N-1):
    print(N-i+j-1)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
D = list(map(int, input().split()))
S = ""
ND = []
for i in range(10):
  if i not in D:
    ND.append(i)

if K == 9:
  while int(S) < N:
    S = str(ND[0]) + S[:]
  print(int(S))
else:
  l = 0
  F = ND[0]
  while F < N:
    l += 1
    s = l
    F = 0
    ju = 1
    while s != 0:
      F += ND[s%(10-K)] * ju
      s //= 10 - K
      ju *= 10
    print(F, end = ' ')
  print(F)

Fixed submission:
N, K = map(int, input().split())
D = list(map(int, input().split()))
S = ""
ND = []
for i in range(10):
  if i not in D:
    ND.append(i)

if K == 9:
  S = str(ND[0])
  while int(S) < N:
    S = str(ND[0]) + S[:]
  print(int(S))
else:
  l = 0
  F = ND[0]
  j = 10 - K
  cnt = 0
  while F < N:
    l += 1
    s = l
    F = 0
    ju = 1
    if l == j:
      l, s = 0, 0
      j *= 10 - K
      cnt += 1
    for x in range(cnt+1):
      F += ND[s%(10 - K)] * ju
      ju *= 10
      s //= 10 - K
  print(F)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
D = list(map(int, input().split()))
S = ""
ND = []
for i in range(10):
  if i not in D:
    ND.append(i)

if K == 9:
  while int(S) < N:
    S = str(ND[0]) + S[:]
  print(int(S))
else:
  l = 0
  F = ND[0]
  while F < N:
    l += 1
    s = l
    F = 0
    ju = 1
    while s != 0:
      F += ND[s%(10-K)] * ju
      s //= 10 - K
      ju *= 10
  print(F)

Fixed submission:
N, K = map(int, input().split())
D = list(map(int, input().split()))
S = ""
ND = []
for i in range(10):
  if i not in D:
    ND.append(i)

if K == 9:
  S = str(ND[0])
  while int(S) < N:
    S = str(ND[0]) + S[:]
  print(int(S))
else:
  l = 0
  F = ND[0]
  j = 10 - K
  cnt = 0
  while F < N:
    l += 1
    s = l
    F = 0
    ju = 1
    if l == j:
      l, s = 0, 0
      j *= 10 - K
      cnt += 1
    for x in range(cnt+1):
      F += ND[s%(10 - K)] * ju
      ju *= 10
      s //= 10 - K
  print(F)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
mod = int(1e+9 + 7)

def extgcd(a, b):
  x, y, u, v, k, l = 1, 0, 0, 1, a, b
  while l != 0:
    x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
    k, l = l, k % l
  return x, y

def inved(x):
  a, b = extgcd(x, mod)
  return a % mod

frac = [1]
for i in range(8000):
  frac.append((frac[i]*(i+1))%mod)
invf = []
for i in range(8001):
  invf.append(inved(frac[i]))

A = [list(map(int, input().split())) for i in range(N)]
S = 0
for i in range(N):
  for j in range(i):
    F = frac[A[i][0] + A[j][0] + A[i][1] + A[j][1]] * invf[A[i][0] + A[j][0]]
    F %= mod
    F *= invf[A[i][1] + A[j][1]]
    F %= mod
    S += F
    S %= mod
print(S)

Fixed submission:
import numpy as np

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
mod = int(1e+9) + 7
def extgcd(a, b):
  if b == 0:
    return 1, 0
  else:
    x, y, u, v, k, l = 1, 0, 0, 1, a, b
    while l != 0:
      x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
      k, l = l, k % l
    return x, y
def inved(x):
  a, b = extgcd(x, mod)
  return a % mod

fact = [1 for i in range(8001)]
finv = [0 for i in range(8001)]
for i in range(8000):
  fact[i+1] = (fact[i] * (i + 1)) % mod
finv[8000] = inved(fact[8000])
for i in range(8000, 0, -1):
  finv[i-1] = (finv[i] * i) % mod
Y = 0
for i in range(N):
  Y += (fact[2*(A[i][0]+A[i][1])]*finv[2*A[i][0]]*finv[2*A[i][1]])%mod
  Y %= mod
B = [[] for i in range(4001)]
for i in A:
  B[i[0]+i[1]].append(2000-i[0])
f = np.zeros(2000+2000+1,np.int64)
for b in B[::-1]:
  f[1:] += f[:-1].copy()
  np.add.at(f,b,1)
  f %= mod
X = (f * f[::-1] % mod).sum() % mod

print(((X-Y) * inved(2))%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
#まずk学期までの
p=1
for i in range(k):
    p*=a[i]
    p//(10**9 +7)


for i in range(n-k):
    tmp=p
    p//=a[i]
    p*=a[i+k]
    p//(10**9 +7)
    #print(p)
    if p>tmp:
        print("Yes")
    else:
        print("No")


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

for i in range(n-k):

    if a[i]<a[k+i]:
        print("Yes")
    else:
        print("No")

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

p=1
for i in range(k):
    p*=a[i]


for i in range(n-k):
    tmp=p
    p//=a[i]
    p*=a[i+k]
    p//(10**9 +7)

    if p>tmp:
        print("Yes")
    else:
        print("No")


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

for i in range(n-k):

    if a[i]<a[k+i]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
#まずk学期までの
p=1
for i in range(k):
    p*=a[i]


for i in range(n-k):
    tmp=p
    p//=a[i]
    p*=a[i+k]
    #print(p)
    if p>tmp:
        print("Yes")
    else:
        print("No")


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

for i in range(n-k):

    if a[i]<a[k+i]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
#まずk学期までの
p=1
for i in range(k):
    p*=a[i]
#print(p)
j=0

for i in range(n-k):
    tmp=p
    p//=a[j]
    p*=a[i+k]
    #print(p)
    if p>tmp:
        print("Yes")
    else:
        print("No")
    j+=1

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

for i in range(n-k):

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

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
    print(0)
    exit()
for i in range(n):
    if i==0:
        ans=a[i]
    else:
        ans*=a[i]
        if ans>10**18:
            print(-1)
            exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,M=map(int,input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
l=[0]*(N-1)
bo=[1]
box=deque(bo)
count=0
while count<N-1:
    for i in range(M):
        if AB[i][0]==box[0] and l[AB[i][1]-2]==0:
            box.append(AB[i][1])
            l[AB[i][1]-2]=AB[i][0]
            count+=1
        elif AB[i][1]==box[0] and l[AB[i][0]-2]==0:
            box.append(AB[i][0])
            l[AB[i][0]-2]=AB[i][1]
            count+=1
    box.popleft()
print("Yes")
[print(i) for i in l]

Fixed submission:
from collections import deque
n,m=map(int,input().split())
ab=[list(map(int, input().split())) for _ in range(m)]
l=[[] for i in range(n)]#各部屋とつながっている部屋
#print(l,ab)
for a,b in ab:
    l[a-1].append(b)
    l[b-1].append(a)
result=[-1]*n
q=deque([1])
#print(l,result)
while True:
    if len(q)==0:
        break
    x=q.popleft()
    for j in l[x-1]:
        if result[j-1]==-1:
            result[j-1]=x
            q.append(j)
    #print(q,result)

print("Yes")
[print(i) for i in result[1:]]
Buggy python submission (verdict: Runtime Error):
X=int(input())
if (X**0.2)%1==0:
    a=int(X**0.2)
    b=0
    print(a,b)
else:
    b=1
    while b<1002:
        if ((X+b**5)**0.2)%1==0:
            a=int((X+b**5)**0.2)
            print(a,b)
            exit()
        else:
            b+=1
    c=-1
    while c>-1002:
        if ((X+c**5)**0.2)%1==0:
            a=int((X+c**5)**0.2)
            print(a,c)
            exit()
        else:
            c-=1

Fixed submission:
X=int(input())
a=1
while a<1001:
    for i in range(-1000,1001):
        if a**5-i**5==X:
            b=i
            print(a,b)
            exit()
    a+=1

Buggy python submission (verdict: Runtime Error):
X=int(input())
if (X**0.2)%1==0:
    a=int(X**0.2)
    b=0
    print(a,b)
else:
    b=1
    while b<10000:
        if ((X+b**5)**0.2)%1==0:
            a=int((X+b**5)**0.2)
            print(a,b)
            exit()
        elif ((X+(-1*b)**5)**0.2)%1==0:
            a=int((X+b**5)**0.2)
            print(a,-b)
            exit()
        else:
            b+=1

Fixed submission:
X=int(input())
a=1
while a<1001:
    for i in range(-1000,1001):
        if a**5-i**5==X:
            b=i
            print(a,b)
            exit()
    a+=1
Buggy python submission (verdict: Runtime Error):
a,b,n=map(int,input().split())

if b<=n:
    if a%b!=0
        print(a-a//b -1)
    else:
        print(a-a//b)
else:
    print(int(n*a/b))

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

if b<=n:
    if a%b!=0:
        print(a-a//b -1)
    else:
        print(a-a//b)
else:
    print(int(n*a/b))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
l=[]
for i in range(N):
    S=input()
    if S not in l:
        l.append(S)
print(len(l))

Fixed submission:
N=int(input())
s=[input() for i in range(N)]
S=set(s)
print(len(S))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
l=[1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199]
a=0
K=int(input())
for i in range(1,K+1):
    if i in l:
        a+=K**2 +(i-1)*(K//i)**2
    else:
        for j in range(1,K+1):
            if j in l:
                if math.gcd(i,j)==1:
                    a+=K
                else:
                    a+=(K + (math.gcd(i,j)-1)*(K//j))
            else:
                for r in range(1,K+1):
                    a+=gcd(i,j,r)
print(a)

Fixed submission:
import math

a=0

K=int(input())
for i in range(1,K+1):#(1,2,3)
    for j in range(i,K+1):
        for r in range(j,K+1):
            if i==j and i==r:#(1,1,1)のような場合
                a+=math.gcd(i,math.gcd(j,r))
            elif i==j or j==r:#(1,1,2),(1,2,2)のような場合。各3通り
                a+=math.gcd(i,math.gcd(j,r))*3
            else:
                a+=math.gcd(i,math.gcd(j,r))*6
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
l=[1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199]
a=0
b=0
#for i in range(K):
#    b+=
K=int(input())
for i in range(1,K+1):
    if i in l:
        a+=K**2 +(i-1)*(K//i)**2
    else:
        for j in range(1,K+1):
            for r in range(1,K+1):
                a+=gcd(i,j,r)
print(a)

Fixed submission:
import math

a=0

K=int(input())
for i in range(1,K+1):#(1,2,3)
    for j in range(i,K+1):
        for r in range(j,K+1):
            if i==j and i==r:#(1,1,1)のような場合
                a+=math.gcd(i,math.gcd(j,r))
            elif i==j or j==r:#(1,1,2),(1,2,2)のような場合。各3通り
                a+=math.gcd(i,math.gcd(j,r))*3
            else:
                a+=math.gcd(i,math.gcd(j,r))*6
print(a)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
N,M=map(int,input().split())

if N<=1 and M<=1:
    print(0)
else:
    print(int(comb(N,2))+int(comb(M,2)))

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

def combi(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if N<=1 and M<=1:
    print(0)
elif N>=2 and M>=2:
    print(int(combi(N,2))+int(combi(M,2)))
elif N>=2 and M<=1:
    print(int(combi(N,2)))
elif N<=1 and M>=2:
    print(int(combi(M,2)))