import collections





MAX_N = 110

MAX_V = 100100



Item = collections.namedtuple("Item", ("weight", "value"))





def main():

    N, W = [int(i) for i in input().split()]

    items = [Item(int(i), int(j)) for (i, j) in [input().split() for _ in range(N)]]

    dp = [[float('inf')] * MAX_V for _ in range(MAX_N)]



    dp[0][0] = 0



    for i in range(N):

        item = items[i]

        for sum_v in range(MAX_V):

            # i番目の品物を選ぶ

            if sum_v - item.value >= 0:

                dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v - item.value] + item.weight)

            dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v])



    ans = 0

    for sum_v in range(MAX_V):

        if dp[N][sum_v] <= W:

            ans = sum_v



    print(ans)



if __name__ == '__main__':

    main()
import sys

import numpy as np



input = sys.stdin.readline





def main():

    N, W = [int(i) for i in input().strip().split()]

    MAX_V = 10**3 * N



    dp = np.full([N + 1, MAX_V + 1], np.inf)

    dp[0][0] = 0

    for n in range(N):

        w, v = [int(i) for i in input().strip().split()]

        dp[n + 1] = dp[n]

        dp[n + 1][v:] = np.minimum(dp[n][v:], dp[n][:-v] + w)



    ans = np.max(np.where(dp <= W))

    print(ans)





if __name__ == '__main__':

    main()
import collections

MAX_N = 110
MAX_V = 100100
Item = collections.namedtuple("Item", ("weight", "value"))


def main():
    N, W = [int(i) for i in input().split()]
    items = [Item(int(i), int(j)) for (i, j) in [input().split() for _ in range(N)]]
    dp = [[float("inf")] * MAX_V for _ in range(MAX_N)]
    dp[0][0] = 0
    for i in range(N):
        item = items[i]
        for sum_v in range(MAX_V):
            # i番目の品物を選ぶ
            if sum_v - item.value >= 0:
                dp[i + 1][sum_v] = min(
                    dp[i + 1][sum_v], dp[i][sum_v - item.value] + item.weight
                )
            dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v])
    ans = 0
    for sum_v in range(MAX_V):
        if dp[N][sum_v] <= W:
            ans = sum_v
    print(ans)


if __name__ == "__main__":
    main()

import sys
import numpy as np

input = sys.stdin.readline


def main():
    N, W = [int(i) for i in input().strip().split()]
    MAX_V = 10**3 * N
    dp = np.full([N + 1, MAX_V + 1], np.inf)
    dp[0][0] = 0
    for n in range(N):
        w, v = [int(i) for i in input().strip().split()]
        dp[n + 1] = dp[n]
        dp[n + 1][v:] = np.minimum(dp[n][v:], dp[n][:-v] + w)
    ans = np.max(np.where(dp <= W))
    print(ans)


if __name__ == "__main__":
    main()

-import collections +import sys +import numpy as np -MAX_N = 110 -MAX_V = 100100 -Item = collections.namedtuple("Item", ("weight", "value")) +input = sys.stdin.readline -    N, W = [int(i) for i in input().split()] -    items = [Item(int(i), int(j)) for (i, j) in [input().split() for _ in range(N)]] -    dp = [[float("inf")] * MAX_V for _ in range(MAX_N)] +    N, W = [int(i) for i in input().strip().split()] +    MAX_V = 10**3 * N +    dp = np.full([N + 1, MAX_V + 1], np.inf) -    for i in range(N): -        item = items[i] -        for sum_v in range(MAX_V): -            # i番目の品物を選ぶ -            if sum_v - item.value >= 0: -                dp[i + 1][sum_v] = min( -                    dp[i + 1][sum_v], dp[i][sum_v - item.value] + item.weight -                ) -            dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v]) -    ans = 0 -    for sum_v in range(MAX_V): -        if dp[N][sum_v] <= W: -            ans = sum_v +    for n in range(N): +        w, v = [int(i) for i in input().strip().split()] +        dp[n + 1] = dp[n] +        dp[n + 1][v:] = np.minimum(dp[n][v:], dp[n][:-v] + w) +    ans = np.max(np.where(dp <= W))