Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03164 (python)

Fixed submission:
# dp[i][j]: i+1個の品物から価値がj以上になるように選んだときの重量の最小値
N, W = map(int, input().split())
w, v = [], []
for _ in range(N):
    tmp = list(map(int, input().split()))
    w.append(tmp[0])
    v.append(tmp[1])
V = sum(v)
dp = [[float("inf") for _ in range(V+1)] for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for j in range(V+1):
        if j - v[i] >= 0:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

# dp[N][j]がW以下であるときのｊの最大値
ans = []
for j in range(V+1):
    if dp[N][j] <= W:
        ans.append(j)
print(max(ans))

Buggy submission (verdict: Runtime Error):
# dp[i][j]: i+1個の品物から価値がj以上になるように選んだときの重量の最小値

dp[0][0] = 0
for i in range(N):
    for j in range(V+1):
        if j - v[i] >= 0:
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

# dp[N][j]がW以下であるときのｊの最大値
ans = []
for j in range(V+1):
    if dp[N][j] <= W:
        ans.append(j)
print(max(ans))
Problem p03607 (python)

Fixed submission:
d={}
for _ in[0]*int(input()):
    i=input()
    d[i]=d.get(i,0)^1
print(sum(d.values()))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
    
a.sort()
flag=False
ans = 0
i = 0
while i <= len(a) - 1:
    if a[i] != a[i+1]:
        ans += 1
        i += 1
        flag=True
    else:
        i += 2
        flag=False

if flag:
    ans += 1
print(ans)
Problem p02922 (python)

Fixed submission:
import math
A,B=map(int, input().split())
print(math.ceil((B-1)/(A-1)))

Buggy submission (verdict: Runtime Error):
A,B=map(int, input().split())
print(ceil((B-1)/(A-1)))
Problem p02922 (python)

Fixed submission:
from math import ceil

inputs = input()
a = int(inputs.split(" ")[0])
b = int(inputs.split(" ")[1])
print(ceil((b - 1) / (a - 1)))

Buggy submission (verdict: Runtime Error):
inputs = input()
a, b = int(inputs.split(' '))
a * n - (n - 1) >= b
print(int((b + 1) / (a -1))
Problem p03485 (python)

Fixed submission:
from math import ceil

a, b = map(float, input().split())
print(ceil((a + b) / 2))

Buggy submission (verdict: Runtime Error):
from math import ceil
a, b = map(float, input().split(' '))
return ceil(a + b / 2)
Problem p02767 (python)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
ans=10**18 #最小値を求めるので初期化しておく
for i in range(1,101): #1<=P<=100の範囲について消費する体力の総和を計算
 tmp=0
 for num in arr:
   tmp+=(i-num)**2
 ans=min(ans,tmp) #消費する体力の総和の最小値が答えとなる
print(ans)

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

X = list(map(int, input().split()))
ans = 10**18
for i in range(1, 101):
    temp=0
    for num in X:
        temp += (i-num)**2
    ans = min(ans, tmp)
print(ans)

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

X = list(map(int, input().split()))
ans = 10**18
for i in range(1, 101):
    temp=0
    for num in X:
        temp + =(i-num)**2
    ans = min(ans, tmp)
print(ans)

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

X = list(map(int, input().split()))
ans = 10**18
for i in range(1. 101):
    temp=0
    for num in X:
        temp + =(i-num)**2
    ans = min(ans, tmp)
print(ans)
Problem p03145 (python)

Fixed submission:
a=input()
x=[ int(y) for y in a.split() ]
print(x[0]*x[1]//2)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())

print(a*b/2)
Problem p02922 (python)

Fixed submission:
a,b = map(int, input().split())
i = a
c = 1
while int(i) < b:
  i += a - 1
  c += 1
if b == 1:
  print(0)
else:
  print(c)

Buggy submission (verdict: Runtime Error):
i = [input() for i in range(2)]
a = [i for i in i[0]]
b = [i for i in i[1]]
c = 0
for i in range(3):
  if a[i] == b[i]:
    c += 1
  else:
    c += 0
print(c)
Problem p02883 (python)

Fixed submission:
n,k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

def isOk(x):
    cost = 0
    for a, f in zip(A,F):
        eatable = x//f
        if eatable >= a:
            continue
        cost += a - eatable
    if cost <= k:
        return True
    return False

left = -1
right = A[-1] * F[0]
while left+1 < right:
    # mid = int(left + (right-left)//2)
    mid = (left+right)//2
    if isOk(mid):
        right = mid
    else:
        left = mid
print(right)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

def isOk(x):
    cost = 0
    for a, f in zip(A,F):
        eatable = x//f
        if eatable >= a:
            continue
        cost += a - eatable
    if cost <= k:
        return True
    return False

left = -1
right = A[-1] * F[0]
while left+1 < right:
    mid = int(left + (right-left)//2)
    if isOk(mid):
        right = mid
    else:
        left = mid
print(right)n,k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

def isOk(x):
    cost = 0
    for a, f in zip(A,F):
        eatable = x//f
        if eatable >= a:
            continue
        cost += a - eatable
    if cost <= k:
        return True
    return False

left = -1
right = A[-1] * F[0]
while left+1 < right:
    mid = int(left + (right-left)//2)
    if isOk(mid):
        right = mid
    else:
        left = mid
print(right)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

def isOk(x):
    cost = 0
    for A,F in zip(A,F)
        eatable = x//F
        if eatable >= A:
            continue
        cost += A - eatable
    if cost <= k:
        return True
    return False

left = 0
right = 1e12
while left+1 < right:
    mid = int(left + (right-left)//2)
    if isOk(mid):
        right = mid
    else:
        left = mid
if sum(A) <= k:
    right = 0
print(right)
Problem p02888 (python)

Fixed submission:
import bisect as bs
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        s = L[i] + L[j]
        ans += bs.bisect_left(L,s) - j - 1
        # bisect.bisect_left(list, x)
        # はリストにxを挿入できる点を返す
        # すなわち、
        # (val < x for val in list[0:i]) + (val >= x for val in list[i:len(list)])
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        s = L[i] + L[j]
        ans += bs.bisect_left(L,s) - j - 1
        # bisect.bisect_left(list, x)
        # はリストにxを挿入できる点を返す
        # すなわち、
        # (val < x for val in list[0:i]) + (val >= x for val in list[i:len(list)])
print(ans)
Problem p03574 (python)

Fixed submission:
H, W = list(map(int, input().split()))
S = []
for _ in range(H):
    S.append(list(input()))

if H > 1:
    for w in range(W):
        if S[0][w] == ".":
            S[0][w] = str(S[0][max(0,w-1):min(W, w+2)].count("#")
                        +S[1][max(0,w-1):min(W, w+2)].count("#"))

    for h in range(1, H-1):
        for w in range(W):
            if S[h][w] == ".":
                S[h][w] = str(S[h-1][max(0,w-1):min(W, w+2)].count("#")
                            +S[h][max(0,w-1):min(W, w+2)].count("#")
                            +S[h+1][max(0,w-1):min(W, w+2)].count("#"))

    for w in range(W):
            if S[H-1][w] == ".":
                S[H-1][w] = str(S[H-2][max(0,w-1):min(W, w+2)].count("#")
                            +S[H-1][max(0,w-1):min(W, w+2)].count("#"))

else:
    for w in range(W):
        if S[0][w] == ".":
            S[0][w] = str(S[0][max(0,w-1):min(W, w+2)].count("#"))
for h in range(H):
    print("".join(S[h]))

Buggy submission (verdict: Runtime Error):
H, W = list(map(int, input().split()))
S = []
for _ in range(H):
    S.append(list(input()))
    
for w in range(W):
    if S[0][w] == ".":
        S[0][w] = str(S[0][max(0,w-1):min(W, w+2)].count("#")
                    +S[1][max(0,w-1):min(W, w+2)].count("#"))

for h in range(1, H-1):
    for w in range(W):
        if S[h][w] == ".":
            S[h][w] = str(S[h-1][max(0,w-1):min(W, w+2)].count("#")
                        +S[h][max(0,w-1):min(W, w+2)].count("#")
                        +S[h+1][max(0,w-1):min(W, w+2)].count("#"))
            
for w in range(W):
        if S[H-1][w] == ".":
            S[H-1][w] = str(S[H-2][max(0,w-1):min(W, w+2)].count("#")
                        +S[H-1][max(0,w-1):min(W, w+2)].count("#"))
            
for h in range(H):
    print("".join(S[h]))
Problem p03589 (python)

Fixed submission:
import math

N = int(input())

if N%2 == 0:
    print(N, N, N//2)
    
else:
    flag = False
    
    for h in range(1, 3501):
        if flag == True:
            break
        
        for n in range(1, 3501):
            if flag == True:
                break
            
            if ((n*(h*4-N)-N*h) > 0) and (N*h*n)%(n*(h*4-N)-N*h) == 0:
                print(h, n, (N*h*n)//(n*(h*4-N)-N*h))
                flag = True

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

if N%2 == 0:
    print(N, N, N//2)
    
else:
    flag = False
    H = math.ceil(N/4)
    for h in range(H, 10000):
        if flag == True:
            break
        
        N_ = math.ceil((N*h)/(h*4-N)) 
        for n in range(N_, 10000):
            if flag == True:
                break
            
            if (N*h*n)%(n*(h*4-N)-N*h) == 0:
                print(h, n, (N*h*n)//(n*(h*4-N)-N*h))
                flag = True

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

if N%2 == 0:
    print(N, N, N//2)
    
else:
    flag = False
    H = math.ceil(N/4)
    for h in range(H, 3501):
        if flag == True:
            break
        
        N_ = math.ceil((N*h)/(h*4-N)) 
        for n in range(N_, 3501):
            if flag == True:
                break
            
            
            if (N*h*n)%(n*(h*4-N)-N*h) == 0:
                print(h, n, (N*h*n)//(n*(h*4-N)-N*h))
                flag = True
Problem p03612 (python)

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

ans = 0

i = 0

while i < len(P):
    if i+1 == P[i]:
        if i+1 != len(P):
            if i+2 == P[i+1]:
                ans += 1
                i += 1
            else:
                ans += 1
        else:
            ans += 1
    i += 1
    
print(ans)

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

ans = 0

i = 0

while i < len(P):
    if i+1 == P[i]:
        if i+2 == P[i+1]:
            ans += 1
            i += 1
        else:
            ans += 1
    i += 1
    
print(ans)
Problem p03651 (python)

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

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

ans = False

A = sorted(A)

key = 99999999999999
    
if A[-1] < K:
    ans = False

else:
    for i in range(2, A[0]+1):
        key_flag = True
        for a in A:
            if a % i !=0:
                key_flag = False
                break
                
        if key_flag == True:
            key = i
            break

    if key_flag == False:
        ans = True
#         print(1)
    elif K % key == 0:
        ans = True
#         print(2)
    else:
#         print(3)
        ans = False           
    
if ans == True:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
X, Y, Z = list(map(int, input().split(" ")))

import numpy as np

ABC = []

for i in range(X+Y+Z):
    ABC.append(list(map(int, input().split(" "))))

ABC = sorted(ABC, key=lambda row: row[0]-row[1])    

ans = 0

ABC_bk = ABC_np[:Y]
ABC_ak = ABC_np[Y:]

for k in range(Y, Y+Z):
    
    ABC_bk = ABC_bk + ABC_ak[0]
    ABC_ak = ABC_ak.pop(0)
    
    
    before_k = np.asarray(sorted(ABC_bk.tolist(), key=lambda row: row[1]-row[2]))
    after_k = np.asarray(sorted(ABC_ak.tolist(), key=lambda row: row[0]-row[2]) )      
    
    bk_sum = before_k[-Y:].sum(axis=0)[1] + before_k[:-Y].sum(axis=0)[2]
    ak_sum = after_k[-X:].sum(axis=0)[0] + after_k[:-X].sum(axis=0)[2]
    
    tmp = ak_sum + bk_sum
                          
    if ans < tmp:
        ans = tmp
    
print (ans)
Problem p03681 (python)

Fixed submission:
MOD = 1000000007

dp=[0 for _ in range(100001)]
dp[0]=1

for i in range(1, 100001):
    dp[i] = dp[i-1]*i%MOD


N, M = list(map(int, input().split(" ")))

if abs(N - M) > 1:
    print("%d"%(0))
elif (N - M) == 0:
    print ("%d"%(2*((dp[N])*(dp[M]))%MOD))
else :
    print ("%d"%(((dp[N])*(dp[M]))%MOD))

Buggy submission (verdict: Runtime Error):
MOD = 1000000007

def fractorial(n):
    ans = 1
    for i in range(n):
        ans *= (i+1)
        ans = ans % MOD    
    return ans


N, M = list(map(int, input().split(" ")))

if abs(N - M) > 1:
    print("%d"%(0))
elif (N - M) == 0:
    print ("%d"%(2*((factorial(N))*(factorial(M)))%MOD))
else :
    print ("%d"%(((factorial(N))*(factorial(M)))%MOD))

Buggy submission (verdict: Runtime Error):
MOD = 1e+9+7

def fractorial(n):
    ans = 1
    for i in range(n):
        ans *= (i+1)
        ans = ans % MOD    
    return ans


N, M = list(map(int, input().split(" ")))

if abs(N - M) > 1:
    print("%d"%(0))
elif (N - M) == 0:
    print ("%d"%(2*((factorial(N))*(factorial(M)))%MOD))
else :
    print ("%d"%(((factorial(N))*(factorial(M)))%MOD))
Problem p03703 (python)

Fixed submission:
N, K = map(int, input().split())
a = []
for _ in range(N):
    a.append(int(input())-K)
    
su = 0
v = [(0, 0)]
for i in range(N):
    su += a[i]
    v.append((su, i+1))
v = sorted(v)

data = [0]*(N+5)

def sumation(i):
    s = 0
    while i > 0:
        s += data[i]
        i -= i & -i
    return s
    
def add(i, x):
    while i <= N+2:
        data[i] += x
        i += i & -i
ans = 0
for e, i in v:
    ans += sumation(i+1)
    add(i+1, 1)
    
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
a = []
for _ in range(N):
    a.append(int(input())-K)
    
su = 0
v = [(0, 0)]
for i in range(N):
    su += a[i]
    v.append((su, i+1))
v = sorted(v)

data = [0]*(N+1)

def sumation(i):
    s = 0
    while i > 0:
        s += data[i]
        i -= i & -i
    return s
    
def add(i, x):
    while i <= N:
        data[i] += x
        i += i & -i
ans = 0
for e, i in v:
    ans += sumation(i+1)
    add(i+1, 1)
    
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
a = []
for _ in range(N):
    a.append(int(input())-K)
    
su = 0
v = [(0, 0)]
for i in range(N):
    su += a[i]
    v.append((su, i+1))
v = sorted(v)

data = [0]*(N+2)

def sumation(i):
    s = 0
    while i > 0:
        s += data[i]
        i -= i & -i
    return s
    
def add(i, x):
    while i <= N+2:
        data[i] += x
        i += i & -i
ans = 0
for e, i in v:
    ans += sumation(i+1)
    add(i+1, 1)
    
print(ans)
Problem p03721 (python)

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

nums = {}

for _ in range(N):
    a, b = list(map(int, input().split(" ")))
    
    if a in nums:
        nums[a] += b
    else :
        nums[a] = b
        
acc = 0
for key in sorted(nums.keys()):
    acc += nums[key]
    if acc >= K:
        print(key)
        break

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

d = dict()

for i in range(N):
    a, b = list(map(int, input().split(" ")))
    if a in d:
        d[a] = d[a] + b
    else:
        d[a] = b
    
ans_sum = 0

for key in sorted(d.keys()):
    ans_sum += d[key]
    if (ans_sum) >= K:
        print(k)
        break
Problem p04032 (python)

Fixed submission:
s = input()

a = -1
b = -1

for i in range(len(s)-2):
    if s[i]==s[i+1]:
        a = i+1
        b = i+2
        break
    elif s[i]==s[i+2]:
        a = i+1
        b = i+3
        break
if s[-2]==s[-1]:
    a = len(s)-1
    b = len(s)
        
print(str(a)+" "+str(b))

Buggy submission (verdict: Runtime Error):
s = input()

a = -1
b = -1

for i in range(N-2):
    if s[i]==s[i+1]:
        a = i+1
        b = i+2
        break
    elif s[i]==s[i+2]:
        a = i+1
        b = i+3
        break
        
print(str(a)+" "+str(b))
Problem p03001 (python)

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

if x == W * (1 / 2) and y == H * (1 / 2):
   e=1
else:
    e=0

print((W*H)*(1/2),e)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
a = H * (W - x)
b = H * W - H * (W - x)
c = W * (H - y)
d = H * W - W * (H - y)

if W == H:
    if y == x or y == -x + H:
        e = 1
    else:
        e = 0
else:
    if x == W * (1 / 2) and y == H * (1 / 2):
        e = 1
    else:
        e = 0

else:
e = 0

if a <= b:
    if c <= d:
        if a <= c:
            print(c, e)
        else:
            print(a, e)
    else:
        if a <= d:
            print(d, e)
        else:
            print(a, e)
else:
    if c <= d:
        if b <= c:
            print(c, e)
        else:
            print(b, e)
    else:
        if b <= d:
            print(d, e)
        else:
            print(b, e)
Problem p03106 (python)

Fixed submission:
A,B,K = map(int,input().split())
 
cnt = 0
ans = []
 
for i in range(1,101):
    if A%i == 0 and B%i == 0:
        ans.append(i)
 
print(ans[-K])

Buggy submission (verdict: Runtime Error):
a, b, k = (int(i) for i in input().split())
ok_list = []
for i in range(1,max(a, b)):
    if a % i == b % i == 0:
       ok_list.append(i)
print(ok_list[k-1])

Buggy submission (verdict: Runtime Error):
a, b, k = (int(i) for i in input().split())
ok_list = []
for i in range(1,max(a, b)):
    if a % i == b % i == 0:
       ok_list.append(i)
print(ok_list[k])
Problem p03239 (python)

Fixed submission:
# 制限時間以内でコストの最小のものを選ぶ
n, t = map(int, input().split())
v = [list(map(int, list(input().split()))) for i in range(n)]
list = []
for i in range(n):
    if v[i][1] <= t:
        list.append(v[i][0])
if list == []:
    print("TLE")
else:
    print(min(list))

Buggy submission (verdict: Runtime Error):
#制限時間以内でコストの最小のものを選ぶ
n,t=map(int,input().split())
v=[list(map(int,list(input().split()))) for i in range(n)]
list=[]
for i in range(n):
    if v[i][1] <= t:
        list.append(v[i][0])
if list==0:
    print("TLE")
else:
    print(min(list))
Problem p03261 (python)

Fixed submission:
n = int(input())
list_w = [input() for i in range(n)]
list_ok = [list_w[0]]

if len(list_w) != len(set(list_w)):
    print("No")

else:
    for i in range(1, n):
        if list_w[i - 1][-1] == list_w[i][0]:
            list_ok.append(list_w[i])
            i += 1
    if len(list_ok) == len(list_w):
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())
print(x2+(y1-y2),y2+(x2-x1),x1+(y1-y2),y1+(x2-x1))
Problem p03262 (python)

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

def gcdlist(l):
    if len(l) == 2:
        return gcd(l[0], l[1])
    f = l.pop()
    s = l.pop()
    m = gcd(f, s)
    l.append(m)
    return gcdlist(l)


def main():
    n, x = map(int, input().split())
    a = [int(v) for v in input().split(' ')]
    a.append(x)
    a.sort()
    dis = [x2 - x1 for x1, x2 in zip(a, a[1:])]
    max_ = 0
    for i in range(n):
        if len(dis) == 1:
            max_ = dis[0]
            break
        try:
            max_ = gcdlist(dis)
        except:
            max_ = 1
    print(max_)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a %b)

def gcdlist(l):
    if len(l) == 2:
        return gcd(l[0], l[1])
    f = l.pop()
    s = l.pop()
    m = gcd(f, s)
    l.append(m)
    return gcdlist(l)


def main():
    n, x = map(int, input().split())
    a = [int(v) for v in input().split(' ')]
    a.append(x)
    a.sort()
    dis = [x2 - x1 for x1, x2 in zip(a, a[1:])]
    max_ = 0
    for i in range(n):
        if len(dis) == 1:
            max_ = dis[0]
            break
        max_ = gcdlist(dis)
    print(max_)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math

def main():
    n, x = map(int, input().split())
    a = [int(v) for v in input().split(' ')]
    a.append(x)
    a.sort()
    dis = [x2 - x1 for x1, x2 in zip(a, a[1:])]
    max_ = 0
    for i in range(n):
        if len(dis) == 1:
            max_ = dis[0]
            break
        try:
            g = max([math.gcd(d1, d2) for d1, d2 in zip(dis[i:], dis[i+1:])])
        except ValueError:
            break
        if g > max_:
            max_ = g
    print(max_)

if __name__ == '__main__':
    main()
Problem p02791 (python)

Fixed submission:
N = int(input())
m = [0]*N
s = input()
m = s.split()
c = 99999999
k = 0
for i in range(N):
	m[i] = int(m[i])
	if m[i] <= c:
		c = m[i]
		k +=1

print(k)

Buggy submission (verdict: Runtime Error):
N = int(input())
m = [0]*N
s = input()
m = s.split()
c = 99999999
k = 0
for i in range(N):
	if m[i] > c:
		c = m[i]
		k +=1

print(c)
Problem p02767 (python)

Fixed submission:
# coding: utf-8
import sys

N = int(input())
Xi = list(map(int, input().split()))
Xi.sort()
min = Xi[0]
max = Xi[N-1]
tmp = 0
result = sys.maxsize
for i in range(min,max+1):
    for j in range(0,N):
        tmp += (Xi[j] - i)**2
    if tmp <= result:
        result = tmp
    tmp = 0

print(result)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math


N = int(input())
Xi = list(map(int, input().split()))
Xi.sort()
min = Xi[0]
max = Xi[N-1]
tmp = 0
result = math.inf
for i in range(min,max+1):
    for j in range(0,N):
        tmp += (Xi[j] - i)**2
    if tmp <= result:
        result = tmp
    tmp = 0

print(result)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

if __name__=='__main__':
    N = int(input())
    Xi = list(map(int, input().split()))
    Xi.sort()
    min = Xi[0]
    max = Xi[N-1]
    tmp = 0
    result = math.inf
    for i in range(min,max+1):
        for j in range(0,N):
            tmp += (Xi[j] - i)**2
        if tmp <= result:
            result = tmp
        tmp = 0

    print(result)
Problem p03206 (python)

Fixed submission:
d=int(input())
ans="Christmas"
for i in range(25-d):
  ans+=" Eve"
print(ans)

Buggy submission (verdict: Runtime Error):
n,x=[int(i) for i in input().split()]
p=[1]
b=[0]
z=[]
for i in range(n):
  p.append(p[i]*2+1)
  b.append(b[i]*2+2)
  z.append(p[i]+b[i])
ans=0
ici=0
for i in range(n-1, -1, -1):
  if x-ici>z[i]+1:
    ici+=z[i]+2
    ans+=p[i]+1
  elif x-ici<z[i]+1:
    ici+=1
  else:
    ans+=p[i]
    break
print(ans)
Problem p03211 (python)

Fixed submission:
s=input()
ans=999
for i in range(len(s)-2):
  ans=min(abs(753-int(s[i:i+3])),ans)
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
ans=999
for i in range(s.len()-2):
  ans=min(abs(753-int(s[i:i+2])),ans)
print(ans)
Problem p03227 (python)

Fixed submission:
a=input()
if len(a)==3:
    print(a[2]+a[1]+a[0])
else:
    print(a)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
A.sort()
me=1
usr=N-2
lenme=A[0]
lenusr=A[N-1]
ans=A[N-1]-A[0]

for i in range(N-2):
    if max([abs(A[me]-lenme),abs(A[me]-lenusr)])>=max([abs(A[usr]-lenme),abs(A[usr]-lenusr)]):
        if abs(A[me]-lenme)>=abs(A[me]-lenusr):
            ans+=abs(A[me]-lenme)
            lenme=A[me]
        else:
            ans+=abs(A[me]-lenusr)
            lenusr=A[me]
        me+=1
    else:
        if abs(A[usr]-lenme)>=abs(A[usr]-lenusr):
            ans+=abs(A[usr]-lenme)
            lenme=A[usr]
        else:
            ans+=abs(A[usr]-lenusr)
            lenusr=A[usr]
        usr-=1
print(ans)

Buggy submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
for i in range(K):
    if i%2==0:
        if A%2==1:
            A-=1
        B+=int(A/2)
        A=int(A/2)
    else:
        if B%2==1:
            B-=1
        A+=int(B/2)
        B=int(B/2)
print(str(A)+" "+str(B))