Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 7)

N, W = map(int, input().split())
weight = [0]*N
value = [0]*N
dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
  weight[i], value[i] = map(int, input().split())
  
for i in range(N):
  for sum_w in range(W+1):
    if sum_w - weight[i] >= 0:
      dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-weight[i]]+value[i])
    dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[-1][-1]) 


Fixed submission:
import sys
input = sys.stdin.readline

weight = [0]*110
value = [0]*110
dp = [[0]*100010 for i in range(110)]

N, W = map(int, input().split())
for i in range(N):
  weight[i], value[i] = map(int, input().split())

# dp roop
for i in range(N):
  sum_w = 0
  while sum_w <= W:
    if sum_w >= weight[i]:
      dp[i+1][sum_w] = max(dp[i][sum_w - weight[i]] + value[i], dp[i][sum_w])
    else:
      dp[i+1][sum_w] = dp[i][sum_w]
    sum_w += 1
print(dp[N][W])

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

weight = [0]*n
value = [0]*n
for i in range(n):
  weight[i], value[i] = map(int, input().split())

dp = [[0]*(W+1) for _ in range(n+1)]  

for i in range(n):
  sum_w = 0
  while sum_w <= W:
    if sum_w >= weight[i]:
      dp[i+1][sum_w] = max(dp[i][sum_w - weight[i]] + value[i],
                          dp[i][sum_w])
    else:
      dp[i+1][sum_w] = dp[i][sum_w]
    sum_w += 1
print(dp[n][W])    

Fixed submission:
import sys
input = sys.stdin.readline

weight = [0]*110
value = [0]*110
dp = [[0]*100010 for i in range(110)]

N, W = map(int, input().split())
for i in range(N):
  weight[i], value[i] = map(int, input().split())

# dp roop
for i in range(N):
  sum_w = 0
  while sum_w <= W:
    if sum_w >= weight[i]:
      dp[i+1][sum_w] = max(dp[i][sum_w - weight[i]] + value[i], dp[i][sum_w])
    else:
      dp[i+1][sum_w] = dp[i][sum_w]
    sum_w += 1
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

weight = [0]*110
value = [0]*110
dp = [[0]*100010 for i in range(110)]

N, W = map(int, input().split())
for i in range(N):
  weight[i], value[i] = map(int, input().split())

# dp roop
for i in range(N):
  sum_w = 0
  while sum_w <= W:
    if sum_w >= weight[i]:
      dp[i+1][sum_w] = max(dp[i][sum_w - weight[i]] + value[i], dp[i][sum_w])
    else:
      dp[i+1][sum_w] = dp[i][sum_w]
    sum_w += 1
print(dp[N][W])    

Fixed submission:
import sys
input = sys.stdin.readline

weight = [0]*110
value = [0]*110
dp = [[0]*100010 for i in range(110)]

N, W = map(int, input().split())
for i in range(N):
  weight[i], value[i] = map(int, input().split())

# dp roop
for i in range(N):
  sum_w = 0
  while sum_w <= W:
    if sum_w >= weight[i]:
      dp[i+1][sum_w] = max(dp[i][sum_w - weight[i]] + value[i], dp[i][sum_w])
    else:
      dp[i+1][sum_w] = dp[i][sum_w]
    sum_w += 1
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import numpy as np

def chmax(a, b):
  if a<b:
    a = b
  return a

weight = np.array([0]*110)
value = np.array([0]*110)
dp = np.array([[0]*100010 for i in range(110)])

N, W = map(int, input().split())
for i in range(N):
  weight[i], value[i] = map(int, input().split())

# dp roop
for i in range(N):
  sum_w = 0
  while sum_w <= W:
    if (sum_w - weight[i]) >= 0:
      dp[i+1][sum_w] = chmax(dp[i+1][sum_w],
                             dp[i][sum_w - weight[i]] + value[i])
    dp[i+1][sum_w] = chmax(dp[i+1][sum_w], dp[i][sum_w])
    sum_w += 1
print(dp[N][W])    

Fixed submission:
import sys
input = sys.stdin.readline

weight = [0]*110
value = [0]*110
dp = [[0]*100010 for i in range(110)]

N, W = map(int, input().split())
for i in range(N):
  weight[i], value[i] = map(int, input().split())

# dp roop
for i in range(N):
  sum_w = 0
  while sum_w <= W:
    if sum_w >= weight[i]:
      dp[i+1][sum_w] = max(dp[i][sum_w - weight[i]] + value[i], dp[i][sum_w])
    else:
      dp[i+1][sum_w] = dp[i][sum_w]
    sum_w += 1
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def chmax(a, b):
  if a<b:
    a = b
  return a

weight = [0]*110
value = [0]*110
dp = [[0]*100010 for i in range(110)]
    
N, W = map(int, input().split())
for i in range(N):
  weight[i], value[i] = map(int, input().split())

# dp roop
for i in range(N):
  sum_w = 0
  while sum_w <= W:
    if (sum_w - weight[i]) >= 0:
      dp[i+1][sum_w] = chmax(dp[i+1][sum_w],
                             dp[i][sum_w - weight[i]] + value[i])
    dp[i+1][sum_w] = chmax(dp[i+1][sum_w], dp[i][sum_w])
    sum_w += 1
print(dp[N][W])    

Fixed submission:
import sys
input = sys.stdin.readline

weight = [0]*110
value = [0]*110
dp = [[0]*100010 for i in range(110)]

N, W = map(int, input().split())
for i in range(N):
  weight[i], value[i] = map(int, input().split())

# dp roop
for i in range(N):
  sum_w = 0
  while sum_w <= W:
    if sum_w >= weight[i]:
      dp[i+1][sum_w] = max(dp[i][sum_w - weight[i]] + value[i], dp[i][sum_w])
    else:
      dp[i+1][sum_w] = dp[i][sum_w]
    sum_w += 1
print(dp[N][W])