Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

import itertools

X, Y = two_int()

def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

def calc(a, b, p):
    if b==0:
        return 1
    elif b%2==0:
        d=calc(a,b//2, p)
        return (d*d)%p
    else:
        return (a*calc(a,b-1,p))%p

dan = (X+Y)/3
if dan.is_integer():
    n = int(dan+1)
    k = X-(n-1)+1
    print(int(comb(n-1,k-1,(10**9+7))))
else:
    print(0)

Fixed submission:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

import itertools

X, Y = two_int()

def comb(n,r,mod, N):
    def cmb(n, r, mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7 #出力の制限
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    return cmb(n,r,mod)

def calc(a, b, p):
    if b==0:
        return 1
    elif b%2==0:
        d=calc(a,b//2, p)
        return (d*d)%p
    else:
        return (a*calc(a,b-1,p))%p

dan = (X+Y)/3
if dan.is_integer():
    n = int(dan+1)
    k = Y-(n-1)+1
    print(int(comb(n-1,k-1,(10**9+7),X)))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
D=many_int()

num=998244353


dicts={}
for d in D:
    if d in dicts:
        dicts[d] += 1
    else:
        dicts[d] = 1

sums = 1
keys = sorted(list(dicts.keys()))

test = [i for i in range(len(keys))]
flg=False
for t,k in zip(test,keys):
    if t!=k:
        flg=True

if dicts[0]!=1:
    flg=True
        
if flg:
    sums=0

for i in range(len(keys)-1):
    if i >= 1:
        for j in range(dicts[keys[i+1]]):
            sums *= (dicts[keys[i]])
            sums = sums%num
print(sums)

Fixed submission:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
D=many_int()

num=998244353


dicts={i:0 for i in range(N)}
for d in D:
    if d in dicts:
        dicts[d] += 1
    else:
        dicts[d] = 1

sums = 1
keys = sorted(list(dicts.keys()))

test = [i for i in range(len(keys))]
flg=False
for t,k in zip(test,keys):
    if t!=k:
        flg=True

if keys[0]!=0 or D[0]!=0:
    flg=True
else:
    if dicts[0]!=1:
        flg=True
        
if flg:
    sums=0

for i in range(len(keys)-1):
    if i >= 1:
        for j in range(dicts[keys[i+1]]):
            sums *= (dicts[keys[i]])
            sums = sums%num
print(sums)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int,input().split()))

# dp = [[0 for i in range(N)] for _ in range(M)]

# sortedA = sorted(A,reverse=True)

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

print(sum(A))

Fixed submission:
import heapq as hq

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

# dp = [[0 for i in range(N)] for _ in range(M)]

# sortedA = sorted(A,reverse=True)

A = list(map(lambda x:x*-1, A))

hq.heapify(A)
for i in range(M):
    m=hq.heappop(A)*-1
    hq.heappush(A,(m//2)*-1)
#     print(A)

print(abs(sum(A)))
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = input()

now=S[0]
smartS=now
for subs in S:
    if now != subs:
        smartS+=subs
        now=subs

smartS = list(smartS)

if len(smartS)>=2:
    now=smartS[1]
    for i in range(K):
        smartS[2*i]=now
    
    count=0
    
    for i,subs in enumerate(smartS):
        if subs=="L":
            if i==0 :
                count+=1
            else:
                if smartS[i-1] != "L":
                    count+=1
        if subs=="R":
            if i==len(smartS)-1:
                count += 1
            else:
                if smartS[i+1] != "R":
                    count+=1
    print(N-count+1)
else:
    print(N-1)

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

count=0
for i in range(N-1):
    if S[i]==S[i+1]:
        count+=1
print(min(N-1, count+2*K))

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

RLcount=0
for i in range(1,len(S)):
    if S[i-1:i+1]=="RL":
        RLcount+=1


if RLcount > K:
    temp = (RLcount-K)
    NN = N-2*temp
if S[0]=="L":
    NN -= 1
if S[-1]=="R":
    NN -= 1
if RLcount < K:
    NN = N-1

print(int(NN))

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

count=0
for i in range(N-1):
    if S[i]==S[i+1]:
        count+=1
print(min(N-1, count+2*K))
Buggy python submission (verdict: Runtime Error):
S=int(input())
T=int(input())

count=0
for s,t in zip(S,T):
    if s==t:
        count+=1
print(count)

Fixed submission:
S=input()
T=input()

count=0
for s,t in zip(S,T):
    if s==t:
        count+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

print(sum(range(1,N)))

Fixed submission:
N=int(input())

print(sum(range(1,N)))
Buggy python submission (verdict: Runtime Error):
M,D = map(int,input().split())
​
count = 0
if M < 4 or D < 22:
    print(count)
else :
    for m in range(4,M+1):
        for da in range(2,10):
            if da > m:
                break
            db = int(m/da)
#             if m == M and da == int(D/10) and db > D%10:
#                 break
#             if db < 2:
#                 continue
            if da*10+db <= D and da*db == m:
                count += 1
​
print(count)

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

count=0
for i in range(1,M+1):
    for j in range(22,D+1):
        temp=str(j)
        if temp[0] >="2" and temp[1]>="2":
            if int(temp[1]) * int(temp[0])==i:
                count+=1

print(count)
Buggy python submission (verdict: Runtime Error):
input_data = []
data = input()



i=0
k=0

#最後二つが同じなら削除
inv_data=data[::-1]
memory=inv_data[0]
count=1
for ch in inv_data[1:]:
    if ch==memory:
        count+=1
    else:
        break
if count>=2:
    if count%2!=0:
        count-=1

    k+=count//2
    
    data=data[:len(data)-count] 


memory="first"
max_len=len(data)
while max_len!=i:
    if data[i] != memory:
        memory=data[i]
        i+=1             
    else:
   
        memory=data[i:i+2]
        i+=2
    k+=1
    
print(k)

Fixed submission:
input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    try:
        if data[i] != memory:
            memory=data[i]
            i+=1             
        else:
            memory=data[i:i+2]
            i+=2
    except:
        break
    k+=1
    
print(k)

Buggy python submission (verdict: Runtime Error):
input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    if data[i] != memory:
        memory=data[i]
        i+=1             
    else:
   
        memory=data[i:i+2]
        i+=2
    k+=1
    
print(k)

Fixed submission:
input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    try:
        if data[i] != memory:
            memory=data[i]
            i+=1             
        else:
            memory=data[i:i+2]
            i+=2
    except:
        break
    k+=1
    
print(k)

Buggy python submission (verdict: Runtime Error):
input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    if data[i] == memory:
        memory=data[i:i+2]
        i+=2
    else:
        memory=data[i]
        i+=1        
    k+=1
    
print(k)

Fixed submission:
input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    try:
        if data[i] != memory:
            memory=data[i]
            i+=1             
        else:
            memory=data[i:i+2]
            i+=2
    except:
        break
    k+=1
    
print(k)

Buggy python submission (verdict: Runtime Error):
input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    if data[i] == memory:
        memory=data[i:i+2]
        print(memory)
        i+=2
    else:
        memory=data[i]
        i+=1        
    k+=1
    
print(k)

Fixed submission:
input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    try:
        if data[i] != memory:
            memory=data[i]
            i+=1             
        else:
            memory=data[i:i+2]
            i+=2
    except:
        break
    k+=1
    
print(k)
Buggy python submission (verdict: Runtime Error):
N=int(input())
dums = list(map(int, input().split()))

M_1 = 0
for i,val in enumerate(dums):
    i+=1
    if i%2==1:
        M_1 += val
    else:
        M_1 -= val

out_dict = {i+1:0 for i in range(N)}
out_dict[1] = M_N

for i in range(1,N):
    out_dict[i+1] = 2*dums[i-1] - out_dict[i]

print(" ".join(list(map(str, out_dict.values()))))

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

M_1 = 0
for i,val in enumerate(dums):
    i+=1
    if i%2==1:
        M_1 += val
    else:
        M_1 -= val

out_dict = {i+1:0 for i in range(N)}
out_dict[1] = M_1

for i in range(1,N):
    out_dict[i+1] = 2*dums[i-1] - out_dict[i]

print(" ".join(list(map(str, out_dict.values()))))
Buggy python submission (verdict: Runtime Error):
matchNums=input()

flg=False
for i in range(len(matchNums)-1):
    if matchNums[i] == matchNums[i+1]:
        flg = True
if flg:
    print("Bad")
else
    print("Good")

Fixed submission:
matchNums=input()

flg=False
for i in range(len(matchNums)-1):
    if matchNums[i] == matchNums[i+1]:
        flg = True
if flg:
    print("Bad")
else:
    print("Good")
Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())
bi = C*D/math.gcd(D,C)
A-=1
Bbi =B//bi
Abi =A//bi
sa = Bbi -Abi
Bc = B//C
Bd = B//D
Ac = A//C
Ad = A//D
print(int( B-A - ((Bc-Ac) + (Bd-Ad) - sa)  ))

Fixed submission:
import fractions

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

# CとDの最小公倍数算出
bi = C*D//fractions.gcd(D,C)

A-=1
Bbi =B//bi
Abi =A//bi
sa = Bbi -Abi
# print(B-A-sa)

Bc = B//C
Bd = B//D

Ac = A//C
Ad = A//D

print(int( B-A - ((Bc-Ac) + (Bd-Ad) - sa)  ))

Buggy python submission (verdict: Runtime Error):
import math

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

# CとDの最小公倍数算出
bi = C*D/math.gcd(D,C)

A-=1
Bbi =B//bi
Abi =A//bi
sa = Bbi -Abi
# print(B-A-sa)

Bc = B//C
Bd = B//D

Ac = A//C
Ad = A//D

print(int( B-A - ((Bc-Ac) + (Bd-Ad) - sa)  ))

Fixed submission:
import fractions

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

# CとDの最小公倍数算出
bi = C*D//fractions.gcd(D,C)

A-=1
Bbi =B//bi
Abi =A//bi
sa = Bbi -Abi
# print(B-A-sa)

Bc = B//C
Bd = B//D

Ac = A//C
Ad = A//D

print(int( B-A - ((Bc-Ac) + (Bd-Ad) - sa)  ))
Buggy python submission (verdict: Runtime Error):

N, M=map(int, input().split())
A = [int(input()) for i in range(M)]

def fib(x):
    a = 1
    b = 1
    if x == 0:
        return 0
    elif x == 1:
        return a
    elif x == 2:
        return b
    else:
        for i in range(x-2):
            c = a + b
            a = b
            b = c
        return b 

before_a=1
output = fib(A[0])
if M>=1:
    for i in range(M-1):
        output *= fib(A[i+1]-A[i]-1)
    output *= fib(N-A[M-1])
else:
    output *= fib(N+1)
print(output%1000000007)

Fixed submission:

N, M=map(int, input().split())
A = [int(input()) for i in range(M)]

def fib(x):
    a = 1
    b = 1
    if x == 0:
        return 0
    elif x == 1:
        return a
    elif x == 2:
        return b
    else:
        for i in range(x-2):
            c = a + b
            a = b
            b = c
        return b 

before_a=1
output=1
if M>=1:
    output = fib(A[0])
    for i in range(M-1):
        output *= fib(A[i+1]-A[i]-1)
    output *= fib(N-A[M-1])
else:
    output *= fib(N+1)
print(output%1000000007)

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

N, M=map(int, input().split())
A = [int(input()) for i in range(M)]

def fib(n):
    x =np.sqrt(5) 
    return int(1/x * ( ((1+x)/2)**n - ((1-x)/2)**n ) )

before_a=0
output = 1
A.append(N)
for a in A:
    sa = a-before_a
    before_a = a
    output *= fib(sa)

for i in range(len(A)-1):
    if A[i]+1 == A[i+1]:
        output=0
        break
print(output%1000000007)

Fixed submission:

N, M=map(int, input().split())
A = [int(input()) for i in range(M)]

def fib(x):
    a = 1
    b = 1
    if x == 0:
        return 0
    elif x == 1:
        return a
    elif x == 2:
        return b
    else:
        for i in range(x-2):
            c = a + b
            a = b
            b = c
        return b 

before_a=1
output=1
if M>=1:
    output = fib(A[0])
    for i in range(M-1):
        output *= fib(A[i+1]-A[i]-1)
    output *= fib(N-A[M-1])
else:
    output *= fib(N+1)
print(output%1000000007)
Buggy python submission (verdict: Runtime Error):
a,p=map(int,inqut().sprit())
print((3*a+p)//2)

Fixed submission:
a,p=map(int,input().split())
print((3*a+p)//2)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())

import math
sums = 0
for i in range(1,N+1):
    num=int(math.log(K//i,2)+1)
#     if num>int(num):
#         num=int(num)+1
    if i>K-1:
        sums +=(1/N)
    else:
        sums += 1/(N * math.pow(2,num))

print(sums)

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

import math
sums = 0
for i in range(1,N+1):
    num=int(math.log(K/i,2)+1)
    
    if i>K-1:
        sums +=(1/N)
    else:
        if i*2**(num)>=K>i*2**(num-1):
            sums += 1/(N * math.pow(2,num))
        else:
            sums += 1/(N * math.pow(2,num-1))

print(sums)
Buggy python submission (verdict: Runtime Error):
N=int(input())
tree_dict={i:-1 for i in range(N)}
tree_map=[[] for i in range(N)]
start=set([i for i in range(N)])

edge=[]

#数字の若いほうから見ていくとする
for i in range(N-1):
    u,v,w = map(int, input().split())
    tree_map[u-1].append([v-1,w])

def fill(index, now_color, dist):
    for v,w in tree_map[index]:
        
        if tree_dict[v] == -1:
#             if w%2==0:
#                 tree_dict[v] = now_color
#                 fill(v, tree_dict[v], w)
#             else:
#                 tree_dict[v] = -1*now_color
#                 fill(v, tree_dict[v],w)
            tree_dict[v] = (dist+w)%2
            fill(v, tree_dict[v],w)

now_color=1
tree_dict[start]=now_color
fill(0,now_color, 0)

for i in tree_dict.values():
    if i==-1:
        print(0)
    else:
        print(1)

Fixed submission:
import sys

sys.setrecursionlimit(100000)

N=int(input())
tree_dict={i:0 for i in range(N)}
tree_map=[[] for i in range(N)]
start=set([i for i in range(N)])

edge=[]

#数字の若いほうから見ていくとする
for i in range(N-1):
    u,v,w = map(int, input().split())
    tree_map[u-1].append([v-1,w])
    tree_map[v-1].append([u-1,w])

def fill(index, now_color, dist):
    for v,w in tree_map[index]:
        
        if tree_dict[v] == 0:
            if w%2==0:
                tree_dict[v] = now_color
                fill(v, tree_dict[v], w)
            else:
                tree_dict[v] = -1*now_color
                fill(v, tree_dict[v],w)


now_color=1
tree_dict[0]=now_color
fill(0,now_color, 0)

for i in tree_dict.values():
    if i==-1:
        print(0)
    else:
        print(1)
Buggy python submission (verdict: Runtime Error):
DATA=list(map(int, input().split(" ")))
DATA=sorted(DATA)
if DATA[0] == DATA[-1]:
    print("Yes")
else;
    print("No")

Fixed submission:
DATA=list(map(int, input().split(" ")))
DATA=sorted(DATA)
if DATA[0] == DATA[-1]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))


N,Q=two_int()
S=one_str()

for i in range(Q):
    l,r =two_int()
    print(S[l-1:r].count("AC"))

Fixed submission:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

length, N=two_int()

S=one_str()

ac_list = [0]

hoge = 0
for i in range(length-1):
    if S[i:i+2]=="AC":
        hoge += 1
    ac_list.append(hoge)

for i in range(N):
    l, r = two_int()
    print(ac_list[r-1] - ac_list[l-1])

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

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N,Q=two_int()
S=one_str()

for i in range(Q):
    l,r =two_int()
    print(S[l-1:r].count("AC"))

Fixed submission:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

length, N=two_int()

S=one_str()

ac_list = [0]

hoge = 0
for i in range(length-1):
    if S[i:i+2]=="AC":
        hoge += 1
    ac_list.append(hoge)

for i in range(N):
    l, r = two_int()
    print(ac_list[r-1] - ac_list[l-1])

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

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N,Q=two_int()
S=one_str()

for i in range(Q):
    l,r =two_int()
    print(S[l-1:r].count("AC"))

Fixed submission:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

length, N=two_int()

S=one_str()

ac_list = [0]

hoge = 0
for i in range(length-1):
    if S[i:i+2]=="AC":
        hoge += 1
    ac_list.append(hoge)

for i in range(N):
    l, r = two_int()
    print(ac_list[r-1] - ac_list[l-1])
Buggy python submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N=input_int()



dicts={}
dicts["JPY"]=0
dicts["BTC"]=0

for i in range(N):
    x, u = input().split()
    dicts[u] += float(x)

sums = dicts["JPY"] + dicts["BTC"] * 380000.0

print(sums)

Fixed submission:
def input_int():
    return map(int, input().split())

def input_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=input_int()



dicts={}
dicts["JPY"]=0
dicts["BTC"]=0

for i in range(N):
    x, u = input().split()
    dicts[u] += float(x)

sums = dicts["JPY"] + dicts["BTC"] * 380000.0

print(sums)
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if B%A==0:
    print(A+B)
else:
    print(B-A)


Fixed submission:
DATA=input()
DATA=DATA.split(" ")
A=int(DATA[0])
B=int(DATA[1])

if B%A==0:
    print(A+B)
else:
    print(B-A)

Buggy python submission (verdict: Runtime Error):
A=input()
B=input()
if B%A==0:
    print(A+B)
else:
    print(B-A)

Fixed submission:
DATA=input()
DATA=DATA.split(" ")
A=int(DATA[0])
B=int(DATA[1])

if B%A==0:
    print(A+B)
else:
    print(B-A)

Buggy python submission (verdict: Runtime Error):
A=input()
B=input()
if A%B==0:
    print(A+B)
else:
    print(B-A)


Fixed submission:
DATA=input()
DATA=DATA.split(" ")
A=int(DATA[0])
B=int(DATA[1])

if B%A==0:
    print(A+B)
else:
    print(B-A)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,W=map(int,input().split())
A = [list(map(int, input().split())) for i in range(N)]



dp=np.zeros((N+1,W+1))


for i in range(N):
    for w in range(W+1):
        if w>=A[i][0]:
            dp[i+1][w] = max([dp[i][w-A[i][0]]+A[i][1], dp[i][w]])
        else:
            dp[i+1][w] = dp[i][w]
        
print(int(dp[N][W]))

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



dp = [[0 for i in range(W+1)] for j in range(N+1)]


for i in range(N):
    for w in range(W+1):
        if w>=A[i][0]:
            dp[i+1][w] = max([dp[i][w-A[i][0]]+A[i][1], dp[i][w]])
        else:
            dp[i+1][w] = dp[i][w]
        
print(int(dp[N][W]))

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



dp=np.zeros((N+1,W+1))


for i in range(N):
    for w in range(W+1):
        if w>=A[i][0]:
            dp[i+1][w] = max([dp[i][w-A[i][0]]+A[i][1], dp[i][w]])
        else:
            dp[i+1][w] = dp[i][w]
        
print(int(dp[N][W]))

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



dp = [[0 for i in range(W+1)] for j in range(N+1)]


for i in range(N):
    for w in range(W+1):
        if w>=A[i][0]:
            dp[i+1][w] = max([dp[i][w-A[i][0]]+A[i][1], dp[i][w]])
        else:
            dp[i+1][w] = dp[i][w]
        
print(int(dp[N][W]))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N,W=map(int,input().split())
A = [list(map(int, input().split())) for i in range(N)]



dp=np.zeros((N+1,W+1))


for i in range(N):
    for w in range(W+1):
        if w>=A[i][0]:
            dp[i+1][w] = max([dp[i][w-A[i][0]]+A[i][1], dp[i][w]])
        else:
            dp[i+1][w] = dp[i][w]
        
print(int(dp[N][W]))

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



dp = [[0 for i in range(W+1)] for j in range(N+1)]


for i in range(N):
    for w in range(W+1):
        if w>=A[i][0]:
            dp[i+1][w] = max([dp[i][w-A[i][0]]+A[i][1], dp[i][w]])
        else:
            dp[i+1][w] = dp[i][w]
        
print(int(dp[N][W]))