Buggy python submission (verdict: Time Limit Exceeded):
def calc():
  N,W=map(int,input().split())
  dp=[-1]*(W+1)
  dp[0]=0
  for i in range(N):
    w,v=map(int,input().split())
    for j in range(W-w,-1,-1):
      if dp[j]!=-1:
        dp[j+w]=max(dp[j+w],dp[j]+v)
  print(max(dp))
  
calc()

Fixed submission:
def calc():
  N,W=map(int,input().split())
  dp=[-1]*(W+1)
  dp[0]=0
  for i in range(N):
    w,v=map(int,input().split())
    for j in range(W-w,-1,-1):
      if dp[j]!=-1:
        if dp[j+w]<dp[j]+v:
          dp[j+w]=dp[j]+v
  print(max(dp))
  
calc()

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

dp=[-1]*(W+1)
dp[0]=0

for i in range(N):
  w,v=map(int,input().split())
  for j in range(W-w,-1,-1):
    if dp[j]!=-1:
      dp[j+w]=max(dp[j+w],dp[j]+v)
      
print(max(dp))

Fixed submission:
def calc():
  N,W=map(int,input().split())
  dp=[-1]*(W+1)
  dp[0]=0
  for i in range(N):
    w,v=map(int,input().split())
    for j in range(W-w,-1,-1):
      if dp[j]!=-1:
        if dp[j+w]<dp[j]+v:
          dp[j+w]=dp[j]+v
  print(max(dp))
  
calc()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,W=map(int,input().split())
weight=np.zeros(N,np.int64)
values=np.zeros(N,np.int64)
for i in range(N):
  weight[i],values[i]=map(int,input().split())

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

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


Fixed submission:
def calc():
  N,W=map(int,input().split())
  dp=[-1]*(W+1)
  dp[0]=0
  for i in range(N):
    w,v=map(int,input().split())
    for j in range(W-w,-1,-1):
      if dp[j]!=-1:
        if dp[j+w]<dp[j]+v:
          dp[j+w]=dp[j]+v
  print(max(dp))
  
calc()

Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
weight=[0]*N
values=[0]*N
for i in range(N):
  weight[i],values[i]=map(int,input().split())

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>=weight[i]:
      dp[i+1][w]=max(dp[i][w],dp[i][w-weight[i]]+values[i])
    else:
      dp[i+1][w]=dp[i][w]
      
print(dp[N][W])


Fixed submission:
def calc():
  N,W=map(int,input().split())
  dp=[-1]*(W+1)
  dp[0]=0
  for i in range(N):
    w,v=map(int,input().split())
    for j in range(W-w,-1,-1):
      if dp[j]!=-1:
        if dp[j+w]<dp[j]+v:
          dp[j+w]=dp[j]+v
  print(max(dp))
  
calc()

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

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

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

Fixed submission:
def calc():
  N,W=map(int,input().split())
  dp=[-1]*(W+1)
  dp[0]=0
  for i in range(N):
    w,v=map(int,input().split())
    for j in range(W-w,-1,-1):
      if dp[j]!=-1:
        if dp[j+w]<dp[j]+v:
          dp[j+w]=dp[j]+v
  print(max(dp))
  
calc()

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

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

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

Fixed submission:
def calc():
  N,W=map(int,input().split())
  dp=[-1]*(W+1)
  dp[0]=0
  for i in range(N):
    w,v=map(int,input().split())
    for j in range(W-w,-1,-1):
      if dp[j]!=-1:
        if dp[j+w]<dp[j]+v:
          dp[j+w]=dp[j]+v
  print(max(dp))
  
calc()