Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

from collections import Counter
from copy import deepcopy
from heapq import heapify, heappush, heappop


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

    #n = 3 * 10 ** 5
    #a = list(range(1, n + 1))

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

    k_mx = len(c)

    for k in range(1, n + 1):
        if k > k_mx:
            print(0)
            continue

        cp = deepcopy(c)

        for _ in range(k_mx - k):
            cnt = heappop(cp)
            while cnt:
                mn = heappop(cp)
                cnt -= 1
                heappush(cp, mn + 1)

        ans = heappop(cp)
        print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

from collections import Counter
from copy import deepcopy
from bisect import insort


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

    #n = 3 * 10 ** 5
    #a = list(range(1, n + 1))

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

    k_mx = len(c)

    for k in range(1, n + 1):
        if k > k_mx:
            print(0)
            continue

        cp = deepcopy(c)
        ans = 0

        while True:
            eat = cp[-k:]
            if eat[0] == 0:
                break

            cp = cp[:-k]
            for e in eat:
                left = e - eat[0]
                insort(cp, left)

            ans += eat[0]

        print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

from collections import Counter
from copy import deepcopy
from bisect import insort


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

    #n = 3 * 10 ** 5
    #a = list(range(1, n + 1))

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

    k_mx = len(c)

    for k in range(1, n + 1):
        if k > k_mx:
            print(0)
            continue

        cp = deepcopy(c)
        ans = 0

        while True:
            eat = cp[-k:]
            if eat[0] == 0:
                break

            cp = cp[:-k]
            for e in eat:
                left = e - eat[0]
                insort(cp, left)

            ans += eat[0]

        print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

from collections import Counter
from heapq import heapify, heappush, heappop
from copy import deepcopy


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

    #n = 3 * 10 ** 5
    #a = list(range(1, n + 1))

    c = Counter(a)
    c = [-e for e in c.values()]
    heapify(c)

    k_mx = len(c)

    for k in range(1, n + 1):
        if k > k_mx:
            print(0)
            continue

        ans = -1
        mn = -1
        cp = deepcopy(c)
        end = False
        while not end:
            ans -= mn
            eat = []
            for _ in range(k):
                mn = heappop(cp)
                if mn >= 0:
                    end = True
                    break
                eat.append(mn)

            for e in eat:
                heappush(cp, e - mn)

        print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

from collections import Counter
from heapq import heapify, heappush, heappop
from copy import deepcopy


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

    c = Counter(a)
    c = [-e for e in c.values()]
    heapify(c)

    k_mx = len(c)

    for k in range(1, n + 1):
        if k > k_mx:
            print(0)
            continue

        ans = -1
        cp = deepcopy(c)
        end = False
        while not end:
            ans += 1
            eat = []
            for _ in range(k):
                mn = heappop(cp)
                if mn == 0:
                    end = True
                    break
                eat.append(mn + 1)

            for e in eat:
                heappush(cp, e)

        print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
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()