ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 7):
#include <stdio.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+200;
set<int>e[N];
vector<pair<int,int>>v;
int a[N];
bool cmp(pair<int,int>x,pair<int,int>y){
	return x.second>y.second;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		v.clear();
		for(int i=1;i<=n;++i){
			a[i]=0;
			e[i].clear();
		}
		int mx=0;
		for(int i=1;i<n;++i){
			int x,y;
			cin>>x>>y;
			e[x].insert(y);
			e[y].insert(x);
			a[x]++;
			a[y]++;
		}
		for(int i=1;i<=n;++i) v.push_back({i,a[i]});
		sort(v.begin(),v.end(),cmp);
		int ans=1;
		int cnt=0;
		while(cnt<n-1&&v[cnt].second==v[cnt+1].second) cnt++;
		if(cnt==0){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			int f=1;
			cnt=1;
			while(cnt<n-1&&v[cnt].second==v[cnt+1].second) cnt++;
			for(int i=1;i<=cnt;++i){
				if(e[v[i].first].find(v[0].first)==e[v[i].first].end()){
					f=0;
					break;
				}
			}
			if(f) ans--;
		}else if(cnt==1){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			if(e[v[0].first].find(v[1].first)!=e[v[0].first].end())ans--;
		}else{
			ans+=v[0].second-1;
			ans+=v[1].second-1;
		}
		cout<<max(ans,0)<<'\n';
	} 
	return 0;
}

Submission (verdict: Accepted):
#include <stdio.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=2e5+200;
set<int>e[N];
vector<pair<int,int>>v;
int a[N];
bool cmp(pair<int,int>x,pair<int,int>y){
	return x.second>y.second;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		v.clear();
		for(int i=1;i<=n;++i){
			a[i]=0;
			e[i].clear();
		}
		int mx=0;
		for(int i=1;i<n;++i){
			int x,y;
			cin>>x>>y;
			e[x].insert(y);
			e[y].insert(x);
			a[x]++;
			a[y]++;
		}
		for(int i=1;i<=n;++i) v.push_back({i,a[i]});
		sort(v.begin(),v.end(),cmp);
		int ans=1;
		int cnt=0;
		while(cnt<n-1&&v[cnt].second==v[cnt+1].second) cnt++;
		if(cnt==0){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			int f=1;
			cnt=1;
			while(cnt<n-1&&v[cnt].second==v[cnt+1].second) cnt++;
			for(int i=1;i<=cnt;++i){
				if(e[v[i].first].find(v[0].first)==e[v[i].first].end()){
					f=0;
					break;
				}
			}
			if(f) ans--;
		}else if(cnt==1){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			if(e[v[0].first].find(v[1].first)!=e[v[0].first].end())ans--;
		}else{
			ans+=v[0].second-1;
			ans+=v[1].second-1;
		}
		cout<<max(ans,0)<<'\n';
	} 
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 7):
#include <stdio.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+200;
set<int>e[N];
vector<pair<int,int>>v;
int a[N];
bool cmp(pair<int,int>x,pair<int,int>y){
	return x.second>y.second;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		v.clear();
		for(int i=1;i<=n;++i){
			a[i]=0;
			e[i].clear();
		}
		int mx=0;
		for(int i=1;i<n;++i){
			int x,y;
			cin>>x>>y;
			e[x].insert(y);
			e[y].insert(x);
			a[x]++;
			a[y]++;
		}
		for(int i=1;i<=n;++i) v.push_back({i,a[i]});
		sort(v.begin(),v.end(),cmp);
		int ans=1;
		int cnt=0;
		while(cnt<n&&v[cnt].second==v[cnt+1].second) cnt++;
		if(cnt==0){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			int f=1;
			cnt=1;
			while(cnt<n&&v[cnt].second==v[cnt+1].second) cnt++;
			for(int i=1;i<=cnt;++i){
				if(e[v[i].first].find(v[0].first)==e[v[i].first].end()){
					f=0;
					break;
				}
			}
			if(f) ans--;
		}else if(cnt==1){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			if(e[v[0].first].find(v[1].first)!=e[v[0].first].end())ans--;
		}else{
			ans+=v[0].second-1;
			ans+=v[1].second-1;
		}
		cout<<max(ans,0)<<'\n';
	} 
	return 0;
}

Submission (verdict: Runtime error on test 7):
#include <stdio.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+200;
set<int>e[N];
vector<pair<int,int>>v;
int a[N];
bool cmp(pair<int,int>x,pair<int,int>y){
	return x.second>y.second;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		v.clear();
		for(int i=1;i<=n;++i){
			a[i]=0;
			e[i].clear();
		}
		int mx=0;
		for(int i=1;i<n;++i){
			int x,y;
			cin>>x>>y;
			e[x].insert(y);
			e[y].insert(x);
			a[x]++;
			a[y]++;
		}
		for(int i=1;i<=n;++i) v.push_back({i,a[i]});
		sort(v.begin(),v.end(),cmp);
		int ans=1;
		int cnt=0;
		while(cnt<n-1&&v[cnt].second==v[cnt+1].second) cnt++;
		if(cnt==0){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			int f=1;
			cnt=1;
			while(cnt<n&&v[cnt].second==v[cnt+1].second) cnt++;
			for(int i=1;i<=cnt;++i){
				if(e[v[i].first].find(v[0].first)==e[v[i].first].end()){
					f=0;
					break;
				}
			}
			if(f) ans--;
		}else if(cnt==1){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			if(e[v[0].first].find(v[1].first)!=e[v[0].first].end())ans--;
		}else{
			ans+=v[0].second-1;
			ans+=v[1].second-1;
		}
		cout<<max(ans,0)<<'\n';
	} 
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 7):
#include <stdio.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+200;
set<int>e[N];
vector<pair<int,int>>v;
int a[N];
bool cmp(pair<int,int>x,pair<int,int>y){
	return x.second>y.second;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		v.clear();
		for(int i=1;i<=n;++i){
			a[i]=0;
			e[i].clear();
		}
		int mx=0;
		for(int i=1;i<n;++i){
			int x,y;
			cin>>x>>y;
			e[x].insert(y);
			e[y].insert(x);
			a[x]++;
			a[y]++;
		}
		for(int i=1;i<=n;++i) v.push_back({i,a[i]});
		sort(v.begin(),v.end(),cmp);
		int ans=1;
		int cnt=0;
		while(cnt<n-1&&v[cnt].second==v[cnt+1].second) cnt++;
		if(cnt==0){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			int f=1;
			cnt=1;
			while(cnt<n&&v[cnt].second==v[cnt+1].second) cnt++;
			for(int i=1;i<=cnt;++i){
				if(e[v[i].first].find(v[0].first)==e[v[i].first].end()){
					f=0;
					break;
				}
			}
			if(f) ans--;
		}else if(cnt==1){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			if(e[v[0].first].find(v[1].first)!=e[v[0].first].end())ans--;
		}else{
			ans+=v[0].second-1;
			ans+=v[1].second-1;
		}
		cout<<max(ans,0)<<'\n';
	} 
	return 0;
}

Submission (verdict: Runtime error on test 7):
#include <stdio.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+200;
set<int>e[N];
vector<pair<int,int>>v;
int a[N];
bool cmp(pair<int,int>x,pair<int,int>y){
	return x.second>y.second;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		v.clear();
		for(int i=1;i<=n;++i){
			a[i]=0;
			e[i].clear();
		}
		int mx=0;
		for(int i=1;i<n;++i){
			int x,y;
			cin>>x>>y;
			e[x].insert(y);
			e[y].insert(x);
			a[x]++;
			a[y]++;
		}
		for(int i=1;i<=n;++i) v.push_back({i,a[i]});
		sort(v.begin(),v.end(),cmp);
		int ans=1;
		int cnt=0;
		while(cnt<n-1&&v[cnt].second==v[cnt+1].second) cnt++;
		if(cnt==0){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			int f=1;
			cnt=1;
			while(cnt<n-1&&v[cnt].second==v[cnt+1].second) cnt++;
			for(int i=1;i<=cnt;++i){
				if(e[v[i].first].find(v[0].first)==e[v[i].first].end()){
					f=0;
					break;
				}
			}
			if(f) ans--;
		}else if(cnt==1){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			if(e[v[0].first].find(v[1].first)!=e[v[0].first].end())ans--;
		}else{
			ans+=v[0].second-1;
			ans+=v[1].second-1;
		}
		cout<<max(ans,0)<<'\n';
	} 
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Runtime error on test 7):
#include <stdio.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+200;
set<int>e[N];
vector<pair<int,int>>v;
int a[N];
bool cmp(pair<int,int>x,pair<int,int>y){
	return x.second>y.second;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		v.clear();
		for(int i=1;i<=n;++i){
			a[i]=0;
			e[i].clear();
		}
		int mx=0;
		for(int i=1;i<n;++i){
			int x,y;
			cin>>x>>y;
			e[x].insert(y);
			e[y].insert(x);
			a[x]++;
			a[y]++;
		}
		for(int i=1;i<=n;++i) v.push_back({i,a[i]});
		sort(v.begin(),v.end(),cmp);
		int ans=1;
		int cnt=0;
		while(cnt<n&&v[cnt].second==v[cnt+1].second) cnt++;
		if(cnt==0){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			int f=1;
			cnt=1;
			while(cnt<n&&v[cnt].second==v[cnt+1].second) cnt++;
			for(int i=1;i<=cnt;++i){
				if(e[v[i].first].find(v[0].first)==e[v[i].first].end()){
					f=0;
					break;
				}
			}
			if(f) ans--;
		}else if(cnt==1){
			ans+=v[0].second-1;
			ans+=v[1].second-1;
			if(e[v[0].first].find(v[1].first)!=e[v[0].first].end())ans--;
		}else{
			ans+=v[0].second-1;
			ans+=v[1].second-1;
		}
		cout<<max(ans,0)<<'\n';
	} 
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;



#define ll long long int

#define MOD 1000000007

#define ii pair<int, int>

#define fi first

#define se second



void solve() {

    int n; cin >> n;

    vector<int> v(n);

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

    int inv = 0, rev = 0;

    for (int i = 0; i < n - 1; i++) {

        if (v[i] < v[i + 1]) {

            inv++;

        } else {

            rev++;

        }

    }

    if (inv < rev) {

        cout <<"NO\n";

    } else {

        cout << "YES\n";

    }

}



int main() 

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    int tt = 1; cin >> tt;

    for (int t = 1; t <= tt; t++) {

         solve();

    }

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;



#define ll long long int

#define MOD 1000000007

#define ii pair<int, int>

#define fi first

#define se second



void solve() {

    int n; cin >> n;

    vector<int> v(n);

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

    int inv = 0, rev = 0;

    for (int i = 0; i < n - 1; i++) {

        if (v[i] < v[i + 1]) {

            inv++;

        } else {

            rev++;

        }

    }

    if (inv <= rev) {

        cout <<"NO\n";

    } else {

        cout << "YES\n";

    }

}



int main() 

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    int tt = 1; cin >> tt;

    for (int t = 1; t <= tt; t++) {

         solve();

    }

}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;



#define ll long long int

#define MOD 1000000007

#define ii pair<int, int>

#define fi first

#define se second



void solve() {

    /*

    se ai > ai + 1 continua desordenado independente

    so adianta tentar qnd ai <= ai + 1



    se o array ou tiver sortado ou tiver um numero de pares (ai, ai + 1)

    com ai <= ai + 1 que caso eu ajeite fique sortado ent da

    */

    int n; cin >> n;

    vector<int> v(n);

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

    vector<int> ok(n);

    for (int i = 0; i < n - 1; i++) {

        if (v[i] < v[i + 1]) {

            ok[i] = ok[i + 1] = true;

        }

    }

    for (int i = 0; i < n; i++) {

        if (!ok[i]) {

            cout << "NO\n";

            return;

        }

    }

    cout << "YES\n";

}



int main() 

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    int tt = 1; cin >> tt;

    for (int t = 1; t <= tt; t++) {

         solve();

    }

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;



#define ll long long int

#define MOD 1000000007

#define ii pair<int, int>

#define fi first

#define se second



void solve() {

    /*

    se ai > ai + 1 continua desordenado independente

    so adianta tentar qnd ai <= ai + 1



    se o array ou tiver sortado ou tiver um numero de pares (ai, ai + 1)

    com ai <= ai + 1 que caso eu ajeite fique sortado ent da

    */

    int n; cin >> n;

    vector<int> v(n);

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

    vector<int> ok(n);

    for (int i = 0; i < n - 1; i++) {

        if (v[i] < v[i + 1]) {

            ok[i] = ok[i + 1] = true;

        }

    }

    for (int i = 0; i < n; i++) {

        if (!ok[i]) {

            cout << "NO\n";

            return;

        }

    }

    cout << "YES\n";

}



int main() 

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    int tt = 1; cin >> tt;

    for (int t = 1; t <= tt; t++) {

         solve();

    }

}

Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;



#define ll long long int

#define MOD 1000000007

#define ii pair<int, int>

#define fi first

#define se second



void solve() {

    /*

    se ai > ai + 1 continua desordenado independente

    so adianta tentar qnd ai <= ai + 1



    se o array ou tiver sortado ou tiver um numero de pares (ai, ai + 1)

    */

    int n; cin >> n;

    vector<int> v(n);

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

    for (int i = 0; i < n - 1; i++) {

        int k = min(v[i], v[i + 1]);

        v[i] -= k, v[i + 1] -= k;

    }

    for (int i = 0; i < n - 1; i++) {

        if (v[i] > v[i + 1]) {

            cout << "NO\n";

            return;

        }

    }

    cout << "YES\n";

}



int main() 

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    int tt = 1; cin >> tt;

    for (int t = 1; t <= tt; t++) {

         solve();

    }

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;



#define ll long long int

#define MOD 1000000007

#define ii pair<int, int>

#define fi first

#define se second



void solve() {

    int n; cin >> n;

    vector<int> v(n);

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

    int inv = 0, rev = 0;

    for (int i = 0; i < n - 1; i++) {

        if (v[i] < v[i + 1]) {

            inv++;

        } else {

            rev++;

        }

    }

    if (inv < rev) {

        cout <<"NO\n";

    } else {

        cout << "YES\n";

    }

}



int main() 

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    int tt = 1; cin >> tt;

    for (int t = 1; t <= tt; t++) {

         solve();

    }

}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;



#define ll long long int

#define MOD 1000000007

#define ii pair<int, int>

#define fi first

#define se second



void solve() {

    int n; cin >> n;

    vector<int> v(n);

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

    int inv = 0, rev = 0;

    for (int i = 0; i < n - 1; i++) {

        if (v[i] < v[i + 1]) {

            inv++;

        } else {

            rev++;

        }

    }

    if (inv <= rev) {

        cout <<"NO\n";

    } else {

        cout << "YES\n";

    }

}



int main() 

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    int tt = 1; cin >> tt;

    for (int t = 1; t <= tt; t++) {

         solve();

    }

}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t ;
    cin >> t;
    while (t--)
    {
        int  n;
        int k;
        cin >> n >> k;
        int arr[n];
        for ( int i = 0 ; i < n ; i++){
            cin >> arr[i];
        }
        sort(arr, arr + n);
      	int cnt = 1;
      	vector<int> frequency;
        for( int j = 1 ; j < n ; j++){
          	if(arr[j]!=arr[j-1]){
              	frequency.push_back(cnt);
                cnt=1;
            }
        	cnt++;
    	}
        	frequency.push_back(cnt);
      	sort(frequency.begin(), frequency.end());
      	int ans = frequency.size();
      	for( int i = 0 ; i < frequency.size() ; i++){
          if( k >= frequency[i] ) {
            k -= frequency[i];
            ans--;
          }else{
            break;
          }
        }
      cout << ans << endl;
    }
  
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t ;
    cin >> t;
    while (t--)
    {
        int  n;
        int k;
        cin >> n >> k;
        int arr[n];
        for ( int i = 0 ; i < n ; i++){
            cin >> arr[i];
        }
        sort(arr, arr + n);
      	int cnt = 1;
      	vector<int> frequency;
        for( int j = 1 ; j < n ; j++){
          	if(arr[j]!=arr[j-1]){
              	frequency.push_back(cnt);
                cnt=1;
            }
        	cnt++;
    	}
        	frequency.push_back(cnt);
      	sort(frequency.begin(), frequency.end());
      	int ans = frequency.size();
      	for( int i = 0 ; i < frequency.size() ; i++){
          if( k >= frequency[i] ) {
            k -= frequency[i];
            ans--;
          }else{
            break;
          }
        }
      cout << max(ans, 1) << endl;
    }
  
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t ;
    cin >> t;
    while (t--)
    {
        int  n;
        int k;
        cin >> n >> k;
        int arr[n];
        for ( int i = 0 ; i < n ; i++){
            cin >> arr[i];
        }
        sort(arr, arr + n);
      	int cnt = 1;
      	vector<int> frequency;
        for( int j = 1 ; j < n ; j++){
          	if(arr[j]!=ar[j-1]){
              	frequency.push_back(cnt);
                cnt=1;
            }
        	cnt++;
    	}
      	sort(frequency.begin(), frequency.end());
      	int ans = frequency.size();
      	for( int i = 0 ; i < frequency.size() ; i++){
          if( k >= frequency[i] ) {
            k -= frequency[i];
            ans--;
          }
        }
      cout << ans << endl;
    }
  
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t ;
    cin >> t;
    while (t--)
    {
        int  n;
        int k;
        cin >> n >> k;
        int arr[n];
        for ( int i = 0 ; i < n ; i++){
            cin >> arr[i];
        }
        sort(arr, arr + n);
      	int cnt = 1;
      	vector<int> frequency;
        for( int j = 1 ; j < n ; j++){
          	if(arr[j]!=arr[j-1]){
              	frequency.push_back(cnt);
                cnt=1;
            }
        	cnt++;
    	}
      	sort(frequency.begin(), frequency.end());
      	int ans = frequency.size();
      	for( int i = 0 ; i*1ULL < frequency.size() ; i++){
          if( k >= frequency[i] ) {
            k -= frequency[i];
            ans--;
          }
        }
      cout << ans << endl;
    }
  
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Compilation error):
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t ;
    cin >> t;
    while (t--)
    {
        int  n;
        int k;
        cin >> n >> k;
        int arr[n];
        for ( int i = 0 ; i < n ; i++){
            cin >> arr[i];
        }
        sort(arr, arr + n);
      	int cnt = 1;
      	vector<int> frequency;
        for( int j = 1 ; j < n ; j++){
          	if(arr[j]!=ar[j-1]){
              	frequency.push_back(cnt);
                cnt=1;
            }
        	cnt++;
    	}
      	sort(frequency.begin(), frequency.end());
      	int ans = frequency.size();
      	for( int i = 0 ; i < frequency.size() ; i++){
          if( k >= frequency[i] ) {
            k -= frequency[i];
            ans--;
          }
        }
      cout << ans << endl;
    }
  
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t ;
    cin >> t;
    while (t--)
    {
        int  n;
        int k;
        cin >> n >> k;
        int arr[n];
        for ( int i = 0 ; i < n ; i++){
            cin >> arr[i];
        }
        sort(arr, arr + n);
      	int cnt = 1;
      	vector<int> frequency;
        for( int j = 1 ; j < n ; j++){
          	if(arr[j]!=arr[j-1]){
              	frequency.push_back(cnt);
                cnt=1;
            }
        	cnt++;
    	}
        	frequency.push_back(cnt);
      	sort(frequency.begin(), frequency.end());
      	int ans = frequency.size();
      	for( int i = 0 ; i < frequency.size() ; i++){
          if( k >= frequency[i] ) {
            k -= frequency[i];
            ans--;
          }else{
            break;
          }
        }
      cout << max(ans, 1) << endl;
    }
  
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t ;
    cin >> t;
    while (t--)
    {
        int  n;
        int k;
        cin >> n >> k;
        int arr[n];
        for ( int i = 0 ; i < n ; i++){
            cin >> arr[i];
        }
        sort(arr, arr + n);
      	int cnt = 1;
      	vector<int> frequency;
        for( int j = 1 ; j < n ; j++){
          	if(arr[j]!=arr[j-1]){
              	frequency.push_back(cnt);
                cnt=0;
            }
        	cnt++;
    	}
        	frequency.push_back(cnt);
      	sort(frequency.begin(), frequency.end());
      	int ans = frequency.size();
      	for( int i = 0 ; i < frequency.size() ; i++){
          if( k >= frequency[i] ) {
            k -= frequency[i];
            ans--;
          }else{
            break;
          }
        }
      cout << max(ans, 1) << endl;
    }
  
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t ;
    cin >> t;
    while (t--)
    {
        int  n;
        int k;
        cin >> n >> k;
        int arr[n];
        for ( int i = 0 ; i < n ; i++){
            cin >> arr[i];
        }
        sort(arr, arr + n);
      	int cnt = 1;
      	vector<int> frequency;
        for( int j = 1 ; j < n ; j++){
          	if(arr[j]!=arr[j-1]){
              	frequency.push_back(cnt);
                cnt=1;
            }
        	cnt++;
    	}
      	sort(frequency.begin(), frequency.end());
      	int ans = frequency.size();
      	for( int i = 0 ; i*1ULL < frequency.size() ; i++){
          if( k >= frequency[i] ) {
            k -= frequency[i];
            ans--;
          }
        }
      cout << ans << endl;
    }
  
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t ;
    cin >> t;
    while (t--)
    {
        int  n;
        int k;
        cin >> n >> k;
        int arr[n];
        for ( int i = 0 ; i < n ; i++){
            cin >> arr[i];
        }
        sort(arr, arr + n);
      	int cnt = 1;
      	vector<int> frequency;
        for( int j = 1 ; j < n ; j++){
          	if(arr[j]!=arr[j-1]){
              	frequency.push_back(cnt);
                cnt=1;
            }
        	cnt++;
    	}
        	frequency.push_back(cnt);
      	sort(frequency.begin(), frequency.end());
      	int ans = frequency.size();
      	for( int i = 0 ; i < frequency.size() ; i++){
          if( k >= frequency[i] ) {
            k -= frequency[i];
            ans--;
          }else{
            break;
          }
        }
      cout << ans << endl;
    }
  
    return 0;
}