n, max_weight = list(map(int, input().split()))

WV = [list(map(int, input().split())) for _ in range(n)]

W, V = list(zip(*WV))

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

for i in range(n):

    for w in range(1, max_weight + 1):

        if w >= W[i]:

            dp[i + 1][w] = max(dp[i][w], dp[i][w - W[i]] + V[i])

        else:

            dp[i + 1][w] = dp[i][w]



print((dp[n][max_weight]))

import numpy as np



N, W = list(map(int, input().split()))

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

for _ in range(N):

    w, v = list(map(int, input().split()))

    np.maximum(dp[w:], dp[:-w] + v, out=dp[w:])

print((dp[W]))
n, max_weight = list(map(int, input().split()))
WV = [list(map(int, input().split())) for _ in range(n)]
W, V = list(zip(*WV))
dp = list([0] * (max_weight + 1) for _ in range(n + 1))
for i in range(n):
    for w in range(1, max_weight + 1):
        if w >= W[i]:
            dp[i + 1][w] = max(dp[i][w], dp[i][w - W[i]] + V[i])
        else:
            dp[i + 1][w] = dp[i][w]
print((dp[n][max_weight]))

import numpy as np

N, W = list(map(int, input().split()))
dp = np.zeros(W + 1, np.int64)
for _ in range(N):
    w, v = list(map(int, input().split()))
    np.maximum(dp[w:], dp[:-w] + v, out=dp[w:])
print((dp[W]))

-n, max_weight = list(map(int, input().split())) -WV = [list(map(int, input().split())) for _ in range(n)] -W, V = list(zip(*WV)) -dp = list([0] * (max_weight + 1) for _ in range(n + 1)) -for i in range(n): -    for w in range(1, max_weight + 1): -        if w >= W[i]: -            dp[i + 1][w] = max(dp[i][w], dp[i][w - W[i]] + V[i]) -        else: -            dp[i + 1][w] = dp[i][w] -print((dp[n][max_weight])) +import numpy as np + +N, W = list(map(int, input().split())) +dp = np.zeros(W + 1, np.int64) +for _ in range(N): +    w, v = list(map(int, input().split())) +    np.maximum(dp[w:], dp[:-w] + v, out=dp[w:]) +print((dp[W]))