Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
    poplist = a[:i] + a[i+1:]
    print(max(poplist))


Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]

max_value = max(a)
max_index = a.index(max_value)

for i in range(n):
    if not i == max_index:
        print(max_value)
    else:
        newlist = a[:i] + a[i+1:]
        print(max(newlist))
Buggy python submission (verdict: Runtime Error):
if W/2 == x and H/2 == y:
    print(W*H/2, 1)
else:
    print(W*H/2, 0)

Fixed submission:
W, H, x, y = map(int, input().split())

#正方形なら複数　これも面積半分?
#長方形なら一つ 点対称の線を引けば面積半分にできる

if W/2 == x and H/2 == y:
    print(W*H/2, 1)
else:
    print(W*H/2, 0)
Buggy python submission (verdict: Runtime Error):
memo = {}

def starsFib(n,a):
    if n == 1:
        return 1
    elif n == 2:
        return 2

    elif n in a:
        return 0
    else:
        memo[n] = starsFib(n-1,a) + starsFib(n-2,a)
        return memo[n]

def run():
    n,m = map(int, input().split())
    a = [int(input()) for i in range(m)]

    all = starsFib(n,a)

    ans = all % 1000000007

    print(ans)

if __name__ == '__main__':
    run()


Fixed submission:
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

mod = 10**9+7
dp = [-1]*(n+1)
dp[0] = 1
dp[1] = 1

for i in a:
    dp[i] = 0

for i in range(2, n+1):
    if dp[i] < 0:
        dp[i] = (dp[i-1] + dp[i-2])%mod

print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int,input().split()))

if k > n:
    k = n-1

'''
n番目の場所に到達する時
n-1番目から、1つ飛んでくる
n-2番目から、２つ飛んでくる
...
n-K番目から、kつ飛んでくる

可能性がある　その時の最小値を考える

初期条件
dp[0] = 0
dp[1~Kまで]を計算

*** n-j
dp[n] = dp[n-j] + abs(h[n] - h[n-j])

漸化式
n >= 2
dp[n] = min(jump_list)

1~K
jump_list = [1 ~ j で dp[n] = dp[n-j] + abs(h[n] - h[n-j])]

k~N
jump_list = [1 ~ k で dp[n] = dp[n-j] + abs(h[n] - h[n-j])]

'''

#初期値
dp = [0]

def create_jump_list(j,i):
    alist = []
    for x in range(j, i):
        alist.append(
            dp[x] + abs(h[i] - h[x])
        )
    return alist

# kまで
for i in range(1, k+1):
    jump_list = create_jump_list(0,i)
    dp.append(
        min(jump_list)
    )

for i in range(k+1,n):
    jump_list = create_jump_list(i-k, i)
    dp.append(
        min(jump_list)
    )

#print(dp)
print(dp[n-1])


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

if k > n:
    k = n-1

'''
n番目の場所に到達する時
n-1番目から、1つ飛んでくる
n-2番目から、２つ飛んでくる
...
n-K番目から、kつ飛んでくる

可能性がある　その時の最小値を考える

初期条件
dp[0] = 0
dp[1~Kまで]を計算

*** n-j
dp[n] = dp[n-j] + abs(h[n] - h[n-j])

漸化式
n >= 2
dp[n] = min(jump_list)

1~K
jump_list = [1 ~ j で dp[n] = dp[n-j] + abs(h[n] - h[n-j])]

k~N
jump_list = [j-k ~ j で dp[n] = dp[n-j] + abs(h[n] - h[n-j])]

'''

#初期値
dp = [0]

def create_jump_list(j,i):
    alist = []
    for x in range(j, i):
        alist.append(
            dp[x] + abs(h[i] - h[x])
        )
    return alist

# kまで
for i in range(1, k+1):
    jump_list = create_jump_list(0,i)
    dp.append(
        min(jump_list)
    )

for i in range(k+1,n):
    jump_list = create_jump_list(i-k, i)
    dp.append(
        min(jump_list)
    )
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
res = 0
a, b = [0], [0]

for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

for i in range(n+1):
    j = m
    if a[i] > k:
        break
    while True:
        if a[i] + b[j] <= k:
            break
        j -= 1
    res = max(res, i+j)

print(res)


Fixed submission:
import sys
input = sys.stdin.readline

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
res = 0
a, b = [0], [0]

for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

j = m

for i in range(n+1):
    if a[i] > k:
        break
    while True:
        if a[i] + b[j] <= k:
            break
        j -= 1
    res = max(res, i+j)

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

n = int(input())
a = list(map(int, input().split()))
q = int(input())
oper = [list(map(int, input().split())) for _ in range(q)]
a.sort()
res = sum(a)

for i in range(q):
    b, c = oper[i]
    if b in a:
        bCount = a.count(b)
        idx = a.index(b)

        a = a[:idx] + a[idx+bCount:]
        a.extend([c]*bCount)
        dif = c-b

        res += dif*bCount

    print(res)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
q = int(input())
oper = [list(map(int, input().split())) for _ in range(q)]
dic = {}
for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1
        
res = sum(a)

for i in range(q):
    b, c = oper[i]
    if b in dic:
        bCount = dic[b]
        del(dic[b])
        if c in dic:
            dic[c] += bCount
        else:
            dic[c] = bCount

        dif = c-b

        res += dif*bCount

    print(res)

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

n = int(input())
a = list(map(int, input().split()))
q = int(input())
oper = [list(map(int, input().split())) for _ in range(q)]
a.sort()
res = sum(a)

for i in range(q):
    b, c = oper[i]
    if b in a:
        bCount = a.count(b)
        idx = a.index(b)

        a = a[:idx] + a[idx+1:]
        a.extend([c]*bCount)
        dif = c-b

        res += dif*bCount

    print(res)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
q = int(input())
oper = [list(map(int, input().split())) for _ in range(q)]
dic = {}
for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1
        
res = sum(a)

for i in range(q):
    b, c = oper[i]
    if b in dic:
        bCount = dic[b]
        del(dic[b])
        if c in dic:
            dic[c] += bCount
        else:
            dic[c] = bCount

        dif = c-b

        res += dif*bCount

    print(res)
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()) )

books = 0

p1 = 0
p2 = 0

while K > 0 and ( p1 < N or p2 < M ):
    books += 1

    if p1 < N and A[p1] < B[p2]:
        # print("chosen", "p1", p1)
        K -= A[p1]
        p1 += 1

    elif p2 < M:
        # print("chosen", "p2", p2)
        K -= B[p2]
        p2 += 1

    # print(K, p1, p2)

# print(K)

if K < 0:
    books -= 1
    print(books)

elif K == 0:
    print(books)

else:
    if p1 < N:
        while K > 0 and p1 < N:
            books += 1
            K -= A[p1]
            p1 += 1

    if p2 < M:
        while K > 0 and p2 < M:
            books += 1
            K -= B[p2]
            p2 += 1

    print(books)

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

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

A.insert(0, 0)
B.insert(0,0)

# convert to the cumulative/prefix sum
for i in range(1, len(A)):
    A[i] += A[i-1]

for i in range(1, len(B)):
    B[i] += B[i-1]

# print(A)
# print(B)

books_stack_a = 0

books_stack_b = M

cur_max = 0

for books_stack_a in range(0, N + 1):
    if A[books_stack_a] > K:
        break
    diff = K - A[books_stack_a]
    while diff < B[books_stack_b]:
        books_stack_b -= 1

    cur_max = max(cur_max, books_stack_b + books_stack_a)

print(cur_max)

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()) )

books = 0

p1 = 0
p2 = 0

while K > 0 and ( p1 < N or p2 < M ):
    books += 1

    if p1 < N and A[p1] < B[p2]:
        # print("chosen", "p1", p1)
        K -= A[p1]
        p1 += 1

    elif p2 < M:
        # print("chosen", "p2", p2)
        K -= B[p2]
        p2 += 1

    # print(K, p1, p2)

if K < 0:
    books -= 1
print(books)

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

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

A.insert(0, 0)
B.insert(0,0)

# convert to the cumulative/prefix sum
for i in range(1, len(A)):
    A[i] += A[i-1]

for i in range(1, len(B)):
    B[i] += B[i-1]

# print(A)
# print(B)

books_stack_a = 0

books_stack_b = M

cur_max = 0

for books_stack_a in range(0, N + 1):
    if A[books_stack_a] > K:
        break
    diff = K - A[books_stack_a]
    while diff < B[books_stack_b]:
        books_stack_b -= 1

    cur_max = max(cur_max, books_stack_b + books_stack_a)

print(cur_max)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
As = np.array(input().split()).astype(np.int64)

Q = int(input())

for q in range(Q):
  B, C = map(int, input().split())
  As[np.where(As==B)] = C
  print(As.sum())

Fixed submission:
import numpy as np

N = int(input())
lis = np.zeros(10**5)

As = np.array(input().split()).astype(np.int64)
NUM = As.sum()

for n in As:
  lis[n-1] += 1

Q = int(input())
for q in range(Q):
  B, C = map(int, input().split())
  nnn = lis[B-1]
  lis[B-1] = 0
  lis[C-1] += nnn
  NUM = NUM - B*nnn + C*nnn
  print(int(NUM))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Nums = input().split()

A = 1
break_flag = 0
for i in range(N):
  A*=int(Nums[i])
  if A > 10**18:
    A = -1
    break_flag = 1
  if A == 0:
    break_flag = 2

if break_flag == 1:
  print(-1)
else:
  print(A)

Fixed submission:
N = int(input())
Nums = input().split()

AA = set(Nums)

if '0' in AA:
  print(0)
else:
  A = 1
  for i in range(N):
    A*=int(Nums[i])
    if A > 10**18:
      A = -1
      break
  print(A)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  N, K = map(int, input().split())
  A_list = input().split()

  root = [1]

  break_flag = 0
  for n in range(K):
    new = A_list[ int(root[n])-1 ]
    if new not in root:
      root.append(new)
    else:
      ind = root.index(new)
      break
  else:
    print(new)
    break_flag = 1
    
  if break_flag == 0:  
	  pre = len(root[:ind])
	  roop = len(root)-pre

	  print(root[ind:][(K-pre)%roop])
   
if __name__ == '__main__':
  main()

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

  root = [1]

  record = [-1]*N
  break_flag = 0
  for n in range(K):
    new = int(A_list[ int(root[n])-1 ])
    if record[new-1] <0:
      record[new-1]=1
      root.append(new)
    else:
      ind = root.index(new)
      break
  else:
    print(new)
    break_flag = 1
    
  if break_flag == 0:  
	  pre = len(root[:ind])
	  roop = len(root)-pre

	  print(root[ind:][(K-pre)%roop])
   
if __name__ == '__main__':
  main()

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

root = [1]

break_flag = 0
for n in range(K):
  new = A_list[ int(root[n])-1 ]
  if new not in root:
    root.append(new)
  else:
    ind = root.index(new)
    break
else:
  print(new)
  break_flag = 1
    
if break_flag == 0:  
	pre = len(root[:ind])
	roop = len(root)-pre

	print(root[ind:][(K-pre)%roop])

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

  root = [1]

  record = [-1]*N
  break_flag = 0
  for n in range(K):
    new = int(A_list[ int(root[n])-1 ])
    if record[new-1] <0:
      record[new-1]=1
      root.append(new)
    else:
      ind = root.index(new)
      break
  else:
    print(new)
    break_flag = 1
    
  if break_flag == 0:  
	  pre = len(root[:ind])
	  roop = len(root)-pre

	  print(root[ind:][(K-pre)%roop])
   
if __name__ == '__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
se = []
for i in range(N):
  Si = input()
  if Si not in se:
    se.append(Si)
print(len(se))

Fixed submission:
N = int(input())
se = {-1}
for i in range(N):
  se.add(input())
print(len(se)-1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
base = np.zeros((1,3))
for _ in range(N):
  base = np.vstack([base, np.array(list(map(int, input().split()))).reshape(1,-1) ])

base = base[1:]

DP_list = [[0,0,0] for _ in range(N)]
pre_check = -1

i = 0
DP_list[i][0] = base[i][0]
DP_list[i][1] = base[i][1]
DP_list[i][2] = base[i][2]


for i in range(1,N):
  DP_list[i][0] = base[i][0] + max(DP_list[i-1][1], DP_list[i-1][2])
  DP_list[i][1] = base[i][1] + max(DP_list[i-1][0], DP_list[i-1][2])
  DP_list[i][2] = base[i][2] + max(DP_list[i-1][1], DP_list[i-1][0])

print(int(max(DP_list[-1])))

Fixed submission:
N = int(input())
a, b, c = [0] * N, [0] * N, [0] * N
for i in range(N):
	a[i], b[i], c[i] = map(int, input().split())
dp = [[0] * 3 for _ in range(N)]
#print(dp)
dp[0] = [a[0], b[0], c[0]]
for i in range(N - 1):
	dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + a[i + 1], dp[i][2] + a[i + 1])
	dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + b[i + 1], dp[i][2] + b[i + 1])
	dp[i + 1][2] = max(dp[i + 1][2], dp[i][0] + c[i + 1], dp[i][1] + c[i + 1])
print(max(dp[N - 1]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
base = np.zeros((1,3))
for _ in range(N):
  base = np.vstack([base, np.array(list(map(int, input().split()))).reshape(1,-1) ])

base = base[1:]

DP_list = [0 for _ in range(N)]
pre_check = -1

for i in range(0,N):
  for j in [0,1,2]:
    if j != pre_check:
      PRE = DP_list[i-1] if i>0 else 0
      if PRE + base[i, j] > DP_list[i]:
        DP_list[i] = PRE + base[i, j]
        pre_check_cnt = j
  pre_check = pre_check_cnt

print(int(DP_list[-1]))

Fixed submission:
N = int(input())
a, b, c = [0] * N, [0] * N, [0] * N
for i in range(N):
	a[i], b[i], c[i] = map(int, input().split())
dp = [[0] * 3 for _ in range(N)]
#print(dp)
dp[0] = [a[0], b[0], c[0]]
for i in range(N - 1):
	dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + a[i + 1], dp[i][2] + a[i + 1])
	dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + b[i + 1], dp[i][2] + b[i + 1])
	dp[i + 1][2] = max(dp[i + 1][2], dp[i][0] + c[i + 1], dp[i][1] + c[i + 1])
print(max(dp[N - 1]))
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
ws = [0] * N
vs = [0] * N

for i in range(N):
  ws[i], vs[i] = map(int, input().split())

import numpy as np
dp_table = [[0]*(W+1) for _ in range(N+1)]

for i in range(1,N+1):
  for w_now in range(1,W+1):
    if w_now - ws[i-1] >= 0:
      dp_table[i][w_now] = max( dp_table[i-1][w_now], dp_table[ i-1][w_now-ws[i-1] ] + vs[i-1] )
    else:
      dp_table[i][w_now] = dp_table[i-1][w_now]
print(int(dp_table[-1][-1]))

Fixed submission:
N, W = map(int, input().split())
ws = [0] * N
vs = [0] * N

for i in range(N):
  ws[i], vs[i] = map(int, input().split())

dp_table = [[0]*(W+1) for _ in range(N+1)]

for i in range(1,N+1):
  for w_now in range(1,W+1):
    if w_now - ws[i-1] >= 0:
      dp_table[i][w_now] = max( dp_table[i-1][w_now], dp_table[ i-1][w_now-ws[i-1] ] + vs[i-1] )
    else:
      dp_table[i][w_now] = dp_table[i-1][w_now]
print(int(dp_table[-1][-1]))

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
ws = [0] * N
vs = [0] * N

for i in range(N):
  ws[i], vs[i] = map(int, input().split())

import numpy as np
dp_table = np.zeros((N+1,W+1))

for i in range(1,N+1):
  for w_now in range(1,W+1):
    if w_now - ws[i-1] >= 0:
      dp_table[i, w_now] = max( dp_table[i-1 , w_now], dp_table[ i-1, w_now-ws[i-1] ] + vs[i-1] )
    else:
      dp_table[i, w_now] = dp_table[i-1 , w_now]
print(int(dp_table[-1, -1]))

Fixed submission:
N, W = map(int, input().split())
ws = [0] * N
vs = [0] * N

for i in range(N):
  ws[i], vs[i] = map(int, input().split())

dp_table = [[0]*(W+1) for _ in range(N+1)]

for i in range(1,N+1):
  for w_now in range(1,W+1):
    if w_now - ws[i-1] >= 0:
      dp_table[i][w_now] = max( dp_table[i-1][w_now], dp_table[ i-1][w_now-ws[i-1] ] + vs[i-1] )
    else:
      dp_table[i][w_now] = dp_table[i-1][w_now]
print(int(dp_table[-1][-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):
    if 0<=S-(x+y)<=K:
      cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
ans = 1
n = input()
n = int(n)
nums = input().split()
for i in range(n):
    mul = int(nums[i])
    ans = ans * mul

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

Fixed submission:
ans = 1
n = input()
n = int(n)
nums = input().split()
for i in range(n):
    mul = int(nums[i])
    if mul == 0:
        print(0)
        exit()


for i in range(n):
    mul = int(nums[i])
    ans = ans * mul
    if ans > 10**18:
        print(-1)
        exit()

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

exit()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
x = 1
for i in A:
    x *= i
if x > 10**18:
    print(-1)
else:
    print(x)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
x = 1
if 0 in A:
    print(0)
else:
    for i in A:
        x *= i
        if x > 10**18:
            break
    if x > 10**18:
        print(-1)
    else:
        print(x)
Buggy python submission (verdict: Runtime Error):
A,B,N = map(int,input().split())
tmp=0
for i in range(N//2,N+1):
    floor = (A*i)//B-A*(i//B)
    if floor>tmp:
        tmp = floor
print(tmp)

Fixed submission:
K=int(input())
A,B=map(int,input().split())
for i in range(A,B+1):
    if i%K==0:
        print("OK")
        break
    elif i%K!=0 and i==B:
        print("NG")
Buggy python submission (verdict: Runtime Error):
import math as mt
A,B,N = map(int,input().split())
print(math.floor((A*N)/B)-A*math.floor(N/B))

Fixed submission:
import math
A,B,N = map(int,input().split())
if B-1>N:
    print(math.floor((A*N)/B)-A*math.floor(N/B))
else:
    print(math.floor((A*(B-1))/B)-A*math.floor((B-1)/B))

Buggy python submission (verdict: Runtime Error):
import math as mt
A,B,N = map(int,input().split())
print(math.floor((A*N)/B)-A*math.floor(N/B)

Fixed submission:
import math
A,B,N = map(int,input().split())
if B-1>N:
    print(math.floor((A*N)/B)-A*math.floor(N/B))
else:
    print(math.floor((A*(B-1))/B)-A*math.floor((B-1)/B))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N = map(int,input().split())
tmp=0
for i in range(0,N+1):
    floor = (A*i)//B-A*(i//B)
    if floor>tmp:
        tmp = floor
print(tmp)

Fixed submission:
import math
A,B,N = map(int,input().split())
if B-1>N:
    print(math.floor((A*N)/B)-A*math.floor(N/B))
else:
    print(math.floor((A*(B-1))/B)-A*math.floor((B-1)/B))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math as mt
N=int(input())
#R=map(int, input().split())
A=list(map(int,input().split()))
count=1
p_count=0
for i in range(0,N-1):
    print(A.count(i+1))
print(0)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = [0] * N
for i in A:
    ans[i-1]=ans[i-1]+1
for i in range(0,N):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math as mt
N=int(input())
#R=map(int, input().split())
A=list(map(int,input().split()))
for i in range(0,N):
    print(A.count(i+1))

    



Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = [0] * N
for i in A:
    ans[i-1]=ans[i-1]+1
for i in range(0,N):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
X = list(map(int,input().split()))
X.sort()
a=list()
c=N-1
for i in range(X[0],X[c]):
    b=0
    for j in range(0,N):
        if i-X[j]>10**5:
            break
        b+=(i-X[j])**2
    a.append(b)
print(min(a))

Fixed submission:
import numpy as np
N=int(input())
X = list(map(int,input().split()))
X.sort()
a=list()
c=N-1
for i in range(X[0],X[c]+1):
    b=0
    for j in range(0,N):
        if i-X[j]>10**5:
            break
        b+=(i-X[j])**2
    a.append(b)
print(min(a))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
X = list(map(int,input().split()))
X.sort()
a=list()
c=N-1
for i in range(X[0],X[c]):
    b=0
    for j in range(0,N):
        b+=(i-X[j])**2
    a.append(b)
print(min(a))

Fixed submission:
import numpy as np
N=int(input())
X = list(map(int,input().split()))
X.sort()
a=list()
c=N-1
for i in range(X[0],X[c]+1):
    b=0
    for j in range(0,N):
        if i-X[j]>10**5:
            break
        b+=(i-X[j])**2
    a.append(b)
print(min(a))
Buggy python submission (verdict: Runtime Error):
H=int(input())
A=int(input())
a=int(H/A)
if H%A!=0:
    a+=1
print(a)

Fixed submission:
H,A=map(int,input().split())
a=int(H/A)
if H%A!=0:
    a+=1
print(a)
Buggy python submission (verdict: Runtime Error):
import numpy as np
while(1):
    N,A,B = map(int,input().split())
    x=abs(A-B)
    

    if x%2==0:
        print(x//2)
    else:
        y,z=max(N-A,N-B),max(A-1,B-1)
        a,b=min(A-1,B-1),min(N-A,N-B)
        c,d=max(A-1,B-1)-a,max(N-A,N-B)-b
        e,f=c//2+a+1,d//2+b+1
        if y>z:
            print(min(z,e,f))
        else:
            print(min(y,e,f))

Fixed submission:
import numpy as np
N,A,B = map(int,input().split())
x=abs(A-B)
    

if x%2==0:
    print(x//2)
else:
    y,z=max(N-A,N-B),max(A-1,B-1)
    a,b=min(A-1,B-1),min(N-A,N-B)
    c,d=max(A-1,B-1)-a,max(N-A,N-B)-b
    e,f=c//2+a+1,d//2+b+1
    if y>z:
        print(min(z,e,f))
    else:
        print(min(y,e,f))
Buggy python submission (verdict: Runtime Error):
import fractions
A,B=map(int,input().split())
print(int(A*B/fractions.gcd(A,B)))

Fixed submission:
from math import sqrt
from decimal import Decimal
ans = [1,2,3]
A,B=int(input()),int(input())
ans.remove(A)
ans.remove(B)
print(ans[0])

Buggy python submission (verdict: Runtime Error):
from math import sqrt
from decimal import Decimal
ans = [1,2,3]
A,B=map(int,input().split())
ans.remove(A)
ans.remove(B)
print(ans[0])

Fixed submission:
from math import sqrt
from decimal import Decimal
ans = [1,2,3]
A,B=int(input()),int(input())
ans.remove(A)
ans.remove(B)
print(ans[0])
Buggy python submission (verdict: Runtime Error):
N=int(input())
S,T=map(str,input().split())
S,T=list(S),list(T)
print(S[2])
x=list("a"*(N*2))
for i in range(0,N*2):
    if i%2==0:
        x[i]=S[i//2]
    else:
        x[i]=T[i//2]
x="".join(x)
print(x)


Fixed submission:
N=int(input())
S,T=map(str,input().split())
S,T=list(S),list(T)
x=list("a"*(N*2))
for i in range(0,N*2):
    if i%2==0:
        x[i]=S[i//2]
    else:
        x[i]=T[i//2]
x="".join(x)
print(x)
Buggy python submission (verdict: Runtime Error):
import math as mt 
A,B=map(int,input().split())
print(int(A*B/mt.gcd(A,B)))

Fixed submission:
import fractions
A,B=map(int,input().split())
print(int(A*B/fractions.gcd(A,B)))