Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint32_t, uint32_t> a, pair<uint32_t, uint32_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main() {
  uint64_t N;
  cin >> N;
  vector<uint32_t> A(N);
  map<uint32_t, uint32_t> Num_Map;
  ArrayInput(A);
  for (uint32_t i = 0; i < N; ++i) Num_Map[A[i]]++;
  vector<pair<uint32_t, uint32_t>> Num_Pair;
  priority_queue<pair<uint32_t, uint32_t>> Que;
  for (auto itr = Num_Map.begin(); itr != Num_Map.end(); ++itr) {
    Que.push(make_pair(itr->second, itr->first));
  }
  cout << N << endl;
  priority_queue<pair<uint32_t, uint32_t>> TempQue;
  vector<pair<uint32_t, uint32_t>> t_p(Que.size());
  uint32_t res;
  uint32_t t_r = 0;
  for (uint32_t K = 2; K <= N; ++K) {
    TempQue = Que;
    res = 0;
    while (TempQue.size() >= K) {
      t_r = 0;
      for (uint32_t i = 0; i < K; ++i) {
        t_p[i] = TempQue.top();
        TempQue.pop();
      }
      t_r = t_p[K - 1];
      for (uint32_t i = 0; i < K; ++i) {
        t_p[i].first -= t_r;
        if (t_p[i].first != 0) TempQue.push(t_p[i]);
      }
      res += t_r;
    }
    cout << res << endl;
  }
  return 0;
}


Compiler output:
a.cc:27:23: error: 'uint32_t' was not declared in this scope
   27 | bool Sec_compare(pair<uint32_t, uint32_t> a, pair<uint32_t, uint32_t> b) {
      |                       ^~~~~~~~
a.cc:11:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
   10 | #include <set>
  +++ |+#include <cstdint>
   11 | #include <string>
a.cc:27:33: error: 'uint32_t' was not declared in this scope
   27 | bool Sec_compare(pair<uint32_t, uint32_t> a, pair<uint32_t, uint32_t> b) {
      |                                 ^~~~~~~~
a.cc:27:33: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:27:41: error: template argument 1 is invalid
   27 | bool Sec_compare(pair<uint32_t, uint32_t> a, pair<uint32_t, uint32_t> b) {
      |                                         ^
a.cc:27:41: error: template argument 2 is invalid
a.cc:27:51: error: 'uint32_t' was not declared in this scope
   27 | bool Sec_compare(pair<uint32_t, uint32_t> a, pair<uint32_t, uint32_t> b) {
      |                                                   ^~~~~~~~
a.cc:27:51: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:27:61: error: 'uint32_t' was not declared in this scope
   27 | bool Sec_compare(pair<uint32_t, uint32_t> a, pair<uint32_t, uint32_t> b) {
      |                                                             ^~~~~~~~
a.cc:27:61: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:27:69: error: template argument 1 is invalid
   27 | bool Sec_compare(pair<uint32_t, uint32_t> a, pair<uint32_t, uint32_t> b) {
      |                                                                     ^
a.cc:27:69: error: template argument 2 is invalid
a.cc: In function 'bool Sec_compare(int, int)':
a.cc:28:9: error: request for member 'second' in 'a', which is of non-class type 'int'
   28 |   if (a.second != b.second) {
      |         ^~~~~~
a.cc:28:21: error: request for member 'second' in 'b', which is of non-class type 'int'
   28 |   if (a.second != b.second) {
      |                     ^~~~~~
a.cc:29:14: error: request for member 'second' in 'a', which is of non-class type 'int'
   29 |     return a.second < b.second;
      |              ^~~~~~
a.cc:29:25: error: request for member 'second' in 'b', which is of non-class type 'int'
   29 |     return a.second < b.second;
      |                         ^~~~~~
a.cc:31:14: error: request for member 'first' in 'a', which is of non-class type 'int'
   31 |     return a.first < b.first;
      |              ^~~~~
a.cc:31:24: error: request for member 'first' in 'b', which is of non-class type 'int'
   31 |     return a.first < b.first;
      |                        ^~~~~
a.cc: In function 'int main()':
a.cc:36:3: error: 'uint64_t' was not declared in this scope
   36 |   uint64_t N;
      |   ^~~~~~~~
a.cc:36:3: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:37:10: error: 'N' was not declared in this scope
   37 |   cin >> N;
      |          ^
a.cc:38:10: error: 'uint32_t' was not declared in this scope
   38 |   vector<uint32_t> A(N);
      |          ^~~~~~~~
a.cc:38:10: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:38:18: error: template argument 1 is invalid
   38 |   vector<uint32_t> A(N);
      |                  ^
a.cc:38:18: error: template argument 2 is invalid
a.cc:39:25: error: template argument 3 is invalid
   39 |   map<uint32_t, uint32_t> Num_Map;
      |                         ^
a.cc:39:25: error: template argument 4 is invalid
a.cc:40:13: error: no matching function for call to 'ArrayInput(int&)'
   40 |   ArrayInput(A);
      |   ~~~~~~~~~~^~~
a.cc:17:20: note: candidate: 'template<class T> void ArrayInput(std::vector<_Tp>&)'
   17 | static inline void ArrayInput(vector<T>& A) {
      |                    ^~~~~~~~~~
a.cc:17:20: note:   template argument deduction/substitution failed:
a.cc:40:13: note:   mismatched types 'std::vector<_Tp>' and 'int'
   40 |   ArrayInput(A);
      |   ~~~~~~~~~~^~~
a.cc:41:16: error: expected ';' before 'i'
   41 |   for (uint32_t i = 0; i < N; ++i) Num_Map[A[i]]++;
      |                ^~
      |                ;
a.cc:41:24: error: 'i' was not declared in this scope
   41 |   for (uint32_t i = 0; i < N; ++i) Num_Map[A[i]]++;
      |                        ^
a.cc:42:33: error: template argument 1 is invalid
   42 |   vector<pair<uint32_t, uint32_t>> Num_Pair;
      |                                 ^~
a.cc:42:33: error: template argument 2 is invalid
a.cc:43:41: error: template argument 1 is invalid
   43 |   priority_queue<pair<uint32_t, uint32_t>> Que;
      |                                         ^~
a.cc:43:41: error: template argument 2 is invalid
a.cc:43:41: error: template argument 3 is invalid
a.cc:44:27: error: request for member 'begin' in 'Num_Map', which is of non-class type 'int'
   44 |   for (auto itr = Num_Map.begin(); itr != Num_Map.end(); ++itr) {
      |                           ^~~~~
a.cc:44:51: error: request for member 'end' in 'Num_Map', which is of non-class type 'int'
   44 |   for (auto itr = Num_Map.begin(); itr != Num_Map.end(); ++itr) {
      |                                                   ^~~
a.cc:45:9: error: request for member 'push' in 'Que', which is of non-class type 'int'
   45 |     Que.push(make_pair(itr->second, itr->first));
      |         ^~~~
a.cc:48:41: error: template argument 1 is invalid
   48 |   priority_queue<pair<uint32_t, uint32_t>> TempQue;
      |                                         ^~
a.cc:48:41: error: template argument 2 is invalid
a.cc:48:41: error: template argument 3 is invalid
a.cc:49:33: error: template argument 1 is invalid
   49 |   vector<pair<uint32_t, uint32_t>> t_p(Que.size());
      |                                 ^~
a.cc:49:33: error: template argument 2 is invalid
a.cc:49:44: error: request for member 'size' in 'Que', which is of non-class type 'int'
   49 |   vector<pair<uint32_t, uint32_t>> t_p(Que.size());
      |                                            ^~~~
a.cc:50:11: error: expected ';' before 'res'
   50 |   uint32_t res;
      |           ^~~~
      |           ;
a.cc:51:11: error: expected ';' before 't_r'
   51 |   uint32_t t_r = 0;
      |           ^~~~
      |           ;
a.cc:52:16: error: expected ';' before 'K'
   52 |   for (uint32_t K = 2; K <= N; ++K) {
      |                ^~
      |                ;
a.cc:52:24: error: 'K' was not declared in this scope
   52 |   for (uint32_t K = 2; K <= N; ++K) {
      |                        ^
a.cc:54:5: error: 'res' was not declared in this scope
   54 |     res = 0;
      |     ^~~
a.cc:55:20: error: request for member 'size' in 'TempQue', which is of non-class type 'int'
   55 |     while (TempQue.size() >= K) {
      |                    ^~~~
a.cc:56:7: error: 't_r' was not declared in this scope; did you mean 't_p'?
   56 |       t_r = 0;
      |       ^~~
      |       t_p
a.cc:57:20: error: expected ';' before 'i'
   57 |       for (uint32_t i = 0; i < K; ++i) {
      |                    ^~
      |                    ;
a.cc:57:28: error: 'i' was not declared in this scope
   57 |       for (uint32_t i = 0; i < K; ++i) {
      |                            ^
a.cc:58:26: error: request for member 'top' in 'TempQue', which is of non-class type 'int'
   58 |         t_p[i] = TempQue.top();
      |                          ^~~
a.cc:59:17: error: request for member 'pop' in 'TempQue', which is of non-class type 'int'
   59 |         TempQue.pop();
      |                 ^~~
a.cc:62:20: error: expected ';' before 'i'
   62 |       for (uint32_t i = 0; i < K; ++i) {
      |                    ^~
      |                    ;
a.cc:62:28: error: 'i' was not declared in this scope
   62 |       for (uint32_t i = 0; i < K; ++i) {
      |                            ^
a.cc:64:40: error: request for member 'push' in 'TempQue', which is of non-class type 'int'
   64 |         if (t_p[i].first != 0) TempQue.push(t_p[i]);
      |                                        ^~~~