Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def nap(n, gsbA, gsbB):
    dp = [0] * (n + 1)
    for i in range(1, n + 1):
        tmp = dp[i - 1] + 1
        for mA, mB in zip(gsbA, gsbB):
            if i - mA >= 0:
                tmp = max(tmp, mB + dp[i - mA])
        dp[i] = tmp
    return dp[n]

def main():
    N = II()
    gsbA = LI()
    gsbB = LI()
    ans = nap(N, gsbA, gsbB)
    ans = nap(ans, gsbB, gsbA)
    return ans

print(main())

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def get(n, rates):
    rates.sort()
    r0, a0, b0 = rates[0]
    r1, a1, b1 = rates[1]
    r2, a2, b2 = rates[2]
    if r0 >= 1:
        return n
    if r1 >= 1 or a0 == a1 == a2 or r0 == r1 == r2:
        return (n % a0) + (n // a0) * b0
    if r2 >= 1 or r1 == r2 or a1 == a2 or r0 == r1 or a0 == a1 or a0 == a2:
        if r0 == r1 or a0 == a1:
            r1, a1, b1 = r2, a2, b2
        ret = n
        for m0 in range(n // a0 + 1):
            rem = n - m0 * a0
            d = rem % a1
            tmp = d + m0 * b0 + (rem // a1) * b1
            ret = max(ret, tmp)
        return ret
    ret = n
    for m0 in range(n // a0 + 1):
        d0 = m0 * b0
        rem = n - m0 * a0
        for m1 in range(rem // a1 + 1):
            n2 = rem - m1 * a1
            d = n2 % a2
            tmp = d + d0 + m1 * b1 + (n2 // a2) * b2
            ret = max(ret, tmp)
    return ret

def main():
    N = II()
    ga, sa, ba = LI()
    gb, sb, bb = LI()
    rates = [[ga / gb, ga, gb], [sa / sb, sa, sb], [ba / bb, ba, bb]]
    rates2 = [[gb / ga, gb, ga], [sb / sa, sb, sa], [bb / ba, bb, ba]]
    ans = N
    ans = get(ans, rates)
    ans = get(ans, rates2)
    return ans

print(main())
### BUGGY CODE ###

import numpy as np

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]

# インデックスはライフ 値はそれを以下にする最小MP
dp = [np.inf for i in range(H+1)]
dp[0] = 0

for i in range(1, H+1):
    quietus_MP = np.inf
    for j in AB:
        if i-j[0] >= 0:
            dp[i] = min(dp[i-j[0]]+j[1], dp[i])
        # 一回で倒せて一番MP使わない魔法
        if j[0] > i:
            quietus_MP = min(j[1], quietus_MP)
    # 一回で倒す場合
    dp[i] = min(quietus_MP, dp[i])

print(dp[-1])

### FIXED CODE ###

import numpy as np

H, N = map(int, input().split())
AB = np.array([list(map(int, input().split())) for i in range(N)])
A = AB[:, 0]
B = AB[:, 1]

# インデックスはライフ 値はそれを以下にする最小MP
dp = np.array([10**10 for i in range(H+1)], dtype=int)
# dp = np.array([np.inf for i in range(H+1)], dtype=int)
dp[0] = 0

for i in range(1, H+1):
    # print(np.maximum(i-A, 0))
    dp[i] = min(dp[np.maximum(i-A, 0)] + B)

print(dp[-1])
### BUGGY CODE ###

#7  Integer Cards
n,m = map(int,input().split())
a = list( map(int,input().split()))
bc=[[0]*2 for _ in range(m)]
for i in range(m):
    bc[i] = list(map(int,input().split()))

a.sort()
bc.sort(reverse=True,key=lambda x:x[1])

import bisect
ans=[]
for (bb,cc) in bc:
    idx = bisect.bisect(a,cc)
    n_replace = min(idx,bb)
    ans.extend([cc]*n_replace)
    a=a[n_replace:]
    
print(sum(ans)+sum(a))


### FIXED CODE ###

n,m=map(int,input().split())
a = list(map(int, input().split()))
bc=[list(map(int,input().split())) for _ in range(m)]
#print(bc)
bc=sorted(bc,key= lambda x:x[1],reverse=True)
#print(bc)

bc2=[]
for i in range(m):
    bc2.extend([bc[i][1]]*bc[i][0])
    if len(bc2)>n: break
#print(bc2)
a.extend(bc2)
a.sort(reverse=True)

print(sum(a[:n]))
### BUGGY CODE ###

from collections import Counter
n = int(input())
A = list(map(int, input().split()))
c = Counter(A)
s_A = set(A)
d = {}
for a in s_A:
    tmp = 0
    for item in c.items():
        if item[0] == a:
            if item[1] > 1:
                    tmp += int((c[a] - 1 ) * (c[a] - 2) / 2)
            continue
        if item[1] > 1:
            tmp += int(item[1] * (item[1] - 1) / 2)
    d[a] = tmp

for a in A:
    print(d[a])

### FIXED CODE ###

from collections import Counter
n = int(input())
A = list(map(int, input().split()))
c = Counter(A)
sum = 0
for v in c.values():
    sum += int(v*(v-1)/2)

for i in A:
    print(sum - (c[i] - 1))
### BUGGY CODE ###

import sys
if __name__ == '__main__':
    lines = sys.stdin.readlines()
    line = [a.strip('\n').split(' ') for a in lines]
    for i,v in enumerate(line):
        if i == 0:
            n = int(v[0])
            p = v[1]
        else:
            numbers = list(v[0])
            # print(numbers)

    count = 0
    leng = len(list(p))
    p = int(p)

    numbers_int = [int(i) for i in numbers]

    map_ = dict()
    a = 10 % p
    for i in set(numbers_int):
        c = i% p
        for j in range(n):
            map_[i,j] = c
            c = c *a


    count = 0
    for i in range(n):
        for j in range(i,n):
            tar = numbers_int[i:j+1]
            # print(tar)
            leng = len(tar)
            su = 0 
            for k,v in enumerate(tar):
                su += map_[v,leng - k -1]
                # print(v, leng - k)
                # print(map_[1,1])
            if su % p == 0:
                count += 1
                # print(tar)

    print(count)

### FIXED CODE ###

from collections import Counter

N, P = map(int, input().split())
S = input()

c = 0

if P == 2 or P == 5:
    for i,v in enumerate(S):
        if int(v) % P == 0:
            c += (i+1)

else:
    T = [0]*(N+1)
    d = 1
    for i,v in enumerate(S[::-1]):
        a = (int(v) * d + T[i])% P
        T[i+1] = a
        d *= 10
        d %= P
    count = Counter(T)

    c = sum(x * (x -1) / 2 for x in count.values())

print(int(c))
### BUGGY CODE ###

# -*- coding: utf-8 -*-


def calc_dist(s, start_i, start_j, goal_i, goal_j, h, w):
    from collections import deque

    result = 0
    d = deque()
    d.append((start_i, start_j))
    dist = [[0 for _ in range(w)] for _ in range(h)]
    visited = [[False for _ in range(w)] for _ in range(h)]
    visited[start_i][start_j] = True
    dxy = [(1, 0), (-1, 0), (0, -1), (0, 1)]

    while d:
        hd, wd = d.popleft()

        for dx, dy in dxy:
            nx = wd + dx
            ny = hd + dy

            if nx < 0 or nx >= w or ny < 0 or ny >= h:
                continue

            if s[ny][nx] == '#':
                continue

            if visited[ny][nx]:
                continue

            visited[ny][nx] = True
            dist[ny][nx] = dist[hd][wd] + 1
            d.append((ny, nx))
            result = max(result, dist[ny][nx])

            if nx == goal_j and ny == goal_i:
                return result

    return result


def main():
    h, w = map(int, input().split())
    s = [list(input()) for _ in range(h)]
    ans = 0

    for start_i in range(h):
        for start_j in range(w):
            for goal_i in range(h):
                for goal_j in range(w):
                    if s[start_i][start_j] == '#':
                        continue

                    if s[goal_i][goal_j] == '#':
                        continue

                    ans = max(ans, calc_dist(s, start_i, start_j, goal_i, goal_j, h, w))

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-


def calc_dist(s, start_i, start_j, h, w):
    from collections import deque

    result = 0
    d = deque()
    d.append((start_i, start_j))
    dist = [[0 for _ in range(w)] for _ in range(h)]
    visited = [[False for _ in range(w)] for _ in range(h)]
    visited[start_i][start_j] = True
    dxy = [(1, 0), (-1, 0), (0, -1), (0, 1)]

    while d:
        hd, wd = d.popleft()

        for dx, dy in dxy:
            nx = wd + dx
            ny = hd + dy

            if nx < 0 or nx >= w or ny < 0 or ny >= h:
                continue

            if s[ny][nx] == '#':
                continue

            if visited[ny][nx]:
                continue

            visited[ny][nx] = True
            dist[ny][nx] = dist[hd][wd] + 1
            d.append((ny, nx))
            result = max(result, dist[ny][nx])

    return result


def main():
    h, w = map(int, input().split())
    s = [list(input()) for _ in range(h)]
    ans = 0

    # KeyInsight
    # 始点のみを全探索(終点は全探索する必要はない)
    # 距離はBFSで計算
    for start_i in range(h):
        for start_j in range(w):
            if s[start_i][start_j] == '#':
                continue

            ans = max(ans, calc_dist(s, start_i, start_j, h, w))

    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import bisect
import collections
from collections import defaultdict
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 32


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


n, m, s, t = list(map(int, input().split()))

MAX_VAL = 10 ** 20
uvab = llmi(m)
jpy_cost = defaultdict(dict)
snuke_cost = defaultdict(dict)


def dijkstra2_scipy(adj, start, n=None, limit=None):
    """
    caution!  add 10**-10 to avoid 0 cost
    """
    from scipy.sparse import csr_matrix
    from scipy.sparse.csgraph._shortest_path import dijkstra
    if limit:
        limit += 0.5
    cost, row_ind, col_ind = [], [], []
    for k1, _v in adj.items():
        for k2, _cost in _v.items():
            row_ind.append(k1)
            col_ind.append(k2)
            cost.append(_cost + 10 ** -10)
    cost_matrix = csr_matrix((cost, (row_ind, col_ind)))
    return dijkstra(cost_matrix, indices=[start])[0]


for u, v, a, b in uvab:
    u = u - 1
    v = v - 1
    jpy_cost[u][v] = a
    jpy_cost[v][u] = a
    snuke_cost[u][v] = b
    snuke_cost[v][u] = b

jpy_dijk = dijkstra2_scipy(jpy_cost, start=s - 1)
snuke_dijk = dijkstra2_scipy(snuke_cost, start=t - 1)
res = []
min_val = MAX_VAL
for i in reversed(range(n)):
    # 都市  i で両替
    val = jpy_dijk[i] + snuke_dijk[i]
    assert val < MAX_VAL
    min_val = min(min_val, val)
    res.append(min_val)
for x in reversed(res):
    print(10 ** 15 - int(x))


### FIXED CODE ###

from collections import defaultdict
from heapq import heapify, heappop
import heapq
n,m,s,t =list(map(int,input().split()))

MAX_VAL = 10**20
uvab =  [list(map(int,input().split())) for _ in range(m)]
jpy_cost = defaultdict(dict)
snuke_cost = defaultdict(dict)


for u,v,a,b in uvab:
    u=u-1
    v=v-1
    jpy_cost[u][v] = a
    jpy_cost[v][u] =a
    snuke_cost[u][v]=b
    snuke_cost[v][u]=b


# Dijktra's shortest path algorithm. Prints the path from source to target.


def dijkstra(adj, source):
    INF = MAX_VAL
    dist = [INF for x in range(n)]
    dist[source] = 0
    PQ = []
    heapq.heappush(PQ, [dist[source], source])

    while (PQ):
        u_dist,u_id = heapq.heappop(PQ)  # u is a tuple [u_dist, u_id]
        if u_dist == dist[u_id]:
            for v in adj[u_id]:
                w_uv = adj[u_id][v]
                if dist[u_id] + w_uv < dist[v]:
                    dist[v] = dist[u_id] + w_uv
                    heapq.heappush(PQ, [dist[v], v])
    return dist


jpy_dijk =  dijkstra(jpy_cost,s-1)
snuke_dijk = dijkstra(snuke_cost,t-1)
#
# print(s,t)
# print(jpy_dijk)
# print(snuke_dijk)
# print([jpy_dijk[i]+snuke_dijk[i] for i in range(n)])

#ord n
res = []
min_val = MAX_VAL
for i in reversed(range(n)):
    #都市  i で両替
    val = jpy_dijk[i]+ snuke_dijk[i]
    assert val < MAX_VAL
    min_val=min(min_val,val)
    res.append(min_val)
#ord n
for x in reversed(res):
    print(10**15-  x)
### BUGGY CODE ###

x,k,d=map(int,input().split())
ans=x
for i in range(k):
  if abs(ans-d)<abs(ans+d):
    ans=abs(ans-d)
  elif abs(ans-d)>abs(ans+d):
    ans=abs(ans+d)
  else:
    if (k-i)%2==1:
      ans=d
    break
print(ans)

### FIXED CODE ###

x,k,d=map(int,input().split())
x=abs(x)
sa=x//d
ans=x
pbk,mbk=0,0
bk1,bk2,bk3=1,1,1
mansbk,pansbk=0,0
if sa>=k:
  ans=x-d*k
else:
  ans=x-d*sa
  k=k-sa
  for i in range(k):
    mansbk=abs(ans-d)
    pansbk=abs(ans+d)
    if mansbk!=pansbk:
      ans=min(mansbk,pansbk)
      if bk3!=1:
        bk1=min(mansbk,pansbk)
        bk2=max(mansbk,pansbk)
        ans=mbk if (k-i)%2==0 else bk1
        break
      else:
        bk3=max(mansbk,pansbk) 
    else:
      ans=0 if (k-i)%2==0 else d
      break
    pbk=max(mansbk,pansbk)
    mbk=min(mansbk,pansbk)
print(ans)
### BUGGY CODE ###

char = ['M', 'A', 'R', 'C', 'H']

n = int(input())
s = [input() for _ in range(n)]
s = [i[0] for i in s if i[0] in char]

# print(s)

from itertools import permutations, combinations,combinations_with_replacement,product

c = list(combinations(s,3))

ans = 0

for i in c:
    if i[0] != i[1] and i[0] != i[2] and i[1] != i[2]:
        ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
S = [0] * 5
for _ in range(N):
  s = input()
  if s[0] == "M": S[0] += 1
  elif s[0] == "A": S[1] += 1
  elif s[0] == "R": S[2] += 1
  elif s[0] == "C": S[3] += 1
  elif s[0] == "H": S[4] += 1
 
import itertools
ans = 0
for v in itertools.combinations(S, 3):
  ans +=  v[0] * v[1] * v[2]
print(ans)
### BUGGY CODE ###

h,w=map(int,input().split())
nx,ny=map(int,input().split())
gx,gy=map(int,input().split())
maze=[input()for i in range(h)]
from heapq import heapify, heappop, heappush
seen=set()
gx-=1;gy-=1

hq=[(0,nx-1,ny-1)]
while hq:
    c,x,y=heappop(hq)
    if w*x +y in seen:continue
    seen.add(w*x +y)
    if x==gx and y==gy:print(c);exit()
    if x and w*(x-1)+y not in seen and maze[x-1 ][y]!="#":
        heappush(hq,(c,x-1,y))
    if y and w*x+y-1 not in seen and maze[x][y-1]!="#":
        heappush(hq,(c,x,y-1))
    if x+1<h  and w*(x+1)+y not in seen and maze[x+1][y]!="#":
        heappush(hq,(c,x+1,y))
    if y+1<w  and w*x+y+1 not in seen and maze[x][y+1]!="#":
        heappush(hq,(c,x,y+1))
    for i in range(max(0,x-2),min(h,x+3)):
        for j in range(max(0,y-2),min(w,y+3)):
            if i==x and j==y:continue
            if maze[i][j]=="."and w*i + j not in seen:
                heappush(hq,(c+1,i,j))

print(-1)

### FIXED CODE ###

import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
h,w=map(int,input().split())
nx,ny=map(int,input().split())
gx,gy=map(int,input().split())
maze=[input()for i in range(h)]
from heapq import heapify, heappop, heappush
seen=set()
gx-=1;gy-=1
SIZE=h*w
hq=[(nx-1)*w+ny-1]
while hq:
    d=heappop(hq)
    c,d=divmod(d,SIZE)
    x,y=divmod(d,w)
    if w*x +y in seen:continue
    seen.add(w*x +y)
    if x==gx and y==gy:print(c);exit()
    if x and w*(x-1)+y not in seen and maze[x-1 ][y]!=35:
        heappush(hq,(c*SIZE+w*(x-1)+y))
    if y and w*x+y-1 not in seen and maze[x][y-1]!=35:
        heappush(hq,(c*SIZE+w*x+y-1))
    if x+1<h  and w*(x+1)+y not in seen and maze[x+1][y]!=35:
        heappush(hq,(c*SIZE+w*(x+1)+y))
    if y+1<w  and w*x+y+1 not in seen and maze[x][y+1]!=35:
        heappush(hq,(c*SIZE+w*x+y+1))
    for i in range(max(0,x-2),min(h,x+3)):
        for j in range(max(0,y-2),min(w,y+3)):
            if i==x and j==y:continue
            if maze[i][j]==46 and w*i + j not in seen:
                heappush(hq,(c+1)*SIZE+w*i+j)

print(-1)
### BUGGY CODE ###

N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
mod=998244353
S=sum(A)

dp=[0 for j in range(S+1)]
sub=[0 for j in range(S+1)]
dp[0]=pow(2,N,mod)
dp[A[0]]=pow(2,N-1,mod)
sub[0]=1
sub[A[0]]=1

for i in range(1,N):
    for j in range(S,-1,-1):
        dp[j]=(dp[j]+pow(2,mod-2,mod)*(j>=A[i])*dp[j-A[i]])%mod
        sub[j]=(sub[j]+(j>=A[i])*sub[j-A[i]])%mod

if S%2==1:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[i]
        ans%=mod
    print(ans)
else:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[i]
        ans%=mod
    ans+=3*sub[S//2]
    ans%=mod
    print(ans)

### FIXED CODE ###

N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
mod=998244353
inv=pow(2,mod-2,mod)
S=sum(A)

dp=[0 for j in range(S+1)]
sub=[0 for j in range(S+1)]
dp[0]=pow(2,N,mod)
dp[A[0]]=pow(2,N-1,mod)
sub[0]=1
sub[A[0]]=1

for i in range(1,N):
    for j in range(S,A[i]-1,-1):
        dp[j]=(dp[j]+inv*dp[j-A[i]])%mod
        sub[j]=(sub[j]+sub[j-A[i]])%mod

if S%2==1:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[i]
        ans%=mod
    print(ans)
else:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[i]
        ans%=mod
    ans+=3*sub[S//2]
    ans%=mod
    print(ans)
### BUGGY CODE ###

N=int(input())
S=input()

# 全ての組み合わせ数
allcnt = S.count("R") * S.count("G") * S.count("B")

# 除外するものチェック
rem = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    k = j + (j - i)
    if k >= N:
      continue
    if len(set([S[i],S[j],S[k]])) == 3:
      rem += 1
print(allcnt - rem)


### FIXED CODE ###

N=int(input())
S=input()

# 全ての組み合わせ数
allcnt = S.count("R") * S.count("G") * S.count("B")

# 除外するものチェック
rem = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    k = j + (j - i)
    if k >= N:
      break
    if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
      rem += 1
print(allcnt - rem)
### BUGGY CODE ###

H,W = map(int, input().split())
black,white = [],[]

for h in range(H):
    a = input()
    for w in range(W):
        if a[w]=="#":
            black.append((h,w))
        else:
            white.append((h,w))

ans = 0
for wh,ww in white:
    tmp = float("inf")
    for bh,bw in black:
        if tmp > abs(wh-bh) + abs(ww-bw):
            tmp =  abs(wh-bh) + abs(ww-bw)
    ans = max(ans, tmp)
print(ans)


### FIXED CODE ###

from collections import deque

H,W = map(int, input().split())
maze = [input() for _ in range(H)]
visited = [[False]*W for _ in range(H)]
q = deque([])

# initialize
for h in range(H):
    for w in range(W):
        if maze[h][w] == "#":
            q.append((h,w,0))
            visited[h][w] = True

ans = 0
while q:
    h,w,d = q.popleft()
    for dy,dx in zip([0,0,-1,1], [-1,1,0,0]):
        nh, nw = h+dy, w+dx
        if not(0<=nh<H and 0<=nw<W):
            continue
        if not visited[nh][nw]:
            q.append((nh,nw,d+1))
            visited[nh][nw] = True
            ans = max(ans, d+1)

print(ans)
### BUGGY CODE ###

n = int(raw_input())
ax = []
bx = []
for _ in xrange(n):
    a,b = map(int,raw_input().split())
    ax.append(a)
    bx.append(b)

ax.reverse()
bx.reverse()
cnt = 0
for i in xrange(n):
    if ax[i] % bx[i] !=0:
        cnt += bx[i] - (ax[i] % bx[i])
        k = bx[i] - (ax[i] % bx[i])
        ax = map(lambda x:x+k,ax)

print cnt


### FIXED CODE ###

n = int(raw_input())
ax = []
bx = []
for _ in xrange(n):
    a,b = map(int,raw_input().split())
    ax.append(a)
    bx.append(b)

ax = ax[::-1]
bx = bx[::-1]
cnt = 0
for i in xrange(n):
    if (ax[i] + cnt) % bx[i] !=0:
        k = bx[i] - ((ax[i] + cnt) % bx[i])
        cnt += k

print cnt
### BUGGY CODE ###

n=int(input())
c=input()
list=[0 for i in range(n+1)]
for i in range(n+1):
  if i>0 and i<n:
    r=c.count('R',i,)
    w=c.count('W',0,i)
  if i==0:
    r=c.count('R',i,)
    w=0
  if i==n:
    r=0
    w=c.count('W')


  if r<=w:
    list[i]=w
  else:
    list[i]=r
print(min(list))

### 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))
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N):
    for j in range(N):
        if i==j:
            continue
        if A[i]%A[j]==0:
            break
    else:
        ans+=1
print(ans)

### FIXED CODE ###

from collections import Counter
N=int(input())
A=sorted(list(map(int,input().split())))
c=Counter(A)
if 1 in A:
    if c[1]==1:
        print(1)
    else:
        print(0)
    exit()
n=max(A)
ans=[0]*(n+1)
for k,v in c.items():
    if v==1:
        ans[k]=1
for i in c.keys():
    t=i*2
    while t<=n:
        ans[t]=0
        t+=i
print(sum(ans))
### BUGGY CODE ###

l=input().split()
n=int(l[0])
W=int(l[1])
lweight=[]
lvalue=[]
for i in range(n):
	l=input().split()
	u=int(l[0])
	v=int(l[1])
	lweight.append(u)
	lvalue.append(v)
dp=[[0 for i in range(W+1)] for i in range(n+1)]
for i in range(n+1):
	dp[i][0]=0
for j in range(W+1):
	dp[0][j]=0
for i in range(1,n+1):
	for j in range(1,W+1):
		if(j>=lweight[i-1]):
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-lweight[i-1]]+lvalue[i-1])
		else:
			dp[i][j]=dp[i-1][j]
print(dp[n][W])


### FIXED CODE ###

#dp[i][j] denotes min weight if possible to obtain value j from first i items
l=input().split()
n=int(l[0])
W=int(l[1])
lweight=[]
lvalue=[]
for i in range(n):
	l=input().split()
	u=int(l[0])
	v=int(l[1])
	lweight.append(u)
	lvalue.append(v)
k=sum(lvalue)
dp=[[-1 for i in range(k+1)] for i in range(n+1)]
for i in range(n+1):
	dp[i][0]=0
for i in range(1,n+1):
	for j in range(1,k+1):
		if(dp[i-1][j]>-1):
			dp[i][j]=dp[i-1][j]
			if(j>=lvalue[i-1] and dp[i-1][j-lvalue[i-1]]!=-1):
				dp[i][j]=min(dp[i][j],dp[i-1][j-lvalue[i-1]]+lweight[i-1])
		elif(j>=lvalue[i-1] and dp[i-1][j-lvalue[i-1]]!=-1):
			dp[i][j]=dp[i-1][j-lvalue[i-1]]+lweight[i-1]
		else:
			dp[i][j]=-1
maxa=0
for i in range(n+1):
	for j in range(k+1):
		if(dp[i][j]!=-1 and dp[i][j]<=W):
			if(j>maxa):
				maxa=j
print(maxa)