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



Sample input:
3
2 1 2


Sample output:
3
1
0

Submission status: Runtime Error

Solution code:
import bisect
import copy

n = int(input())
a = sorted([int(x) for x in input().split()])
num = len(set(a))

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

# k=1 : ans = n
print(n)

# 2 <= k <= num : ans = {sum(min(cnt, n//k))} // k
i = 0
s = sum(aa)
for k in range(2, num+1):
    #s2 = copy.copy(sum)
    #i = bisect.bisect(aa[:i], n//k)
    while(aa[-i-1] >= n//k):
        s -= aa[-i-1]
        i += 1
    print((i*(n//k) + s) // k) #aa[:i]
    #aaa = [min(cnt, n//k) for cnt in aa]
    #print(sum(aaa)//k)

# num < k : ans = 0
for k in range(num+1, n+1):
    print(0)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
 
#input
N = int(input())
A = list(map(int, input().split()))

#output
from collections import Counter
import numpy as np

l = Counter(A).most_common()
l = [b for a, b in l]
M = len(l)
O = l[0]

number_of_operation = [0] * O
maximum_operation = [0] * N
operation_matrix = np.zeros((O, M), int)

for m in range(M):
    operation_matrix[0:l[m], m] += 1

for o in range(O):
    number_of_operation[o] = sum(operation_matrix[o])

for K in range(N):
    temp_number_of_operation = list(number_of_operation)
    for o in range(O-1):
        p, q = divmod(temp_number_of_operation[o], K+1)
        if p > 0:
            temp_number_of_operation[o+1] += q
        maximum_operation[K] += p
    maximum_operation[K] += number_of_operation[O-1]//(K+1)

for m in maximum_operation:
    print(m)

Submission status: Runtime Error

Solution code:
n = int(input())
a = sorted([int(x) for x in input().split()])
num = len(set(a))

aa = []
i=0
while(i<n):
    cnt = a.count(a[i])
    aa.append(cnt)
    i += cnt
aa.sort(reverse=True)

# k=1
# ans = n
print(n)

# 2 <= k <= num
# ans = {sum(min(cnt, n//k))} // k
i = 0
for k in range(2, num+1):
    while(aa[i]>=n//k and i<len(aa)):
        i += 1
    print((i*(n//k)+sum(aa[i:])) // k)
    #aaa = [min(cnt, n//k) for cnt in aa]
    #print(sum(aaa)//k)

# num < k
# ans = 0
for k in range(num+1, n+1):
    print(0)

Submission status: Runtime Error

Solution code:
n = int(input())
a = sorted([int(x) for x in input().split()])
num = len(set(a))

aa = []
i=0
while(i<n):
    cnt = a.count(a[i])
    aa.append(cnt)
    i += cnt
aa.sort(reverse=True)

# k=1
# ans = n
print(n)

# 2 <= k <= num
# ans = {sum(min(cnt, n//k))} // k
i = 0
for k in range(2, num+1):
    while(aa[i]>=n//k and i<=len(aa)):
        i += 1
    print((i*(n//k)+sum(aa[i:])) // k)
    #aaa = [min(cnt, n//k) for cnt in aa]
    #print(sum(aaa)//k)

# num < k
# ans = 0
for k in range(num+1, n+1):
    print(0)

Submission status: Runtime Error

Solution code:
n = int(input())
a = sorted([int(x) for x in input().split()])
num = len(set(a))

aa = []
i=0
while(i<n):
    cnt = a.count(a[i])
    aa.append(cnt)
    i += cnt
aa.sort(reverse=True)

# k=1
print(n)

# 2 <= k <= num
i = 0
for k in range(2, num+1):
    if aa[i] >= n//k:
        i += 1
    print((i*(n//k)+sum(aa[n_over:])) // k)
    #aaa = [min(cnt, n//k) for cnt in aa]
    #print(sum(aaa)//k)

# num < k
for k in range(num+1, n+1):
    print(0)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
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))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input(""))
A = input("")
A = A.split(" ")
b = set(A)
print(N)
num_value = []
for i in b:
    num_value.append(A.count(i))
num_value.sort(reverse = True)
result = [0 for i in range(N + 1)]
i = 2
memory = copy.deepcopy(num_value)
while i != N + 1 :
    new_num = []
    if len(num_value) >= i :
        for j in range(i):
            num_value[j] -= 1
        while 0 in num_value :
            del num_value[num_value.index(0)]
        result[i] += 1
    else :
        print(result[i])
        if result[i] == 0 :
            break
        i += 1
        num_value = copy.deepcopy(memory)
print("0\n"*int(N + 1 - i))

Submission status: Runtime Error

Solution code:
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)
    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())

Submission status: Runtime Error

Solution code:
N = input("")
A = input("")
A = A.split(" ")
num = {}
num_key = 0
print(N)
for i in A:
    if not i in num.keys():
        num[i] = A.count(i)
num_key = len(num.keys())
num_value = list(num.values())
num_value.sort(reverse = True)
result = []
for i in range(N+1):
  result.append(0)
i = 2
memory = num_value
while i != N + 1 :
    new_num = []
    if len(num_value) >= i :
        for j in range(i):
            num_value[j] -= 1
        for k in num_value:
            if k != 0:
                new_num.append(k)
        num_value = new_num
        result[i] += 1
    else :
        print(result[i])
        i += 1
        num_value = memory

Submission status: Runtime Error

Solution code:
N = input("")
A = input("")
A = A.split(" ")
num = {}
num_key = 0
print(N)
for i in A:
    if not i in num.keys():
        num[i] = A.count(i)
num_key = len(num.keys())
num_value = list(num.values())
num_value.sort(reverse = True)
result = [0 for i in range(N + 1)]
i = 2
memory = num_value
while i != N + 1 :
    new_num = []
    if len(num_value) >= i :
        for j in range(i):
            num_value[j] -= 1
        for k in num_value:
            if k != 0:
                new_num.append(k)
        num_value = new_num
        result[i] += 1
    else :
        print(result[i])
        i += 1
        num_value = memory

Submission status: Runtime Error

Solution code:
N = input("")
A = input("")
A = A.split(" ")
num = {}
num_key = 0
print(N)
for i in A:
    if not i in num.keys():
        num[i] = A.count(i)
num_key = len(num.keys())
num_value = list(num.values())
num_value.sort(reverse = True)
result = [0 for i in range(N + 1)]
i = 2
while i != N + 1 :
    new_num = []
    if len(num_value) > i :
        for j in range(i):
            num_value[j] -= 1
        for k in num_value:
            if k != 0:
                new_num.append(k)
        num_value = new_num
        result[i] += 1
    else :
        print(result[i])

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
 
#input
N = int(input())
A = list(map(int, input().split()))
 
from collections import Counter
import numpy as np
 
l = Counter(A).most_common()
l = [b for a, b in l]
l = np.array(l)
 
maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
    l = [b for a, b in l]
    l = np.array(l)
    while l[K] > 0:
        l[0:K+1] -= 1
        l = np.sort(l, kind = "quicksort")[::-1]
        maximum_operation[K] += 1
 
for m in maximum_operation:
    print(m)

Submission status: Runtime Error

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

B3b = [A.count(b) for b in set(A)]   #B数字の数
B3b.sort()

for k in range(1,N+1):
    B3 = B3b.copy()
    count = 0
    if len(B3)<k :
        print(0)
    else:
        while len(B3)>=k:
            n = len(B3)
            count += 1
            for d in range(n-1, n-k-1, -1):
                B3[d] -= 1
                if B3[d]== 0:
                    del(B3[d])
            if k > 1 and k < len(B3):
                if B3[n-k-1]>B3[n-k]:
                    B3.sort()
        print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
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=[i for i in BN if i > 0]
BN.sort(reverse=True)

for K in xrange(1, N+1):
    x = np.zeros(K)
    for i in BN:
        x[x.argmin()] += i

    print (int(x.min()))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
 
#input
N = int(input())
A = list(map(int, input().split()))
 
#output
from collections import Counter
 
l = Counter(A).most_common()
l = [b for a, b in l]
 
maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
	l = [b for a, b in l]
    while l[K] > 0:
        for i in range(K+1):
            l[i] -= 1
        l.sort(reverse = True)
        maximum_operation[K] += 1
 
for m in maximum_operation:
    print(m)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

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

#output
from collections import Counter
 
l = Counter(A).most_common()
l = [b for a, b in l]

maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
    l = [b for a, b in l]
    while l[K][1] > 0:
        for i in range(K+1):
            l[i] -= 1
        l.sort(reverse = True)
        maximum_operation[K] += 1

for m in maximum_operation:
    print(m)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

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

#output
from collections import Counter
from operator import itemgetter
import math
import numpy as np

l = Counter(A).most_common()
l = [[a, b] for a, b in l]

maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
    l = [[a, b] for a, b in l]
    while l[K][1] > 0:
        for i in range(K+1):
            l[i][1] -= 1
        l.sort(key = itemgetter(1), reverse = True)
        maximum_operation[K] += 1

for m in maximum_operation:
    print(m)

Submission status: Runtime Error

Solution code:
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-1)
    S=[0]*(n+1)
    for i in range(n): S[i+1]=S[i]+A[i]
    # output
    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()

Submission status: Runtime Error

Solution code:
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]+=1
    B=[]
    for i in range(n_min,n_max+1): B+=[i]*bin[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-1)
    S=[0]*(n+1)
    for i in range(n): S[i+1]=S[i]+A[i]
    # output
    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()

Submission status: Runtime Error

Solution code:
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
    if j < n - 1:
        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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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

# 解説AC
# https://twitter.com/maspy_stars/status/1185552225474498560
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] * (max(A) + 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:
        # 全部取れるとしていい
        # 最後に2つ以上余ると max_c <= cnt に矛盾する
        return cnt

    # S = N
    # i = 1
    # while i < k:
    #     # 最大値は毎回取ることにしてもう見ない
    #     S -= C[-i]
    #     cnt = S // (k - i)
    #     max_c = C[-i - 1]
    #     if max_c <= cnt:
    #         return cnt
    #     i += 1

    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')

Submission status: Runtime Error

Solution code:
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

# 解説AC
# https://twitter.com/maspy_stars/status/1185552225474498560
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


C = np.bincount(A)
C.sort()
cs = C[::-1].cumsum()[::-1]


def solve(k):
    cnt = N // k
    if C[-1] <= cnt:
        # 全部取れるとしていい
        # 最後に2つ以上余ると max_c <= cnt に矛盾する
        return cnt

    # S = N
    # i = 1
    # while i < k:
    #     # 最大値は毎回取ることにしてもう見ない
    #     S -= C[-i]
    #     cnt = S // (k - i)
    #     max_c = C[-i - 1]
    #     if max_c <= cnt:
    #         return cnt
    #     i += 1

    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')

Submission status: Runtime Error

Solution code:
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()))


def test(k):
    if memo[k]:
        bc, ret = memo[k]
    else:
        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


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

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(map(int,input().split()))
dic = collections.Counter(l)
val = sorted(dic.values())

print(n) # 1
for k in range(2, n+1):
    if len(val) < k:
        print(0)
    else:
        print(sum([min(k ,i) for i in val]) // k)

Submission status: Runtime Error

Solution code:
import sys
import collections

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

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
import collections

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

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import collections

def solve(N: int, A: "List[int]"):
    counter = sorted(list(collections.Counter(A).values()),reverse=True)
    for i in range(1,N+1):
        c_index = 0
        n = N
        while counter[c_index]*i > N:
            n-=counter[c_index]
            c_index+=1
            i-=1
        print(n//i)
    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))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
import collections

def max_fetch(k,c,N):
    if c[0]*k <= N:
        return N//k
    else:
        return max_fetch(k-1,c[1:],N-c[0])

def solve(N: int, A: "List[int]"):
    counter = sorted(list(collections.Counter(A).values()),reverse=True)
    for i in range(1,N+1):
        if counter[0]*i <= N:
            print(N//i)
            continue
        print(max_fetch(i,counter,N))
    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))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M, L = map(int, input().split())
roads = [[float('inf')]*N for _ in range(N)]
kyuyu = [[float('inf')]*N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    if c <= L:  # 移動出来ない経路は消す
        roads[a-1][b-1] = c
        roads[b-1][a-1] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            roads[i][j] = min(roads[i][j], roads[i][k]+roads[k][j])

for i in range(N):
    for j in range(i+1, N):
        if roads[i][j] <= L:
            kyuyu[i][j] = 1
            kyuyu[j][i] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            kyuyu[i][j] = min(kyuyu[i][j], kyuyu[i][k]+kyuyu[k][j])

Q = int(input())
for _ in range(Q):
    s, t = map(lambda x: int(x)-1, input().split())
    dist = kyuyu[s][t]
    if dist == float('inf'):
        print(-1)
    else:
        print(dist)

Submission status: Runtime Error

Solution code:
import bisect

n = int(input())
a_array = map(int, input().split())
card = [0 for _ in range(n)]
for m in a_array:
    card[m] += 1
card.sort(reverse=True)
for i in range(n):
    num = card
    count = 0
    while num[i] != 0:
        count += num[i]
        dif = num[i]
        buf = []
        for j in num[i + 1:]:
            buf.append(j)
        for j in num[:i+1]:
            bisect.insort(buf, j - dif)
        num = buf
    print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort()
c = []
hoge = 1
for i in range(1,N):
    if A[i] == A[i-1]:
        hoge += 1
    else:
        c.append(hoge)
        hoge = 1
c.sort(reverse = True)
for i in range(N):
    print(N)
    if N > 0:
        N -= C[i]

Submission status: Runtime Error

Solution code:
import collections as co
N = int(input())
ls_A = list(map(int, input().split()))
co_A = co.Counter(ls_A).most_common()
vl_A = co_A.values()
count = 0
for i in range(1,N+1):
    a = sum(vl_A[:i+1])
    print(min(a, N - a))

Submission status: Runtime Error

Solution code:
n=int(input())
listl = [int(i) for i in input().split()]

listl.sort()

ans=1
bef = listl[0]
for i in range(1,n):
    now = listl[i]
    if bef!=now:
        ans+=1
        bef = now

num = n - ans
tmpm = 1
tmpc = 1
for i in range(n):
    tmpm *= num-i
    tmpc *= i+1
    print(int(tmpm/tmpc))

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
G = {}
for i in range(N):
    if A[i] not in G:
        G[A[i]] = 0
    G[A[i]] += 1
C = sorted(list(G.values()),reverse=True)
B = [0 for _ in range(N+1)]
B[1] = N
n = len(G)
for k in range(N//2+1,N+1):
    if n>=k:
        B[k] = 1
for k in range(2,N//2+1):
    D = C[:]
    cnt = 0
    while True:
        if C[k-1]>=1:
            for i in range(k):
                C[i] -= 1
            C = sorted(C,reverse=True)
            cnt += 1
        else:break
    B[k] = cnt
for k in range(1,N+1):
    print(B[k])

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=[]
k=1
for i in range(n-1):
    if a[i]==a[i+1]:
        k+=1
    else:
        b.append(k)
        k=1
b.append(k)
b.sort(reverse=True)
print(n)
l=len(b)
for i in range(2,n+1):
    if l<i:
        print(0)
    else:
        c=b.copy()
        ans=0
        for j in range(n+1):
            if c[i-1]!=0:
                ans += c[i-1]
                for m in range(i):
                    c[m]-=c[i-1]
                c.sort(reverse=True)
            else:
                break
        print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
while (l[-1]>l[-2]+l[-3]) and (len(l)>3):
	del l[-1]
n=len(l)
ans=0
i=0
while i<n-2:
	j=i+1
	while j<n-1:
		k=j+1
		while k<n:
			if l[k]<l[i]+l[j]:
				ans=ans+1
			else:
				k=n
			k=k+1
		j=j+1
	i=i+1
print(ans)

Submission status: Runtime Error

Solution code:
import collections
import heapq


def solve(cards):
    counter = collections.Counter(cards)

    counts = [(-count, card) for card, count in counter.items()]
    # Max heap
    heapq.heapify(counts)
    print(counts)

    ans = [0] * len(cards)
    for k in range(1, len(cards) + 1):
        times = 0
        heap = counts.copy()
        while heap:
            if len(heap) < k:
                break
            to_remove = [heapq.heappop(heap) for _ in range(k)]
            for e in to_remove:
                count, card = e
                count = - count - 1
                if count == 0:
                    continue
                heapq.heappush(heap, (-count, card))
            times += 1
        ans[k - 1] = times

    return ans


if __name__ == "__main__":
    n = int(input())
    a_s = [int(l) for l in input().split(' ')]
    for ans in solve(a_s):
        print(ans)

Submission status: Runtime Error

Solution code:
import heapq
n = int(input())
a = [int(i) for i in input().split()]
b = {}
for i in a:
    if i in b:
        b[i] += 1
    else:
        b[i] = 1
c = [-b[i] for i in b]
heapq.heapify(c)


def take(k, a):
    a = a.copy()
    b = []
    for _ in range(k):
        if len(a) == 0:
            return -1
        c = heapq.heappop(a)
        if c == 0:
            return - 1
        heapq.heappush(b, c + 1)
    while a:
        c = heapq.heappop(a)
        heapq.heappush(b, c)
    return b


for k in range(1, n+1):
    l = 0
    d = c.copy()
    while True:
        d = take(k, d)
        if d == -1:
            print(l)
            break
        l += 1

Submission status: Runtime Error

Solution code:
num =input()
lst = num.split()
curtain = int(lst[1]) * 2
ans = int(lst[0]) - curtain

if(ans <= 0):
 print("0")
else:
 print("{}".format(ans))