ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: c++20 

Code 1:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;cin>>t;
    while(t--){
        long long n,k;cin>>n>>k;
        vector<long long>v(n);
        map<long long,long long>m;
        for(long long i=0;i<n;i++){cin>>v[i];m[v[i]]++;}
        vector<long long>a;
        for(auto& [x,y]:m){a.push_back(y);}
        sort(a.begin(),a.end());
        long long ans=a.size();
        for(long long i=0;i<a.size()-1;i++){if(k>=a[i]){k-=a[i];ans--;}}
        cout<<ans<<endl;
    }
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;cin>>t;
    while(t--){
        long long n,k;cin>>n>>k;
        vector<long long>v(n);
        map<long long,long long>m;
        for(long long i=0;i<n;i++){cin>>v[i];m[v[i]]++;}
        vector<long long>a;
        for(auto& [x,y]:m){a.push_back(y);}
        sort(a.begin(),a.end());
        long long ans=a.size();
        for(long long i=0;i<a.size();i++){if(k>=a[i]){k-=a[i];ans--;}}
        cout<<ans<<endl;
    }
}

Answer: 1
Problem: 2057B - Gorilla and the Exam
Language: c++20 

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


int main() {
    
ios_base::sync_with_stdio(false);
cin.tie(NULL);
	// your code goes here
    int t;
    cin>>t;
    
    while(t--)
    {
        int i,n,k,totaluniq;
        cin>>n>>k;
        
        //int a[n];
        map<int, int> mp;
        
        for(i=0;i<n;i++)
        {
            int temp;
            cin>>temp;
            mp[temp]++;
        }
        
        
        totaluniq=mp.size();
        
        if(k==0)
        {
            cout<<totaluniq<<endl;
        }
        else if(k>=n-1)
        {
            cout<<1<<endl;
        }
        else
        {
        vector<int> pq;
        for(auto it=mp.begin();it!=mp.end();it++)
        {
            pq.push_back(it->second);
        }
        
        sort(pq.begin(), pq.end());
        int ctr=0;
        
        for(auto it=pq.begin(); it!=pq.end()&&ctr<k&&totaluniq>1; it++)
        {
            int freq=*it;
            
            if(freq+ctr<=k)
            {ctr+=freq;
            totaluniq--;
            }
            else
            {
                break;
            }
        }
        
        cout<<totaluniq<<endl;
        }
    }
}


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

int main() {
	// your code goes here
    int t;
    cin>>t;
    
    while(t--)
    {
        int i,n,k,totaluniq;
        cin>>n>>k;
        
        //int a[n];
        unordered_map<int, int> mp;
        
        for(i=0;i<n;i++)
        {
            int t;
            cin>>t;
            mp[t]++;
        }
        
        
        totaluniq=mp.size();
        
        if(k==0)
        {
            cout<<totaluniq<<endl;
        }
        else if(k>=n-1)
        {
            cout<<1<<endl;
        }
        else
        {
        vector<int> pq;
        for(auto it=mp.begin();it!=mp.end();it++)
        {
            pq.push_back(it->second);
        }
        
        sort(pq.begin(), pq.end());
        int ctr=0;
        
        for(auto it=pq.begin(); it!=pq.end()&&ctr<k&&totaluniq>1; it++)
        {
            int freq=*it;
            
            if(freq+ctr<=k)
            {ctr+=freq;
            totaluniq--;
            }
            else
            {
                break;
            }
        }
        
        cout<<totaluniq<<endl;
        }
    }
}


Answer: 1
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Code 1:
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ULL;
const int N=4e5 + 5;
using namespace std;
vector<int>vv;
void solve(){
  int a,b,sum=0;
  cin>>a>>b;
  set<int>se;
  map<int,int>m;
  for(int i=0;i<a;i++){
    int c;
    cin>>c;
    se.insert(c);
    m[c]++;   
  }
  vector<int>v;
  for(auto i:se){
    v.push_back(m[i]);
  }
  sort(v.begin(),v.end());
  for(int i=0;i<v.size();i++){
    if(v[i]<=b){
      b-=v[i];
      continue;
    }
    sum++;
 
  }
  if(sum==0)sum++;
  vv.push_back(sum);
}
int main(){
  int t;
  cin>>t;
  while(t--)solve();
  for(auto i:vv)cout<<i<<'\n';
}

Code 2:
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ULL;
const int N=4e5 + 5;
using namespace std;
void solve(){
  int a,b,sum=0;
  cin>>a>>b;
  set<int>se;
  map<int,int>m;
  for(int i=0;i<a;i++){
    int c;
    cin>>c;
    se.insert(c);
    m[c]++;   
  }
  vector<int>v;
  for(auto i:se){
    v.push_back(m[i]);
  }
  sort(v.begin(),v.end());
  for(int i=0;i<v.size();i++){
    if(v[i]<=b){
      b-=v[i];
      continue;
    }
    sum++;
 
  }
  if(sum==0)sum++;
  cout<<sum<<'\n';
  for(auto i:v)cout<<i<<" ";
}
int main(){
  int t;
  cin>>t;
  while(t--)solve();
}

Answer: 1
Problem: 2057B - Gorilla and the Exam
Language: c++20 

Code 1:
#include <bits/stdc++.h>
using namespace std;
int arr[100002];
void solve(){
    int n,k;
    cin>>n>>k;
    unordered_map<int,int>mp;
    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        mp[x]++;
    }
    int size=mp.size();
    priority_queue<int,vector<int>,greater<int>>pq;
    int i=0;
    for(auto it:mp){
        arr[i++]=it.second;
    }
    sort(arr,arr+i);
    for(int j=0;j<i;j++){
        if(k>=arr[j]){
            k-=arr[j];
            size--;
        }
        else break;
    }
    if(size<=0)size=1;
    cout<<size<<endl;
}
int main() {
	int t;
	cin>>t;
	while(t--){
	    solve();
	}

}


Code 2:
#include <bits/stdc++.h>
using namespace std;
int arr[100002];
map<int,int>mp;
void solve(){
    int n,k;
    cin>>n>>k;
    mp.clear();
    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        mp[x]++;
    }

    int i=0;
    for(auto it:mp){
        arr[i++]=it.second;
    }
    int size=i;
    sort(arr,arr+i);
    for(int j=0;j<i;j++){
        if(k>=arr[j]){
            k-=arr[j];
            size--;
        }
        else break;
    }
    if(size<=0)size=1;
    cout<<size<<endl;
}
int main() {
	int t;
	cin>>t;
	while(t--){
	    solve();
	}

}


Answer: 2
Problem: 2057B - Gorilla and the Exam
Language: c++23 

Code 1:
 #include "bits/stdc++.h"
using namespace std;

#define int unsigned long long
#define dub long double
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef unordered_map<int,int> umap;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(a) a.begin(),a.end()
#define endl '\n'
#define INF 2147483647
//#define INF 9223372036854775807
#define null '\0'
const int N = 1e5 + 10, Mod = 1e9 + 7;
int n,m;
int fact[N];
void solve(){
    string s,t;
    cin >> s >> t;
    n = s.size();
    m = t.size();
    vector<vint> dp(n+1,vint(m+1));
    vector<vint> pi(n+1,vint(m+1));
    rep(i,0,n+1) {
        rep(j,0,m+1) {
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else {
                if(s[i-1] == t[j-1])
                    dp[i][j] = dp[i-1][j-1] + 1;
                else dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
            }
        }
    }
//    cout << "check\n";
    int res = n + m - dp[n][m];
    int ans = 1;
    rep(i,0,n+1) {
        rep(j,0,m+1) {
            if(i == 0 || j == 0) pi[i][j] = min(i,j) + 1;
            else if(dp[i][j] > dp[i-1][j-1]) {
                pi[i][j] = pi[i-1][j-1];
            }
            else
                pi[i][j] = pi[i-1][j] + pi[i][j-1];
        }
    }
    cout << pi[n][m] << endl;

}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int test_n = 1;
    cin>>test_n;
    for(int t_c = 1;t_c <= test_n;t_c ++){
        cout << "Case "<<t_c<<": ";
        solve();
    }
    return 0;
}

Code 2:
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define dub long double
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef unordered_map<int,int> umap;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(a) a.begin(),a.end()
#define endl '\n'
#define INF 2147483647
//#define INF 9223372036854775807
#define null '\0'
const int N = 1e5 + 10, Mod = 1e9 + 7;
int n,m,k;
void solve(){
    cin >> n >> k;
    vint a(n);
    rep(i,0,n) cin >> a[i];
    map<int,int> mp;
    rep(i,0,n) mp[a[i]] ++;
    int ans = 0;
    vii v;
    for(auto i : mp) {
        v.push_back({i.second , i.first});
        ans++;
    }
    sort(all(v));
    for(auto i : v) {
        if(i.first <= k) k -= i.first , ans--;
    }
    cout << max(1LL,ans) << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int test_n = 1;
    cin>>test_n;
    for(int t_c = 1;t_c <= test_n;t_c ++){
        solve();
    }
    return 0;
}

Answer: 2
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Code 1:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin>>arr[i];   
        }
        map<int,int> freq;
        for(int num: arr){
            freq[num]++;
        }
        vector<int> counts;
        for(auto &entry: freq){
            counts.push_back(entry.second);
        }
        sort(counts.begin(),counts.end());
        long long sum=0;
        int i=0;
        for(int count: counts){
            if(sum+count<=k){
                i++;
                sum+=count;
            }
            else{
                break;
            }
        }
        int ans=counts.size()-i;
        if(ans>0){
            cout<<ans<<endl;
        }
        else{
            cout<<1<<endl;
        }
    }
    return 0;
}


Code 2:
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin>>t;
    while(t--){
        int n, k;
        cin >> n >> k;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }

        unordered_map<int, int> freq;
        for(int num : arr){
            freq[num]++;
        }

        priority_queue<int, vector<int>, greater<int>> minHeap;
        for(auto &entry : freq){
            minHeap.push(entry.second);
        }

        int sum=0,removed=0;
        while(!minHeap.empty() && sum + minHeap.top()<=k){
            sum+=minHeap.top();
            minHeap.pop();
            removed++;
        }
        int ans = minHeap.size();
        cout << (ans > 0 ? ans : 1) << endl;
    }
    return 0;
}


Answer: 1
Problem: 2057B - Gorilla and the Exam
Language: c++20 

Code 1:
/**

                            * بسم الله الرحمن الرحيم *

    ﴾ رَبِّ اشْرَحْ لِي صَدْرِي * وَيَسِّرْ لِي أَمْرِي * وَاحْلُلْ عُقْدَةً مِّن لِّسَانِي * يَفْقَهُوا قَوْلِي ﴿

**/
#include <bits/stdc++.h>
#define ll long long
#define fi(l, r) for(ll i=l;i<r;i++)
#define fj(l, r) for(ll j=l;j<r;j++)
#define fir(r, l) for(ll i=r;i>=l;i--)
#define fjr(r, l) for(ll j=r;j>=l;j--)
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vll vector<ll>
#define vllll vector<vll>
#define vpll vector<pair<ll,ll>>
#define vb vector<bool>
#define pd push_back
using namespace std;

void solving(){
    ll n,k; cin>>n>>k;
    ll a[n];
    unordered_map<ll,ll> mp;
    fi(0,n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    vll counts;
    for(auto e:mp ){
        counts.push_back(e.second);
    }
    sort(all(counts));
    ll e1=0;
    ll e2=counts.size()-1;
    ll res=counts.size();
    while(e1<e2){
        if(counts[e1]<=k){
            k-=counts[e1];
            res--;
            e1++;
        }else break;
    }
    cout<<res<<'\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin>>n;
    while(n--) solving();
}

Code 2:
/**

                            * بسم الله الرحمن الرحيم *

    ﴾ رَبِّ اشْرَحْ لِي صَدْرِي * وَيَسِّرْ لِي أَمْرِي * وَاحْلُلْ عُقْدَةً مِّن لِّسَانِي * يَفْقَهُوا قَوْلِي ﴿

**/
#include <bits/stdc++.h>
#define ll long long
#define fi(l, r) for(ll i=l;i<r;i++)
#define fj(l, r) for(ll j=l;j<r;j++)
#define fir(r, l) for(ll i=r;i>=l;i--)
#define fjr(r, l) for(ll j=r;j>=l;j--)
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vll vector<ll>
#define vllll vector<vll>
#define vpll vector<pair<ll,ll>>
#define vb vector<bool>
#define pd push_back
using namespace std;

void solving(){
    ll n,k; cin>>n>>k;
    ll a[n];
    map<ll,ll> mp;
    fi(0,n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    vll counts;
    for(auto e:mp ){
        counts.push_back(e.second);
    }
    sort(all(counts));
    ll e1=0;
    ll e2=counts.size()-1;
    ll res=counts.size();
    while(e1<e2){
        if(counts[e1]<=k){
            k-=counts[e1];
            res--;
            e1++;
        }else break;
    }
    cout<<res<<'\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin>>n;
    while(n--) solving();
}

Answer: 2
Problem: 2057B - Gorilla and the Exam
Language: c++23 

Code 1:
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int> a(n);
        set<int> s;
        unordered_map<int,int> m;
        vector<int> freq;
        for(int i=0;i<n;i++){
            cin>>a[i];
            m[a[i]]++;
            
            s.insert(a[i]);
        }
        for (unordered_map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
            freq.push_back(it->second);
        }
        sort(freq.begin(),freq.end());

        int ans=s.size();
        for(int i=0;i<freq.size();i++){
            if(k>=freq[i]){
                k=k-freq[i];
                ans--;
            }
            else {
                break;
            }
        }
        if(ans==0) cout<<"1"<<endl;
       else  cout<<ans<<endl;


    }
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int> a(n);
        //set<int> s;
      
        map<int,int> m;
        vector<int> freq;
        for(int i=0;i<n;i++){
            cin>>a[i];
            m[a[i]]++;
            
            //s.insert(a[i]);
        }
        for (map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
            freq.push_back(it->second);
        }
        sort(freq.begin(),freq.end());

        int ans=m.size();
        for(int i=0;i<freq.size();i++){
            if(k>=freq[i]){
                k=k-freq[i];
                ans--;
            }
            else {
                break;
            }
        }
        if(ans==0) cout<<"1"<<endl;
       else  cout<<ans<<endl;


    }
}

Answer: 2
Problem: 2057B - Gorilla and the Exam
Language: c++17 

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

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        int temp = k;
        vector<int>v(n);
        map<int,int>m;
        vector<int>v2(n);
        for(int i=0;i<v.size();i++){
            cin>>v[i];
            m[v[i]]++;
        }
        int max = m[v[0]];
        // int idx = v[0];
        for(auto i:m){
            if(i.second>max){
                max = i.second;
                // idx = i.first;
            }
            // max = i.second;
        }
        // m[idx] = 0;
        // if (temp == 0){

        //     cout<<m.size()<<endl;
        //     continue;
        // }
        for(auto i:m){
            v2.push_back(i.second);
        }
        sort(v2.begin(),v2.end());

        for(int i=0;i<v2.size();i++){
            if(k>=v2[i]){
                k = k - v2[i];
                v2[i] = 0;
            }
        }
        // k = temp;
        int count = 0;
        for(int i=0;i<v2.size();i++){
            if(v2[i] != 0) count++;
        }
        
        // for(int i=0;i<v2.size();i++){
        //     cout<<v2[i]<<" ";
        // }cout<<endl;
        if(count == 0){
            cout<<1<<endl;
        }

        else if(m.size() == temp && n == temp ){
            cout<<1<<endl;
        }
        else{
            cout<<(count)<<endl;
        }
        
   
}
}


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

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int>v(n);
        map<int,int>m;
        vector<int>v2(n);
        for(int i=0;i<v.size();i++){
            cin>>v[i];
            m[v[i]]++;
        }
        int max = m[v[0]];
        int idx;
        for(auto i:m){
            if(i.second>max){
                max = i.second;
                idx = i.first;
            }
            // max = i.second;
        }
        m[idx] = 0;
        for(auto i:m){
            v2.push_back(i.second);
        }
        sort(v2.begin(),v2.end());

        for(int i=0;i<v2.size();i++){
            if(k>0){
                k = k - v2[i];
                v2[i] = 0;
            }
        }
    
        int count = 0;
        for(int i=0;i<v2.size();i++){
            if(v2[i] != 0) count++;
        }
        if(n==1){
            cout<<1<<endl;
        }
        else{
            cout<<count+1<<endl;
        }
        // cout<<(count+1)<<endl;
   
}
}


Answer: 1
Problem: 2057B - Gorilla and the Exam
Language: c++23 

Code 1:
#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n,k;
    cin>>n>>k;
    vector<int> nums(n,0);
    for(int i=0;i<n;i++){
        cin>>nums[i];
    }
    sort(nums.begin(),nums.end());
    vector<int>sum={1};
    for(int i=1;i<n;i++){
        if(nums[i]==nums[i-1]){
            sum.back()++;
        }
        else{
            sum.push_back(1);
        }
    }
    sort(sum.begin(),sum.end());
    for(int i=0;i<sum.size();i++){
        if(k<sum[i]){
            cout<<sum.size()-i<<"\n";
            return;
        }
        k-=sum[i];
    }
    cout<<1<<"\n";
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){      
        solve();
    }
    return 0;
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
auto compare = [](const pair<int, int>& a, const pair<int, int>& b) {
    return a.second < b.second;
    };
void solve(){
    int n,k;
    cin>>n>>k;
    unordered_map<int,int>umap;
    for(int i=0;i<n;i++){
        int num;
        cin>>num;
        umap[num]++;
    }   
    vector<pair<int,int>>pq;
    for(auto const&pairs:umap){
        pq.push_back(make_pair(pairs.first,pairs.second));
    }
    sort(pq.begin(),pq.end(),compare);
    int i=0;
    while(k>0&&pq.size()>0){
        auto top = pq[i];
        if(k>=top.second){
            k-=top.second;
            pq[i++].second=0;
        }
        else{
            break;
        }
    }
    int account=0;
    for(int j=0;j<pq.size();j++){
        if(pq[j].second!=0){
            account++;
        }
    }
    if(account!=0)
        cout<<account<<"\n";
    else
        cout<<1<<"\n";
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){      
        solve();
    }
    return 0;
}

Answer: 1
Problem: 2057B - Gorilla and the Exam
Language: c++23 

Code 1:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int t;
  cin>>t;
  while(t--){
    int n;
    int k;
    cin>>n>>k;
    vector<long long>a(n);
    int i=0;
    map<long long,int>mp;
    for(i=0;i<n;i++){
      cin>>a[i];
      mp[a[i]]++;
    }
    if(n==k)
    cout<<"1"<<endl;
    else{
   vector<int>f;
   int c=0;
   f.reserve(n);
   for(auto p:mp){
     f.push_back(p.second);
     c++;
   }
   sort(f.begin(),f.end());
   int s=0;
   int co=0;
   for(i=0;i<c;i++){
    if((s+f[i])<=k){
      s=s+f[i];
      co++;
    }
     else if((s+f[i])>k){
       break;
     }
   }
   cout<<(c-co)<<endl;
    }
  }
  return 0;
}

Code 2:
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int t;
  cin>>t;
  while(t--){
    int n;
    int k;
    cin>>n>>k;
    vector<long long>a(n);
    int i=0;
    unordered_map<long long,int>mp;
    for(i=0;i<n;i++){
      cin>>a[i];
      mp[a[i]]++;
    }
    int c=0;
    for(auto p:mp){
      c++;
    }
    if(c<k)
    cout<<"0"<<endl;
    else
    cout<<(c-k)<<endl;
  }
  return 0;
}

Answer: 1
Problem: 2057B - Gorilla and the Exam
Language: c++17 

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

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    long long t;
    cin >> t; 

    while (t--)
    {
        long long n, k;
        cin >> n >> k; 
        long long arr[n];

        
        for (long long i = 0; i < n; i++) {
            cin >> arr[i];
        }

        
        map<long long, long long> freq;
        for (long long num : arr) {
            freq[num]++;
        }
        
        vector<pair<long,long>>p;
        for(auto it : freq)
        {
               p.push_back({it.second,it.first});
        }
        sort(p.begin(),p.end());
        
        long long count = p.size();
        for(auto it:p)
        {
               if(k>=it.first)
               {
                     k-=it.first;
                     count--;
               }
               else
               {
                     break;
               }
        }
        if(count<=0)
        cout<<1<<endl;
        else
        cout << count << endl;
        
    }

    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    long long t;
    cin >> t; 

    while (t--)
    {
        long long n, k;
        cin >> n >> k; 
        long long arr[n];

        
        for (long long i = 0; i < n; i++) {
            cin >> arr[i];
        }

        
        unordered_map<long long, long long> freq;
        for (long long num : arr) {
            freq[num]++;
        }

        
        priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> pq;
        for (const auto& entry : freq) {
            pq.push({entry.second, entry.first});
        }

        
        long long count = 0;
        while (k > 0 && !pq.empty()) {
            pair<long long, long long> top = pq.top();
            pq.pop();

            long long temp = min(top.first, k);
            k -= temp;

            if (temp < top.first) {
                pq.push({top.first - temp, top.second});
                break;
            }
        }
        if(pq.empty())
        count = 1;
        
        while (!pq.empty()) {
            pq.pop();
            count++;
        }

        cout << count << endl;
    }

    return 0;
}


Answer: 1