Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import deque

H, W = map(int, input().split())
ch, cw = map(int, input().split())
gh, gw = map(int, input().split())

ch += 1
cw += 1
gh += 1
gw += 1

maze = ["#"*(W+4), "#"*(W+4)] + ["##" + input() + "##" for _ in range(H)] + ["#"*(W+4), "#"*(W+4)]
visited = [[-1]*(W+4) for _ in range(H+4)]
visited[ch][cw] = 0

walk = [[-1, 0], [1, 0], [0, -1], [0, 1]]
warp = [[-2, -2], [-2, -1], [-2, 0], [-2, 1], [-2, 2], [-1, -2], [-1, -1], [-1, 0], [-1, 1], [-1, 2],
        [0, -2], [0, -1], [0, 1], [0, 2], [1, -2], [1, -1], [1, 0], [1, 1], [1, 2], [2, -2], [2, -1], [2, 0], [2, 1], [2, 2]]

stack_walk = [[ch, cw]]
stack_warp = [[ch, cw]]

while stack_walk or stack_warp:
    while stack_walk:
        h, w = stack_walk.pop()
        for dh, dw in walk:
            h_next = h + dh
            w_next = w + dw
            if maze[h_next][w_next]=="." and (visited[h_next][w_next]==-1 or visited[h_next][w_next] > visited[h][w]):
                visited[h_next][w_next] = visited[h][w]
                stack_walk.append([h_next, w_next])
                stack_warp.append([h_next, w_next])
    
    while stack_warp:
        h, w = stack_warp.pop()
        for dh, dw in warp:
            h_next = h + dh
            w_next = w + dw
            if maze[h_next][w_next]=="." and visited[h_next][w_next]==-1:
                visited[h_next][w_next] = visited[h][w] + 1
                stack_walk.append([h_next, w_next])
                stack_warp.append([h_next, w_next])

print(visited[gh][gw])


Fixed submission:
N, X, T = map(int, input().split())

if (N%X==0):
    print(T * (N // X))
else:
    print(T * (N // X + 1))
Buggy python submission (verdict: Time Limit Exceeded):
R, C, K = map(int, input().split())

grid = [[0 for c in range(C)] for r in range(R)]

for k in range(K):
    r, c, v = map(int, input().split())
    grid[r-1][c-1] = v

dp = [[[-1000 for c in range(C)] for r in range(R)] for k in range(4)]

if grid[0][0] > 0:
    dp[1][0][0] = grid[0][0]
dp[0][0][0] = 0

for r in range(R):
    for c in range(C):
        if c >= 1:
            dp[0][r][c] = max(dp[0][r][c], dp[0][r][c-1])
            dp[1][r][c] = max(dp[1][r][c], dp[1][r][c-1])
            dp[2][r][c] = max(dp[2][r][c], dp[2][r][c-1])
            dp[3][r][c] = max(dp[3][r][c], dp[3][r][c-1])
        if r >= 1:
            dp[0][r][c] = max(dp[0][r][c], dp[0][r-1][c], dp[1][r-1][c], dp[2][r-1][c], dp[3][r-1][c])
        v = grid[r][c]
        if v > 0:
            if c >= 1:
                dp[1][r][c] = max(dp[1][r][c], dp[0][r][c-1] + v)
                dp[2][r][c] = max(dp[2][r][c], dp[1][r][c-1] + v)
                dp[3][r][c] = max(dp[3][r][c], dp[2][r][c-1] + v)
            if r >= 1:
                dp[1][r][c] = max(dp[1][r][c], dp[0][r-1][c]+v, dp[1][r-1][c]+v, dp[2][r-1][c]+v, dp[3][r-1][c]+v)

print(max(dp[0][R-1][C-1], dp[1][R-1][C-1], dp[2][R-1][C-1], dp[3][R-1][C-1]))


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

grid = [[0 for c in range(C)] for r in range(R)]

for k in range(K):
    r, c, v = map(int, input().split())
    grid[r-1][c-1] = v

dp = [[[-1000 for c in range(C)] for r in range(R)] for k in range(4)]

if grid[0][0] > 0:
    dp[1][0][0] = grid[0][0]
dp[0][0][0] = 0

for r in range(R):
    for c in range(C):
        if c >= 1:
            dp[0][r][c] = max(dp[0][r][c], dp[0][r][c-1])
            dp[1][r][c] = max(dp[1][r][c], dp[1][r][c-1])
            dp[2][r][c] = max(dp[2][r][c], dp[2][r][c-1])
            dp[3][r][c] = max(dp[3][r][c], dp[3][r][c-1])
        if r >= 1:
            dp[0][r][c] = max(dp[0][r][c], dp[0][r-1][c], dp[1][r-1][c], dp[2][r-1][c], dp[3][r-1][c])
        v = grid[r][c]
        if v > 0:
            if c >= 1:
                dp[1][r][c] = max(dp[1][r][c], dp[0][r][c-1] + v)
                dp[2][r][c] = max(dp[2][r][c], dp[1][r][c-1] + v)
                dp[3][r][c] = max(dp[3][r][c], dp[2][r][c-1] + v)
            if r >= 1:
                dp[1][r][c] = max(dp[1][r][c], dp[0][r-1][c]+v, dp[1][r-1][c]+v, dp[2][r-1][c]+v, dp[3][r-1][c]+v)

print(max(dp[0][R-1][C-1], dp[1][R-1][C-1], dp[2][R-1][C-1], dp[3][R-1][C-1]))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K = map(int, input().split())
Alist = list(map(int, input().split()))

asum = sum(Alist)
cut = []
length = []
for n in range(N):
    tmp = K * Alist[n] / asum
    cut.append(int(tmp) + 1)
    length.append(Alist[n] / (int(tmp)+1))

amari = K - sum(cut) + N
length = np.array(length)

for _ in range(amari):
    max_idx = np.argmax(length)
    cut[max_idx] += 1
    length[max_idx] = Alist[max_idx] / cut[max_idx]

ans = max(length)

if ans%1>0:
    print(int(ans)+1)
else:
    print(int(ans))

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

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

left = 0
right = max(Alist)

while right - left > 1:
    mid = (left + right) // 2
    
    cnt = 0
    for A in Alist:
        if A % mid == 0:
            cnt += (A // mid) - 1
        else:
            cnt += (A // mid)
    
    if cnt <= K:
        right = mid
    else:
        left = mid

print(right)
Buggy python submission (verdict: Time Limit Exceeded):
from scipy.special import comb

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

MOD = 10**9 + 7

base = 2**n - 1
a = comb(n, a, exact=True)
b = comb(n, b, exact=True)

print((base - a - b)%MOD)


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

MOD = 10**9 + 7

def comb(n, r, mod):
    if r > n-r:
        r = n - r
    
    res_X = 1
    for i in range(n-r+1, n+1):
        res_X = (res_X * i)%mod
    
    res_Y = 1
    for i in range(1, r+1):
        res_Y = (res_Y * i)%mod
    
    return (res_X * pow(res_Y, mod-2, mod))%mod

base = (pow(2, n, MOD) - 1)%MOD
a = comb(n, a, MOD)
b = comb(n, b, MOD)

print((base - a - b)%MOD)
Buggy python submission (verdict: Runtime Error):
S, T = input().split()
A, B = input().split()
U = input()

if S==U:
    print(A-1, B)
else:
    print(A, B-1)

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

if S==U:
    print(A-1, B)
else:
    print(A, B-1)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
plist = list(map(int, input().split()))

ans = 0
for i in range(N-K+1):
    ans = max(ans, sum(plist[i:i+K]))

print((ans + K)/2)


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

pre = sum(plist[:K])
ans = pre
for i in range(0, N-K):
    pre = pre - plist[i] + plist[i+K]
    ans = max(ans, pre)

print((ans + K)/2)
Buggy python submission (verdict: Runtime Error):
H = int(input())

def solve(h):
    ans = 0
    if h==2 or h==3:
        ans = 3
    else:
        ans += 1
        ans += 2 * solve(h//2)
    return ans

ans = solve(H)
print(ans)

Fixed submission:
H = int(input())

def solve(h):
    ans = 0
    if h==1:
        ans = 1
    else:
        ans += 1
        ans += 2 * solve(h//2)
    return ans

ans = solve(H)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X, Y = map(int, input().split())

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

if (2*Y - X) < 0:
    print(0)
elif (2*X - Y) < 0:
    print(0)
else:
    if (X - 2*Y) % 3 != 0 or (2*X - Y) % 3 != 0:
        print(0)
    else:
        a = (2 * Y - X) // 3
        b = (2 * X - Y) // 3
        m = 10**9+7
        res = 1
        for i in range(1,a+b+1):
            res = res*i%m
        for i in range(1,a+1):
            res = res*mod_inv(i,m)%m
        for i in range(1,b+1):
            res = res*mod_inv(i,m)%m
        print(res)

Fixed submission:
X, Y = map(int, input().split())
M = 1000000007

def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
 
    return result


if (2*Y - X) < 0:
    print(0)
elif (2*X - Y) < 0:
    print(0)
else:
    if (X - 2*Y) % 3 != 0 or (2*X - Y) % 3 != 0:
        print(0)
    else:
        a = (2 * Y - X) // 3
        b = (2 * X - Y) // 3
        ans = cmb(a+b, a)
        ans = ans % M
        print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
Alist = list(map(int, input().split()))

Alist = [[idx+1, a] for (idx, a) in enumerate(Alist)]

Alist.sort(key=lambda x:x[1])

ans = [a for a, _ in Alist]
print(" ".join(ans))

Fixed submission:
N = int(input())
Alist = list(map(int, input().split()))
 
Alist = [[idx+1, a] for (idx, a) in enumerate(Alist)]
 
Alist.sort(key=lambda x:x[1])
 
ans = [str(a) for a, _ in Alist]
print(" ".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, K, Q = map(int, input().split())

Anslist = np.ones(N) * K
check = np.array(range(N))

for i in range(Q):
    a = int(input())
    Anslist[check != a-1] -= 1

for i in range(N):
    if Anslist[i] > 0:
        print("Yes")
    else:
        print("No")


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

Anslist = [0 for i in range(N)]
for _ in range(Q):
    a = int(input())
    Anslist[a-1] += 1

for i in range(N):
    if Anslist[i] > Q - K:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
Alist = list(map(int, input().split()))

Alist = sorted(Alist, reverse=True)

cnt = 0
while cnt <= M:
    cnt += 1
    Alist[0] = Alist[0]//2
    if Alist[0] <= Alist[1]:
        Alist = sorted(Alist, reverse=True)

print(sum(Alist))

Fixed submission:
import heapq
N, M = map(int, input().split())
Alist = list(map(int, input().split()))

q = []
for a in Alist:
    heapq.heappush(q, -a)

for i in range(M):
    m = heapq.heappop(q)
    heapq.heappush(q, -((-m)//2))

print(-sum(q))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
Alist = list(map(int, input().split()))

Alist = sorted(Alist, reverse=True)
for i in range(M):
    Alist[0] = Alist[0]//2
    Alist = sorted(Alist, reverse=True)

print(sum(Alist))

Fixed submission:
import heapq
N, M = map(int, input().split())
Alist = list(map(int, input().split()))

q = []
for a in Alist:
    heapq.heappush(q, -a)

for i in range(M):
    m = heapq.heappop(q)
    heapq.heappush(q, -((-m)//2))

print(-sum(q))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
Alist = list(map(int, input().split()))

Alist = sorted(Alist, reverse=True)
for i in range(M):
    Alist = [Alist[0]//2] + Alist[1:]
    Alist = sorted(Alist, reverse=True)

print(sum(Alist))

Fixed submission:
import heapq
N, M = map(int, input().split())
Alist = list(map(int, input().split()))

q = []
for a in Alist:
    heapq.heappush(q, -a)

for i in range(M):
    m = heapq.heappop(q)
    heapq.heappush(q, -((-m)//2))

print(-sum(q))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000)

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

def solve(A, M):
    if len(A) > 1:
        if M==1:
            B = sum(A[1:]) + A[0]//2
        else:
            A = [A[0]//2] + A[1:]
            A.sort(reverse=True)
            B = solve(A, M-1)
    else:
        B = A[0] // (2**M)
    return B

Alist.sort(reverse=True)
B = solve(Alist, M)
print(B)

Fixed submission:
import heapq
N, M = map(int, input().split())
Alist = list(map(int, input().split()))

q = []
for a in Alist:
    heapq.heappush(q, -a)

for i in range(M):
    m = heapq.heappop(q)
    heapq.heappush(q, -((-m)//2))

print(-sum(q))

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

def solve(A, M):
    if len(A) > 1:
        if M==1:
            B = sum(A[1:]) + A[0]//2
        else:
            A = [A[0]//2] + A[1:]
            A.sort(reverse=True)
            B = solve(A, M-1)
    else:
        B = A[0] // (2**M)
    return B

Alist.sort(reverse=True)
B = solve(Alist, M)
print(B)

Fixed submission:
import heapq
N, M = map(int, input().split())
Alist = list(map(int, input().split()))

q = []
for a in Alist:
    heapq.heappush(q, -a)

for i in range(M):
    m = heapq.heappop(q)
    heapq.heappush(q, -((-m)//2))

print(-sum(q))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

H = H[::-1]
for i in range(1, N):
    if H[i] > H[i-1] + 1:
        check = 1
        break
    if H[i] > H[i-1]:
        H[i] -= 1

if check:
    print('No')
else:
    print('Yes')

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

H = H[::-1]
check = 0
for i in range(1, N):
    if H[i] > H[i-1] + 1:
        check = 1
        break
    if H[i] > H[i-1]:
        H[i] -= 1

if check:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Alist = [int(input()) for _ in range(N)]

m = max(Alist)
for i in range(N):
    if Alist[i]==m:
        print(max(Alist[:i] + Alist[i+1:]))
    else:
        print(m)


Fixed submission:
N = int(input())
Alist = [int(input()) for _ in range(N)]
Alist_sorted = sorted(Alist)

m = max(Alist)
for i in range(N):
    if Alist[i]==m:
        print(Alist_sorted[-2])
    else:
        print(m)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Alist = [int(input()) for _ in range(N)]

m = max(Alist)
for i in range(N):
    if Alist[i]==m:
        print(max(Alist[:i] + Alist[i+1:]))
    else:
        print(m)


Fixed submission:
N = int(input())
Alist = [int(input()) for _ in range(N)]
Alist_sorted = sorted(Alist)

m = max(Alist)
for i in range(N):
    if Alist[i]==m:
        print(Alist_sorted[-2])
    else:
        print(m)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Alist = [int(input()) for _ in range(N)]

for i in range(N):
    print(max(Alist[:i] + Alist[i+1:]))


Fixed submission:
N = int(input())
Alist = [int(input()) for _ in range(N)]
Alist_sorted = sorted(Alist)

m = max(Alist)
for i in range(N):
    if Alist[i]==m:
        print(Alist_sorted[-2])
    else:
        print(m)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations as f
L, R = map(int, input().split())

s = set(map(lambda x:x%2019, range(L, R+1)))

print(min([i*j%2019 for i, j in f(s, 2)]))


Fixed submission:
from itertools import combinations as f
L, R = map(int, input().split())

s = set(map(lambda x:x%2019, range(L, R+1)[:2019]))

print(min([i*j%2019 for i, j in f(s, 2)]))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

klist = []
sdict = {}
for m in range(M):
    tmp = list(map(int, input().split()))
    klist.append(tmp[0])
    sdict[m] = tmp[1:]
plist = list(map(int, input().split()))

def solve(N, plist, switch_num):
    global M
    num = 0

    if N == 1:
        idx = []
        idx2 = []
        for m in range(M):
            if switch_num in sdict[m]:
                idx.append(plist[m])
            else:
                idx2.append(plist[m])
        if sum(idx) == len(idx):
            if sum(idx2) == 0:
                return 1
            else:
                return 0
        elif sum(idx) == 0:
            if sum(idx2) == 0:
                return 2
        else:
            return 0

    # switch1 == OFF
    new_plist = plist
    num += solve(N-1, new_plist, switch_num+1)
    
    # switch1 == ON
    new_plist = []
    for i in range(M):
        if switch_num in sdict[i]:
            new_plist.append(1 - plist[i])
        else:
            new_plist.append(plist[i])
    num += solve(N-1, new_plist, switch_num+1)

    return num

print(solve(N, plist, 1))


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

klist = []
sdict = {}
for m in range(M):
    tmp = list(map(int, input().split()))
    klist.append(tmp[0])
    sdict[m] = tmp[1:]
plist = list(map(int, input().split()))

def solve(N, plist, switch_num):
    global M
    num = 0

    if N == 1:
        idx = []
        idx2 = []
        count = 0
        for m in range(M):
            if switch_num in sdict[m]:
                count += 1
                idx.append(plist[m])
            else:
                idx2.append(plist[m])
        if sum(idx) == len(idx) or sum(idx) == 0:
            if sum(idx2) == 0:
                if count == 0:
                    return 2
                else:
                    return 1
            else:
                return 0
        else:
            return 0

    # switch1 == OFF
    new_plist = plist
    num += solve(N-1, new_plist, switch_num+1)
    
    # switch1 == ON
    new_plist = []
    for i in range(M):
        if switch_num in sdict[i]:
            new_plist.append(1 - plist[i])
        else:
            new_plist.append(plist[i])
    num += solve(N-1, new_plist, switch_num+1)

    return num

print(solve(N, plist, 1))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

LL, MM = map(int, input().split())
gate = [LL + i for i in range(MM-LL+1)]

for _ in range(M-1):
    LL, MM = map(int, input().split())
    tmp = [LL + i for i in range(MM-LL+1)]
    gate = list(set(gate) & set(tmp))

print(len(gate))


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

min_, max_ = map(int, input().split())

for _ in range(M-1):
    LL, MM = map(int, input().split())
    min_ = max(min_, LL)
    max_ = min(max_, MM)


if min_ <= max_:
    print(max_ - min_ + 1)
else:
    print(0)

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

LL, MM = map(int, input().split())
gate = [LL + i for i in range(MM-LL+1)]

for _ in range(M-1):
    LL, MM = map(int, input().split())
    tmp = [LL + i for i in range(MM-LL+1)]
    gate = list(set(gate) & set(tmp))

print(len(gate))


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

min_, max_ = map(int, input().split())

for _ in range(M-1):
    LL, MM = map(int, input().split())
    min_ = max(min_, LL)
    max_ = min(max_, MM)


if min_ <= max_:
    print(max_ - min_ + 1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N, K = input().split()
K = int(K)
N[K-1].lower()
print(N)

Fixed submission:
N, K = map(int, input().split())
S = input()
S = S[:K-1] + S[K-1].lower() + S[K:]
print(S)
Buggy python submission (verdict: Runtime Error):
R, G, B, N = map(int, input().split())

count = 0
for i in range(N // R + 1):
    n = N - R * i
    for j in range(n // G + 1):
        if (n - G*j) >= 0 and (n - G*j) % B == 0:
            count += 1

print(count)


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

print(N - K + 1)

Buggy python submission (verdict: Runtime Error):
R, G, B, N = map(int, input().split())

count = 0
for i in range(N // R + 1):
    n = N - R * i
    for j in range(n // G + 1):
        if (n - G*j) >= 0 and (n - G*j) % B == 0:
            count += 1

print(count)


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

print(N - K + 1)

Buggy python submission (verdict: Runtime Error):
R, G, B, N = map(int, input().split())

count = 0
for i in range(N // R + 1):
    n = N - R * i
    for j in range(n // G + 1):
        if (n - G*j) >= 0 and (n - G*j) % B == 0:
            count += 1

print(count)


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

print(N - K + 1)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
AB_list = np.zeros((N, 2))

for i in range(N):
    A, B = map(int, input().split())
    AB_list[i] = [A, B]

if N==1:
    print(int(M*AB_list[0, 0]))
else:
    AB_list = AB_list[np.argsort(AB_list[:, 0])]
    i = 0
    money = 0
    while(AB_list[i, 1] <= M):
        money += AB_list[i,0] * AB_list[i, 1]
        M -= AB_list[i, 1]
        i += 1

    money += AB_list[i, 0] * M
    print(int(money))


Fixed submission:
import numpy as np
N, M = map(int, input().split())
AB_list = np.zeros((N, 2))

for i in range(N):
    A, B = map(int, input().split())
    AB_list[i] = [A, B]

if N==1:
    print(int(M*AB_list[0, 0]))

elif np.sum(AB_list[:, 1]) == M:
    tmpsum = 0
    for i in range(N):
        tmpsum += AB_list[i, 0] * AB_list[i, 1]
    print(int(tmpsum))

else:
    AB_list = AB_list[np.argsort(AB_list[:, 0])]
    i = 0
    money = 0
    while(AB_list[i, 1] <= M):
        money += AB_list[i,0] * AB_list[i, 1]
        M -= AB_list[i, 1]
        i += 1

    money += AB_list[i, 0] * M
    print(int(money))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input())

if (2*(K-1) + 1 <= N):
    print('YES')
else:
    print('NO')


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

if (2*(K-1) + 1 <= N):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
X_list = list(map(int, input().split()))
X_list.sort()
err_list = [X_list[i+1] - X_list[i] for i in range(len(X_list)-1)]
err_list.sort()

if N == 1:
    print(sum(err_list))
else:
    print(sum(err_list[:-(N-1)]))


Fixed submission:
T, X = map(int, input().split())

print(T/X)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
AB = np.zeros((3, N))

for i in range(N):
    tmpA, tmpB = map(int, input().split())
    AB[0, i] = tmpA + tmpB
    AB[1, i] = tmpA
    AB[2, i] = tmpB

AB = AB[:, np.argsort(AB[0, :])][::-1]

point = 0
for i in range(N):
    if i%2==0:
        point += AB[1, i]
    else:
        point -= AB[2, i]
 
print(int(point))


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

ab = [A, B]
max_katu = min(ab)

if A+B >= N:
    min_katu = A+B-N
else:
    min_katu = 0


ans = [str(max_katu), str(min_katu)]
print(' '.join(ans))
Buggy python submission (verdict: Runtime Error):
l = map(int, raw_input().split())
print(int(l[0] * l[1] / 2)

Fixed submission:
l = list(map(int, input().split()))
print(int(l[0] * l[1] / 2))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h_list = []
for _ in range(N):
    h_list.append(int(input()))
h_list.sort()

err_list = [h_list[i+K-1] - h_list[i] for i in range(N-K+1)]
print(min(err_list))


Fixed submission:
D = int(input())

ch = 'Christmas'
for _ in range(25 - D):
    ch += ' Eve'
print(ch)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def check_753(N):
    num = [0 for _ in range(10)]
    for i in range(len(N)):
        num[int(N[i])] = 1
    if sum(num) == 3:
        if num[3]+num[5]+num[7] == 3:
            return True
        else:
            return False
    else:
        return False

count = 0
for i in range(N):
    count += int(check_753(str(i+1)))
print(count)


Fixed submission:
N = input()
k = len(N)
N = int(N)

nums = ['3', '5', '7']
add3 = lambda x: x + '3'
add5 = lambda x: x + '5'
add7 = lambda x: x + '7'

cnt = 0
for _ in range(k-1):
    num_tmp = []
    num_tmp.append(list(map(add3, nums)))
    num_tmp.append(list(map(add5, nums)))
    num_tmp.append(list(map(add7, nums)))
    nums = sum(num_tmp, [])

    for i in range(len(nums)):
        if '3' in nums[i] and '5' in nums[i] and '7' in nums[i] and int(nums[i]) <= N:
            cnt += 1

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

count = 0
for a in range(1, N+1):
    b = K - a % K
    while b <= N:
        if (a % K) == (b % K):
            c = K - a % K
            count += (N - c) // K + 1
        b += K

print(count)


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

count = 0
for a in range(1, N+1):
    b = K - a % K
    if (a % K) == (b % K):
        count += ((N - b) // K + 1) ** 2

print(count)