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

def money(n):
    re = A*n + B*len(str(n))
    return re

tmp = 0
if X >= money(1000000000):
    print(1000000000)
elif X < money(1):
    print(0)
else:
    left = 0
    right = 10**9
    while 1:
        mid = (left + right) // 2
        if money(mid) == X or right - left <= 1:
            print(mid)
            break
        elif money(mid) < X:
            left = mid
        elif money(mid) > X:
            right = mid

Fixed submission:
S = input()

if S == 'SUN':
    print(7) 
elif S == 'MON':
    print(6) 
elif S == 'TUE':
    print(5) 
elif S == 'WED':
    print(4) 
elif S == 'THU':
    print(3) 
elif S == 'FRI':
    print(2) 
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
N = int(input())

count = 0
for i in range(1, N+1):
    if i % 2 == 1:
        count += 1

print(count/N)N = int(input())

count = 0
for i in range(1, N+1):
    if i % 2 == 1:
        count += 1

print(count/N)

Fixed submission:
N = int(input())

count = 0
for i in range(1, N+1):
    if i % 2 == 1:
        count += 1

print(count/N)
Buggy python submission (verdict: Time Limit Exceeded):
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

A,B = map(int, input().split())

yaku_list = cf(A,B)
count = 1

for i in yaku_list:
  if is_prime(int(i)):
    count += 1

print(count)

Fixed submission:
def dfs(n):
    table =[]
    i = 2
    while n >= i**2:
        while n % i == 0:
            if i not in table:
                table.append(i)
            n /= i
        i += 1
    if n > 1:
        table.append(int(n))
    return table

A,B = map(int, input().split())

yaku_A = dfs(A)
yaku_B = dfs(B)
count = 1

for i in yaku_A:
  if i in yaku_B:
    count += 1

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

N_point = []

A = []
for i in range(Q):
  A.append(int(input()))

for i in range(N):
  N_point.append(K)

def calc_hiku(n):
    return n - 1

for i in A:
  N_point = list(map(calc_hiku, N_point))
  N_point[i-1] = int(N_point[i-1]) + 1

for num in N_point:
  if num > 0:
    print('Yes')
  else:
    print('No')

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

N_point = []

A = []
for i in range(Q):
  A.append(int(input()))

for i in range(N):
  N_point.append(K)

def calc_hiku(n):
    return n - Q

for i in A:
  #N_point = list(map(calc_hiku, N_point))
  N_point[i-1] = int(N_point[i-1]) + 1

N_point = list(map(calc_hiku, N_point))
#N_point_w = list(map(lambda x: x - K, N_point))

for num in N_point:
  if num > 0:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
r = input()

menseki = 3 * r * r
print(menseki)

Fixed submission:
r = int(input())

menseki = 3 * r * r
print(menseki)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

max_A = max(A)
for i in range(N):
    if A[i] != max_A:
        print(max_A)
    else:
        print(sorted(A, reverse=True)[1])

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

max_A = max(A)
next_A = sorted(A, reverse=True)[1]
for i in range(N):
    if A[i] != max_A:
        print(max_A)
    else:
        print(next_A)

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


for i in range(N):
    B = list(A)
    B.pop(i)
    print(max(B))

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

max_A = max(A)
next_A = sorted(A, reverse=True)[1]
for i in range(N):
    if A[i] != max_A:
        print(max_A)
    else:
        print(next_A)
Buggy python submission (verdict: Runtime Error):
import heapq
N,M = map(int, input().split())
A = list(map(int, input().split()))
BC = []

for i in range(M):
    BC.append(list(map(int, input().split())))

BC.sort(key=lambda x: x[1], reverse=True)
A_min = min(A)
heapq.heapify(A)
for i in range(M):
    for j in range(BC[i][0]):
        if BC[i][1] > min(A):
            heapq.heappush(A,BC[i][1])
            heapq.heappop(A)

    A_min = min(A)

print(sum(A))

Fixed submission:
N,M = map(int,input().split())
L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

L_max = max(L)
R_min = min(R)

result = R_min - L_max + 1

if result < 0:
    print(0)
else:
    print(result)
Buggy python submission (verdict: Time Limit Exceeded):
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)

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

for n in range(N):
    for w in range(W+1):
        if w>=weight[n]:
            dp[n+1][w] = max(dp[n][w-weight[n]]+value[n], dp[n][w])
        else:
            dp[n+1][w] = dp[n][w]


print(dp[N][W])

Fixed submission:
import numpy as np
N, W = map(int, input().split())
w, v = [], []
for i in range(N):
    a, b = map(int, input().split())
    w += [a]
    v += [b]
 
DP = np.zeros(W+1, dtype=int)

for i in range(N):
    DP[w[i]:] = np.maximum(DP[:-w[i]]+ v[i], DP[w[i]:])
print(DP[-1])
Buggy python submission (verdict: Runtime Error):
s = input()

def func(k):
    cnt = 0
    buf = 0
    arr = [0 for _ in s]
    arr.append(0)
    for i in range(len(s)) :
        if arr[i] == 1 :
            cnt -= 1
            buf += 1
        if (i+1 is not len(s)) and s[i] == s[i+1] :
            continue
        val = (int(s[i]) + cnt + buf)%2
        if val == 0:
            if i+k > len(s) :
                if buf > 0 :
                    buf -= 1
                    continue
                else :
                    return False
            cnt += 1
            arr[i+k] += 1
    return True

l, r = 1, len(s)+1
while r-l > 1:
    mid = (r+l)//2
    # print(mid, func(mid))
    if func(mid) : l = mid
    else : r = mid

print(l)


Fixed submission:
s = input()
n = len(s)

ans = n
for i in range(n-1) :
    if s[i] != s[i+1] :
        ans = min(ans, max(i+1, n-i-1))

print(ans)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = input()
print(a.count('ABC'))


Fixed submission:
a = int(input())
b = input()
print(b.count('ABC'))
Buggy python submission (verdict: Runtime Error):
from itertools import permutations

N = int(input())
Nlist = [i for i in range(1, int(input())+1)] 
Nlist = list(permutations(Nlist)) 

P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

print(abs(X.index(P)-X.index(Q)))

Fixed submission:
from itertools import permutations
 
N = int(input())
Nlist = [i for i in range(1, N+1)] 
Nlist = list(permutations(Nlist)) 
 
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
 
print(abs(Nlist.index(P) - Nlist.index(Q)))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
if a >= c:
  a -= c
  print(a,b)
elif c-a < b:
  b -= (c-a)
  a = 0
  print(a,b)
else:
  print(0,0)

Fixed submission:
a,b = input().split()
print(b+a)

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
if a >= c:
  a -= c
  print(a,b)
elif a < c:
  b -= (c-a)
  a = 0
  print(a,b)
else:
  print(0,0)

Fixed submission:
a,b = input().split()
print(b+a)

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

Fixed submission:
a,b = input().split()
print(b+a)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c = map(int, input().split())
for i in range(c):
  if a > 0:
    a -= 1
  elif b > 0:
    b -= 1
  else:
    break
    
print(a,b)

Fixed submission:
a,b,c = map(int, input().split())
if a >= c:
  a -= c
  print(a,b)
elif c-a < b:
  b -= (c-a)
  a = 0
  print(a,b)
else:
  print(0,0)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = (input())

print(6 - (a+b))

Fixed submission:
a = int(input())
b = int(input())

print(6 - (a+b))
Buggy python submission (verdict: Runtime Error):
a = input()
if 'AC' in s:
  print('Yes')
else:
  print('No')

Fixed submission:
a = input()
if 'AC' in a:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
a = input()
print(a.startswith('YAKI')startswith)

Fixed submission:
a = input()
if a.startswith('YAKI'):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
a = 'CODEFESTIVAL2016'
b = input()
lista = list(a)
listb = list(b)
count = 0
for i in range(len(lista)):
  if lista[i]!=listb[i]:
    count++
print(count)

Fixed submission:
a = 'CODEFESTIVAL2016'
b = input()
lista = list(a)
listb = list(b)
count = 0
for i in range(len(lista)):
  if lista[i]!=listb[i]:
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
a = 'CODEFESTIVAL2016'
b = input()
lista = list(a)
listb = list(b)
count = 0
for i in range(len(lista)):
  if lista[i]!=listb[i]:
    count++
print(count)

Fixed submission:
a = 'CODEFESTIVAL2016'
b = input()
lista = list(a)
listb = list(b)
count = 0
for i in range(len(lista)):
  if lista[i]!=listb[i]:
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
a = input()
a_first, a_last = s[:4], s[4:]
print(a_first + ' ' + a_last)

Fixed submission:
a = input()
a_first, a_last = a[:4], a[4:]
print(a_first + ' ' + a_last)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
b = ""
ab = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for i in range(int(len(s))):
    for j in range(int(len(ab))):
        if (s[i] == ab[j]):
            if (int(j+n) > 25):
                b += ab[j+n-25]
                break
            else:
                b += ab[j+n]
                break

print(b)


Fixed submission:
n = int(input())
s = input()
b = ""
ab = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for i in range(int(len(s))):
    for j in range(int(len(ab))):
        if (s[i] == ab[j]):
            if (int(j+n) > 25):
                b += ab[j+n-26]
                break
            else:
                b += ab[j+n]
                break

print(b)
Buggy python submission (verdict: Runtime Error):
"""
abc141-b
"""

S = input()

ans="Yes"

for i in range(int(len(S))):
    if (i % 2 == 0):
        if (S[i] == "L"):
            ans="No"
            break
    else:
        if (S[i] == "R"):
            ans="No"
            break
print(ans

Fixed submission:
"""
abc141-b
"""

S = input()

ans="Yes"

for i in range(int(len(S))):
    if (i % 2 == 0):
        if (S[i] == "L"):
            ans="No"
            break
    else:
        if (S[i] == "R"):
            ans="No"
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

print (n^3

Fixed submission:
n = int(input())

print(n**3)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a_array = list(map(int(), input().split()))
b_array = list(map(int(), input().split()))
c_array = list(map(int(), input().split()))

c_array.append(0)

sum = 0

for m in a_array:
    sum += b_array[m-1]

for i in range(n-1):
    if (a_array[i] + 1 == a_array[i+1]):
        sum += c_array[a_array[i]-1]

print(sum)


Fixed submission:
n = int(input())
a_array, b_array, c_array = [list(map(int, input().split())) for _ in range(3)]
c_array.append(0)

sum = 0

for m in a_array:
    sum += b_array[m-1]

for i in range(n-1):
    if (a_array[i] + 1 == a_array[i+1]):
        sum += c_array[a_array[i]-1]

print(sum)
Buggy python submission (verdict: Runtime Error):
n, x = list(map(int, input().split()))
l = input()
ans = 1
cnt = 0

l_list = l.split(' ')

for i in l_list:
    cnt += i
    if cnt > x:
        break
    ans += 1

print (ans)


Fixed submission:
n, x = list(map(int, input().split()))
l = input()
ans = 1
cnt = 0

l_list = l.split(' ')

for i in l_list:
    cnt += int(i)
    if cnt > x:
        break
    ans += 1

print (ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = []
l2 = []

for i in range(n):
    a, b = list(map(int, input().split()))
    l.append([a,b])
l.sort()

for i in range(len(l)-1):
    for j in range(i+1, len(l)):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))
##print(l2)

try:
    cnt = max(l2, key=l2.count)
except:
    cnt = "1000000 1000000"
x, y = list(map(int, cnt.split()))

ans = 0

for i in range(len(l)):
    if [l[i][0] + x, l[i][1] + y] in l:
        ans += 1

print(n - ans)


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

if k == 1:
    print(0)
else:
    print(n-k)

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = []
l2 = []

for i in range(n):
    a, b = list(map(int, input().split()))
    l.append([a,b])

for i in range(n-1):
    for j in range(i+1, n):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))
##print(l2)

try:
    cnt = max(l2, key=l2.count)
except:
    cnt = 0
x, y = list(map(int, cnt.split()))

ans = 0

for i in range(len(l)):
    if [l[i][0] + x, l[i][1] + y] in l:
        ans += 1

print(n - ans)


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

if k == 1:
    print(0)
else:
    print(n-k)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(200000)

n, m = list(map(int, input().split()))
b = [-1]
ans = 1

def dfs(top, bot, dp):
    if top == bot:
        return 1
    elif top < bot:
        return 0
    else:
        if (top,bot) in dp:
            return dp[(top,bot)]
        dp[(top,bot)] = dfs(top - 1, bot, dp) + dfs(top - 2, bot, dp)
    
for i in range(m):
    broken = int(input())
    b.append(broken)

b.append(n + 1)
##print (b)

dp = dict()

for i in range(len(b) - 1):
    if b[i + 1] == b[i] + 1:
        ans = 0
        break
    else:
##        print (b[i + 1] - 1, b[i] + 1)
        ans *= dfs(b[i + 1] - 1, b[i] + 1, dp)
        ans %= 1000000007

print (ans)


Fixed submission:
x = input()
x2 = x.split(" ")

x2.sort()

print (int(x2[0]) + int(x2[1]))

Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
b = [-1]
ans = 1

def dfs(top, bot):
    if top == bot:
        return 1
    elif top < bot:
        return 0
    else:
        return dfs(top - 1, bot) + dfs(top - 2, bot)
    
for i in range(m):
    broken = int(input())
    b.append(broken)

b.append(n + 1)
##print (b)

for i in range(len(b) - 1):
    if b[i] + 1 in b:
        ans = 0
        break
    else:
##        print (b[i + 1] - 1, b[i] + 1)
        ans *= dfs(b[i + 1] - 1, b[i] + 1)
        ans %= 1000000007

print (ans)


Fixed submission:
x = input()
x2 = x.split(" ")

x2.sort()

print (int(x2[0]) + int(x2[1]))
Buggy python submission (verdict: Runtime Error):
N = int (input ())
S = str (input ())
 
def dot_num ():
    cnt = 0
    for i in range (N):
        if S [i] == '.':
            cnt += 1
    return cnt
 
def hash_num ():
    cnt = 0
    for i in range (N):
        if S [i] == '#':
            cnt += 1
    return cnt
 
dots = dot_num ()
hashes = hash_num ()
 
if S [0] == '.':
    dots -= 1
 
if S [N-1] == '#':
    hashes -= 1
    
print (min (dots, hashes))

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

if C < A and C > B:
    print ("Yes")

elif C > A and C < B:
    print ("Yes")

else:
    print ("No")

Buggy python submission (verdict: Runtime Error):
A = int (input ())
B = int (input ())
C = int (input ())

if C < A and C > B:
    print ("Yes")

elif C > A and C < B:
    print ("Yes")

else:
    print ("No")

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

if C < A and C > B:
    print ("Yes")

elif C > A and C < B:
    print ("Yes")

else:
    print ("No")
Buggy python submission (verdict: Runtime Error):
N = int (input ())
S = str (input ())

def dot_num ():
    cnt = 0
    for i in range (1, N+1):
        if S [i] == '.':
            cnt += 1
    return cnt

def hash_num ():
    cnt = 0
    for i in range (1, N+1):
        if S [i] == '#':
            cnt += 1
    return cnt

dots = dot_num ()
hashes = hash_num ()

if S [0] == '.':
    dots -= 1

if S [N] == '#':
    hashes -= 1
    
print (min (dots, hashes))


Fixed submission:
N = int (input ())
S = str (input ())
S = '.' + S
N += 1
cnt = 0
inf = int(1e9)

A = list(range(N))
for i in range(N):
    A[i] =[inf,inf]
A[0][0] = A[0][1] = 0
for i in range (1,N):
    for j in range (2):
        if j == 1:
            if S[i] == '.':
                A[i][j] = min(A[i][j], A[i-1][0] + 1)
                A[i][j] = min(A[i][j], A[i-1][1] + 1)
            else:
                A[i][j] = min(A[i][j], A[i-1][0] )
                A[i][j] = min(A[i][j], A[i-1][1] )
        else:
            if S[i] == '#':
                A[i][j] = min(A[i][j], A[i-1][0] + 1)
            else:
                A[i][j] = min(A[i][j], A[i-1][0])                

ans = min(A[N-1][0],A[N-1][1])

print (ans)

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

def dot_num ():
    cnt = 0
    for i in range (N):
        if S [i] == '.':
            cnt += 1
    return cnt

def hash_num ():
    cnt = 0
    for i in range (N):
        if S [i] == '#':
            cnt += 1
    return cnt

dots = dot_num ()
hashes = hash_num ()

if S [0] == '.' and S [1] == '#':
    dots -= 1

if S [N-1] == '#' and S [N-2] == '.':
    hashes -= 1
    
print (min (dots, hashes))


Fixed submission:
N = int (input ())
S = str (input ())
S = '.' + S
N += 1
cnt = 0
inf = int(1e9)

A = list(range(N))
for i in range(N):
    A[i] =[inf,inf]
A[0][0] = A[0][1] = 0
for i in range (1,N):
    for j in range (2):
        if j == 1:
            if S[i] == '.':
                A[i][j] = min(A[i][j], A[i-1][0] + 1)
                A[i][j] = min(A[i][j], A[i-1][1] + 1)
            else:
                A[i][j] = min(A[i][j], A[i-1][0] )
                A[i][j] = min(A[i][j], A[i-1][1] )
        else:
            if S[i] == '#':
                A[i][j] = min(A[i][j], A[i-1][0] + 1)
            else:
                A[i][j] = min(A[i][j], A[i-1][0])                

ans = min(A[N-1][0],A[N-1][1])

print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans = 10**12

i = 2
while i <= n//2 + 1:
    if n % i == 0:
        ans = min(ans, (n//i) + i - 2)
    i += 1

print(ans)



Fixed submission:
import math
n = int(input())

ans = 10**12

i = 1
while i <= int(math.sqrt(n)):
    if n % i == 0:
        ans = min(ans, (n//i) + i - 2)
    i += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

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

v = a*a*b

if v == x:
    print(0)
    exit(0)

h = (2*x)/(a*a)

t = np.arctan(h/a)

print(t*180/np.pi)




Fixed submission:
import numpy as np

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

v = a*a*b

if v == x:
    print(0)
    exit(0)

t = None
if x >= v/2:
    pad = a*a*b - x
    h = (2*pad)/(a*a)
    t = np.arctan(h/a)
else:
    w = (2*x)/(a*b)
    t = np.arctan(b/w)
print(t*180/np.pi)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

sum = 0
for i in range(1, n):
    sum += i

print(sum)


Fixed submission:
n = int(input())
print(sum(range(1, n)))
Buggy python submission (verdict: Runtime Error):
x,a,b=map(int, input()split())
if abs(x-b) > abs(x-a):
  print('A')
else:
  print('B')

Fixed submission:
x,a,b=map(int, input().split())
if abs(x-b) > abs(x-a):
  print('A')
else:
  print('B')
Buggy python submission (verdict: Runtime Error):
# ARC60 D recursive with memorization
dp = [{} for j in range(N+1)]
def rec_dp(i, j):
    if(j in dp[i]):
        return dp[i][j]
    
    res = 0
    if(i == N):
        res = 0
    elif(j < w[i]):
        res = rec_dp(i+1, j)
    else:
        res = max(rec_dp(i+1, j), rec_dp(i+1, j-w[i]) + v[i])
    
    dp[i][j] = res
    return res

print(rec_dp(0, w_limit))

Fixed submission:
# ARC60 D input
nw = list(map(int, input().split()))
N = nw[0]
w_limit = nw[1]

w = []
v = []
for i in range(N):
    wv = list(map(int, input().split()))
    w.append(wv[0])
    v.append(wv[1])

# ARC60 D recursive with memorization
dp = [{} for j in range(N+1)]
def rec_dp(i, j):
    if(j in dp[i]):
        return dp[i][j]
    
    res = 0
    if(i == N):
        res = 0
    elif(j < w[i]):
        res = rec_dp(i+1, j)
    else:
        res = max(rec_dp(i+1, j), rec_dp(i+1, j-w[i]) + v[i])
    
    dp[i][j] = res
    return res

print(rec_dp(0, w_limit))

Buggy python submission (verdict: Time Limit Exceeded):
# ARC60 D input
nw = list(map(int, input().split()))
N = nw[0]
w_limit = nw[1]

w = []
v = []
for i in range(N):
    wv = list(map(int, input().split()))
    w.append(wv[0])
    v.append(wv[1])

# ARC60 D recursive with memorization
dp = [{} for i in range(w_limit+1) for j in range(N+1)]
def rec_dp(i, j):
    if(j in dp[i]):
        return dp[i][j]
    
    res = 0
    if(i == N):
        res = 0
    elif(j < w[i]):
        res = rec_dp(i+1, j)
    else:
        res = max(rec_dp(i+1, j), rec_dp(i+1, j-w[i]) + v[i])
    
    dp[i][j] = res
    return res

print(rec_dp(0, w_limit))

Fixed submission:
# ARC60 D input
nw = list(map(int, input().split()))
N = nw[0]
w_limit = nw[1]

w = []
v = []
for i in range(N):
    wv = list(map(int, input().split()))
    w.append(wv[0])
    v.append(wv[1])

# ARC60 D recursive with memorization
dp = [{} for j in range(N+1)]
def rec_dp(i, j):
    if(j in dp[i]):
        return dp[i][j]
    
    res = 0
    if(i == N):
        res = 0
    elif(j < w[i]):
        res = rec_dp(i+1, j)
    else:
        res = max(rec_dp(i+1, j), rec_dp(i+1, j-w[i]) + v[i])
    
    dp[i][j] = res
    return res

print(rec_dp(0, w_limit))
Buggy python submission (verdict: Runtime Error):
from itertools import groupby

N = input()
A = map(int, input().split())

B = [len(list(group)) for key, group in groupby(sorted(A))]
C = []
for i, val in enumerate(B):
	if val % 2 == 0: C.append(2)
	else: C.append(1)

D = [len(list(group)) for key, group in groupby(sorted(C))]

if D[1] % 2 == 0:
	answer = D[0] +D[1]
else:
	answer = D[0] +D[1] - 1

print(answer)

Fixed submission:
N = int(input())

A = len(set(list(map(int, input().split()))))

if A % 2 == 0:
    print(A - 1)
else:
    print(A)
Buggy python submission (verdict: Runtime Error):
S, T = input().split()
return T + S

Fixed submission:
S, T = input().split()
print(T + S)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

a, b = map(int, input().split())
if not 0 <= a <= 9 or not 0 <= b <= 9:
  print("-1")
  sys.exit()
  
c = a * b
print(c)



Fixed submission:
# coding: utf-8

a, b = map(int, input().split())
if not 0 <= a <= 9 or not 0 <= b <= 9:
  print("-1")
else:
  c = a * b
  print(c)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import heepq

n, m = map(int, input().split())
s = list(map(lamda x: int(x)*(-1), input().split()))
heapq.heapify(s)

for i in range(m):
  maxi = heapq.heappop(s)
  heapq.heappush(s, maxi // 2)

print(-sum(s))

Fixed submission:
# coding: utf-8
import heapq

n, m = map(int, input().split())
s = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(s)

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

print(-sum(s))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

n, m = map(int, input().split())
s = list(map(int, input().split()))

for i in range(m):
  index = s.index(max(s))
  s[index] = s[index] // 2

sum = sum(s)
print(sum)

Fixed submission:
# coding: utf-8
import heapq

n, m = map(int, input().split())
s = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(s)

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

print(-sum(s))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

n, m = map(int, input().split())
a = list(map(int, input().split()))
s = sorted(a, reverse=True)

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

sum = sum(s)
print(sum)

Fixed submission:
# coding: utf-8
import heapq

n, m = map(int, input().split())
s = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(s)

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

print(-sum(s))