Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
  
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            
            ans+=gcd(a,b,c)  
print(ans)
n=int(input())

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

  
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            
            ans+=gcd(a,b,c)  
print(ans)


Fixed submission:
n=int(input())
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
  
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            
            ans+=gcd(a,b,c)  
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
  
ans=0
k=0
for a in range(1,n+1):
    for b in range(1,n+1):
      k=gcd(a,b)
        for c in range(1,n+1):
            ans+=gcd(k,c)  
print(ans)

Fixed submission:
n=int(input())
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
  
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            
            ans+=gcd(a,b,c)  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

  
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            
            ans+=gcd(a,b,c)  
print(ans)


Fixed submission:
n=int(input())
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
  
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            
            ans+=gcd(a,b,c)  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

def gcd(a,b):
    if a < b:
      a, b = b, a
    while b != 0:
      a, b = b, a % b
    return a

ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            i=gcd(a,b)
            j=gcd(c,i)
            ans+=j
    
print(ans)

Fixed submission:
n=int(input())
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
  
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            
            ans+=gcd(a,b,c)  
print(ans)
Buggy python submission (verdict: Runtime Error):
num1 = int(input().split())
num2 = list(map(int, input().split())    
            
num2 = sorted(num2, reverse=True)
           
N=num1[0]
M=num1[1]
A=num2[M-1]

if A<N/M/4:
    print('No')
else:
    print('Yes')


Fixed submission:
num=input()
num=num.split()

print(num[2]+" "+num[0]+" "+num[1])

Buggy python submission (verdict: Runtime Error):
a,b,c=num(int,input().split())

print(c,a,b)

Fixed submission:
num=input()
num=num.split()

print(num[2]+" "+num[0]+" "+num[1])

Buggy python submission (verdict: Runtime Error):
a,b,c=num(input(),split())
  
  print(c,a,b)

Fixed submission:
num=input()
num=num.split()

print(num[2]+" "+num[0]+" "+num[1])
Buggy python submission (verdict: Runtime Error):
num1 = int(input().split())
num2 = list(map(int, input().split())    
            
            
sorted(num2,reverse=True)            
N=num1[0]
M=num1[1]
A=num2[M-1]

if A<N/M/4:
    print('No')
else:
    print('Yes')

Fixed submission:
n,m = map(int,input().split())
li = list(map(int,input().split()))
  
li.sort(reverse=True)
  
a=li[m-1]
b=sum(li)

if a>=b/4/m:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
num1 = int(input().split())
num2 = sorted(map(int, input().split())

N=num1[0]
M=num1[1]
A=num2[M-1]

if A<N/M/4:
    print('No')
else:
    print('Yes')

Fixed submission:
n,m = map(int,input().split())
li = list(map(int,input().split()))
  
li.sort(reverse=True)
  
a=li[m-1]
b=sum(li)

if a>=b/4/m:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
num1 = int(input().split())
num2 = list(map(int, input().split()))

sorted(num2, reverse=True)
N=num1[0]
M=num1[1]
A=num2[M-1]

if A<N/M/4:
    print('No')
else:
    print('Yes')

Fixed submission:
n,m = map(int,input().split())
li = list(map(int,input().split()))
  
li.sort(reverse=True)
  
a=li[m-1]
b=sum(li)

if a>=b/4/m:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
num1 = int(input().split())
num2 = list(map(int, input().split()))

num2.sort(reverse=True)
N=num1[0]
M=num1[1]
A=num2[M-1]

if A<N/M/4:
    print('No')
else:
    print('Yes')

Fixed submission:
n,m = map(int,input().split())
li = list(map(int,input().split()))
  
li.sort(reverse=True)
  
a=li[m-1]
b=sum(li)

if a>=b/4/m:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
num1 = int(input().split())
num2 = list(map(int, input().split()))

num2.sort(reverse=True)
N=int(num1[0])
M=int(num1[1])
A=int(num2[M-1])

if A<N/M/4:
    print('No')
else:
    print('Yes')

Fixed submission:
n,m = map(int,input().split())
li = list(map(int,input().split()))
  
li.sort(reverse=True)
  
a=li[m-1]
b=sum(li)

if a>=b/4/m:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
num1=input().split()
num2=input().split()

num2.sort(reverse=True)
N=int(num1[0])
M==int(num1[1])
A=int(num2[int(num1[1])-1])

if A<N/M/4:
    print('Yes')
    else:
    print('No')

Fixed submission:
n,m = map(int,input().split())
li = list(map(int,input().split()))
  
li.sort(reverse=True)
  
a=li[m-1]
b=sum(li)

if a>=b/4/m:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
print(round(int(input()/2))

Fixed submission:
import math
print(math.ceil(int(input())/2))
Buggy python submission (verdict: Runtime Error):
n,y = map(int,input().split())

for a in range(n+1):
  for b in range(n+1-a):
    c=n-a-b
    if y==a*10000+b*5000+c*1000 and n==a+b+c:
      i=a
      j=b
      k=c
      
      break
      
print(i,j,k)

    
    


Fixed submission:
n,y = map(int,input().split())
l=0
for a in range(n+1):
  for b in range(n+1-a):
    c=n-a-b
    if y==a*10000+b*5000+c*1000 and n==a+b+c:
      i=a
      j=b
      k=c
      
      l=1
      break

if l==1:
  print(i,j,k)
else:
  print(-1,-1,-1)
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())

killcount_a = -(-C//B)
killcount_b = -(-A//D)

if a <= b:
  print("Yes")
else:
  print("No")

Fixed submission:
a, b, c, d = map(int, input().split())
 
killcount_a = -(-c//b)
killcount_b = -(-a//d)
 
if killcount_a <= killcount_b:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a, b = [int(i) for i in input().split()]

if 1 <= a =< 9 and 1 <= b =< 9:
    print(a*b)
else:
    print(-1)

Fixed submission:
a, b = [int(i) for i in input().split()]
 
if 1 <= a <= 9 and 1 <= b <= 9:
    print(a*b)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
s = input()
even = ['R', 'U', 'D']
odd = ['L', 'U', 'D']

for i, j in enumerate(s):
    if i % 2 == 0:
        if j not in odd:
            print('No')
            break
    else:
        if j not in even:
            printt('No')
            break
else:
    print('Yes')

Fixed submission:
s = input()
even = ['R', 'U', 'D']
odd = ['L', 'U', 'D']

for i, j in enumerate(s):
    if i % 2 == 0:
        if j not in even:
            print('No')
            break
    else:
        if j not in odd:
            print('No')
            break
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
n = input()
print((n - 2) * 180)

Fixed submission:
n = int(input())
print((n - 2) * 180)
Buggy python submission (verdict: Runtime Error):
a = input()

b = a.count('o')

if 8 - b <= 15 - len(s):
  print('YES')
else:
  print('NO')

Fixed submission:
a = input()

b = a.count('o')

if 8 - b <= 15 - len(a):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
a,b=[int(i) for i in input().split()]
c=list(input())

c[b] = str.lower(c[b])

c = ''.join(c)

print(c)

Fixed submission:
a,b=[int(i) for i in input().split()]
c=list(input())

c[b-1] = str.lower(c[b-1])

c = ''.join(c)

print(c)
Buggy python submission (verdict: Runtime Error):
a = str(input())

if a == 'A':
    print('T')
elif a == 'T'
    print('A')
elif a == 'G':
    print('C')
elif a == 'C':
    print('G')

Fixed submission:
a = str(input())

if a == 'A':
    print('T')
elif a == 'T':
    print('A')
elif a == 'G':
    print('C')
elif a == 'C':
    print('G')
Buggy python submission (verdict: Runtime Error):
a = int(input())

btc = 0
yen = 0

for i in range(a):
    a = input().split()
    if a[1] == 'BTC':
        btc += float(a[0])
    else:
        yen += int(a[0])

btc = btc * 380000

print(float(btc + yen))3

Fixed submission:
a = int(input())

btc = 0
yen = 0

for i in range(a):
    a = input().split()
    if a[1] == 'BTC':
        btc += float(a[0])
    else:
        yen += int(a[0])

btc = btc * 380000

print(float(btc + yen))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = [int(i) for i in input().split()]

numbers = min(b)

b = [i - min(b) for i in b]

theend = False

while theend == False:

    indexnotzero = 0

    for i in range(len(b)):
        if b[i] == 0:
            continue
        else:
            indexnotzero = i
            break
    try:
        length = b.index(0, indexnotzero)
    except ValueError:
        length = len(b)
    minimum = min(b[indexnotzero:length])

    numbers += minimum

    b[indexnotzero:length] = [i - minimum for i in b[indexnotzero:length]]

    if b.count(0) == a:
        theend = True

print(numbers)

Fixed submission:
a = int(input())
b = [int(i) for i in input().split()]

numbers = min(b)

b = [i - min(b) for i in b]

theend = False

while theend == False:
  
    if b.count(0) == a:
        theend = True
        break

    indexnotzero = 0

    for i in range(len(b)):
        if b[i] == 0:
            continue
        else:
            indexnotzero = i
            break

    if indexnotzero == len(b) - 1:
        numbers += b[len(b) - 1]
        break

    try:
        length = b.index(0, indexnotzero)
    except ValueError:
        length = len(b)
    minimum = min(b[indexnotzero:length])

    numbers += minimum

    b[indexnotzero:length] = [i - minimum for i in b[indexnotzero:length]]

print(numbers)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = [int(i) for i in input().split()]

numbers = min(b)

b = [i - min(b) for i in b]

theend = False

while theend == False:

    indexnotzero = 0

    for i in range(len(b)):
        if b[i] == 0:
            continue
        else:
            indexnotzero = i
            break

    if indexnotzero == len(b) - 1:
        numbers += b[len(b) - 1]
        theend = True
        break
    try:
        length = b.index(0, indexnotzero)
    except ValueError:
        length = len(b)
    minimum = min(b[indexnotzero:length])

    numbers += minimum

    b[indexnotzero:length] = [i - minimum for i in b[indexnotzero:length]]

    if b.count(0) == a:
        theend = True

print(numbers)

Fixed submission:
a = int(input())
b = [int(i) for i in input().split()]

numbers = min(b)

b = [i - min(b) for i in b]

theend = False

while theend == False:
  
    if b.count(0) == a:
        theend = True
        break

    indexnotzero = 0

    for i in range(len(b)):
        if b[i] == 0:
            continue
        else:
            indexnotzero = i
            break

    if indexnotzero == len(b) - 1:
        numbers += b[len(b) - 1]
        break

    try:
        length = b.index(0, indexnotzero)
    except ValueError:
        length = len(b)
    minimum = min(b[indexnotzero:length])

    numbers += minimum

    b[indexnotzero:length] = [i - minimum for i in b[indexnotzero:length]]

print(numbers)
Buggy python submission (verdict: Runtime Error):
a = int(input())
if a = 25:
  print('Christmas')
elif a = 24:
  print('Christmas Eve')
elif a = 23:
  print('Christmas Eve Eve')
elif a = 22:
  print('Christmas Eve Eve Eve')

Fixed submission:
a = int(input())
if a == 25:
  print('Christmas')
elif a == 24:
  print('Christmas Eve')
elif a == 23:
  print('Christmas Eve Eve')
elif a == 22:
  print('Christmas Eve Eve Eve')
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = []
for i in range(a):
  b.append(int(input()))

b.sort()

b[-1::] == b[-1::] / 2

print(sum(b))

Fixed submission:
a = int(input())
b = []
for i in range(a):
    b.append(int(input()))

b.sort()

b[-1] = b[-1] / 2

print(int(sum(b)))
Buggy python submission (verdict: Runtime Error):
a, b = [int(i) for i in input().split()]
c = []
for i in range(a):
    c.append(int(input()))

c.sort()

temp = 999999999999999999999999999999999999999999999999999999999999999999999999999999999
for a in range(len(c) - b + 1):
    if c[a + 2] - c[a] < temp:
        temp = c[a + 2] - c[a]

print(temp)

Fixed submission:
a, b = [int(i) for i in input().split()]
c = []
for i in range(a):
    c.append(int(input()))

c.sort()

temp = 999999999999999999999999999999999999999999999999999999999999999999999999999999999
for a in range(len(c) - b + 1):
    s = c[a + b - 1]
    t = c[a]
    if s - t < temp:
        temp = s - t

print(temp)

Buggy python submission (verdict: Runtime Error):
a, b = [int(i) for i in input().split()]
c = []
for i in range(a):
    c.append(int(input()))

c.sort()

temp = 99999999
for a in range(len(c) - b + 1):
    if c[a + 2] - c[a] < temp:
        temp = c[a + 2] - c[a]

print(temp)

Fixed submission:
a, b = [int(i) for i in input().split()]
c = []
for i in range(a):
    c.append(int(input()))

c.sort()

temp = 999999999999999999999999999999999999999999999999999999999999999999999999999999999
for a in range(len(c) - b + 1):
    s = c[a + b - 1]
    t = c[a]
    if s - t < temp:
        temp = s - t

print(temp)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = [int(i) for i in input().split()]

res = 0

for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i + j + l == s:
                res += 1
                break

print(res)

Fixed submission:
k, s = [int(i) for i in input().split()]

res = 0

for i in range(k+1):
    for j in range(k+1):
        temp = s - i - j
        if temp >= 0 and temp <= k:
            res += 1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

# 整数を一つ入力
N = int(input())

res = 0

for a in range(1,N+1):
    for b in range(1,N+1):
        for c in range(1,N+1):
            res += gcd(a,b,c)

print(res)


Fixed submission:
import math
from functools import reduce
from functools import lru_cache

@lru_cache(maxsize=10000)
def gcd(*numbers):
    return reduce(math.gcd, numbers)

# 整数を一つ入力
N = int(input())

res = 0

for a in range(1,N+1):
    for b in range(1,N+1):
        gcdab = gcd(a,b)
        for c in range(1,N+1):
            res += gcd(gcdab,c)

print(res)
Buggy python submission (verdict: Runtime Error):
s = input()
if s == "hi" * len(s) // 2:
    print("Yes")
else:
    print("No")

Fixed submission:
s = input()
if s == "hi" * (len(s) // 2):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import sys
# スペース区切りの整数入力
N,M = map(int, input().split())

sc = {}
snum = '0' * N

for i in range(M):
    s,c = map(int, input().split())
    if s in sc:
        if c != sc[s]:
            print(-1)
            sys.exit()
    sc[s] = c

for i in sc:
    snum = snum[:i-1] + str(sc[i]) + snum[i:] 

if N == len(str(int(snum))):
    print(snum)
else:
    if 1 in sc:
        print(-1)
    else:
        print(1+snum[1:])



Fixed submission:
import sys
# スペース区切りの整数入力
N,M = map(int, input().split())

sc = {}
snum = '0' * N

for i in range(M):
    s,c = map(int, input().split())
    if s in sc:
        if c != sc[s]:
            print(-1)
            sys.exit()
    sc[s] = c

for i in sc:
    snum = snum[:i-1] + str(sc[i]) + snum[i:] 

if N == len(str(int(snum))):
    print(snum)
else:
    if 1 in sc:
        print(-1)
    else:
        print("1"+snum[1:])
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
p = [int(x) for x in input().split()]

x = []
ok = 1

for i in range(1,n):
    res = "ok"
    for j in range(i):
        #print(j,i,p[j],p[i])
        if p[j] < p[i]:
            res = "ng"
            break
    if res == "ok":
        ok = ok + 1

print(ok)


Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
p = [int(x) for x in input().split()]

ok = 1
minp = [p[0]]

for i in range(1,n):
    if p[i] < minp[i-1]:
        minp.append(p[i])
        ok = ok + 1
    else:
        minp.append(minp[i-1])

print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
p = [int(x) for x in input().split()]

x = []
oklist = [0]

for i in range(1,n):
    res = "ok"
    for j in range(i):
        #print(j,i,p[j],p[i])
        if p[j] < p[i]:
            res = "ng"
            break
    if res == "ok":
        oklist.append(i)

print(len(oklist))

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
p = [int(x) for x in input().split()]

ok = 1
minp = [p[0]]

for i in range(1,n):
    if p[i] < minp[i-1]:
        minp.append(p[i])
        ok = ok + 1
    else:
        minp.append(minp[i-1])

print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
p = [int(x) for x in input().split()]

x = []
oklist = [0]

for i in range(1,n):
    res = "ok"
    for j in range(i):
        #print(j,i,p[j],p[i])
        if p[j] < p[i]:
            res = "ng"
    if res == "ok":
        oklist.append(i)

#print(oklist)
print(len(oklist))


Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
p = [int(x) for x in input().split()]

ok = 1
minp = [p[0]]

for i in range(1,n):
    if p[i] < minp[i-1]:
        minp.append(p[i])
        ok = ok + 1
    else:
        minp.append(minp[i-1])

print(ok)
Buggy python submission (verdict: Time Limit Exceeded):
INF = 10**10 - 1


#指定数分の３つの整数を順番に受けてリストに入力
# スペース区切りの整数入力
N,Wmax = map(int, input().split())
w = [0]*(N+1)
v = [0]*(N+1)
for i in range(1,N+1):
    w[i],v[i] = map(int, input().split())

#dpの初期化
dp = [[-INF] * (Wmax+1) for i in range(N+1)]
for i in range(0,N+1):
    dp[i][0] = 0
#print(dp[0])

for i in range(1,N+1):
    for ww in range(1,Wmax+1):
        if w[i] > ww:
            dp[i][ww] = dp[i-1][ww]        
        else:
            dp[i][ww] = max(dp[i-1][ww],dp[i-1][ww-w[i]]+v[i])
    #print(dp[i])

Vmax = 0
for ww in range(1,Wmax+1):
    Vmax = max(Vmax,dp[N][ww])
print(Vmax)


Fixed submission:
INF = 10**10 - 1


#指定数分の３つの整数を順番に受けてリストに入力
# スペース区切りの整数入力
N,Wmax = map(int, input().split())
w = [0]*(N+1)
v = [0]*(N+1)
for i in range(1,N+1):
    w[i],v[i] = map(int, input().split())

#dpの初期化
dp = [[-INF] * (Wmax+1) for i in range(N+1)]
for i in range(0,N+1):
    dp[i][0] = 0
#print(dp[0])

for i in range(1,N+1):
    for ww in range(1,Wmax+1):
        dp[i][ww] = dp[i-1][ww]        
        if w[i] > ww:
            continue
        else:
            dp[i][ww] = max(dp[i][ww],dp[i-1][ww-w[i]]+v[i])
    #print(dp[i])

Vmax = 0
for ww in range(1,Wmax+1):
    Vmax = max(Vmax,dp[N][ww])
print(Vmax)

Buggy python submission (verdict: Time Limit Exceeded):
INF = 10**10 - 1


#指定数分の３つの整数を順番に受けてリストに入力
# スペース区切りの整数入力
N,Wmax = map(int, input().split())
w = [0]*(N+1)
v = [0]*(N+1)
for i in range(1,N+1):
    w[i],v[i] = map(int, input().split())

#dpの初期化
dp = [[-INF] * (Wmax+1) for i in range(N+1)]
for i in range(0,N+1):
    dp[i][0] = 0
#print(dp[0])

for i in range(1,N+1):
    for ww in range(1,Wmax+1):
        dp[i][ww] = dp[i-1][ww]        
        if w[i] > ww:
            continue
        else:
            dp[i][ww] = max(dp[i][ww],dp[i-1][ww-w[i]]+v[i])
    #print(dp[i])

Vmax = 0
for ww in range(1,Wmax+1):
    Vmax = max(Vmax,dp[N][ww])
print(Vmax)


Fixed submission:
INF = 10**10 - 1


#指定数分の３つの整数を順番に受けてリストに入力
# スペース区切りの整数入力
N,Wmax = map(int, input().split())
w = [0]*(N+1)
v = [0]*(N+1)
for i in range(1,N+1):
    w[i],v[i] = map(int, input().split())

#dpの初期化
dp = [[-INF] * (Wmax+1) for i in range(N+1)]
for i in range(0,N+1):
    dp[i][0] = 0
#print(dp[0])

for i in range(1,N+1):
    for ww in range(1,Wmax+1):
        dp[i][ww] = dp[i-1][ww]        
        if w[i] > ww:
            continue
        else:
            dp[i][ww] = max(dp[i][ww],dp[i-1][ww-w[i]]+v[i])
    #print(dp[i])

Vmax = 0
for ww in range(1,Wmax+1):
    Vmax = max(Vmax,dp[N][ww])
print(Vmax)
Buggy python submission (verdict: Runtime Error):
INF = 10**10 - 1


#指定数分の３つの整数を順番に受けてリストに入力
# スペース区切りの整数入力
N,Wmax = map(int, input().split())
w = [0]*(N+1)
v = [0]*(N+1)
for i in range(1,N+1):
    w[i],v[i] = map(int, input().split())

#dpの初期化
dp = [[-INF] * (Wmax+1) for i in range(N+1)]
for i in range(0,N+1):
    dp[i][0] = 0
#print(dp[0])

for i in range(1,N+1):
    for ww in range(1,Wmax+1):
        if w[i] > ww:
            dp[i][ww] = dp[i-1][ww]        
        else:
            dp[i][ww] = max(dp[i-1][ww],dp[i-1][ww-w[i]]+v[i])
    #print(dp[i])

Vmax = 0
for ww in range(1,Wmax+1):
    Vmax = max(Vmax,dp[N][ww])
print(Vmax)


Fixed submission:
INF = 10**10 - 1

#指定数分の複数の整数を順番に受けてリストに入力
N,Wmax = map(int, input().split())
w = [0]*(N+1)
v = [0]*(N+1)
Vsum = 0
for i in range(1,N+1):
    w[i],v[i] = map(int, input().split())
    Vsum += v[i]

#dpの初期化
dp = [[INF] * (Vsum+1) for i in range(N+1)]
for i in range(0,N+1):
    dp[i][0] = 0
#print(dp[0])

for i in range(1,N+1):
    for vv in range(1,Vsum+1):
        if v[i] > vv:
            dp[i][vv] = dp[i-1][vv]
        else:
            dp[i][vv] = min(dp[i-1][vv],dp[i-1][vv-v[i]]+w[i])
    #print(dp[i])

Vmax = 0
for vv in range(1,Vsum+1):
    if dp[N][vv] <= Wmax:
        Vmax = vv
print(Vmax)

Buggy python submission (verdict: Time Limit Exceeded):
INF = 10**10 - 1

#指定数分の複数の整数を順番に受けてリストに入力
N,Wmax = map(int, input().split())
w = [0]*(N+1)
v = [0]*(N+1)
Vsum = 0
for i in range(1,N+1):
    w[i],v[i] = map(int, input().split())
    Vsum += v[i]

#dpの初期化
dp = [[INF] * (Vsum+1) for i in range(N+1)]
for i in range(0,N+1):
    dp[i][0] = 0
#print(dp[0])

for i in range(1,N+1):
    for vv in range(1,Vsum+1):
        if v[i] > vv:
            dp[i][vv] = dp[i-1][vv]
        else:
            dp[i][vv] = min(dp[i-1][vv],dp[i-1][vv-v[i]]+w[i])
    #print(dp[i])

Vmax = 0
for vv in range(1,Vsum+1):
    if dp[N][vv] <= Wmax:
        Vmax = vv
print(Vmax)


Fixed submission:
INF = 10**10 - 1

#指定数分の複数の整数を順番に受けてリストに入力
N,Wmax = map(int, input().split())
w = [0]*(N+1)
v = [0]*(N+1)
Vsum = 0
for i in range(1,N+1):
    w[i],v[i] = map(int, input().split())
    Vsum += v[i]

#dpの初期化
dp = [[INF] * (Vsum+1) for i in range(N+1)]
for i in range(0,N+1):
    dp[i][0] = 0
#print(dp[0])

for i in range(1,N+1):
    for vv in range(1,Vsum+1):
        if v[i] > vv:
            dp[i][vv] = dp[i-1][vv]
        else:
            dp[i][vv] = min(dp[i-1][vv],dp[i-1][vv-v[i]]+w[i])
    #print(dp[i])

Vmax = 0
for vv in range(1,Vsum+1):
    if dp[N][vv] <= Wmax:
        Vmax = vv
print(Vmax)