Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

R, G, B, N = map(int, input().split())
R_max = N // R
G_max = N // G
ans = 0
for r, g in product(range(R_max+1), range(G_max+1)):
    b, r = divmod((N - (r*R + g*G)), B)
    if r == 0 and b >= 0: ans += 1
print(ans)

Fixed submission:
from itertools import product

R, G, B, N = map(int, input().split())
R_max = N // R
G_max = N // G
ans = 0
for r, g in product(range(R_max+1), range(G_max+1)):
    if N >= r*R + g*G and (N - (r*R + g*G)) % B == 0: ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

R, G, B, N = map(int, input().split())
colors = sorted([(N // R, R), (N // G, G), (N // B, B)])
ans = 0
for i, j in product(range(colors[1][0]+1), range(colors[2][0]+1)):
    I = colors[1][1]; J = colors[2][1]; 
    if N >= i*I + j*J and (N - (i*I + j*J)) % colors[0][1] == 0: ans += 1
print(ans)

Fixed submission:
from itertools import product

R, G, B, N = map(int, input().split())
R_max = N // R
G_max = N // G
ans = 0
for r, g in product(range(R_max+1), range(G_max+1)):
    if N >= r*R + g*G and (N - (r*R + g*G)) % B == 0: ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

R, G, B, N = map(int, input().split())
R_max = N // R
G_max = N // G
ans = 0
for r, g in product(range(R_max+1), range(G_max+1)):
    if N >= r*R + g*G and (N - (r*R + g*G)) % B == 0: ans += 1
print(ans)

Fixed submission:
from itertools import product

R, G, B, N = map(int, input().split())
R_max = N // R
G_max = N // G
ans = 0
for r, g in product(range(R_max+1), range(G_max+1)):
    if N >= r*R + g*G and (N - (r*R + g*G)) % B == 0: ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

cand = []

for i in range(N+1):
    st = '.'*i + '#'*(N-i)
    temp = 0
    for s, t in zip(S, st):
        if s != t:
            temp += 1
    cand.append(temp)
    
print(min(cand))

Fixed submission:
N = int(input())
S = input()

cand = []
black = 0
white = 0

for s in S:
    if s == '.':
        white +=1
cand.append(white)
        
for s in S:
    if s == '#':
        black += 1
    else:
        white -= 1
    cand.append(black+white)

print(min(cand))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
A = [-a for a in A]
B = sorted(list(map(int, input().split())), reverse=True)
B = [-b for b in B]
C = sorted(list(map(int, input().split())), reverse=True)
C = [-c for c in C]

unchecked = {}

h = []
heapq.heappush(h, (A[0]+B[0]+C[0], 0, 0, 0))
counter = 0
while counter < K:
    val, i, j, k = heapq.heappop(h)
    if unchecked.setdefault("{},{},{}".format(i, j, k), True):
        unchecked["{},{},{}".format(i, j, k)] = False
        print(- val)
        counter += 1
    if i+1 < X:
        heapq.heappush(h, (A[i+1] + B[j] + C[k], i+1, j, k))
    if j+1 < Y:
        heapq.heappush(h, (A[i] + B[j+1] + C[k], i, j+1, k))
    if k+1 < Z:
        heapq.heappush(h, (A[i] + B[j] + C[k+1], i, j, k+1))

Fixed submission:
import heapq

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
A = [-a for a in A]
B = sorted(list(map(int, input().split())), reverse=True)
B = [-b for b in B]
C = sorted(list(map(int, input().split())), reverse=True)
C = [-c for c in C]

checked = []

h = []
heapq.heappush(h, (A[0]+B[0]+C[0], 0, 0, 0))
for _ in range(K):
    val, i, j, k = heapq.heappop(h)
    print(- val)
    if i+1 < X and (i+1, j, k) not in checked:
        heapq.heappush(h, (A[i+1] + B[j] + C[k], i+1, j, k))
        checked.append((i+1, j, k))
    if j+1 < Y and (i, j+1, k) not in checked:
        heapq.heappush(h, (A[i] + B[j+1] + C[k], i, j+1, k))
        checked.append((i, j+1, k))
    if k+1 < Z and (i, j, k+1) not in checked:
        heapq.heappush(h, (A[i] + B[j] + C[k+1], i, j, k+1))
        checked.append((i, j, k+1))
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
ACs_indices = [i for i in range(N-1) if S[i:i+2] == 'AC']

for _ in range(Q):
    l, r = map(int, input().split())
    ans = 0
    for idx in ACs_indices:
        if idx in range(l-1, r-1):
            ans += 1
    print(ans)

Fixed submission:
N, Q = map(int, input().split())
S = input()
cum_sum = [0]*(N+1)
for i in range(2, N+1):
    if S[i-2:i] == 'AC':
        cum_sum[i] = cum_sum[i-1] + 1
    else:
        cum_sum[i] = cum_sum[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    ans = cum_sum[r] - cum_sum[l]
    print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

B = np.array(B)
A = np.array(A)
vec = A@B + C
ans = np.sum(vec > 0)
print(ans)

Fixed submission:
import numpy as np

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

B = np.array(B)
A = np.array(A)
vec = A.dot(B) + C
ans = np.sum(vec > 0)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = input().split()

numbers = {'1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
cand = {a: numbers[a] for a in A}
dp = {i: '-1' for i in range(N+1)}
dp[0] = ''
for i in range(N+1):
    for a in A:
        if i+cand[a] <= N:
            dp[i+cand[a]] = str(max(int(dp[i+cand[a]]), int(dp[i] + a)))
print(dp[N])

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

numbers = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = {i: -1 for i in range(N+1)}
dp[0] = 0
for i in range(N+1):
    for a in A:
        j = i + numbers[a]
        if j <= N:
            dp[j] = max(dp[j], dp[i]*10 + a)
print(dp[N])

Buggy python submission (verdict: Runtime Error):
numbers = {'1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}

N, M = map(int, input().split())
A = list(input().split())
cands = [(a, numbers[a]) for a in A]

dp = {i: None for i in range(1, N+1)}
for c in cands:
    dp[c[1]] = int(c[0])
for i in range(2, N+1):
    for c in cands:
        j = i - c[1]
        if j >= 1 and dp[j] is not None:
            if dp[i] is None:
                dp[i] = int(''.join(str(dp[j]) + c[0]))
            else:
                if len(str(dp[i])) <  len(str(dp[j]) + c[0]):
                    dp[i] = int(str(dp[j]) + c[0])
                elif len(str(dp[i])) ==  len(str(dp[j]) + c[0]):
                    dp[i] = max(dp[i], int(''.join(sorted(str(dp[j]) + c[0], reverse=True))))
print(''.join(sorted(dp[N], reverse=True)))

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

numbers = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = {i: -1 for i in range(N+1)}
dp[0] = 0
for i in range(N+1):
    for a in A:
        j = i + numbers[a]
        if j <= N:
            dp[j] = max(dp[j], dp[i]*10 + a)
print(dp[N])

Buggy python submission (verdict: Time Limit Exceeded):
numbers = {'1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}

N, M = map(int, input().split())
A = list(input().split())
cands = [(a, numbers[a]) for a in A]

dp = {i: None for i in range(1, N+1)}
for c in cands:
    dp[c[1]] = int(c[0])
for i in range(2, N+1):
    for c in cands:
        j = i - c[1]
        if j >= 1 and dp[j] is not None:
            if dp[i] is None:
                dp[i] = int(''.join(sorted(str(dp[j]) + c[0], reverse=True)))
            else:
                dp[i] = max(dp[i], int(''.join(sorted(str(dp[j]) + c[0], reverse=True))))
print(dp[N])

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

numbers = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = {i: -1 for i in range(N+1)}
dp[0] = 0
for i in range(N+1):
    for a in A:
        j = i + numbers[a]
        if j <= N:
            dp[j] = max(dp[j], dp[i]*10 + a)
print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
*H, = map(int, input().split())
INF = 10**12
dp = {i: INF for i in range(N+1)}
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min([dp[i-j] + abs(H[i] - H[i-j]) for j in range(1, min(i, K)+1)])
print(dp[N-1])

Fixed submission:
N, K = map(int, input().split())
*H, = map(int, input().split())
INF = 10**12
dp = [INF]*N
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    beg = min(i, K)
    h_now = H[i]
    dp[i] = min([d + abs(h_now - h) for d, h in zip(dp[i-beg:i], H[i-beg:i])])
print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
*H, = map(int, input().split())
INF = 10**12
dp = {i: INF for i in range(N+1)}
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    for j in range(1, min(i, K)+1):
        dp[i] = min(dp[i], dp[i-j] + abs(H[i] - H[i-j]))
print(dp[N-1])

Fixed submission:
N, K = map(int, input().split())
*H, = map(int, input().split())
INF = 10**12
dp = [INF]*N
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    beg = min(i, K)
    h_now = H[i]
    dp[i] = min([d + abs(h_now - h) for d, h in zip(dp[i-beg:i], H[i-beg:i])])
print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
*H, = map(int, input().split())
INF = 10**12
dp = {i: INF for i in range(N+1)}
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    for j in range(1, K+1):
        if i >= j:
            dp[i] = min(dp[i], dp[i-j] + abs(H[i] - H[i-j]))
print(dp[N-1])

Fixed submission:
N, K = map(int, input().split())
*H, = map(int, input().split())
INF = 10**12
dp = [INF]*N
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    beg = min(i, K)
    h_now = H[i]
    dp[i] = min([d + abs(h_now - h) for d, h in zip(dp[i-beg:i], H[i-beg:i])])
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))
dp = [0 for i in range(W+1)]
for w, v in items:
    for i in reversed(range(W+1)):
        if i - w >= 0: dp[i] = max(dp[i-w] + v, dp[i])
print(max(dp))

Fixed submission:
import numpy as np

N, W = map(int, input().split())
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))
dp = np.array([[0 for j in range(W+1)] for _ in range(N+1)])
for i in range(1, N+1):
    w, v = items[i-1]
    dp[i, :w] = dp[i-1, :w]
    dp[i, w:] = np.maximum(dp[i-1, :-w] + v, dp[i-1, w:])
print(dp[N, W])

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))
dp = [[0 for j in range(W+1)] for i in range(N+1)]
for i in range(1, N+1):
    w, v = items[i-1]
    for j in range(W+1):
        if j - w >= 0:
            dp[i][j] = max(dp[i-1][j-w] + v, dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
print(max(dp[N]))

Fixed submission:
import numpy as np

N, W = map(int, input().split())
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))
dp = np.array([[0 for j in range(W+1)] for _ in range(N+1)])
for i in range(1, N+1):
    w, v = items[i-1]
    dp[i, :w] = dp[i-1, :w]
    dp[i, w:] = np.maximum(dp[i-1, :-w] + v, dp[i-1, w:])
print(dp[N, W])

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))
dp = {i: {j: 0 for j in range(W+1)} for i in range(N+1)}
for i in range(1, N+1):
    w, v = items[i-1]
    for j in range(W+1):
        if j - w >= 0:
            dp[i][j] = max(dp[i-1][j-w] + v, dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
print(max(dp[N].values()))

Fixed submission:
import numpy as np

N, W = map(int, input().split())
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))
dp = np.array([[0 for j in range(W+1)] for _ in range(N+1)])
for i in range(1, N+1):
    w, v = items[i-1]
    dp[i, :w] = dp[i-1, :w]
    dp[i, w:] = np.maximum(dp[i-1, :-w] + v, dp[i-1, w:])
print(dp[N, W])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, W = map(int, input().split())
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))
v_max = sum([i[1] for i in items])
INF = 10**12
dp = np.array([[INF for j in range(N * v_max+1)] for _ in range(N+1)])
dp[0, 0] = 0
for i in range(1, N+1):
    w, v = items[i-1]
    dp[i, :v] = dp[i-1, :v]
    dp[i, v:] = np.minimum(dp[i-1, :-v] + w, dp[i-1, v:])
ans = 0
for v in range(N * v_max, -1, -1):
    if dp[N][v] <= W:
        ans = v
        break
print(ans)

Fixed submission:
import numpy as np

N, W = map(int, input().split())
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))
v_max = sum([i[1] for i in items])
INF = 10**12
dp = np.array([[INF for j in range(v_max+1)] for _ in range(N+1)])
dp[0, 0] = 0
for i in range(1, N+1):
    w, v = items[i-1]
    dp[i, :v] = dp[i-1, :v]
    dp[i, v:] = np.minimum(dp[i-1, :-v] + w, dp[i-1, v:])
ans = 0
for v in range(v_max, -1, -1):
    if dp[N][v] <= W:
        ans = v
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()
len_S = len(S)
len_T = len(T)

dp = {i: {j: 0 for j in range(len_T+1)} for i in range(len_S+1)}
for i in range(len_S):
    for j in range(len_T):
        if S[i] == T[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

# backtrack
ans = ''
i, j = len_S, len_T
while i > 0 and j > 0:
    if S[i-1] == T[j-1]:
        ans = S[i-1] + ans
        i, j = i - 1, j - 1
    else:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        else:
            j -= 1
print(ans)

Fixed submission:
S = input()
T = input()
len_S = len(S)
len_T = len(T)

dp = {i: {j: 0 for j in range(len_T+1)} for i in range(len_S+1)}
for i in range(len_S):
    for j in range(len_T):
        if S[i] == T[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

# backtrack
ans = ''
i, j = len_S, len_T
while i > 0 and j > 0:
    if S[i-1] == T[j-1]:
        ans = S[i-1] + ans
        i, j = i - 1, j - 1
    else:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        else:
            j -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
*P, = map(float, input().split())
dp = [[0]*(N+1) for _ in range(N)]
dp[0][0] = 1 - P[0]; dp[0][1] = P[0]
for i in range(1, N):
    for j in range(i+2):
        dp[i][j] = dp[i-1][j] * (1 - P[i]) + dp[i-1][j-1] * P[i]
print(sum(dp[N-1][N//2 + 1:]))

Fixed submission:
N = int(input())
*P, = map(float, input().split())
dp = [[0]*(N+1) for _ in range(N)]
dp[0][0] = 1 - P[0]; dp[0][1] = P[0]
for i in range(1, N):
    for j in range(i+2):
        dp[i][j] = dp[i-1][j] * (1 - P[i]) + dp[i-1][j-1] * P[i]
print(sum(dp[N-1][N//2 + 1:]))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
*A, = map(int, input().split())
dp = [False] * (K+1)
for i in range(1, K+1):
    for a in A:
        if i - a < 0: break
        dp[i] |= not dp[i-a]
print('First' if dp[K] else 'Second')

Fixed submission:
N, K = map(int, input().split())
*A, = map(int, input().split())
dp = [False] * (K+1)
for i in range(1, K+1):
    for a in A:
        if i - a < 0: break
        dp[i] |= not dp[i-a]
print('First' if dp[K] else 'Second')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
*A, = map(int, input().split())
dp = [[0] * (N+1) for _ in range(N+1)]
for n in range(1, N+1):
    for i in range(N-n+1):
        j = i + n
        if (N - n) % 2 == 0: # first player
            dp[i][j] = max(dp[i+1][j] + A[i], dp[i][j-1] + A[j-1])
        else: # second player
            dp[i][j] = min(dp[i+1][j] - A[i], dp[i][j-1] - A[j-1])
print(dp[0][N])

Fixed submission:
N = int(input())
*A, = map(int, input().split())
dp = [[0] * (N+1) for _ in range(N+1)]
for n in range(1, N+1):
    for i in range(N-n+1):
        j = i + n
        if (N - n) % 2 == 0: # first player
            dp[i][j] = max(dp[i+1][j] + A[i], dp[i][j-1] + A[j-1])
        else: # second player
            dp[i][j] = min(dp[i+1][j] - A[i], dp[i][j-1] - A[j-1])
print(dp[0][N])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate

MOD = 10**9 + 7
N, K = map(int, input().split())
*A, = map(int, input().split())
dp = [0] * (K+1)
dp[K] = 1
for a in A:
    temp = [0] * (K+1)
    for k in range(K+1):
        temp[k - min(a, k)] += dp[k]; temp[k - min(a, k)] %= MOD
        temp[k] -= dp[k]; temp[k] %= MOD
    temp = list(accumulate(temp))
    dp = [(d + t) % MOD for d, t in zip(dp, temp)]
print(dp[0] % MOD)

Fixed submission:
from itertools import accumulate

MOD = 10**9 + 7
N, K = map(int, input().split())
*A, = map(int, input().split())
dp = [0] * (K+1)
dp[K] = 1
for a in A:
    temp = [0] * (K+1)
    for k in range(K+1):
        temp[k - min(a, k)] += dp[k]; temp[k - min(a, k)] %= MOD
        temp[k] -= dp[k]; temp[k] %= MOD
    temp = list(accumulate(temp))
    dp = [(d + t) % MOD for d, t in zip(dp, temp)]
print(dp[0] % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9 + 7
K = input()
D = int(input())
N = len(K)
dp0 = [[0] * D for _ in range(N+1)]
dp1 = [[0] * D for _ in range(N+1)]
dp0[0][0] = 1
for i, digit in enumerate(K, 1):
    digit = int(digit)
    for d in range(D):
        for k in range(10):
            dp1[i][(d + k) % D] += dp1[i-1][d]
            dp1[i][(d + k) % D] %= MOD
            if k < digit:
                dp1[i][(d + k) % D] += dp0[i-1][d]
                dp1[i][(d + k) % D] %= MOD
            elif k == digit:
                dp0[i][(d + k) % D] += dp0[i-1][d]
                dp0[i][(d + k) % D] %= MOD
print((dp0[N][0] + dp1[N][0] - 1) % MOD)

Fixed submission:
MOD = 10**9 + 7
K = input()
D = int(input())
N = len(K)
dp0 = [[0] * D for _ in range(N+1)]
dp1 = [[0] * D for _ in range(N+1)]
dp0[0][0] = 1
for i, digit in enumerate(K, 1):
    digit = int(digit)
    for d in range(D):
        for k in range(10):
            dp1[i][(d + k) % D] += dp1[i-1][d]
            dp1[i][(d + k) % D] %= MOD
            if k < digit:
                dp1[i][(d + k) % D] += dp0[i-1][d]
                dp1[i][(d + k) % D] %= MOD
            elif k == digit:
                dp0[i][(d + k) % D] += dp0[i-1][d]
                dp0[i][(d + k) % D] %= MOD
print((dp0[N][0] + dp1[N][0] - 1) % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H = sorted(H)
ans = 10**10
for i in range(N - K + 1):
    temp = H[i:i+K]
    ans = min(ans, temp[-1] - temp[0])
print(ans)

Fixed submission:
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H = sorted(H)
ans = 10**10
for i in range(N - K + 1):
    ans = min(ans, H[i+K-1] - H[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H = sorted(H)
ans = 10**10
for i in range(N - K + 1):
    ans = min(ans, H[i:i+K][-1] - H[i:i+K][0])
print(ans)

Fixed submission:
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H = sorted(H)
ans = 10**10
for i in range(N - K + 1):
    ans = min(ans, H[i+K-1] - H[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H = sorted(H)
cand = [H[i:i+K][-1] - H[i:i+K][0] for i in range(N - K + 1)]
print(min(cand))

Fixed submission:
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H = sorted(H)
ans = 10**10
for i in range(N - K + 1):
    ans = min(ans, H[i+K-1] - H[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

n = int(input())
V = list(map(int, input().split()))

odds_counter = defaultdict(int)
evens_counter = defaultdict(int)

for o in V[0::2]:
    odds_counter[o] += 1
for e in V[1::2]:
    evens_counter[e] += 1

odds = sorted(odds_counter.items(), key=lambda x: x[1], reverse=True)
evens = sorted(evens_counter.items(), key=lambda x: x[1], reverse=True)

if odds[0][0] != evens[0][0]:
    ans = n - odds[0][1] - evens[0][1]
else:
    if odds[0][1] >= evens[0][1]:
        if len(odds) == 1:
            ans = n//2 - evens[1][1]
        else:
            ans = n - evens[0][1] - odds[1][1]
    else:
        if len(evens) == 1:
            ans = n//2 - odds[1][1]
        else:
            ans = n - odds[0][1] - evens[1][1]
print(ans)


Fixed submission:
from collections import defaultdict

n = int(input())
V = list(map(int, input().split()))

odds_counter = defaultdict(int)
evens_counter = defaultdict(int)

for o in V[0::2]:
    odds_counter[o] += 1
for e in V[1::2]:
    evens_counter[e] += 1

odds = sorted(odds_counter.items(), key=lambda x: x[1], reverse=True)
evens = sorted(evens_counter.items(), key=lambda x: x[1], reverse=True)

if odds[0][0] != evens[0][0]:
    ans = n - odds[0][1] - evens[0][1]
else:
    if len(odds) == 1 and len(evens) == 1:
        ans = odds[0][1]
    elif len(odds) == 1 and len(evens) != 1:
        ans = n - odds[0][1] - evens[1][1]
    elif len(odds) != 1 and len(evens) == 1:
        ans = n - odds[1][1] - evens[0][1]
    else:
        ans = min(n - odds[0][1] - evens[1][1], n - odds[1][1] - evens[0][1])
print(ans)
Buggy python submission (verdict: Runtime Error):
*S = sorted(input().split(), reverse=True)
print(eval(S[0]+S[1]+ '+' + S[2]))

Fixed submission:
abc = list(map(int, input().split()))
abc = list(reversed(sorted(abc)))

ans = abc[0]*10 + abc[1] + abc[2]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

N, X = map(int, input().split())
cities = list(map(int, input().split()))

ans = gcd([abs(c - X) for c in cities])


print(ans)


Fixed submission:
from functools import reduce

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

def gcd_list(numbers):
    return reduce(gcd, numbers)

N, X = map(int, input().split())
cities = list(map(int, input().split()))

ans = gcd_list([abs(c - X) for c in cities])

print(ans)