Harryxun/stf_run huggingface dataset:
N,Wmax=map(int,input().split(' '))
W=[]
V=[]
for _ in range(N):
	w,v = map(int,input().split(' '))
	W.append(w)
	V.append(v)

Vmax=sum(V)

#dp[i][v]=i番目の品物までだけを選び価値の合計をvとしたときの必要な重量の最小値

dp = []
for _ in range(N):
	dp.append([None]*(Vmax+1))

dp[0][V[0]+1] = W[0]

for i in range(1,N):
	#新しく積めるようになる荷物の価値をV[i]とする
	#このとき価値の合計をvにするのに必要な重量の最小値は
	#	dp[i-1][v-V[i]]+W[i] と
	# dp[i-1][v] のうち小さいほう
	for v in range(Vmax+1):
		if v-V[i]<0:
			dp[i][v] = dp[i-1][v]
		else:
			if dp[i-1][v]:
				if dp[i-1][v-V[i]]:
					dp[i][v] = min(dp[i-1][v],dp[i-1][v-V[i]]+W[i])
				else:
					dp[i][v] = dp[i-1][v]
			else:
				if dp[i-1][v-V[i]]:
					dp[i][v] = dp[i-1][v-V[i]]+W[i]

ans = 0
for v in range(Vmax+1):
	try:
		ans = v if dp[-1][v]<=Wmax else ans
	except TypeError:
		pass

print(ans)


### FIXED CODE ###

N,Wmax=map(int,input().split(' '))
W=[]
V=[]
for _ in range(N):
	w,v = map(int,input().split(' '))
	W.append(w)
	V.append(v)

Vmax=sum(V)

# dp[i][v]=i番目の品物までだけを選び価値の合計をvとしたときの必要な重量の最小値
# ただしそのような価値の合計が実現不可能なときはNoneを格納

dp = []
for _ in range(N):
	dp.append([None]*(Vmax+1))

dp[0][0] = 0
dp[0][V[0]] = W[0]

for i in range(1,N):
	# 新しく積めるようになる荷物の価値をV[i]とする
	# このとき価値の合計をvにするのに必要な重量の最小値は
	#	  dp[i-1][v-V[i]]+W[i] と
	#   dp[i-1][v] のうち小さいほう
	for v in range(Vmax+1):
		if v-V[i]<0:
			dp[i][v] = dp[i-1][v]
		else:
			if dp[i-1][v] is not None:
				if dp[i-1][v-V[i]] is not None:
					dp[i][v] = min(dp[i-1][v],dp[i-1][v-V[i]]+W[i])
				else:
					dp[i][v] = dp[i-1][v]
			else:
				if dp[i-1][v-V[i]] is not None:
					dp[i][v] = dp[i-1][v-V[i]]+W[i]

ans = 0
for v in range(Vmax+1):
	try:
		ans = v if dp[-1][v]<=Wmax else ans
	except TypeError:
		pass

print(ans)
K = int(input())

def get_next_lun(before_number,keta):  

  if keta == 1: #終了条件を忘れない
      if before_number == 9:
        return [8,9]
      if before_number == 0:
        return [1,2]
      else:
        return [before_number-1,before_number,before_number+1]
  else:
      if before_number == 9:
        for i in get_next_lun(before_number,keta-1):
        return []
      if before_number == 0:
        return []
      else:
        return [before_number-1,before_number,before_number+1]
      
      return 


### FIXED CODE ###

#161d
import math
import copy

K = int(input())

keta = 1
lunlun_numbers_list = [1,2,3,4,5,6,7,8,9]
lunlun_numbers_numer = 9

if K <=9:
    print(lunlun_numbers_list[K-1])
else:
    while 1:
        new_lunlun_numbers_list = list()
        for lower_keta in lunlun_numbers_list:
            ketasu = int(math.log10(lower_keta)//1 + 1)

            if lower_keta>=10:
                last_keta = lower_keta - ((lower_keta//10) * 10)
            else:
                last_keta = lower_keta

            #print(lower_keta,ketasu,last_keta)

            if last_keta !=0: 
                new_lunlun_numbers_list.append(lower_keta*10 + last_keta - 1)
            
            new_lunlun_numbers_list.append(lower_keta*10 + last_keta)

            if last_keta !=9:
                new_lunlun_numbers_list.append(lower_keta*10 + last_keta + 1)

        if len(new_lunlun_numbers_list)+lunlun_numbers_numer >= K:
            new_lunlun_numbers_list.sort(reverse=False)
            print(new_lunlun_numbers_list[K-lunlun_numbers_numer-1])
            #print(new_lunlun_numbers_list)
            break
        else:
            lunlun_numbers_numer+=len(new_lunlun_numbers_list)

        lunlun_numbers_list = copy.copy(new_lunlun_numbers_list)
n = input()

def kuriage(x):
    if x == "":
        return "1"
    elif x[-1] != "9":
        return x[:-1] + str(int(x[-1]) + 1)
    else:
        return kuriage(x[:-1])


ans = 0

while n != "":
    m = int(n[-1])
    if m <= 5:
        ans += m
        n = n[:-1]
    else:
        ans += 10 - m
        n = kuriage(n[:-1])

print(ans)

### FIXED CODE ###

n = input()

dp1 = [0] * (len(n) + 1)
dp2 = [1] * (len(n) + 1)

for i in range(1, len(n) + 1):
    m = int(n[i - 1])
    dp1[i] = min(dp1[i - 1] + m, dp2[i - 1] + 10 - m)
    dp2[i] = min(dp1[i - 1] + m + 1, dp2[i - 1] + 9 - m)

print(dp1[-1])
n = int(input())
bol = 0
for i in range(1,10):
  for j in range(1:10):
    if i*j == n:
      bol = 1
      break
if bol == 1:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = int(input())
bol = 0
for i in range(1,10):
  for j in range(1,10):
    if i*j == n:
      bol = 1
      break
if bol == 1:
  print("Yes")
else:
  print("No")
n=int(input())
c=input()
count=0

for i in range(n):
  if c[i]=='W':
    #print('when W in',i)
    s=c[i:]
    num=s.find('R')
    if num<0:
      break
    num+=i
    #print('when num ',num)
    t=c[num:]
    num_ch=t.find('W')
    if num_ch<0:
      num_ch=n-num   
    #print(num_ch)
    num_ch+=num
    
    #print('when num_ch',num_ch)
    if num-i-1<=num_ch-num:
      #print('間が小さいので塗り替える')
      for j in range(i,num):
        #print(j)
        c=c[:j]+'R'+c[j+1:]
        count+=1
    else:
      #print('間が大きいので交換する')
      for j in range(num,num_ch):
        #print(j)
        c=c[:j]+'W'+c[j+1:]
        c[i+j-num]='R'
        count+=1
#print(c)
print(count)


### FIXED CODE ###

n=int(input())
c=input()
list=[0 for i in range(n+1)]
r=0
for i in range(n):
  if c[i]=='R':
    r+=1
w=0
list[0]=max(r,w)

#i corresponds to the right side boundary of c[i]
for i in range(n):
  if c[i]=='W':
    w+=1
  if c[i]=='R':
    r-=1
  list[i+1]=max(r,w)
print(min(list))
import math
R=int(input())
print(2*math.pi*r)

### FIXED CODE ###

import math
r=int(input())
print(2*r*math.pi)
N, A, B, C, D = list(map(int, input().split()))

S = input()

# 以下indexに変更
A-=1
B-=1
C-=1
D-=1

L = [1]*N

# 0を岩、1を通路とする
for i in range(N):
    if S[i] == '#':
        L[i] =  0


def search(idx, g, reversed_goal):
    L[idx] =0
    if reversed_goal:
        if idx == g:
            if L[idx-1] and L[idx+1]:
                return True
                
            return False
    else:
        if idx == g:
            return True 

    if reversed_goal and L[idx+2] and L[idx+1]:
        L[idx] =1
        L[idx+1] = 0
        return True


    if idx+2 <= g and L[idx+2]:
        L[idx] = 1
        return search(idx+2, g, reversed_goal)
    
    if idx+1 <= g and L[idx+1]:
        L[idx] = 1
        return search(idx+1, g, reversed_goal)
    
    return False

def main():
    reversed_goal = C > D
    if not reversed_goal:
        if search(B,D,False):
            if search(A,C,False):
                return 'Yes'
            
        return 'No'

    else:
        if search(B,D,True):
            if search(A,C,False):
                return 'Yes'

        return 'No'

ans = main()
print(ans)



### FIXED CODE ###

if __name__ == '__main__':
    N, A, B, C, D = map(int, input().split())
    S = str(input())
 
    answer = "-1"
 
    if C < D:
       if S[A:D:].count("##") >= 1:
           answer = "No"
       else:
           answer = "Yes"
    else:
       if S[B-2:D+1:].count("...") >= 1:
           answer = "Yes"
       else:
           answer = "No"
 
    print(answer)
import stdin from sys
n = int(stdin.readline().rstrip())
li = [int(stdin.readline().rstrip()) for _ in range(5)]
m = min(li)
if n % m == 0:
    print(n//m + 4)
else:
    print(n//m + 5)


### FIXED CODE ###

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
m = min(a,b,c,d,e)
if n % m == 0:
    print(n//m + 4)
else:
    print(n//m + 5)
n = input()
x = 1
ans = 0
while 1:
  if x > n:
     break
  if ( x % 3 == 0 ) or ( '3' in str(x) ):
     ans = ans + str(x)
  x += 1
print ans

### FIXED CODE ###

n = input()
ans = '' 
for i in range(3,n+1):
    if i%3 == 0 or '3' in str(i):
        ans += ' ' + str(i)
print ans
N = int(input())
S = set(map(int, input().split()))

print('Three' if len(S) == 3 else 'Four')


### FIXED CODE ###

N = int(input())
S = set(input().split())

print('Three' if len(S) == 3 else 'Four')
import numpy as np

A = np.array(list(list(map(int, input().split())) for l in range(3)))
N = int(input())
b = np.array(list(int(input()) for l in range(N)))
bingo = np.zeros((3, 3))
bingo = bingo == 1

for b_i in b:
    hantei = A == b_i
    bingo = np.logical_or(bingo, hantei)

for i in range(3):
    if all(bingo[i]) or all(bingo[:,i]):
        print('Yes')
        exit()

if (bingo[0,0] and bingo[1,1] and bingo[2,2]) or (bingo[0,2] and bingo[1,1] and bingo[3,1]):
    print('Yes')
    exit()

print('No')

### FIXED CODE ###

import numpy as np

A = np.array(list(list(map(int, input().split())) for l in range(3)))
N = int(input())
b = np.array(list(int(input()) for l in range(N)))
bingo = np.zeros((3, 3))
bingo = bingo == 1

for b_i in b:
    hantei = A == b_i
    bingo = np.logical_or(bingo, hantei)

for i in range(3):
    if all(bingo[i]) or all(bingo[:,i]):
        print('Yes')
        exit()

if (bingo[0,0] and bingo[1,1] and bingo[2,2]) or (bingo[0,2] and bingo[1,1] and bingo[2,0]):
    print('Yes')
    exit()

print('No')
n = int(input())
s = str(input())
k = int(input())
wordn = ""
w = s[k-1]
for i in s:
    if w != i:
        word += "*"
    else:
        word += w
print(word)

### FIXED CODE ###

n = int(input())
s = str(input())
k = int(input())
word = ""
w = s[k-1]
for i in s:
    if w != i:
        word += "*"
    else:
        word += w
print(word)
def main():
    n =int( input())
    sn=[]
    for i in range(n):
        
        inWord = str(input())
        addFlag = True
        for s in sn:
            if s["word"] == inWord and len(sn) !=0:
                s["count"]+=1
                addFlag = False
                break
        if addFlag ==True:
            sn.append( {"word":inWord,"count":1})
        
    a= sorted(sn, reverse=True,key=lambda x:x['count'])
    most = a[0]["count"]

    mostWords=[]
    for elm in a:
        if elm["count"] == most:
            mostWords.append(elm["word"])
        
    mostWords.sort()
    for elm in mostWords:
        print(elm)
    return
main()



### FIXED CODE ###

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

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

else:
    print("No")
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))


S, T = input().split()
A, B = MI()
U = input()
if U == S:
    S -= 1
elif U == T:
    B -= 1
print(A, B)

### FIXED CODE ###

def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))


S, T = input().split()
A, B = MI()
U = input()
if U == S:
    A -= 1
elif U == T:
    B -= 1
print(A, B)
N,K=map(int,input().split())
x=list(map(int,input().split()))

#ゼロに最も近い正負の要素を含むようにK個の配列を舐める
#全部負または全部正(max*min>=0)ならabs(max-min)
#正負またぐ負場合(max*min<0)、
# min(負の絶対値最大*2+正の最大,負の絶対値最大+正の最大*2)

#符号切り替わりサーチ
for i in range(N):
    if x[i]>=0:
        pos_start=i
        break

#K個の配列をスライド
ans=2*(max(x)-min(x))   #ans init. 考えられる最大プラスアルファ?
for i in range(K+1):
    start=pos_start-K+i
    end=pos_start+i
    #print('search start,end ',start,end)
    if start>=0 and end<=N:
        #print('start,end ',start,end)
        obj_arr=x[start:end]
        M=max(obj_arr)
        m=min(obj_arr)
        if M*m>=0:
            ans=min(ans,max(abs(M),abs(m)))
        else:
            ans=min(ans,min(abs(m)*2+M,abs(m)+M*2))
print(ans)


### FIXED CODE ###

N,K=map(int,input().split())
x=list(map(int,input().split()))

# min( 左端に到達し右へ, 右端に到達し左へ)
ans=10**9
for i in range(N-K+1):
    l=abs(x[i])+abs(x[i]-x[i+K-1])
    r=abs(x[i+K-1])+abs(x[i]-x[i+K-1])
    ans=min(ans,min(l,r))
print(ans)
N, A, B, C=map(int,input().split())2l=[int(input())foriinrange(N)]3INF=10**945defdfs(cur, a, b, c):6ifcur==N:7returnabs(a-A)+abs(b-B)+abs(c-C)-30ifmin(a, b, c)>0elseINF8ret0=dfs(cur+1, a, b, c)9ret1=dfs(cur+1, a+l[cur], b, c)+1010ret2=dfs(cur+1, a, b+l[cur], c)+1011ret3=dfs(cur+1, a, b, c+l[cur])+1012returnmin(ret0, ret1, ret2, ret3)1314print(dfs(0,0,0,0))

### FIXED CODE ###

from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
value=10**10
itelst=[list(permutations(L,i)) for i in range(3,N+1)]
for n in range(N-2):
    for lst in itelst[n]:
        lstsum=sum(lst)
        a=0
        for i1 in range(len(lst)-2):
            a+=lst[i1]
            b=0
            for i2 in range(i1+1,len(lst)-1):
                b+=lst[i2]
                c=lstsum-a-b
                c1,b1,a1=sorted([a,b,c])
                a1=A-a1 if A-a1>0 else a1-A
                b1=B-b1 if B-b1>0 else b1-B
                c1=C-c1 if C-c1>0 else c1-C
                value=min(value, (len(lst)-3)*10 + a1+b1+c1)





print(value)
from collections import defaultdict


def main():
    N, K = map(int, input().split())
    integers = [list(map(int, input().split())) for _ in range(N)]
    # bitwise orの結果の候補を計算
    len_bin_k = len('{:b}'.format(K))
    keys = [K]
    for shift in range(1, len_bin_k + 1):
        if (K >> shift) & 1 == 1:
            # 右からshift bit目が0で、それより右が全部1の数
            # （例）K:1100101、shift:3 => 1100011
            keys.append(((K >> shift) << shift) - 1)
    vals = defaultdict(int)
    for a, b in integers:
        for k in keys:
            # bitwise orの結果を変えない整数の場合は価値を合算
            if k | a == k:
                vals[k] += b
    ans = max(vals.values())
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import defaultdict


def main():
    N, K = map(int, input().split())
    integers = [list(map(int, input().split())) for _ in range(N)]
    # bitwise orの結果の候補を計算
    len_bin_k = len('{:b}'.format(K))
    keys = [K]
    for shift in range(1, len_bin_k + 1):
        if (K >> shift) & 1 == 1:
            # 右からshift bit目が0で、それより右が全部1の数
            # （例）K:1100101、shift:3 => 1100011
            keys.append(((K >> shift) << shift) - 1)
    vals = defaultdict(int)
    for a, b in integers:
        for k in keys:
            # bitwise orの結果を変えない整数の場合は価値を合算
            if k | a == k:
                vals[k] += b
    if len(vals.values()) == 0:
        print(0)
    else:
        print(max(vals.values()))


if __name__ == '__main__':
    main()
import itertools
n,m,q = map(int,input().split())
group = []
for i in range(q):
  w,x,y,z = map(int,input().split())
  v = (w,x,y,z)
  group.append(v)
#groupに(a,b,c,d)がタプルで入っている
max_value = max(group[i][3] for i in range(len(group)))

#Aの配列を試す

l = [i for i in range(1,m+1)]
h = itertools.combinations_with_replacement(l,n)
array =[]

for v in h:
    array.append(v)
#arrayが全ての配列になった


for j in range(len(array)):
  total = 0
  for i in range(q):
    if array[j][group[i][1]-1] - array[j][group[i][0]-1] == group[i][2]:
      total += group[i][3]
  if total >= max_value:
    max_value = total  

print(max_value)

### FIXED CODE ###

k = int(input())
a,b = map(int,input().split())
c =0
for i in range(1,int(b/k)+1):
    if a <= i*k <= b:
        c = 1
        break
if c ==1:
    print('OK')
else:
    print('NG')
S, W = map(int, input().split())
if S =< W:
  print("unsafe")
else:
  print("safe")

### FIXED CODE ###

S, W = map(int, input().split())
if S <= W:
  print("unsafe")
else:
  print("safe")
import math
A,B,C,D = map(int, input().split())

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

ac=int(A/C)
bc=int(B/C)
ad=int(A/D)
bd=int(B/D)
acd=int(A/lcm(C,D))
bcd=int(B/lcm(C,D))

if A%C==0:
    c_div=bc-ac+1
else:
    c_div = bc - ac
if B%C==0:
    d_div=bd-ad+1
else:
    d_div = bd - ad
if B%lcm(C,D)==0:
    cd_div=bcd-acd+1
else:
    cd_div = bcd - acd

print(B-A+1-c_div-d_div+cd_div)

### FIXED CODE ###

from fractions import gcd

A, B, C, D = map(int, input().split())


def division(x, p, q):
    return x - x // p - x // q + x // (p * q // gcd(p, q))


print(division(B, C, D) - division(A - 1, C, D))
a,b,c,d = input()

li1 = [a,b]
li2 = [c,d]

int1 = int(''.join(li1))
int2 = int(''.join(li2))

if (int1 > 12 and int2 > 12):
    ans = 'NA'
elif (int1 == 0 and int2 == 0):
    ans = 'NA'
elif (int1 > 12 and int2 == 0):
    ans = 'NA'
elif (int1 > 12):
    ans = 'YYMM'
elif (int2 > 12 and int1 == 0):
    ans = 'NA'
elif (int2 > 12):
    ans = 'MMYY'
elif:
    ans = 'AMBIGUOUS'

print(ans)


### FIXED CODE ###

a,b,c,d = input()

li1 = [a,b]
li2 = [c,d]

int1 = int(''.join(li1))
int2 = int(''.join(li2))

if (int1 in range(1,13)) and (int2 in range(1,13)):
    ans = 'AMBIGUOUS'
elif (int1 in range(1,13)) and (int2 not in range(1,13)):
    ans = 'MMYY'
elif (int2 in range(1,13)) and (int1 not in range(1,13)):
    ans = 'YYMM'
else:
    ans = 'NA'

print(ans)
text = raw_input("半角英数20文字まで入力: ")
n = len(text)
rev = []
for i in range(n):
    rev.append(text[(n-1)-i])
ans = ''.join(rev)
print ans

### FIXED CODE ###

text = raw_input()
n = len(text)
rev = []
for i in range(n):
    rev.append(text[(n-1)-i])
ans = ''.join(rev)
print ans
import random

T = 26


def read_input():
    D = int(input())
    cs = list(map(int, input().split()))
    ss = [list(map(int, input().split())) for _ in range(D)]
    return D, cs, ss


def greedy(D, cs, ss):
    ts = []
    last = [0] * T
    for d in range(D):
        d_true = d + 1
        diffs = []
        ssc = ss[d]
        for t in range(T):
            s = ssc[t]
            d = s + cs[t] * (d_true - last[t])
            diffs.append((d, t))
        
        dc, tc = max(diffs)
        last[tc] = d_true
        ts.append(tc)
    
    return ts


def evaluate(out, D, c, s):
    sat = 0
    last = [0] * 26
    for d in range(D):
        assert(1 <= out[d] and out[d] <= 26)
        j = out[d] - 1
        last[j] = d + 1
        for i in range(26):
            sat -= (d + 1 - last[i]) * c[i]
        sat += s[d][j]
        
    return sat, max(0, 1000000 + sat)


def anneal(D, cs, ss, ts_init):
    def calc_cs(tds):
        last = 0
        css = 0
        for d in tds:
            css += (d + 1 - last) * (d - last) // 2
            last = d
        css += D - 1 - last
        return css

    ts = ts_init.copy()
    tds = [set() for t in range(26)]
    for d in range(D):
        t = ts[d]
        tds[t].add(d)

    for i in range(10000):
        r = random.random()
        if r < 1:  # flip
            d1, d2 = random.randint(0, D-1), random.randint(0, D-1)
            if d1 == d2 or ts[d1] == ts[d2]:
                continue
            d1, d2 = min(d1, d2), max(d1, d2)
            t1, t2 = ts[d1], ts[d2]
            diff1 = (ss[d2][t1] - ss[d1][t1]) + (ss[d1][t2] - ss[d2][t2])
            tds1_after = tds[t1].copy()
            tds1_after.add(d2)
            tds1_after.remove(d1)
            tds2_after = tds[t2].copy()
            tds2_after.add(d1)
            tds2_after.remove(d2)
            # print(tds1_after)
            # print(tds[t1])
            # print(calc_cs(sorted(tds1_after)))
            # print(calc_cs(sorted(tds[t1])))
            diff2 = cs[t1] * (calc_cs(sorted(tds1_after)) - calc_cs(sorted(tds[t1]))) \
                + cs[t2] * (calc_cs(sorted(tds2_after)) - calc_cs(sorted(tds[t2])))
            diff = diff1 + diff2
            # print(diff1, diff2)
            if diff > 0:
                # print("yead")
                ts[d1], ts[d2] = ts[d2], ts[d1]
                tds[t1] = tds1_after
                tds[t2] = tds2_after
        else:
            pass

        if i % 100 == 0:
            # print(evaluate(inc(ts), D, cs, ss))
    
    return ts


def inc(ts):
    return [t + 1 for t in ts]


def solve(D, cs, ss):
    ts = greedy(D, cs, ss)
    ts = anneal(D, cs, ss, ts)
    ts = inc(ts)
    return ts


if __name__ == "__main__":
    D, cs, ss = read_input()
    ts = solve(D, cs, ss)

    for t in ts:
        print(t)


### FIXED CODE ###

D = int(input())
cs = list(map(int, input().split()))
ss = [list(map(int, input().split())) for _ in range(D)]

ts = []
for i in range(D):
    t = 1
    ts.append(t)

for t in ts:
    print(t)
A=input()
print(3*A**2)

### FIXED CODE ###

r=int(input())
print(3*(r**2))
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if sum(a)+sum(b)<k:
    ans=m+n
else:
    numa=[0]
    numb=[0]
    for i in range(n):
        if numa[-1]+a[i]>k:
            break
        numa.append(numa[-1]+a[i])
    for j in range(m):
        if numb[-1]+b[i]>k:
            break
        numb.append(numb[-1]+b[i])
    n=len(numa)
    m=len(numb)-1
    ans=0
    for i in range(n):
        num1=k-numa[i]
        for j in range(m+1):
            if numb[m]<=num1:
                break
            m-=1
        ans=max(ans,i+m)
print(ans)


### FIXED CODE ###

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if sum(a)+sum(b)<k:
    ans=m+n
else:
    numa=[0]
    numb=[0]
    for i in range(n):
        numa.append(numa[-1]+a[i])
    for j in range(m):
        numb.append(numb[-1]+b[j])
    ans=0
    for i in range(n+1):
        if numa[i]>k:
            break
        while numb[m]>k-numa[i]:
            m-=1
        ans=max(ans,i+m)
print(ans)
a, b = map(int, raw_input().split():)

print a * b ,
print a * 2 + b * 2

### FIXED CODE ###


l = map(int, raw_input().split())
 
print "%d %d" % (l[0]*l[1], (l[0]+l[1])*2)
n = int(input())
h = list(map(int,input().split()))

INF = 10 ** 20

dp = [INF]*(n+1)
dp[0] = dp[1] = 0
dp[2] = h[1]-h[0]
 
coin_list = list(map(int,input().split()))
 
for i in range(3,n+1):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
 
print(dp[n])

### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))

INF = 10 ** 20

dp = [INF]*(n)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
 
for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
 
print(dp[n-1])
import math

a, b = map(int, input().split())

ans = a * b // math.gcd(a, b)

print(ans)

### FIXED CODE ###

import fractions

a, b = map(int, input().split())

ans = a * b // fractions.gcd(a, b)

print(ans)
import sys
import collections
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    n = I()
    mylist = list(MI())
    max_a = max(mylist)
    exlude_list = set()
    tlist = [False] * (max_a+1)
    for a in mylist:
        if tlist[a]:
            exclude_set.add(a)
        else:
            tlist[a] = True
    ans = 0
    
    for i in range(1, max_a//2 + 1):
        if not tlist[i]:
            continue
        else:
            for j in range(2*i, max_a+1, i):
                tlist[j]=False
    for i in range(len(tlist)):
        if tlist[i] and not i in exclue_set:
            ans += 1
    print(ans)
                
    

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import collections
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    n = I()
    mylist = list(MI())
    max_a = max(mylist)
    exclude_set = set()
    tlist = [False] * (max_a+1)
    for a in mylist:
        if tlist[a]:
            exclude_set.add(a)
        else:
            tlist[a] = True
    ans = 0
    
    for i in range(1, max_a//2 + 1):
        if not tlist[i]:
            continue
        else:
            for j in range(2*i, max_a+1, i):
                tlist[j]=False
    for i in range(len(tlist)):
        if tlist[i] and not i in exclude_set:
            ans += 1
    print(ans)
                
    

if __name__ == '__main__':
    main()
A,B=map(int,input().split())
if A<=8 and B<=8:
  print("Yay!")
ekse:
  print(":(")
  

### FIXED CODE ###

A,B=map(int,input().split())
if A>8 or B>8:
  print(":(")
else:
  print("Yay!")