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

Code 1:
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

template <typename K, typename V>
std::vector<std::pair<K, V>> sortMapByValue(const std::map<K, V> &mp) {
    std::vector<std::pair<K, V>> vec(mp.begin(), mp.end());

    std::sort(vec.begin(), vec.end(), [](const auto &a, const auto &b) {
        return a.second < b.second; // Sort in ascending order by value
    });

    return vec;
}

int main()
{
    int t;
    cin >> t;
    while(t--){
        int n, k;
        cin >> n >> k;
        vector<int> v;
        for(int i = 0; i < n; i++){
            int x;
            cin >> x;
            v.push_back(x);
        }


    
    std::map<int, int> values;

    for(int i=0; i<n; i++){
        values[v[i]]++;
    }
    int res=0;
   auto v2=sortMapByValue(values);
    for(int i=0; i<v2.size(); i++){
        k=k-v2[i].second;
        if(k<=0){
            
            break;
        }
        res++;
    
     
    }
    cout<<res+1<<endl;
    }
}


Code 2:
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

template <typename K, typename V>
std::vector<std::pair<K, V>> sortMapByValue(const std::map<K, V> &mp) {
    std::vector<std::pair<K, V>> vec(mp.begin(), mp.end());

    std::sort(vec.begin(), vec.end(), [](const auto &a, const auto &b) {
        return a.second < b.second; // Sort in ascending order by value
    });

    return vec;
}

int main()
{
    int t;
    cin >> t;
    while(t--){
        int n, k;
        cin >> n >> k;
        vector<int> v;
        for(int i = 0; i < n; i++){
            int x;
            cin >> x;
            v.push_back(x);
        }


    
    std::map<int, int> values;

    for(int i=0; i<n; i++){
        values[v[i]]++;
    }
    int res=0;
   auto v2=sortMapByValue(values);
    for(int i=0; i<v2.size(); i++){

        if(k>=v2[i].second){
            k-=v2[i].second;
            v2[i].second=0;
            
        }
          
    
     
    }
    for(int i=0; i<v2.size(); i++){
        if(v2[i].second>0){
            res++;
        }
    }
    if(res==0){
        res=1;
    }


    cout<<res<<endl;
    }
}


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

Code 1:
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;

int main() {
#ifdef LOCAL
  freopen("b.in", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int n, k;
    cin >> n >> k;
    unordered_map<int, int> mp;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      mp[x]++;
    }
    vector<int> a;
    for(auto e : mp) { a.push_back(e.second); }
    sort(a.begin(), a.end());
    int ans = a.size();
    a.pop_back();
    for (auto e : a) {
      if (k >= e) {
        k -= e;
        ans --;
      } else break;
    }
    cout << ans << endl;
  }
  return 0;
}

Code 2:
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;

int main() {
#ifdef LOCAL
  freopen("b.in", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) { cin >> a[i]; }
    sort(a.begin(), a.end());
    vector<int> b;
    int cnt = 1;
    for (int i = 1; i < n; i++) {
      if (a[i] == a[i - 1]) { cnt ++; }
      else {
        b.push_back(cnt);
        cnt = 1;
      }
    }
    b.push_back(cnt);
    sort(b.begin(), b.end());

    int ans = b.size();
    b.pop_back();
    for (auto e : b) {
      if (k >= e) {
        k -= e;
        ans --;
      } else break;
    }
    cout << ans << endl;
  }
  return 0;
}

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

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


int return1(long long int a , long long int b){
    if((a<0 && b<0 )|| (a>0 && b>0)){
        return 1;
    }
    if(a==0 && b==0){
        return 0;
    }
    return -1;
}

int main(){

    unsigned int testcase;
    std::cin>>testcase;


    while(testcase--){
        int a , b;
        std::unordered_map<long long int , long long int>arr;
        std::cin>>a>>b;
        for(int i=0;i<a;i++){
            long long int y;
            std::cin>>y;
            arr[y]++;
        }

        std::vector<int>arr2;
        for(auto n:arr){
            arr2.push_back(n.second);
        }

        std::sort(arr2.begin() , arr2.end());
        int counter=1;
        int i;
        for(i=0;i<arr2.size()-1; i++){
            if(b<arr2[i]){
                break;
            }
            b-=arr2[i];
        }
        std::cout<<counter+arr2.size()-1-i<<"\n";
}    return 0;
}

Code 2:
#include <bits/stdc++.h>

using i64 = long long;

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

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t = 1;
    std::cin >> t;

    while (t--) {
        solve();
    }
}


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

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


#define md : 1000000007;



void solve(){
    int n,k;
    cin >> n >> k;

    vector<int> vec(n);

    unordered_map<int,int> mp;
    vector<int>count = {1};

    for(int i=0; i<n; i++){
        cin >> vec[i];
        mp[vec[i]]++;
    }

    sort(vec.begin(),vec.end());
    for(int i=1; i<vec.size(); i++){
        if(vec[i] == vec[i-1]){
            count.back()++;
        }else{
            count.push_back(1);
        }
    }

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

    int i;
    for( i=0; i<count.size(); ){
        if(count[i] > k) break;
        i++;
        k-=count[i];
        if(k == 0) break;
    }

    int res = count.size()-i != 0 ? count.size()-i : 1;

    cout << res <<  endl;
    // priority_queue<pair<int,int>, vector<pair<int,int>>, greater<> > st;

    // for(auto x: mp){
    //     st.push({x.second, x.first});
    // }

    // int count = 0;

    // while(!st.empty() && k){
    //     int temp = (st.top()).first;
    //     if(temp > k) k = 0;
    //     else{
    //         k-=temp;
    //         st.pop();
    //     }
    // }

    // st.size() > 0 ? cout <<  st.size() : cout << 1 ;
    // cout << endl;


}




int main(){

    int t;
    cin>>t;


    while(t--)
        solve();

    return 0;
}

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


#define md : 1000000007;



void solve(){
    int n,k;
    cin >> n >> k;

    vector<int> vec(n);
    vector<int>count = {1};

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

    sort(vec.begin(),vec.end());
    for(int i=1; i<vec.size(); i++){
        if(vec[i] == vec[i-1]){
            count.back()++;
        }else{
            count.push_back(1);
        }
    }

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

    int i;
    int m = count.size();
    for( i=0; i<m-1; ){
        if(count[i] > k) break;
        k-=count[i++];
    }

    cout << m-i <<  endl;
    // priority_queue<pair<int,int>, vector<pair<int,int>>, greater<> > st;

    // for(auto x: mp){
    //     st.push({x.second, x.first});
    // }

    // int count = 0;

    // while(!st.empty() && k){
    //     int temp = (st.top()).first;
    //     if(temp > k) k = 0;
    //     else{
    //         k-=temp;
    //         st.pop();
    //     }
    // }

    // st.size() > 0 ? cout <<  st.size() : cout << 1 ;
    // cout << endl;


}




int main(){

    int t;
    cin>>t;


    while(t--)
        solve();

    return 0;
}

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

Code 1:
#include <bits/stdc++.h>
using namespace std;
map<int,int>mp;
int main()
{
	int t;
	cin>>t;
	while(t--){
		long long n,m;
		cin>>n>>m;
		mp.clear();
		for(int i=1;i<=n;i++){
			int a;
			cin>>a;
			mp[a]++;
		}
		multiset<int>st;
		for(auto b:mp)
			st.insert(b.second);
		int ans=st.size();
		for(int a:st){
			if(m>=a)ans--,m-=a;
		}cout<<max(1,ans)<<'\n';
	}
}

Code 2:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int T; // Number of test cases
    cin >> T;

    while (T--) {
        int n, m;
        cin >> n >> m;

        vector<long long> a(n); // Input array
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }

        // Sort the array to group identical values together
        sort(a.begin(), a.end());

        // Calculate frequencies of each distinct element
        vector<long long> freq;
        long long count = 1; // Frequency counter
        for (int i = 1; i < n; i++) {
            if (a[i] == a[i - 1]) {
                count++; // Increment frequency if the same value continues
            } else {
                freq.push_back(count); // Store frequency
                count = 1;             // Reset frequency counter
            }
        }
        freq.push_back(count); // Add the last frequency

        // Sort the frequencies to handle smallest groups first
        sort(freq.begin(), freq.end());

        // Minimize the number of distinct groups
        int distinct_groups = freq.size(); // Start with all groups
        for (int i = 0; i < freq.size(); i++) {
            if (m >= freq[i]) {
                m -= freq[i];     // Use changes to eliminate this group
                distinct_groups--; // Reduce the count of distinct groups
            } else {
                break; // No more changes can be made
            }
        }

        // Output the result for this test case
        cout << distinct_groups << endl;
    }

    return 0;
}


Answer: 1
Problem: 2057B - Gorilla and the Exam
Language: other

Code 1:
#include <stdio.h>
#include <stdlib.h>

int sort (const void* a, const void* b) {
    return (*(int*)a - *(int*)b);
}

int main() {
    int x;
    scanf("%d", &x);
    
    while (x--) {
        int n, k;
        scanf("%d %d", &n, &k);
        
        int* a = (int*)malloc(n * sizeof(int));
        int max = 0;
        for (int i=0; i<n; i++) {
            scanf(" %d", &a[i]);
            
            if (a[i] > max) {
                max = a[i];
            }
        }
        
        int* count = (int*)calloc(max + 1, sizeof(int));
        for (int i=0; i<n; i++) {
            count[a[i]]++;
        }
        
        int b = 0;
        int* c = (int*)malloc(n * sizeof(int));
        for (int i=1; i<=max; i++) {
            if (count[i] > 0) {
                c[b++] = count[i];
            }
        }
        
        qsort(c, b, sizeof(int), sort);
        
        int ans = b;
        for (int i=0; i<b; i++) {
            if (c[i] <= k) {
                k = k - c[i];
                ans--;
            }
            else {
                break;
            }
        }
        
        if (ans == 0) {
            ans = 1;
        }
        printf("%d \n", ans);
    }
    
    return 0;
}

Code 2:
#include <stdio.h>
#include <stdlib.h>

int sort (const void* a, const void* b) {
    return (*(int*)a - *(int*)b);
}

int main() {
    int x;
    scanf("%d", &x);
    
    while (x--) {
        int n, k;
        scanf("%d %d", &n, &k);
        
        int* a = (int*)malloc(n * sizeof(int));
        int max = 0;
        for (int i=0; i<n; i++) {
            scanf(" %d", &a[i]);
        }
        
        qsort(a, n, sizeof(int), sort);
        
        int* count = (int*)malloc(n * sizeof(int));
        int c = 1;
        int m = 0;
        for (int i=0; i<n-1; i++) {
            if (a[i] == a[i+1]) {
                c++;
            }
            else {
                count[m++] = c;
                c = 1;
            }
        }
        
        count[m++] = c;
        
        qsort(count, m, sizeof(int), sort);
        
        int ans = m;
        for (int i=0; i<m; i++) {
            if (count[i] <= k) {
                k = k - count[i];
                ans--;
            }
            else {
                break;
            }
        }
        
        if (ans == 0) {
            ans = 1;
        }
        printf("%d \n", ans);
        
        free(a);
        free(count);
    }
    
    return 0;
}

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

Code 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;
}

Code 2:
#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;
}

Answer: 2
Problem: 2057B - Gorilla and the Exam
Language: python

Code 1:
for q in range(int(input())):
    n,k=list(map(int,input().split(' ')))
    a=list(map(int,input().split(' ')))
    b=set(a)
    d={}
    for i in b:
        d[i]=0
    for i in a:
        d[i]+=1
    l=[]
    for i in d:
        l.append(d[i])
    pre=0
    ans=len(l)
    l.sort()
    for i in range(len(l)):
        if(pre+l[i]<=k):
            pre+=l[i]
            ans-=1
    print(max(ans,1))

Code 2:
for q in range(int(input())):
    n,k=list(map(int,input().split(' ')))
    a=list(map(int,input().split(' ')))
    d={}
    for i in range(n):
        if(a[i] not in d):
            d[a[i]]=1
        else:
            d[a[i]]+=1
    l=[]
    for i in d:
        l.append(d[i])
    pre=0
    ans=len(l)
    l.sort()
    for i in range(len(l)):
        if(pre+l[i]<=k):
            pre+=l[i]
            ans-=1
    print(max(ans,1))




Answer: 1
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--){

    int n;
    int k;
    cin >> n >> k;

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

    }

    vector<int>ans;

    for(auto it:mpp){
      ans.push_back(it.second);
    }

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

    int s= ans.size();
    int mini=s;
    for(int i=0;i<s;i++){
      k-=ans[i];
      if(k<=0){
        break;
      }
      mini--;
    }

    cout << mini << endl;
  }
}


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

int main(){
  int t;
  cin >>t;
  while(t--){

    int n;
    int k;
    cin >> n >> k;

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

    }

    vector<int>ans;

    for(auto it:mpp){
      ans.push_back(it.second);
    }

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

    int s= ans.size();
    int mini=s;
    for(int i=0;i<s;i++){
      k-=ans[i];
      if(k<0){
        break;
      }
      mini--;
    }

    cout << max(mini,1) << endl;
  }
}


Answer: 2
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--) {
        int n,k;
        cin >> n >> k;
        long int a[n];
        map <long int,int> freq;
        //set <long int> s;
        for(int i=0;i<n;i++) {
            cin >> a[i];
            //s.insert(a[i]);
            freq[a[i]]++;
        }
        if(k>=n-1) {cout << "1\n";}
        else {
            vector <pair<long int,int>> f;
            for (const auto& elem : freq) {
                f.push_back(elem); 
            }
            sort(f.begin(), f.end(), 
            [](const pair<long int, int>& a, const pair<long int, int>& b) {
                return a.second > b.second;
            });
            for(int i=0;i<k;i++) {
                int last=f.size();
                f[last-1].second--;
                if(f[last-1].second==0) {f.pop_back();}
            }
            cout << f.size() << "\n";
        }
    }
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin >> t;
    while(t--) {
        int n,k;
        cin >> n >> k;
        long int a[n];
        map <long int,int> freq;
        set <long int> s;
        for(int i=0;i<n;i++) {
            cin >> a[i];
            s.insert(a[i]);
            freq[a[i]]++;
        }
        vector <pair<long int,int>> f;
        for (const auto& elem : freq) {
            f.push_back(elem); 
        }
        sort(f.begin(), f.end(), 
        [](const pair<long int, int>& a, const pair<long int, int>& b) {
            return a.second < b.second;  // Compare the second element of each pair
        });
        int index=0;
        for(int i=0;i<k;i++) {
            f[index].second--;
            if(f[index].second==0) {
                s.erase(f[index].first);
                index++;
            }
            if(index==n-1) {break;}
        }
        cout << s.size() << "\n";
    }
}

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

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define yes cout<<"YES\n"
#define no  cout<<"NO\n"

void solve(){
    
    int n,k;
    cin>>n>>k;
    map<int,int>m;
    vector<int>v;
    
    for (int i=1; i<=n; ++i) {
        int x;
        cin>>x;
        m[x]++;
    }
    
    for(auto it:m)
        v.push_back(it.second);
    sort(v.begin(),v.end());
    int s=(int)v.size();
    
    for (int i=0; i<v.size(); ++i) {
        if(k>=v[i]){
            k-=v[i];
            s--;
        }
        else break;
    }
    s?cout<<s<<endl:cout<<1<<endl;
}

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


Code 2:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define yes cout<<"YES\n"
#define no  cout<<"NO\n"

void solve(){
    
    int n,k;
    cin>>n>>k;
    map<int,int>m;
    vector<int>v;
    
    for (int i=1; i<=n; ++i) {
        int x;
        cin>>x;
        m[x]++;
    }
    
    for(auto it:m)
        v.push_back(it.second);
    
    int s=(int)v.size();
    
    for (int i=0; i<v.size(); ++i) {
        if(k>=v[i]){
            k-=v[i];
            s--;
        }
        else break;
    }
    s?cout<<s<<endl:cout<<1<<endl;
}

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

Answer: 1
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> v(n);

        unordered_map<int,int> mp;
        int x;
        for(int i=0;i<n;i++){
            cin>>x;
            mp[x]++;
        }

        vector<int> freq;

        for(auto p:mp){
            freq.push_back(p.second);
        }

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

        int ans = 1;

        int i=0;
        for(int i=0;i<freq.size()-1;i++){
            if(k>=freq[i]){
                k-=freq[i];
            }else{
                ans++;
            }
        }
        
        cout<<ans<<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> mp;
        int x;
        for(int i=0;i<n;i++){
            cin>>x;
            mp[x]++;
        }

        vector<int> freq;

        for(auto p:mp){
            freq.push_back(p.second);
        }

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

        int ans = 1;

        int i=0;
        for(int i=0;i<freq.size()-1;i++){
            if(k>=freq[i]){
                k-=freq[i];
            }else{
                ans++;
            }
        }
        
        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; // Number of test cases
    cin >> T;

    while (T--) {
        long long n, m;
        cin >> n >> m;

        vector<long long> a(n); // Array to store input numbers
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }

        // Sort the array to group identical elements
        sort(a.begin(), a.end());

        vector<long long> freq; // Frequency array for unique elements
        long long count = 1; // Initialize frequency counter

        // Calculate frequencies
        for (int i = 1; i < n; i++) {
            if (a[i] != a[i - 1]) {
                freq.push_back(count); // Store frequency
                count = 1;             // Reset counter
            } else {
                count++;
            }
        }
        freq.push_back(count); // Add the last frequency

        // Sort the frequency array
        sort(freq.begin(), freq.end());

        // Start with all distinct groups
        long long distinct_groups = freq.size();

        // Use available changes to reduce distinct groups
        for (auto f : freq) {
            if (m >= f) {
                m -= f;               // Use changes for this group
                distinct_groups--;    // Reduce group count
            } else {
                break; // No more changes can be used
            }
        }

        // Output the result
        cout << distinct_groups << '\n';
    }

    return 0;
}


Code 2:
#include <bits/stdc++.h>
using namespace std;
map<int,int>mp;
int main()
{
	int t;
	cin>>t;
	while(t--){
		long long n,m;
		cin>>n>>m;
		mp.clear();
		for(int i=1;i<=n;i++){
			int a;
			cin>>a;
			mp[a]++;
		}
		multiset<int>st;
		for(auto b:mp)
			st.insert(b.second);
		int ans=st.size();
		for(int a:st){
			if(m>=a)ans--,m-=a;
		}cout<<max(1,ans)<<'\n';
	}
}

Answer: 2