Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
def knapsack():
  dp = np.zeros((N+1, W+1), dtype=int)
  c = np.arange(1, N+1)
  cc = np.arange(1, W+1)
  for i in c:
    w, v = map(int, input().split())
    dp[i][w:] = max(dp[i-1][w:], dp[i-1][:-w] + v)
    dp[i][:] = max(dp[i][:], dp[i-1][:])
  return dp[-1][-1]
print(knapsack())

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
def knapsack():
  dp = np.zeros((N+1, W+1), dtype=int)
  c = np.arange(1, N+1)
  for i in c:
    w, v = map(int, input().split())
    dp[i][w:] = np.maximum(dp[i-1][w:], dp[i-1][:-w] + v)
    dp[i][:] = np.maximum(dp[i][:], dp[i-1][:])
  return dp[-1][-1]
print(knapsack())

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
def knapsack():
  dp = np.zeros((N+1, W+1), dtype=int)
  c = np.arange(1, N+1)
  cc = np.arange(1, W+1)
  for i in c:
    w, v = map(int, input().split())
    for sum_w in cc:
      if sum_w - w >= 0:
        dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w-w] + v)
      dp[i][sum_w] = max(dp[i][sum_w], dp[i-1][sum_w])
  return dp[-1][-1]
print(knapsack())

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
def knapsack():
  dp = np.zeros((N+1, W+1), dtype=int)
  c = np.arange(1, N+1)
  for i in c:
    w, v = map(int, input().split())
    dp[i][w:] = np.maximum(dp[i-1][w:], dp[i-1][:-w] + v)
    dp[i][:] = np.maximum(dp[i][:], dp[i-1][:])
  return dp[-1][-1]
print(knapsack())

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
def knapsack():
  dp = np.zeros((N+1, W+1), dtype=int)
  for i in range(1, N+1):
    w, v = map(int, input().split())
    for sum_w in range(1, W+1):
      if sum_w - w >= 0:
        dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w-w] + v)
      dp[i][sum_w] = max(dp[i][sum_w], dp[i-1][sum_w])
  return dp[-1][-1]
print(knapsack())

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
def knapsack():
  dp = np.zeros((N+1, W+1), dtype=int)
  c = np.arange(1, N+1)
  for i in c:
    w, v = map(int, input().split())
    dp[i][w:] = np.maximum(dp[i-1][w:], dp[i-1][:-w] + v)
    dp[i][:] = np.maximum(dp[i][:], dp[i-1][:])
  return dp[-1][-1]
print(knapsack())

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
def knapsack(w, v):
  dp = np.zeros((N+1, W+1), dtype=int)
  for i in range(1, N+1):
    w, v = map(int, input().split())
    for sum_w in range(1, W+1):
      if sum_w - w >= 0:
        dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w-w] + v)
      dp[i][sum_w] = max(dp[i][sum_w], dp[i-1][sum_w])
  return dp[-1][-1]
print(knapsack(w, v))

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
def knapsack():
  dp = np.zeros((N+1, W+1), dtype=int)
  c = np.arange(1, N+1)
  for i in c:
    w, v = map(int, input().split())
    dp[i][w:] = np.maximum(dp[i-1][w:], dp[i-1][:-w] + v)
    dp[i][:] = np.maximum(dp[i][:], dp[i-1][:])
  return dp[-1][-1]
print(knapsack())

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
w = np.zeros(N, dtype=int)
v = np.zeros(N, dtype=int)
for i in range(N):
  w[i], v[i] = map(int, input().split())
def knapsack(w, v):
  dp = np.zeros((N+1, W+1), dtype=int)
  for i in range(1, N+1):
    for sum_w in range(1, W+1):
      if sum_w - w[i-1] >= 0:
        dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w-w[i-1]] + v[i-1])
      dp[i][sum_w] = max(dp[i][sum_w], dp[i-1][sum_w])
  return dp[-1][-1]
print(knapsack(w, v))

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
def knapsack():
  dp = np.zeros((N+1, W+1), dtype=int)
  c = np.arange(1, N+1)
  for i in c:
    w, v = map(int, input().split())
    dp[i][w:] = np.maximum(dp[i-1][w:], dp[i-1][:-w] + v)
    dp[i][:] = np.maximum(dp[i][:], dp[i-1][:])
  return dp[-1][-1]
print(knapsack())

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
w = np.zeros(N, dtype=int)
v = np.zeros(N, dtype=int)
for i in range(N):
  w[i], v[i] = map(int, input().split())
dp = np.zeros((N+1, W+1), dtype=int)
for i in range(1, N+1):
  for sum_w in range(1, W+1):
    if sum_w - w[i-1] >= 0:
      dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w-w[i-1]] + v[i-1])
    dp[i][sum_w] = max(dp[i][sum_w], dp[i-1][sum_w])
print(dp[N][W])

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
def knapsack():
  dp = np.zeros((N+1, W+1), dtype=int)
  c = np.arange(1, N+1)
  for i in c:
    w, v = map(int, input().split())
    dp[i][w:] = np.maximum(dp[i-1][w:], dp[i-1][:-w] + v)
    dp[i][:] = np.maximum(dp[i][:], dp[i-1][:])
  return dp[-1][-1]
print(knapsack())

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
w = np.zeros(N, dtype=int)
v = np.zeros(N, dtype=int)
for i in range(N):
  w[i], v[i] = map(int, input().split())
dp = np.zeros((N+1, W+1), dtype=int)
for i in range(1, N+1):
  for sum_w in range(1, W+1):
    if sum_w - w[i-1] >= 0:
      dp[i][sum_w] = max([dp[i-1][sum_w], dp[i-1][sum_w-w[i-1]] + v[i-1], dp[i][sum_w]])
    else:
      dp[i][sum_w] = max(dp[i][sum_w], dp[i-1][sum_w])
print(dp[N][W])

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
def knapsack():
  dp = np.zeros((N+1, W+1), dtype=int)
  c = np.arange(1, N+1)
  for i in c:
    w, v = map(int, input().split())
    dp[i][w:] = np.maximum(dp[i-1][w:], dp[i-1][:-w] + v)
    dp[i][:] = np.maximum(dp[i][:], dp[i-1][:])
  return dp[-1][-1]
print(knapsack())