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):
import sys
input = sys.stdin.readline
n=int(input())
a=[int(j) for j in input().split()]
from collections import Counter
c=Counter(a)
l=c.most_common()
ll=[]
for i,j in l:
    ll.append(j)
ll.sort()
s=sum(ll)
rem=0
for k in range(1,n+1):
    rest=k-rem
    while ll and ll[-1]>s//rest:
        s-=ll[-1]
        ll.pop()
        rem+=1
        rest-=1
    print(s//rest)

Solution (Python):
from collections import *
MAX = 3*pow(10,5) + 2
n = int(input())
a = list(map(int,input().split()))
b = [0 for i in range(MAX)]
c = [0 for i in range(MAX)]
for i in a:
    b[i] += 1
for i in b:
    c[i] += 1
s = n
last = n
print(last)
for k in range(2,n+1):
    while(s//k < last):
        best = min(last,s//k)
        for i in range(last,best,-1):
            s -= c[i]
            c[i-1] += c[i]
            c[i] = 0
        last = best
    print(last)

Solution (Python):
import bisect
n = int(input())
a = list(map(int,input().split()))
a.sort()


b = []
cnt = 1
for i in range(1,n):
    if a[i] == a[i-1]:
        cnt += 1
    else:
        b.append(cnt)
        cnt = 1
b.append(cnt)
b.sort()


p = [0]*(n+1)
for i in range(1,n+1):
    kp = bisect.bisect_left(b,i)
    p[i] = p[i-1]+len(b)-kp


for k in range(1,n+1):
    ok = 0
    ng = n+1
    while abs(ng-ok) > 1:
        mid = (ok+ng)//2
        if p[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 bisection(l,r,f,discrete=True,left=True):
    eps=1 if discrete else 10**-12
    if((not left)^f(r)): return r if left else r+1
    elif(left^f(l)): return l-1 if left else l
    while(r-l>eps):
        h=(l+r)//2 if discrete else (l+r)/2
        if((not left)^f(h)): l=h
        else: r=h
    return h if not discrete else l if left else r

def resolve():
    from collections import Counter
    from bisect import bisect_left
    n=int(input())
    A=Counter(map(int,input().split()))
    A=list(A.values())
    A.sort()
    m=len(A)
    S=[0]*(m+1)
    for i in range(m):
        S[i+1]=S[i]+A[i]
    for k in range(1,n+1):
        def check(p):
            i=bisect_left(A,p)
            return S[i]+(m-i)*p>=k*p
        print(bisection(0,n//k+1,check))
resolve()

Solution (Python):
from collections import Counter
from itertools import groupby, accumulate

n = int(input())
aaa = list(map(int, input().split()))
cnt = sorted(Counter(aaa).values())

remain = len(cnt)
total = 0
kkk = [0] * (n + 1)
p = 1

for c, itr in groupby(cnt):
    l = len(list(itr))
    for i in range(p, c + 1):
        kkk[remain + total // i] = i
    remain -= l
    total += c * l
    p = c + 1

for i in range(p, n + 1):
    kkk[remain + total // i] = i

kkk.reverse()
kkk = list(accumulate(kkk, func=max))
kkk.reverse()

print(*kkk[1:])

Solution (Python):
from collections import Counter
import bisect
N=int(input())
A=list(map(int,input().split()))
C=list(Counter(A).values())
C.sort()
L=len(C)


D=[L-bisect.bisect_left(C,x) for x in range(N+1)]
S=[0]
for n in range(1,N+1):
    S.append(S[-1]+D[n])


T=[x/S[x] for x in range(1,N+1)]
for K in range(1,N+1):
    print(bisect.bisect_right(T,1/K))

Solution (Python):
from collections import Counter
from itertools import groupby


def bin_search(k, greater_count, smaller_sum):
    l = 0
    r = n + 1
    while l < r - 1:
        m = (l + r) // 2
        gc = greater_count[m]
        ss = smaller_sum[m]
        if gc + ss // m >= k:
            l = m
        else:
            r = m
    return l


n = int(input())
aaa = list(map(int, input().split()))
cnt = sorted(Counter(aaa).values())


greater_count = [0] * (n + 2)  
smaller_sum = [n] * (n + 2)  

remain = greater_count[1] = len(cnt)
total = smaller_sum[1] = 0

cnt_grp = [(c, len(list(itr))) for c, itr in groupby(cnt)]

for (c, l), (c2, _) in zip(cnt_grp, cnt_grp[1:]):
    remain -= l
    total += c * l
    for i in range(c + 1, c2 + 1):
        greater_count[i] = remain
        smaller_sum[i] = total





buf = []
for k in range(1, len(cnt) + 1):
    buf.append(bin_search(k, greater_count, smaller_sum))

buf.extend([0] * (n - len(cnt)))

print(*buf)

Solution (Python):
from collections import Counter
from itertools import groupby


def bin_search(k, greater_count, smaller_sum):
    l = 0
    r = n + 1
    while l < r - 1:
        m = (l + r) // 2
        gc = greater_count[m]
        ss = smaller_sum[m]
        if gc + ss // m >= k:
            l = m
        else:
            r = m
    return l


n = int(input())
aaa = list(map(int, input().split()))
cnt = sorted(Counter(aaa).values())


greater_count = [0] * (n + 2)  
smaller_sum = [n] * (n + 2)  

remain = greater_count[1] = len(cnt)
total = smaller_sum[1] = 0
pointer = 2

for c, itr in groupby(cnt):
    l = len(list(itr))
    remain -= l
    total += c * l
    for i in range(pointer, c + 2):
        greater_count[i] = remain
        smaller_sum[i] = total
    pointer = c + 2





buf = []
for k in range(1, len(cnt) + 1):
    buf.append(bin_search(k, greater_count, smaller_sum))

buf.extend([0] * (n - len(cnt)))

print(*buf)

Solution (Python):
import itertools
import collections
N = int(input())
A = [int(_) for _ in input().split()]
c = sorted(collections.Counter(A).values())
acc = list(itertools.accumulate([0] + c))
n = len(acc) - 1
j = 0
for i in range(1, n + 1):
    r = 0
    while i - j > 0:
        if (i - j) * c[-1 - j] <= acc[-1 - j]:
            r = acc[-1 - j] // (i - j)
            break
        else:
            j += 1
    print(r)
for _ in range(N - n):
    print(0)

Solution (Python):
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

A = np.array(A, dtype=int)
C = np.bincount(A, minlength=N + 2)
D = np.bincount(C, minlength=N + 2)

ld = (D * np.arange(len(D))).cumsum()
ud = D[::-1].cumsum()[::-1]

X = np.arange(1, N + 1, dtype=int)

L = np.zeros(N + 1, dtype=int)
L[X] = (ld[X] + X * ud[X + 1]) // X

i = len(L) - 1
for k in range(1, N + 1):
    while i > 0 and L[i] < k:
        i -= 1
    print(i)

Solution (Python):
import collections
import bisect
n=int(input())
a=collections.Counter(map(int,input().split()))
a=list(a.values())
a.sort()
b=[0]*len(a)
b[0]=a[0]
for i in range(len(a)-1):
    b[i+1]=b[i]+a[i+1]
s=sum(a)
ans=[i for i in range(0,n+1)]
ans=ans[::-1]
for t in range(1,n+1):
    ANS=ans[n+(-n//t):]
    for A in ANS:
        z=bisect.bisect_right(a,A)
        if A*t<=(b[z-1] if z>=1 else 0)+A*(len(b)-z):
            print(A)
            break

Solution (Python):
import collections
import bisect
n=int(input())
a=collections.Counter(map(int,input().split()))
a=list(a.values())
a.sort()
b=[0]*len(a)
b[0]=a[0]
for i in range(len(a)-1):
    b[i+1]=b[i]+a[i+1]
s=sum(a)

ans=[i for i in range(0,n+1)]
ans=ans[::-1]
for t in range(1,n+1):
    ANS=ans[n+(-n//t):]
    
    for A in ANS:
        z=bisect.bisect_right(a,A)
        
        if A*t<=(b[z-1] if z>=1 else 0)+A*(len(b)-z):
            print(A)
            break

Solution (Python):




def main():
  input()
  cards = list(map(int, input().split()))
  counts = [0] * len(cards)
  values = [0] * len(cards)

  for c in cards:
    c -= 1
    values[counts[c]] += 1
    counts[c] += 1

  lengths = []
  used = 0

  for i, v in enumerate(values):
    used += v
    lengths.append(used // (i + 1))

  number = len(lengths) - 1

  for k in range(1, len(cards) + 1):
    while number >= 0 and lengths[number] < k:
      number -= 1
    print(number + 1)


if __name__ == '__main__':
  main()

Solution (Python):
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

C = list(np.bincount(A).tolist())
C.sort()
deleted = 0
S = N


def solve(k):
    global S, deleted

    k -= deleted
    while k > 0 and C[-1] > S // k:
        S -= C.pop()
        deleted += 1
        k -= 1
    if k > 0:
        return S // k
    return 0


for k in range(1, N + 1):
    print(solve(k))

Solution (Python):
import os
import sys



if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))


def test(k):
    bc = np.bincount(A)
    bc.sort()
    bc = bc[np.searchsorted(bc, 1):]
    bc = bc[::-1]
    ret = 0

    while len(bc) >= k:
        bc[:k] -= 1
        bc.sort()
        bc = bc[np.searchsorted(bc, 1):]
        bc = bc[::-1]
        ret += 1
    return ret


def cumsum(it):
    """
    累積和
    :param collections.Iterable it:
    :return:
    """
    s = 0
    ret = []
    for a in it:
        s += a
        ret.append(s)
    return ret


C = [0] * (N + 1)
for a in A:
    C[a] += 1
C.sort()
cs = list(reversed(cumsum(reversed(C))))


def solve(k):
    cnt = N // k
    if C[-1] <= cnt:
        
        
        return cnt

    
    
    
    
    
    
    
    
    
    

    ng = 0
    ok = k
    while abs(ng - ok) > 1:
        i = (ng + ok) // 2
        s = N - cs[-i]
        cnt = s // (k - i)
        max_c = C[-i - 1]
        if max_c <= cnt:
            ok = i
        else:
            ng = i
    if ok < k:
        i = ok
        s = N - cs[-i]
        return s // (k - i)
    else:
        return 0


ans = [0] * N
for k in reversed(range(1, N + 1)):
    ans[k - 1] = solve(k)
print(*ans, sep='\n')

Solution (Python):
def f_distinct_numbers():
    
    from collections import Counter
    N = int(input())
    A = [int(i) for i in input().split()]

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

    cumsum = [0] * (N + 1)  
    judge = [0] * (N + 1)
    for i in range(1, N + 1):
        cumsum[i] = cumsum[i - 1] + d[i]
        judge[i] = cumsum[i] // i

    
    ans = []
    x = N
    for k in range(1, N + 1):
        while x > 0 and k > judge[x]:  
            x -= 1
        ans.append(x)
    return ' '.join(map(str, ans))

print(f_distinct_numbers())

Solution (Python):
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n = int(input())
    aa = list(map(int, input().split()))
    aa = list(Counter(aa).values())
    aa.sort()
    cs = [0]
    s = 0
    for a in aa:
        s += a
        cs += [s]
    
    
    ans = n + 1
    i = len(aa)
    for k in range(1, n + 1):
        while 1:
            while i > 0 and aa[i - 1] >= ans:
                i -= 1
            s = cs[i] + ans * (len(aa) - i)
            if s >= ans * k:
                break
            else:
                ans -= 1
        print(ans)

main()

Solution (Python):
N = int(input())
 
A = list(map(int,input().split()))
 
dic = {}
 
for a in A:
 
    if a not in dic:
        dic[a] = 1
    else:
        dic[a] += 1
 
B = []
for i in dic:
    B.append(dic[i])
 
B.sort()
 
B_sub = B.copy()
 
for i in range(len(B)-1):
    B_sub[i+1] += B_sub[i] 
 
aind = N + 1
nind = len(B) - 1
 

 
for i in range(N):
 
    i += 1
 
    while True:
 
        while nind > 0 and B[nind] > aind - 1:
 
          nind -= 1
 
        if i > len(B):
            print (0)
            break
 
        elif ((len(B) - 1) - nind ) * (aind-1) + B_sub[nind] >= (aind - 1) * i:
            print (aind - 1)
            break
 
        aind -= 1

Solution (Python):
import sys
from collections import Counter
from bisect import bisect_left

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

class BitSum:
    def __init__(self, n):
        self.n = n
        self.table = [0] * (n + 1)

    def update(self, i, x):
        i += 1
        while i <= self.n:
            self.table[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

def main():
    n = int(input())
    aa = list(map(int, input().split()))
    aa = list(Counter(aa).values())
    aa.sort()
    bit = BitSum(len(aa))
    for i, a in enumerate(aa):
        bit.update(i, a)
    
    for k in range(1, n + 1):
        l = 0
        r = n // k + 2
        while l + 1 < r:
            m = (l + r) // 2
            i = bisect_left(aa, m)
            s = bit.sum(i - 1) + m * (len(aa) - i)
            if s >= m * k:
                l = m
            else:
                r = m
        print(l)

main()

Solution (Python):

import sys
import collections

def solve(N: int, A: "List[int]"):
    counter = sorted(list(collections.Counter(A).values()),reverse=True)
    c_index = 0
    k=0
    for i in range(1,N+1):
        k+=1
        if len(counter)<i:
            print(0)
            continue
        while counter[c_index]*k > N and c_index<len(counter)-1:
            N-=counter[c_index]
            c_index+=1
            k-=1
        print(N//k)
    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):

N = int(input())

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

dic = {}

for a in A:

    if a not in dic:
        dic[a] = 1
    else:
        dic[a] += 1

B = []
for i in dic:
    B.append(dic[i])

B.sort()

B_sub = B.copy()

for i in range(len(B)-1):
    B_sub[i+1] += B_sub[i] 

aind = N + 1
nind = len(B) - 1



for i in range(N):

    i += 1

    while True:

        while nind > 0 and B[nind] > aind - 1:

          nind -= 1

        if i > len(B):
            print (0)
            break

        elif ((len(B) - 1) - nind ) * (aind-1) + B_sub[nind] >= (aind - 1) * i:
            print (aind - 1)
            break

        aind -= 1

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

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

from collections import Counter
from itertools import accumulate
import bisect

C=Counter(A)

LIST=sorted(C.values())
LEN=len(LIST)
SUM=[0]+list(accumulate(LIST))
MIN=0
MAX=SUM[-1]

for k in range(1,N+1):
    MIN=0
    while MIN!=MAX:
        mid=(MIN+MAX+1)//2
        x=bisect.bisect_right(LIST,mid)

        if SUM[x]+(LEN-x)*mid>=mid*k:
            MIN=mid
        else:
            MAX=mid-1

    print(MIN)

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

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

from collections import Counter
from itertools import accumulate
import bisect

C=Counter(A)

LIST=sorted(C.values())
LEN=len(LIST)
SUM=[0]+list(accumulate(LIST))
MIN=0
MAX=SUM[-1]

for k in range(1,N+1):
    MIN=0
    while MIN!=MAX:
        mid=(MIN+MAX+1)//2
        x=bisect.bisect_right(LIST,mid)

        if SUM[x]+(LEN-x)*mid>=mid*k:
            MIN=mid
        else:
            MAX=mid-1

    print(MIN)

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

num = [0 for _ in range(N)]
for a in A:
    num[a-1] += 1
num.sort()
cum = [0 for _ in range(N)]
cum[0] = num[0]
for i in range(1, N):
    cum[i] = cum[i-1] + num[i]

index = N - 1
ans = N
for k in range(1, N+1):
    while ans > 0:
        tmp_index = index
        while tmp_index >= 0 and num[tmp_index] > ans:
            tmp_index -= 1
        decided = N - tmp_index - 1
        rest_total = 0 if tmp_index < 0 else cum[tmp_index]
        if rest_total >= ans * (k - decided):
            index = tmp_index
            break
        ans -= 1
    print(ans)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
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 = 10 ** 9 + 7



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


v_acc = [0] * m
ret = 0
for l in range(m - 1, -1, -1):
    ret += L[l][1]
    v_acc[l] = ret


v_acc += [0]



for i in range(1, n + 1):
    ok = 0
    ng = n // i + 1
    while ng > ok + 1:
        mid = (ng + ok) // 2
        lower_num = bisect_right(L, (mid, INF))
        if acc[lower_num - 1] + v_acc[lower_num] * mid >= i * mid:
            ok = mid
        else:
            ng = mid
    print(ok)

Solution (Python):
from collections import Counter
from bisect import bisect_left
from itertools import accumulate



N = int(input())
A = list(map(int, input().split()))
a = list(Counter(A).values())
a.sort()
b = list(accumulate(a))
length = len(a)

for i in range(1, N + 1):
    if i == 1:
        print(b[-1])
    elif len(a) < i:
        print(0)
    else:
        n = b[-1] // i
        for j in reversed(range(1, n + 1)):
            t = bisect_left(a, j)
            if j * i <= b[t - 1] + (length - t) * j:
                print(j)
                break

Solution (Python):
from collections import Counter
from bisect import bisect_left
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
a = list(Counter(A).values())
a.sort()
b = list(accumulate(a + [0]))
s = sum(a)
length = len(a)

for i in range(1, N + 1):
    if i == 1:
        print(s)
    elif len(a) < i:
        print(0)
    else:
        n = s // i
        for j in reversed(range(1, n + 1)):
            t = bisect_left(a, j)
            if j * i <= b[t - 1] + (length - t) * j:
                print(j)
                break

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = list(Counter(A).values())
D = [0] * (N+1)
for k, d in Counter(C).items():
    D[k] = d

ckd, cd = [0] * (N+1), [0] * (N+1)

for i in range(1,N+1):
    cd[i] = cd[i-1] + D[i]
    ckd[i] = ckd[i-1] + i*D[i]

INF = float('inf')
def f(x):
    if x:
        return (x*(cd[-1] - cd[x]) + ckd[x]) // x
    return INF

cur = N
v = f(cur)
for k in range(1,N+1):
    while k > v:
        cur -= 1
        v = f(cur)
    print(cur)

Solution (Python):
from collections import Counter
from itertools import accumulate



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

















cv = Counter(c.values())
max_take = max(cv.keys())

lx = list(accumulate(cv[i] for i in range(max_take + 1)))
rx = list(accumulate(cv[i] * i for i in range(max_take + 1)))
ax = [rx[i] + (lx[-1] - lx[i]) * i for i in range(max_take + 1)]


def bisec(l0, r0, predicate):
    l, r = l0, r0

    while abs(l - r) > 1:
        mid = (l + r) // 2
        if predicate(mid):
            r = mid
        else:
            l = mid

    return r


for k in range(1, n + 1):
    print(bisec(n + 1, 0, lambda x: x * k <= ax[min(x, max_take)]))

Solution (Python):
from bisect import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
k=a[0]
data=[]
count=1
for i in range(1,n):
    if a[i]==k:
        count+=1
    else:
        k=a[i]
        data.append(count)
        count=1
data.append(count)
data.sort()
l=len(data)
lst=[]
for u in data:
    if lst:
        lst.append(u+lst[-1])
    else:
        lst.append(u)
li=[0]*(n+1)
for ans in range(1,n+1):
    i=bisect(data,ans)
    if i==0:
        j=ans*l
    else:
        j=lst[i-1]+ans*(l-i)
    k=j//ans
    li[k]=ans
z=0
for i in range(n):
    if li[n-i]==0:
        li[n-i]=z
    else:
        z=li[n-i]
for i in range(1,n+1):
    print(li[i])

Solution (Python):
import bisect
def main():

    N = int(input())
    A = list(map(int, input().split()))
    cntA = dict()
    for a in A:
        cntA[a] = cntA.get(a, 0) + 1

    cnt = dict()
    for a in cntA:
        cnt[cntA[a]] = cnt.get(cntA[a], 0) + 1

    sum1 = [0]
    for i in range(1, N+1):
        if i in cnt:
            sum1.append(sum1[-1]+ i * cnt[i])
        else:
            sum1.append(sum1[-1])

    sum2 = [0]
    for i in range(N, -1, -1):
        if i in cnt:
            sum2.append(sum2[-1]+cnt[i])
        else:
            sum2.append(sum2[-1])
    sum2 = sum2[::-1]

    vals = []
    for i in range(1, N+1):
        v = (sum1[i] + i * sum2[i+1]) // i
        vals.append(v)
    vals = vals[::-1]

    for i in range(1, N+1):
        j = bisect.bisect_left(vals, i)
        print(N-j)


if __name__ == '__main__':
    main()

Solution (Python):



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

c = [0]*(n+1)

for i in range(n):
    c[a[i]] += 1

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

sum1 = 0
sum2 =sum(d)-d[0]
fx = []
for x in range(1,n+1):
    sum1 += x*d[x]
    sum2 -= d[x]
    fx.append((sum1+x*sum2)//x)
fx.sort()
for i in range(1,n+1):
    j = bisect.bisect_left(fx,i)
    print(n-j)

Solution (Python):
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True 
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def f(k,p):
  return (c[p] >= k*p)

def ff(k,p):
  acc = n 
  for i in range(len(b)):
    if b[i]>p:
      acc -= b[i]-p 
    else:
      break
  return (acc >= k*p)

n = inn()
a = inl()
h = {}
for x in a:
  if x in h:
    h[x] += 1
  else:
    h[x] = 1
b = []
for x in h:
  b.append(h[x])
b.sort(reverse=True)



c = [0]*(n+1)
for p in range(1,n+1):
  acc = n 
  for i in range(len(b)):
    if b[i]>p:
      acc -= b[i]-p 
    else:
      break
  c[p] = acc


for k in range(1,n+1):
  mn = 0
  mx = n//k + 1
  while mx > mn+1:
    mid = (mn+mx)//2
    if f(k,mid):
      mn = mid 
    else:
      mx = mid 
  print(mn)

Solution (Python):
from collections import Counter
from itertools import accumulate
from bisect import bisect_right
N = int(input())
As = list(map(int, input().split()))
ct = Counter(As)
ctm = [c[1] for c in ct.most_common()]
ctm.reverse()
L = len(ctm)
acc = [0] +  list(accumulate(ctm))

arr = [0]
for n in range(1, N+1):
  idx = bisect_right(ctm, n)
  arr.append(acc[idx] + n*(L-idx))

for n in range(1, N+1):
  f = 0
  t = N // n + 1
  while f + 1 < t:
    m = f + (t-f) // 2
    if arr[m] >= m*n:
      f = m
    else:
      t = m
  print(f)

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
C = list(C.values())
C.sort()
n = len(C)
m = max(C)
S = [0]*(m+1)
b = 0
for i in range(n):
    c = C[i]
    if b<c:
        for j in range(b+1, c+1):
            S[j] = S[j-1]+(n-i)
        b = c
for i in range(1, N+1):
    ok = 0
    ng = N+1
    while ng-ok>1:
        mid = (ok+ng)//2
        if S[min(m, mid)]>=mid*i:
            ok = mid
        else:
            ng = mid
    print(ok)

Solution (Python):
from collections import Counter
from itertools import accumulate

def bisect(ng, ok, judge):
    while abs(ng-ok) > 1:
        m = (ng+ok)//2
        if judge(m):
            ok = m
        else:
            ng = m
    return ok

N = int(input())
A = Counter(Counter(map(int,input().split())).values())
m = max(A.keys())
nA = list(accumulate(A[c] for c in range(m+1)))
wA = list(accumulate(A[c]*c for c in range(m+1)))

A = [wA[i]+(nA[-1]-nA[i])*i for i in range(m+1)]
for k in range(1,N+1):
    print(bisect(N+1, 0, lambda x: x*k <= A[min(x,m)]))

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    d = defaultdict(lambda : 0)
    for i in a:
        d[i] += 1
    d = list(d.values())
    q = []
    for i in d:
        heappush(q,i)
    ans = []
    for k in range(n):
        if not q:
            break
        else:
            x = heappop(q)
            ans.append(x)
            while q and x:
                y = heappop(q)
                y += 1
                x -= 1
                heappush(q,y)
    for i in ans[::-1]+[0]*(n-len(ans)):
        print(i)
    return


if __name__ == "__main__":
    solve()

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
AA = inpl()
cnts = defaultdict(int)
ed = set()
for a in AA:
    cnts[a] += 1
    ed.add(a)

aa1 = [[i,0] for i in range(1,N+1)]
for e in ed:
    aa1[cnts[e]-1][1] += 1

aa2 = [0] 
aa3 = [0] 
for t,n in aa1:
    aa2.append(aa2[-1] + n)
    aa3.append(aa3[-1] + n*t)

L = len(aa1)
tmpl_t = []
tmpl_c = []
for i,(t,n) in enumerate(aa1):
    tmp = n + aa3[i]//t
    tmp += aa2[-1] - aa2[i+1]
    tmpl_t.append(t)
    tmpl_c.append(tmp)
    

tmpl_t.reverse()
tmpl_t.append(0)
tmpl_c.reverse()


ans = [0]*N
for i in range(1,N+1):
    idx = bisect.bisect_left(tmpl_c,i)
    if idx == 0:
        ans[i-1] = N//i
    else:
        ans[i-1] = tmpl_t[idx]

print('\n'.join(map(str,ans)))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

"""
・大きいKから見る
・a_N <= S//K：全て取り切れて、S//Kが解
・a_N > S/K：a_Nは常に選ぶとしてよい。K-1枚でa_{N-1}までのゲームに帰着
"""

from collections import Counter

N,*A = map(int,read().split())

counter = Counter(A)
C = list(counter.values())
C.sort()
S = sum(C)

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

print('\n'.join(map(str,answer)))