Buggy python submission (verdict: Runtime Error):
import numpy
def DP():
  n,m=map(int,input().split())
  dp=[0]*(m+2)
 
  for i in range(n):  #商品を一つずつ見ていく。
    w,v=(map(int,input().split()))
    for j in range(m+1,w,-1): #w~(限界-w)までのdpの箱に入れていく。(例)w,m=3,8なら3~5
      dp[j]=max(dp[j-w]+v,dp[j])
  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):
def DP():
  
  n,m=map(int,input().split())
  dp=[0]*(m+2)

  for i in range(n):  #商品を一つずつ見ていく。
    w,v=(map(int,input().split()))
    for j in range(m+1,w,-1): #w~(限界-w)までのdpの箱に入れていく。(例)w,m=3,8なら3~5
      if (dp[j-w]+v)>dp[j]:
        dp[j]=dp[j-w]+v
      else:
        dp[j]=dp[j]
  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):
def DP():
  n,m=map(int,input().split())
  dp=[0]*(m+2)

  for i in range(n):  #商品を一つずつ見ていく。
    w,v=(map(int,input().split()))
    for j in range(m+1,w,-1): #w~(限界-w)までのdpの箱に入れていく。(例)w,m=3,8なら3~5
      dp[j]=max(dp[j-w]+v,dp[j])
  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,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
print(max(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,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
print(dp[W])

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,m=map(int,input().split())
dp=[0]*(m+2)

for i in range(n):  #商品を一つずつ見ていく。
  w,v=(map(int,input().split()))
  for j in range(m+1,w,-1): #w~(限界-w)までのdpの箱に入れていく。(例)w,m=3,8なら3~5
    if (dp[j-w]+v)>dp[j]:
      dp[j]=dp[j-w]+v
    else:
      dp[j]=dp[j]
    
print(dp[m+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: Time Limit Exceeded):
n,m=map(int,input().split())
dp=[0]*(m+2)

for i in range(n):  #商品を一つずつ見ていく。
  w,v=(map(int,input().split()))
  for j in range(m+1,w,-1): #w~(限界-w)までのdpの箱に入れていく。(例)w,m=3,8なら3~5
    dp[j]=max(dp[j-w]+v,dp[j])
    
print(dp[m+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: Time Limit Exceeded):
n,m=map(int,input().split())
d=[ list(map(int,input().split()))  for i in range(n)]
dp=[0]*(m+2)

for i in range(n):  #商品を一つずつ見ていく。
  for j in range(m+1,d[i][0],-1): #w~(限界-w)までのdpの箱に入れていく。(例)w,m=3,8なら3~5
    dp[j]=max(dp[j-d[i][0]]+d[i][1],dp[j]) #d[i][0]=w d[i][1]=v
    
print(dp[m+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())