Language: C++

import java.util.*;

class Main {
	Scanner sc;
	int N;
	int[] A, C, D, skD, sD;
	
	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		N = sc.nextInt();
		C = new int[N+1];
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			C[a]++;
		}
		D = new int[N+1];
		for (int i = 0; i <= N; i++) D[C[i]]++;
		
		sD = new int[N+1];
		skD = new int[N+1];
		
		sD[0] = D[0]; skD[0] = 0;
		for (int i = 1; i <= N; i++) {
			sD[i] = sD[i-1] + D[i];
			skD[i] = skD[i-1] + i*D[i];
		}
		int K = 1;
		int lastK = -1;
		for (int X = N; X > 0; X--) {
			int f = f(X);
			if (f != lastK) {
				for (; K <= f; K++) System.out.println(X);
				lastK = f;
			}
		}
		for (; K <= N; K++) System.out.println(0);
	}
	
	private int f(int X) {
		return (skD[X]+X*(sD[N]-sD[X]))/X;
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:9: error: 'Scanner' does not name a type
    4 |         Scanner sc;
      |         ^~~~~~~
a.cc:6:12: error: expected unqualified-id before '[' token
    6 |         int[] A, C, D, skD, sD;
      |            ^
a.cc:8:15: error: expected ':' before 'Main'
    8 |         public Main() {
      |               ^~~~~
      |               :
a.cc:12:16: error: expected ':' before 'void'
   12 |         private void calc() {
      |                ^~~~~
      |                :
a.cc:42:16: error: expected ':' before 'int'
   42 |         private int f(int X) {
      |                ^~~~
      |                :
a.cc:46:15: error: expected ':' before 'static'
   46 |         public static void main(String[] args) {
      |               ^~~~~~~
      |               :
a.cc:46:33: error: 'String' has not been declared
   46 |         public static void main(String[] args) {
      |                                 ^~~~~~
a.cc:46:42: error: expected ',' or '...' before 'args'
   46 |         public static void main(String[] args) {
      |                                          ^~~~
a.cc:49:2: error: expected ';' after class definition
   49 | }
      |  ^
      |  ;
a.cc: In constructor 'Main::Main()':
a.cc:9:17: error: 'sc' was not declared in this scope
    9 |                 sc = new Scanner(System.in);
      |                 ^~
a.cc:9:26: error: expected type-specifier before 'Scanner'
    9 |                 sc = new Scanner(System.in);
      |                          ^~~~~~~
a.cc: In member function 'void Main::calc()':
a.cc:13:21: error: 'sc' was not declared in this scope
   13 |                 N = sc.nextInt();
      |                     ^~
a.cc:14:17: error: 'C' was not declared in this scope
   14 |                 C = new int[N+1];
      |                 ^
a.cc:19:17: error: 'D' was not declared in this scope
   19 |                 D = new int[N+1];
      |                 ^
a.cc:22:17: error: 'sD' was not declared in this scope
   22 |                 sD = new int[N+1];
      |                 ^~
a.cc:23:17: error: 'skD' was not declared in this scope
   23 |                 skD = new int[N+1];
      |                 ^~~
a.cc:33:34: error: 'f' cannot be used as a function
   33 |                         int f = f(X);
      |                                 ~^~~
a.cc:35:53: error: 'System' was not declared in this scope
   35 |                                 for (; K <= f; K++) System.out.println(X);
      |                                                     ^~~~~~
a.cc:39:37: error: 'System' was not declared in this scope
   39 |                 for (; K <= N; K++) System.out.println(0);
      |                                     ^~~~~~
a.cc: In member function 'int Main::f(int)':
a.cc:43:25: error: 'skD' was not declared in this scope
   43 |                 return (skD[X]+X*(sD[N]-sD[X]))/X;
      |                         ^~~
a.cc:43:35: error: 'sD' was not declared in this scope
   43 |                 return (skD[X]+X*(sD[N]-sD[X]))/X;
      |                                   ^~
a.cc: In static member function 'static void Main::main(int*)':
a.cc:47:27: error: expected ';' before '.' token
   47 |                 new Main().calc();
      |                           ^