ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Compilation error):
#include<bit/stdc++.h>
using namespace std;

void solve()
{
    string a,b,c;
    cin>>a>>b>>c;
    int n=a.size();
    int m=b.size();
    vector<vector<int>>dp(n+1,vector<int>(m+1,0));
    
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i and j)
            {
                char ch1=a[i];
                char ch2=b[j];
                dp[i][j]=min(dp[i-1][j]+ch1!=c[i+j-1],dp[i][j-1]+ch2!=c[i+j-1]);
            }
            else if(i)
            {
                char ch=a[i-1];
                dp[i][j]=dp[i-1][j]+(ch!=c[i+j-1]);
            }
            else if(j)
            {
                char ch=b[j];
                dp[i][j]=dp[i][j-1]+(ch!=c[i+j-1]);
            }
            else
            {
                dp[i][j]=0;
            }
        }
    }
    return dp[n][m];
}

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;

void solve()
{
    string a,b,c;
    cin>>a>>b>>c;
    int n=a.size();
    int m=b.size();
    vector<vector<int>>dp(n+1,vector<int>(m+1,0));
    
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i and j)
            {
                char ch1=a[i];
                char ch2=b[j];
                dp[i][j]=min(dp[i-1][j]+ch1!=c[i+j-1],dp[i][j-1]+ch2!=c[i+j-1]);
            }
            else if(i)
            {
                char ch=a[i-1];
                dp[i][j]=dp[i-1][j]+(ch!=c[i+j-1]);
            }
            else if(j)
            {
                char ch=b[j];
                dp[i][j]=dp[i][j-1]+(ch!=c[i+j-1]);
            }
            else
            {
                dp[i][j]=0;
            }
        }
    }
    return dp[n][m];
}

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

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

void solve()
{
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.size();
    int m = b.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));

    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            if (i and j)
            {
                char ch1 = a[i - 1];
                char ch2 = b[j - 1];
                dp[i][j] = min(dp[i - 1][j] + static_cast<int>(ch1 != c[i + j - 1]), dp[i][j - 1] + static_cast<int>(ch2 != c[i + j - 1]));
            }
            else if (i)
            {
                char ch = a[i - 1];
                dp[i][j] = dp[i - 1][j] + (ch != c[i + j - 1]);
            }
            else if (j)
            {
                char ch = b[j - 1];
                dp[i][j] = dp[i][j - 1] + (ch != c[i + j - 1]);
            }
            else
            {
                dp[i][j] = 0;
            }
        }
    }
    
    cout << dp[n][m] << endl;
}

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Compilation error):
#include<bit/stdc++.h>
using namespace std;

void solve()
{
    string a,b,c;
    cin>>a>>b>>c;
    int n=a.size();
    int m=b.size();
    vector<vector<int>>dp(n+1,vector<int>(m+1,0));
    
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i and j)
            {
                char ch1=a[i];
                char ch2=b[j];
                dp[i][j]=min(dp[i-1][j]+ch1!=c[i+j-1],dp[i][j-1]+ch2!=c[i+j-1]);
            }
            else if(i)
            {
                char ch=a[i-1];
                dp[i][j]=dp[i-1][j]+(ch!=c[i+j-1]);
            }
            else if(j)
            {
                char ch=b[j];
                dp[i][j]=dp[i][j-1]+(ch!=c[i+j-1]);
            }
            else
            {
                dp[i][j]=0;
            }
        }
    }
    return dp[n][m];
}

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

Submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;

void solve()
{
    string a,b,c;
    cin>>a>>b>>c;
    int n=a.size();
    int m=b.size();
    vector<vector<int>>dp(n+1,vector<int>(m+1,0));
    
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i and j)
            {
                char ch1=a[i];
                char ch2=b[j];
                dp[i][j]=min(dp[i-1][j]+ch1!=c[i+j-1],dp[i][j-1]+ch2!=c[i+j-1]);
            }
            else if(i)
            {
                char ch=a[i-1];
                dp[i][j]=dp[i-1][j]+(ch!=c[i+j-1]);
            }
            else if(j)
            {
                char ch=b[j];
                dp[i][j]=dp[i][j-1]+(ch!=c[i+j-1]);
            }
            else
            {
                dp[i][j]=0;
            }
        }
    }
    return dp[n][m];
}

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
//जय सिया राम
// Author : **Aditya Raj**

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
#define ll  long long int
#define ld long double
#define endl '\n'
#define loopi(n) for(int i=0;i<n;i++)


void solve(){
    int l,r;
    cin>>l>>r;
    int a,b,c;
    int ans = 0;
    a = 0;
    b = 0;
    c = 0;
    for(int i=30;i>=0;i--){
        int b1 = 0;
        int b2 = 0;

        if(l&(1ll << i)){
            b1 = 1;
        }
        if(r&(1ll << i)){
            b2 = 1;
        }
        if(b1==b2){
            ans += b1*(1ll << i);
        }
        else{
            a = ans + (1ll<<i);
            b = a - 1;
            break;
        }
    }

    for(int i = l;i<r;i++){
        if(i != a && i != b){
            c = i;
            break;
        }
    }

    cout<<a<<" "<<b<<" "<<c<<" "<<endl;


}



signed main() {    
    //fast input output
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int t = 1;
    cin>>t;

    while(t--){

        solve();

    }
    return 0;
}




Submission (verdict: Wrong answer on test 1):
//जय सिया राम
// Author : **Aditya Raj**

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
#define ll  long long int
#define ld long double
#define endl '\n'
#define loopi(n) for(int i=0;i<n;i++)


void solve(){
    int l,r;
    cin>>l>>r;
    int a,b,c;
    int ans = 0;
    a = 0;
    b = 0;
    c = 1;
    for(int i=30;i>=0;i--){
        int b1 = 0;
        int b2 = 0;

        if(l&(1ll << i)){
            b1 = 1;
        }
        if(r&(1ll << i)){
            b2 = 1;
        }
        if(b1==b2){
            ans += b1*(1ll << i);
        }
        else{
            a = ans + (1ll<<i);
            b = a - 1;
            break;
        }
    }

    for(int i = l;i<r;i++){
        if(i != a && i != b){
            c = i;
            break;
        }
    }

    cout<<a<<" "<<b<<" "<<c<<" "<<endl;


}



signed main() {    
    //fast input output
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int t = 1;
    cin>>t;

    while(t--){

        solve();

    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
//जय सिया राम
// Author : **Aditya Raj**

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
#define ll  long long int
#define ld long double
#define endl '\n'
#define loopi(n) for(int i=0;i<n;i++)


void solve(){
    int l,r;
    cin>>l>>r;
    int a,b,c;
    int ans = 0;
    a = 0;
    b = 0;
    c = 1;
    for(int i=30;i>=0;i--){
        int b1 = 0;
        int b2 = 0;

        if(l&(1ll << i)){
            b1 = 1;
        }
        if(r&(1ll << i)){
            b2 = 1;
        }
        if(b1==b2){
            ans += b1*(1ll << i);
        }
        else{
            a = ans + (1ll<<i);
            b = a - 1;
            break;
        }
    }

    for(int i = l;i<r;i++){
        if(i != a && i != b){
            c = i;
            break;
        }
    }

    cout<<a<<" "<<b<<" "<<c<<" "<<endl;


}



signed main() {    
    //fast input output
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int t = 1;
    cin>>t;

    while(t--){

        solve();

    }
    return 0;
}




Submission (verdict: Accepted):
//जय सिया राम
// Author : **Aditya Raj**

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
#define ll  long long int
#define ld long double
#define endl '\n'
#define loopi(n) for(int i=0;i<n;i++)


void solve(){
    int l,r;
    cin>>l>>r;
    int a,b,c;
    int ans = 0;
    a = 0;
    b = 0;
    c = 0;
    for(int i=30;i>=0;i--){
        int b1 = 0;
        int b2 = 0;

        if(l&(1ll << i)){
            b1 = 1;
        }
        if(r&(1ll << i)){
            b2 = 1;
        }
        if(b1==b2){
            ans += b1*(1ll << i);
        }
        else{
            a = ans + (1ll<<i);
            b = a - 1;
            break;
        }
    }

    for(int i = l;i<=r;i++){
        if(i != a && i != b){
            c = i;
            break;
        }
    }

    cout<<a<<" "<<b<<" "<<c<<" "<<endl;


}



signed main() {    
    //fast input output
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int t = 1;
    cin>>t;

    while(t--){

        solve();

    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
//जय सिया राम
// Author : **Aditya Raj**

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
#define ll  long long int
#define ld long double
#define endl '\n'
#define loopi(n) for(int i=0;i<n;i++)


void solve(){
    int l,r;
    cin>>l>>r;
    int a,b,c;
    int ans = 0;
    a = 0;
    b = 0;
    c = 0;
    for(int i=30;i>=0;i--){
        int b1 = 0;
        int b2 = 0;

        if(l&(1ll << i)){
            b1 = 1;
        }
        if(r&(1ll << i)){
            b2 = 1;
        }
        if(b1==b2){
            ans += b1*(1ll << i);
        }
        else{
            a = ans + (1ll<<i);
            b = a - 1;
            break;
        }
    }

    for(int i = l;i<r;i++){
        if(i != a && i != b){
            c = i;
            break;
        }
    }

    cout<<a<<" "<<b<<" "<<c<<" "<<endl;


}



signed main() {    
    //fast input output
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int t = 1;
    cin>>t;

    while(t--){

        solve();

    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Runtime error on test 1):
#include<iostream>
#include<map>
#include<unordered_map>
#include<vector>

#define ll long long 
#define mp make_pair
#define d double

using namespace std;

void f(vector<ll> &v,ll &n){
   for(ll i = 0;i<n;i++){
       cin>>v[i];
   }
}

int main(){
    ll t;
    cin>>t;

    while(t--){
       ll n;
       cin>>n;
         
       vector<int> dig(n);
       
       string s;
       cin>>s;
       
       for(ll i=0;i<n;i++){
           dig[i] = s[i]-'0';
       }
       
       for(ll i=1;i<n;i++){
           ll curr = i;
           while(curr>=1 && dig[curr]-1>dig[curr-1]){
               int frwd = dig[curr]-1;
               dig[curr] = dig[curr-1];
               dig[curr-1] = frwd;
               curr--;
           }
       }
       
       for(auto it : dig) cout<<it<<" ";
       cout<<endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<map>
#include<unordered_map>
#include<vector>

#define ll long long 
#define mp make_pair
#define d double

using namespace std;

void f(vector<ll> &v,ll &n){
   for(ll i = 0;i<n;i++){
       cin>>v[i];
   }
}

int main(){
    ll t;
    cin>>t;

    while(t--){
       ll n;
       string s;
       cin>>s;
       n = s.length();
       vector<int> dig(n);
     
       for(ll i=0;i<n;i++){
           dig[i] = s[i]-'0';
       }
       
       for(ll i=1;i<n;i++){
           ll curr = i;
           while(curr>=1 && dig[curr]-1>dig[curr-1]){
               int frwd = dig[curr]-1;
               dig[curr] = dig[curr-1];
               dig[curr-1] = frwd;
               curr--;
           }
       }
       
       for(auto it : dig) cout<<it<<" ";
       cout<<endl;
    }
}

Submission (verdict: Accepted):
#include<iostream>
#include<map>
#include<unordered_map>
#include<vector>
 
#define ll long long 
#define mp make_pair
#define d double
 
using namespace std;
 
void f(vector<ll> &v,ll &n){
   for(ll i = 0;i<n;i++){
       cin>>v[i];
   }
}
 
int main(){
    ll t;
    cin>>t;
 
    while(t--){
       ll n;
       string s;
       cin>>s;
       n = s.length();
       vector<int> dig(n);
     
       for(ll i=0;i<n;i++){
           dig[i] = s[i]-'0';
       }
       
       for(ll i=1;i<n;i++){
           ll curr = i;
           while(curr>=1 && dig[curr]-1>dig[curr-1]){
               int frwd = dig[curr]-1;
               dig[curr] = dig[curr-1];
               dig[curr-1] = frwd;
               curr--;
           }
       }
       
       for(auto it : dig) cout<<it;
       cout<<endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 1):
#include<iostream>
#include<map>
#include<unordered_map>
#include<vector>

#define ll long long 
#define mp make_pair
#define d double

using namespace std;

void f(vector<ll> &v,ll &n){
   for(ll i = 0;i<n;i++){
       cin>>v[i];
   }
}

int main(){
    ll t;
    cin>>t;

    while(t--){
       ll n;
       cin>>n;
         
       vector<int> dig(n);
       
       string s;
       cin>>s;
       
       for(ll i=0;i<n;i++){
           dig[i] = s[i]-'0';
       }
       
       for(ll i=1;i<n;i++){
           ll curr = i;
           while(curr>=1 && dig[curr]-1>dig[curr-1]){
               int frwd = dig[curr]-1;
               dig[curr] = dig[curr-1];
               dig[curr-1] = frwd;
               curr--;
           }
       }
       
       for(auto it : dig) cout<<it<<" ";
       cout<<endl;
    }
}

Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<map>
#include<unordered_map>
#include<vector>

#define ll long long 
#define mp make_pair
#define d double

using namespace std;

void f(vector<ll> &v,ll &n){
   for(ll i = 0;i<n;i++){
       cin>>v[i];
   }
}

int main(){
    ll t;
    cin>>t;

    while(t--){
       ll n;
       string s;
       cin>>s;
       n = s.length();
       vector<int> dig(n);
     
       for(ll i=0;i<n;i++){
           dig[i] = s[i]-'0';
       }
       
       for(ll i=1;i<n;i++){
           ll curr = i;
           while(curr>=1 && dig[curr]-1>dig[curr-1]){
               int frwd = dig[curr]-1;
               dig[curr] = dig[curr-1];
               dig[curr-1] = frwd;
               curr--;
           }
       }
       
       for(auto it : dig) cout<<it<<" ";
       cout<<endl;
    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 16):


#include <bits/stdc++.h>



#define ll long long 

#define mr make_pair



using namespace std;



ll max(ll a, ll b){

    if(a>b) return a;

    return b;

}



ll min(ll a, ll b){

    if(a<b) return a;

    return b;

}



int max(int a,int b){

    if(a>b) return a;

    return b;

}



int min(int a,int b){

    if(a<b) return a;

    return b;

}



void f(vector<ll> &v,ll &n){

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

       cin>>v[i];

   }

}



void sort(vector<ll>& v){

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

}



void sort(vector<int>& v){

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

}



ll solve(string a,string b,string c,ll i1,ll i2,vector<vector<ll>>& dp){

    if(i1==0 && i2==0){

        return 0;

    }

    

    if(dp[i1][i2] != -1){

        return dp[i1][i2];

    }

    

    ll maxi = LONG_MAX;

    

    if(i1>0){

        ll val = solve(a,b,c,i1-1,i2,dp);

        if(a[i1-1] == c[i1+i2-1]){

            maxi = min(maxi,val);

        }

        else if(val != LONG_MAX){

            maxi = min(maxi,1+val);

        }

    }

    

    if(i2>0){

        ll val = solve(a,b,c,i1,i2-1,dp);

        if(b[i2-1] == c[i1+i2-1]){

            maxi = min(maxi,val);

        }

        else if(val != LONG_MAX){

            maxi = min(maxi,1+val);

        }

    }

    

    return dp[i1][i2] = maxi;

}



int main(){

    ll t;

    cin>>t;

 

    while(t--){

       string a,b,c;

       cin>>a;

       cin>>b;

       cin>>c;

       

       ll n = a.length();

       ll m = b.length();

       

       vector<vector<ll>> dp(n+1,vector<ll>(m+1,-1));

       

       cout<<solve(a,b,c,n,m,dp)<<endl;

    }

    

}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
int main() {
    int cases;
    int n;
    int max;
    int min;
    int one,two,three;
    cin>> cases;
    for(int cas=1; cas<=cases; cas++){
        cin>>min>>max;
        one = pow(2,floor(log2(max)));
        two = one/2;
        three = two-1;
        cout<<one<<" "<<two<<" "<<three<<endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
int main() {
    int cases;
    int n;
    int max;
    int min;
    int one,two,three;
    cin>> cases;
    for(int cas=1; cas<=cases; cas++){
        cin>>min>>max;
        one = pow(2,floor(log2(max)));
        two = one/2;
        three = two-1;
        cout<<one<<" "<<two<<" "<<three<<endl;
    }
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <bit>
using namespace std;
int main() {
    int cases;
    int n;
    int max;
    int min;
    int one,two=0,three=0;
    cin>> cases;
    for(int cas=1; cas<=cases; cas++){
        cin>>min>>max;
        n = 31- __builtin_clz(max^min);
        one = ((1<<(n)) -1); two = one+1; three= one ==min ? max:min;

        cout<<one<<" "<<two<<" "<<three<<endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <bit>
using namespace std;
int main() {
    int cases;
    int n;
    int max;
    int min;
    int one,two=0,three=0;
    cin>> cases;
    for(int cas=1; cas<=cases; cas++){
        cin>>min>>max;
        n = 31- __builtin_clz(max^min);
        one = ((1<<(n)) -1); two = one+1; three= one ==min ? max:min;

        cout<<one<<" "<<two<<" "<<three<<endl;
    }
    return 0;
}


Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <cmath>
#include <bit>
using namespace std;
int main() {
    int cases;
    int n;
    int max;
    int min;
    int one,two=0,three=0;
    cin>> cases;
    for(int cas=1; cas<=cases; cas++){
        cin>>min>>max;
        n = 31- __builtin_clz(max^min);
        one = min|((1<<(n)) -1); two = one+1; three= one ==min ? max:min;

        cout<<one<<" "<<two<<" "<<three<<endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define ll long long
using namespace std;
static bool Cmp(pair<ll,ll>&a,pair<ll,ll>&b){
    return a.second<b.second;
}
int main(){
    int t;
    cin>>t;
    while(t--){
       ll n,k;
       cin>>n>>k;
       vector<ll>a(n);
       map<ll,ll>mp;
       for(auto &i:a){
           cin>>i;
           mp[i]++;
       }
    vector<pair<ll,ll>>v(mp.begin(),mp.end());
    sort(v.begin(),v.end(),Cmp);
    
    
    ll size=v.size();
    ll cnt=0;
    for(int i=0;i<n-1 && k>0;i++){
        if(v[i].second<=k){
            k=k-v[i].second;
            cnt++;
        }
        else{
            break;
        }
    }
    
    cout<<size-cnt<<endl;
    }
    return 0;
}

Submission (verdict: Happy New Year!):
#include<bits/stdc++.h>
#define ll long long
using namespace std;
static bool Cmp(pair<ll,ll>&a,pair<ll,ll>&b){
    return a.second<b.second;
}
int main(){
    int t;
    cin>>t;
    while(t--){
       ll n,k;
       cin>>n>>k;
       vector<ll>a(n);
       map<ll,ll>mp;
       for(auto &i:a){
           cin>>i;
           mp[i]++;
       }
       
     
        vector<pair<ll,ll>>v(mp.begin(),mp.end());
        sort(v.begin(),v.end(),Cmp);
        
        
        ll size=v.size();
        ll cnt=0;
        for(int i=0;i<size-1 && k>0;i++){
            if(v[i].second<=k){
                k=k-v[i].second;
                cnt++;
            }
            else{
                break;
            }
        }
        
           cout<<size-cnt<<endl;
        }
           
        
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Happy New Year!):
#include<bits/stdc++.h>
#define ll long long
using namespace std;
static bool Cmp(pair<ll,ll>&a,pair<ll,ll>&b){
    return a.second<b.second;
}
int main(){
    int t;
    cin>>t;
    while(t--){
       ll n,k;
       cin>>n>>k;
       vector<ll>a(n);
       map<ll,ll>mp;
       for(auto &i:a){
           cin>>i;
           mp[i]++;
       }
       
     
        vector<pair<ll,ll>>v(mp.begin(),mp.end());
        sort(v.begin(),v.end(),Cmp);
        
        
        ll size=v.size();
        ll cnt=0;
        for(int i=0;i<size-1 && k>0;i++){
            if(v[i].second<=k){
                k=k-v[i].second;
                cnt++;
            }
            else{
                break;
            }
        }
        
           cout<<size-cnt<<endl;
        }
           
        
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define ll long long
#define pi pair<int,int>
using namespace std;
static bool Cmp(pair<ll,ll>&a,pair<ll,ll>&b){
    return a.second<b.second;
}
int main(){
    int t;
    cin>>t;
    while(t--){
       ll n,k;
       cin>>n>>k;
       vector<ll>a(n);
       map<ll,ll>mp;
       for(auto &i:a){
           cin>>i;
           mp[i]++;
       }
       
     
        vector<pair<ll,ll>>v(mp.begin(),mp.end());
        sort(v.begin(),v.end(),Cmp);
        
        
        ll size=v.size();
        ll cnt=0;
        for(int i=0;i<size-1 && k>0;i++){
            if(v[i].second<=k){
                k=k-v[i].second;
                cnt++;
            }
            else{
                break;
            }
        }
        
           cout<<size-cnt<<endl;
        }
           
        
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define ll long long
using namespace std;
static bool Cmp(pair<ll,ll>&a,pair<ll,ll>&b){
    return a.second<b.second;
}
int main(){
    int t;
    cin>>t;
    while(t--){
       ll n,k;
       cin>>n>>k;
       vector<ll>a(n);
       map<ll,ll>mp;
       for(auto &i:a){
           cin>>i;
           mp[i]++;
       }
    vector<pair<ll,ll>>v(mp.begin(),mp.end());
    sort(v.begin(),v.end(),Cmp);
    
    
    ll size=v.size();
    ll cnt=0;
    for(int i=0;i<n-1 && k>0;i++){
        if(v[i].second<=k){
            k=k-v[i].second;
            cnt++;
        }
        else{
            break;
        }
    }
    
    cout<<size-cnt<<endl;
    }
    return 0;
}