Harryxun/stf_run huggingface dataset:
def main():
    N = int(input())
    X = int(input(), 2)

    def popcount(x):
        '''xの立っているビット数をカウントする関数
        (xは64bit整数)'''

        # 2bitごとの組に分け、立っているビット数を2bitで表現する
        x = x - ((x >> 1) & 0x5555555555555555)

        # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
        x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

        x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
        x = x + (x >> 8) # 16bitごと
        x = x + (x >> 16) # 32bitごと
        x = x + (x >> 32) # 64bitごと = 全部の合計
        return x & 0x0000007f
  
    def f(x):
        temp = x
        count = 0
        while temp > 0:
            temp = temp % popcount(temp)
            count += 1
        return count
    
    ans = [0]*N
    for i in range(0, N):
        xi = X ^ (1 << i)
        ans[N-i-1] = f(xi)
    for a in ans:
        print(a)

main()

### FIXED CODE ###

N=int(input())
X=input()
num_X = int(X, base=2)
pop_x = X.count("1")
if pop_x <= 1:
    mod0 = pop_x + 1
    res0 = num_X % mod0
else:
    mod1 = pop_x - 1
    mod0 = pop_x + 1
    res1 = num_X % (mod1)
    res0 = num_X % (mod0)

# pops = [0]*(N+20)
for i in range(N):
    tmp = 0
    if X[i] == "0":
        # +
        tmp = (res0 + pow(2, N-i-1, mod0))%mod0
    else:
        if pop_x == 1:
            print(0)
            continue
        tmp = (res1 - pow(2, N-i-1, mod1))%mod1
    
    if tmp == 0:
        print(1)
        continue
    cnt = 1
    while tmp != 0:
        pop = bin(tmp).count("1")
        tmp %= pop
        cnt += 1
    print(cnt)
n=int(input())
A=set()
for i in range(n):
    a=input()
    if a in A:
        A.remove(a)
    else:
        A.add(a)
print(len(A)

### FIXED CODE ###

n=int(input())
A=set()
for i in range(n):
    a=input()
    if a in A:
        A.remove(a)
    else:
        A.add(a)
print(len(A))
import math

def combi(n ,k):
    return math.factorial(n)/(math.factorial(k)*math.factorial(n-k))

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

cnt_list = []
for i in range(1,K+1):
    if N-K+1 >= i:
        cnt = combi(N-K+1,i)*combi(K-1,i-1)
    else:
        cnt =0
    cnt_list.append(cnt%(10**9+7))

for i in range(len(cnt_list)):
    print(cnt_list[i])

### FIXED CODE ###

import math

def combi(n ,k):
    return math.factorial(n)//(math.factorial(k)*math.factorial(n-k))

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

cnt_list = []
for i in range(1,K+1):
    if N-K+1 >= i:
        cnt = int(combi(N-K+1,i)*combi(K-1,i-1))
    else:
        cnt =0
    cnt_list.append(cnt%(10**9+7))

for i in range(len(cnt_list)):
    print(cnt_list[i])
i = map(int,input().split())
if (i[0] == i[1] and i[0] != i[2]) or (i[0] == i[2] and i[0] != i[1])  or (i[1] == i[2] and i[1] != i[0]):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

i = list(map(int,input().split()))
if (i[0] == i[1] and i[0] != i[2]) or (i[0] == i[2] and i[0] != i[1])  or (i[1] == i[2] and i[1] != i[0]):
  print("Yes")
else:
  print("No")
import math

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

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

print(lcm(A, B))

### FIXED CODE ###

import fractions

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

print((A * B) // fractions.gcd(A, B))
n = int(input())
l = list(map,int().split())
s = 0
for i in range(n):
  j = i + 1
  while j <= n - 1:
    s += l[i] * l[j]
  	j += 1
print(s)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
s = 0
for i in range(n):
  j = i + 1
  while j <= n - 1:
    s += l[i] * l[j]
    j += 1
print(s)
A,B,C=int(input())
if A+B >= C:
    print(B+C)
else:
    print(A+2*B+1)


### FIXED CODE ###

A,B,C = map(int,input().split())
if A+B >= C:
    print(B+C)
else:
    print(A+2*B+1)
string = input()
q = int(input())
for c in range(0,q):
    instruction = input().split(' ')
    if instruction[0] == 'print':
        print(string[int(instruction[1]):int(instruction[2]) + 1])
    elif instruction[0] == 'reverse':
        string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)
    elif instruction[0] == 'replace':
        if instruction[1] == instruction[2]:
            string[instruction[1]] = instruction[3]
        else:
            string = string.replace(string[int(instruction[1]):int(instruction[2])+1], instruction[3], 1)

### FIXED CODE ###

string = input()
q = int(input())
for c in range(0,q):
    instruction = input().split(' ')
    if instruction[0] == 'print':
        print(string[int(instruction[1]):int(instruction[2]) + 1])
    elif instruction[0] == 'reverse':
        string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)
    elif instruction[0] == 'replace':
        string = string[:int(instruction[1])] + instruction[3] + string[int(instruction[2])+1:]
n,a,b=map(int,input().split())

ans=0
for i in ranpe(1,n+1):
  s=0
  x=i
  while 0<x:
    s+=x%10
    x//=10
  if a<=s and s<=b:
    ans+=i
print(ans)

### FIXED CODE ###

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

ans=0
for i in range(1,n+1):
  s=0
  x=i
  while 0<x:
    s+=x%10
    x//=10
  if a<=s and s<=b:
    ans+=i
print(ans)
mod = 10**9+7

def stairs(n):
    if n == 0:
        return 1
    elif n == 1:
        return 1
    else:
        return stairs(n-1)%mod+stairs(n-2)%mod

def main():
    n,m = map(int,input().split(' '))
    a=[-1]
    a_list=[]
    ans = 1
    for i in range(m):
        a.append(int(input()))
    a.append(n+1)
    for i in range(m+1):
        a_list.append(a[i+1]-a[i]-2)
    for i in a_list:
        if i <0:
            ans = 0
            break
        ans *= stairs(i)
        ans %= mod
    print(ans)

main()

### FIXED CODE ###

import sys
mod = 10**9+7
def main():
    n,m=map(int,input().split(' '))
    if m > 0:
        aaa = set(map(int,sys.stdin))
    else:
        aaa = set()

    dp = [0] * (n+1)
    dp[0] = 1
    dp[1] = 1 if 1 not in aaa else 0
    for i in range(2,n+1):
        if i in aaa:
            continue
        dp[i] = dp[i-1]+dp[i-2]

    print(dp[n]%mod)

main()
import math

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

print(math.floor(ans))

### FIXED CODE ###

s=input().split()
a=int(s[0])
b=int(float(s[1])*1000) 
ans=a*b
print(ans//1000)
md = m / 60 * 360

bx = math.sin(math.radians(md)) * b
by = math.cos(math.radians(md)) * b

hd = h / 12 * 360 + m / 60 * 30

ax = math.sin(math.radians(hd)) * a
ay = math.cos(math.radians(hd)) * a

ans = math.sqrt((ax - bx)**2 + (by - ay)**2)
print(ans)

### FIXED CODE ###

import math
a, b, h, m = map(int, input().split())

md = m / 60 * 360

bx = math.sin(math.radians(md)) * b
by = math.cos(math.radians(md)) * b

hd = h / 12 * 360 + m / 60 * 30

ax = math.sin(math.radians(hd)) * a
ay = math.cos(math.radians(hd)) * a

ans = math.sqrt((ax - bx)**2 + (by - ay)**2)
print(ans)
import numpy as np
from math import factorial as fac

N,M=  map(int, input().split())
broken_steps=[]

for m in range(M):
    broken_steps.append(int(input()))

for i in range(len(broken_steps)-1):
    if broken_steps[i+1]-broken_steps[i]==1:
        print("{}".format(0))
        FLG=True

if FLG!=True:        
    count=0
    for two_step in range(M,N//2+1):
        one_step=N-two_step*2
        count+=fac(two_step+one_step)/(fac(two_step)*fac(one_step))

    print("{}".format(count%1000000007))

### FIXED CODE ###

MOD = 10**9 + 7
N, M = [int(s) for s in input().split()]
#行ってはいけないところには0がはいる
ls = [1 for _ in range(N + 1)]
for i in range(M):
    ls[int(input())] = 0

for n in range(2, N + 1):
    if ls[n] != 0:
        #(n*m)mod k ==(n(mod k)*m(mod k))
        ls[n] = (ls[n - 1] + ls[n - 2]) % MOD
print(ls[N])
n,k=map(int,input().split())
p=[int(i)-1for i in input().split()]
c=list(map(int,input().split()))
ans=-10**9
for i in range(n):
    start=i
    cycle=[0]
    for _ in range(n):
        i=p[i]
        cycle+=[cycle[-1]+c[i]]
        if i==start:break
    S,L=cycle[-1],len(cycle)-1
    if S<=0:ans=max(ans,max(cycle[1:k+1]))
    else:
        if k>L:ans=max(ans,(k//L-1)*S+max(max(cycle),max(cycle[:k%L+1])+S)) 
        else:ans=max(ans,cycle[:k+1])
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
p=[int(i)-1for i in input().split()]
c=list(map(int,input().split()))
ans=-10**9
for i in range(n):
    start=i
    cycle=[0]
    for _ in range(n):
        i=p[i]
        cycle+=[cycle[-1]+c[i]]
        if i==start:break
    S,L=cycle[-1],len(cycle)-1
    if S<=0:ans=max(ans,max(cycle[1:k+1]))
    else:
        if k>L:ans=max(ans,(k//L-1)*S+max(max(cycle),max(cycle[:k%L+1])+S)) 
        else:ans=max(ans,max(cycle[:k+1]))
print(ans)
N, K = map(int, input().split())
A = list(map(int, input().split()))

X = 0
town = 1
counted = []
for k in range(N):
  X += 1
  counted.append(town)
  town = A[town-1]
  if town in counted:
    Q = len(counted[counted.index(town):])
    roop = counted[counted.index(town):]
    I = counted[:counted.index(town)]
    ini = X - Q
    break
print(I)
print(roop)
ans = 1
if K > ini:    
  num = (K-ini) % Q
  print(roop[num])
else:
  print(I[K])
  

### FIXED CODE ###

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

X = 0
town = 1
counted = [0 for _ in range(N)]
List = [0 for _ in range(N)]
for k in range(N):
  X += 1
  counted[k] = town
  town = A[town-1]
  if List[town-1] == 1:
    ini = counted.index(town)
    Q = X - ini
    break
  else:
    List[town-1] = 1
if K >= ini:    
  num = (K-ini) % Q
  print(counted[ini+num])
else:
  print(counted[K])
a, b = list(map(int, input().split())
if a * 500  < b :
  print('No')
else:
  print('Yes')


### FIXED CODE ###

a, b = list(map(int, input().split()))
if a * 500  < b :
            print('No')
else:
            print('Yes')
N,Y=map(int,input().split(" "))

x,y,z=-1,-1,-1
bp=0
for i in range(N+1):
    for j in range(N+1-i):
        if Y==9000*i+4000*j+1000*N:
            x=i
            y=j
            z=N-i-j
            bp=1
            break
    if bp==1:
        break
        
print(f"{x} {y} {z}")

### FIXED CODE ###

N,Y=map(int,input().split(" "))

x=-1
y=-1
z=-1
bp=0

for i in range(N+1):
    for j in range(N+1-i):
        if Y==9000*i+4000*j+1000*N:
            x=i
            y=j
            z=N-i-j
            bp=1
            break
    if bp==1:
        break
        
print("{} {} {}".format(x,y,z))
import math
a,b,c = list(map(int, input().split()))
if ((math.sqrt(a) + math.sqrt(b)) < math.sqrt(c)):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = int(input()) - 1
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[n])
r = raw_input()

print"math.pi*2*%d math.pi*r**2" % (r)

### FIXED CODE ###

import math
r = float(raw_input())
l = math.pi*2*r
s = math.pi*r**2
print'%f %f' % (s, l)
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]

minimum = (h - 1) * (w - 1)
for div_h in range(1 << (h - 1)):
  h_index = [0] * h
  cur_index = 0
  bin_h = format(div_h, f'0{h-1}b')
  for i in range(1, h):
    if bin_h[-i] == '1':
      cur_index += 1
    h_index[i] = cur_index
  white_choco = [0] * (cur_index + 1)
  divide = 0
  j = 0
  while j < w:
    for i in range(h):
      if s[i][j] == '1':
        h_i = h_index[i]
        if white_choco[h_i] < k:
          white_choco[h_i] += 1
        else:
          break
    else:
      j += 1
      continue
    white_choco = [0] * (cur_index + 1)
    divide += 1
  minimum = min(minimum, divide + cur_index)
print(minimum)

### FIXED CODE ###

h, w, k = map(int, input().split())
s = [[int(s_ij) for s_ij in input()] for _ in range(h)]

minimum = (h - 1) * (w - 1)
for div_h in range(1 << (h - 1)):
  h_index = [0] * h
  cur_index = 0
  mask = 1 << (h - 2)
  for i in range(1, h):
    if div_h & mask:
      cur_index += 1
    h_index[i] = cur_index
    mask >>= 1
  white_choco = [0] * (cur_index + 1)
  divide = 0
  j = 0
  flag = False
  while j < w:
    for i in range(h):
      white_choco[h_index[i]] += s[i][j]
    if max(white_choco) > k:
      if flag:
        break
      flag = True
      white_choco = [0] * (cur_index + 1)
      divide += 1
    else:
      j += 1
      flag = False
  else:
    minimum = min(minimum, divide + cur_index)
print(minimum)
n, m = map(int, input().split())
abc = [list(map(int, input().split())) for x in range(m)]
nodes = [[] for x in range(n + 1)]

for a, b, c in abc:
    nodes[a].append([a, b, c])

costs = [None for x in range(n + 1)]
costs[1] = 0
flg = True
for i in range(n):
    for node in nodes[1:]:
        for a, b, c in node:
            if costs[b] == None or costs[b] < costs[a] + c:
                flg = False
                costs[b] = costs[a] + c
            else:
                costs[b] = costs[b]
    if flg:
        print(costs[n])
        break
    flg = True
else:
    print("inf")



### FIXED CODE ###

n, m = map(int, input().split())
abc = [list(map(int, input().split())) for x in range(m)]
nodes = [[] for x in range(n + 1)]

for a, b, c in abc:
    nodes[a].append([a, b, -c])

costs = [None for x in range(n + 1)]
costs[1] = 0
flg = True
for i in range(n):
    for a, b, c in abc:
        if costs[a] == None:
            continue
        if costs[b] == None or costs[b] < costs[a] + c:
            flg = False
            costs[b] = costs[a] + c
    # for node in nodes[1:]:
    #     for a, b, c in node:
    #         if costs[a] == None:
    #             continue
    #         if costs[b] == None or costs[b] > costs[a] + c:
    #             flg = False
    #             costs[b] = costs[a] + c
#     if flg:
#         print(costs[n])
#         break
#     flg = True
# else:
#     print("inf")

ans = costs[n]
negative = [False for x in range(n + 1)]
for i in range(n - 1):
    for a, b, c in abc:
        if costs[a] == None:
            continue
        if costs[b] == None or costs[b] < costs[a] + c:
            costs[b] = costs[a] + c
            negative[b] = True

        if negative[a] == True:
            negative[b] = True

print(negative[n] and "inf" or ans)
x = int(input())
if x != 1:
  return 0
elif x != 0:
  return 1


### FIXED CODE ###

x = int(input())
if x == 1:
    print(0)
elif x == 0:
    print(1)
import math

N = int(input())

ans = 0
for i in range(1, int(math.sqrt(N)) + 1):
  tmp = int((N - i) / i)
  if (N - i) % i == 0 and N % tmp != 0 and tmp >= math.sqrt(N):
    ans += tmp

print(ans)

### FIXED CODE ###

import math

N = int(input())

ans = 0
for i in range(1, int(math.sqrt(N)) + 1):
  if i > N / 2:
    continue
  tmp = int((N - i) / i)
  if (N - i) % i == 0 and N % tmp != 0 and tmp >= math.sqrt(N):
    ans += tmp

print(ans)
X, Y, Z = input().split(' ')
print([Z, X, Y].join(' '))

### FIXED CODE ###

X, Y, Z = input().split(' ')
print(' '.join([Z, X, Y]))
import random
N = int(input())
engine = [list(map(int, input().split())) for i in range(N)]

used = [False]*N
x = 0
y = 0

if N <= 50:

  for _ in range(5000000):
      i = random.randint(0, N-1)
      if used[i]:
          if x*x+y*y <= (x-engine[i][0])**2+(y-engine[i][1])**2:
              x -= engine[i][0]
              y -= engine[i][1]
              used[i] = False
      else:
          if x*x+y*y <= (x+engine[i][0])**2+(y+engine[i][1])**2:
              x += engine[i][0]
              y += engine[i][1]
              used[i] = True

  print((x*x+y*y)**(1/2))

else:
  print(ans)


### FIXED CODE ###

from math import *
n = int(input())
engine = [list(map(int, input().split())) for i in range(n)]

args = []
for i in range(n):
    x, y = engine[i]
    if x == 0:
        if y < 0:
            args.append((-pi/2, x, y))
        elif y > 0:
            args.append((pi/2, x, y))

    elif y == 0:
        if x > 0:
            args.append((0, x, y))
        elif x < 0:
            args.append((pi, x, y))

    else:
        args.append((atan2(y, x), x, y))

args.sort()
l = len(args)
args = args[:] + args[:]
ans = 0
for i in range(1, l+1):
    for j in range(l):
        x, y = 0, 0
        for k in range(j, j+i):
            x += args[k][1]
            y += args[k][2]
        ans = max(ans, hypot(x, y))

print(ans)
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split() for i in range(N)))
y = list(map(int,input().split() for i in range(N)))
if min(y)-max(x) < 1:
  print("War")
else:
  print("No War")


### FIXED CODE ###

N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)
if min(y) >= max(x)+1:
  print("No War")
else:
  print("War")
k, x = map(int, input().split())
print("Yes" if 500*k >= x, else "No")

### FIXED CODE ###

k, x = map(int, input().split())
print("Yes") if 500*k >= x else print("No")
N, M = [int(nm) for nm in input().split()]
X = [int(x) for x in input().split()]

if N > M:
  print(0)
else:
  X.sort()
  mn_X = X[0]
  for m in range(M):
    X[m] = X[m] - mn_X #一番座標が小さい点を原点とする

  DX = [] #隣り合う二点間の距離
  DX.append(0)
  for mm in range(M-1):
    dx = X[mm+1] - X[mm] #隣り合う二点間の距離を求める
    DX.append(dx)
  #print(DX)
  
  DXX = list(tuple(DX))
  DXX.sort(reverse=True) #DXXのi=0,1,2,...,N-2、つまり大きい値を取ってきたい
  I = [] #「XをN個に分割するとき、どの座標で分割するか」
  for i in range(N-1):
    big_dx = DXX[i]
    idx = DX.index(big_dx)
    I.append(idx)
  I.sort()
  #print(I)
  
  #最初のコマは原点に置く
  move = X[I[0]] - 0
  #print(move)
  
  for j in range(0, N-2):
    move += (X[I[j+1]] - X[I[j]+1])
  #print(move)
  
  #最後のコマ
  move += (X[-1] - X[I[N-2]+1])
  
  print(move)

### FIXED CODE ###

N, M = [int(nm) for nm in input().split()]
X = [int(x) for x in input().split()]

if N >= M:
  print(0)
elif N == 1:
  ans = max(X) - min(X)
  print(ans)
else:
  X.sort()
  mn_X = X[0]
  for m in range(M):
    X[m] = X[m] - mn_X #一番座標が小さい点を原点とする

  DX = [] #隣り合う二点間の距離
  for mm in range(M-1):
    dx = X[mm+1] - X[mm] #隣り合う二点間の距離を求める
    DX.append(dx)
  #print(DX)
  
  DXX = list(tuple(DX))
  DXX.sort(reverse=True) #DXXのi=0,1,2,...,N-2、つまり大きい値を取ってきたい
  I = [] #「XをN個に分割するとき、どの座標で分割するか」
  for i in range(N-1):
    big_dx = DXX[i]
    idx = DX.index(big_dx)
    I.append(idx)
  I.sort()
  #print(I)
  
  #最初のコマは原点に置く
  move = X[I[0]] - 0
  #print(move)
  
  for j in range(0, N-2):
    move += (X[I[j+1]] - X[I[j]+1])
  #print(move)
  
  #最後のコマ
  move += (X[-1] - X[I[N-2]+1])
  
  print(move)
N, K = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
d = 0
e = []

for i in range(len(b)):
    d = d + b[i]
    c.append(d)

for i in range(len(b) - K):
    e.append(c[i + K] - c[i] + K)

print(max(e)/2)


### FIXED CODE ###

N, K = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
d = 0
e = []

for i in range(len(b)):
    d = d + b[i]
    c.append(d)

for i in range(len(b) - K):
    e.append(c[i + K] - c[i] + K)
if N==K:
    print((sum(b) + K)/2)
else:    
    print(max(e)/2)
from collections import Counter
n = int(input())
ns = list(map(int, input().split()))
rslt = 0
a = 10 ** 9 + 7
cnt = Counter(ns)
if n % 2 == 0:
    for i in range(2, n, 2):
        if cnt[i] != 2:
            print(0)
            exit()
    rslt = pow(2, n // 2, a)
else:
    for i in range(1, n, 2):
        if cnt[i] != 2:
            print(0)
            exit()
    if c[0] == 1:
        rslt = pow(2, n // 2, a)
print(rslt)

### FIXED CODE ###

from collections import Counter
n = int(input())
ns = list(map(int, input().split()))
rslt = 0
a = 10 ** 9 + 7
cnt = Counter(ns)
if n % 2 == 0:
    for i in range(1, n, 2):
        if cnt[i] != 2:
            print(0)
            exit()
    rslt = pow(2, n // 2, a)
else:
    for i in range(2, n, 2):
        if cnt[i] != 2:
            print(0)
            exit()
    if cnt[0] == 1:
        rslt = pow(2, n // 2, a)
print(rslt)
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
t=0
while True:
  maxi=A[0]
  maxi_2=A[1]
  t+=1
  maxi=maxi//2
  if t==M :
    A[0]=maxi
    break
  elif maxi_2>maxi :
    A[0]=maxi
    A.sort(reverse=True)
    continue
  else:
    continue

amount=sum(A)
print(amount)

### FIXED CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
  A[i]*=-1
import heapq
heapq.heapify(A)
import math
for i in range(M):
  maxi=heapq.heappop(A)
  maxi=math.ceil(maxi/2)
  heapq.heappush(A,maxi)
  
ans=sum(A)*(-1)
print(ans)
N,K = map(int,input().split())
h = list(map(int,input().split()))

dp = [float("inf")]*(10**5+10)
dp[0] = 0

for i in range(N-1):
    Mi = min(K+1,N-i)
    for j in range(1,Mi):
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))

print(dp[N-1])


### FIXED CODE ###

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

dp = [float("inf")]*N
dp[0] = 0

for i in range(1,N):
    if i == 1:
        dp[i] = min(dp[i],dp[i-1] + abs(H[i]-H[i-1]))
    else:
        dp[i] = min(dp[i],dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))

print(dp[N-1])
N,M,K = (int(x) for x in input().split())
A = list(map(int, input.split()))
B = list(map(int, input.split()))
i,j = 0
time = 0
while time < K and i < N-1 or j < M-1:
    if A[i] < B[j]:
        time += A[i]
        i += 1
    elif A[i] > B[j]:
        time += B[j]
        j += 1
allbooks = i + j
print(allbooks)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
N = input()
if(N.lower() = N):
  print("a")
else:
  print("A")

### FIXED CODE ###

N = input()
if(N.lower() == N):
  print("a")
else:
  print("A")
import numpy as np

input_N = input().split()
N = int(input_N[0])

input_xyh = [input().split() for i in range(N)]

xyh = np.array(input_xyh)
xyh = xyh.astype(np.int64)
xyh = xyh.T
h = xyh[0]
x = xyh[1]
y = xyh[2]

# [0, 100]に座標があるのでMAXを定義する
coord_max = 100

for pos_y in range(coord_max):
    for pos_x in range(coord_max):
        # 頂上がどれくらいの高さであってほしいか
        # -1はまだよくわからないとき、0以上は確定
        # -2はダメ
        needH = -1

        for i in range(N):
            if h[i] > 0:
                tmp = h[i] + abs(pos_y - y[i]) + abs(pos_x - x[i])
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break
        if needH == -2:
            continue

        for i in range(N):
            # 高さが0の場合に矛盾してないか調べる
            if h[i] == 0:
                dist = abs(pos_y - y[i]) + abs(pos_x - x[i])
                if needH > dist:
                    needH = -2
                    break

        if needH == -2: continue

        # 見つけられたら答えをそのまま返す
        print(pos_x + " " + pos_y + " " + needH)

return 0


### FIXED CODE ###

import numpy as np

input_N = input().split()
N = int(input_N[0])

input_xyh = [input().split() for i in range(N)]

xyh = np.array(input_xyh)
xyh = xyh.astype(np.int64)
xyh = xyh.T
x = xyh[0]
y = xyh[1]
h = xyh[2]

# [0, 100]に座標があるのでMAXを定義する
coord_max = 101

for pos_y in range(coord_max):
    for pos_x in range(coord_max):
        # 頂上がどれくらいの高さであってほしいか
        # -1はまだよくわからないとき、0以上は確定
        # -2はダメ
        needH = -1

        for i in range(N):
            if h[i] > 0:
                tmp = h[i] + abs(pos_y - y[i]) + abs(pos_x - x[i])
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break
        if needH == -2:
            continue

        for i in range(N):
            # 高さが0の場合に矛盾してないか調べる
            if h[i] == 0:
                dist = abs(pos_y - y[i]) + abs(pos_x - x[i])
                if needH > dist:
                    needH = -2
                    break

        if needH == -2:
            continue

        # 見つけられたら答えをそのまま返す
        print(str(pos_x) + " " + str(pos_y) + " " + str(needH))
N = int(input())
*A, = map(int, input().split())
dic = {}
for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1
for k, v in dic.items():
    if k == v:
        continue
    elif k > v:
        ans += v
    else:
        ans += v - k
print(ans)

### FIXED CODE ###

N = int(input())
*A, = map(int, input().split())
dic = {}
ans = 0
for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1
for k, v in dic.items():
    if k == v:
        continue
    elif k > v:
        ans += v
    else:
        ans += v - k
print(ans)