Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import pandas as pd

k, x = map(int, input().split())

axis = list(range(-1000000, 1000001, 1))
df = pd.DataFrame(axis)
df = df.rename(columns = {0 : 'var'})

res = []

if k == 1:
    print(x)
else:
    for i in range(1, k):

        a = df[df['var'] == x + i]
        a = list(a['var'])
        res.append(a)
        
        a = df[df['var'] == x - i]
        a = list(a['var'])
        res.append(a)
    res.append([x])
    res = sum(res, []) #リスト一段解除
    res = sorted(res) #並び替え
    print(*res)


Fixed submission:
k, x = map(int, input().split())

res = []
if k == 1:
    print(x)
else:
    for i in range(1, k):
        res.append(x + i)
    for i in range(1, k):
        res.append(x - i)
    res.append(x)
    res = sorted(res)
    print(*res)

Buggy python submission (verdict: Runtime Error):
import pandas as pd

k, x = map(int, input().split())

axis = list(range(-10, 11, 1))
df = pd.DataFrame(axis)
df = df.rename(columns = {0 : 'var'})

res = []

if k == 1:
    print(x)
else:
    for i in range(1, k):

        a = df[df['var'] == x + i]
        a = list(a['var'])
        res.append(a)
        
        a = df[df['var'] == x - i]
        a = list(a['var'])
        res.append(a)
    res.append([x])
    res = sum(res, []) #リスト一段解除
    res = sorted(res) #並び替え
    print(*res)


Fixed submission:
k, x = map(int, input().split())

res = []
if k == 1:
    print(x)
else:
    for i in range(1, k):
        res.append(x + i)
    for i in range(1, k):
        res.append(x - i)
    res.append(x)
    res = sorted(res)
    print(*res)

Buggy python submission (verdict: Runtime Error):

k, x = map(int, input().split())

axis = list(range(-10, 11, 1))
df = pd.DataFrame(axis)
df = df.rename(columns = {0 : 'var'})

res = []

if k == 1:
    print(x)
else:
    for i in range(1, k):

        a = df[df['var'] == x + i]
        a = list(a['var'])
        res.append(a)
        
        a = df[df['var'] == x - i]
        a = list(a['var'])
        res.append(a)
    res.append([x])
    res = sum(res, []) #リスト一段解除
    res = sorted(res) #並び替え
    print(*res)


Fixed submission:
k, x = map(int, input().split())

res = []
if k == 1:
    print(x)
else:
    for i in range(1, k):
        res.append(x + i)
    for i in range(1, k):
        res.append(x - i)
    res.append(x)
    res = sorted(res)
    print(*res)

Buggy python submission (verdict: Runtime Error):
import pandas as pd

k, x = map(int, input().split())

axis = list(range(-10, 11, 1))
df = pd.DataFrame(axis)
df = df.rename(columns = {0 : 'var'})

res = []

if k == 1:
    print(x)
else:
    for i in range(1, k):

        a = df[df['var'] == x + i]
        a = list(a['var'])
        res.append(a)
        
        a = df[df['var'] == x - i]
        a = list(a['var'])
        res.append(a)
    res.append([x])
    res = sum(res, []) #リスト一段解除
    res = sorted(res) #並び替え
    print(*res)

Fixed submission:
k, x = map(int, input().split())

res = []
if k == 1:
    print(x)
else:
    for i in range(1, k):
        res.append(x + i)
    for i in range(1, k):
        res.append(x - i)
    res.append(x)
    res = sorted(res)
    print(*res)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ps = map(int, input().split())

swap = 0
done = False
ok = True
for i in range(n):
    p = next(ps)
    if p != i+1:
        if done:
            ok = False
            break
        elif swap != 0:
            if swap == i+1:
                done = True
                swap = 0
            else:
                ok = False
                break
        else:
            swap = p

if ok:
    print("YES")
else:
    print("NO")


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

k = (a + b) / 2
if k == int(k):
    print(int(k))
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
input_line = list(map(int,input().split()))
tree_info = []
for i in range(input_line[0]-1):
    info = list(input().split())
    tree_info.append(info)
counter = [0] * input_line[0]
for i in range(input_line[1]):
    count_info = list(map(int, input().split()))
    counter[count_info[0]-1] += count_info[1]
for i in range(1,len(counter)):
    counter[i] += counter[int(tree_info[i-1][0])-1]
print(" ".join(list(map(str,counter))))
    

Fixed submission:
input_number = int(input())
input_string = input()
if input_number < 3200:
    print("red")
else:
    print(input_string)

Buggy python submission (verdict: Runtime Error):
input_number = map(int,input())
input_string = input()
if input_number < 3200:
  print(input_number)
else:
  print(input_string)

Fixed submission:
input_number = int(input())
input_string = input()
if input_number < 3200:
    print("red")
else:
    print(input_string)
Buggy python submission (verdict: Runtime Error):
M = int(input())
D = int(input())
D_array = list(map(int, str(D)))

ans = 0
for i in range(2,M+1):
  for d10 in range(2,int(D_array[0])+1):
    for d1 in range(2,10):
      if int(str(d10)+str(d1)) <= D:
        if int(d1)*int(d10) == i:
          ans += 1
print(ans)

Fixed submission:
M,D = map(int,input().split())
D_array = list(map(int, str(D)))

ans = 0
for i in range(2,M+1):
  for d10 in range(2,int(D_array[0])+1):
    for d1 in range(2,10):
      if int(str(d10)+str(d1)) <= D:
        if int(d1)*int(d10) == i:
          ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
M = int(imput())
D = int(imput())
D_array = list(map(int, str(D)))

ans = 0
for i in range(2,M+1):
  for d10 in range(2,int(D_array[0])+1):
    for d1 in range(2,10):
      if int(str(d10)+str(d1)) <= D:
        if int(d1)*int(d10) == i:
          ans += 1
print(ans)

Fixed submission:
M,D = map(int,input().split())
D_array = list(map(int, str(D)))

ans = 0
for i in range(2,M+1):
  for d10 in range(2,int(D_array[0])+1):
    for d1 in range(2,10):
      if int(str(d10)+str(d1)) <= D:
        if int(d1)*int(d10) == i:
          ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split)

print (max([a+b, a-b, a*b]))


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

print (max([a+b, a-b, a*b]))

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

print (max(a+b, a-b, a*b))


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

print (max([a+b, a-b, a*b]))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(input().split())
print (c-(a-b))

Fixed submission:
a,b,c = map(int,input().split())
print (max(0,c-(a-b)))
Buggy python submission (verdict: Runtime Error):
s = input()

sum = 700

for i in s:
  if i == o:
    sum += 100
  
  else:
    sum += 0
    
print (sum)

Fixed submission:
s = input()

print(s.count("o")*100+700)
Buggy python submission (verdict: Runtime Error):
a, b　= map(int, input().split())
c = a*b

if c%2 == 0:
  print ("Even")
else:
  print ("Odd")

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

if c % 2 == 0:
    print("Even")
else:
    print("Odd")

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

if c%2 == 0:
  print ("Even")
else:
  print ("Odd")

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

if c % 2 == 0:
    print("Even")
else:
    print("Odd")

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

if c%2 == 0:
  print ("Even")
else:
  print ("Odd")

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

if c % 2 == 0:
    print("Even")
else:
    print("Odd")

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

if c%2 == 0:
  print ("Even")
else:
  print ("Odd")

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

if c % 2 == 0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split))

ans = 0
while all(i%2 == 0 for i in A):
  A = [i/2 for i in A]
  ans += 1

print (ans)

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

ans = 0
while all(i%2 == 0 for i in A):
  A = [i/2 for i in A]
  ans += 1

print (ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
a = 0

for i in A:
  if A%2 == 0:
    a += 1
  else:
    brake:
      print a

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

ans = 0
while all(i%2 == 0 for i in A):
  A = [i/2 for i in A]
  ans += 1

print (ans)
Buggy python submission (verdict: Runtime Error):
now_Rating = int(input(R))
average = int(input(G))

x = 2*average-now_Rating

prtint(x)



Fixed submission:
R = int(input())
G = int(input())

x = 2*G-R
print (x)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

if abs(A-B)=>2:
  if A-B>0:
    ans=2*A-1
  else:
    ans=2*B-1
else:
  ans=A+B
print(ans)

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

if abs(A-B)>=2:
  if A-B>0:
    ans=2*A-1
  else:
    ans=2*B-1
else:
  ans=A+B
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
count = 0
DIC = {}
for i in range(n):
    j = ''.join(sorted(input()))
    if j in DIC:
        count += DIC[j]
        DIC[j] += 1
    else:
        DIC[j] = 1
print(count)


Fixed submission:
N = int(input())
count = 0
DIC = {}
for i in range(N):
    j = ''.join(sorted(input()))
    if j in DIC:
        count += DIC[j]
        DIC[j] += 1
    else:
        DIC[j] = 1
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = [int(i) for i in input().split(' ')]
count = 0
for i in range(N):
    if X[i]! = i+1:
        count+=1
if count <= 2:
    print("YES")
else:
    print("NO")

Fixed submission:
N = int(input())
X = [int(i) for i in input().split()]
count = 0
for i in range(N):
    if X[i] != i+1:
        count+=1
if count <= 2:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
L,R = map(int,input().split(' '))
if R - L >= 2019:
  print(0)
else:
  MIN = flaot('inf')
  for i in range(L,R):
    for j in range(i,R+1):
      MIN = min(MIN,(j-i) % 2019)
print(MIN)

Fixed submission:
L,R = map(int,input().split(' '))
MIN = 2019
if R - L >= 2019:
  print(0)
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      A = i * j
      MIN = min(A%2019,MIN)
  print(MIN)
Buggy python submission (verdict: Runtime Error):
import collections
S = input()
L = collections.Counter(S)
if len(L) == 2 and L[0][1] == 2:
  print('Yes')
else:
  print('No')


Fixed submission:
import collections
S = input()
L = collections.Counter(S)
T = L.most_common()
if len(T) == 2 and T[0][1] == 2:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
P,Q,R = map(int,input().split(' '))
List = [P,Q,R].sort()
print(List[0]+List[1])

Fixed submission:
List = list(map(int,input().split(' ')))
List.sort()
print(sum(List[0:2]))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split(' '))
left = float('-inf')
right = float('inf')
for i in range(M):
  L,R = map(int,input().split(' '))
  if left <= L:
    left = L
  if R <= right:
    right = R
  if (right - left) < 0:
    print(0)
    exit()
print(right-left+1)

Fixed submission:
A,B = map(int,input().split(' '))
if A >= 13:
  print(B)
elif 6 <= A < 13:
  print(int(B/2))
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split(' '))
num = 0
for i in range(int(N//R)+1):
  for j in range(int(N//G)+1):
    if (N-R*i-G*j) >= 0  and (N-R*i-G*j) % B == 0:
      num += 1
print(num)

Fixed submission:
R,G,B,N = map(int,input().split(' '))
A,B,C = sorted([R,G,B])
if A==1 and B==1 and C ==1:
  print(int((N+2)*(N+1)/2))
  exit()
num = 0
E = int(N//C+1)
F = int(N//B+1)
for i in range(E):
  for j in range(F):
    X = N-C*i-B*j
    if X >= 0  and X % A == 0:
      num += 1
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split(' '))
list = [R,G,B]
A,B,C = sorted(list)
num = 0
E = int(N//C+1)
F = int(N//B+1)
for i in range(E):
  for j in range(F):
    X = N-C*i-B*j
    if X >= 0  and X % A == 0:
      num += 1
print(num)

Fixed submission:
R,G,B,N = map(int,input().split(' '))
A,B,C = sorted([R,G,B])
if A==1 and B==1 and C ==1:
  print(int((N+2)*(N+1)/2))
  exit()
num = 0
E = int(N//C+1)
F = int(N//B+1)
for i in range(E):
  for j in range(F):
    X = N-C*i-B*j
    if X >= 0  and X % A == 0:
      num += 1
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split(' '))
list = [R,G,B]
A,B,C = sorted(list)
num = 0
for i in range(int(N//C)+1):
  for j in range(int(N//B)+1):
    X = N-C*i-B*j
    if X >= 0  and X % A == 0:
      num += 1
print(num)

Fixed submission:
R,G,B,N = map(int,input().split(' '))
A,B,C = sorted([R,G,B])
if A==1 and B==1 and C ==1:
  print(int((N+2)*(N+1)/2))
  exit()
num = 0
E = int(N//C+1)
F = int(N//B+1)
for i in range(E):
  for j in range(F):
    X = N-C*i-B*j
    if X >= 0  and X % A == 0:
      num += 1
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split(' '))
num = 0
for i in range(int(N//R)+1):
  for j in range(int(N//G)+1):
    A = N-R*i-G*j
    if A >= 0  and A % B == 0:
      num += 1
print(num)

Fixed submission:
R,G,B,N = map(int,input().split(' '))
A,B,C = sorted([R,G,B])
if A==1 and B==1 and C ==1:
  print(int((N+2)*(N+1)/2))
  exit()
num = 0
E = int(N//C+1)
F = int(N//B+1)
for i in range(E):
  for j in range(F):
    X = N-C*i-B*j
    if X >= 0  and X % A == 0:
      num += 1
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split(' '))
num = 0
for i in range(int(N//R)+1):
  for j in range(int(N//G)+1):
    if (N-R*i-G*j) >= 0  and (N-R*i-G*j) % B == 0:
      num += 1
print(num)

Fixed submission:
R,G,B,N = map(int,input().split(' '))
A,B,C = sorted([R,G,B])
if A==1 and B==1 and C ==1:
  print(int((N+2)*(N+1)/2))
  exit()
num = 0
E = int(N//C+1)
F = int(N//B+1)
for i in range(E):
  for j in range(F):
    X = N-C*i-B*j
    if X >= 0  and X % A == 0:
      num += 1
print(num)
Buggy python submission (verdict: Runtime Error):
import math
S = [input() for i in range(5)]
#合計時間
num = 0
#ポイント
point = int(S[0])
for i in range(1,5):
  if point[-1] == 0:
    num += point
    point = S[i]
  else:
    if point[-1] > int(S[i][-1]):
      num += point + 10 - point[-1]
      point = S[i]
    else:
      num += int(S[i]) +10 - intS[i][-1]
   
    
num += point

print(num)

Fixed submission:
N = sorted([(input())for i in range(5)],key=lambda x:x[-1])
S = list(map(int,N))
#合計時間
num = 0
key = 0
for x in S:
  if x % 10 == 0:
    num += x
  elif key == 0 and x % 10 != 0:
    num += x 
    key = 1
  else:
    num += x + 10 - int(str(x)[-1])
print(num)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split(' '))
S = input()
#文字列のパターン
pattern = 'AC'

for x in range(Q):
  l,r = map(int, input().split(' '))
  S_fragment = S[l-1:r]
  print(S_fragment.count(pattern))

Fixed submission:
N,Q = map(int,input().split(' '))
S = input()
#文字列のパターン
pattern = 'AC'
X = [0] * (N+1)

for i in range(N):
  X[i+1] = X[i] +(1 if S[i:i+2] =='AC' else 0)

for j in range(Q):
  l,r = map(int, input().split(' '))
  print(X[r-1]-X[l-1])
Buggy python submission (verdict: Runtime Error):
H,W = map(int, input().split(','))
h,w = map(int, input().split(','))
print((H-h)*(W-w))

Fixed submission:
H,W = map(int, input().split(' '))
h,w = map(int, input().split(' '))
print((H-h)*(W-w))
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int,input().split(' '))


def calc1(A,B,C):
  if A*C <= B:
    return C
  else:
    #回数
    N = 0
    while A*N <=B:
      N += 1
    return N-1
print(calc1(A,

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


def calc1(A,B,C):
  if A*C <= B:
    return C
  else:
    #回数
    N = 0
    while A*N <=B:
      N += 1
    return N-1
print(calc1(A,B,C))
Buggy python submission (verdict: Runtime Error):
# 与えられた整数の約数を返す
def func_divisors(x):
  divisors = []
  for i in range(1,int(x**0.5)+1):
    if x % i == 0:
      divisors.append(i)
      if i != x / i:
        divisors.append(int(x/i))
        
  divisors.sort()
  return divisors
  
A_divisors = func_divisors(A)
B_divisors = func_divisors(B)
C_divisors = list(set(A_divisors) & set(B_divisors))

print(C_divisors[K-1])
  

Fixed submission:
A,B,K = map(int,input().split(' '))
# 与えられた整数の約数を返す
def func_divisors(x):
  divisors = []
  for i in range(1,int(x**0.5)+1):
    if x % i == 0:
      divisors.append(i)
      if i != x / i:
        divisors.append(int(x/i))
        
  divisors.sort()
  return divisors
  
A_divisors = func_divisors(A)
B_divisors = func_divisors(B)
C_divisors = sorted(list(set(A_divisors) & set(B_divisors)),reverse=True)

print(C_divisors[K-1])
Buggy python submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split(' '))
L = [int(input()) for i in range(N)]
# 上限
MAX = 10 ** 9
#再帰関数
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else MAX
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  print(ret0,ret1,ret2,ret3)
  return min(ret0,ret1,ret2,ret3)
print(dfs(0, 0, 0, 0))

Fixed submission:
N, A, B, C = map(int, input().split(' '))
L = [int(input()) for i in range(N)]
# 上限
MAX = 10 ** 9
#再帰関数
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else MAX
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + L[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + L[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10
  return min(ret0,ret1,ret2,ret3)
print(dfs(0, 0, 0, 0))
Buggy python submission (verdict: Runtime Error):
import heapq

N = int(input())
A = list(map(int,input().split(' ')))
A_min = heapq.nsmallest(2,A)
X= A_min[0]
Y = A_min[1]

while X > 0 and Y > 0:
  if X <= Y:
    Y -= X
  else:
    X -= Y
print(max(X,Y))


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

if B % A == 0:
  print(B+A)
else:
  print(B-A)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split(' '))
H = list(map(int,input().split(' ')))
dp = [0]*N

for i in range(1,N):
  x = max(0,i-K)
  dp[i] = min([dp[j] + abs(H[i] - H[j]) for j in range(x,i)])
  
print(dp[-1])


Fixed submission:
import numpy as np
N,K = map(int,input().split())
H = np.array(list(map(int,input().split())))
dp = np.zeros(N,dtype=int)

for i in range(1,N):
  x = max(0,i-K)
  dp[i] = np.min(dp[x:i] + abs(H[x:i] - H[i]))

print(dp[-1])

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

for i in range(1,N):
  x = max(0.i-K)
  dp[i] = min([dp[j] + abs(H[i] - H[j]) for j in range(x,i)])
  
print(dp[-1])

Fixed submission:
import numpy as np
N,K = map(int,input().split())
H = np.array(list(map(int,input().split())))
dp = np.zeros(N,dtype=int)

for i in range(1,N):
  x = max(0,i-K)
  dp[i] = np.min(dp[x:i] + abs(H[x:i] - H[i]))

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split(' '))
H = list(map(int,input().split(' ')))
dp = [float('inf')]*N
dp[0] = 0

for i in range(1,N):
  dp[i] = min([dp[j] + abs(H[i] - H[j]) for j in range(max(0,i-K),i)])
  
print(dp[-1])


Fixed submission:
import numpy as np
N,K = map(int,input().split())
H = np.array(list(map(int,input().split())))
dp = np.zeros(N,dtype=int)

for i in range(1,N):
  x = max(0,i-K)
  dp[i] = np.min(dp[x:i] + abs(H[x:i] - H[i]))

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
def knapsack(N,W,weight,value):
  #初期化
  inf=float("inf")
  dp=[[-inf for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=0

  #DP
  for i in range(N):
    for w in range(W+1):
      if weight[i]<=w: #dp[i][w-weight[i]の状態にi番目の荷物が入る可能性がある
        dp[i+1][w]=max(dp[i][w-weight[i]]+value[i], dp[i][w])
      else: #入る可能性はない
        dp[i+1][w]=dp[i][w]
  return dp[N][W]

N,W = map(int,input().split(' '))
WEIGHT = []
VALUE = []
for i in range(N):
  w,v = map(int,input().split(' '))
  WEIGHT.append(w)
  VALUE.append(v)
print(knapsack(N,W,WEIGHT,VALUE))
              

Fixed submission:
def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)

    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int,input().split(' '))
DP = [[None]*(W+1)]*(N+1)
WV = list(tuple(map(int,input().split(' '))) for i in range(N))
DP[0] = [0]*(W+1)
for i in range(0,N):
  DP[i+1] = [None]*(W+1)
  for j in range(0,W+1):
    if WV[i][0] > j:
      DP[i+1][j] = DP[i][j]
    else:
      DP[i+1][j] = max(DP[i][j],DP[i][j-WV[i][0]] + WV[i][1])
print(DP[-1][-1])

Fixed submission:
def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)

    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())

Buggy python submission (verdict: Runtime Error):
def DP():
    n,w = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)

    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())



Fixed submission:
def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)

    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split(' '))

H = [int(input()) for i in range(N)]
H.sort()
ans = float('inf')
for i in range(N-K+1):
  frag = H[i:i+K]
  ans = min(ans,frag[-1] - frag[0])
  
print(ans)

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)))

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

H = sorted(list(map(int,(input() for i in range(N)))))
ans = float('inf')
for i in range(N-K+1):
  frag = H[i:i+K]
  ans = min(ans,frag[-1] - frag[0])
  
print(ans)



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)))
Buggy python submission (verdict: Runtime Error):
#主人の大好きな数字
fav = 753
listA = list(input())
N = len(listA)
#ダックスフンドの選ぶ数字
s = 0

for i in range(0,N-2):
  a,b,c = map(str,listA[i:i+3])
  x = a+b+c
  if abs(fav-s) > abs(fav-int(x)):
    s = int(a+b+c)
print(abs(fav-s)

Fixed submission:
#主人の大好きな数字
fav = 753
listA = list(input())
N = len(listA)
#ダックスフンドの選ぶ数字
s = 0

for i in range(0,N-2):
  a,b,c = map(str,listA[i:i+3])
  x = a+b+c
  if abs(fav-s) > abs(fav-int(x)):
    s = int(a+b+c)
print(abs(fav-s))
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N == 1:
  print('Hello World')
else:
  A,B = map(int,input().split(' '))
  print(A + B)

Fixed submission:
N = int(input())
 
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A + B)