Problem:
 Score : 600 points    Problem Statement  Takahashi has N cards. The i -th of these cards has an integer A_i written on it.  Takahashi will choose an integer K , and then repeat the following operation some number of times:   Choose exactly K cards such that the integers written on them are all different, and eat those cards. (The eaten cards disappear.)   For each K = 1,2, \ldots, N , find the maximum number of times Takahashi can do the operation.      Constraints   1 \le N \le 3 \times 10^5  1 \le A_i \le N  All values in input are integers.         Input  Input is given from Standard Input in the following format:  N  A_1  A_2  \ldots  A_N       Output  Print N integers.
The t -th (1 \le t \le N) of them should be the answer for the case K=t .        Sample Input 1 3
2 1 2      Sample Output 1 3
1
0  For K = 1 , we can do the operation as follows:   Choose the first card to eat.  Choose the second card to eat.  Choose the third card to eat.   For K = 2 , we can do the operation as follows:   Choose the first and second cards to eat.   For K = 3 , we cannot do the operation at all. Note that we cannot choose the first and third cards at the same time.       Sample Input 2 5
1 2 3 4 5      Sample Output 2 5
2
1
1
1       Sample Input 3 4
1 3 3 3      Sample Output 3 4
1
0
0

Solution (Python):
I = int(input())
from collections import Counter
from itertools import accumulate
As = map(int, input().split())
xs = sorted([x for x in Counter(As).values()]) + [10**18]
Xs = accumulate(xs)

N = len(xs) - 1
rs = [0]*I
mny = N+1
for l, (x, X) in enumerate(zip(xs[1:], Xs)):
    l += 2
    y = X//(x+1) + (N-l+1) + 1
    for i in range(y, mny):
        rs[i-1] = X//(i-(N-l+1))
    mny = min(y, mny)
for r in rs:
    print(r)

Solution (Python):
I = int(input())
from collections import Counter
from itertools import accumulate
As = map(int, input().split())
xs = sorted([x for x in Counter(As).values()]) + [10**18]
Xs = accumulate(xs)

N = len(xs) - 1
rs = [0]*I
mny = N+1
for l, (x, X) in enumerate(zip(xs[1:], Xs)):
    l += 2
    y = X//(x+1) + (N-l+1) + 1
    if y-(N-l+1) > 0 and x <= X//(y-(N-l+1)):
        y+=1
    for i in range(y, mny):
        rs[i-1] = X//(i-(N-l+1))
    mny = min(y, mny)
for r in rs:
    print(r)

Solution (Python):
I = int(input())
from collections import Counter
from itertools import accumulate
As = map(int, input().split())
xs = sorted([x for x in Counter(As).values()]) + [10**18]
Xs = accumulate(xs)

def bsearch(target, min_i, max_i, func):
    
    if func(max_i) <= target:
        return max_i
    if target < func(min_i):
        return min_i - 1
    index = (max_i + min_i)//2
    while True:
        if func(index) <= target:
            if target < func(index+1):
                return index
            index, min_i = (index+1 + max_i)//2, index+1
            continue
        index, max_i = (index-1 + min_i)//2, index-1


N = len(xs) - 1
rs = [0]*I
mny = N+1
for l, (x, X) in enumerate(zip(xs[1:], Xs)):
    l += 2
    y = bsearch(0, N-l+2, N+1, lambda k: x > X//(k-(N-l+1)))
    y+=1
    
    for i in range(y, mny):
        rs[i-1] = X//(i-(N-l+1))
    mny = min(y, mny)
for r in rs:
    print(r)

Solution (Python):
import bisect
N = int(input())
count = {}
for x in map(int, input().split()):
    count[x] = count.get(x, 0) + 1

a = sorted(count.values())
sums = a[:]
n = len(a)
for i in range(1, n):
    sums[i] += sums[i-1]
    
def check(k, x):
    pos = bisect.bisect_right(a, x)
    if pos == 0:
        return x * n >= k * x
    return sums[pos-1]+ x * (n - pos) >= k * x

x = N
for k in range(1, N + 1):
    while not check(k, x):
        x -= 1
    print(x)

Solution (Python):
import bisect
N = int(input())
count = {}
for x in map(int, input().split()):
    count[x] = count.get(x, 0) + 1

a = sorted(count.values())
sums = a[:]
n = len(a)
for i in range(1, n):
    sums[i] += sums[i-1]
    
def check(k, x):
    pos = bisect.bisect_right(a, x)
    if pos == 0:
        return x * n >= k * x
    return sums[pos-1]+ x * (n - pos) >= k * x

x = 0
res = []
for k in range(N, 0, -1):
    while check(k, x+1):
        x += 1
    res.append(x)
    
for x in res[::-1]:
    print(x)

Solution (Python):
import sys
input = sys.stdin.readline
import bisect
from collections import Counter
def solve():
  n = int(input())
  a = sorted(list(int(i) for i in input().split()))
  c = Counter(a)
  val = list(c.values())
  val.sort()
  ans = [0]*(n+1)
  t = len(val)
  for i in range(1,n+1):
    place = bisect.bisect_left(val,i)
    ans[i] = ans[i-1]+t-place
  for i in range(1,n+1):
    ok = 0
    ng = n+1
    while ng-ok > 1:
      mid = (ok+ng)//2
      if ans[mid] >= i*mid:
        ok = mid
      else:
        ng = mid
    print(ok)
  
solve()

Solution (Python):
from collections import Counter

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

cntA = Counter(As)
cntCntA = Counter(cntA.values())

accDs = [cntCntA[0]]
for i in range(1, N+1):
    accDs.append(accDs[-1] + cntCntA[i])

accKDs = [0]
for i in range(1, N+1):
    accKDs.append(accKDs[-1] + i*cntCntA[i])

fXs = [0]
for X in range(1, N+1):
    fXs.append((accKDs[X] + X*(accDs[N]-accDs[X])) // X)

anss = [0] * (N+1)
for X, fX in enumerate(fXs):
    anss[fX] = X

for i in reversed(range(N)):
    if anss[i] == 0:
        anss[i] = anss[i+1]

print('\n'.join(map(str, anss[1:])))

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



def bi_search(k):
    ok = 0
    ng = n // k + 1
    while ng > ok + 1:
        mid = (ng + ok) // 2
        if calc(mid, k):
            ok = mid
        else:
            ng = mid
    return ok


def calc(x, k):
    
    l = bisect_left(L, (x, 0))
    
    if kv_acc[l - 1] + acc[l] * x >= k * x:
        return True
    else:
        return False




n = I()
A = LI()
L = [(0, 0)] + sorted([(k, v) for k, v in Counter(Counter(A).values()).items()])
m = len(L)
acc = [0] * (m + 1)
for i in range(m - 1, -1, -1):
    acc[i] = acc[i + 1] + L[i][1]

kv_acc = list(accumulate([k * v for k, v in L]))
for k in range(1, n + 1):
    print(bi_search(k))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
types = {}
for i in A: types[i] = types.get(i, 0) + 1
A = sorted([types[k] for k in types], reverse=True)
L = len(A)
cumsum = [0 for i in range(L+1)]
for i in range(L-1, -1, -1):
    cumsum[i] = A[i] + cumsum[i+1]



def getMidPoint(lo, hi, O):
    if lo >= hi: return lo
    mid = lo + (hi - lo+1) // 2
    if A[mid] > O:
        return getMidPoint(mid, hi, O)
    else:
        return getMidPoint(lo, mid-1, O)

getMid = [getMidPoint(0, L - 1, o) for o in range(N+1)]


def calc(O):
    

    mid = getMid[O]
    if A[mid] < O: mid = - 1
    return (mid+1) + cumsum[mid+1] // O

for K in range(1, N+1):
    def getO(lo, hi):
        if lo >= hi: return lo
        mid = lo + (hi - lo+1) // 2
        if calc(mid) < K:
            return getO(lo, mid - 1)
        else:
            return getO(mid, hi)
        
    print(getO(0, N))

Solution (Python):
import sys
input = sys.stdin.readline


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


from collections import Counter
import bisect

l = Counter(A).most_common()
l = [b for a, b in l]
M = len(l)
l.sort()
p = sum(l)

maximum_operation = [0] * N

ll = []
for x in reversed(range(1, N+1)):
    a = bisect.bisect_left(l, x)
    if a == 0:
        b = M*x
        c = 0
    elif a >= M:
        b = 0
        c = p
    else:
        b = (M-a)*x
        c = sum(l[0:a]) 
    ll.append((b + c)/x)

for K in range(M):
    maximum_operation[K] = N - bisect.bisect_left(ll, K+1)

for m in maximum_operation:
    print(m)

Solution (Python):
import bisect
import sys
input = sys.stdin.readline

n = int(input())
a = [int(item) for item in input().split()]
cnt = [0] * (n + 1)
for item in a:
    cnt[item] += 1
cnt.sort()
cumsum = [0] * (n + 2)
for i in range(n+1):
    cumsum[i+1] = cumsum[i] + cnt[i]

indexes = [0] * (n+1)
for i in range(n+1):
    indexes[i] = bisect.bisect_left(cnt, i) - 1

ans = []
for i in range(n):
    if cnt[i+1] == 0:
        ans.append(0)
        continue
    l = 0; r = n+1
    while r - l > 1:
        mid = (l + r) // 2
        index = indexes[mid]
        if index <= i:
            l = mid
            continue
        num = index - i
        if mid * num <= cumsum[index + 1]:
            l = mid
        else:
            r = mid
    ans.append(l)

ans.reverse()
print("\n".join([str(item) for item in ans]))

Solution (Python):
n, *a = open(0).read().split()
n = int(n)
a = list(map(int, a))
sum = [0] * -~n
o = [0] * -~n
ct = [0] * -~n
b = []
for i in a:
    ct[i] += 1
for i in range(1, n + 1):
    if ct[i]:
        b.append(i)
b.sort(key=lambda x: ct[x])

for i in range(len(b)):
    sum[i] += (sum[i - 1] if i else 0) + ct[b[i]]

j = len(b) - 1
cnt = 0
for i in range(1, n + 1)[::-1]:
    while j >= 0 and ct[b[j]] >= i:
        cnt += 1
        j -= 1
    o[i] = (sum[j] if j >= 0 else 0) // i + cnt

ans = [0]
j = n
for i in range(1, n + 1):
    while j and o[j] < i:
        j -= 1
    ans.append(j)

print(*ans[1:])

Solution (Python):
from collections import Counter
n = int(input())
c = Counter(map(int, input().split()))
cnt = sorted(c.values())

x = [0]*(n+1)
ad = [0]*(n+1)

for i in cnt:
    x[0] += 1
    x[i] -= 1
    ad[i] += i
    ad[-1] -= i

for i in range(n):
    x[i+1] += x[i]
    ad[i+1] += ad[i]

b = [0]*(n+1)
for i in range(n):
    b[i] = x[i] + ad[i]//(i+1)

prev = 0
ans = [0]*n
for i in reversed(range(n)):
    if prev !=b[i]:
        for j in range(prev, b[i]):
            ans[j] = i+1
        prev = b[i]
print(*ans, sep="\n")

Solution (Python):
import collections
import numpy as np












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

counter = collections.Counter(a)        
nums = list(counter.values())           
num_counter = collections.Counter(nums) 
lastest_add = np.count_nonzero(nums)    
building, longests = [0], [0]
for i in range(1, n+1):                 
    appended = building[-1] + lastest_add   
    building.append(appended)               
    longests.append(appended // i)          
    lastest_add -= num_counter[i]           


lastest_longest = 0
k_most = []
for i, x in enumerate(reversed(longests)):
    while x > lastest_longest:
        lastest_longest += 1
        k_most.append(n-i)

k_most.extend([0]*(n-len(k_most)))      

for longests_num in k_most:
    print(longests_num)

Solution (Python):
from collections import Counter
N = int(input())

C = list(Counter(map(int, input().split())).values())
C.sort()

rest = N
removed = 0
for K in range(1, N + 1):
    d = K - removed
    while C and C[- 1] > rest//d:
        rest -= C[- 1]
        C.pop()
        removed += 1
        d -= 1
    print(rest//d)

Solution (Python):
from collections import Counter
N = int(input())
C = sorted(list(Counter(map(int, input().split())).values()))

rest = N
removed = 0
for K in range(1, N + 1):
    d = K - removed
    while C and C[- 1] > rest//d:
        rest -= C[- 1]
        C.pop()
        removed += 1
        d -= 1
    print(rest//d)

Solution (Python):

from collections import Counter
from itertools import accumulate

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

B = list(Counter(A).values())

C = [0] * N 
for i in B:
    C[i-1] += 1

F = list(accumulate(C))

S = [0] * N
f = [0] * N
S[0] = f[0] = sum(C) 
for i in range(2, N+1):
    S[i-1] = (S[i-2] + C[i-1] + S[0] - F[i-1] ) 
    f[i-1] = S[i-1] / i

f.sort()
n = 0     
K = 1
    
while K != N+1:
    if K <= f[n]:
        print(N-n)
        K += 1
    else:
        n += 1
    if n == N:
        for i in range(N-K+1):
            print(0)
        K = N+1

Solution (Python):
N = int(input())
A = map(int, input().split())
C = [0]*N
for a in A:
    C[a - 1] += 1
D = [0]*(N + 1)
for c in C:
    D[c] += 1

Dk_accum = [0]*(N + 1)
for i in range(1, N + 1):
    Dk_accum[i] = Dk_accum[i - 1] + i*D[i]
    
D_sum = sum(D)
D_accum = [0]*(N + 2)
D_accum[0] = D_sum
for i in range(1, N + 1):
    D_accum[i] = D_accum[i - 1] - D[i - 1]
    
F = [0]*(N + 1)
for i in range(1, N + 1):
    F[i] = (Dk_accum[i]//i + D_accum[i + 1])

i = N
for K in range(1, N + 1):
    while i > 0 and K > F[i]:
        i -= 1
    print(i)

Solution (Python):

import sys
from collections import Counter
from itertools import accumulate
from collections import defaultdict
INF = float("inf")


def solve(N: int, A: "List[int]"):
    c = Counter(A)
    d = Counter(c.values())
    d = tuple(accumulate([d[i] for i in range(N, -1, -1)]))[::-1]
    S = [0]*(N+1)
    for i in range(1, N+1):
        S[i] = S[i-1] + d[i]

    def isOK(y):
        return S[y] < K*y

    def binary_search(x):
        ng = -1
        ok = len(x)+1

        while abs(ok - ng) > 1:
            mid = (ok + ng)//2
            if isOK(mid):
                ok = mid
            else:
                ng = mid
        return ng, ok

    for K in range(1, N+1):
        ng, ok = binary_search(range(N))
        print(ng)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)


if __name__ == '__main__':
    main()

Solution (Python):


def f(m,k):
    if m == 0: return 0
    if m < k: return 0


    z = 0
    if acc[m]//k >= c[m]:
        return acc[m]//k
    else:
        return f(m-1,k-1)


import sys

readline = sys.stdin.readline 

from itertools import accumulate

n = int(input())
a = [int(i) for i in readline().split()]

res = [0]*(n+1)
for i in a: res[i] += 1

c = [0]
for i in res:
    if i > 0: c.append(i)
c.sort()

l = len(c)-1

acc = list(accumulate(c))


res = [n]+[acc[m]//c[m] for m in range(1,l+1)]





m = l
for k in range(1,n+1):
    k -= l-m
    if res[m] >= k:
        print(acc[m]//k)
    else:

        while res[m] < k:
            m -= 1
            k -= 1
        print(acc[m]//(k))

Solution (Python):

N=int(raw_input())
AN=map(int, raw_input().split())

BN=[0 for i in xrange(N)]
for i in AN:
    BN[i-1] += 1
BN.sort()

LN = [0 for i in xrange(N)]
s = 0
j = 0
try:
    for X in xrange(1, N+1):
        while j<N and  BN[j] < X:
            s += BN[j]
            j += 1
        LN[X-1] = int((s + X*(N - j)) / X)
except IndexError:
    pass

KN = [0 for i in xrange(N)]
for i in xrange(len(LN)):
    KN[LN[i]-1] = i+1

for i in xrange(len(KN)-2, -1, -1):
    if KN[i] == 0:
        KN[i] = KN[i+1]

for i in KN:
    print (str(i))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    c = sorted(collections.Counter(LI()).values(), reverse=True) + [0]
    ci = 0
    t = n
    r = [0]
    for i in range(n,0,-1):
        while c[ci] > i:
            ci += 1
        t -= ci
        r.append(t // i)

    rr = []
    r.reverse()
    ri = 0
    for i in range(n,0,-1):
        while r[ri] >= i:
            ri += 1
        rr.append(ri)

    rr.reverse()

    return JA(rr,"\n")


print(main())

Solution (Python):

from bisect import bisect_left

def isOK(c, k, N, L, cum_sum):
    i = bisect_left(L, c)
    s = c * (N - i) + cum_sum[i];
    return (s >= c * k)

N = int(input())
D = list(map(int, input().split()))
freq = [0] * N
for d in D:
    freq[d - 1] += 1
    
freq.sort()
cum_sum = [0] * (N + 1)
for i in range(N):
    cum_sum[i + 1] = cum_sum[i] + freq[i]
    
for k in range(1, N + 1):
    l = 0
    r = int(N / k) + 1
    while l + 1 < r:
        c = int((l + r) / 2)
        ok = isOK(c, k, N, freq, cum_sum)
        if ok:
            l = c
        else:
            r = c
    print(l)

Solution (Python):
N=int(raw_input())
AN=map(int, raw_input().split())

BN=[0 for i in xrange(N)]
for i in AN:
    BN[i-1] += 1
BN.sort()

LN = [0 for i in xrange(N)]
s = 0
j = 0
try:
    for X in xrange(1, N+1):
        while j<N and  BN[j] < X:
            s += BN[j]
            j += 1
        LN[X-1] = (s + X*(N - j)) / X
except IndexError:
    pass

KN = [0 for i in xrange(N)]
for i in xrange(len(LN)):
    KN[LN[i]-1] = i+1

for i in xrange(len(KN)-2, -1, -1):
    if KN[i] == 0:
        KN[i] = KN[i+1]

for i in KN:
    print (str(i))

Solution (Python):
import sys 
import collections as cl


N=int(input())
A=list(map(int,sys.stdin.readline().split()))
c=cl.Counter(A)
NumberTupleList=c.most_common()
NumberList=[x[1] for x in NumberTupleList[::-1]]
LengthOfNumberList=len(NumberList)
FormulaList=[0 for i in range(N)]
flag=0
S=sum(NumberList)
for x in range(1,N+1):
    while flag<LengthOfNumberList and NumberList[flag]<=x:
        flag+=1
    if flag<LengthOfNumberList:
        FormulaList[x-1]=(sum(NumberList[:flag])+x*(LengthOfNumberList-flag))/x
    else:
        FormulaList[x-1]=S/x
pin=N-1
for K in range(1,N+1):
    while pin>=0 and K>FormulaList[pin]:
        pin-=1
    print(pin+1)

Solution (Python):
from collections import defaultdict
from bisect import bisect
N = int(input())
A = list(map(int,input().split()))

d = defaultdict(lambda:0)

for i in range(N):
    d[A[i]] += 1

C = [0]*(N+1)

for i in d:
    C[d[i]] += 1

C1 = [0]*(N+1)
C2 = [0]*(N+1)

for i in range(N):
    C1[i+1] = C1[i] + (i+1)*C[i+1]
    C2[i+1] = C2[i] + C[i+1]

l = [0]*N
for n in range(N):
    l[n] = C1[n+1]//(n+1)+C2[N]-C2[n+1]
    l[n] *= -1


for i in range(N):
    print(bisect(l,-(i+1)))

Solution (Python):
from collections import defaultdict
from bisect import bisect
N = int(input())
A = list(map(int,input().split()))

d = defaultdict(lambda:0)

for i in range(N):
    d[A[i]] += 1

C = [0]*(N+1)

for i in d:
    C[d[i]] += 1

C1 = [0]*(N+1)
C2 = [0]*(N+1)

for i in range(N):
    C1[i+1] = C1[i] + (i+1)*C[i+1]
    C2[i+1] = C2[i] + C[i+1]

l = [0]*N
for n in range(N):
    l[n] = C1[n+1]//(n+1)+C2[N]-C2[n+1]
    l[n] *= -1


for i in range(N):
    print(bisect(l,-(i+1)))

Solution (Python):
from collections import defaultdict
from bisect import bisect_right
import sys
sys.setrecursionlimit(10**9)
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
class CountUp:
    def __init__(self, start=0):
        self.index = start-1

    def __call__(self):
        self.index += 1
        return self.index

N = int(input())
A = inpl()
ui = defaultdict(CountUp())
B = []
Ns = 0
for a in A:
    i = ui[a]
    if i >= Ns:
        Ns += 1
        B.append(1)
    else:
        B[i] += 1
B.sort()
C = []
prev = B[0]
n = 0
for b in B:
    if b == prev:
        n += 1
    else:
        C.append((prev,n))
        prev = b
        n = 1
else:
    C.append((prev,n))

f = []
S = 0
T = Ns
nc = 0
nxtc = C[0][0]
for i in range(1,N+1):
    if i == nxtc:
        n = C[nc][1]
        S += i*n
        T -= n
        nc += 1
        if nc < len(C):
            nxtc = C[nc][0]
        else:
            nxtc = None
    f.append(-(S//i + T))



for K in range(1,N+1):
    print(bisect_right(f,-K))

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
B = [0]*(n+1)
C = [0]*(n+1)
for a in A:
    B[a] += 1
    C[B[a]] += 1

X = [0]
for i in range(1,n+1):
    X.append(X[i-1] + C[i])
for j in range(1,n+1):
    X[j] = X[j] // j

ind = n
k = 1
while k<=n:
    if ind<0:
        for _ in range(n-k+1):
            print(0)
        break
    if k<=X[ind]:
        print(ind)
        k += 1
    else:
        ind -= 1

Solution (Python):
import bisect

n = int(input())
A = list(map(int, input().split()))
counts = [0]*(n)
for a in A:
    counts[a-1] += 1
counts.sort()

cumsum = []
num = 0
for count in counts:
    num += count
    cumsum.append(num)

answers = [0]*(n)
for i in range(1, n+1):
    idx = bisect.bisect_right(counts, i)
    left = cumsum[idx-1]
    right = (n-idx)*i
    K = (right+left)//i
    answers[K-1] = i

now = 0
for i in range(n-1, -1, -1):
    if answers[i] == 0:
        answers[i] = now
    now = answers[i]

for ans in answers:
    print(ans)

Solution (Python):
import bisect

n = int(input())
A = list(map(int, input().split()))
counts = [0]*(n)
for a in A:
    counts[a-1] += 1
counts.sort()

cumsum = []
num = 0
for count in counts:
    num += count
    cumsum.append(num)

answers = [0]*(n)
for i in range(1, n+1):
    idx = bisect.bisect_right(counts, i)
    left = cumsum[idx-1]
    right = (n-idx)*i
    K = (right+left)//i
    answers[K-1] = i

now = 0
for i in range(n-1, -1, -1):
    if answers[i] == 0:
        answers[i] = now
    now = answers[i]

for ans in answers:
    print(ans)

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

A.sort()
D = [1]
t = A[0]
for i in range(1, N):
  if A[i] == t:
    D[-1] += 1
  else:
    D.append(1)
    t = A[i]

D.sort()
L = len(D)
S = [0] * L
S[0] = D[0]
for i in range(1, L):
  S[i] = S[i - 1] + D[i]

def hersCode(n):
  ok = 0
  ng = N + 1
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if nasu(mid, n):
      ok = mid
    else:
      ng = mid
  return ok

def honya(n):
  ok = -1
  ng = L
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if D[mid] >= n:
      ok = mid
    else:
      ng = mid
  return ok + 1

def nasu(x, n):
  a = honya(x)
  ans = a * x + S[L - a - 1]
  if ans >= n * x:
    return True
  else:
    return False

D.sort(reverse = True)
for i in range(1, N + 1):
  if L < i:
    print(0)
    continue
  print(hersCode(i))

Solution (Python):
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

C = [0] * (N + 1)
S = [0] * (N + 1)

for a in Counter(A).values() :
    C[a] += 1
    S[a] += a

for i in range(1, N + 1) :
    C[i] += C[i-1]
    S[i] += S[i-1]

for K in range(1, N + 1) :
    ok, ng = 0, N + 1
    while ng - ok > 1 :
        mid = (ng + ok) // 2
        if S[mid] + mid * (C[-1] - C[mid]) >= K * mid :
            ok = mid
        else :
            ng = mid
    print(ok)

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from collections import Counter
    n=int(input())
    A=list(Counter(map(int,input().split())).values())
    A.sort()
    m=len(A)
    S=[0]*(m+1) 
    for i in range(m): S[i+1]=S[i]+A[i]
    
    from bisect import bisect_left
    p=n
    i=bisect_left(A,p) 
    for k in range(1,n+1):
        while(S[i]+p*(m-i)<k*p): 
            p-=1
            i=bisect_left(A,p)
        print(p)
resolve()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def bin_sort(A,n_min=None,n_max=None):
    if(n_min is None): n_min=min(A)
    if(n_max is None): n_max=max(A)
    bin=[0]*(n_max-n_min+1)
    for a in A: bin[a-n_min]+=1
    B=[]
    for i in range(n_min,n_max+1): B[len(B):len(B)]=[i]*bin[i-n_min]
    return B

def resolve():
    n=int(input())
    A=[0]*n
    for a in map(int,input().split()): A[a-1]+=1
    A=bin_sort(A,0,n)
    S=[0]*(n+1)
    for i in range(n): S[i+1]=S[i]+A[i]
    
    p=n; i=n
    for k in range(1,n+1):
        while(1):
            while(1):
                if(i<=0 or A[i-1]<p): break
                i-=1
            if(S[i]+p*(n-i)>=k*p): break
            p-=1
        print(p)
resolve()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def bin_sort(A,n_min=None,n_max=None):
    if(n_min is None): n_min=min(A)
    if(n_max is None): n_max=max(A)
    bin=[0]*(n_max-n_min+1)
    for a in A: bin[a-n_min]+=1
    B=[]
    for i in range(n_min,n_max+1): B.extend([i]*bin[i-n_min])
    return B

def resolve():
    n=int(input())
    A=[0]*n
    for a in map(int,input().split()): A[a-1]+=1
    A=bin_sort(A,0,n)
    S=[0]*(n+1)
    for i in range(n): S[i+1]=S[i]+A[i]
    
    p=n; i=n
    for k in range(1,n+1):
        while(1):
            while(1):
                if(i<=0 or A[i-1]<p): break
                i-=1
            if(S[i]+p*(n-i)>=k*p): break
            p-=1
        print(p)
resolve()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def bin_sort(A,n_min=None,n_max=None):
    if(n_min is None): n_min=min(A)
    if(n_max is None): n_max=max(A)
    bin=[0]*(n_max-n_min+1)
    for a in A: bin[a-n_min]+=1
    B=[]
    for i in range(n_min,n_max+1):
        for _ in range(bin[i-n_min]): B.append(i)
    return B

def resolve():
    n=int(input())
    A=[0]*n
    for a in map(int,input().split()): A[a-1]+=1
    A=bin_sort(A,0,n)
    S=[0]*(n+1)
    for i in range(n): S[i+1]=S[i]+A[i]
    
    p=n; i=n
    for k in range(1,n+1):
        while(1):
            while(1):
                if(i<=0 or A[i-1]<p): break
                i-=1
            if(S[i]+p*(n-i)>=k*p): break
            p-=1
        print(p)
resolve()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def bin_sort(A,n_min=None,n_max=None):
    if(n_min is None): n_min=min(A)
    if(n_max is None): n_max=max(A)
    bin=[0]*(n_max-n_min+1)
    for a in A: bin[a-n_min]+=1
    B=[]
    for i in range(n_min,n_max+1): B+=[i]*bin[i-n_min]
    return B

def resolve():
    n=int(input())
    A=[0]*n
    for a in map(int,input().split()): A[a-1]+=1
    A=bin_sort(A,0,n)
    S=[0]*(n+1)
    for i in range(n): S[i+1]=S[i]+A[i]
    
    p=n; i=n
    for k in range(1,n+1):
        while(1):
            while(1):
                if(i<=0 or A[i-1]<p): break
                i-=1
            if(S[i]+p*(n-i)>=k*p): break
            p-=1
        print(p)
resolve()

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

c = [0] * (N + 1)
Dx = [0] * (N + 1)
for a in A:
    c[a] += 1 
    Dx[c[a]]+=1
    

Sx=[0]
for j in range(1,N+1):
    Sx.append(Sx[j-1]+Dx[j])

for h in range(1,N+1):
    Sx[h]=Sx[h]/h

x=N
k=1
while k<N+1:
    if x<0:
        for _ in range(N-k+1):
            print(0)
        exit(0)
    if k<=Sx[x]:
        print(x)
        k+=1
    else:
        x-=1

Solution (Python):
n = int(input())
arr = list(map(int,input().split()))

from collections import Counter
c = Counter(arr)
c = list(c.values())
c.sort()
s = n

sol = []
removed = 0
for k in range(1,n+1):
    rest = k - removed
    while c and c[-1] > s//rest:
        s -= c[-1]
        c.pop()
        rest -= 1
        removed += 1
    sol.append(s//rest)

print("\n".join(map(str,sol)))

Solution (Python):
import bisect
from collections import Counter
import sys
input = sys.stdin.buffer.readline

N = int(input())
a = list(map(int, input().split()))
c = sorted(list(Counter(a).values()))
M = len(c)
cs = [0]*(M+1)
for i in range(M):
    cs[i+1] = cs[i] + c[i]

kmax = [0] * (N+1)
for i in range(1, N+1):
    j = bisect.bisect_left(c, i) if i <= c[-1] else M
    kmax[i] = (cs[j] + i * (M-j)) // i

idx = N
for k in range(1, N+1):
    while k > kmax[idx]:
        if idx == 0:
            break
        idx -= 1
    print(idx)

Solution (Python):
import bisect
N=int(input())
A=list(map(int,input().split()))

D={}
for i in range(N):
    if A[i] not in D:
        D[A[i]]=1
    else:
        D[A[i]]+=1
        
D[0]=0

D=list(D.values())

D.sort()

B=[D[0]]
for i in range(1,len(D)):
    B.append(B[-1]+D[i])
D=D+[10**15]



cnt=N
for i in range(1,N+1):
    for j in range(N+1):
        C=bisect.bisect_left(D,cnt+0.1)
        if i*cnt<=B[C-1]+cnt*(len(B)-1-C+1):
            print(cnt)
            break
        else:
            cnt-=1

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from collections import Counter
    n=int(input())
    A=list(Counter(map(int,input().split())).values())
    A.sort()
    m=len(A)
    S=[0]*(m+1) 
    for i in range(m): S[i+1]=S[i]+A[i]
    
    p=n
    i=m
    from bisect import bisect_left
    for k in range(1,n+1):
        while(1):
            
            while(1):
                if(i<=0 or A[i-1]<p): break
                i-=1
            if(S[i]+p*(m-i)>=k*p): break 
            p-=1 
        print(p)
resolve()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from collections import Counter
    n=int(input())
    A=list(Counter(map(int,input().split())).values())
    A.sort()
    m=len(A)
    S=[0]*(m+1) 
    for i in range(m): S[i+1]=S[i]+A[i]
    
    p=n
    i=m-1
    from bisect import bisect_left
    for k in range(1,n+1):
        while(1):
            
            i=bisect_left(A,p)
            if(S[i]+p*(m-i)>=k*p): break
            p-=1 
        print(p)
resolve()

Solution (Python):
import bisect as b
n = int(input())

d = [0]*n
for el in map(int, input().split()):
    d[el-1] += 1

d.sort()

s = [0]*(n+1)
for i in range(n):
    s[i+1] = s[i] + d[i]

for k in range(1, n+1):
    l = 0
    r = n//k + 1
    while(l+1 < r):
        c = (l+r)//2
        i = b.bisect_left(d, c)
        total = s[i] + c * (n - i)
        if total >= k * c:
            l = c
        else:
            r = c
    print(l)

Solution (Python):
import sys
input = sys.stdin.readline

from collections import Counter
from itertools import accumulate
from math import floor
from bisect import bisect_left


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

    c = Counter(a)
    c = list(c.values())

    d = Counter(c)
    d_li = [0] * (n + 1)
    for k, v in d.items():
        d_li[k] = v

    dk_acm = list(accumulate(d_li))

    kdk_acm = [0]
    for k, e in enumerate(d_li[1:], 1):
        kdk_acm.append(kdk_acm[-1] + k * e)

    def f(x):
        kdk_sm = kdk_acm[x]
        dk_sm = dk_acm[n] - dk_acm[x]

        return floor((kdk_sm + x * dk_sm) / x)

    fs = [float("inf")] + [f(x) for x in range(1, n + 1)]
    fs = fs[::-1]

    for k in range(1, n + 1):
        print(n - bisect_left(fs, k))


if __name__ == "__main__":
    main()