Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

for i in range(1, N + 1):
    print(A.index(i) + 1, end=' ')


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

import numpy as np

A = np.array(A)
print(' '.join([str(i + 1) for i in A.argsort()]))

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

for i in range(1, N + 1):
    print(A.index(i) + 1, end=' ')

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

import numpy as np

A = np.array(A)
print(' '.join([str(i + 1) for i in A.argsort()]))
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
import math
gcd = math.gcd(A, B)
#gcd
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
# n == 1のとき、[1, 1]を返す
def factorization(n):
    
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if gcd == 1:
    print(1)
else:
    ans = len(factorization(gcd)) + 1
    print(ans)

Fixed submission:
a, b = map(int, input().split())
import fractions
gcd = fractions.gcd(a, b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    #arr.append([1, 1])
    return arr
if a == 1 or b == 1:
    print(len(factorization(gcd)))
    quit()
print(len(factorization(gcd)) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]
import numpy as np

all_score = np.array([k for _ in range(n)])
for i in a:
    all_score -= 1
    all_score[i - 1] += 1

for j in all_score:
    if j > 0:
        print('Yes')
    else:
        print('No')

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

all_score = [k - q for _ in range(n)]
for ai in a:
    all_score[ai - 1] += 1
for j in all_score:
    if j > 0:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]
import numpy as np

all_score = np.array([k for _ in range(n)])
for i in a:
    all_score -= 1
    all_score[i - 1] += 1

print(np.where(all_score > 0)[0].tolist()[0])

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

all_score = [k - q for _ in range(n)]
for ai in a:
    all_score[ai - 1] += 1
for j in all_score:
    if j > 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split())
         


while len(v) > 1:
   v =　sorted(v)
   v1 = v.pop(0)
   v2 = v.pop(0)
   v.append((v1+v2)/2)
print(v[0])


Fixed submission:
def solve(N, values):
    while len(values) > 1:
        values.sort()
        x = values.pop(0)
        y = values.pop(0)
        values.append((x + y) / 2)
    return values[0]


N = int(input())
values = [int(v) for v in input().split()]
ans = solve(N, values)
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split())
         


while len(v_sort) > 1:
   v_sort =　sorted(v)
   v1 = v_sort.pop(0)
   v2 = v_sort.pop(0)
   v_sort.append((v1+v2)/2)
print(v_sort[0])

Fixed submission:
def solve(N, values):
    while len(values) > 1:
        values.sort()
        x = values.pop(0)
        y = values.pop(0)
        values.append((x + y) / 2)
    return values[0]


N = int(input())
values = [int(v) for v in input().split()]
ans = solve(N, values)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

def sorted_str(string):
    s = sorted(string)
    return s

dic_list = []
for i in range(N):
    dic_list.append(sorted_str(s_list[i]))

cnt = 0
for i in range(N):
    #dic = strcount(s_list[i])
    dic_i = dic_list[i]
    for j in range(i + 1, N):
        #dic = strcount(s_list[i])
        dic_j = dic_list[j]
        if dic_i == dic_j:
            cnt += 1
print(cnt)

Fixed submission:
N = int(input())
anagram = {}

ans = 0
for i in range(N):
    tmp = str(sorted(input()))
    if tmp in anagram:
        ans += anagram[tmp]
        anagram[tmp] += 1
    else:
        anagram[tmp] = 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

def strcount(string):
    dic = {}
    for s in string:
        if s not in dic:
            dic[s] = 1
        else:
            dic[s] += 1
    return dic

dic_list = []
for i in range(N):
    dic_list.append(strcount(s_list[i]))

cnt = 0
for i in range(N):
    #dic = strcount(s_list[i])
    dic_i = dic_list[i]
    for j in range(i + 1, N):
        #dic = strcount(s_list[i])
        dic_j = dic_list[j]
        if dic_i == dic_j:
            cnt += 1
print(cnt)

Fixed submission:
N = int(input())
anagram = {}

ans = 0
for i in range(N):
    tmp = str(sorted(input()))
    if tmp in anagram:
        ans += anagram[tmp]
        anagram[tmp] += 1
    else:
        anagram[tmp] = 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

def strcount(string):
    dic = {}
    for s in string:
        if s not in dic:
            dic[s] = 1
        else:
            dic[s] += 1
    return dic

cnt = 0
for i in range(N):
    dic = strcount(s_list[i])
    for j in range(i + 1, N):
        #dic = strcount(s_list[i])
        if dic == strcount(s_list[j]):
            cnt += 1
print(cnt)


Fixed submission:
N = int(input())
anagram = {}

ans = 0
for i in range(N):
    tmp = str(sorted(input()))
    if tmp in anagram:
        ans += anagram[tmp]
        anagram[tmp] += 1
    else:
        anagram[tmp] = 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

def strcount(string):
    dic = {}
    for s in string:
        if s not in dic:
            dic[s] = 1
        else:
            dic[s] += 1
    return dic

cnt = 0
for i in range(N):
    dic = strcount(s_list[i])
    for j in range(i + 1, N):
        #dic = strcount(s_list[i])
        if dic == strcount(s_list[j]):
            cnt += 1
print(cnt)

Fixed submission:
N = int(input())
anagram = {}

ans = 0
for i in range(N):
    tmp = str(sorted(input()))
    if tmp in anagram:
        ans += anagram[tmp]
        anagram[tmp] += 1
    else:
        anagram[tmp] = 1

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
max_ = 0
pre = s[0]
ren = 1
for i in range(1, len(s)):
    if s[i] == pre:
        ren += 1
        max_ = max(max_, ren)
    else:
        ren = 1
        pre = s[i]
from collections import deque
status = deque([[1] * len(s)])
for i in range(max_):
    sta = [0] * len(s)
    if s[1] == 'L':
        sta[0] = status[i][1]
    else:
        sta[0] = 0
    if s[-2] == 'R':
        sta[-1] = status[i][-2]
    else:
        sta[-1] = 0
    a = [[1] * len(s)]
    for j in range(1, len(s) - 1):
        #print(sta)
        if s[j - 1] == 'R':
            sta[j] += status[i][j - 1]
        if s[j + 1] == 'L':
            sta[j] += status[i][j + 1]
    status.append(sta)
for i in range(1 + max_ - 2):
    status.popleft()
if (max_ - 2) % 2 == 0:
    print(' '.join([str(i) for i in status[1]]))
else:
    print(' '.join([str(i) for i in status[0]]))


Fixed submission:
a, b, c = map(int, input().split())
print(max(0, b + c - a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n - 1, -1, -1):
    if i + 1 > n // 2:
        ans[i] = a[i]
    else:
        cnt = 0
        for j in range(i, n, i + 1):
            if ans[j] == 1:
                cnt += 1
        #ans[i] = cnt % 2 + a[i]
        if cnt % 2 == a[i]:
            ans[i] = 0
        else:
            ans[i] = 1 
print(sum(s))
for i, j in enumerate(s):
    if j == 1:
        print(i + 1)
            

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = [0] * n
for i in range(n - 1, -1, -1):
    if i + 1 > n // 2:
        s[i] = a[i]
    else:
        cnt = 0
        for j in range(i, n, i + 1):
            if s[j] == 1:
                cnt += 1
        if cnt % 2 == a[i]:
            s[i] = 0
        else:
            s[i] = 1
print(sum(s))
for i, j in enumerate(s):
    if j == 1:
        print(i + 1)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

if L - R + 1 >= 2019:
     print(0)
else:
    ans = float('Inf')
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)


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

if R - L + 1 >= 2019:
    print(0)
else:
    res = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            res = min(res, (i * j) % 2019)
    print(res)

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

if L - R + 1 >= 2019:
     print(0)
else:
    ans = float('Inf')
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)

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

if R - L + 1 >= 2019:
    print(0)
else:
    res = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            res = min(res, (i * j) % 2019)
    print(res)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))

import numpy
p = np.array(p)
cnt = 0
for i in range(1, n-1):
    pi = np.array(p[i-1:i+2])
    #print(pi)
    if np.argsort(pi)[1] == 1:
        cnt += 1
print(cnt)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
import numpy as np
p = np.array(p)
cnt = 0
for i in range(1, n-1):
    pi = np.array(p[i-1:i+2])
    #print(pi)
    if np.argsort(pi)[1] == 1:
        cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))

import numpy
p = np.array(p)
cnt = 0
for i in range(1, n-1):
    pi = np.array(p[i-1:i +2])
    #print(pi)
    if np.argsort(pi)[1] == 1:
        cnt += 1
print(cnt)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
import numpy as np
p = np.array(p)
cnt = 0
for i in range(1, n-1):
    pi = np.array(p[i-1:i+2])
    #print(pi)
    if np.argsort(pi)[1] == 1:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
div_c = B // C
div_d = B // D
cd = lcm(C, D)
div_cd = B // cd
B_ = B - (div_c + div_d - div_cd)

div_c2 = A // C
div_d2 = A // D
div_cd2 = A // cd
A_ = A - (div_c2 + div_d2 - div_cd2)

print(B_ - A_)

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

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
div_c = B // C
div_d = B // D
cd = lcm(C, D)
div_cd = B // cd
B_ = B - (div_c + div_d - div_cd)

A -= 1
div_c2 = A // C
div_d2 = A // D
div_cd2 = A // cd
A_ = A - (div_c2 + div_d2 - div_cd2)

print(B_ - A_)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
R_max = N // R + 1
G_max = N // G + 1
B_max = N // B + 1
ans = 0
for i in range(0, R_max):
    for j in range(0, G_max):
        #for k in range(0, B_max):
            #if i * R + j * G + k * B == N:
        #a, b = divmod(N - (i * R + j * G), B)
        if (N - (i * R + j * G)) % B == 0 and (N - (i * R + j * G)) >= 0:
            #print('ans', i, j)
            ans += 1
print(ans)

Fixed submission:
R, G, B, N = map(int, input().split())
R_max = N // R + 1
G_max = N // G + 1
B_max = N // B + 1
ans = 0
for i in range(0, R_max):
    for j in range(0, G_max):
        #for k in range(0, B_max):
            #if i * R + j * G + k * B == N:
        #a, b = divmod(N - (i * R + j * G), B)
        if (N - (i * R + j * G)) % B == 0 and (N - (i * R + j * G)) >= 0:
            #print('ans', i, j)
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
s1 = []
s2 = []
for i in range(len(s)):
    if i % 2 == 0:
        s1.append('0')
        s2.append('1')
    else:
        s1.append('1')
        s2.append('0')
print(min(min_1, min_2))

Fixed submission:
s = list(input())
s1 = []
s2 = []
for i in range(len(s)):
    if i % 2 == 0:
        s1.append('0')
        s2.append('1')
    else:
        s1.append('1')
        s2.append('0')
min_1 = 0
#for i in range(2):
for i in range(len(s)):
    if s[i] != s1[i]:
        min_1 += 1
        
min_2 = 0
for i in range(len(s)):
    if s[i] != s2[i]:
        min_2 += 1
print(min(min_1, min_2))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ninzu = [int(input()) for i in range(5)]
cond = [N, 0, 0, 0, 0, 0]
flag = [0] * 6
cnt = 0
while cond[5] < N:
    if cond[0] >= ninzu[0]:
        flag[0] = 1
    else:
        flag[0] = 0
    if cond[1] >= ninzu[1]:
        flag[1] = 1
    else:
        flag[1] = 0
    if cond[2] >= ninzu[2]:
        flag[2] = 1
    else:
        flag[2] = 0
    if cond[3] >= ninzu[3]:
        flag[3] = 1
    else:
        flag[3] = 0
    if cond[4] >= ninzu[4]:
        flag[4] = 1
    else:
        flag[4] = 0
    for i in range(4, -1, -1):
        if flag[i]:
            cond[i + 1] += ninzu[i]
            cond[i] -= ninzu[i]
        else:
            cond[i + 1] += cond[i]
            cond[i] = 0
    cnt += 1
print(cnt)

Fixed submission:
N = int(input())
ninzu = [int(input()) for i in range(5)]
import math
min_ = min(ninzu)
a = math.ceil(N / min_)
print(a + 4)
Buggy python submission (verdict: Runtime Error):
s = input()
acgt = ['A', 'C', 'G', 'T']
ans = 0
for si in s:
    if si in acgt:
        cnt += 1
        ans = max(ans, cnt)
    else:
        cnt = 0
    #print(ans)
print(ans)

Fixed submission:
s = input()
acgt = ['A', 'C', 'G', 'T']
ans = 0
cnt = 0
for si in s:
    if si in acgt:
        cnt += 1
        ans = max(ans, cnt)
    else:
        cnt = 0
    #print(ans)
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
acgt = ['A', 'C', 'G', 'T']
ans = 0
for si in s:
    if si in acgt:
        cnt += 1
        ans = max(ans, cnt)
    else:
        cnt = 0
    #print(ans)
print(ans)

Fixed submission:
s = input()
acgt = ['A', 'C', 'G', 'T']
ans = 0
cnt = 0
for si in s:
    if si in acgt:
        cnt += 1
        ans = max(ans, cnt)
    else:
        cnt = 0
    #print(ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(Q)]
import re
for l, r in lr:
    s_ = s[l - 1 : r]
    ans = len(re.findall('AC', s_))
    print(ans)

Fixed submission:
N, Q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(Q)]
ac_sum = [0] * (N + 1)
s = list(s)
i = 0
while i < N:
    if s[i : i + 2] == ['A', 'C']:
        #print(i)
        ac_sum[i + 2] += ac_sum[i] + 1
        ac_sum[i + 1] += ac_sum[i] + 1
        i += 2
    else:
        ac_sum[i + 1] = ac_sum[i]
        i += 1
for l, r in lr:
    l -= 1
    r -= 1
    print(ac_sum[r] - ac_sum[l])
Buggy python submission (verdict: Runtime Error):
s_list = list(s)

print(min(s_list.count('1'), s_list.count('0')) * 2)

Fixed submission:
s = input()
s_list = list(s)

print(min(s_list.count('1'), s_list.count('0')) * 2)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

import re
#re.findall('01', s)
ans = 0
while '01' in s or '10' in s:
    ans += len(re.findall('01', s))
    s = re.sub('01', '', s)
    ans += len(re.findall('10', s))
    s = re.sub('10', '', s)

print(ans * 2)

Fixed submission:
s = input()
s_list = list(s)

print(min(s_list.count('1'), s_list.count('0')) * 2)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
x = list(map(int, input().split()))

x.sort()
s = [0] * (M - 1)
for i in range(M - 1):
    s[i] = x[i + 1] - x[i]

s.sort(reverse=True)

res = sum(s)
if M == 1:
    print(0)
    quit()
else:
    for i in range(N - 1):
        res -= s[i]

print(res)


Fixed submission:
N, M = map(int, input().split())
x = list(map(int, input().split()))
if N >= M:
    print(0)
    quit()


x.sort()
s = [0] * (M - 1)
for i in range(M - 1):
    s[i] = x[i + 1] - x[i]

s.sort(reverse=True)

res = sum(s)
if M == 1:
    print(0)
    quit()
else:
    for i in range(N - 1):
        res -= s[i]

print(res)

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

x.sort()
s = [0] * (M - 1)
for i in range(M - 1):
    s[i] = x[i + 1] - x[i]

s.sort(reverse=True)

res = sum(s)
if M == 1:
    print(0)
else:
    for i in range(N - 1):
        res -= s[i]

print(res)

Fixed submission:
N, M = map(int, input().split())
x = list(map(int, input().split()))
if N >= M:
    print(0)
    quit()


x.sort()
s = [0] * (M - 1)
for i in range(M - 1):
    s[i] = x[i + 1] - x[i]

s.sort(reverse=True)

res = sum(s)
if M == 1:
    print(0)
    quit()
else:
    for i in range(N - 1):
        res -= s[i]

print(res)

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

x.sort()
s = [0] * (M - 1)
for i in range(M - 1):
    s[i] = x[i + 1] - x[i]

s.sort(reverse=True)
res = sum(s)
for i in range(N - 1):
    res -= s[i]
print(res)

Fixed submission:
N, M = map(int, input().split())
x = list(map(int, input().split()))
if N >= M:
    print(0)
    quit()


x.sort()
s = [0] * (M - 1)
for i in range(M - 1):
    s[i] = x[i + 1] - x[i]

s.sort(reverse=True)

res = sum(s)
if M == 1:
    print(0)
    quit()
else:
    for i in range(N - 1):
        res -= s[i]

print(res)
Buggy python submission (verdict: Runtime Error):
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - wv[i][0] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - wv[i][0]] + wv[i][1])
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])          
print(dp[n][w])


Fixed submission:
n = int(input())
h = list(map(int, input().split()))
dp = [float('Inf')] * n
dp[0] = 0
for i in range(1, n):
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[n - 1])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('Inf')] * (10 ** 5 + 1)
dp[0] = 0
for i in range(n):
    for j in range(1, k + 1):
        if i + j < n:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[n - 1])

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

dp = [float('Inf') for _ in range(n)]
dp[0] = 0
for i in range(1, n):
    for j in range(1, k + 1):
        if i - j >= 0:
            if dp[i] > dp[i - j] + abs(a[i] - a[i - j]):
                dp[i] = dp[i - j] + abs(a[i] - a[i - j])
print(dp[n - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
dp = [float('Inf') for _ in range(n)]
dp[0] = 0
for i in range(1, n):
    for j in range(1, k + 1):
        if i - j >= 0:
            if dp[i] > dp[i - j] + abs(a[i] - a[i - j]):
                dp[i] = dp[i - j] + abs(a[i] - a[i - j])
print(dp[n - 1])

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

dp = [float('Inf') for _ in range(n)]
dp[0] = 0
for i in range(1, n):
    for j in range(1, k + 1):
        if i - j >= 0:
            if dp[i] > dp[i - j] + abs(a[i] - a[i - j]):
                dp[i] = dp[i - j] + abs(a[i] - a[i - j])
print(dp[n - 1])
Buggy python submission (verdict: Time Limit Exceeded):
n, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - a[i][0] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - a[i][0]] + a[i][1])
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[n][w])

Fixed submission:
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - wv[i][0] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - wv[i][0]] + wv[i][1])
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])          
print(dp[n][w])

Buggy python submission (verdict: Time Limit Exceeded):
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - wv[i][0] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - wv[i][0]] + wv[i][1])
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])          
print(dp[n][w])

Fixed submission:
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - wv[i][0] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - wv[i][0]] + wv[i][1])
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])          
print(dp[n][w])
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]

H = sorted(H)
ans = float('Inf')
for i in range(N - K + 1):
    ans = min(ans, H[i + 2] - H[i])
print(ans)

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

H = sorted(H)
ans = float('Inf')
for i in range(N - (K - 1)):
    ans = min(ans, H[i + (K - 1)] - H[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
x = list(map(int, input().split()))

import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

x.sort()
import numpy as np
x = np.array(x)
x -= X
print(gcd(*x))

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

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

x.sort()
import numpy as np
x = np.array(x)
x -= X
print(abs(gcd(*x)))
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

for i in range(len(S)):
    if S[i] != '1':
        print(int(S[i]))
        break
    else:
        if i == N - 1:
            print(1)
            break
        else:
            continue


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

for i in range(len(S)):
    if S[i] != '1':
        print(int(S[i]))
        break
    else:
        if i == K - 1:
            print(1)
            break
        else:
            continue

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

for i in range(len(S)):
    if S[i] != '1':
        print(S[i])
        break
    else:
        if i == N - 1:
            print(1)
            break
        else:
            continue

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

for i in range(len(S)):
    if S[i] != '1':
        print(int(S[i]))
        break
    else:
        if i == K - 1:
            print(1)
            break
        else:
            continue