Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# input
N = int(input())
A = list(map(int, input().split()))

count = [0, 0, 0, 0, 0, 0, 0, 0, 0]

for i in range(N):
    if A[i] < 400:
        count[0] = 1
    elif A[i] < 800:
        count[1] = 1
    elif A[i] < 1200:
        count[2] = 1
    elif A[i] < 1600:
        count[3] = 1
    elif A[i] < 2000:
        count[4] = 1
    elif A[i] < 2400:
        count[5] = 1
    elif A[i] < 2800:
        count[6] = 1
    elif A[i] < 3200:
        count[7] = 1
    else:
        count[8] += 1

color_max = sum(count)
if count[8] == 0:
    count_min = sum(count)
else:
    count_min = sum(count[:7]) + 1

print(count_min, count_max)

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

count = [0, 0, 0, 0, 0, 0, 0, 0, 0]

for i in range(N):
    if A[i] < 400:
        count[0] = 1
    elif A[i] < 800:
        count[1] = 1
    elif A[i] < 1200:
        count[2] = 1
    elif A[i] < 1600:
        count[3] = 1
    elif A[i] < 2000:
        count[4] = 1
    elif A[i] < 2400:
        count[5] = 1
    elif A[i] < 2800:
        count[6] = 1
    elif A[i] < 3200:
        count[7] = 1
    else:
        count[8] += 1

color_max = sum(count)
if count[8] == 0:
    color_min = sum(count)
else:
    color_min = sum(count[:7]) + 1

print(color_min, color_max)
Buggy python submission (verdict: Runtime Error):
# input
N, M = map(int, input().split())
R = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
    ans = 0
    for j in range(1, M + 1):
        if i in R[j]:
            ans += 1
    print(ans)



Fixed submission:
# input
N, M = map(int, input().split())
R = [list(map(int, input().split())) for _ in range(M)]

for i in range(1, N + 1):
    ans = 0
    for j in range(M):
        if i in R[j]:
            ans += 1
    print(ans)
Buggy python submission (verdict: Runtime Error):
# input
N, K = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(M)]

count = 0

for i in range(N):
    count += A[i][1]
    if count >= K:
        print(A[i][0])
        break

Fixed submission:
# input
N, K = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]

A = sorted(A)

count = 0

for i in range(N):
    count += A[i][1]
    if count >= K:
        print(A[i][0])
        break
Buggy python submission (verdict: Runtime Error):
# input
n = int(input())
A = list(map(int, input().split()))

# 偶数番目が＋
A_even = A
S_even = 0
ans_even = 0
for i in range(n):
    if (S + A_even[i]) * ((-1) ** (i - 1)) > 0:
        continue
    ans_even += S + A_even[i] + 1
    A_even[i] = (-1) ** (i - 1) - S
    S = (-1) ** (i - 1)

# 奇数番目が＋
A_odd = A
S_odd = 0
ans_odd = 0
for i in range(n):
    if (S + A_odd[i]) * ((-1) ** i) > 0:
        continue
    ans_odd += S + A_odd[i] + 1
    A_odd[i] = (-1) ** i - S
    S = (-1) ** i

ans = min(ans_even, ans_odd)

print(ans)

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

# 偶数番目が＋
A_even = A[:]
S_even = 0
ans_even = 0
for i in range(n):
    if (S_even + A_even[i]) * ((-1) ** (i - 1)) > 0:
        S_even += A_even[i]
        continue
    A_even[i] = (-1) ** (i - 1) - S_even
    ans_even += abs(A[i] - A_even[i])
    S_even = (-1) ** (i - 1)

# 奇数番目が＋
A_odd = A[:]
S_odd = 0
ans_odd = 0
for i in range(n):
    if (S_odd + A_odd[i]) * ((-1) ** i) > 0:
        S_odd += A_odd[i]
        continue
    A_odd[i] = (-1) ** i - S_odd
    ans_odd += abs(A[i] - A_odd[i])
    S_odd = (-1) ** i

ans = int(min(ans_even, ans_odd))

print(ans)
Buggy python submission (verdict: Runtime Error):
# input
O = input()
E = input()

password = [0 for _ in range(len(O) + len(E))]

for i in range(len(O)):
    password[2 * i] = O[i]

for i in range(len(E)):
    password[2 * i + 1] = E[i]

password_str = ''.join(str_list)
print(password_str)

Fixed submission:
# input
O = input()
E = input()

password = [0 for _ in range(len(O) + len(E))]

for i in range(len(O)):
    password[2 * i] = O[i]

for i in range(len(E)):
    password[2 * i + 1] = E[i]

password_str = ''.join(password)
print(password_str)
Buggy python submission (verdict: Runtime Error):
# input
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

for i in range(N - M + 1):
    for j in range(N - M + 1):
        for k in range(M):
            for l in range(M):
                if B[k][l] == A[i + k][j + l]:
                    ans += 1
                else:
                    break
            if ans == M * 2:
                print("Yes")
                exit()
            else:
                ans = 0
                break

print('No')

Fixed submission:
import numpy as np

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

A_arr = np.array(A)
B_arr = np.array(B)

for i in range(N - M + 1):
    for j in range(N - M + 1):
        if np.array_equal(A_arr[i:i + M, j:j + M], B_arr):
            print('Yes')
            exit()

print('No')
Buggy python submission (verdict: Runtime Error):
# input
N, M = map(int, input().split())
G = [list(map(int, input().split())) for _ in range(M)]
edges = [set() for _ in range(N)]

for a, b in G:
    edges[a - 1].add((b - 1, 1))
    edges[b - 1].add((a - 1, 1))

def dfs(start, edges, path):
    path.append(start)
    if len(path) == n:
        path.pop()
        return 1
    ans = 0
    for u in edges[start]:
        if u in path:
            continue
        ans += dfs(u, path)
    path.pop()
    return ans    

print(dfs(0, []))


Fixed submission:
# input
N, M = map(int, input().split())
G = [list(map(int, input().split())) for _ in range(M)]
edges = [set() for _ in range(N)]

for a, b in G:
    edges[a - 1].add(b - 1)
    edges[b - 1].add(a - 1)

def dfs(start, edges, path):
    path.append(start)
    if len(path) == N:
        path.pop()
        return 1
    ans = 0
    for u in edges[start]:
        if u in path:
            continue
        ans += dfs(u, edges, path)
    path.pop()
    return ans    

print(dfs(0, edges, []))
Buggy python submission (verdict: Runtime Error):
# input
s = input()

i = 0

while s[i] != 'a':
    i += 1

j = len(s) - 1

while s[j] != 'z':
    j -= 1

ans = j - i + 1
print(ans)

Fixed submission:
# input
s = input()

i = 0

while s[i] != 'A':
    i += 1

j = len(s) - 1

while s[j] != 'Z':
    j -= 1

ans = j - i + 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

# input
N = int(input())

N_f = math.factorial(N)

ans = 0

for i in range(1, math.ceil(math.sqrt(N_f))):
    if N_f % i == 0:
        ans += 1
        if N_f != i ** 2:
            ans += 1

ans = ans % (10 ** 9 + 7)

print(ans)


Fixed submission:
import math

# input
N = int(input())

# エラトステネスの篩で素数を列挙（table[q] = 0: qは素数, table[i] = j: iはjを素因数に持つ）
def prime_factor_table(n):
    table = [0] * (n + 1)
    
    for i in range(2, n + 1):
        if table[i] == 0:
            for j in range(i + i, n + 1, i):
                table[j] = i
    
    return table

def prime_factor(n, prime_factor_table):
    prime_count = dict()

    while prime_factor_table[n] != 0:
        if prime_factor_table[n] in prime_count.keys():
            prime_count[prime_factor_table[n]] += 1
        else:
            prime_count[prime_factor_table[n]] = 1
        n = int(n/prime_factor_table[n])
    if n in prime_count.keys():
        prime_count[n] += 1
    else:
        prime_count[n] = 1
    return prime_count

Ps = dict()
P_1000 = prime_factor_table(1000)
ans = 1

for i in range(2, N + 1):
    P_i = prime_factor(i, P_1000)
    for k in P_i.keys():
        if k in Ps.keys():
            Ps[k] += P_i[k]
        else:
            Ps[k] = P_i[k]

for k in Ps.keys():
    ans = (ans * (Ps[k] + 1)) % (10 ** 9 + 7)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# input
K, S = map(int, input().split())

ans = 0

for i in range(min([S + 1, K + 1])):
    for j in range(min([S -i + 1, K + 1])):
        for k in range(min([S - i - j + 1, K + 1])):
            if i + j + k == S:
                ans += 1

print(ans)

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

ans = 0

for i in range(min([S + 1, K + 1])):
    for j in range(min([S -i + 1, K + 1])):
        if S - i - j <= K:
            ans += 1

print(ans)

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

ans = 0

for i in range(K + 1):
    for j in range(K + 1):
        for k in range(K + 1):
            if i + j + k == S:
                ans += 1

print(ans)

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

ans = 0

for i in range(min([S + 1, K + 1])):
    for j in range(min([S -i + 1, K + 1])):
        if S - i - j <= K:
            ans += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
# input
K, S = map(int, input())

ans = 0

for i in range(K + 1):
    for j in range(S - i + 1):
        for k in range(S - i - j + 1):
            if i + j + k == S:
                ans += 1

print(ans)

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

ans = 0

for i in range(min([S + 1, K + 1])):
    for j in range(min([S -i + 1, K + 1])):
        if S - i - j <= K:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
# input
sx, sy, tx, ty = map(int, input().split())

for i in range(tx - sx):
    print('R')

for i in range(ty - sy):
    print('U')

for i in range(tx - sx):
    print('L')

for i in range(ty - sy):
    print('D')

print('L')

for i in range(ty - sy + 1):
    print('U')

for i in range(tx - sx + 1):
    print('R')

print('D')

print('R')

for i in range(ty - sy + 1):
    print('D')

for i in range('tx - sx + 1'):
    print('L')

print('U')

Fixed submission:
# input
sx, sy, tx, ty = map(int, input().split())

for i in range(ty - sy):
    print('U', end = "")

for i in range(tx - sx):
    print('R', end = "")

for i in range(ty - sy):
    print('D', end = "")

for i in range(tx - sx):
    print('L', end = "")

print('L', end = "")

for i in range(ty - sy + 1):
    print('U', end = "")

for i in range(tx - sx + 1):
    print('R', end = "")

print('D', end = "")

print('R', end = "")

for i in range(ty - sy + 1):
    print('D', end = "")

for i in range(tx - sx + 1):
    print('L', end = "")

print('U')
Buggy python submission (verdict: Runtime Error):
# input
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [list(map(int, input().split())) for _ in range(M)]

for i in range(M):
    T[P[i][0]] -= P[i][1]
    print(sum(T))
    T[P[i][0]] += P[i][1]

Fixed submission:
# input
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [list(map(int, input().split())) for _ in range(M)]

for i in range(M):
    temp = T[P[i][0] - 1]
    T[P[i][0] - 1] = P[i][1]
    print(sum(T))
    T[P[i][0] - 1] = temp
Buggy python submission (verdict: Time Limit Exceeded):
# input
a, b, x = map(int, input().split())

ans = 0

for i in range(a, b + 1):
    if i % x == 0:
        ans += 1

print(ans)


Fixed submission:
# input
import math

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

# 0,...,nの中でxで割り切れるのは
# 0, x, 2x,..., (n // x)* x の(n //x) + 1個

if a % x == 0:
    ans = ((b // x) + 1) - ((a // x) + 1) + 1
    print(ans)
else:
    ans = ((b // x) + 1) - ((a // x) + 1)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions

# input
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]


T = 1 # 高橋くんの最小得票数
A = 1 # 青木くんの最小得票数
ans = 2

for i in range(0, N):
    T_tmp = TA[i][0]
    A_tmp = TA[i][1]
    while T_tmp < T or A_tmp < A:
        T_tmp += TA[i][0]
        A_tmp += TA[i][1]
    T = T_tmp
    A = A_tmp
    ans = T + A

print(ans)


Fixed submission:
import math

# input
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]


T = 1 # 高橋くんの最小得票数
A = 1 # 青木くんの最小得票数
ans = 2

for i in range(0, N):
    #m = max(math.ceil(T / TA[i][0]), math.ceil(A / TA[i][1]))
    m = max(-(-T // TA[i][0]), -(-A // TA[i][1]))
    T = TA[i][0] * m
    A = TA[i][1] * m
    ans = T + A

print(ans)

Buggy python submission (verdict: Runtime Error):
from functools import reduce
import math

# input
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

# 最小公倍数
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

ans = 1
for i in range(N):
    if TA[i][0] + TA[i][1] >= ans:
        ans = TA[i][0] + TA[i][1]
    else:
        ans = lcm_base(ans, TA[i][0] + TA[i][1])

print(ans)


Fixed submission:
import math

# input
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]


T = 1 # 高橋くんの最小得票数
A = 1 # 青木くんの最小得票数
ans = 2

for i in range(0, N):
    #m = max(math.ceil(T / TA[i][0]), math.ceil(A / TA[i][1]))
    m = max(-(-T // TA[i][0]), -(-A // TA[i][1]))
    T = TA[i][0] * m
    A = TA[i][1] * m
    ans = T + A

print(ans)
Buggy python submission (verdict: Runtime Error):
# input
S = [list(input()) for _ in range(3)]

P_curr = 0

while S[P_curr] != []
    if S[P_curr][0] == 'a':
        P_curr = 0
    if S[P_curr][0] == 'b':
        P_curr = 1
    if S[P_curr][0] == 'c':
        P_curr = 2
    del S[P_curr][0]

if P_curr == 0:
    print('A')
if P_curr == 1:
    print('B')
if P_curr == 2:
    print('C')



Fixed submission:
# input
S = [list(input()) for _ in range(3)]

P_curr = 0

while S[P_curr] != []:
    if S[P_curr][0] == 'a':
        del S[P_curr][0]
        P_curr = 0
    elif S[P_curr][0] == 'b':
        del S[P_curr][0]
        P_curr = 1
    elif S[P_curr][0] == 'c':
        del S[P_curr][0]
        P_curr = 2

if P_curr == 0:
    print('A')
if P_curr == 1:
    print('B')
if P_curr == 2:
    print('C')
Buggy python submission (verdict: Runtime Error):
import collections

# input
n, a = map(int, input().split())
X = [int(i) - a for i in input().split()]

S = collections.Counter([0, X[0]])
# Xから1枚以上選んで作ることが可能な和:作り方の場合の数
# 1枚も選ばない＝0:1通り
# X[0]のみ選ぶ＝X[0]:1通り

for i in X[1:]: # 選べるカードを増やしていく (X[0] ~ X[i] から選ぶ)
    S_temp = collections.Counter()
    for s, c in S.items():
        S_temp[s + i] += c # X[0] ~ X[i - 1] で作れる和に X[i] を足す
    sums += sums2

print(S[0] - 1) # 1枚も選ばないのはルール違反

Fixed submission:
import collections

# input
n, a = map(int, input().split())
X = [int(i) - a for i in input().split()]

sums = collections.Counter([0, X[0]])
# Xから1枚以上選んで作ることが可能な和:作り方の場合の数
# 1枚も選ばない＝0:1通り
# X[0]のみ選ぶ＝X[0]:1通り

for i in X[1:]: # 選べるカードを増やしていく (X[0] ~ X[i] から選ぶ)
    sums2 = collections.Counter()
    for s, c in sums.items():
        sums2[s + i] += c # X[0] ~ X[i - 1] で作れる和に X[i] を足す
    sums += sums2

print(sums[0] - 1) # 1枚も選ばないのはルール違反
Buggy python submission (verdict: Runtime Error):
# input
A = map(int, input().split())

ans1 = 0
ans2 = 0

for i in range(len(A)):
    if A[i] == 5:
        ans1 += 1
    if A[i] == 7:
        ans2 += 1

if ans1 == 2 and ans2 == 1:
    print('YES')
else:
    print('NO')

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

ans1 = 0
ans2 = 0

for i in range(len(A)):
    if A[i] == 5:
        ans1 += 1
    if A[i] == 7:
        ans2 += 1

if ans1 == 2 and ans2 == 1:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
# input
A = map(int, input().split())

ans1 = 0
ans2 = 0

for i in range(len(A)):
    if A[i] == 5:
        ans1 += 1
    if A[i] == 7:
        ans2 += 1

if ans1 == 2 and ans2 == 1:
    print('YES')
else:
    print("NO")

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

ans1 = 0
ans2 = 0

for i in range(len(A)):
    if A[i] == 5:
        ans1 += 1
    if A[i] == 7:
        ans2 += 1

if ans1 == 2 and ans2 == 1:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
# input
n, l = map(int, input().split())
S = sorted([input() for _ in range(N)])

ans = ''

for i in range(N):
    ans += S[i]

print(ans)


Fixed submission:
# input
n, l = map(int, input().split())
S = sorted([input() for _ in range(n)])

ans = ''

for i in range(n):
    ans += S[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
from functools import reduce

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

N = int(input())

As = map(int, input().split())

print(gcd_list(As))


Fixed submission:
# -*- coding: utf-8 -*-
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 = int(input())

As = map(int, input().split())

print(gcd_list(As))
Buggy python submission (verdict: Runtime Error):
def func(long n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3*n + 1

s = int(input())

data = set()
data.add(s)
for i in range(1000010):
    l = len(data)
    val = func(s)
    data.add(val)
    if l == len(data):
        print(i+2)
        break
    s = val


Fixed submission:
def func(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3*n + 1

s = int(input())
data = set()
data.add(s)
for i in range(1000010):
    l = len(data)
    val = func(s)
    data.add(val)
    if l == len(data):
        print(i+2)
        break
    s = val

Buggy python submission (verdict: Runtime Error):
def func(long n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3*n + 1

s = int(input())

data = set(s)

for i in range(1000010):
    l = len(data)
    val = func(s)
    data.add(val)
    if l == len(data):
        print(i+2)
        break
    s = val


Fixed submission:
def func(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3*n + 1

s = int(input())
data = set()
data.add(s)
for i in range(1000010):
    l = len(data)
    val = func(s)
    data.add(val)
    if l == len(data):
        print(i+2)
        break
    s = val
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = []

for i in range(N):
        H.append(int(input()))

H.sort()

ans = []
for i in range(N-K-1):
        # print(i)
        dif = H[i+K-1] - H[i]
        ans.append(dif)

print(min(ans))
        

Fixed submission:
n,k=map(int,input().split())
H=[]
for i in range(n):
    H.append(int(input()))
 
H.sort()
 
#print(H)
 
ans=H[n-1]-H[0]
 
for i in range(n-k+1):
    #print(H[i+k-1]-H[i])
    ans=min(ans,H[i+k-1]-H[i])
 
print(ans)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = []

for i in range(N):
        h = int(input())
        H.append(int(input()))

H.sort()

ans = []
for i in range(N-K-1):
        # print(i)
        dif = H[i+K-1] - H[i]
        ans.append(dif)

print(min(ans))
        

Fixed submission:
n,k=map(int,input().split())
H=[]
for i in range(n):
    H.append(int(input()))
 
H.sort()
 
#print(H)
 
ans=H[n-1]-H[0]
 
for i in range(n-k+1):
    #print(H[i+k-1]-H[i])
    ans=min(ans,H[i+k-1]-H[i])
 
print(ans)

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

H.sort()
ans = []

for i in range(N-K-1):
        # print(i)
        dif = H[i+K-1] - H[i]
        ans.append(dif)

print(min(ans))
        

Fixed submission:
n,k=map(int,input().split())
H=[]
for i in range(n):
    H.append(int(input()))
 
H.sort()
 
#print(H)
 
ans=H[n-1]-H[0]
 
for i in range(n-k+1):
    #print(H[i+k-1]-H[i])
    ans=min(ans,H[i+k-1]-H[i])
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
H = []
for i in range(N):
        h = int(input())
        H.append(h)

H.sort()
ans = []

for i in range(N-K+1):
        dif = max(H[i:i+K]) - min(H[i:i+K])
        ans.append(dif)
        
print(min(ans))

Fixed submission:
n,k=map(int,input().split())
H=[]
for i in range(n):
    H.append(int(input()))
 
H.sort()
 
#print(H)
 
ans=H[n-1]-H[0]
 
for i in range(n-k+1):
    #print(H[i+k-1]-H[i])
    ans=min(ans,H[i+k-1]-H[i])
 
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-


if __name__ == '__main__':
    # スペース区切りの整数の入力
    b, c = map(int, input().split())
    # b, c = map(int, input().split())
    print(b * c / 2.0)


Fixed submission:
# -*- coding: utf-8 -*-


if __name__ == '__main__':
    # スペース区切りの整数の入力
    b, c, d = map(int, input().split())
    # b, c = map(int, input().split())
    print(int(b * c / 2.0))
Buggy python submission (verdict: Runtime Error):
import numpy as np

#initialization
nmatch = np.array([0,2,5,5,4,5,6,3,7,6])
N,M = map(int,input().split())
dp = [-1]*(N+1) # contains the number of digits it can make
dp[0] = 0
ff = np.array(list(map(int,input().split()))).reshape(-1,1)
fg = nmatch[ff].reshape(-1,1)
Atemp = np.concatenate([ff,fg],axis=1)
index0 = np.argsort(Atemp[:,0])
index1 = np.argsort(Atemp[:,1])
A = Atemp[index1] #sorted by the number of matches: ascending
B = Atemp[index0]
B = B[::-1] #sorted by the number: descending
for i in range(1,N+1):
    for k in range(M):
        j = A[k,1]
        i_old = i - j #available matches
        if (i-j) < 0:
            break
        if (i-j) == 0 and dp[i] == -1:
            dp[i] = 1
        if dp[i_old] != -1 and dp[i_old]+1 > dp[i]:
            dp[i] = dp[i_old] + 1
#print(dp)
ndigits = dp[N]
j = N
final_number = ''
for l in range(ndigits,0,-1):
    index = 0
    while True:
        temp_j = j - B[index,1]
        if temp_j < 0:
            index += 1
            continue
        if dp[temp_j] + 1 == dp[j]:
            final_number += str(B[index,0])
            j = temp_j
            break
        else:
            index += 1
        if index > M:
            break
print(int(final_number))


Fixed submission:
a = input()
b = a.split()
A = int(b[0])
B = int(b[1])
if B%A == 0:
    print(A+B)
else:
    print(B-A)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M = map(int,input().split())
P = list(map(int,input().split()))
P.sort()
Q = [0] + P[:len(P)-1]
P = np.array(P)
Q = np.array(Q)
R = P-Q
R[0] = 0
for i in range(1,N):
    index = np.argmax(R)
    R[index] = 0
print(sum(R))

Fixed submission:
T, X = map(int, input().split())
print(T/X)
Buggy python submission (verdict: Runtime Error):
    a = int(input())
    list = [22,23,24,25]
    message = ['Christmas Eve Eve Eve','Christmas Eve Eve', 'Christmas Eve', 'Christmas']
    index = list.index(a)
    print(message[index])

Fixed submission:
a = int(input())
list = [22,23,24,25]
message = ['Christmas Eve Eve Eve','Christmas Eve Eve', 'Christmas Eve', 'Christmas']
index = list.index(a)
print(message[index])

Buggy python submission (verdict: Runtime Error):
a = int(input())
list = [22,23,24,25]
message = ['Christmas Eve Eve Eve','Christmas Eve Eve', 'Christmas Eve', 'Christmas']
index = list.index(a)
print(message[a])

Fixed submission:
a = int(input())
list = [22,23,24,25]
message = ['Christmas Eve Eve Eve','Christmas Eve Eve', 'Christmas Eve', 'Christmas']
index = list.index(a)
print(message[index])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,K = map(int, input().split())
h = []
sum = []
for i in range(N):
    h.append(int(input()))
h = np.array(h)
h = np.sort(h) # sorted; ascending
for i in range(N-K+1):
    sum = np.append(sum,h[i+K-1]-h[i])
print(int(min(sum)))

Fixed submission:
N,K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1]-h[i] for i in range(N-K+1)))