Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def resolve():
    n, w = map(int, input().split())
    goods = np.array([list(map(int, input().split())) for _ in range(n)])

    dp = np.ndarray((n, w))
    dp.fill(-1)

    print(knapsack(n - 1, w, goods, dp))

def knapsack(i, j, goods, dp):
    """残りi個の品物から、重さがj以下になるように選んだときの価値の最大値をreturnする関数"""
    if i < 0:
        # もう品物は残っていない
        res = 0

    elif dp[i - 1, j - 1] != -1:
        return dp[i - 1, j - 1]

    elif j < goods[i][0]:
        # 品物が重すぎて入らない
        res = knapsack(i - 1, j, goods, dp)
        dp[i - 1, j - 1] = res
    else:
        # 品物を入れる場合と入れない場合とで、価値が大きい方をreturn
        res = max(knapsack(i - 1, j - goods[i][0], goods, dp) + goods[i][1], knapsack(i - 1, j, goods, dp))
        dp[i - 1, j - 1] = res

    return res
  
resolve()

Fixed submission:
def resolve():
    n, w = map(int, input().split())
    goods = [list(map(int, input().split())) for _ in range(n)]

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

    for i in range(1, n + 1):
        for j in reversed(range(w + 1)):
            # もしi番目の品物が入るのであれば
            if goods[i - 1][0] <= j:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - goods[i - 1][0]] + goods[i - 1][1])
            else:
                dp[i][j] = dp[i - 1][j]

    print(dp[n][w])
    
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def resolve():
    n, w = map(int, input().split())
    goods = np.array([list(map(int, input().split())) for _ in range(n)])

    dp = np.zeros(1)
    print(knapsack(n - 1, w, goods, dp))



def knapsack(i, j, goods, dp):
    """残りi個の品物から、重さがj以下になるように選んだときの価値の最大値をreturnする関数"""
    if i < 0:
        # もう品物は残っていない
        return 0
    if j < goods[i][0]:
        # 品物が重すぎて入らない
        return knapsack(i - 1, j, goods, dp)
    else:
        # 品物を入れる場合と入れない場合とで、価値が大きい方をreturn 
        return max(knapsack(i - 1, j - goods[i][0], goods, dp) + goods[i][1], knapsack(i - 1, j, goods, dp))

resolve()

Fixed submission:
def resolve():
    n, w = map(int, input().split())
    goods = [list(map(int, input().split())) for _ in range(n)]

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

    for i in range(1, n + 1):
        for j in reversed(range(w + 1)):
            # もしi番目の品物が入るのであれば
            if goods[i - 1][0] <= j:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - goods[i - 1][0]] + goods[i - 1][1])
            else:
                dp[i][j] = dp[i - 1][j]

    print(dp[n][w])
    
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
n, w = map(int, input().split())
weight = [0] * 110
value = [0] * 110

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

  dp = [[0] * 100100 for _ in range(110)]

  for i in range(n):

    for sum_w in range(1, 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(max(dp[n]))

Fixed submission:
def resolve():
    n, w = map(int, input().split())
    goods = [list(map(int, input().split())) for _ in range(n)]

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

    for i in range(1, n + 1):
        for j in reversed(range(w + 1)):
            # もしi番目の品物が入るのであれば
            if goods[i - 1][0] <= j:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - goods[i - 1][0]] + goods[i - 1][1])
            else:
                dp[i][j] = dp[i - 1][j]

    print(dp[n][w])
    
resolve()