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

A, B, C, D, E, F = map(int, input().split())
max_sugar = E / (100 + E)
res = 0 
ans = [0, 0]
for a in range(F // 100*A + 1): 
        for b in range(F // 100*B + 1): 
                for c in range(int(F * max_sugar) // C + 1):
                        for d in range(int(F * max_sugar) // D + 1): 
                                mass = 100*A*a + 100*B*b + C*c + D*d 
                                sugar = C*c + D*d 
                                if 0 < mass <= F and sugar / mass <= max_sugar:
                                        if res <= sugar / mass:
                                                res = sugar / mass 
                                                ans = [mass, sugar]
                                else:
                                        break
print(str(ans[0]) + " " + str(ans[1]))

### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split())
max_sugar = E / (100 + E)
res = 0 
ans = [0, 0]
for a in range(F // 100*A + 1): 
        for b in range(F // 100*B + 1): 
                for c in range(int(F * max_sugar) // C + 1):
                        for d in range(int(F * max_sugar) // D + 1): 
                                mass = 100*A*a + 100*B*b + C*c + D*d 
                                sugar = C*c + D*d 
                                if 0 < mass <= F and sugar / mass <= max_sugar:
                                        if res <= sugar / mass:
                                                res = sugar / mass 
                                                ans = [mass, sugar]
                                else:
                                        break
print(str(ans[0]) + " " + str(ans[1]))
### BUGGY CODE ###

import sys #追加
sys.setrecursionlimit(500*500)

dGCD = {}

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        temp = dGCD.get((x,a[i]))
        if (temp is None):
            temp = gcd(x, a[i])
            dGCD[(x,a[i])] = temp
        x = (x * a[i]) // temp
    return int(x)

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

LCM = lcm(A)

ans = 0
for a in A:
    ans += LCM//a
    ans %= 1000000007

print(ans)

### FIXED CODE ###

import sys #追加
sys.setrecursionlimit(500*500)

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return int(x)

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

LCM = lcm(A)

ans = 0
for a in A:
    ans += LCM//a

ans %= 1000000007

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

x = int(input())
p = 0
n = 0
while p < x:
  if n%2==0:
    n+= 1
    p+= 6
  else:
    n += 1
    p += 5
print(n)

### FIXED CODE ###

x = int(input())
N = x//11
m = x%11
if m == 0:
  print(2*N)
elif m <= 6:
  print(2*N+1)
else:
  print(2*N+2)
### BUGGY CODE ###

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

def f(X):
  i = 0
  while True:
    if i == len(X)-1:
      return(i)
      break
    elif X[i] < X[i+1]:
      return(i)
      break
    else:
      i += 1
  
X = H
ANS = []
while True:
  if X == []:
    print(max(ANS))
    exit()
  else:
    ANS.append(f(X))
    x = f(X)
    X = X[x+1:n]

### FIXED CODE ###

n = int(input())
H = list(map(int, input().split()))
c = 0
ans = 0
for i in range(1,n):
    if H[i]<=H[i-1]:
        c +=1
    else:
        c = 0
    ans = max(ans,c)
print(ans)
### BUGGY CODE ###

L, R = map(int, input().split())

minimum=2019
z=0
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            z=1
            break
        if z==1:
            break
    
print(minimum)

### FIXED CODE ###

L, R = map(int, input().split())

minimum=2019
z=0
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            z=1
            break
    if z==1:
        break
    
print(minimum)
### BUGGY CODE ###

ress = [[(10 ** i * j) % 13 for j in range(10)] for i in range(6)]

mod = 10 ** 9 + 7

keta = 0
res = 0
state = [1] + [0] * 12
for s in reversed(input()):
    if s == "?":
        new_state = [0] * 13
        for i in range(13):
            for r in ress[keta % 6]:
                new_state[i] += state[(i - r) % 13]
            new_state[i] %= mod
        state = new_state
    else:
        res += ress[keta % 6][int(s)]
    keta += 1

res = (5 - res) % 13

print(state[res] % mod)


### FIXED CODE ###

import numpy as np
from numpy.fft import fft, ifft

mod = 10 ** 9 + 7
S = input()

mat = []
for i in range(6):
    w = np.zeros(13)
    for j in range(10):
        w[(10 ** i * j) % 13] += 1
    mat.append(fft(w))

ress = [[(10 ** i * j) % 13 for j in range(10)] for i in range(6)]


state = np.zeros(13)
state[0] = 1
state = fft(state)

keta = 0
res = 5
for s in reversed(S):
    if s == "?":
        state = state * mat[keta]
    else:
        res -= ress[keta][int(s)]

    if keta == 5:
        keta = 0
        state = fft(np.remainder(np.round(np.real(ifft(state))), mod))
    else:
        keta += 1


state = ifft(state)
print(int(np.round(np.real(state[res % 13]))) % mod)
### BUGGY CODE ###

import copy
H, W = map(int, input().split())
MAP = [list('#' + input() + '#') for j in range(H)]
MAP.insert(0,['#' for i in range(W + 2)])
MAP.append(['#' for i in range(W + 2)])
MAP2 = copy.deepcopy(MAP)


def line(MAP):
    for i in range(1, H + 2):
        start = 1
        goal = 1
        count = 0
        for j in range(1, W + 2):
            if MAP[i][j] == '.':
                goal += 1
                count += 1
            else:
                for x in range(start, goal):
                    MAP[i][x] = count
                goal += 1
                start = goal
                count = 0
def column(MAP2):
    for j in range(1, W + 2):
        start = 1
        goal = 1
        count = 0
        for i in range(1, H + 2):
            if MAP2[i][j] == '.':
                goal += 1
                count += 1
            else:
                for x in range(start, goal):
                    MAP2[x][j] = count
                goal += 1
                start = goal
                count = 0
line(MAP)
column(MAP2)

ans = 0
for i, line in enumerate(MAP):
    for j, dot in enumerate(line):
        if dot != '#':
            ans = max(ans, MAP[i][j] + MAP2[i][j] - 1)
print(ans)

### FIXED CODE ###

def main ():
    H, W = map(int, input().split())
    MAP = [list('#' for i in range(W + 2)) for j in range(H + 2)]
    for i in range(H):
        line = list(input())
        for j, dot in enumerate(line):
            MAP[i + 1][j + 1] = dot
    L = [[0 for j in range(W + 2)] for i in range(H + 2)]


    def line(MAP):
        for i in range(1, H + 2):
            before = 0
            for j in range(1, W + 2):
                if MAP[i][j] == '#':
                    for x in range(before + 1, j):
                        L[i][x] = j - before - 1
                    before = j


    def column(MAP2):
        ans = 0
        for j in range(1, W + 2):
            before = 0
            for i in range(1, H + 2):
                if MAP2[i][j] == '#':
                    for y in range(before + 1, i):
                        ans = max(ans, i - before - 1 + L[y][j])
                    before = i
        return ans - 1

    line(MAP)
    column(MAP)
    print(column(MAP))

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

n = int(input())
length = list(map(int, input().split()))
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
               if length[i] < length[j]+length[k] and length[j] < length[k]+length[i] and length[k] < length[i]+length[j]:
                   count += 1
               else:
                   pass
print(count)

### FIXED CODE ###

import bisect
n = int(input())
length = list(map(int, input().split()))
length = sorted(length)
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        insert_index = bisect.bisect_left(length, length[i]+length[j])
        count += insert_index-j-1               
print(count)
### BUGGY CODE ###

import sys
from collections import deque

H, W = map(int, input().split())
c = [input() for a in range(H)]

d = [[ sys.maxsize for b in range(W)] for a in range(H)]

dy = [1, 0, -1, 0]
dx = [0, 1, 0, -1]

q = deque()

for y in range(H):
  for x in range(W):
    if c[y][x] == '#':
      q.append([y, x])
      d[y][x] = 0
ans = 0
while len(q) > 0:
  y, x = q.popleft()
  for i in range(4):
    ny = y + dy[i]
    nx = x + dx[i]
    if 0 <= nx and nx <= W-1 and 0 <= ny and ny <= H-1 and c[ny][nx] == '.' and d[ny][nx] == sys.maxsize:
      q.append([ny, nx])
      d[ny][nx] = d[y][x]+1
      ans = max(ans, d[ny][nx])

      
print(ans)


### FIXED CODE ###

import sys
from collections import deque

H, W = map(int, input().split())
c = [input() for a in range(H)]

d = [[ sys.maxsize for b in range(W)] for a in range(H)]

dy = [1, 0, -1, 0]
dx = [0, 1, 0, -1]

q = deque()

for y in range(H):
  for x in range(W):
    if c[y][x] == '#':
      q.append([y, x])
      d[y][x] = 0
ans = 0
while len(q) > 0:
  y, x = q.popleft()
  for i in range(4):
    ny = y + dy[i]
    nx = x + dx[i]
    if 0 <= nx and nx <= W-1 and 0 <= ny and ny <= H-1 and c[ny][nx] == '.' and d[ny][nx] == sys.maxsize:
      q.append([ny, nx])
      d[ny][nx] = d[y][x]+1
      ans = max(ans, d[ny][nx])

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

L = input()
MOD = 10 ** 9 + 7
N = len(L)

fact = [0] * (N + 1)
inv = [0] * (N + 1)
fact[0] = 1
inv[0] = pow(1, MOD - 2, MOD)

for i in range(1, N + 1) :
    fact[i] = (fact[i-1] * i) % MOD
    inv[i] = pow(fact[i], MOD - 2, MOD)

def comb(n, r) :
    if n < r or n < 0 or r < 0 :
        return 0
    return (fact[n] * inv[n-r] * inv[r]) % MOD

ret = 0
n1 = [0] * (N + 1)

sum = 0
for k, v in enumerate(L) :
    if v == '1' :
        for i in range(N-k) :
            n1[sum+i] += comb(N-k-1, i)
        sum += 1

n1[L.count('1')] += 1
   
for i, n in enumerate(n1) :
    ret += n * pow(2, i, MOD)
    ret %= MOD
    
print(ret)

### FIXED CODE ###

L = input()
MOD = 10 ** 9 + 7
N = len(L)

s = 0
ret = 0
for k, v in enumerate(L) :
    if v == '1' :
        ret += pow(2, s, MOD) * pow(3, N-k-1, MOD)
        ret %= MOD
        s += 1

ret += pow(2, s, MOD)

print(ret % MOD)
### BUGGY CODE ###

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

ans = 1
for aa in a:
    ans*=aa
if ans > 10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

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

ans = 1
f = True
if a[0] == 0:
    print(0)
    f = False
else:
    for aa in a[::-1]:
        ans*=aa
        if ans > 10**18:
            print(-1)
            f = False
            break
if f:
    print(ans)
### BUGGY CODE ###

words = lambda t : list(map(t, input().split()))
n = int(input())
a = input()

d = {}
for i in range(n-2):
    nums = [0]*10
    for j in range(i+2,n):
        nums[int(a[j-1])] += 1
        #print(i,j, nums)
        for k in range(10):
            if nums[k] > 0:
                d[int(a[i])*100 + k*10 + int(a[j])] = 1
        #print(d)

print(len(d))


### FIXED CODE ###

words = lambda t : list(map(t, input().split()))
n = int(input())
a = input()

d = {}
r_nums = [0] * 10
for i in range(1,n):
    r_nums[int(a[i])] += 1
l_nums = [0] * 10

for i in range(1,n-1):
    center = int(a[i])
    r_nums[int(a[i])] -= 1
    l_nums[int(a[i-1])] += 1
    #print(l_nums, center, r_nums)
    for j in range(10):
        for k in range(10):
            if r_nums[j] > 0 and l_nums[k] > 0:
                d[k*100 + center*10 + j] = 1
    #print(d)
print(len(d))
### BUGGY CODE ###

import math
def num_divisors_trial_division(n):
    num = 0
    for i in range(1, int(math.sqrt(n) + 1e-9) + 1):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1
    
    return num
N=int(input())
ans=[]
li=[i for i in range(1,N+1)]
for i in range(1,N+1):
  ans.append(num_divisors_trial_division(i))
print(sum([a*b for a,b in zip(ans,li)]))


### FIXED CODE ###

N=int(input())
ans=(N*(N+1))//2  #1の時
for i in range(2,N+1):
  m=N//i
  ans+=i*(m*(m+1)//2)
print(ans)
### BUGGY CODE ###

R,G,B,N=map(int,input().split())
cnt=0
for i in range(N//R+1):
    for j in range((N-i*R)//G+1):
        for k in range((N-i*R-j*G)//B+1):
            if R*i+G*j+B*k==N:
                cnt+=1
print(cnt)

### FIXED CODE ###

R,G,B,N=map(int,input().split())
cnt=0
for i in range(N//R+1):
    for j in range((N-i*R)//G+1):
            if i*R + j*G +((N-i*R-j*G)//B)*B==N:
                cnt+=1
print(cnt)
### BUGGY CODE ###

import sys
import bisect
 
N, Q = map(int, input().split(' '))
G = [list(map(int, sys.stdin.readline().split(' '))) for _ in range(N)]
T = [int(sys.stdin.readline()) for _ in range(Q)]
 
G.sort(key = lambda x : -x[2])
T.sort()
 
class SegTree :
    def __init__(self, n) :
        self.n = n
        self.A = [None] * (2 << (n + 1).bit_length())
 
    def update(self, i, l, r, ll, rr, val) :
        if r <= ll or rr <= l :
            return
        if ll <= l and r <= rr :
            self.A[i] = val
            return
 
        if self.A[i] != None :
            self.A[i * 2] = self.A[i * 2 + 1] = self.A[i]
            self.A[i] = None
 
        m = (l + r) // 2
        self.update(i * 2, l, m, ll, rr, val)
        self.update(i * 2 + 1, m, r, ll, rr, val)
 
    def get(self, i, l, r, p) :
        if self.A[i] != None or l + 1 == r :
            return self.A[i]
        m = (l+r) // 2
        if p < m :
            return self.get(i * 2, l, m, p)
        else :
            return self.get(i * 2 + 1, m, r, p)
 
ST = SegTree(Q)
for g in G :
    s = max(0, g[0] - g[2])
    e = g[1] - g[2]
    if e <= 0 :
        continue
 
    ll = bisect.bisect_left(T, s)
    rr = bisect.bisect_left(T, e)
 
    if ll == rr :
        continue
 
    ST.update(1, 0, Q, ll, rr, g[2])
 
for i in range(Q) :
    ans = ST.get(1, 0, Q, i)
    if ans == None :
        print(-1)
    else :
        print(ans)


### FIXED CODE ###

import sys
import bisect
 
N, Q = map(int, input().split(' '))
G = [list(map(int, sys.stdin.readline().split(' '))) for _ in range(N)]
T = [int(sys.stdin.readline()) for _ in range(Q)]

class SegTree :
    def __init__(self, n) :
        self.n = n
        self.A = [10**15] * (2 << (n + 1).bit_length())
 
    def update(self, l, r, val) :
      l += len(self.A) // 2
      r += len(self.A) // 2
      while l < r:
          if l & 1 :
              self.A[l] = min(self.A[l], val)
              l += 1
          if r & 1:
              self.A[r-1] = min(self.A[r-1], val)
              r -= 1
          l //= 2
          r //= 2

    def get(self, i) :
      i += len(self.A) // 2
      ret = self.A[i]
      while i > 0 :
          i //= 2
          ret = min(ret, self.A[i])
      return ret if ret < 10**15 else -1

ST = SegTree(Q)
for g in G :
    s = g[0] - g[2]
    e = g[1] - g[2]
 
    ll = bisect.bisect_left(T, s)
    rr = bisect.bisect_left(T, e)
 
    if ll == rr :
        continue
 
    ST.update(ll, rr, g[2])
 
for i in range(Q) :
    ans = ST.get(i)
    print(ans)
### BUGGY CODE ###

n = int(input())
s = input()

ans = []
for x in range(len(s)-2):
  for y in range(x+1, len(s)-1):
    Z = list(set(s[y+1:]))
    for z in Z:
      ans.append(s[x]+s[y]+z)
print(len(list(set(ans))))

### FIXED CODE ###

n = int(input())
s = input()

cnt = 0
for i in range(1000):
  x = str(i).zfill(3)
  a = s.find(x[0])
  b = s[a+1:].find(x[1])
  c = s[a+b+2:].find(x[2])
  if -1 not in (a,b,c):
    cnt += 1
print(cnt)
### BUGGY CODE ###

s = input()
q = int(input())
for _ in range(q):
    t = input().split()
    if int(t[0]) == 1:
        s = s[::-1]
    else:
        s = t[2]*abs(int(t[1])-2)+s+t[2]*(int(t[1])-1)

print(s)

### FIXED CODE ###

from collections import deque
s = deque(input())
num = int(input())
cnt = 0
for _ in range(num):
    t = input().split()
    if t[0] == "1":
        cnt += 1
    else:
        if (int(t[1])+cnt) % 2 == 1:
            s.appendleft(t[2])
        else:
            s.append(t[2])
if cnt % 2 == 1:
    s.reverse()
print("".join(s))
### BUGGY CODE ###

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

ken_d = {k:[]  for k in range(1, N+1)}

for p in PY:
    ken_d[p[0]].append(p[1])

for k in ken_d.keys():
    ken_d[k].sort()

for p in PY:
    x = ken_d[p[0]].index(p[1]) + 1
    print(str(p[0]).zfill(6) + str(x).zfill(6))


### FIXED CODE ###

N, M = map(int, input().split())
import sys
PY = [list(map(int,sys.stdin.readline().rstrip().split())) for _ in range(M)]

# ken = {p[0] for p in PY}
# ken_d = {k:[] for k in ken}
ken_d = [[] for _ in range(N+1)]

rankdic = {} # 通し番号：県における順位

for i, p in enumerate(PY):
    # print(p)
    ken_d[p[0]].append([i, p[1]])

for k in range(N+1):
    ken_d[k].sort(key=lambda x:x[1])
    for i, v in enumerate(ken_d[k]):
        rankdic[v[0]] = i # 通し番号辞書に入れる

for i, p in enumerate(PY):
    x = rankdic[i] + 1
    print(str(p[0]).zfill(6) + str(x).zfill(6))
### BUGGY CODE ###

import sys
n = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(n)]

for i in range(n):
    if A[i] == max(A):
        tmp = A.pop(i)
        print(max(A))
        A.insert(i, tmp)
    else:
        print(max(A))

### FIXED CODE ###

import sys
n = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(n)]
tmp = sorted(A)
maxa = max(A)
for i in range(n):
    if A[i] == maxa:
        print(tmp[-2])
    else:
        print(maxa)
### BUGGY CODE ###

import math
import bisect
n,d,a = map(int,input().split())
L = []
kyo = []
s = 0
for i in range(n):
    x,h = map(int,input().split())
    L.append([x,h])
    kyo.append(x)
    s += h
L.sort()
kyo.sort()
ans = 0
temp = 0
while s != 0:
    if L[temp][1] != 0:
        times = int(math.ceil(L[temp][1]/a))
        ans += times
        s -= L[temp][1]
        damage = a*times
        ran = L[temp][0]+2*d
        k = bisect.bisect_right(kyo, ran)
        next = temp+1
        for i in range(temp+1, k):
            if L[i][1] > damage:
                L[i][1] -= damage
                s -= damage
                next = min(next, i)
            else:
                s -= L[i][1]
                L[i][1] = 0
        temp = next
    else:
        for i in range(temp+1, n):
            if L[i] != 0:
                temp = i
                break
print(ans)


### FIXED CODE ###

import math
import bisect
n,d,a = map(int,input().split())
L = []
kyo = []
for i in range(n):
    x,h = map(int,input().split())
    L.append([x,h])
    kyo.append(x)
L.sort()
kyo.sort()
ans = 0
imos = [0]*(n+1)
cur = 0
ran = 2*d
for i in range(n):
    if imos[cur] < L[cur][1]:
        t = int(math.ceil((L[cur][1]-imos[cur])/a))
        ans += t
        imos[cur] += t*a
        lim = bisect.bisect_right(kyo, kyo[cur]+ran)
        imos[lim] -= t*a
    imos[i+1] += imos[i]
    cur += 1
print(ans)
### BUGGY CODE ###

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

st = set()

for i in range(1,m+1):
    lst = [i%x==x/2 for x in a]
    if all(lst):
        st.add(i)
        break
            
f = (((m // i) - 1) //2)
print(len(st) + f)

### FIXED CODE ###

from fractions import gcd
from functools import reduce

def lcm(a,b):
    return a*b//gcd(a,b)

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

lh = list(map(lambda x:x//2, l))
lcm = reduce(lcm,lh)
res = 0
times = [(lcm//x)%2==1 for x in lh]

if all(times):
    res = ((m // lcm) +1) // 2

print(res)
### BUGGY CODE ###

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

for i in range(N-1):
    for j in range(i+1, N):
        ans += A[i]*A[j]

print(ans % (10**9+7))

### FIXED CODE ###

import itertools
N = int(input())
A = list(map(int, input().split()))
ans = 0
sumall = 0
for j in range(N):
    sumall += A[j]
for i in range(N):
    ans += A[i]*(sumall-A[i])
    sumall = sumall - A[i]

print(ans % (10**9+7))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

s_len, n = map(int, input().split())
s = input().rstrip()
for i in range(n):
  a, b = map(int, input().split())
  s_slice = s[a-1:b]  
  print(sum([s_slice[i:2+i]=="AC" for i in range(len(s_slice)-1)]))
  


### FIXED CODE ###

import sys
input = sys.stdin.readline

import bisect
left = bisect.bisect_left
right = bisect.bisect_right 

n, q = list(map(int, input().split()))
s = input()
lr = [list(map(int, input().split())) for i in range(q)]
a = [i for i in range(n-1) if s[i:i+2]=="AC"]

for i in range(q):
  left_index = left(a, lr[i][0]-1)      
  right_index = right(a, lr[i][1]-2)  
  print(right_index - left_index)
### BUGGY CODE ###

N = int(input())
l = [int(input()) for i in range(5)]
ans = [0]*6
ans[0] = N
ans_num = 0
while(ans[5]!=N):
  tmp = [0]*6
  ans_num+=1
  for i in range(5):
    ans_tmp = ans[i]
    if ans_tmp!=0:
      if ans_tmp<=l[i]:
        tmp[i+1] = ans_tmp
        ans[i]=0
      else:
        tmp[i+1] = l[i]
        ans[i]-=l[i]
  for i in range(6):
    ans[i]+=tmp[i]
print(ans_num)

### FIXED CODE ###

N = int(input())
l = [int(input()) for i in range(5)]
tmp = 0
for i in range(5):
  if l[i] > N:
    tmp += 1

if tmp == 5:
  print(5)
else:
    ans = 0
    if N%min(l) == 0:
      ans+=5+N//min(l)-1
    else:
      ans+=5+N//min(l)
    print(ans)
### BUGGY CODE ###

n,k = (int(i) for i in input().split())
b = [[int(i)-1 for i in input().split()] for i in range(n-1)]
x,d,ans = [[] for i in range(n)],[[None]*n for i in range(n)],n
for i,j in b:
	x[i].append(j)
	x[j].append(i)
for i in range(n):
	q,v,d[i][i] = [],[1]*n,(0,-1)
	v[i] = 0
	for j in x[i]:
		q.append((j,1,j))
		d[i][j],v[j] = (1,j),0
	while q:
		p = q.pop()
		for j in x[p[0]]:
			if v[j]:
				q.append((j,p[1]+1,p[2]))
				d[i][j],v[j] = (p[1]+1,p[2]),0
if k%2:
	for i in range(n-1):
		a = n
		for j,j2 in d[b[i][0]]:
			if b[i][1]!=j2 and (k-1)//2>=j: a-=1
		for j,j2 in d[b[i][1]]:
			if b[i][0]!=j2 and (k-1)//2>=j: a-=1
		ans = min(a,ans)
else:
	for i in range(n):
		a = n
		for j,j2 in d[i]:
			if j<=k//2: a-=1
		ans = min(a,ans)
print(ans)

### FIXED CODE ###

from collections import deque
n,k = (int(i) for i in input().split())
b = [[int(i)-1 for i in input().split()] for i in range(n-1)]
x,d,ans,c = [[] for i in range(n)],[[] for i in range(n)],n,0
for i,j in b:
	x[i].append(j)
	x[j].append(i)
def f(s):
	for i in range(n):
		q,v = deque(),[1]*n
		v[i] = 0
		for j in x[i]:
			q.append((j,1,j))
			d[i].append(j)
			v[j] = 0
		while q:
			p = q.pop()
			if p[1]<s:
				for j in x[p[0]]:
					if v[j]:
						q.append((j,p[1]+1,p[2]))
						d[i].append(p[2])
						v[j] = 0
if k>n//2:
	for i in x: c = max(len(i),c)
if n-c+1<=k: ans = 0
elif k==1: ans = n-2
else:
	f(k//2)
	if k%2:
		for i,j in b: ans = min(ans,n-len(d[i])-len(d[j])+d[i].count(j)+d[j].count(i)-2)
	else:
		for i in range(n): ans = min(ans,n-len(d[i])-1)
print(ans)
### BUGGY CODE ###

#N人の参加者 全員がＫポイント持っている 
#Q回の正解
#Aは誰が正解したか
N,K,Q=map(int,input().split())
Ans=[]
for _ in range(Q):
    hoge=int(input())
    Ans.append(hoge-1)
# print(Ans) 
person=N*[K]
# print(person)

#問題
for i in range(Q):
    #人
    for j in range(N):
        if Ans[i]==j:
            pass
        else:
            person[j]-=1
    # print(person)
# print(person)

for i in range(N):
    if person[i]>0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

#N人の参加者 全員がＫポイント持っている 
#Q回の正解
#Aは誰が正解したか
N,K,Q=map(int,input().split())
Ans=[]
for _ in range(Q):
    hoge=int(input())
    Ans.append(hoge-1)
# print(Ans) 
person=N*[K-Q]
# print(person)

#問題
for i in range(Q):
    person[Ans[i]]+=1
    # #人
    # for j in range(N):
    #     if Ans[i]==j:
    #         pass
    #     else:
    #         person[j]-=1
    # print(person)
# print(person)

for i in range(N):
    if person[i]>0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###


N = int(input())
d =  {}
a = list(map(int,input().split()))
for i in range(N):
    if a[i] not in d.keys():
        d[a[i]] = 1
    else:
        d[a[i]] +=1
ans = 0
for k,v in d.items():
    if v < k:
        ans += v
    else:
        ans += abs(v-k)
print(ans)


### FIXED CODE ###

from collections import Counter
inf = 10**10


N = int(input())
a = list(map(int,input().split()))
c = Counter(a)
ans = 0
for i,j in c.items():
    if j>=i:
        ans += j-i
    else:
        ans += j
print(ans)