peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N = int(input())
A = int(input())

total = N

for i in range(1, 10000):
    if total - 500*i == 0:
        print('Yes')
        break
    elif total - 500*i < 0:
        total = total - 500*(i - 1)
        break

        
if total - A > 0:
    print('No')
else:
    for j in range(A):
        total = total - 1
        if total == 0:
            print('Yes')
            break
# Judge status: Wrong Answer
N = int(input())

if N >= 189:
  print(3)
elif 189 > N >= 135:
  print(2)
elif 135 > N >= 105:
  print(1)
else:
  print(0)
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
x = 100
count1 = 0
for i in a:
    count1 += (i - x)**2

for X in range(-100, 100):
    count = 0
    for i in a:
        count += (i - X)**2
    if count < count1:
        count1 = count

print(count1)
# Judge status: Accepted
n=int(input())
name=""
for i in range(15):
  n=n-1
  name=name+chr(97+n%26)
  n=n//26
  if n==0:
    break
print(name[::-1])
# Judge status: Accepted
n,m,k = map(int,input().split())
for i in range(n+1):
  for j in range(m+1):
    if i*m+j*n-2*i*j == k:
      print("Yes")
      exit()
print("No")
# Judge status: Accepted
N,L = map(int,input().split())

S = []
for i in range(N):
    S.append(input())

sorted_S = sorted(S)

print(*sorted_S,sep='')
# Judge status: Wrong Answer
N = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(0, N - 1):
    if p[i + 1] != i + 2:
        count += 1

print("NO") if count > 2 else print("YES")
# Judge status: Wrong Answer
N = int(input())

# print(Decimal(N) // Decimal(3))
print(round(N//3, 12))
# Judge status: Accepted
n,k = map(int, input().split())
cnt=0

while(n>=1):
    n /= k
    cnt += 1
print(cnt)
# Judge status: Accepted
import sys
input = sys.stdin.readline
r,g,b = [int(i) for i in input().split()]
d = 10 * g + b
if d % 4 == 0 :
    print("YES")
else :
    print("NO")
# Judge status: Accepted
a, b = map(int, input().split())
if a == b:
    print('Draw')
elif a == 1:
    print('Alice')
elif b == 1:
    print('Bob')
elif a < b:
    print('Bob')
else:
    print('Alice')
# Judge status: Wrong Answer
import bisect
n,*a=map(int,open(0).read().split())
a=sorted(a)
m=a[-1]
l=bisect.bisect_left(a,(m+1)//2)
r=bisect.bisect_right(a,(m+1)//2)
if abs(2*a[l]-1-m)<=abs(2*a[r]-1-m):
  k=a[l]
else:
  k=a[r]
if len(a)==2:
  k=a[0]
print(m,k)
# Judge status: Wrong Answer
h = int(input())
w = int(input())
n = int(input())

cell_cnt=0
x=0

for x in range(h):
	cell_cnt+=w
	if cell_cnt>=n:
		break
print(x+1)
# Judge status: Wrong Answer
N = int(input())
K = int(input())

X = int(input())
Y = int(input())

print(N*X + (N-K)*Y)
# Judge status: Accepted
import math

K = int(input())
ans = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += math.gcd(math.gcd(i,j),k)

print(ans)
# Judge status: Accepted
import itertools
import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
L = list(map(list,list(itertools.permutations(list(i for i in range(1,N+1)),N))))
a = L.index(P)
b = L.index(Q)
print(abs(a-b))
# Judge status: Wrong Answer
if __name__ == "__main__":
    a, b, k = map(int, input().split())

    output = dict()

    for i in range(k):
        if a<= a+i <= b:
            output[a+i] = a+i
    
    for i in range(-k+1,1):
        if a<= b+i <= b:
            output[b+i] = b+i
    
    for o in output.keys():
        print(o)
# Judge status: Accepted
N,M = map(int, input().split())
H = list(map(int, input().split()))
L = []
for i in range(M):
  a, b = map(int, input().split())
  if H[a-1] > H[b-1]:
    L.append(b-1)
  elif H[a-1] < H[b-1]:
    L.append(a-1)
  else:
    L.append(a-1)
    L.append(b-1)
print(N - len(set(L)))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
a2 = [i*i for i in a]
S = int((sum(a) * sum(a) - sum(a2))/2)
print(int(S % (1000000007)))
# Judge status: Wrong Answer
n,h=map(int,input().split())
X=[]
for i in range(n):
    a,b=map(int,input().split())
    X.append([a,-b])
    
X.sort(key=lambda x:x[0],reverse=True)

Y=X[1:]
Y.sort(key=lambda x:x[1],reverse=True)

cnt=0

for i in range(n-1):
    if Y[i][1]<=X[0][1]:
        h+=Y[i][1]
        cnt+=1
        if h<=0:
            break

if h>0:
    h+=X[0][1]
    cnt+=1
    if h>0:
        cnt+=h//X[0][0]
print(cnt)
# Judge status: Accepted
o = input()
e = input()
ans = ''
for i in range(len(e)):
  ans += o[i]+e[i]
print(ans if len(o)==len(e) else ans+o[-1])
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
A = map( lambda x:x//400, A)
A = list(map( lambda x:x if x<8 else 8, A))
cnt8 = A.count(8)
A = list(set(A))
if 8 in A:
    A.remove(8)
sum = len(A)
if sum == 0:
    print(1, end=' ')
else:
    print(sum, end=' ')
sum += cnt8
print(sum)
# Judge status: Accepted
L,R,d = map(int, input().split())
a = 0
for i in range(L,R+1):
  if(i%d==0):
    a+=1
print(a)
# Judge status: Accepted
a=int(input())
a%=1000
if a==0:
    print(0)
else:
    print(1000-a)
# Judge status: Wrong Answer
S = input()

print(S[-1])
if S[-1] == 's':
    print(S + 'es')
else:
    print(S + 's')
# Judge status: Accepted
N,M,K=map(int,input().split())
F=False

for x in range(N+1):
    for y in range(M+1):
        F|=(x*(M-y)+y*(N-x)==K)

if F:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,m = map(int,input().split())
hwd = list(map(int,input().split()))
s = sum(hwd)
print(n-s) if n >= s else print(-1)
# Judge status: Accepted
import sys

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if v <= w:
    print('NO')
    sys.exit()

time = abs((a-b)/(v-w))

if t<time:
    print('NO')
else:
    print('YES')
# Judge status: Accepted
a, b, x = map(int, input().split())
if a <= x < a+b:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
s = list(input())
# print(s)

if s[0] != s[1] and s[1] != s[2] and s[2] !=s [3]:
    print('Good')
else:
    print('Bad')
# Judge status: Accepted
d = 25 - int(input())
s = 'Christmas'
for i in range(d):
    s += ' Eve'
print(s)
# Judge status: Accepted
n = int(input().rstrip())
cnt = 0
flg = False
d_list = [[0, 0] for i in range(n)]
for i in range(n):
  d_list[i] = list(map(int, input().rstrip().split(" ")))
for ds in d_list:
  if ds[0] == ds[1]:
    cnt += 1
  else:
    cnt = 0
  if cnt >= 3:
    flg = True
    break
if flg:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
S = list(input())
#%%
ans= 0
for i in range(1,N):
    set1 = set()
    set2 = set()
    
    for s in S[:i]:
        set1.add(s)
    for s in S[i:]:
        set2.add(s)
    
    sets = set1 & set2
    ans = max(ans,len(list(sets)))

print(ans)
# Judge status: Wrong Answer
W=list(map(int,input().split()))
ne=0
if 0 in W:
  print("Zero")
  exit()
else:
  for i in range(len(W)):
    if W[i]<0:
      ne+=1
  if ne%2==0:
    print("Positive")
  else:
    print("Negative")
# Judge status: Accepted
a=int(input())
s=str(input())

if a>=3200:
    print(s)
else:
    print("red")
# Judge status: Wrong Answer
a, b = map(int, input().split())

if a or b > 8:
    print('Yay!')
else:
    print(':(')
# Judge status: Accepted
s = input()
alpha = ["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"]
if s in alpha:
    print("a")
else:
    print("A")
# Judge status: Accepted
N = int(input())

S = [input() for i in range(N)]

print(len(set(S)))
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Cs = list(input())
from collections import deque
Q = deque()
for i, c in enumerate(Cs):
    if c=='R':
        Q.append(i)

ans = 0
for i in range(N):
    c = Cs[i]
    if c=='W':
        if not Q:
            break
        r = Q.pop()
        if r>i:
            ans += 1
        else:
            break
print(ans)
# Judge status: Accepted
import math
N=int(input())
a=list(map(int,input().split()))
ans=0

for i in range(N):
    if (i%2==0)and(a[i]%2!=0):
        ans+=1
        #print(i,end='=>')
        #print(a[i])

print(ans)
# Judge status: Accepted
N = input().strip()
k = len(N)
cmax = 0
for i in range(k):
    cmax += int(N[i])
if k>1:
    cnt = (int(N[0])-1)+9*(k-1)
    cmax = max(cmax,cnt)
print(cmax)
# Judge status: Wrong Answer
a = input().split()
q = int(a[0]) * 4
h = int(a[1]) * 2
s = int(a[2])
d = int(a[3]) / 2
b = int(input())

if min([q,h,s,d]) != d:
  print(int(b * min([q,h,s])))
else:
  if b % 2 == 0:
    print(int(b * d))
  elif b != 1:
    print(int((b-1) * d) + min([q,h,s]))
  else:
    print(min([q,h,s]))
# Judge status: Wrong Answer
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if (a-b)>=(c-a):
  print("B")
else:
  print("A")
# Judge status: Wrong Answer
n, k = map(int,input().split())
count = 1
origk = k
while(True):
    if n <= k:
        print(count)
        break
    k *= origk
    count+=1
# Judge status: Accepted
D=int(input())
c=list(map(int,input().split()))
s=[]
t=[]
for i in range(D):
  s.append(list(map(int,input().split())))
l=[0]*26

max=0
target=0
deg=0
#初期t生成
for d in range(D):
  degsum=0
  max=0
  for i in range(26):
    degsum+=c[i]*(d-l[i])
  for i in range(26):
    w=degsum-c[i]*(d-l[i])-s[d][i]
    if max < -w:
      max=-w
      target=i
  t.append(target+1)
  l[target]=d

for i in range(D):
  print(t[i])
# Judge status: Accepted
def main():
    n = int(input())
    A = list(map(int, input().split()))

    res_list = [0] * 100001

    for num in A:
        res_list[num] += 1
        
        if num != 0:
            res_list[num-1] += 1
        if num != 10**5:
            res_list[num+1] += 1
    
    print(max(res_list))

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
flg = None #正
cur = a_ls[0]
cnt = 1
for a in a_ls[1:]:
    if a > cur:
        if flg is None:
            flg = True
        if not flg:
            flg = None
            cnt += 1
    if a < cur:
        if flg is None:
            flg = False
        if flg:
            cnt += 1
            flg = None
    cur = a
print(cnt)
# Judge status: Accepted
N = int (input())
print (int (N * (N+1) / 2 ) )
# Judge status: Accepted
a,b,c,x,y=map(int,input().split())

mi=min([x,y])
ma=max([x,y])
g=ma-mi
ans,ab=0,0


if 2*c <= a+b:
  if x>=y:
    ans+=2*c*y + (x-y)*a
    ab=2*c*x
  else:
    ans+=2*c*x + (y-x)*b
    ab=2*c*y
else:
  ans+=a*x+b*y

if ab >= ans: 
  print(ans)
else:
  if ab!=0:
    print(ab)
  else:
    print(ans)
# Judge status: Accepted
A, B = map(int, input().split())
print('IMPOSSIBLE' if abs(A-B) % 2 != 0 else int(min(A, B) + (abs(A-B) / 2)))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
m=int(sum(a)/n+0.5)
print(sum((i-m)**2 for i in a))
# Judge status: Accepted
A=int(input())
B=int(input())
C=int(input())
X=int(input())


count=0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        count+=1

print(count)
# Judge status: Accepted
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
    num = 0
    ans = float('inf')
    for j in range(m):
        man = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if man < ans :
            ans = man
            num = j
    print(num+1)
# Judge status: Wrong Answer
n=input()
for i in range(len(n)):
    if i ==9:
        print('Yes')
        break
print('No')
# Judge status: Accepted
W,a,b = list(map(int,input().split()))
if a+W <= b:
    print(b-(a+W))
elif b+W <= a:
    print(a-(b+W))
else:
    print(0)
# Judge status: Wrong Answer
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

a, b, c = MAP()
print("Yes" if a**0.5+b**0.5<c**0.5 else "No")
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))
    result = sum([(a - max(A))**2 for a in A])
    for i in range(min(A), max(A)):
        tmp = sum([(i - a)**2 for a in A])
        if result > tmp:
            result = tmp

    print(result)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n,*l=map(int,open(0).read().split())
from heapq import *
l.sort()
q=[-l.pop()]
a=0
for _ in range(n-1):
  m=heappop(q)
  a-=m
  t=-l.pop()
  heappush(q,t)
  heappush(q,t)
print(a)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
D = {}
for i in A:
  if i in D:
    D[i] += 1
  else:
    D[i] = 1
p = 0
for i in D:
  if D[i] >= i:
    p += i - D[i]
  else:
    p += D[i]
print(p)
# Judge status: Wrong Answer
N = input()
A = input().split()
A = [int(x) for x in A]
Q = int(input())
BC = []
for i in range(Q):
    bc = input().split()
    bc = [int(x) for x in bc]
    BC.append(bc)


for j in range(len(BC)):
    for k in range(len(A)):
        if A[k] == BC[j][0]:
            A[k] = BC[j][1]
    total = sum(A)
    print(A)
# Judge status: Accepted
n, k, s = map(int, input().split())

a = [s]*n

ans = ""

for i in range(n-k):
    if s == 1:
        a[i] = 2
    elif s == 1000000000:
        a[i] = 1000000000-1
    else:
        a[i] = s+1

for i in range(n):
    ans += " " + str(a[i])

print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
if a == b: print('Draw')
elif a == 1: print('Alice')
elif b == 1: print('Bob')
elif a > b: print('Alice')
elif a < b: print('Bob')
# Judge status: Wrong Answer
def main():
    l, r, d=map(int, input().split())
    # c=0
    # for i in range(l,r+1):
        # if not i%d:
            # c+=1
    # print(c)
    print((r-l+1)//d)


if __name__=='__main__':
    main()
# Judge status: Wrong Answer
N,K,Q =map(int,input().split())
M = [K-Q]*N

for q in range(Q):
  a = int(input())
  M[a-1]+=1
  
print(M)

for m in M:
  if m<=0:
    print("No")
  else:
    print("Yes")
# Judge status: Accepted
x,y,z=map(int,input().split())
ans=(x-z)//(y+z)
print(ans)
# Judge status: Accepted
N = int(input())
k = 0
ans = 0
while N >= ans:
    k += 1
    ans = k * (k+1) / 2

num = int(k * (k+1) / 2 - N)
for i in range(1,k+1):
    if i != num:
        print(i)
# Judge status: Accepted
N, R = list(map(int, input().split()))
if N >= 10:
    print(R)
else:
    print(R + 100 * (10 - N))
# Judge status: Wrong Answer
n = int(input())
res = 0
upper = 1e6
i = 2
lst = set()
if n < 2:
   print(res)
   exit()
while i <= upper:
   if n % i == 0 and i not in lst:
      n = n // i
      upper = min(upper, n)
      lst.add(i)
      res += 1
   i += 1
if upper == 1e6:
   res += 1

print(res)
# Judge status: Accepted
N=input()
N=int(N)
S=[0]*N
for i in range(N):
    S[i]=input()

M=input()
M=int(M)
T=[0]*M
for i in range(M):
    T[i]=input()

A=[]
for i in S:
    A.append(S.count(i)-T.count(i))

print(max(0,max(A)))
# Judge status: Wrong Answer
s=input()
t=input()
s_array=[]
t_array=[]
for i in range(len(s)):
  s_array.append(s[i])
for i in range(len(t)):
  t_array.append(t[i])

s_array=sorted(s_array)

t_array=sorted(t_array,reverse=True)
for i in range(min([len(s_array),len(t_array)])):
  if s_array[i]<t_array[i]:
    print('Yes')
    exit()
  elif s_array[i]>t_array[i]:
    print('No')
    exit()
print('No')
# Judge status: Accepted
S = input()
T = input()
result = 0

for i in range(len(S)):
    if S[i] != T[i]:
        result += 1

print(result)
# Judge status: Accepted
a, b, c = map(int, input().split())
a, b , c =  c , a, b
print(a, b, c )
# Judge status: Accepted
N = int(input())
h = list(map(int, input().split()))

#dp[i]:i番目に到達するまでにはらうコストの最小値

dp = [0 for i in range(N)]
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N):
    cost_1 = dp[i-1] + abs(h[i]-h[i-1])
    cost_2 = dp[i-2] + abs(h[i]-h[i-2])
    dp[i] = min(cost_1, cost_2)

print(dp[N-1])
# Judge status: Accepted
import fractions
#from functools import reduce
N,*a=map(int,open(0).read().split())
L=[]
L_base=a[0]
b=a[:]
b.reverse()
R=[]
R_base=b[0]
for i in range(N-1):
    L_base=fractions.gcd(L_base,a[i])
    L.append(L_base)
    R_base=fractions.gcd(R_base,b[i])
    R.append(R_base)
LR=[R[-1]]
for i in range(N-2):
    LR.append(fractions.gcd(L[i],R[-2-i]))
LR.append(L[-1])
print(max(LR))
# Judge status: Accepted
S = input()
print('No' if ('A' in S) == False or ('B' in S) == False else 'Yes')
# Judge status: Accepted
from fractions import gcd
a,b,c,d=map(int,input().split())
e=c*d//gcd(c,d)#最小公倍数
sm=(b//c-(a-1)//c)+(b//d-(a-1)//d)-(b//e-(a-1)//e)
print(int(b-a+1-sm))
# Judge status: Accepted
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(readline().rstrip().decode("utf-8"))
S = readline().rstrip().decode("utf-8")

ans = 0
for i in range(N-1):
    left = S[:i+1] 
    right = S[i+1:]
    # print("left: {} right: {}".format(left, right))

    tmp = len(set(left) & set(right))
    ans = max(tmp, ans)
print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int, input().split()))

flag=True
if a[0]!=0:
    flag=False
top_list=[1]
bot_list=[a[-1]]

for i in range(n):
    top_list.append((top_list[i]-a[i])*2)
# print(top_list)

for i in range(1,n+1):
    bot_list.append(bot_list[i-1]+a[n-i])
bot_list.reverse()
# print(bot_list)

total=0
for i in range(n+1):
    if top_list[i]<=0 or bot_list[i]<=0:
        flag=False
    total+=min(top_list[i],bot_list[i])

print(total if flag else -1)
# Judge status: Wrong Answer
N = int(input())
A =[i for i in input().split()]
A = sorted(A,reverse=True)
Alice = 0
Bob = 0
while len(A) != 0:
    Alice += int(A.pop(0))
    if len(A) == 0:
        break
    else:
        Bob += int(A.pop(0))
print(Alice - Bob)
# Judge status: Accepted
N, X, Y = map(int, input().split())
X, Y = X-1, Y-1
ans = {i:0 for i in range(1, N)}

for i in range(N-1):
    for j in range(i+1, N):
        d = min(j-i, abs(X-i)+1+abs(Y-j))
        ans[d] += 1
        
for _, v in ans.items():
    print(v)
# Judge status: Wrong Answer
import math
n,d = map(int,input().split())
c = 0

for i in range (n):
  a,b = map(int,input().split())
  if math.sqrt(abs(a*a) +abs(b *b)) >=d:
    c+=1

print(c)
# Judge status: Wrong Answer
S = list(input())

count = 0
buffer = 'R'
for s in S:
    if s == 'R' and buffer == 'R':
        count += 1
    elif s == 'S':
        buffer = 'S'
print(count)
# Judge status: Accepted
#ABC071

s = sorted(set(input()))
l = "abcdefghijklmnopqrstuvwxyz"
for i in l:
    
    if i not in s:
        print(i)
        break
        
else:
    print("None")
    
    
## if i in s == False はうまくいかない
##in/not inを使う
# Judge status: Wrong Answer
a,b,c = map(int,input().split())

res = (c-a-b)**2 - a*b 

if res > 0 :
  print('Yes')
  
else:
  print('No')
# Judge status: Wrong Answer
S = input()
if int(S[5:7]) <= 4:
	print("TBD")
else:
	print("Heisei")
# Judge status: Accepted
K,X = map(int,input().split())
for i in range(X-K+1,X+K):
    print(i, end= ' ')
# Judge status: Wrong Answer
print("bust" if sum(map(int, input().split())) > 22 else "win" )
# Judge status: Wrong Answer
n = int(input())
if n <= 999:
  print('ABC'+str(n))
else:
  print('ABD'+str(n-999))
# Judge status: Accepted
k,a,b = map(int,input().split())
ans = 1
if b-a<2:
    ans += k
else:
    if k-(a-1)>0:
        k = k-(a-1)
        if k%2==0:ans = k//2*(b-a)+a
        else: ans = k//2*(b-a)+a+1
    else:
        ans += k
print(ans)
# Judge status: Wrong Answer
def main():

    k, n = map(int,input().split())
    a = list(map(int,input().split()))

    mx = 0
    cnt = 0
    for i in range(1,n):
        tmp = a[i] - a[i - 1]
        if tmp > mx:
            mx = tmp
        cnt += tmp
    tmp = k - a[-1]
    if tmp > mx :
        mx = tmp
    cnt = cnt + tmp - mx
    print(cnt)



if __name__ =='__main__':
    main()
# Judge status: Accepted
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N, M = map(int, input().split())

divisors = make_divisors(M)
ans = 0
for d in divisors:
    if N*d <= M:
        ans = d

print(ans)
# Judge status: Accepted
N, W = map(int, input().split())
v = []
w = []
for i in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)
dp = [ [0 for i in range(W+1)] for j in range(N+1)]
for i in range(1,N+1):
    for j in range(1,W+1):
        if w[i-1] <= j:
            dp[i][j] = max(v[i-1] + dp[i-1][j-w[i-1]], dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
print(dp[N][W])
# Judge status: Wrong Answer
N = int(input())

if N % 2 == 0:
  print(N/2)
else:
  print(N//2 +1)
# Judge status: Wrong Answer
from functools import reduce
def resolver(N, A):
    X = reduce(int.__xor__, A)
    ans = [X^a for a in A]
    
    return ans

def test():
    pass

def main():

    #test()

    N = int(input())
    A = list(map(int, input().split()))
    ans = resolver(N, A)

    print(ans)



if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
S = list(input())
ans = 0
cnt = 0
for s in S:
    if s in ['A','C','G','T']:
        cnt += 1
    else:
        ans = max(ans,cnt)
        cnt = 0
print(ans)
# Judge status: Accepted
N = int(input())
s = list(map(int, input().split()))
cond = True
for i in s:
  if i%2 == 0:
    if i%3 == 0 or i%5 == 0:
      continue
    else:
      cond = False
      break
if cond is True:
  print("APPROVED")
else:
  print("DENIED")
# Judge status: Wrong Answer
import math
a, b, n = map(int, input().split())

base = math.floor(1 / b)
if b >= n:
    ans = math.floor(a*n/b) - a*math.floor(n/b)
else:
    num = b - 1
    ans = math.floor(a*num/b) - a*math.floor(num/b)
print(ans)
# Judge status: Wrong Answer
n=int(input())
x=[]
for i in range(5):
  x.append(int(input()))
print(5+(n//min(x)))
# Judge status: Accepted
import sys
w = input()

count_list = [w.count(i) for i in w]
count_list = list(set(count_list))

print('Yes' if all( i % 2 == 0 for i in count_list) else 'No')
# Judge status: Accepted
H, W = map(int, input().split())

ans = 0
x = H * W

if H == 1 or W == 1:
    ans = 1
elif x % 2 == 0:
    ans = x // 2
else:
    ans = (x // 2) + 1

print(ans)
# Judge status: Accepted
w,h,x,y=map(int,input().split())
a=w/2
b=h/2
s=w*h/2
cnt=0
if x==a and y==b:
    cnt=1
print(s,cnt)
# Judge status: Wrong Answer
N,L = map(int,input().split())
M = []
for i in range(N):
    M.append(input())
print(M)
M = sorted(M)

print(''.join(M))
# Judge status: Accepted
S = int(input())

L = [0] * (S + 10)
L[3] = 1
e = 10 ** 9 + 7

for i in range(4, S + 1):
    L[i] += 1
    for j in range(3, i):
        if i - j <= 0:
            break
        L[i] += L[i - j]
        L[i] = L[i] % e

print(L[S])
# Judge status: Accepted
# coding: utf-8
K = int(input())
S = input()

if len(S) <= K:
    print(S)
else:
    print(S[:K] + '...')
# Judge status: Wrong Answer
a, b = map(int, input().split())

if a > b:
  print("Alice")
elif a < b:
  print("Bob")
else:
  print("Draw")
# Judge status: Accepted
n=int(input())
def nums(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return nums(num//26-1)+chr(90)
    else:
        return nums(num//26)+chr(64+num%26)
      
print(nums(n).lower())
# Judge status: Wrong Answer
s = list(input())
t = list(input())
n = len(s)
flag = 0
ans = "YNeos"
for i in range(n):
  if s[i] != t[i]:
    flag += 1
print(ans[::2]) if flag % 2 == 0 else print(ans[1::2])
# Judge status: Wrong Answer
def I(): return int(input())
x = I()
div,mod = divmod(x,11)
print(div*2+(1 if mod<=6 else 2))
# Judge status: Wrong Answer
S = input()
wait_day = 0

if S == "SUN":
  wait_day = 6
elif S == "MON":
  wait_day = 6
elif S == "TUE":
  wait_day = 5
elif S == "WED":
  wait_day = 4
elif S == "THU":
  wait_day = 3
elif S == "FRI":
  wait_day = 2
elif S == "SAT":
  wait_day = 1

print(wait_day)