criyle/codenet-compile-errors huggingface dataset:
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]]++;
	}
	vector<int> v;
	 v.push_back(cnt.second);
	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:16:26: error: 'class std::map<int, int>' has no member named 'second'
   16 |          v.push_back(cnt.second);
      |                          ^~~~~~
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]]++;
	}
	vector<int> v;
	fore(p, cnt) v.push_back(p.second);
	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:16:14: error: 'p' was not declared in this scope
   16 |         fore(p, cnt) v.push_back(p.second);
      |              ^
a.cc:16:9: error: 'fore' was not declared in this scope; did you mean 'fork'?
   16 |         fore(p, cnt) v.push_back(p.second);
      |         ^~~~
      |         fork
a.cc:27:36: error: expected ';' before 'cout'
   27 |                         ans += v[i]
      |                                    ^
      |                                    ;
   28 |                                 cout << ans << endl;
      |                                 ~~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<set>

using namespace std;

int main() {
	int N, K, A[N];
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	set<int> values;
	for (int i = 0; i < N; i++) {
		values.insert(A[i]);
	}
	int x = values.size();
	
	int B[x];
	for (int i = 0; i < N; i++) {
		B[A[i]]++;
	}
	sort(B, B + x,greater<int>);
	int rest=0;
	for (int i = 0; i < K; i++) {
		rest += B[i];
	}
	int ans=N-rest;
	cout << ans << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:35: error: expected primary-expression before ')' token
   23 |         sort(B, B + x,greater<int>);
      |                                   ^
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int N, K, A[N];
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	set<int> values;
	for (int i = 0; i < N; i++) {
		values.insert(A[i]);
	}
	int x = values.size();
	
	int B[x];
	for (int i = 0; i < N; i++) {
		B[A[i]]++;
	}
	sort(B, B + x,greater<int>);
	int rest=0;
	for (int i = 0; i < K; i++) {
		rest += B[i];
	}
	int ans=N-rest;
	cout << ans << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'set' was not declared in this scope
   12 |         set<int> values;
      |         ^~~
a.cc:3:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
    2 | #include<algorithm>
  +++ |+#include <set>
    3 | 
a.cc:12:13: error: expected primary-expression before 'int'
   12 |         set<int> values;
      |             ^~~
a.cc:14:17: error: 'values' was not declared in this scope
   14 |                 values.insert(A[i]);
      |                 ^~~~~~
a.cc:16:17: error: 'values' was not declared in this scope
   16 |         int x = values.size();
      |                 ^~~~~~
a.cc:22:35: error: expected primary-expression before ')' token
   22 |         sort(B, B + x,greater<int>);
      |                                   ^
Language: C++

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

int main() {
	int N, K, A[N];
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	set<int> values;
	for (int i = 0; i < N; i++) {
		insert.values(A[i]);
	}
	int x = values.size();
	
	int B[x];
	for (int i = 0; i < N; i++) {
		B[A[i]]++;
	}
	sort(B, B + x,greater<int>);
	int rest=0;
	for (int i = 0; i < K; i++) {
		rest += B[i];
	}
	int ans=N-rest;
	cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: 'insert' was not declared in this scope
   14 |                 insert.values(A[i]);
      |                 ^~~~~~
a.cc:22:35: error: expected primary-expression before ')' token
   22 |         sort(B, B + x,greater<int>);
      |                                   ^
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int N, K, A[N];
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	set<int> values;
	for (int i = 0; i < N; i++) {
		insert.values(A[i]);
	}
	int x = values.size();
	
	int B[x];
	for (int i = 0; i < N; i++) {
		B[A[i]]++;
	}
	sort(B, B + x,greater<int>);
	int rest=0;
	for (int i = 0; i < K; i++) {
		rest += B[i];
	}
	int ans=N-rest;
	cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'set' was not declared in this scope
   12 |         set<int> values;
      |         ^~~
a.cc:3:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
    2 | #include<algorithm>
  +++ |+#include <set>
    3 | 
a.cc:12:13: error: expected primary-expression before 'int'
   12 |         set<int> values;
      |             ^~~
a.cc:14:17: error: 'insert' was not declared in this scope
   14 |                 insert.values(A[i]);
      |                 ^~~~~~
a.cc:16:17: error: 'values' was not declared in this scope
   16 |         int x = values.size();
      |                 ^~~~~~
a.cc:22:35: error: expected primary-expression before ')' token
   22 |         sort(B, B + x,greater<int>);
      |                                   ^
Language: C++

#include<iostream>
#include<algorithm>
#include<sort>

using namespace std;

int main() {
	int N, K, A[N];
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	set<int> values;
	for (int i = 0; i < N; i++) {
		insert.values(A[i]);
	}
	int x = values.size();
	
	int B[x];
	for (int i = 0; i < N; i++) {
		B[A[i]]++;
	}
	sort(B, B + x,greater<int>);
	int rest=0;
	for (int i = 0; i < K; i++) {
		rest += B[i];
	}
	int ans=N-rest;
	cout << ans << endl;

}

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

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

int main() {
	int N, K, A[N];
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	set<int> values;
	for (int i = 0; i < N; i++) {
		insert.values(A[i]);
	}
	int x = values.size();
	
	int B[x];
	for (int i = 0; i < N; i++) {
		B[A[i]]++;
	}
	sort(B, B + x,greater<int>);
	int rest=0;
	for (int i = 0; i < K; i++) {
		rest += B[i];
	}
	int ans=N-rest;
	cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: 'insert' was not declared in this scope; did you mean 'assert'?
   12 |                 insert.values(A[i]);
      |                 ^~~~~~
      |                 assert
a.cc:20:35: error: expected primary-expression before ')' token
   20 |         sort(B, B + x,greater<int>);
      |                                   ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  int N,K;
  cin>>N>>K;
  
  int a[N];
  for(int i=0;i<N;++i){
    cin>>a[i];
  }
  
  // バケット法
  int bucket[N]={0};
  for(int i=0;i<N;++i){
    ++bucket[a[i]];
  }
  
  sort(bucket,bucket+N,greater<int>());
  
  int count=0;
  
  for(int i=0;i<N;++i){
    if(bucket[i]>0)
      ++count;
  }
  
  if(count<=K)
    cout<<0<<endl;
  else
    int ans=0;
    for(int i=K;i<N;++i){
      ans=ans+bucket[i];
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |       ans=ans+bucket[i];
      |       ^~~
      |       abs
a.cc:37:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |     cout<<ans<<endl;
      |           ^~~
      |           abs
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  int N,K;
  cin>>N>>K;
  
  int a[N];
  for(int i=0;i<N;++i){
    cin>>a[i];
  }
  
  // バケット法
  int bucket[N]={0};
  for(int i=0;i<N;++i){
    ++bucket[a[i]];
  }
  
  sort(bucket,bucket+N,greater<int>());
  
  int count=0;
  
  for(int i=0;i<N;++i){
    if(bucket[i]>0)
      ++count;
  }
  
  if(count<=K)
    cout<<0<<endl;
  else
    int ans=0;
    for(int i=K,i<N,++i){
      ans=ans+bucket[i];
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:18: error: expected ';' before '<' token
   34 |     for(int i=K,i<N,++i){
      |                  ^
      |                  ;
a.cc:34:18: error: expected primary-expression before '<' token
a.cc:34:24: error: expected ';' before ')' token
   34 |     for(int i=K,i<N,++i){
      |                        ^
      |                        ;
a.cc:35:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |       ans=ans+bucket[i];
      |       ^~~
      |       abs
a.cc:37:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |     cout<<ans<<endl;
      |           ^~~
      |           abs
Language: C++

#include <iostream>
#include <algorithm>
#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[i];
  }
  
  // バケット法
  int bucket[N]={0};
  for(int i=0;i<N;++i){
    ++bucket[a[i]];
  }
  
  sort(bucket.begin(),bucket.end(),greater<int>());
  
  int count=0;
  
  for(int i=0;i<N;++i){
    if(bucket[i]>0)
      ++count;
  }
  
  if(count<=K)
    cout<<0<<endl;
  //else
    //cout<<<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:15: error: request for member 'begin' in 'bucket', which is of non-class type 'int [N]'
   21 |   sort(bucket.begin(),bucket.end(),greater<int>());
      |               ^~~~~
a.cc:21:30: error: request for member 'end' in 'bucket', which is of non-class type 'int [N]'
   21 |   sort(bucket.begin(),bucket.end(),greater<int>());
      |                              ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int a[2000010];
int main(){
    int l=100000,r=0;
    int n,k;
    cin>>n>>k;
    int d;
    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;
        return 0;
    }
    sort(a+l,a+r+1);
    int ans=0;
    while(r-l+1>k)
    {
        ans+=a[l];
        l++;
    }
    cout<<ans;
    return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
int main()
{int rq[12]={31,28,31,30,31,30,31,31,30,31,30,31};
 int a,b,c,d,s;
 cin>>a>>b>>c>>d;
 if(a==c)
   {cout<<d-b<<endl;
    return 0;}
 s=rq[a]-b+d;
 for(int i=a+1,i<=c-1;i++)
    s+=rq[i];
 cout<<s<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: expected ';' before '<=' token
   11 |  for(int i=a+1,i<=c-1;i++)
      |                 ^~
      |                 ;
a.cc:11:17: error: expected primary-expression before '<=' token
   11 |  for(int i=a+1,i<=c-1;i++)
      |                 ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int a[2000010];
int main(){
    int l=100000,r=0;
    int n,k;
    cin>>n>>k;
    int d;
    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;
        return 0;
    }
    sort(a+l,a+r+1);
    int ans=0;
    while(r-l+1>k)
    {
        ans+=a[l];
        l++;
    }
    cout<<ans;
    return 0;
}

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: 'i' was not declared in this scope
    8 |     if(r-i+1<=k) return cout<<0<<endl,0;
      |          ^
Language: Java

import java.util.*;
import java.util.Map.Entry;

/**
 * @author varun on 7/1/2018
 * @project CompetitiveProgramming
 */
public class NotSoDiverse {
    private static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
        List<Entry<K, V>> list = new ArrayList<>(map.entrySet());
        list.sort(Entry.comparingByValue());
        Map<K, V> result = new LinkedHashMap<>();
        for (Entry<K, V> entry : list) {
            result.put(entry.getKey(), entry.getValue());
        }
        return result;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int maxNumKeys = scanner.nextInt();
        int[] numbers = new int[N];
        for (int i = 0; i < N; i++) numbers[i] = scanner.nextInt();
        Map<Integer, Integer> frequencyMap = new HashMap<>();
        for (int i : numbers) {
            if (frequencyMap.containsKey(i)) {
                frequencyMap.put(i, frequencyMap.get(i) + 1);
            } else {
                frequencyMap.put(i, 0);
            }
        }
        frequencyMap = sortByValue(frequencyMap);
        int ans = 0;
        while(frequencyMap.keySet().size() > maxNumKeys) {
            List<Integer> valueList = new ArrayList<>(frequencyMap.values());
            List<Integer> keySet = new ArrayList<>(frequencyMap.keySet());
            ans += valueList.get(valueList.size()-1);
            frequencyMap.remove(keySet.get(keySet.size()-1));
        }
        System.out.println(ans);
    }
}


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

#include <bits/stdc++.h>
using namespace std;
int a;int b[200009];
int main(){
  int n,k,ans=0;cin>>n>>k;
  for(int i=0;i<n;++i){
    cin>>a;
    b[a[i]]++;
  }
  int m=n-k;
  sort(b,b+n+1);
  for(int i=0;i<=m;++i){
    ans+=b[i];
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:8: error: invalid types 'int[int]' for array subscript
    8 |     b[a[i]]++;
      |        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int a;int b[200009];
int main(){
  int n,k,ans=0;cin>>n>>k;
  
  for(int i=0;i<n;++i){
    cin>>a[i];
    b[a[i]]++;
  }
  int m=n-k;
  sort(b,b+n+1);
  for(int i=0;i<=m;++i){
    ans+=b[i];
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:11: error: invalid types 'int[int]' for array subscript
    8 |     cin>>a[i];
      |           ^
a.cc:9:8: error: invalid types 'int[int]' for array subscript
    9 |     b[a[i]]++;
      |        ^
Language: C++

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>

using namespace std;


int main() {
	int i, j;
	int n, k;
	vector<int> v(205);
	vector<int> v2(205);
	map<int, int> mp;
	map<int, int>::iterator it;


	cin >> n >> k;

	for (i = 0; i < n; i++) {
		cin >> v[i];
		if (mp.count(v[i]) == 0) {
			mp.insert(pair<int, int>(v[i], 1));
		}
		else {
			mp[v[i]]++;
		}
	}

	if (mp.size() <= k) {
		cout << 0 << endl;
		goto label;
	}

	
	i = 0;
	for (it = mp.begin(); it != mp.end(); it++) {
		v2[i] = (*it).second;
		i++;
	}

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

	i = std::count(v2.begin(), v2.end(),0);
	int nn = i;
	int cnt = 0;

	for (i ; i < nn + mp.size() - k; i++) {
		cnt += v2[i];
	}

	cout << cnt << endl;








	label:


	getchar();
	getchar();
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:9: error: jump to label 'label'
   71 |         label:
      |         ^~~~~
a.cc:42:22: note:   from here
   42 |                 goto label;
      |                      ^~~~~
a.cc:56:13: note:   crosses initialization of 'int cnt'
   56 |         int cnt = 0;
      |             ^~~
a.cc:55:13: note:   crosses initialization of 'int nn'
   55 |         int nn = i;
      |             ^~
Language: C++

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

int main()
{
  int n, k;
  cin >> n >> k;
  a = new int[n];
  a = {0};
  set<int>s;
  for (int i = 0; i < n; i++) {
    int buf;
    cin >> buf;
    a[buf-1]++;
    s.insert(buf);
  }
  size_t sz;
  sz = s.size();
  int ans = 0;
  while(sz > k) {
    int* d = min_element(a, a+n);
    ans += *d;
    int j = d - a;
    s.erase(j);
    sz = s.size();
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'a' was not declared in this scope
   10 |   a = new int[n];
      |   ^
Language: C++

#include<iostream>
using namespace std;
int N, K, A[201010];
//---------------------------------------------------------------------------------------------------
int main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];

    // カウント
    map<int, int> cnt;
    rep(i, 0, N) cnt[A[i]]++;

    // 個数を抜き出して昇順ソート
    vector<int> v;
    fore(p, cnt) v.push_back(p.second);
    sort(v.begin(), v.end());
 
    int n = v.size();
 
    if (n <= K) {
        printf("0\n");
    }
    else {
        int ans = 0;
        rep(i, 0, n - K) ans += v[i];
        printf("%d\n", ans);
    }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'i' was not declared in this scope
    7 |     rep(i, 0, N) cin >> A[i];
      |         ^
a.cc:7:5: error: 'rep' was not declared in this scope
    7 |     rep(i, 0, N) cin >> A[i];
      |     ^~~
a.cc:10:5: error: 'map' was not declared in this scope
   10 |     map<int, int> cnt;
      |     ^~~
a.cc:2:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
    1 | #include<iostream>
  +++ |+#include <map>
    2 | using namespace std;
a.cc:10:9: error: expected primary-expression before 'int'
   10 |     map<int, int> cnt;
      |         ^~~
a.cc:14:5: error: 'vector' was not declared in this scope
   14 |     vector<int> v;
      |     ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include<iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:14:12: error: expected primary-expression before 'int'
   14 |     vector<int> v;
      |            ^~~
a.cc:15:10: error: 'p' was not declared in this scope
   15 |     fore(p, cnt) v.push_back(p.second);
      |          ^
a.cc:15:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
   15 |     fore(p, cnt) v.push_back(p.second);
      |             ^~~
      |             int
a.cc:15:5: error: 'fore' was not declared in this scope
   15 |     fore(p, cnt) v.push_back(p.second);
      |     ^~~~
a.cc:16:10: error: 'v' was not declared in this scope
   16 |     sort(v.begin(), v.end());
      |          ^
a.cc:16:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |     sort(v.begin(), v.end());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)
using namespace std;

int main(){
        const int AMAX = 200000;
        int N,K;
        cin >> N >> K;
        vector<int> a(AMAX + 1);
        rep(i,N){
                int x;
                cin >> x;
                a[x]++;
        }


        int p = -1;
    for(int i = 0; i <= AMAX; i++){
        if(a[i] != 0){
            p = i;
            break;
        }
    }
 
    int del = max(0UL, (a.size() - p) - k);
 
    long cnt = 0;
    for(int i = 0; i < del; i++){
        cnt += a[p + i];
    }
 
    cout << cnt << endl;
 
    return 0;
}
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main(void) {
    const int AMAX = 200000;
    int n, k;
    cin >> n >> k;

    vector<int> a(AMAX + 1);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[x]++;
    }

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

    int p = -1;
    rep(i,AMAX){
        if(a[i] != 0){
            p = i;
            break;
        }
    }

    int del = (a.size() - p) - k;

    long cnt = 0;
    rep(i,del)cnt += a[p + i];

    cout << cnt << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:41: error: 'k' was not declared in this scope
   28 |     int del = max(0UL, (a.size() - p) - k);
      |                                         ^
a.cc: At global scope:
a.cc:65:5: error: redefinition of 'int main()'
   65 | int main(void) {
      |     ^~~~
a.cc:8:5: note: 'int main()' previously defined here
    8 | int main(){
      |     ^~~~
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;

    int a[200001] = {};
    for (int i = 0; i < n; ++i) {
        cin >> x;
        ++a[x];
    }

    int ans = 0;
    sort(a, a + n + 1);
    for (int i = 0; i <= n - k; ++i) {
        ans += a[i];
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: 'x' was not declared in this scope
   13 |         cin >> x;
      |                ^
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;

    int a[200001] = {};
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (a[x] == 0) ++cnt;
        ++a[x];
    }

    int ans = 0;
    if (cnt <= k) {
        cout << ans << endl;
    } else {
        sort(a, a + 200001);
        int y = 200001 - cnt
        while (k != cnt) {
            ans += a[y];
            --cnt;
            ++y;
        }
        cout << ans << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: expected ',' or ';' before 'while'
   26 |         while (k != cnt) {
      |         ^~~~~
Language: C++

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

using namespace std;

typedef long long ll;

int N, K;
map<int, int> bmap;

int main()
{
    cin >> N >> K;
    for (int i = 0; i < N; ++i)
    {
        int a;
        cin >> a;
        bmap[a] = bmap.find(a) != bmap.end() ? bmap[a] + 1 : 1;
    }

    if (bmap.size() <= K)
    {
        cout << 0 << endl;
        return 0;
    }

    vector<int> v;
    for (auto kv : bmap) v.push_back(kv.second);
    sort(v.begin(), v.end());

    int ans = 0;
    while (v.size() != K)
    {
        ans += v.front();
        v.erase(v.begin());
    }
    cout << ans << endl;

    return 0;
}

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

/* ----------------------------
 * ABC 81 C
 * ---------------------------- */
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	map<int, int> a;
	for(int i = 0; i < n; i++){
		int tmp;
		cin >> tmp;
		a[tmp] += 1;
	}
	vector<int> v;
	for(auto x: a){
		v.push_back(x.second);
	}
	sort(v.begin(), v.end());
	int ans = 0;
//	int min = 1 << 30;
//	int min_key = -1;
//	// a に k　種類以上の数字が入っている場合
//	while(a.size() > k){
//		for (auto itr = a.begin(); itr != a.end(); ++itr) {
//			if(itr->second < min) min_key = itr->first;
//		}
//		ans += a[min_key];
//		a.erase(min_key);
//		min = 1 << 30;
//	}
	for(int i = k, i <= v.size(); i++){
		ans += v[i];
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:25: error: expected ';' before '<=' token
   36 |         for(int i = k, i <= v.size(); i++){
      |                         ^~~
      |                         ;
a.cc:36:26: error: expected primary-expression before '<=' token
   36 |         for(int i = k, i <= v.size(); i++){
      |                          ^~
Language: C++

// ConsoleApplication9.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include <iostream>
#include <algorithm>
using namespace std;


int main()
{
	int N, K, i, j,cnt,sum,x, k;
	cnt = 0;
	sum = 0;
	int A[200000];
	int num[200000] = {0};
	cin >> N;
	cin >> K;

	for (i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (i = 0; i < N; i++) {
		num[A[i]]++;
	}
	sort(num, num + N);
	for (i = 0; i < N; i++) {
		if (num[i] == 0)
			cnt++;
	}
	if (N - cnt <= K)
		cout<<"0"<<endl;
	else {
		for (i = cnt; i <= N - K - 1; i++) {
			sum += num[i];
		}
		cout<< sum<<endl;
	}



    return 0;
}



Compiler output:
a.cc:4:10: fatal error: stdafx.h: No such file or directory
    4 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<stdio.h>
int main()
{
	int a[200001],b[200001] = {0};
	int nc,c,d,t,N,K,i,j,count;
	scanf("%d%d",&N,&K);
	for(i=0;i<N;i++)
	{
	scanf("%d",&j);
	a[j]++;
	if(j!=0)
	b[i]=j;
	++nc;
	}
	for(i=0;i<N;i++)
	{
		if(a[i]!=0)
		b[i] = a[i];
		count++;
	}
	for(i=0;i<nc-1;i++)
	{k=i;
	for(j=i+1;j<N;j++)
	   if(b[k]>b[j]) k=j;
	   if(k!=i)
	   {t=b[k];b[k]=b[i];b[i]=t;
		} 
		
	}
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:10: error: 'k' was not declared in this scope
   22 |         {k=i;
      |          ^
Language: C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int a, i, j, k, N, K, b[200000], c[200000], tmp, sum;
  scanf("%d%d", &N, &K);
  
  k=0;
  for(i=0;i<N;i++){
    scanf(" %d", &a);
    match=0;
    for(j=0;j<k;j++){
      if(a==b[j]){
        c[j]++;match=1;break;
      }
    }
    if(match==0){
      b[k]=a;c[k]=1;k++;
    }
  }
  
  for(i=0;i<k-1;i++){
    for(j=0;j<k-i-1;j++){
      if(c[j]>c[j+1]){
        tmp=b[j]; b[j]=b[j+1]; b[j+1]=tmp;
        tmp=c[j]; c[j]=c[j+1]; c[j+1]=tmp;
      }
    }
  }
  
  sum=0;
  if(k<=K)
    printf("0\n");
  else{
    for(i=0;i<=k-K;i++){
      sum+=c[i];
    }
    printf("%d\n", sum);
  }
}


Compiler output:
main.c: In function 'main':
main.c:12:5: error: 'match' undeclared (first use in this function); did you mean 'rpmatch'?
   12 |     match=0;
      |     ^~~~~
      |     rpmatch
main.c:12:5: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_N 200001

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main() {
    vector<int> A;
    int N, K;
    cin >> N >> K;
    int num[MAX_N];
    memset(num, 0, sizeof(num));
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        num[a - 1] += 1;
    }
    for (int i = 0; i < N; ++i) {
        if (num[i] != 0) {
            A.push_back(num[i]);
        }
    }
    int len = (int)A.size();
    sort(A.begin(), A.end());
    int ans = 0;
    for (int i = 0; i < len - K; ++i) {
        ans += A[i];
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:5: error: 'memset' was not declared in this scope
   28 |     memset(num, 0, sizeof(num));
      |     ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   13 | #include <functional>
  +++ |+#include <cstring>
   14 | #include <deque>
Language: C++

#include<cstdio>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
		int n,k;cin>>n>>k;
		int a[200000];memset(a,0,sizeof(a));
		for(int i=0;i<n;i++{cin>>a[i];}
		sort(a,a+200000);
		int ans=0;
		for(int i=0;i<200000-k;i++){
			ans+=a[i];
		}
			cout<<ans<<endl;
	}//main while

Compiler output:
a.cc: In function 'int main()':
a.cc:9:36: error: expected ')' before '{' token
    9 |                 for(int i=0;i<n;i++{cin>>a[i];}
      |                    ~               ^
      |                                    )
Language: C++

#include<cstdio>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
		int n,k:cin>>n>>k;
		int a[200000];memset(a,0,sizeof(a));
		for(int i=0;i<n;i++{cin>>a[i];}
		sort(a,a+200000);
		int ans=0;
		for(int i=0;i<200000-k;i++){
			ans+=a[i];
		}
			cout<<ans<<endl;
	}//main while

Compiler output:
a.cc: In function 'int main()':
a.cc:7:24: error: found ':' in nested-name-specifier, expected '::'
    7 |                 int n,k:cin>>n>>k;
      |                        ^
      |                        ::
a.cc:7:23: error: 'k' has not been declared
    7 |                 int n,k:cin>>n>>k;
      |                       ^
a.cc:7:28: error: qualified-id in declaration before '>>' token
    7 |                 int n,k:cin>>n>>k;
      |                            ^~
a.cc:9:36: error: expected ')' before '{' token
    9 |                 for(int i=0;i<n;i++{cin>>a[i];}
      |                    ~               ^
      |                                    )
a.cc:12:38: error: 'k' was not declared in this scope
   12 |                 for(int i=0;i<200000-k;i++){
      |                                      ^
Language: C++

#include <bits/stdc++.h>

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int main(){
  ios_base::sync_with_stdio(0);
	cin>>n>>k;
	for(int i=0;i<n;++i){
		cin>>x; --x; ++a[x];
	}
	sort(a,a+n);
	reverse(a,a+n);
	for(int i=0;i<n;++i){
		if(i>=k) ans+=a[i];
	}
	cout<<ans;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:14: error: 'n' was not declared in this scope; did you mean 'yn'?
   23 |         cin>>n>>k;
      |              ^
      |              yn
a.cc:23:17: error: 'k' was not declared in this scope
   23 |         cin>>n>>k;
      |                 ^
a.cc:25:22: error: 'x' was not declared in this scope
   25 |                 cin>>x; --x; ++a[x];
      |                      ^
a.cc:25:32: error: 'a' was not declared in this scope
   25 |                 cin>>x; --x; ++a[x];
      |                                ^
a.cc:27:14: error: 'a' was not declared in this scope
   27 |         sort(a,a+n);
      |              ^
a.cc:30:26: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |                 if(i>=k) ans+=a[i];
      |                          ^~~
      |                          abs
a.cc:32:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |         cout<<ans;
      |               ^~~
      |               abs
Language: C++

#include <bits/stdc++.h>

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int main(){
  #include <bits/stdc++.h>

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int main(){
  std::ios::sync_with_stdio(0);
  int cnt[MAX_N];
  int n,k;
  cin >> n >> k;

  rep(i,0,n){
    int a;
    cin >> a;
    a--;
    cnt[a]++;
  }
  sort(cnt,cnt+n);
  reverse(cnt,cnt+n);
  int ans = 0;
  rep(i,0,n) if(i >= k)ans += cnt[i];
  pout(ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   42 | int main(){
      |         ^~
a.cc:42:9: note: remove parentheses to default-initialize a variable
   42 | int main(){
      |         ^~
      |         --
a.cc:42:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:42:11: error: a function-definition is not allowed here before '{' token
   42 | int main(){
      |           ^
a.cc:60:2: error: expected '}' at end of input
   60 | }
      |  ^
a.cc:21:11: note: to match this '{'
   21 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int main(){
  #include <bits/stdc++.h>

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int main(){
  std::ios::sync_with_stdio(0);
  int cnt[MAX_N];
  int n,k;
  cin >> n >> k;

  rep(i,0,n){
    int a;
    cin >> a;
    a--;
    cnt[a]++;
  }
  sort(cnt,cnt+n);
  reverse(cnt,cnt+n);
  int ans = 0;
  rep(i,0,n) if(i >= k)ans += cnt[i];
  pout(ans);
	return 0;
}

  int cnt[MAX_N];
  int n,k;
  cin >> n >> k;

  rep(i,0,n){
    int a;
    cin >> a;
    a--;
    cnt[a]++;
  }
  sort(cnt,cnt+n);
  reverse(cnt,cnt+n);
  int ans = 0;
  rep(i,0,n) if(i >= k)ans += cnt[i];
  pout(ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   42 | int main(){
      |         ^~
a.cc:42:9: note: remove parentheses to default-initialize a variable
   42 | int main(){
      |         ^~
      |         --
a.cc:42:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:42:11: error: a function-definition is not allowed here before '{' token
   42 | int main(){
      |           ^
Language: C++

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

using namespace std;

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

  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    map<int, int>::iterator itr = mp.find(a);
    if (itr != mp.end()) {
      itr->second++;
    } else {
      mp[a] = 1;
    }
  }

  vector<int> vec;
  for (map<int, int>::iterator itr = mp.begin(); itr != mp.end(); itr++) {
    vec.push_back(itr->second);
  }
  sort(vec.begin(), vec.end());

  int ans = 0;

  if (vec.size() > K) {
    for (int i = 0; i < vec.size() - K; i++) {
      ans += vec[i];
    }
  }

  cout << ans << endl;

  return 0;
}


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

#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
  int N, K;
  map<int, int> M;
  vector<int> C;
  cin >> N >> K;
  for(int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    ++M[a];
  }
  for(auto p : M) {
    C.push_back(p.second);
  }
  sort(C.begin(), C.end());
  partial_sum(C.begin(), C.end());
  int d = (int)M.size() - K;
  cout << (d > 0 ? C[d - 1] : 0)  << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:14: error: no matching function for call to 'partial_sum(std::vector<int>::iterator, std::vector<int>::iterator)'
   21 |   partial_sum(C.begin(), C.end());
      |   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/numeric:62,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_numeric.h:256:5: note: candidate: 'template<class _InputIterator, class _OutputIterator> _OutputIterator std::partial_sum(_InputIterator, _InputIterator, _OutputIterator)'
  256 |     partial_sum(_InputIterator __first, _InputIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:256:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:298:5: note: candidate: 'template<class _InputIterator, class _OutputIterator, class _BinaryOperation> _OutputIterator std::partial_sum(_InputIterator, _InputIterator, _OutputIterator, _BinaryOperation)'
  298 |     partial_sum(_InputIterator __first, _InputIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:298:5: note:   candidate expects 4 arguments, 2 provided
Language: C++

#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main() {
  int N, K;
  set<int> S;
  cin >> N >> K;
  for(int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    S.insert(a);
  }
  cout << max(0, S.size() - K) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:14: error: no matching function for call to 'max(int, std::set<int>::size_type)'
   14 |   cout << max(0, S.size() - K) << endl;
      |           ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:14:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::set<int>::size_type' {aka 'long unsigned int'})
   14 |   cout << max(0, S.size() - K) << endl;
      |           ~~~^~~~~~~~~~~~~~~~~
/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,
                 from a.cc:3:
/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:14:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   14 |   cout << max(0, S.size() - K) << endl;
      |           ~~~^~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
using namespace std;

bool cmp(int a,int b){
	return a>b;
}

int main(){
	int s=0,k,i,n,x;
	
	cin>>n>>k;
	
	int a[200005]={0};
	
	for(i=1;i<=n;i++){
		cin>>x;
		
		a[x]++;
	}
	
	sort(a+1,a+200006,cmp);
	
	for(i=k+1;i<=200004;i++){
		s+=a[i];
	}
	
	return 0;
}

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

//競技プログラミング　テンプレ
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)

const int max_v = 300;
const int INF = 1000000;



int main() {
	int n, ans=0 ,k ;
	int mp_size ,min,s,m,ban;
	cin >> n >> k;
	vector <int> A(n);
	//string str;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	map<int ,int> mp;

	REP(i,n){
		mp[A[i]] ++ ;
	}
	mp_size = mp.size();
	while(mp_size >= k){
		max = 200001;
		for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
		 	s= itr ->first; //キー
		 	m= itr ->second; //値
		 	if(min > m) {min =m; ban = s;}
		 }
		 mp_size --; mp[ban] = 0; ans+=m;
	}

	//sort(A.begin(), A.end());

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


Compiler output:
a.cc: In function 'int main()':
a.cc:34:23: error: overloaded function with no contextual type information
   34 |                 max = 200001;
      |                       ^~~~~~
Language: C++

#include <bits/stdc++>
#define rep(i,n) for(int i=0;i<n;i++)
#define N 20002
using namespace std;

int main(){
  int n,k;
  int x;
  int a[N]={0};
  int cnt=0;
  cin >> n >> k;
  rep(i,n){
    scanf("%d",&x);
    if(x>0)cnt++;
    a[x]++;
  }
  sort(a,a+N);
  if(cnt<=k){
    cout << 0 << endl;
    return 0;
  }
  int sum=0;
  for(int i=N-cnt;i<N-k;i++)sum+=a[i];
  cout << sum << endl;

  return 0;
}


Compiler output:
a.cc:1:10: fatal error: bits/stdc++: No such file or directory
    1 | #include <bits/stdc++>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <cstdio> 
#include <algorithm>
using namespace std； 
int main()
{
    int a[1024]={0},b[1024]={0};
    int n,k,i,j,count;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    j=0;
    count=0;
	for(i=0;i<n;i++)
	{
		if(a[i]==a[i+1])
		{
		    count++;
		}
		if(a[i]!=a[i+1])
        {
			b[j++]=count+1;
			count=0;
	    }
	}
	sort(b,b+j);
    count=0;
    for(i=0;i<j-k;i++)
        count+=b[i];
    printf("%d\n",count);
    return 0;
}

Compiler output:
a.cc:3:17: error: 'std\U0000ff1b' is not a namespace-name
    3 | using namespace std；
      |                 ^~~~~
a.cc:3:22: error: expected ';' before 'int'
    3 | using namespace std；
      |                      ^
      |                      ;
    4 | int main()
      | ~~~                   
a.cc: In function 'int main()':
a.cc:13:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   13 |     sort(a,a+n);
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
Language: C++

#include <cstdio> 
#include <algorithm>
using namespace std； 
int main()
{
    int a[1024]={0},b[1024]={0};
    int n,k,i,j,count;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    j=0;
    count=0;
	for(i=0;i<n;i++)
	{
		if(a[i]==a[i+1])
		{
		    count++;
		}
		if(a[i]!=a[i+1])
        {
			b[j++]=count+1;
			count=0;
	    }
	}
	sort(b,b+j);
    count=0;
    for(i=0;i<j-k;i++)
        count+=b[i];
    printf("%d",count);
    return 0;
}

Compiler output:
a.cc:3:17: error: 'std\U0000ff1b' is not a namespace-name
    3 | using namespace std；
      |                 ^~~~~
a.cc:3:22: error: expected ';' before 'int'
    3 | using namespace std；
      |                      ^
      |                      ;
    4 | int main()
      | ~~~                   
a.cc: In function 'int main()':
a.cc:13:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   13 |     sort(a,a+n);
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
Language: C

#include<stdio.h>
#include<algorithm>

int main() {
	int n, k, a[200000] = { 0 }, ans = 0;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		++a[x];
	}
	int norma = 0;
	for (auto&& x : a) {
		if (x > 0) ++norma;
	}
	norma -= k;
	std::sort(std::begin(a), std::end(a), [](int x, int y){return x < y; });
	for (int i = 0; norma > 0; ++i) {
		if (a[i] > 0) {
			--norma;
			ans += a[i];
		}
	}
	printf("%d", ans);
}

Compiler output:
main.c:2:9: fatal error: algorithm: No such file or directory
    2 | #include<algorithm>
      |         ^~~~~~~~~~~
compilation terminated.
Language: C++

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

int main() {
	int n,k,b[200010]={};
    // 配列の初期化
    for(int i=0;i<200010;i++){
        b[i] = 0;
    }    
	cin >> n >> k;
    int cnt = 0;
    //入力 + 初めて登場(?)した数があれば種類をインクリメント
	for(int i=0;i<n;i++){
		cin >> tmp;
        if(b[tmp] == 0){
            cnt++;
        }
        b[tmp]++;
	}
    // ボールの数が少ない順にソート
	sort(b,b+200010);
    // もともとK種類以下なら0を出力
	if(cnt<=k){
		cout << 0 << endl;
		return 0;
	}
	int sum=0;
    // cntがKになるまでb[i]の値をsumに足していく
    int j = 0;
	while(cnt > k){
        if(b[j] != 0){
            sum += b[j];
            cnt--;
        }
        j++;
    }
	cout << sum << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:24: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   14 |                 cin >> tmp;
      |                        ^~~
      |                        tm