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

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,k,maxx=0,minx=200001,minx2,k2=0;
    cin>>n>>k;
    long long a[200001]={0},sum=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a[x]++;
        if(a[x]==1)k2++;
        maxx=max(maxx,x);
    }
    for(int i=1;k2>k;i++){
        for(int j=1;j<=maxx;j++){
            if(a[j]>0){
                if(minx>a[j]){
                    minx=a[j];
                    minx2=j;
                }
            }
        }
        sum+=a[minx2];
        a[minx2]=0;
        minx=200001;
        k2--;
    }
    cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: no matching function for call to 'max(long long int&, int&)'
   12 |         maxx=max(maxx,x);
      |              ~~~^~~~~~~~
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:12:17: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   12 |         maxx=max(maxx,x);
      |              ~~~^~~~~~~~
/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:12:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   12 |         maxx=max(maxx,x);
      |              ~~~^~~~~~~~
Language: C++

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

int main() {
    int N = 0;
    int K = 0;
    
    cin >> N >> K;
    
    vector<int> vec(N, 0);
    vector<int> box(N + 1, 0);
    
    for (int i = 0; i < N; ++i) {
        cin >> vec[i];
    }
    
    for (int i = 0; i < N; ++i) {
        box[vec[i]]++;
    }
    sort(box.begin(), box.end());
    
    int ans = 0;
    
    for (int i = 0; i < N + 1; ++i) {
        if (box[i] != 0) {
            int variation = N + 1 - i;
            for (int j = i; j < N + 1; ++j) {
                if (variation <= K)
                    break;
                else {
                    variation--;
                    ans += box[j];
                }
            }
            break;
        }
    }
    
    cout << ans;
    return 0;



Compiler output:
a.cc: In function 'int main()':
a.cc:40:14: error: expected '}' at end of input
   40 |     return 0;
      |              ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

use std::cmp;
use std::collections::HashMap;
use std::io;

fn read_line() -> String {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line).unwrap();
    return String::from(line.trim());
}

fn main() {
    let nk: Vec<String> = read_line().split_whitespace().map(|s| String::from(s)).collect();
    let n: i64 = nk.get(0).unwrap().parse::<i64>().unwrap();
    let k: i64 = nk.get(1).unwrap().parse::<i64>().unwrap();
    let values: Vec<String> = read_line().split_whitespace().map(|s| String::from(s)).collect();

    let mut counts: HashMap<String, i64> = HashMap::new();
    for value in values {
        *counts.entry(value).or_insert(0) += 1;
    }
    let mut values: Vec<i64> = counts.values().into_iter().map(|i| *i).collect();
    values.sort();
    values.reverse();
    let sum = values[..cmp::min(values.len(), k as usize)].iter().sum::<i64>();
    println!("{}", values.iter().sum::<i64>() - sum);
}

Compiler output:
a.cc:1:1: error: 'use' does not name a type
    1 | use std::cmp;
      | ^~~
a.cc:2:1: error: 'use' does not name a type
    2 | use std::collections::HashMap;
      | ^~~
a.cc:3:1: error: 'use' does not name a type
    3 | use std::io;
      | ^~~
a.cc:5:1: error: 'fn' does not name a type
    5 | fn read_line() -> String {
      | ^~
a.cc:11:1: error: 'fn' does not name a type
   11 | fn main() {
      | ^~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int a[200005];
int b[200005];
int main()
{
	memset(a, 0, sizeof(a));
	int n, k;
	int kind = 0;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
		a[b[i]]++;
		if (a[b[i]] == 1) {
			kind++;
		}
	}
	vector<int> p;
	for (int i = 0; i <= 200005; i++) {
		if (a[i] != 0) {
			p.push_back(a[i]);
		}
	}
	sort(p.begin(), p.end());
	int count = 0;
	for (int i = 0; i < (int)p.size()  && kind>k; i++) {
		count += p[i];
		kind--;
	}
	printf("%d", count);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'memset' was not declared in this scope
    9 |         memset(a, 0, sizeof(a));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<algorithm>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <stack>
#include <map>
#include <algorithm>
#define INF 100000000
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
vector<P> V(2005);

bool comp(const P& a, const P& b) {
	//if (a.second > b.second) return (a.second > b.second);
	return a.second > b.second;
}
int main() {
	int N, K;
	cin >> N >> K;
	memset(&V[0], 0, sizeof(V[0])*V.size());
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		V[x].first = x;
		V[x].second++;
	}
	sort(V.begin(), V.end(), comp);

	int cnt = 0;
	for (int i = 0;; i++) {
		if (V[i].second == 0) break;
		if (i + 1 > K) {
			cnt += V[i].second;
		}
	}
	cout << cnt << endl;
	//for (int i = 0; i < N+1; i++) {
	//	cout << V[i].first << " " << V[i].second << endl;
	//}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: 'memset' was not declared in this scope
   21 |         memset(&V[0], 0, sizeof(V[0])*V.size());
      |         ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <algorithm>
  +++ |+#include <cstring>
    8 | #define INF 100000000
Language: C++

#include <iostream>
#include <algorythm>
using namespace std;

int main(){
    int N,K;
    int A[200];
    int kosu[200];
    int sum=0;
    for(int i=0;i<200;i++){
        kosu[i]=1;
    }
    
    cin >> N;
    cin >> K;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    
    
    int checked=0;
    int i=1;
    int j=0;
    while(i<N)
    {
        
        if(A[i]==A[i-1]){
            kosu[j]++;
        }else{
            j++;
        }
        i++;
        
    }
    
    sort(kosu,kosu+j+1);
    
    for(int i=0;i<j+1-K;i++){
        sum+=kosu[i];
    }
    cout << sum;
}






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

#include <iostream>
using namespace std;

int main(){
    int N,K;
    int A[200];
    int kosu[200];
    int sum=0;
    for(int i=0;i<200;i++){
        kosu[i]=1;
    }
    
    cin >> N;
    cin >> K;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    
    
    int checked=0;
    int i=1;
    int j=0;
    while(i<N)
    {
        
        if(A[i]==A[i-1]){
            kosu[j]++;
        }else{
            j++;
        }
        i++;
        
    }
    
    sort(kosu,kosu+j+1);
    
    for(int i=0;i<j+1-K;i++){
        sum+=kosu[i];
    }
    cout << sum;
}






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

#include <iostream>
include <algorithm>

using namespace std;

int main(){
    int N,K;
    int A[200];
    int kosu[200];
    int sum=0;
    for(int i=0;i<200;i++){
        kosu[i]=1;
    }
    
    cin >> N;
    cin >> K;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    
    cout << "\n";
    int checked=0;
    int i=1;
    int j=0;
    while(i<N)
    {
        
        if(A[i]==A[i-1]){
            kosu[j]++;
        }else{
            j++;
        }
        i++;
        
    }
    
    sort(kosu,kosu+j+1);
    
    for(int i=0;i<j+1-K;i++){
        sum+=kosu[i];
    }
    cout << sum;
}






Compiler output:
a.cc:2:1: error: 'include' does not name a type
    2 | include <algorithm>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:15:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   15 |     cin >> N;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:20:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   20 |     sort(A,A+N);
      |     ^~~~
      |     short
a.cc:22:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   22 |     cout << "\n";
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
ll N,K;
ll A[2000001]={};
ll B[2000001]={};
ll R=0;
ll total=0;
int main() {
		cin>>N>>K;
		for(ll i=1;i<N+1;i++){
			cin>>A[i];
		}
		sort(A,A+N);

		for(ll i=1;i<N+1;i++){
			if(A[i]!=A[i-1])R++;
			B[R]+=1;
		}
		if(R==1){
			total=0;
			break;
		}
		sort(B,B+R+1);

		if(R>K){
			for(ll i=1;i<R-K+1;i++){
				total+=B[i];
			}
		}

		cout<<total<<endl;
		return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:25: error: break statement not within loop or switch
   33 |                         break;
      |                         ^~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n, k, a, s, c[200005];
vector<int> v;
int main() {
	int i;
	scanf("%d%d", &n, &k);
	for(i=1; i<=n; i++) scanf("%d", &a), c[a]++;
	for(i=1; i<=n; i++) if(c[i]) v.push_back(c[i]);
	sort(v.begin(), v.end());
	for(i=0; i<(int)v.size()-k; i++) s += v[i];
	printf("%d", s);
	return 0;
}


Compiler output:
a.cc:6:1: error: 'vector' does not name a type
    6 | vector<int> v;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:11:38: error: 'v' was not declared in this scope
   11 |         for(i=1; i<=n; i++) if(c[i]) v.push_back(c[i]);
      |                                      ^
a.cc:12:14: error: 'v' was not declared in this scope
   12 |         sort(v.begin(), v.end());
      |              ^
Language: C

#include <stdio.h>
#include <stdlib.h>
void heapify(long arr[], long n, long  i)
{
    long largest = i;  // Initialize largest as root
    long l = 2*i + 1;  // left = 2*i + 1
    long r = 2*i + 2;  // right = 2*i + 2
 
    // If left child is larger than root
    if (l < n && arr[l] > arr[largest])
        largest = l;
 
    // If right child is larger than largest so far
    if (r < n && arr[r] > arr[largest])
        largest = r;
 
    // If largest is not root
    if (largest != i)
    {
        swap(arr[i], arr[largest]);
 
        // Recursively heapify the affected sub-tree
        heapify(arr, n, largest);
    }
}
 
// main function to do heap sort
void heapSort(long arr[], long n)
{
    // Build heap (rearrange array)
    for (long i = n / 2 - 1; i >= 0; i--)
        heapify(arr, n, i);
 
    // One by one extract an element from heap
    for (long i=n-1; i>=0; i--)
    {
        // Move current root to end
        swap(arr[0], arr[i]);
 
        // call max heapify on the reduced heap
        heapify(arr, i, 0);
    }
}
 
int main()
{
	long n,k,a[200000],b[200000]={0},c[200000],d=0,i, j,sum=0;
	scanf("%ld %ld",&n,&k);
	for(i=0;i<n;i++)
	{
		scanf("%ld",&a[i]);
		b[a[i]]++;
	}
	for(i=0;i<200000;i++)
	{
		if(b[i] !=0)
		c[d++]=b[i];
	}
		long x = sizeof(c)/sizeof(c[0]);
 
            heapSort(c, x);
		for(i=d-1;i>=0;i--)
		{
			if(k<0)
			break;
			k--;
		}
		for(j=i+1;j>=0;j--)
		sum+=c[j];
	  printf("%ld",sum);
		}

Compiler output:
main.c: In function 'heapify':
main.c:20:9: error: implicit declaration of function 'swap' [-Wimplicit-function-declaration]
   20 |         swap(arr[i], arr[largest]);
      |         ^~~~
Language: C++

#include <iostream>
using namespace std;

int main(){
    int N,K;
    int A[200];
    int kosu[200];
    int sum=0;
    for(int i=0;i<200;i++){
        kosu[i]=1;
    }
    
    cin >> N;
    cin >> K;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    
    cout << "\n";
    int checked=0;
    int i=1;
    int j=0;
    while(i<N)
    {
        
        if(A[i]==A[i-1]){
            kosu[j]++;
        }else{
            j++;
        }
        i++;
        
    }
    
    sort(kosu,kosu+j+1);
    
    for(int i=0;i<j+1-K;i++){
        sum+=kosu[i];
    }
    cout << sum;
}







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

#include <bits/stdc++.h>
 
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);
    vector <pair<int, int> > v;
    int c=1;
    for (int i=0; i<n; i++)
    {
       if (a[i]!=a[i+1]) { v.push_back(c, a[i]); c=1; }
       else c++;
     }
 c=0;
     while (v.size()-k>0)
     {
sort (v.rbegin(), v.rend());
c=c+v[v.size()-1].first;
v.pop_back;
      }
    cout<<c;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:39: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int&, int&)'
   19 |        if (a[i]!=a[i+1]) { v.push_back(c, a[i]); c=1; }
      |                            ~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note:   candidate expects 1 argument, 2 provided
a.cc:27:3: error: invalid use of non-static member function 'void std::vector<_Tp, _Alloc>::pop_back() [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
   27 | v.pop_back;
      | ~~^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1324:7: note: declared here
 1324 |       pop_back() _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
Language: C

#include <stdio.h>
#include <stdlib.h>
void heapify(long arr[], long n, long  i)
{
    long largest = i;  // Initialize largest as root
    long l = 2*i + 1;  // left = 2*i + 1
    long r = 2*i + 2;  // right = 2*i + 2
 
    // If left child is larger than root
    if (l < n && arr[l] > arr[largest])
        largest = l;
 
    // If right child is larger than largest so far
    if (r < n && arr[r] > arr[largest])
        largest = r;
 
    // If largest is not root
    if (largest != i)
    {
        swap(arr[i], arr[largest]);
 
        // Recursively heapify the affected sub-tree
        heapify(arr, n, largest);
    }
}
 
// main function to do heap sort
void heapSort(long arr[], long n)
{
    // Build heap (rearrange array)
    for (long i = n / 2 - 1; i >= 0; i--)
        heapify(arr, n, i);
 
    // One by one extract an element from heap
    for (long i=n-1; i>=0; i--)
    {
        // Move current root to end
        swap(arr[0], arr[i]);
 
        // call max heapify on the reduced heap
        heapify(arr, i, 0);
    }
}

int main()
{
	long n,k,a[200000],b[200000]={0},c[200000],d=0,i, j,sum=0;
	scanf("%ld %ld",&n,&k);
	for(i=0;i<n;i++)
	{
		scanf("%ld",&a[i]);
		b[a[i]]++;
	}
	for(i=0;i<200000;i++)
	{
		if(b[i] !=0)
		c[d++]=b[i];
	}
		long n = sizeof(c)/sizeof(c[0]);
 
            heapSort(c, n);
		for(i=d-1;i>=0;i--)
		{
			if(k<0)
			break;
			k--;
		}
		for(j=i+1;j>=0;j--)
		sum+=c[j];
	  printf("%ld",sum);
		}

Compiler output:
main.c: In function 'heapify':
main.c:20:9: error: implicit declaration of function 'swap' [-Wimplicit-function-declaration]
   20 |         swap(arr[i], arr[largest]);
      |         ^~~~
main.c: In function 'main':
main.c:59:22: error: redeclaration of 'n' with no linkage
   59 |                 long n = sizeof(c)/sizeof(c[0]);
      |                      ^
main.c:47:14: note: previous declaration of 'n' with type 'long int'
   47 |         long n,k,a[200000],b[200000]={0},c[200000],d=0,i, j,sum=0;
      |              ^
Language: C++

#include <iostream>
using namespace std;

int main(){
    int N,K;
    int A[200];
    int kosu[200];
    int sum=0;
    for(int i=0;i<200;i++){
        kosu[i]=1;
    }
    
    cin >> N;
    cin >> K;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    
    cout << "\n";
    int checked=0;
    int i=1;
    int j=0;
    while(i<N)
    {
            
            if(A[i]==A[i-1]){
                kosu[j]++;
            }else{
                j++;
            }
            i++;
        
    }
    
    std::sort(kosu,kosu+j+1);
    
    for(int i=0;i<j+1-K;i++){
        sum+=kosu[i];
    }
    cout << sum;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   18 |     sort(A,A+N);
      |     ^~~~
      |     short
a.cc:36:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   36 |     std::sort(kosu,kosu+j+1);
      |          ^~~~
      |          qsort
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n, k, a, s, c[200005];
vector<int> v;
int main() {
	int i;
	scanf("%d%d", &n, &k);
	for(i=1; i<=n; i++) scanf("%d", &a), c[a]++;
	for(i=1; i<=n; i++) if(c[i]) v.push_back(c[i]);
	sort(v.begin(), v.end());
	for(i=0; i<(int)v.size()-k; i++) s += v[i];
	printf("%d", s);
	return 0;
}

Compiler output:
a.cc:6:1: error: 'vector' does not name a type
    6 | vector<int> v;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:11:38: error: 'v' was not declared in this scope
   11 |         for(i=1; i<=n; i++) if(c[i]) v.push_back(c[i]);
      |                                      ^
a.cc:12:14: error: 'v' was not declared in this scope
   12 |         sort(v.begin(), v.end());
      |              ^
Language: C

#include<stdio.h>
#include<string.h>
int s[200002],zz[200002],hh[200002];

int main()
{
	int z,a,b,i,h,cs,j,p,k;
	scanf("%d %d",&a,&b);
	{
		memset(s,0,sizeof(s));
	
		z=0;cs=0;
		for(i=1;i<=a;i++)
		{
		scanf("%d",&h);
		s[h]++;
		
		if(s[h]==1){z++;zz[z]=h;}
		
		}
		
		if(z<=b)cs=0;
		else if(z==a)cs=z-b;
		else 
		{
			
			k=z-b;
			
			for(j=1;j<=z;j++)
			{
				hh[j]=s[zz[j]];
			}
			for(i=1;i<=z;i++)
			for(j=1;j<=z-i;j++)
			{
				if(hh[j]>hh[j+1])
				{
					p=hh[j];hh[j]=hh[j+1];hh[j+1]=p;
				}
			}
			for(i=1;i<=k;i++)cs+=hh[i];
			
		}
		printf("%d\n",cs);
	
}

Compiler output:
main.c: In function 'main':
main.c:46:1: error: expected declaration or statement at end of input
   46 | }
      | ^
Language: C++

//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
ll N,K;
ll A[2000001]={};
ll B[2000001]={};
ll R=0;
ll total=0;
ll main() {
		cin>>N>>K;
		for(ll i=1;i<N+1;i++){
			cin>>A[i];
		}
		sort(A,A+N);

		for(ll i=1;i<N+1;i++){
			if(A[i]!=A[i-1])R++;
			B[R]+=1;
		}
		sort(B,B+R+1);

		if(R>K){
			for(ll i=1;i<R-K+1;i++){
				total+=B[i];
			}
		}
		cout<<total<<endl;
		return 0;
}


Compiler output:
a.cc:20:1: error: '::main' must return 'int'
   20 | ll main() {
      | ^~
Language: C++

#include <iostream>
using namespace std;

int main(){
    int N,K;
    int A[200];
    int kosu[200];
    int sum=0;
    for(int i=0;i<200;i++){
        kosu[i]=1;
    }
    
    cin >> N;
    cin >> K;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    
    cout << "\n";
    int checked=0;
    int i=1;
    int j=0;
    while(i<N)
    {
            
            if(A[i]==A[i-1]){
                kosu[j]++;
            }else{
                j++;
            }
            i++;
        
    }
    
    sort(kosu,kosu+j+1);
    
    for(int i=0;i<j+1-K;i++){
        sum+=kosu[i];
    }
    cout << sum;
}


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

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int cmp(const void *a,const void *b)
{
    return *(int *)a-*(int *)b;
}
int a[200500];
int t[200500];
int d[200500];
int p[200500];
void yagamiraito(int x,int y)
{
    if(y-x>1)
    {
        int m = x+(y-x)/2;
        int p = x,q = m,i = x;
        yagamiraito(x,m);
        yagamiraito(m,y);
        while(p<m||q<y)
        {
            if(q>=y||(p<m&&d[p]<=d[q]))
                t[i++] = d[p++];  
            else
            {
                t[i++] = d[q++];
                count+=m-p;
            }
        }
        for(i = x;i<y;i++)
            d[i] = t[i];
    }
}

int main (void)
{
    int n,k;
    scanf("%d%d",&n,&k);
    if(n==1)
    {
        printf("0\n");
        return 0;
    }
    memset(t,0,sizeof(t));
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        p[a[i]]++;
    }
    memset(d,0,sizeof(d));
    int num = 0;
    for(int i=1;i<=n;i++)
    {
        if(p[i])
            d[++num] = p[i];
    }
    yagamiraito(1,n+1);
    int p = num - k;
    if(p<1)
    {
        printf("0\n");
        return 0;
    }
    int sum = 0;
    for(int i=1;i<=p;i++)
        sum+=d[i];
    printf("%d\n",sum);
    return 0;
}

Compiler output:
a.cc: In function 'void yagamiraito(int, int)':
a.cc:27:17: error: 'count' was not declared in this scope
   27 |                 count+=m-p;
      |                 ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int bucket[200005];
int main()
{
int n,k,counta=0;
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
{
int input;
scanf("%d",&input);
if(bucket[input]==0)
counta++;
bucket[input]++;
}
long long ans=0;
if(counta>k)
{
vector<int> v;
for(int i=1;i<=n;i++)
if(bucket[i]>0)
v.push_back(bucket[i]);
v.sort(v.begin(),v.end());
for(int i=0;i<counta-k;i++)
ans+=v[i];
}
printf("%lld\n",ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:3: error: 'class std::vector<int>' has no member named 'sort'
   23 | v.sort(v.begin(),v.end());
      |   ^~~~
Language: C

#include<stdio.h>
//int A[200000];
#define num 1000000;
int CNT[num];

int sum(){//残っている数字の種類の数を返す関数
	int i;
	int cnt=0;
	for(i=0;i<10;i++){
		if(CNT[i]>0)cnt++;
	}
	return cnt;
}
int minnum(){//合計の数が最小の数を返す関数
	int i;
	int min=0;
	for(i=0;i<num;i++){
		if(CNT[i]>0){min = i;break;}
	}
	for(i=0;i<num;i++){
		if(CNT[i]!=0 && CNT[min] > CNT[i]){
			min = i;
		}
	}
	return min;
}
int maxnum(){//合計の数が最小の数を返す関数
	int i;
	int max=0;
	for(i=0;i<num;i++){
		if(CNT[max] < CNT[i]){
			max = i;
		}
	}
	return max;
}

int main(){
	int i,n,k,tmp;
	int cnt = 0;
	int min,max;
	scanf("%d",&n);
	scanf("%d",&k);
	for(i=0;i<num;i++)CNT[i]=0;
	for(i=0;i<n;i++){
		scanf("%d",&tmp);
		CNT[tmp]++;
	}
	
	while(1){
		if(sum() <= k){
			break;
		}
		else{
			min = minnum();
			max = maxnum();
			CNT[max] += CNT[min];
			cnt += CNT[min];
			CNT[min] = 0;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Compiler output:
main.c:3:20: error: expected ']' before ';' token
    3 | #define num 1000000;
      |                    ^
main.c:4:9: note: in expansion of macro 'num'
    4 | int CNT[num];
      |         ^~~
main.c: In function 'sum':
main.c:10:20: error: 'CNT' undeclared (first use in this function)
   10 |                 if(CNT[i]>0)cnt++;
      |                    ^~~
main.c:10:20: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'minnum':
main.c:17:22: error: expected expression before ';' token
   17 |         for(i=0;i<num;i++){
      |                      ^
main.c:18:20: error: 'CNT' undeclared (first use in this function)
   18 |                 if(CNT[i]>0){min = i;break;}
      |                    ^~~
main.c:20:22: error: expected expression before ';' token
   20 |         for(i=0;i<num;i++){
      |                      ^
main.c: In function 'maxnum':
main.c:30:22: error: expected expression before ';' token
   30 |         for(i=0;i<num;i++){
      |                      ^
main.c:31:20: error: 'CNT' undeclared (first use in this function)
   31 |                 if(CNT[max] < CNT[i]){
      |                    ^~~
main.c: In function 'main':
main.c:44:22: error: expected expression before ';' token
   44 |         for(i=0;i<num;i++)CNT[i]=0;
      |                      ^
main.c:44:27: error: 'CNT' undeclared (first use in this function)
   44 |         for(i=0;i<num;i++)CNT[i]=0;
      |                           ^~~
Language: C++

#include <bits/stdc++.h>

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);
    vector <pair<int, int> > v;
    int c=1;
    for (int i=0; i<n; i++)
{
if (i==n-1){ v.push_back({c, v[i]}); break; }
if (a[i]!=a[i+1]) {v.push_back({c, a[i]}); c=1; }
else c++;
}
 c=0;
     while (v.size()-k>0)
{
sort (v.rbegin(), v.rend());
c=c+v[v.size()-1].first;
v.pop_back;
}
    cout<<c;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:25: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   18 | if (i==n-1){ v.push_back({c, v[i]}); break; }
      |              ~~~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, int> >::value_type&' {aka 'const std::pair<int, int>&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
a.cc:27:3: error: invalid use of non-static member function 'void std::vector<_Tp, _Alloc>::pop_back() [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
   27 | v.pop_back;
      | ~~^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1324:7: note: declared here
 1324 |       pop_back() _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
Language: C++

#include <bits/stdc++.h>

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);
    vector <pair<int, int> > v;
    int c=1;
    for (int i=0; i<n; i++)
{
if (i==n-1) v.push_back({c, v[i]});
if (a[i]!=a[i+1]) {v.push_back({c, a[i]}); c=1; }
else c++;
}
 c=0;
     while (v.size()-k>0)
{
sort (v.rbegin(), v.rend());
c=c+v[v.size()-1].first;
v.pop_back;
}
    cout<<c;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:24: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   18 | if (i==n-1) v.push_back({c, v[i]});
      |             ~~~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, int> >::value_type&' {aka 'const std::pair<int, int>&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
a.cc:27:3: error: invalid use of non-static member function 'void std::vector<_Tp, _Alloc>::pop_back() [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
   27 | v.pop_back;
      | ~~^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1324:7: note: declared here
 1324 |       pop_back() _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
Language: C++

#include <stdio.h>
#include <string.h>
int a[200500];
int t[200500];
int d[200500];
void quicksort(int *a,int l,int r)
{
    int i,j,t,temp;
    if(l>=r)
       return;

    temp=a[l];
    i=l;
    j=r;
    while(i!=j)
    {
        while(a[j]>=temp && i<j) j--;
        while(a[i]<=temp && i<j) i++;
        if(i<j)
        {
            t=a[i];
            a[i]=a[j];
            a[j]=t;
        }
    }
    a[l]=a[i];
    a[i]=temp;
    quicksort(a,l,i-1);
    quicksort(a,i+1,r);
}
int main (void)
{
    int n,k;
    scanf("%d%d",&n,&k)
    if(n==1)
    {
        printf("0\n");
        return 0;
    }
    memset(t,0,sizeof(t));
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        t[a[i]]++;
    }
    memset(d,0,sizeof(d));
    int num = 0;
    for(int i=1;i<=n;i++)
    {
        if(t[i])
            d[++num] = t[i];
    }
    quicksort(d,1,num);
    int p = num - k;
    if(p<1)
    {
        printf("0\n");
        continue;
    }
    int sum = 0;
    for(int i=1;i<=p;i++)
        sum+=d[i];
    printf("%d\n",sum);
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:34:24: error: expected ';' before 'if'
   34 |     scanf("%d%d",&n,&k)
      |                        ^
      |                        ;
   35 |     if(n==1)
      |     ~~                  
a.cc:58:9: error: continue statement not within a loop
   58 |         continue;
      |         ^~~~~~~~
Language: C++

#include <bits/stdc++.h>

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);
    vector <pair<int, int> > v;
    int c=1;
    for (int i=0; i<n; i++)
{
if (a[i]!=a[i+1]) {v.push_back({c, a[i]}); c=1; }
else c++;
}
 c=0;
     while (v.size()-k>0)
{
sort (v.rbegin(), v.rend());
c=c+v[v.size()-1].first;
v.pop_back;
}
    cout<<c;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:3: error: invalid use of non-static member function 'void std::vector<_Tp, _Alloc>::pop_back() [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
   26 | v.pop_back;
      | ~~^~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1324:7: note: declared here
 1324 |       pop_back() _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
Language: C++

#include <iostream>
#include <map>
#include <vector>
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;
        if( A.find(tmp) != A.end() ) A[tmp] += 1;
        else A[tmp] = 1;
    }

    int M = A.size();
    int ans = 0;

    if( K < M ){
        vector<int> AA(M);
        int cnt = 0;
        for( auto itr = A.begin(); itr != A.end(); ++itr )
            AA[cnt++] = itr->second;

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

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


    cout << ans << endl;

    return 0;
}


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

//2017.12.10
//
#include <iostream>
#include <vector>
#include <algorithm>

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,k,s,kosu ,toru,toku=0,ans=0;
	cin >> n >> k ;
	vector <int> A(n+1,0);
	vector <int> B(n+1,0);
	//string str;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}

	REP(k,n){
	    if(A[k] == n) {
	        toku++;
	    }
	    else{
		s=A[k];
		B[s]++;
	    }
	}
	min =200003
	REP(k,n){
		if(B[k] != 0) kosu++;
		if(min > B[k] && B[k] !=0) min =B[k];
	}
    
    if(toku != 0) kosu++;
	while(1){
		if(kosu <= k) {
			cout << ans <<endl;
			return 0;
		}
        
        
		toru=min;
		if(toru < toku){
		ans +=toru;
		kosu--;
		}
		else{
		    ans +=toku;
		    toku = 0;   
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:14: error: overloaded function with no contextual type information
   35 |         min =200003
      |              ^~~~~~
a.cc:9:50: error: expected ';' before ')' token
    9 | #define REP(i,n) for(int i = 0; i < (int)(n); ++i)
      |                                                  ^
a.cc:36:9: note: in expansion of macro 'REP'
   36 |         REP(k,n){
      |         ^~~
a.cc:49:22: error: cannot resolve overloaded function 'min' based on conversion to type 'int'
   49 |                 toru=min;
      |                      ^~~
Language: C

#include<stdio.h>
void quicksort(int* x,int first,int last){
    int pivot,j,temp,i;
 
     if(first<last){
         pivot=first;
         i=first;
         j=last;
 
         while(i<j){
             while(x[i]<=x[pivot]&&i<last)
                 i++;
             while(x[j]>x[pivot])
                 j--;
             if(i<j){
                 temp=x[i];
                  x[i]=x[j];
                  x[j]=temp;
             }
         }
 
         temp=x[pivot];
         x[pivot]=x[j];
         x[j]=temp;
         quicksort(x,first,j-1);
         quicksort(x,j+1,last);
 
    }
}
int main()
{
int n,k,i;
scanf("%d%d",&n,&k);
int a[n];
for(i=0;i<n;i++) scanf("%d",&a[i]);
quicksort(a,0,n-1);
int u[n],o[n],j=1;
u[0]=a[0]; o[0]=1;
for(i=1;i<n;i++)
{
if(a[i]!=u[j-1])
{
u[j]=a[i];
o[j]=1;
j++;
}
else
{
o[j-1]+=1;
}
if(k>=j) printf("%d\n",0);
else
{
quicksort(o,0,j-1);
int d=j-k;
int op=0;
for(i=0;i<d;i++) op+=o[i];
printf("%d\n",op);
}
return 0;
}

Compiler output:
main.c: In function 'main':
main.c:61:1: error: expected declaration or statement at end of input
   61 | }
      | ^
Language: C

#include<stdio.h>
void quicksort(int* x,int first,int last){
    int pivot,j,temp,i;

     if(first<last){
         pivot=first;
         i=first;
         j=last;

         while(i<j){
             while(x[i]<=x[pivot]&&i<last)
                 i++;
             while(x[j]>x[pivot])
                 j--;
             if(i<j){
                 temp=x[i];
                  x[i]=x[j];
                  x[j]=temp;
             }
         }

         temp=x[pivot];
         x[pivot]=x[j];
         x[j]=temp;
         quicksort(x,first,j-1);
         quicksort(x,j+1,last);

    }
}
int main()
{
int n,k,i;
scanf("%d%d",&n,&k);
int a[n];
for(i=0;i<n;i++) scanf("%d",&a[i]);
quicksort(a,0,n-1);
int u[n],o[n],j=1;
u[0]=a[0]; o[0]=1;
for(i=1;i<n;i++)
{
if(a[i]!=u[j-1])
{
u[j]=a[i];
o[j]=1;
j++;
}
else
{
o[j-1]+=1;
}
if(k>=j) printf("%d\n",0);
else
{
quicsort(o,0,j-1);
int d=j-k;
int op=0;
for(i=0;i<d;i++) op+=o[i];
printf("%d\n",op);
}
return 0;
}



Compiler output:
main.c: In function 'main':
main.c:54:1: error: implicit declaration of function 'quicsort'; did you mean 'quicksort'? [-Wimplicit-function-declaration]
   54 | quicsort(o,0,j-1);
      | ^~~~~~~~
      | quicksort
main.c:61:1: error: expected declaration or statement at end of input
   61 | }
      | ^
Language: C++

#include <iostream>

using namespace std;

int main (){

    int n, k, a[200000], cnt = 0, ans = 0;
    cin >> n >> k;

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

    sort(a, a+n);


    int i;
    for(i=0; i<n; i++){
        if(a[i] != a[i+1]) cnt++;
        if(cnt == k) break;
    }
    for(int j = i+1; j < n; j++) ans++;

    cout << ans << endl;

    return 0;
}


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

#define MAX_N 200000
#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    int N, K;
    int A[MAX_N];
    cin >> N >> K;
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    
    int B[MAX_N];
    fill(B, B+MAX_N, 0);
    for (int i=0; i<N; i++) {
        B[A[i]] += 1;
    }
    sort(B, B+MAX_N, greater<int>());
    
    int ans = 0;
    for (int i=K; i<N; i++) {
        ans += B[i];
    }
    
    cout << ans << endl;
    return 0;
}

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

#include <iostream>
#include <vector>
#include <algorithm>

int main(void){
  int n, k;
  std::cin >> n >> k;
  std::vector<int> a(n, 0);
  for(auto x : a) {
    int tmp;
    std::cin >> tmp;
    a[tmp - 1]++;
  }
  std::sort(a.begin(),a.end());
  int out = 0;
  for(int i = 0; i < n - k; i++) {
    out += a[i];
  }
  std::cout << out << std::endl;

}


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

#include <iostream>
#include <vector>
#include <queue>
#include <functional>
using namespace std;
int main(){
  int c[200000];
  for (int i = 0; i < 200000; i++){
    c[i] = 0;
  }
  int N, K, r;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    c[a]++;
  }
  priority_queue<int, vector<int>, greater<int> >Q;
  for(int i = 0; i < 200000; i++){
    if(c[i] != 0)Q.push(c[i]);
  }
  for(int i = 0; i < N - K; i++){
    r = r + Q.pop();
  }
  cout << r;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:11: error: invalid operands of types 'int' and 'void' to binary 'operator+'
   23 |     r = r + Q.pop();
      |         ~ ^ ~~~~~~~
      |         |        |
      |         int      void
Language: C++

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
  int c[200000];
  for (int i = 0; i < 200000; i++){
    c[i] = 0;
  }
  int N, K, r;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    c[a]++;
  }
  priority_queue<int, vector<int>, greater<int> >Q;
  for(int i = 0; i < 200000; i++){
    if(c[i] != 0)Q.push(c[i]);
  }
  for(int i = 0; i < N - K; i++){
    r = r + (int)Q.pop();
  }
  cout << r;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:23: error: void value not ignored as it ought to be
   22 |     r = r + (int)Q.pop();
      |                  ~~~~~^~
Language: C++

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
  int c[200000];
  for (int i = 0; i < 200000; i++){
    c[i] = 0;
  }
  int N, K, r;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    c[a]++;
  }
  priority_queue<int, vector<int>, greater<int> >Q;
  for(int i = 0; i < 200000; i++){
    if(c[i] != 0)Q.push(c[i]);
  }
  for(int i = 0; i < N - K; i++){
    r = r + Q.pop();
  }
  cout << r;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:11: error: invalid operands of types 'int' and 'void' to binary 'operator+'
   22 |     r = r + Q.pop();
      |         ~ ^ ~~~~~~~
      |         |        |
      |         int      void
Language: C++

#include <string>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;

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

	B = A;
	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());

	for (int i = 0; i < A.size(); i++) {
		C.push_back(count(B.begin(), B.end(), A[i]));
	}

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

	int ans = 0;
	for (int i = 0; i < A.size() - K; i++) {
		ans += C[i];
	}

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


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'cin' was not declared in this scope
   10 |         cin >> N >> K;
      |         ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <queue>
  +++ |+#include <iostream>
    5 | 
a.cc:29:9: error: 'cout' was not declared in this scope
   29 |         cout << ans << endl;
      |         ^~~~
a.cc:29:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:29:24: error: 'endl' was not declared in this scope
   29 |         cout << ans << endl;
      |                        ^~~~
a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    4 | #include <queue>
  +++ |+#include <ostream>
    5 |
Language: C++

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
  int c[200000];
  for (int i = 0; i < 200000; i++){
    c[i] = 0;
  }
  int N, K, r;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    c[a]++;
  }
  priority_queue<int, vector<int>, greater<int> >Q;
  for(int i = 0; i < 200000; i++){
    if(!c[i])Q.push(c[i]);
  }
  for(int i = 0; i < N - K; i++){
    r = r + Q.pop();
  }
  cout << r;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:11: error: invalid operands of types 'int' and 'void' to binary 'operator+'
   22 |     r = r + Q.pop();
      |         ~ ^ ~~~~~~~
      |         |        |
      |         int      void
Language: C++

#include<iostream>
#include<vector>
#include<string>
using namespace std;
int n,k;
int t[500000];

int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>t[i];
	sort(t,t+n);
	int cnt=0;
	int now=10000000;
	bool f=1;
	for(int i=0;i<n;i++){
		if(now!=t[i]){
			cnt++;
			now=t[i];
		}

		if(cnt>k){
		cout<<n-i<<endl;
		f=0;
		break;
		}
	}
	if(f)cout<<0<<endl;
	return 0;
}

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