Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())
sato = set()
miz = set()
for i in range(F//100//A + 1):
	for j in range(F//100//B + 1):
		if i*A + j*B <= F//100:
			miz.add((i*A + j*B)*100)

for i in range(F//C + 1):
	for j in range(F//D + 1):
		if i*C + j*D <= F:
			sato.add(i*C + j*D)
miz = list(miz)
sato = list(sato)
#print(sorted(miz), sorted(sato))
node = 0
for i in range(len(miz)):
	if miz[i] == 0:
		continue
	for j in range(len(sato)):
		c = 100*sato[j]/miz[i]
		q = miz[i] + sato[j]
		if c > E:
			pass
		elif q > F:
			pass
		elif c > node:
			note = [miz[i] + sato[j], sato[j]]
			node = c

print(*note)


Fixed submission:
A, B, C, D, E, F = map(int, input().split())
sato = set()
miz = set()
for i in range(F//100//A + 1):
	for j in range(F//100//B + 1):
		if i*A + j*B <= F//100:
			miz.add((i*A + j*B)*100)

for i in range(F//C + 1):
	for j in range(F//D + 1):
		if i*C + j*D <= F:
			sato.add(i*C + j*D)
miz = list(miz)
sato = list(sato)
#print(sorted(miz), sorted(sato))
node = 0
note = [100*A, 0]
for i in range(len(miz)):
	if miz[i] == 0:
		continue
	for j in range(len(sato)):
		c = 100*sato[j]/miz[i]
		q = miz[i] + sato[j]
		if c > E:
			pass
		elif q > F:
			pass
		elif c > node:
			note = [miz[i] + sato[j], sato[j]]
			node = c

print(*note)

Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())
sato = set()
miz = set()
for i in range(F//100//A + 1):
	for j in range(F//100//B + 1):
		if i*A + j*B <= F//100:
			miz.add((i*A + j*B)*100)

for i in range(F//C + 1):
	for j in range(F//D + 1):
		if i*C + j*D <= F:
			sato.add(i*C + j*D)
miz = list(miz)
sato = list(sato)
#print(sorted(miz), sorted(sato))
node = 0
for i in range(len(miz)):
	if i == 0:
		continue
	for j in range(len(sato)):
		c = 100*sato[j]/miz[i]
		q = miz[i] + sato[j]
		if c > E:
			pass
		elif q > F:
			pass
		elif c > node:
			note = [miz[i] + sato[j], sato[j]]
			node = c

print(*note)

Fixed submission:
A, B, C, D, E, F = map(int, input().split())
sato = set()
miz = set()
for i in range(F//100//A + 1):
	for j in range(F//100//B + 1):
		if i*A + j*B <= F//100:
			miz.add((i*A + j*B)*100)

for i in range(F//C + 1):
	for j in range(F//D + 1):
		if i*C + j*D <= F:
			sato.add(i*C + j*D)
miz = list(miz)
sato = list(sato)
#print(sorted(miz), sorted(sato))
node = 0
note = [100*A, 0]
for i in range(len(miz)):
	if miz[i] == 0:
		continue
	for j in range(len(sato)):
		c = 100*sato[j]/miz[i]
		q = miz[i] + sato[j]
		if c > E:
			pass
		elif q > F:
			pass
		elif c > node:
			note = [miz[i] + sato[j], sato[j]]
			node = c

print(*note)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

print(*a[::-2], *a[n%2::2])

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

print(*a[::-2], end=" ")
print(*a[n%2::2])
Buggy python submission (verdict: Runtime Error):
inputa = int(input())
inputb = input()
flag = 0
res = ""

for c in inputb:
  if c == "o":
    if flag % 2 == 0:
      res += "S"
    else:
      res += "W"
  else:
    res += "S"
    flag += 1

if inputb[0] == "o":
  if flag % 2 != 0:
    print(-1)
  else:
    print(res)
elif inputb[0] == "x":
  if flag % 2 != 1:
    print(-1)
  else:
    print(res)
else:
  print(res)

Fixed submission:
N = int(input())
print(N*800 - N//15*200)
Buggy python submission (verdict: Runtime Error):
N = int(input())
cnt = 0
L = []
for i in range(N):
	L.append(list(map(int, input().split())))

for i in range(N):
	A, B = L[-i+1]
	cnt += -(A + cnt)%B
print(cnt)

Fixed submission:
N = int(input())
cnt = 0
L = []
for i in range(N):
	L.append(list(map(int, input().split())))

L = L[::-1]
 
for i in range(N):
	A, B = L[i]
	if A:
		cnt += -(A + cnt)%B

print(cnt)

Buggy python submission (verdict: Runtime Error):
N = int(input())
cnt = 0
L = []
for i in range(N):
	L.append(list(map(int, input().split())))

for i in range(N):
	A, B = L[-i+1]
	cnt += -(A + cnt)%B
	print(cnt)

Fixed submission:
N = int(input())
cnt = 0
L = []
for i in range(N):
	L.append(list(map(int, input().split())))

L = L[::-1]
 
for i in range(N):
	A, B = L[i]
	if A:
		cnt += -(A + cnt)%B

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = [sorted([i+1, j]) for i, j in enumerate(map(int, input().split()))]

def f(l):
	ul = []
	return [x for x in l if x not in ul and not ul.append(x)]

print(len(l) - len(f(l)))

Fixed submission:
N = int(input())
l = tuple(map(int, input().split()))
cnt = 0
for i in range(N):
	if l[l[i]-1] == i+1:
		cnt += 1
print(cnt//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = [sorted([i+1, j]) for i, j in enumerate(map(int, input().split()))]

def f(l):
	ul = []
	return [x for x in l if x not in ul and not ul.append(x)]

print(len(l) - len(f(l)))

Fixed submission:
N = int(input())
l = tuple(map(int, input().split()))
cnt = 0
for i in range(N):
	if l[l[i]-1] == i+1:
		cnt += 1
print(cnt//2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
d=int(input())
cnt=0
for i in range(0,n):
  x=int(input())
  y=int(input())
  z=sqrt((x*x)+(y*y))
  if(z>=d):
    cnt+=1
    
print(cnt)

Fixed submission:
import math
n, d = map(int, input().split()) 
cnt=0
for i in range(0,n):
  x, y = map(int, input().split()) 
  z=math.sqrt((x*x)+(y*y))
  if(z<=d):
    cnt+=1
    
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

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

ans = 0

for i in range(N):
    for j in range(i+1,N):
            tmp = a[i]*a[j]
            ans += tmp

m = 10**9 + 7

ans = ans % m

print(ans)

Fixed submission:
N = int(input())

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

ans = 0
sum = 0

for i in range(N):
    sum += a[i]

for i in range(N-1):
    sum -= a[i]
    ans += a[i]*sum

m = 10**9 + 7

ans = ans % m

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

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

ans = 0

for i in range(N):
    for j in range(i+1,N):
            tmp = a[i]*a[j]
            ans += tmp

m = 10**9 + 7

ans = ans % m

print(ans)

Fixed submission:
N = int(input())

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

ans = 0
sum = 0

for i in range(N):
    sum += a[i]

for i in range(N-1):
    sum -= a[i]
    ans += a[i]*sum

m = 10**9 + 7

ans = ans % m

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
import sys

N = int(input())

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

A = max(a)+1

# 全ての数に対して、入っているかいないかを判別する配列を作る
c = [0]*A
for i in range(N):
    c[a[i]] += 1

# print(c)

pairwise = True

for i in range(2,A):
    cnt = 0

    # 素因数ずつ数を増やしていき、同じ素因数を持つことがあればpairwiseではない
    # たとえば、3ならば、3,6,9,,と増やしていき、それがc[]に１つ以上含まれているか調べていく
    for j in range(i,A,i):
        cnt += c[j]
    if (cnt > 1):
        pairwise = False

if pairwise:
    print("pairwise coprime")
    sys.exit()

g = 0
for i in range(N):
    g = gcd(g,a[i])
if (g == 1):
    print("setwise coprime")
    sys.exit()

else:
    print('not coprime')

Fixed submission:
from math import gcd
import sys

N = int(input())

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

A = max(a)+1

# 全ての数に対して、入っているかいないかを判別する配列を作る
c = [0]*A
for i in range(N):
    c[a[i]] += 1

# print(c)

pairwise = True

for i in range(2,A):
    cnt = 0

    # 素因数ずつ数を増やしていき、同じ素因数を持つことがあればpairwiseではない
    # たとえば、3ならば、3,6,9,,と増やしていき、それがc[]に１つ以上含まれているか調べていく
    for j in range(i,A,i):
        cnt += c[j]
    if (cnt > 1):
        pairwise = False

if pairwise:
    print("pairwise coprime")
    sys.exit()

g = 0
for i in range(N):
    g = gcd(g,a[i])
if (g == 1):
    print("setwise coprime")
    sys.exit()

else:
    print('not coprime')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

H,W = map(int,input().split())
c_h, c_w = map(int,input().split())
d_h, d_w = map(int,input().split())

c_h -= 1
c_w -= 1
d_h -= 1
d_w -= 1

s = [list(input()) for _ in range(H)]

# print(s)

q = deque()
q.append((c_h,c_w))

INF = 1e9
# マス目に入る数字を入れる配列
# 最初はINFで初期化
dist = [[INF for _ in range(W)] for __ in range(H)]

dist[c_h][c_w] = 0
# (右、上、左、下)
dh = (0,1,0,-1)
dw = (1,0,-1,0)

while(len(q) > 0):
    # dequeの一番左を取り出す。
    now = q.popleft()
    now_h,now_w = now

    d = dist[now_h][now_w]

    # 今のマスの上下左右で動けるか確認する
    for di in range(4):
        next_h = now_h + dh[di]
        next_w = now_w + dw[di]

        if (next_h<0 or next_h>=H or next_w<0 or next_w>=W): continue
        if (s[next_h][next_w] == '#'): continue
        if dist[next_h][next_w] <= d: continue

        # 隣り合う動けるマスには同じ数字を記入
        dist[next_h][next_w] = d

        # dequeに前から入れる
        q.appendleft((next_h,next_w))

    # 魔法を使う場合
    for ew in range(-2,3):
        for eh in range(-2,3):
            next_h = eh + now_h
            next_w = ew + now_w

            if (next_h<0 or next_h>=H or next_w<0 or next_w>=W): continue
            if (s[next_h][next_w] == '#'): continue
            if dist[next_h][next_w] <= d+1: continue

            dist[next_h][next_w] = d+1
            q.append((next_h,next_w))

if (dist[d_h][d_w] == INF):
    print(-1)
else:
    print(dist[d_h][d_w])

# print(dist)


Fixed submission:
from collections import deque

H,W = map(int,input().split())
c_h, c_w = map(int,input().split())
d_h, d_w = map(int,input().split())

c_h -= 1
c_w -= 1
d_h -= 1
d_w -= 1

s = [list(input()) for _ in range(H)]

# print(s)

q = deque()
q.append((c_h,c_w))

INF = 1e9
# マス目に入る数字を入れる配列
# 最初はINFで初期化
dist = [[INF for _ in range(W)] for __ in range(H)]

dist[c_h][c_w] = 0
# (右、上、左、下)
dh = (0,1,0,-1)
dw = (1,0,-1,0)

while(len(q) > 0):
    # dequeの一番左を取り出す。
    now = q.popleft()
    now_h,now_w = now

    d = dist[now_h][now_w]

    # 今のマスの上下左右で動けるか確認する
    for di in range(4):
        next_h = now_h + dh[di]
        next_w = now_w + dw[di]

        if (next_h<0 or next_h>=H or next_w<0 or next_w>=W): continue
        if (s[next_h][next_w] == '#'): continue
        if dist[next_h][next_w] <= d: continue

        # 隣り合う動けるマスには同じ数字を記入
        dist[next_h][next_w] = d

        # dequeに前から入れる
        q.appendleft((next_h,next_w))

    # 魔法を使う場合
    for ew in range(-2,3):
        for eh in range(-2,3):
            next_h = eh + now_h
            next_w = ew + now_w

            if (next_h<0 or next_h>=H or next_w<0 or next_w>=W): continue
            if (s[next_h][next_w] == '#'): continue
            if dist[next_h][next_w] <= d+1: continue

            dist[next_h][next_w] = d+1
            q.append((next_h,next_w))

if (dist[d_h][d_w] == INF):
    print(-1)
else:
    print(dist[d_h][d_w])

# print(dist)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

#約数の個数を求める関数
def yakusu_count(n):
    count = 1
    if n == 1:
        pass
    elif n == 3:
        count =2

    elif n % 2 == 0:
        for i in range(1,n//2 + 1):
            if n % i == 0:
                count += 1

    elif n % 2 == 1:
        for i in range(1, n//2):
            if n % i == 0:
                count += 1
    
    return count

ans = 0
for i in range(1,N+1):
    temp = i * yakusu_count(i)
    ans += temp
print(ans)

Fixed submission:
N = int(input())
ans = 0
for i in range(1,N+1):
    a = N // i
    b = i*(a+1)*a//2
    ans += b
print(ans)
Buggy python submission (verdict: Runtime Error):
s = [1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,54,1,4,1,51]

k = int(input())

print(s[k-1])

Fixed submission:
s = [1,1,1,2,1,
    2,1,5,2,2,
    1,5,1,2,1,
    14,1,5,1,5,
    2,2,1,15,2,
    2,5,4,1,4,1,
    51]

k = int(input())

print(s[k-1])
Buggy python submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]
b = [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
  
ans = 0
j = M
for i in range(N+1):
  if a[i] > K:
    break
  while b[i] > K - a[i]:
    j -= 1
  ans = max(ans,i+j)
print(ans)

Fixed submission:
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]
b = [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
  
ans = 0
j = M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans,i+j)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]
b = [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
  
ans = 0
j = M
for i in range(N+1):
  if a[i] > K:
    break
  while b[i] > K - a[i]:
    j -= 1
  ans = max(ans,i+j)
print(ans)

Fixed submission:
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]
b = [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
  
ans = 0
j = M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans,i+j)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
C = A + B
for i in range(len(C)):
  C[i] = min(A[i],B[i])
  
for i in range(len(C)):
  if K => C[i]:
    K -= C[i]
    ans +=1
  else:
    break
print(ans)
  	

Fixed submission:
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]
b = [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
  
ans = 0
j = M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans,i+j)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
C = A + B
for i in range(len(C)):
  C[i] = min(A[i],B[i])
  
for i in range(len(C)):
  if K >= C[i]:
    K -= C[i]
    ans +=1
  else:
    break
print(ans)
  	

Fixed submission:
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]
b = [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
  
ans = 0
j = M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans,i+j)
print(ans)
Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split())
if N > 0:
  p = list(map(int,input().split()))
a = 101
ans = 0
for i in range(-1,101):
  if N == 0:
    ans = X
    break
  if p.count(i) == 0 and a >= abs(X - i):
    a = abs(X - i)
    ans = i
for i in range(-1,101):
  if a == abs(X - i) and p.count(i) == 0:
    ans = i
    break
print(ans)

Fixed submission:
X,N = map(int,input().split())
if N > 0:
  p = list(map(int,input().split()))
a = 102
ans = 0
for i in range(-1,200):
  if N == 0:
    ans = X
    break
  if p.count(i) == 0 and a > abs(X - i):
    a = abs(X - i)
    ans = i
print(ans)

Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split())
if N >0:
  p = list(map(int,input().split()))
a = 100
ans = []
for i in range(1,101):
  if N == 0:
    ans = X
    break
  if p.count(i) == 0 and a >= abs(X - i):
    a = abs(X - i)
    ans = i
if N > 0:
  for i in range(1,101):
    if abs(X-i) == abs(X-ans) and p.count(i) == 0:
      ans = i
      break
print(ans)

Fixed submission:
X,N = map(int,input().split())
if N > 0:
  p = list(map(int,input().split()))
a = 102
ans = 0
for i in range(-1,200):
  if N == 0:
    ans = X
    break
  if p.count(i) == 0 and a > abs(X - i):
    a = abs(X - i)
    ans = i
print(ans)

Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split())
if N >0:
  p = list(map(int,input().split()))
a = 100
ans = []
for i in range(1,101):
  if N == 0:
    ans = X
    break
  if p.count(i) == 0 and a >= abs(X - i):
    a = abs(X - i)
    ans = i
for i in range(1,101):
  if abs(X-i) == abs(X-ans) and p.count(i) == 0:
    ans = i
    break
print(ans)

Fixed submission:
X,N = map(int,input().split())
if N > 0:
  p = list(map(int,input().split()))
a = 102
ans = 0
for i in range(-1,200):
  if N == 0:
    ans = X
    break
  if p.count(i) == 0 and a > abs(X - i):
    a = abs(X - i)
    ans = i
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input())

print(A*B)

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

print(A*B)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import mul
N = int(input())
a = list(map(int,input().split()))

ans = reduce(mul, a)

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

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

if A.count(0) > 0:
  print(0)
else:
  ans = A[0]
  flag = 0
  for i in range(1,N):
    ans *= A[i]
    if ans > 10 ** 18:
      print(-1)
      flag += 1
      break
  if flag == 0:
    print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
a = list(map(int,input().split()))

b = np.array(a)

ans = np.prod(b)

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

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

if A.count(0) > 0:
  print(0)
else:
  ans = A[0]
  flag = 0
  for i in range(1,N):
    ans *= A[i]
    if ans > 10 ** 18:
      print(-1)
      flag += 1
      break
  if flag == 0:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import add, mul

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

ans = reduce(mul,a)
  
if ans > 10**18:
  print(-1)
else:
  print(ans)

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

if A.count(0) > 0:
  print(0)
else:
  ans = A[0]
  flag = 0
  for i in range(1,N):
    ans *= A[i]
    if ans > 10 ** 18:
      print(-1)
      flag += 1
      break
  if flag == 0:
    print(ans)

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(-1)
else:
  print(ans)

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

if A.count(0) > 0:
  print(0)
else:
  ans = A[0]
  flag = 0
  for i in range(1,N):
    ans *= A[i]
    if ans > 10 ** 18:
      print(-1)
      flag += 1
      break
  if flag == 0:
    print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C,K = list(map(int, input().split()))

    
if A > K:
  print(A)
elif A <= K and A + B > K:
  print(A):
elif A <= K and A + B <= K:
  print(A - (K - A - B))

Fixed submission:
A,B,C,K = map(int,input().split())
 
if K <= A:
    print(str(K))
elif K <= A + B:
    print(str(A))
else:
    print(str(A - (C - (A + B + C - K))))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,K = list(map(int, input().split()))
ans = 0
for i in range(K):
  if i < A:
    ans += 1
  elif A+B-1 < i:
    ans -= 1
    
print(ans)

Fixed submission:
A,B,C,K = map(int,input().split())
 
if K <= A:
    print(str(K))
elif K <= A + B:
    print(str(A))
else:
    print(str(A - (C - (A + B + C - K))))
Buggy python submission (verdict: Runtime Error):
import numpy as np
K = int(input())

s = 0

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      s += np.gcd(i,np.gcd(j,k))
      
print(s)

Fixed submission:
from math import gcd
K = int(input())
sum = 0

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      sum += gcd(gcd(i,j),k)
      
print(sum)

Buggy python submission (verdict: Runtime Error):
import numpy as np
K = int(input())

sum = 0

for i in range(1,K+1):
  for j in range(1,K+1):
    s += np.gcd(i,j)
    for k in range(1,K+1):
      sum += np.gcd(s,k)
      
print(sum)

Fixed submission:
from math import gcd
K = int(input())
sum = 0

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      sum += gcd(gcd(i,j),k)
      
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
K = int(input())

def gcd(a,b,c):
  return np.gcd(a,np.gcd(b,c))

sum = 0

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      sum += gcd(i,j,k)
      
print(sum)

Fixed submission:
from math import gcd
K = int(input())
sum = 0

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      sum += gcd(gcd(i,j),k)
      
print(sum)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
s = list(map(int,input().split()))

count = 0
al = sum(s)

for i in range(N):
  if not(a[i] < s / (4 * M)):
    count += 1
    
if count == M:
  print("Yes")
else:
  print("No")

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

count = 0
al = sum(s)

for i in range(N):
  if not(s[i] < al / (4 * M)):
    count += 1
    
if count >= M:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
s = list(map(int, input().split()))

N = s[0]
K = s[1]

while N >= abs(N - K):
  N = abs(N - K)
  
print(N)

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

N = s[0]
K = s[1]

print(min(N % K, K - N % K))
Buggy python submission (verdict: Time Limit Exceeded):
i = list(map(int, input().split()))
K = i[0]
N = i[1]

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

m = K

for i in range(N):
  for j in range(i,N):
    t = max(abs(s[i] - s[j]), K - abs(s[i] - s[j]))
    if t <= m:
      m = t
      
print(m)

Fixed submission:
i = list(map(int, input().split()))
K = i[0]
N = i[1]

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

m = K

for i in range(N - 1):
  t = max(abs(s[i] - s[i + 1]), K - abs(s[i] - s[i + 1]))
  if t <= m:
     m = t

if max(abs(s[0] - s[N - 1]), K - abs(s[0] - s[N - 1])) <= m:
  m = max(abs(s[0] - s[N - 1]), K - abs(s[0] - s[N - 1]))

print(m)

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

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

m = K

for i in range(N):
  for j in range(N):
    t = max(abs(s[i] - s[j]), K - abs(s[i] - s[j]))
    if t <= m:
      m = t
      
print(m)

Fixed submission:
i = list(map(int, input().split()))
K = i[0]
N = i[1]

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

m = K

for i in range(N - 1):
  t = max(abs(s[i] - s[i + 1]), K - abs(s[i] - s[i + 1]))
  if t <= m:
     m = t

if max(abs(s[0] - s[N - 1]), K - abs(s[0] - s[N - 1])) <= m:
  m = max(abs(s[0] - s[N - 1]), K - abs(s[0] - s[N - 1]))

print(m)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = list(map(int, input().split()))

m = min(s)
M = max(s)

lis = []
ans = 0

for i in range(m,M):
  for j in range(N):
  	ans += (s[j] - i) ** 2
  lis.append(ans)
  ans = 0
  
print(min(lis))

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

m = s[0]
M = s[N-1]

lis = []
ans = 0

for i in range(1000):
  for j in range(N):
  	ans += (s[j] - i) ** 2
  lis.append(ans)
  ans = 0
  
print(min(lis))

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

m = s[0]
M = s[N-1]

lis = []
ans = 0

for i in range(m,M + 1):
  for j in range(N):
  	ans += (s[j] - i) ** 2
  lis.append(ans)
  ans = 0
  
print(min(lis))

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

m = s[0]
M = s[N-1]

lis = []
ans = 0

for i in range(1000):
  for j in range(N):
  	ans += (s[j] - i) ** 2
  lis.append(ans)
  ans = 0
  
print(min(lis))

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

m = s[0]
M = s[N-1]

lis = []
sum = 0

for i in range(m,M):
  for j in range(N):
  	sum += (s[j] - i) ** 2
  lis.append(sum)
  sum = 0
  
print(min(lis))

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

m = s[0]
M = s[N-1]

lis = []
ans = 0

for i in range(1000):
  for j in range(N):
  	ans += (s[j] - i) ** 2
  lis.append(ans)
  ans = 0
  
print(min(lis))