Language: C++

#include <bits/stdc++.h>
using namespace std;

#define int long long
using ll = long long;
const int N = 3e5+100;

int n, a[N], cnt[N];
vector<int> v;
ll ans[N];

int32_t main() {
	scanf("%lld", &n);
	for(int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		cnt[a[i]]++;
	}
	for(int i = 1; i <= n; i++) {
		if(cnt[i]) v.push_back(cnt[i]);
	} sort(v.begin(), v.end());

	int sz = v.size();
	for(int i = 0; i < sz; i++) {
		ll del = (sz - i), tmp = (i == 0 ? v[i] : v[i] - v[i - 1]);
		if(tmp == 0) continue;

		ll to = del;

		for(int k = min(del, sqrt(del) + 2); k > 1; k--) {
			int l = del / k + 1;
			int r = del / (k - 1);
			ll val = del / r;
			ans[l] += val * tmp;
			ans[r + 1] -= val * tmp;
			to = min(to, (ll)l - 1);
		}
		for(int k = 1; k <= to; k++) {
			ll val = del / k;
			ans[k] += val * tmp;
			ans[k + 1] -= val * tmp;
		}
	}
	for(int i = 1; i <= n; i++) ans[i] += ans[i - 1];
	for(int i = 1; i <= n; i++)
		printf("%lld\n", ans[i]);
	return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:29:32: error: no matching function for call to 'min(ll&, __gnu_cxx::__enable_if<true, double>::__type)'
   29 |                 for(int k = min(del, sqrt(del) + 2); k > 1; k--) {
      |                             ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:29:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'})
   29 |                 for(int k = min(del, sqrt(del) + 2); k > 1; k--) {
      |                             ~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:29:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |                 for(int k = min(del, sqrt(del) + 2); k > 1; k--) {
      |                             ~~~^~~~~~~~~~~~~~~~~~~~