Problem p03164 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    maxv=sum(v)+1
    dp=[[2**60]*maxv for _ in range(N+1)]
    dp[0][0]=0
    for i in range(N):
        for j in range(maxv):
            if j>=v[i]:
                dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i])
            else:
                dp[i+1][j]=dp[i][j]

    ans=0
    for j in range(maxv):
        if W >= dp[N][j]:
            ans=j
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    maxv=sum(v)+1
    dp=[[2**60]*maxv for _ in range(N+1)]
    dp[0][0]=0
    for i in range(N):
        for j in range(maxv):
            if j>=v[i]:
                dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i])
            else:                                                                                                                                            empla
                dp[i+1][j]=dp[i][j]                                                                                                                          te)

    ans=0
    for j in range(maxv):
        if W >= dp[N][j]:
            ans=j                                                                                                                                            empla
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int                                                                                                                       empla
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"                                                                                                                   15292
    for i in range(N):                                                                                                                                       46976
        w[i] = int(next(tokens))                                                                                                                             04606
        v[i] = int(next(tokens))                                                                                                                             52921
    solve(N, W, w, v)                                                                                                                                        76, 1
                                                                                                                                                             46068
if __name__ == '__main__':                                                                                                                                   29215
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    maxv=sum(v)+1
    dp=[[2**60]*maxv for _ in range(N+1)]
    dp[0][0]=0
    for i in range(N):
        for j in range(maxv):
            if j>=v[i]:
                dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i])
            else:                                                                                                                                            empla
                dp[i+1][j]=dp[i][j]                                                                                                                          te)

    ans=0
    for j in range(maxv):
        if W >= dp[N][j]:
            ans=j                                                                                                                                            empla
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int                                                                                                                       empla
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"                                                                                                                   15292
    for i in range(N):                                                                                                                                       46976
        w[i] = int(next(tokens))                                                                                                                             04606
        v[i] = int(next(tokens))                                                                                                                             52921
    solve(N, W, w, v)                                                                                                                                        76, 1
                                                                                                                                                             46068
if __name__ == '__main__':                                                                                                                                   29215
    main()