criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<bits/stdc++.h>
using namespace std;
int a[2000010],l=100000,r,n,k,d;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=k;i++)
    {
        cin>>d;
        a[d]++;
        l=min(l,d);
        r=max(r,d);
    }
    if(r-i+1<=k)
    {
        cout<<"0"<<endl;
        return 0;
    }
    sort(a+l,a+r+1);
    int ans=0;
    while(r-l+1>k)
    {
        ans+=a[l];
        l++;
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'i' was not declared in this scope
   14 |     if(r-i+1<=k)
      |          ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N,K;
  cin >> N >> K;
  
  vector<int>ball(N);
  
  for(int i=0;i<N;i++){
    cin >> ball[i];
  }
  
  vector<int>number(N + 1,0);
  
  for(int i=0;i<N;i++){
    number[ball[i]]++;
  }
  
  sort(number.begin(),number.end(),greater<int>());
  
  int ans = 0;
  
  if(N == K)
    cout << 0 <<< endl;
  else{
    for(int i=K+1;i<=N;i++){
    ans += number[i];
    }
  
  cout << ans << endl;
  }
  
  return 0;
}

    

Compiler output:
a.cc: In function 'int main()':
a.cc:26:17: error: expected primary-expression before '<' token
   26 |     cout << 0 <<< endl;
      |                 ^
Language: C++

#include <iostream>
#include <map>
#include <vector>
#include <algorithm> 
int main() {
  int N,K;
  std::cin >> N >> K;
  std::map<int,int> baket;
  for(int i=0; i<N; i++){
    int n;
    std::cin >> n;
    if(baket.count(n))
      baket[n]++;
    else
      baket[n] = 0;
  }
  std::vector<int> cnt;
  for(auto &b:baket)
    cnt.push_back(b.second;
  std::sort(cnt.begin(),cnt.end());
  int sum=0;
  for(int i=0; i<cnt.size()-K;i++)
    sum+=cnt[i];
  std::cout << sum << std::endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:27: error: expected ')' before ';' token
   19 |     cnt.push_back(b.second;
      |                  ~        ^
      |                           )
Language: C++

#include <iostream>
#include <map>
#include <vector>

int main() {
  int N,K;
  std::cin >> N >> K;
  std::map<int,int> baket;
  for(int i=0; i<N; i++){
    int n;
    std::cin >> n;
    if(baket.count(n))
      baket[n]++;
    else
      baket[n] = 0;
  }
  std::vector<int> cnt;
  for(auto &b:baket)
    cnt.push_back(b.second());
  std::sort(cnt.begin(),cnt.end());
  int sum=0;
  for(int i=0; i<cnt.size()-K;i++)
    sum+=cnt[i];
  std::cout << sum << std::endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:27: error: expression cannot be used as a function
   19 |     cnt.push_back(b.second());
      |                   ~~~~~~~~^~
a.cc:20:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   20 |   std::sort(cnt.begin(),cnt.end());
      |        ^~~~
      |        qsort
Language: C++

#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n,k,ans=0;
    cin >> n >> k;
    vector<int> a(n)={};
    for(int i=0;i<n;i++){
        int b;
        cin >> b;
        a.at(b-1)++;
    }
    sort(a.begin(),a.end());
    for(int i=k;i<n;i++){
        ans+=a.at(i);
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:21: error: expected ',' or ';' before '=' token
   11 |     vector<int> a(n)={};
      |                     ^
Language: C++

#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n,k,ans=0;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        int b
        cin >> b;
        a.at(b-1)++;
    }
    sort(a.begin(),a.end());
    for(int i=k;i<n;i++){
        ans+=a.at(i);
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: expected initializer before 'cin'
   14 |         cin >> b;
      |         ^~~
a.cc:15:14: error: 'b' was not declared in this scope
   15 |         a.at(b-1)++;
      |              ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

int B[200010];

int main() {
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        B[A]++;
    }
    sort(RALL(B));
    int sum = 0;
    for (int i = 0; i < K; i++)
    {
        sum += B[i];
    }
    cout << N - sum << endl;
    getchar(); getchar();
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:25: error: request for member 'rbegin' in 'B', which is of non-class type 'int [200010]'
   11 | #define RALL(obj) (obj).rbegin(),(obj).rend()
      |                         ^~~~~~
a.cc:32:10: note: in expansion of macro 'RALL'
   32 |     sort(RALL(B));
      |          ^~~~
a.cc:11:40: error: request for member 'rend' in 'B', which is of non-class type 'int [200010]'
   11 | #define RALL(obj) (obj).rbegin(),(obj).rend()
      |                                        ^~~~
a.cc:32:10: note: in expansion of macro 'RALL'
   32 |     sort(RALL(B));
      |          ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(200010);
  int N,M;
  cin>>N>>M;
  for(int i=0;i<N;i++){
    int b;
    cin>>b;
    a[b]++;
  }
  sort(a.rbegin(),a.rend());
  int counter=0;
  for(int i=0;i<K;i++){
    counter+=a[i];
  }
  cout<<counter<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: 'K' was not declared in this scope
   14 |   for(int i=0;i<K;i++){
      |                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int a[200010];
  int N,M;
  cin>>N>>M;
  for(int i=0;i<N;i++){
    int b;
    cin>>b;
    a[b]++;
  }
  sort(a.rbegin(),a.rend());
  int counter=0;
  for(int i=0;i<K;i++){
    counter+=a[i];
  }
  cout<<counter<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:10: error: request for member 'rbegin' in 'a', which is of non-class type 'int [200010]'
   12 |   sort(a.rbegin(),a.rend());
      |          ^~~~~~
a.cc:12:21: error: request for member 'rend' in 'a', which is of non-class type 'int [200010]'
   12 |   sort(a.rbegin(),a.rend());
      |                     ^~~~
a.cc:14:17: error: 'K' was not declared in this scope
   14 |   for(int i=0;i<K;i++){
      |                 ^
Language: C++

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

int main(){
  int n,k;
  cin >>n >>k;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin >>a[i];
  sort(a.begin(),a.end());
  int x=1;
  for(int i=0;i<n-1;i++){
    if(a[i]!=a[i+1])
      x++;
  }
  if(x>k)
    cout <<x-k <<endl;
  else
    cout <"0" <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:15: error: invalid operands of types 'const char [2]' and '<unresolved overloaded function type>' to binary 'operator<<'
   19 |     cout <"0" <<endl;
      |           ~~~~^~~~~~
Language: C++

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

int main(){
  int n,k;
  cin >>n >>k;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin >>a[i];
  sort(a.begin(),a.end());
  int x=1;
  for(int i=0;i<n-1;i++){
    if(a[i]!=a[i+1])
      x++;
  }
  if(x>k)
    cout <<x-k <<endl;
  else
    cout <'0' <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:15: error: invalid operands of types 'char' and '<unresolved overloaded function type>' to binary 'operator<<'
   19 |     cout <'0' <<endl;
      |           ~~~~^~~~~~
Language: C++

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

int main()
{
    int N, K;
    cin >> N >> K;

    vector<int> nums(N);
    for (int i = 0; i < N; i++)
        cin >> nums.at(i);

    vector<int> packet(N + 1, 0);
    for (int x : nums)
        packet.at(x)++;

    sort(packet.begin(), packet.end());

    int ans = 0;
    for (int i = 0; i <= N; i++)
    {
        if (packet.at(x) == 0)
            continue;

        ans += packet.at(x);
        if (N - 1 - K == i)
        {
            cout << ans << endl;
            return 0;
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:23: error: 'x' was not declared in this scope
   22 |         if (packet.at(x) == 0)
      |                       ^
a.cc:25:26: error: 'x' was not declared in this scope
   25 |         ans += packet.at(x);
      |                          ^
Language: C++

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N),B(N);
  for(int i=0; i<N; i++){
    cin A.at(i);
  }
  int k=0;
  for(int i=1; i<=N; i++){
    for(int j=0; j<N; j++){
      if(i=A.at(j)){
        k++;
      }
    }
    B.at(i)=k;
    k=0;
  }
  sort(B.begin(), B.end());
  for(int i=0; i<N-K; i++){
    k+=B.at(i);
  }
  cout << k << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:8: error: expected ';' before 'A'
    9 |     cin A.at(i);
      |        ^~
      |        ;
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(){
  int n,k;
  cin>>n>>k;
  map<int,int> mp;
  int a;
  REP(i,n){
    cin>>a;
    mp[a]++;
  }
  vector<pair<int,int>> cnts;
  int num,cnt;
  for(auto p:mp){
    num = p.first;
    cnt = p.second;
    cnts.push_back(make_pair(cnt,num));
  }
  
  sort(cnts.begin(),cnts.end());
  int ans=0;
  int change=cnts.size()-k;
  change = max(0,change);
  REP(i,change){
    ans += cnts[i].first();
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:25: error: expression cannot be used as a function
   27 |     ans += cnts[i].first();
      |            ~~~~~~~~~~~~~^~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(){
  int n,k;
  cin>>n>>k;
  map<int,int> mp;
  int a;
  REP(i,n){
    cin>>a;
    mp[a]++;
  }
  vector<pair<int,int>> cnts;
  int num,cnt;
  for(auto p:mp){
    num = p.first;
    cnt = p.second;
    cnts.push_back(make_pair(cnt,num));
  }
  
  sort(cnts.begin(),cnts.end());
  int ans=0;
  int change=cnts.size()-k;
  change = max(0,change);
  REP(i,change){
    ans += cnts.first();
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:17: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   27 |     ans += cnts.first();
      |                 ^~~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(){
  int n,k;
  cin>>n>>k;
  map<int,int> mp;
  int a;
  REP(i,n){
    cin>>a;
    mp[a]++;
  }
  vector<pair<int,int>> cnts;
  int num,cnt;
  for(auto p:mp){
    num = p.first;
    cnt = p.second;
    cnts.push_back(make_pair(cnt,num));
  }
  
  sort(cnts.begin(),cnts.end());
  int ans=0;
  int change;
  change = max(0,cnts.size()-k);
  REP(i,change){
    ans += cnts.first();
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:15: error: no matching function for call to 'max(int, std::vector<std::pair<int, int> >::size_type)'
   25 |   change = max(0,cnts.size()-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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:25:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'})
   25 |   change = max(0,cnts.size()-k);
      |            ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:25:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |   change = max(0,cnts.size()-k);
      |            ~~~^~~~~~~~~~~~~~~~~
a.cc:27:17: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   27 |     ans += cnts.first();
      |                 ^~~~~
Language: C++

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

int getnum() {
    char C; int s = 0,t = 1
    while (!isdigit(C = getchar())) if(c=='-') t=-1;
    do {s = s * 10 + c - '0'; } while( isdigit( c = getchar()));
    return s * t;
}   

int main() {
  int N = getnum();
  int K = getnum();
  int A[200000];
  int kinds = 0
  while(N--) {
    int a = getnum();
    if (!A[a]) kinds++;
    A[a]++;
  }
  sort(A+1, A+N+1);
  int cnt = 0;
  if(kinds > K) for (int i = 0; i < kinds - K; i++) cnt += A[i];
  printf("%d\n", cnt);
}

Compiler output:
a.cc: In function 'int getnum()':
a.cc:6:5: error: expected ',' or ';' before 'while'
    6 |     while (!isdigit(C = getchar())) if(c=='-') t=-1;
      |     ^~~~~
a.cc:7:22: error: 'c' was not declared in this scope
    7 |     do {s = s * 10 + c - '0'; } while( isdigit( c = getchar()));
      |                      ^
a.cc:7:49: error: 'c' was not declared in this scope
    7 |     do {s = s * 10 + c - '0'; } while( isdigit( c = getchar()));
      |                                                 ^
a.cc: In function 'int main()':
a.cc:16:3: error: expected ',' or ';' before 'while'
   16 |   while(N--) {
      |   ^~~~~
Language: C++

#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define yokuwaruprime (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  rep(i,n){
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:2: error: expected '}' at end of input
   20 | }
      |  ^
a.cc:14:11: note: to match this '{'
   14 | int main(){
      |           ^
Language: Java

import java.util.Scanner;
public class AC_081_C {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int data[] = new int[n];
		int group[] = new int[n+1];
		int sum = 0;
		int alter = 0;
		for(int i = 0; i < n; i++) {
			data[i] = sc.nextInt();
			group[data[i]]++;
		}
		for(int i = 1; i < n+1; i++) {
			if(group[i] > 0) {
				sum++;
			}
		}
		while(sum > k) {
			int min = n;
			int ming = 0;
			for(int i = 1; i < n+1; i++) {
				if(group[i] > 0 && group[i] < min) {
					min = group[i];
					ming = i;
				}
			}
			group[ming] = 0;
			alter = alter + min;
			sum=sum-1;
		}
		System.out.println(alter);
	}
}

Compiler output:
Main.java:2: error: class AC_081_C is public, should be declared in a file named AC_081_C.java
public class AC_081_C {
       ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int
 
/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
 
/* func */
 
/*struct*/
struct aaa {
	aaa() {
		cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);
	};
}aaaaaaa;
 
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 9o'clock direction
//Take the x-axis downward and the y-axis right
 
//#define int ll
//#define int long long
 
 int a[200010];
signed main()
{
  int n, k;
  cin>>n>>k;
  for(int i = 0; i < n; ++i){
    int t;
    cin>>t;
    ++a[t];
  }
  sort(a, a+n+1);
  int ans = 0;
  for(int i = 0; i <= n-k; ++i)
    ans += a[i];
    cout<<ans;
  }

  return 0;
}

Compiler output:
a.cc:80:3: error: expected unqualified-id before 'return'
   80 |   return 0;
      |   ^~~~~~
a.cc:81:1: error: expected declaration before '}' token
   81 | }
      | ^
Language: C++

#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  map<ll,ll>MP;
  for(int i=0;i<n;i++){ll a;cin>>a;MP[a]++;}
  vi num;
  for(auto a:MP){
    num.pb(a.S);
  }
  ll ans=0;
  sort(ALL(num));
  for(int i=0;i<max(0LL,num.size()-k);i++)
    ans+=num[i];
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:20: error: no matching function for call to 'max(long long int, long long unsigned int)'
   33 |   for(int i=0;i<max(0LL,num.size()-k);i++)
      |                 ~~~^~~~~~~~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:33:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   33 |   for(int i=0;i<max(0LL,num.size()-k);i++)
      |                 ~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:33:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   33 |   for(int i=0;i<max(0LL,num.size()-k);i++)
      |                 ~~~^~~~~~~~~~~~~~~~~~
Language: Java

package atCoder;

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class main {
	public static void main(String[] args) throws IOException {
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		int[] firstLine = Stream.of(stdin.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int[] elements = Stream.of(stdin.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int maxNumsOfType = firstLine[1];
		HashMap<Integer, Integer> numCounter = new HashMap<Integer, Integer>();
		Arrays.stream(elements).forEach(num -> {
			if (!numCounter.containsKey(num)) numCounter.put(num,1);
			else numCounter.put(num, numCounter.get(num)+1);
		});
		//System.out.println(numCounter);
		int numsOfType = 0;
		int changedSum = 0;
		for(int i = 0; i < numCounter.keySet().size(); i++) {
			numsOfType++;
		}
		while(numsOfType > maxNumsOfType) {
			int minNum = minKey(numCounter);
			changedSum += numCounter.get(minNum);
			numCounter.remove(minNum);
			numsOfType--;
		}
		System.out.println(changedSum);
	}
	
	public static int minKey(HashMap<Integer, Integer> hashMap) {
		int[] min = { Integer.MAX_VALUE , Integer.MAX_VALUE };
		for (int key: hashMap.keySet()){
			int value = hashMap.get(key);
			if(min[1] > value) {
				min[0] = key;
				min[1] = value;
			}
		}
		return min[0];
	}
}

Compiler output:
Main.java:7: error: class main is public, should be declared in a file named main.java
public class main {
       ^
1 error
Language: Java

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class C81 {
	public static void main(String[] args) throws IOException {
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		int[] firstLine = Stream.of(stdin.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int[] elements = Stream.of(stdin.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int maxNumsOfType = firstLine[1];
		HashMap<Integer, Integer> numCounter = new HashMap<Integer, Integer>();
		Arrays.stream(elements).forEach(num -> {
			if (!numCounter.containsKey(num)) numCounter.put(num,1);
			else numCounter.put(num, numCounter.get(num)+1);
		});
		//System.out.println(numCounter);
		int numsOfType = 0;
		int changedSum = 0;
		for(int i = 0; i < numCounter.keySet().size(); i++) {
			numsOfType++;
		}
		while(numsOfType > maxNumsOfType) {
			int minNum = minKey(numCounter);
			changedSum += numCounter.get(minNum);
			numCounter.remove(minNum);
			numsOfType--;
		}
		System.out.println(changedSum);
	}
	
	public static int minKey(HashMap<Integer, Integer> hashMap) {
		int[] min = { Integer.MAX_VALUE , Integer.MAX_VALUE };
		for (int key: hashMap.keySet()){
			int value = hashMap.get(key);
			if(min[1] > value) {
				min[0] = key;
				min[1] = value;
			}
		}
		return min[0];
	}
}

Compiler output:
Main.java:5: error: class C81 is public, should be declared in a file named C81.java
public class C81 {
       ^
1 error
Language: C++

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N), d(N) = {0};
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
    d.at(A.at(i))++;
  }
  
  sort(d.begin(), d.end());

  int S = 0;
  for (int i = 0; i < N; i++) {
    if (i < N - K) S += d.at(i);
  }
  
  cout << S << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:26: error: expected ',' or ';' before '=' token
    7 |   vector<int> A(N), d(N) = {0};
      |                          ^
Language: C++

#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a[200001];
	int N; cin >> N;
	int K; cin >> K;

	REP(i, N) {
    int tmp;
    cin >> tmp;
		a[tmp]++;
  }

  sort(a, a+N+1);

  int ans = 0;
  for(int i = 0; i <= N-K; ++i)
    ans += a[i];
  }

  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc:37:3: error: 'cout' does not name a type
   37 |   cout << ans << endl;
      |   ^~~~
a.cc:38:3: error: expected unqualified-id before 'return'
   38 |   return 0;
      |   ^~~~~~
a.cc:39:1: error: expected declaration before '}' token
   39 | }
      | ^
Language: C++

#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a[200001];
	int N; cin >> N;
	int K; cin >> K;
	map<int, int> mp;

	REP(i, N) {
    int tmp;
    cin >> tmp;
		a[tmp]++;
  }

  sort(a, a+n+1);

  int ans = 0;
  REP(i, N - K + 1) {
    ans += a[i];
  }

  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:13: error: 'n' was not declared in this scope
   31 |   sort(a, a+n+1);
      |             ^
Language: C++

#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a[200001];
	int N; cin >> N;
	int K; cin >> K;
	map<int, int> mp;

	REP(i, N) {
    int tmp;
    cin >> tmp;
		a[tmp]++;
  }

  sort(A, A+n+1);

  int ans = 0;
  REP(i, N - K + 1) {
    ans += a[i];
  }

  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:8: error: 'A' was not declared in this scope
   31 |   sort(A, A+n+1);
      |        ^
a.cc:31:13: error: 'n' was not declared in this scope
   31 |   sort(A, A+n+1);
      |             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i, ball, balls, num_ball_type;
    int ball_type[210000] = {0};
    int counter = 0;
    int number_of_changed_type = 0;

    cin >> balls >> num_ball_type;

    for (i=0; i<balls; i++) {
        cin >> ball;
        ball_type[ball]++;
    }

    sort(ball_type, ball_type+210000, greater<int>());
    
    for (i=0, i<210000; i++) {

        if(ball_type[i] == 0) {
            break;
        }
        if(counter >= num_ball_type) { //ボールの種類をカウントしている．カウンターがK以上になった場合(0から)，変更するボールを数え始める
            number_of_changed_type += ball_type[i];
        } else {
            counter++;
        }
    }

    cout << number_of_changed_type << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:28: error: expected ';' before ')' token
   19 |     for (i=0, i<210000; i++) {
      |                            ^
      |                            ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    int min = 400000;
    for (int i=0; i<N; i++) {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    int num = 0;
    vector<int> cnt(N);
    for (int i=0; i<N; i++) {
        cnt.at(A.at(i) - 1)++;
    }
    int num = 0;
    for (int i=0; i<N; i++) {
        if (cnt.at(i) != 0) num++;
    }
    if (num <= K) cout << 0 << endl;
    else {
        sort(cnt.begin(), cnt.end(), greater<int>());
        int sum = 0;
        for (int i=0; i<K; i++) {
            sum += cnt.at(i);
        }
        int ans = N - sum;
        cout << ans << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: redeclaration of 'int num'
   18 |     int num = 0;
      |         ^~~
a.cc:13:9: note: 'int num' previously declared here
   13 |     int num = 0;
      |         ^~~
Language: C++

#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
 int n,k;cin>>n>>k;
int a[n];
  rep(i, n){int p;
            cin>>p;
            a[p-1]++;}
  
  sort(a,a+n,reverse<int>());
  
  int dec=0;
  rep(i, k)dec+=a[i];
  
  cout<<n-dec<<endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:26: error: no matching function for call to 'reverse<int>()'
   14 |   sort(a,a+n,reverse<int>());
      |              ~~~~~~~~~~~~^~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:1083:5: note: candidate: 'template<class _BIter> void std::reverse(_BIter, _BIter)'
 1083 |     reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
      |     ^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1083:5: note:   candidate expects 2 arguments, 0 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:249:1: note: candidate: 'template<class _ExecutionPolicy, class _BidirectionalIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::reverse(_ExecutionPolicy&&, _BidirectionalIterator, _BidirectionalIterator)'
  249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
      | ^~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:249:1: note:   candidate expects 3 arguments, 0 provided
Language: C++

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

# you have n balls.  i-th ball is written Ai
# we want for a kind of numbers to be lessor or equal to K by re-writing ball number Ai
# calculate minimum count

# 方針
# 何種類あるかを調べる : num_cnt
# その中でもっとも個数の少ないものから順に書き換える : num_cnt - K 
# ただし num_cnt > k の場合にのみこの操作をする

num = [0]*max(A)
cnt = [0]*max(A)

# count sequence
for a in A:
    if num[a-1] == 0:
        num[a-1] = 1

    cnt[a-1] += 1

kind = sum(num)

if kind > K:
    new_cnt = sorted([e for e in cnt if e != 0])
    res = sum(new_cnt[:(kind-K)])
else:
    res = 0

print(res)

Compiler output:
a.cc:4:3: error: invalid preprocessing directive #you
    4 | # you have n balls.  i-th ball is written Ai
      |   ^~~
a.cc:5:3: error: invalid preprocessing directive #we
    5 | # we want for a kind of numbers to be lessor or equal to K by re-writing ball number Ai
      |   ^~
a.cc:6:3: error: invalid preprocessing directive #calculate
    6 | # calculate minimum count
      |   ^~~~~~~~~
a.cc:8:3: error: invalid preprocessing directive #\U000065b9\U000091dd
    8 | # 方針
      |   ^~~~
a.cc:9:3: error: invalid preprocessing directive #\U00004f55\U00007a2e\U0000985e\U00003042\U0000308b\U0000304b\U00003092\U00008abf\U00003079\U0000308b
    9 | # 何種類あるかを調べる : num_cnt
      |   ^~~~~~~~~~~~~~~~~~~~
a.cc:10:3: error: invalid preprocessing directive #\U0000305d\U0000306e\U00004e2d\U00003067\U00003082\U00003063\U00003068\U00003082\U0000500b\U00006570\U0000306e\U00005c11\U0000306a\U00003044\U00003082\U0000306e\U0000304b\U00003089\U00009806\U0000306b\U000066f8\U0000304d\U000063db\U00003048\U0000308b
   10 | # その中でもっとも個数の少ないものから順に書き換える : num_cnt - K
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:11:3: error: invalid preprocessing directive #\U0000305f\U00003060\U00003057
   11 | # ただし num_cnt > k の場合にのみこの操作をする
      |   ^~~~~~
a.cc:16:3: error: invalid preprocessing directive #count
   16 | # count sequence
      |   ^~~~~
a.cc:1:1: error: 'N' does not name a type
    1 | N, K = map(int, input().split())
      | ^
Language: C++

//
//  main.cpp
//  ABC081-c
//
//  Created by hiroaki on 2019/02/17.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n,k;
    cin >>n>>k;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin>>a.at(i);
    }
    int b[200001]={0};
    vector<int> v={a[0]};//elsements
    for (int i=0;i<n; i++) {
        int flag=0;
        for (int j=0; j<v.size(); j++) {
            if (a[i]==v[j]) {
                flag=1;
            }
        }
        if (flag==0) {
            v.push_back(a[i]);
        }
    }
    for (int i=0; i<n; i++) {
        b[a[i]]++;
    }
    vector<int> s;
    for (int i=0; i<v.size(); i++) {
        s.push_back(b[v[i]]);
    }
    std::sort(s.begin(), s.end());
    int sum=0;
    for (int i=0; i<k; i++) {
        sum=sum+s[s.size()-(i+1)];
    }
    cout<<n-sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   41 |     std::sort(s.begin(), s.end());
      |          ^~~~
      |          qsort
Language: C++

//
//  main.cpp
//  ABC081-c
//
//  Created by hiroaki on 2019/02/17.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n,k;
    cin >>n>>k;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin>>a.at(i);
    }
    int b[200001]={0};
    vector<int> v={a[0]};//elsements
    for (int i=0;i<n; i++) {
        int flag=0;
        for (int j=0; j<v.size(); j++) {
            if (a[i]==v[j]) {
                flag=1;
            }
        }
        if (flag==0) {
            v.push_back(a[i]);
        }
    }
    for (int i=0; i<n; i++) {
        b[a[i]]++;
    }
    vector<int> s;
    for (int i=0; i<v.size(); i++) {
        s.push_back(b[v[i]]);
    }
    sort(s.begin(), s.end(),0);
    int sum=0;
    for (int i=0; i<k; i++) {
        sum=sum+s[s.size()-(i+1)];
    }
    cout<<n-sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   41 |     sort(s.begin(), s.end(),0);
      |     ^~~~
      |     short
Language: C++

//
//  main.cpp
//  ABC081-c
//
//  Created by hiroaki on 2019/02/17.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n,k;
    cin >>n>>k;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin>>a.at(i);
    }
    int b[200001]={0};
    vector<int> v={a[0]};//elsements
    for (int i=0;i<n; i++) {
        int flag=0;
        for (int j=0; j<v.size(); j++) {
            if (a[i]==v[j]) {
                flag=1;
            }
        }
        if (flag==0) {
            v.push_back(a[i]);
        }
    }
    for (int i=0; i<n; i++) {
        b[a[i]]++;
    }
    vector<int> s;
    for (int i=0; i<v.size(); i++) {
        s.push_back(b[v[i]]);
    }
    sort(s.begin(), s.end());
    int sum=0;
    for (int i=0; i<k; i++) {
        sum=sum+s[s.size()-(i+1)];
    }
    cout<<n-sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   41 |     sort(s.begin(), s.end());
      |     ^~~~
      |     short
Language: C++



#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n,k;
    cin >>n>>k;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin>>a.at(i);
    }
    int b[200001]={0};
    vector<int> v={a[0]};//elsements
    for (int i=0;i<n; i++) {
        int flag=0;
        for (int j=0; j<v.size(); j++) {
            if (a[i]==v[j]) {
                flag=1;
            }
        }
        if (flag==0) {
            v.push_back(a[i]);
        }
    }
    for (int i=0; i<n; i++) {
        b[a[i]]++;
    }
    vector<int> s;
    for (int i=0; i<v.size(); i++) {
        s.push_back(b[v[i]]);
    }
    sort(s.begin(), s.end());
    int sum=0;
    for (int i=0; i<k; i++) {
        sum=sum+s[s.size()-(i+1)];
    }
    cout<<n-sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   35 |     sort(s.begin(), s.end());
      |     ^~~~
      |     short
Language: C++

#include <vector>
#include <iostream>
#include <unordered_map>

int main(void) {
	int N, K, V;
	std::cin >> N >> K;

	std::unordered_map<int, int> mymap;

	for (int i = 0; i < N; i++) {
		std::cin >> V;
		if (mymap.find(V) == mymap.end()) {
			mymap[V] = 1;
		} else {
			int v = mymap[V];
			mymap[V] = v + 1;
		}
	}

	std::vector<int> count;
	for (std::unordered_map<int, int>::iterator it = mymap.begin();
			it != mymap.end(); ++it) {
		count.push_back(it->second);
	}
	std::sort(count.begin(), count.end());
	int res = 0;
	for (int i = 0; i < count.size() - K; i++) {
		res += count[i];
	}
	std::cout << res;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:14: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   26 |         std::sort(count.begin(), count.end());
      |              ^~~~
      |              qsort
Language: C++

#include<iostream>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    int a[n];
    int bucket[200001];
    for (int i = 1; i < 200001; ++i) {
        bucket[i] = 0;
    }
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        bucket[a[i]]++;
    }
    sort(bucket + 1, bucket + 200001, greater<int>());
    int ans = 0;
    for (int i = 1; i < 200001; ++i) {
        if (i <= k) continue;
        if (bucket[i] == 0) break;
        ans += bucket[i];
    }
    cout << ans << endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |     sort(bucket + 1, bucket + 200001, greater<int>());
      |     ^~~~
      |     short
Language: C++

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

int main(){
    int N,K,A[200000];
    cin >> N >> K;
    for (int i=0; i<N; ++i) cin >> A[i];

    int num[200000] = {0};
    for (int i=0; i < N; ++i) {
        num[A[i]-1]++;
    }
    sort (num,num+N,great<int>());
    int sum;
    for (int i=N; i>=K; --i){
        sum += num[i];
    }
    cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:21: error: 'great' was not declared in this scope
   16 |     sort (num,num+N,great<int>());
      |                     ^~~~~
a.cc:16:27: error: expected primary-expression before 'int'
   16 |     sort (num,num+N,great<int>());
      |                           ^~~
Language: C++

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

int main(){
    int N,K,A[200000];
    cin >> N >> K;
    for (int i=0; i<N; ++i) cin >> A[i];

    int num[200000] = {0};
    for (int i=0; i < N; ++i) {
        num[A[i]-1]++;
    }
    sort (num,num+N,great<int>());
    int sum;
    for (int i=N; i>=K; --i){
        sum += num[i];
    }
    cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:21: error: 'great' was not declared in this scope
   15 |     sort (num,num+N,great<int>());
      |                     ^~~~~
a.cc:15:27: error: expected primary-expression before 'int'
   15 |     sort (num,num+N,great<int>());
      |                           ^~~
Language: C++

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

int main(){
	int n,k,input,t,ans=0;cin>>n>>k;
  	vector<int> a(n);
  	map<int,int> mp;
  
 	for(int i=0;i<n;i++){
    	cin>>input;
      	a[i]=input;
      	mp[input]=0;
    }
  	
  for(int i=0;i<n;i++){
      	mp[a[i]]++;
    }
  
  //何種る減らす必要があるか？（0だったら終了）
  t=mp.size()-k;
  if(t<=0){ cout<<0<<endl; return 0;}
  
  //mapのsecondをvector bに移し、sort
  vector<int> b(mp.size(),0);
  int w=0;
  for(auto itr=mp.begin();itr!=mp.end();++itr){
  	b[w++]=itr->second;
  }
  sort(b.begin(),b.end());
  for(int i=0;i<t;i++){
  	ans+=b[i];
  }
  cout

Compiler output:
a.cc: In function 'int main()':
a.cc:33:7: error: expected ';' at end of input
   33 |   cout
      |       ^
      |       ;
a.cc:33:7: error: expected '}' at end of input
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include<iostream>

using namespace std;

typedef long long LL;
typedef unsigned long long uLL;
typedef long double ldb;
typedef pair<int,int> pii;

int A[200001];

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k;
    cin>>n>>k;
    for(int i = 0; i < n; ++i)
    {
        int inp;
        cin>>inp;
        ++A[inp];
    }
    sort(A, A+n+1);
    reverse(A,A+n+1);
    int ans = 0;
    for(int i = k; i <=n; ++i)
        ans += A[i];
    cout<<ans;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   23 |     sort(A, A+n+1);
      |     ^~~~
      |     short
a.cc:24:5: error: 'reverse' was not declared in this scope
   24 |     reverse(A,A+n+1);
      |     ^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000;
#define mod MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    int n, k; cin >> n >> k;
    int a[n];
    map<int, int> mp;
    set<int> w;
    vector<int> v;
    int ans = 0;
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        mp[a[i]]++;
        w.insert(a[i]);
    }
    int s = w.size();
    for(int i = 0; i < w.size(); i++){
        sum += mp[a[i]];
        v.push_back(mp[w[i]]);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    for(int i = 0; i < w.size(); i++){
        if(s <= k){
            break;
        } else {
            s--;
            ans += mp[v[i]];
        }
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:25: error: no match for 'operator[]' (operand types are 'std::set<int>' and 'int')
   26 |         v.push_back(mp[w[i]]);
      |                         ^
Language: C++

#include <iostream>
#include <set>
#include <string>
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a,a+n,greater<>());
    set<int>st;
    int x[300000]={0};
    for(int i=0;i<n;i++){
        st.insert(a[i]);
        x[a[i]]++;
    }
    int no=st.size();
    int y=no-k;
    sort(x,x+300000,greater<>());
    int ans=0;
    for(int i=no-y;i<no;i++)ans+=x[i];
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |     sort(a,a+n,greater<>());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <set>
#include <string>
using namespace std;

int main(){
    int n,k,a[n];
    cin >> n >> k;
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a,a+n,greater<>());
    set<int>st;
    int x[300000]={0};
    for(int i=0;i<n;i++){
        st.insert(a[i]);
        x[a[i]]++;
    }
    int no=st.size();
    int y=no-k;
    sort(x,x+300000,greater<>());
    int ans=0;
    for(int i=no-y;i<no;i++)ans+=x[i];
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |     sort(a,a+n,greater<>());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <set>
#include <string>
using namespace std;

int main(){
    int n,k,a[n];
    cin >> n >> k;
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a,a+n);
    set<int>st;
    int x[300000]={0};
    for(int i=0;i<n;i++){
        st.insert(a[i]);
        x[a[i]]++;
    }
    int no=st.size();
    int y=no-k;
    sort(x,x+300000,greater<>());
    int ans=0;
    for(int i=no-y;i<no;i++)ans+=x[i];
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |     sort(a,a+n);
      |     ^~~~
      |     short
Language: C++

#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<queue>
#include<iostream>
#include<unorded_map>
using namespace std;
typedef long long ll;
typedef double lf;
typedef unsigned un;
typedef int in;
#define mian main
#define maxn 10000+10
#define maxm 10000+10
#define _(a) read(a)
#define non void
#define inf 2147483647
#define bre break
#define con continue
#define prq priority_queue
#define re register
#define bu bool
#define cz char
#define cst const
#define ope operator
#define inl inline
#define upp upper_bound
#define low lower_bound
#define next_per next_permutation
inl cz gc(){static cz buf[100000],*L=buf,*R=buf;return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;}
template<typename T>inl T Max(T a,T b){return a>b?a:b;}
template<typename T>inl T Min(T a,T b){return a<b?a:b;}
template<typename T>inl T Abs(T a){return a<0?-a:a;}
template<typename T>inl non read(T &a){a=0;T k=1;char c=gc();while(c<'0'||c>'9')k=c=='-'?-1:k,c=gc();while(c>='0'&&c<='9')a=a*10+(c^48),c=gc();if(c!='.'){a*=k;return;}T t=0.1;while(c<'0'||c>'9')c=gc();while(c>='0'&&c<='9')a+=t*(c^48),c=gc(),t*=0.1;a*=k;}
template<typename T>non write(T a,cz t=' '){if(a==0){putc(48,stdout),putc(t,stdout);return;}if(a<0){a=-a;putc('-',stdout);}cz c[30];in le=0;while(a){c[++le]=a%10+48;a/=10;}for(re in i=le;i>=1;--i)putc(c[i],stdout);putc(t,stdout);}
unorded_map<int,int>m;
in n,k,a,s;
in main()
{
	read(n),read(k);
	for(re in i=1;i<=n;++i){read(a);if(!m[a])m[a]=1,++s;}
	cout<<k-s<<endl;
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
}


Compiler output:
a.cc:8:9: fatal error: unorded_map: No such file or directory
    8 | #include<unorded_map>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+5;
int n,k;
bool b[MAXN];
int main(){
    scanf ("%d%d",&n,&k);
    for (int i=0;i<n;i++){
        int x;
        scanf ("%d",x);
        b[x]=1;
    }
    for (int i=0;i<MAXN;i++)
        if (b[i]) sum++;
    if (sum>k) printf ("0\n");
    else printf ("%d\n",n-sum);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:19: error: 'sum' was not declared in this scope
   14 |         if (b[i]) sum++;
      |                   ^~~
a.cc:15:9: error: 'sum' was not declared in this scope
   15 |     if (sum>k) printf ("0\n");
      |         ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  vector<int> c(n+1);
  for(i=0;i<=n;i++)c[i]=0;
  int y=0;
  int a[n];for(int i=0;i<n;i++){
    cin>>a[i];
    if(c[a[i]]==0)y++;
    c[a[i]]++;
  }
  int ans=0;
  sort(c.begin(),c.end());
  for(int i=n+1-y;;i++){
    if(y<=k){
      cout<<ans<<endl;
      return 0;
    }
    ans+=c[i];
    y--;
  }
}
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:6:7: error: 'i' was not declared in this scope
    6 |   for(i=0;i<=n;i++)c[i]=0;
      |       ^
Language: C++

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

int main()
{
	int N, K, A[201010];
	cin >> N >>K;
	for (int i = 0; i < N; i++){
		cin>>A[i];
	}
	map<int, int> cnt;
	for (int i = 0; i < N; i++) {
		cnt[A[i]]++;
	}
	int x = map.size();
	vector<int> v;
	for (int i = 0; i < x; i++) {
		v.push_back(map[i]);
	}
	sort(v.begin(), v.end());

	int n = v.size();

	if (n <= K) {
		cout << 0 << endl;
	}
	else {
		int ans = 0;
		for (int i = 0; i < n - K; i++) {
			ans += v[i];
				cout << ans << endl;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:20: error: missing template arguments before '.' token
   15 |         int x = map.size();
      |                    ^
a.cc:18:32: error: missing template arguments before '[' token
   18 |                 v.push_back(map[i]);
      |                                ^