Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayR)):
    if len(arrayAns) >= i
        if arrayAns[i] <= int(arrayR[i]):
           arrayAns[i] = int(arrayR[i])
        else:
            break
print(sum(arrayAns))


Fixed submission:
s = input()
if s[2] == s[3]:
    if s[4] == s[5]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayR)):
    if arrayAns[0] <= int(arrayR[i]):
        arrayAns[0] = int(arrayR[i])
        arrayAns.sort()
    else:
        break
print(sum(arrayAns))


Fixed submission:
s = input()
if s[2] == s[3]:
    if s[4] == s[5]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
arrayP = list(input().split())
arrayQ = list(input().split())
arrayR = list(input().split())
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayR)):
    if arrayAns[0] <= int(arrayR[i]):
        arrayAns[0] = int(arrayR[i])
        arrayAns.sort()
print(sum(arrayAns))

Fixed submission:
s = input()
if s[2] == s[3]:
    if s[4] == s[5]:
        print("Yes")
    else:
        print("No")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n, x, y = map(int, input().split())
array = [0]*(n-1)

for i in range(1, n+1):
    for j in range(i+2, n+1):
        array[min(j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j))-1] += 1

print(n)
for k in range(1, n):
    print(array[k])

Fixed submission:
n, x, y = map(int, input().split())
array = [0]*(n-1)

for i in range(1, n+1):
    for j in range(i+2, n+1):
        array[min(j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j))-1] += 1

print(n)
for k in range(1, n-1):
    print(array[k])

Buggy python submission (verdict: Runtime Error):
n, x, y = map(int, input().split())
array = [0]*(n-1)

for i in range(1, n+1):
    for j in range(i+2, n+1):
        array[min(j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j))-1] += 1

print(n)
for k in range(1, n):
    print(array[k])

Fixed submission:
n, x, y = map(int, input().split())
array = [0]*(n-1)

for i in range(1, n+1):
    for j in range(i+2, n+1):
        array[min(j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j))-1] += 1

print(n)
for k in range(1, n-1):
    print(array[k])

Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int, input().split())
array = []

for i in range(1, n+1):
    for j in range(i+2, n+1):
        array.append(min(j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)))

print(n)
for k in range(2, n):
    print(array.count(k))

Fixed submission:
n, x, y = map(int, input().split())
array = [0]*(n-1)

for i in range(1, n+1):
    for j in range(i+2, n+1):
        array[min(j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j))-1] += 1

print(n)
for k in range(1, n-1):
    print(array[k])

Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int, input().split())
array = []

for i in range(1, n+1):
    for j in range(i+1, n+1):
        array.append(min(j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)))

for k in range(1, n):
    print(array.count(k))

Fixed submission:
n, x, y = map(int, input().split())
array = [0]*(n-1)

for i in range(1, n+1):
    for j in range(i+2, n+1):
        array[min(j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j))-1] += 1

print(n)
for k in range(1, n-1):
    print(array[k])

Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int, input().split())
array = []

for i in range(1, n+1):
    for j in range(i+1, n+1):
        array.append(min(j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)))

for k in range(1, n):
    print(array.count(k))

Fixed submission:
n, x, y = map(int, input().split())
array = [0]*(n-1)

for i in range(1, n+1):
    for j in range(i+2, n+1):
        array[min(j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j))-1] += 1

print(n)
for k in range(1, n-1):
    print(array[k])
Buggy python submission (verdict: Runtime Error):
s = input()
end = (len(s)-1)//2
start = (len(s)+3)//2
if s[0:end] == s[end-1::-1]:
    if s[start-1::] == s[-1:start-2:-1]:
        if s[0::] == s[::-1]
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Fixed submission:
s = input()
end = (len(s)-1)//2
start = (len(s)+3)//2
if s[0:end] == s[end-1::-1]:
    if s[start-1::] == s[-1:start-2:-1]:
        if s[0::] == s[::-1]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
count = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        if (i + j) % 2 == 0:
            count += 1
print(count)


Fixed submission:
H, W = map(int, input().split())

if H !=1 and W !=1:
    answer = H * W // 2
    if H * W % 2 != 0:
        answer += 1
    print(answer)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
import math

a, b, c = map(int, input().split())
if (c - a - b) * * 2 > 4 * a * b:
    print("Yes")
else:
    print("No")


Fixed submission:
import math

a, b, c = map(int, input().split())
if (c - a - b) ** 2 > 4 * a * b and c - a - b > 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
A,B = map(int, input().split())
answerA = math.ceil(A/0.08)
answerAA = math.floor((A+1)/0.08)
answerB = math.ceil(B/0.1)
answerBB = math.floor((B+1)/0.1)
if answerA < answerB and answerAA >= answerB:
    print(answerB)
elif answerB < answerA and answerBB >= answerA:
    print(answerA)
elif answerB > answerAA:
    print("-1")
elif answerBB < answerA:
    print("-1")
elif answerA >= answerB and answerAA <= answerBB:
    print(answerA)
elif answerB >= answerA and answerBB <= answerAA:
    print(answerB)
else:
    print("-1")


Fixed submission:
s = input()
if s == "AAA" or s == "BBB":
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())

if A != B and B != C and A != C:
    print("No")
elif A = B and B = C:
    print("No")
else:
    print("Yes")

Fixed submission:
A,B,C = map(int,input().split())

if A != B and B != C and A != C:
    print("No")
elif A == B and B == C:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)
if c.most_common()[0][1] => 2:
    print("NO")
else:
    print("YES")

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)
if c.most_common()[0][1] >= 2:
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import copy
N,K = map(int, input().split())
p = list(map(int, input().split()))
que = deque([0]* K)
Max = deque([0]* K)
sumM = 0
sumq = 0
E = 0.0

for i in range(N):
    sumq -= que.popleft()
    sumq += p[i]
    que.append(p[i])
    if sumM < sumq:
        Max = copy.deepcopy(que)
        sumM = sumq
for num in Max:
    E += (num+1)* num //2/num
print(E)

Fixed submission:
from collections import deque
import copy
N,K = map(int, input().split())
p = list([(i+1)* i/2/i for i in map(int, input().split())])
que = deque([0]* K)
sumM = 0
sumq = 0
E = 0.0

for i in range(N):
    sumq -= que.popleft()
    sumq += p[i]
    que.append(p[i])
    if E < sumq:
        E = sumq
print(E)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
p = list(map(int, input().split()))
Max = []
E = 0.0

for i in range(N-(K-1)):
    if sum(Max) < sum(p[i:i+K:]):
        Max = p[i:i+K:]

for num in Max:
    E += (num+1)* num //2/num

print(E)


Fixed submission:
from collections import deque
import copy
N,K = map(int, input().split())
p = list([(i+1)* i/2/i for i in map(int, input().split())])
que = deque([0]* K)
sumM = 0
sumq = 0
E = 0.0

for i in range(N):
    sumq -= que.popleft()
    sumq += p[i]
    que.append(p[i])
    if E < sumq:
        E = sumq
print(E)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
p = list(map(int, input().split()))
Max = []
E = 0.0

for i in range(N-(K-1)):
    if sum(Max) < sum(p[i:i+K:]):
        Max = p[i:i+K:]

for num in Max:
    E += sum(range(num+1))/num

print(E)

Fixed submission:
from collections import deque
import copy
N,K = map(int, input().split())
p = list([(i+1)* i/2/i for i in map(int, input().split())])
que = deque([0]* K)
sumM = 0
sumq = 0
E = 0.0

for i in range(N):
    sumq -= que.popleft()
    sumq += p[i]
    que.append(p[i])
    if E < sumq:
        E = sumq
print(E)
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
for i in range(K):
    H.pop()
print(sum(H))


Fixed submission:
N,K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
for i in range(K):
    H.pop()
    if len(H) == 0:
        break
print(sum(H))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N, D, A = map(int, input().split())
XH = [0]*N
count = 0
for i in range(N):
    XH[i] = list(map(int, input().split()))
XH.sort()
XHd = deque(XH)
while len(XHd) > 0:
    if XHd[0][1] > 0:
        for i in range(len(XHd)):
            if XHd[i][0] <= XHd[0][0] + 2* D:
                XHd[i][1] -= A
        count += 1
    else:
        XHd.popleft()
print(count)

Fixed submission:
from math import ceil
from collections import deque
count = 0
ans = 0

N, D, A = map(int, input().split())
Monster = [0]*N
for i in range(N):
    Monster[i] = list(map(int, input().split()))
Monster = [[x, ceil(h/A)] for x, h in Monster]
Monster.sort()
que = deque([])

for x,h in Monster:
    # 範囲外となったダメージを削除する
    while que and x > que[0][0]:
        a, b = que.popleft()
        count -= b
    # 範囲内で既に起きたダメージを受ける
    need = max(0, h-count)
    ans += need
    count += need
    # 爆発が届く限界と起きた回数を記録しておく
    que.append([x + 2*D, need])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, D, A = map(int, input().split())
XH = [0]*N
count = 0
delL = []
for i in range(N):
    XH[i] = list(map(int, input().split()))
XH.sort()
while len(XH) > 0:
    if XH[0][1] > 0:
        for i in range(len(XH)):
            if XH[i][0] <= XH[0][0] + 2* D:
                XH[i][1] -= A
        count += 1
    else:
        XH = XH[1::]
print(count)

Fixed submission:
from math import ceil
from collections import deque
count = 0
ans = 0

N, D, A = map(int, input().split())
Monster = [0]*N
for i in range(N):
    Monster[i] = list(map(int, input().split()))
Monster = [[x, ceil(h/A)] for x, h in Monster]
Monster.sort()
que = deque([])

for x,h in Monster:
    # 範囲外となったダメージを削除する
    while que and x > que[0][0]:
        a, b = que.popleft()
        count -= b
    # 範囲内で既に起きたダメージを受ける
    need = max(0, h-count)
    ans += need
    count += need
    # 爆発が届く限界と起きた回数を記録しておく
    que.append([x + 2*D, need])
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
for i in range(N-2):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        ans += 1
print(ans)

Fixed submission:
k,x = map(int,input().split())

if k*500 >= x:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
for i in range(N):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        ans += 1
print(ans)

Fixed submission:
N = int(input())
S = input()
ans = 0
for i in range(N-2):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
N,M = map(int,input().split())
a = list(map(int,input().split()))

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(a)
print((M+lcm//2)//lcm)

Fixed submission:
from fractions import gcd
from functools import reduce
N,M = map(int,input().split())
a = list(map(int,input().split()))

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(a)
test = a[0]
count = 0
while test%2 ==0:
    test = test//2
    count += 1
for i in range(N):
    if (a[i]//2**count)%2 == 0:
        print(0)
        exit()
print((M+lcm//2)//lcm)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()
memo = [""]*N
ans = 0
for i in range(N):
    if i >= K:
        if T[i] == "r":
            if memo[i-K] == "p":
                memo[i] = T[i+K]
            else:
                memo[i] = "p"
                ans += P
        elif T[i] == "s":
            if memo[i-K] == "r":
                memo[i] = T[i+K]
            else:
                memo[i] = "r"
                ans += R
        else:
            if memo[i-K] == "s":
                memo[i] = T[i+K]
            else:
                memo[i] = "s"
                ans += S
    else:
        if T[i] == "r":
            memo[i] = "p"
            ans += P
        elif T[i] == "s":
            memo[i] = "r"
            ans += R
        else:
            memo[i] = "s"
            ans += S
print(ans)



Fixed submission:
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()
memo = [""]*N
ans = 0
for i in range(N):
    if i >= K:
        if T[i] == "r":
            if memo[i-K] == "p":
                if i+K <= N-1:
                    memo[i] = T[i+K]
            else:
                memo[i] = "p"
                ans += P
        elif T[i] == "s":
            if memo[i-K] == "r":
                if i+K <= N-1:
                    memo[i] = T[i+K]
            else:
                memo[i] = "r"
                ans += R
        else:
            if memo[i-K] == "s":
                if i+K <= N-1:
                    memo[i] = T[i+K]
            else:
                memo[i] = "s"
                ans += S
    else:
        if T[i] == "r":
            memo[i] = "p"
            ans += P
        elif T[i] == "s":
            memo[i] = "r"
            ans += R
        else:
            memo[i] = "s"
            ans += S
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
count = 0
k = 1
for i in range(N):
    if a[0] != k:
        a.pop(0)
        count += 1
    else:
        a.pop(0)
        k += 1
if k == 1:
    print(-1)
else:
    print(count)



Fixed submission:
from collections import deque
N = int(input())
a = list(map(int,input().split()))
a = deque(a)
count = 0
k = 1
for i in range(N):
    if a[0] != k:
        a.popleft()
        count += 1
    else:
        a.popleft()
        k += 1
if k == 1:
    print(-1)
else:
    print(count)
Buggy python submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
keta = 0
for i in range(1,24):
    cx = x - b*(i)
    if cx < a*(10**(i-1)):
        keta = i-1
        break
if keta == 0:
    print(0)
elif keta >= 10:
    t = len(cx//a)
    print(10**9)
else:
    cx = x - keta*b
    if cx//a >= 10**9:
        print(10**9)
    else:
        if len(cx//a) > keta:
            print(10**(keta)-1)
        else:
            print(cx//a)

Fixed submission:
S = input()
l = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
print(7-l.index(S))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

# 因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a = prime_factorize(N)
if len(a) == 1:
    print(N-1)
else:
    minAns = float('inf')
    for i in range(1 << len(a)):
        x = 1
        y = 1
        for j in range(len(a)):
            if (i >> j) & 1 == 1:
                x *= a[j]
            else:
                y *= a[j]
        if x-1 + y-1 < minAns:
            minAns = x-1 + y-1
    print(minAns)



Fixed submission:
import math
N = int(input())
ans = float('inf')
for i in range(1,math.ceil(math.sqrt(N)+1)):
    if N % i == 0:
        j = N//i
        if ans > i+j-2:
            ans = i+j-2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
count = 0
for a in range(N):
    for b in range(a+1, N):
        Ll = L[b+1:N]
        la = L[a]
        lb = L[b]
        ab = la + lb
        sa = abs(la-lb)
        first = bisect.bisect_left(Ll, ab) -1 
        second = bisect.bisect_right(Ll, sa)
        count += first - second +1
print(count)




Fixed submission:
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
count = 0
total = []
for a in range(N-2):
    for b in range(a+1, N-1):
        la = L[a]
        lb = L[b]
        ab = la + lb
        sa = abs(la-lb)
        first = bisect.bisect_left(L, ab) -1 
        second = bisect.bisect_right(L, sa)
        if first > second and first >= b+1:
            count += first - max(second, b+1) +1
print(count)
Buggy python submission (verdict: Runtime Error):
import math
import collections
A,B = map(int,input().split())
GCD = math.gcd(A,B)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

Bunkai = factorization(GCD) 
print(len(Bunkai) + 1)





Fixed submission:
import fractions
A,B = map(int,input().split())
GCD = fractions.gcd(A,B)
if GCD == 1:
    print(1)
    exit()
    
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

Bunkai = factorization(GCD) 
print(len(Bunkai) + 1)
Buggy python submission (verdict: Runtime Error):
 N = int(input())
print(N*(N-1)//2)

Fixed submission:
N = int(input())
print(N*(N-1)//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(N):
    ans += i
print(ans)

Fixed submission:
N = int(input())
print(N*(N-1)//2)
Buggy python submission (verdict: Runtime Error):
import math
A, B , C , D = map(int, input().split())

bc = B // C 
bd = B // D
bcd = B // (C*D//math.gcd(C, D))
ans = B- (bc + bd - bcd)
ac = (A-1) // C
ad = (A-1) // D
acd = (A-1) //(C*D//math.gcd(C, D))
ans2=  A-1 - (ac + ad - acd)
ans = ans - ans2
print(ans)

Fixed submission:
import fractions
A, B , C , D = map(int, input().split())

bc = B // C 
bd = B // D
bcd = B // (C*D//fractions.gcd(C, D))
ans = B- (bc + bd - bcd)
ac = (A-1) // C
ad = (A-1) // D
acd = (A-1) //(C*D//fractions.gcd(C, D))
ans2=  A-1 - (ac + ad - acd)
ans = ans - ans2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A, B , C , D = map(int, input().split())
count= 0
for i in range(A, B+1):
    if i % C != 0 :
        if i % D != 0:
            count += 1
print(count)


Fixed submission:
import fractions
A, B , C , D = map(int, input().split())

bc = B // C 
bd = B // D
bcd = B // (C*D//fractions.gcd(C, D))
ans = B- (bc + bd - bcd)
ac = (A-1) // C
ad = (A-1) // D
acd = (A-1) //(C*D//fractions.gcd(C, D))
ans2=  A-1 - (ac + ad - acd)
ans = ans - ans2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A, B , C , D = map(int, input().split())
count= 0
for i in range(A, B+1):
    if i % C != 0 and i % D != 0:
         count += 1
print(count)


Fixed submission:
import fractions
A, B , C , D = map(int, input().split())

bc = B // C 
bd = B // D
bcd = B // (C*D//fractions.gcd(C, D))
ans = B- (bc + bd - bcd)
ac = (A-1) // C
ad = (A-1) // D
acd = (A-1) //(C*D//fractions.gcd(C, D))
ans2=  A-1 - (ac + ad - acd)
ans = ans - ans2
print(ans)
Buggy python submission (verdict: Runtime Error):
N,W = map(int,input().split())

v = [0] * N
w = [0] * N
for i in range(N):
    w[i],v[i] = map(int,input().split())

dp = [[0] * (W+1) for _ in range(N)]

for i in range(N):
    for j in range(1, W+1):
        if w[i] > j:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j],v[i]+dp[i-1][j-w[i]])

print(max(dp[N-1]))

Fixed submission:
N,W = map(int,input().split())

v = [0] * N
w = [0] * N
for i in range(N):
    w[i],v[i] = map(int,input().split())
sumv = sum(v)+1
dp = [[float('inf')] * (sumv) for _ in range(N+1)]
for i in range(N):
    dp[i][0] = 0
for i in range(1, N+1):
    for j in range(1, sumv):
        if v[i-1] > j:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(dp[i-1][j],w[i-1]+dp[i-1][j-v[i-1]])
ans = 0
for i in range(1, sumv+1):
    if dp[N][-i] <= W:
        ans = sumv - i
        break
print(ans)