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

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

typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

// #define int long long
#define ll long long
#define F first
#define S second
#define endl '\n'
#define pb(x) push_back((x))
#define f(i,n) for(int i=0;i<n;i++)
#define g(i,m,n) for(int i=m; i<=n; i++)
#define asc(a) (a).begin(),(a).end()
#define desc(a) (a).rbegin(),(a).rend()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pa1(a,n) g(i,1,n) cout<<a[i]<<" "; cout<<endl;
#define pa(a,n) f(i,n) cout<<a[i]<<" "; cout<<endl;
#define ia1(a,n) vector<int> a(n+1); g(i,1,n) cin>>a[i];
#define ia(a,n) vector<int> a(n); f(i,n) cin>>a[i];

const int mod = 1e9+7;
const int INF = 1e9;

void solve() {
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    f(i,n)
    {
        cin>>a[i];
    }
    sort(a.begin(), a.end());
    vector<int> cnt;
    cnt={1};
    for(int i=1; i<=n;i++)
    {
        if(a[i]==a[i-1])
        {
            cnt.back()++;
        }
        else
        {
            cnt.emplace_back(1);
        }
    }
sort(cnt.begin(),cnt.end());
    int m=cnt.size();
    for(int i=0;i<m-1;i++)
    {
        if(cnt[i]>k)
        {
            cout<<m-i-1<<endl;
            return;
        }
        else{
            k-=cnt[i];
        }
    }
    cout<<1;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

// #define int long long
#define ll long long
#define F first
#define S second
#define endl '\n'
#define pb(x) push_back((x))
#define f(i,n) for(int i=0;i<n;i++)
#define g(i,m,n) for(int i=m; i<=n; i++)
#define asc(a) (a).begin(),(a).end()
#define desc(a) (a).rbegin(),(a).rend()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pa1(a,n) g(i,1,n) cout<<a[i]<<" "; cout<<endl;
#define pa(a,n) f(i,n) cout<<a[i]<<" "; cout<<endl;
#define ia1(a,n) vector<int> a(n+1); g(i,1,n) cin>>a[i];
#define ia(a,n) vector<int> a(n); f(i,n) cin>>a[i];

const int mod = 1e9+7;
const int INF = 1e9;

void solve() {
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    f(i,n)
    {
        cin>>a[i];
    }
    sort(a.begin(), a.end());
    vector<int> cnt;
    cnt={1};
    for(int i=1; i<n;i++)
    {
        if(a[i]==a[i-1])
        {
            cnt.back()++;
        }
        else
        {
            cnt.emplace_back(1);
        }
    }
sort(cnt.begin(),cnt.end());
    int m=cnt.size();
    for(int i=0;i<m-1;i++)
    {
        if(cnt[i]>k)
        {
            cout<<m-i<<endl;
            return;
        }
        else{
            k-=cnt[i];
        }
    }
    cout<<1;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}