ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define v(a) vector<(a)>
#define rep(a, i) for(int i = 0; i < (a); i++)
#define read(a, n) for(int i = 0; i < (n); i++){ cin >> a[i];}
#define pB pop_back
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define int long long
#define pi pair<int, int>
const int mod = 998244353;
#define bismillah ios::sync_with_stdio(0); cin.tie(0);
const int INF = 1e18;


void solve(){
    string aa, bb, c; cin >> aa >> bb >> c;

    vector<vector<int>> dp(2005, vector<int>(2005, 1e9));
    dp[0][0] = 0;
    int x = aa.size();
    int y = bb.size();
    for(int a = 0; a <= x; a++){
        for(int b = 0; b <= y; b++){  
            int z = a + b;

            if(z > c.size()) continue;

            if(a < x && aa[a] == c[z]){
                dp[a+1][b] = min(dp[a+1][b], dp[a][b]);
            }

            

            if(b < y && bb[b] == c[z]){
                dp[a][b+1] = min(dp[a][b+1], dp[a][b]);
            }

            if(a < x) dp[a+1][b] = min(dp[a+1][b], dp[a][b]+1);
            if(b < y) dp[a][b+1] = min(dp[a][b+1], dp[a][b]+1);
            
        }
    }

    cout << dp[x][y];
    
}

signed main() {
    bismillah
    int t = 1;
    cin >> t;
    while(t--) {
        solve();
        cout << "\n";
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define v(a) vector<(a)>
#define rep(a, i) for(int i = 0; i < (a); i++)
#define read(a, n) for(int i = 0; i < (n); i++){ cin >> a[i];}
#define pB pop_back
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define int long long
#define pi pair<int, int>
const int mod = 998244353;
#define bismillah ios::sync_with_stdio(0); cin.tie(0);
const int INF = 1e18;
 
 
void solve(){
    string aa, bb, c; cin >> aa >> bb >> c;
    
    int x = aa.size();
    int y = bb.size();
    vector<vector<int>> dp(x+1, vector<int>(y+1, 1e9));
    dp[0][0] = 0;
    for(int a = 0; a <= x; a++){
        for(int b = 0; b <= y; b++){  
            int z = a + b;
 
            if(z > c.size()) continue;
 
            if(a > 0 && aa[a-1] == c[z-1]){
                dp[a][b] = min(dp[a][b], dp[a-1][b]);
            }
 
            
 
            if(b > 0 && bb[b-1] == c[z-1]){
                dp[a][b] = min(dp[a][b], dp[a][b-1]);
            }
 
            if(a > 0) dp[a][b] = min(dp[a][b], dp[a-1][b] + 1);
            if(b > 0) dp[a][b] = min(dp[a][b], dp[a][b-1]+1);
            
        }
    }
 
    cout << dp[x][y];
    
}
 
signed main() {
    bismillah
    int t = 1;
    cin >> t;
    while(t--) {
        solve();
        cout << "\n";
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define v(a) vector<(a)>
#define rep(a, i) for(int i = 0; i < (a); i++)
#define read(a, n) for(int i = 0; i < (n); i++){ cin >> a[i];}
#define pB pop_back
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define int long long
#define pi pair<int, int>
const int mod = 998244353;
#define bismillah ios::sync_with_stdio(0); cin.tie(0);
const int INF = 1e18;


void solve(){
    string aa, bb, c; cin >> aa >> bb >> c;

    vector<vector<int>> dp(2005, vector<int>(2005, 1e9));
    dp[0][0] = 0;
    int x = aa.size();
    int y = bb.size();
    for(int a = 0; a <= x; a++){
        for(int b = 0; b <= y; b++){  
            int z = a + b;

            if(a > 0 && aa[a-1] == c[z-1]){
                dp[a][b] = min(dp[a][b], dp[a-1][b]);
            }

            

            if(b > 0 && bb[b-1] == c[z-1]){
                dp[a][b] = min(dp[a][b], dp[a][b-1]);
            }

            if(a > 0) dp[a][b] = min(dp[a][b], dp[a-1][b] + 1);
            if(b > 0) dp[a][b] = min(dp[a][b], dp[a][b-1]+1);
            
        }
    }

    cout << dp[x][y];
    
}

signed main() {
    bismillah
    int t = 1;
    cin >> t;
    while(t--) {
        solve();
        cout << "\n";
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define v(a) vector<(a)>
#define rep(a, i) for(int i = 0; i < (a); i++)
#define read(a, n) for(int i = 0; i < (n); i++){ cin >> a[i];}
#define pB pop_back
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define int long long
#define pi pair<int, int>
const int mod = 998244353;
#define bismillah ios::sync_with_stdio(0); cin.tie(0);
const int INF = 1e18;


void solve(){
    string aa, bb, c; cin >> aa >> bb >> c;

    vector<vector<int>> dp(2005, vector<int>(2005, 1e9));
    dp[0][0] = 0;
    int x = aa.size();
    int y = bb.size();
    for(int a = 0; a <= x; a++){
        for(int b = 0; b <= y; b++){  
            int z = a + b;

            if(z > c.size()) continue;

            if(a > 0 && aa[a-1] == c[z-1]){
                dp[a][b] = min(dp[a][b], dp[a-1][b]);
            }

            

            if(b > 0 && bb[b-1] == c[z-1]){
                dp[a][b] = min(dp[a][b], dp[a][b-1]);
            }

            if(a > 0) dp[a][b] = min(dp[a][b], dp[a-1][b] + 1);
            if(b > 0) dp[a][b] = min(dp[a][b], dp[a][b-1]+1);
            
        }
    }

    cout << dp[x][y];
    
}

signed main() {
    bismillah
    int t = 1;
    cin >> t;
    while(t--) {
        solve();
        cout << "\n";
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define v(a) vector<(a)>
#define rep(a, i) for(int i = 0; i < (a); i++)
#define read(a, n) for(int i = 0; i < (n); i++){ cin >> a[i];}
#define pB pop_back
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define int long long
#define pi pair<int, int>
const int mod = 998244353;
#define bismillah ios::sync_with_stdio(0); cin.tie(0);
const int INF = 1e18;


void solve(){
    string aa, bb, c; cin >> aa >> bb >> c;

    vector<vector<int>> dp(2005, vector<int>(2005, 1e9));
    dp[0][0] = 0;
    int x = aa.size();
    int y = bb.size();
    for(int a = 0; a <= x; a++){
        for(int b = 0; b <= y; b++){  
            int z = a + b;

            if(z > c.size()) continue;

            if(a > 0 && aa[a-1] == c[z-1]){
                dp[a][b] = min(dp[a][b], dp[a-1][b]);
            }

            

            if(b > 0 && bb[b-1] == c[z-1]){
                dp[a][b] = min(dp[a][b], dp[a][b-1]);
            }

            if(a > 0) dp[a][b] = min(dp[a][b], dp[a-1][b] + 1);
            if(b > 0) dp[a][b] = min(dp[a][b], dp[a][b-1]+1);
            
        }
    }

    cout << dp[x][y];
    
}

signed main() {
    bismillah
    int t = 1;
    cin >> t;
    while(t--) {
        solve();
        cout << "\n";
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define v(a) vector<(a)>
#define rep(a, i) for(int i = 0; i < (a); i++)
#define read(a, n) for(int i = 0; i < (n); i++){ cin >> a[i];}
#define pB pop_back
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define int long long
#define pi pair<int, int>
const int mod = 998244353;
#define bismillah ios::sync_with_stdio(0); cin.tie(0);
const int INF = 1e18;


void solve(){
    string aa, bb, c; cin >> aa >> bb >> c;

    vector<vector<int>> dp(2005, vector<int>(2005, 1e9));
    dp[0][0] = 0;
    int x = aa.size();
    int y = bb.size();
    for(int a = 0; a <= x; a++){
        for(int b = 0; b <= y; b++){  
            int z = a + b;

            if(z > c.size()) continue;

            if(a < x && aa[a] == c[z]){
                dp[a+1][b] = min(dp[a+1][b], dp[a][b]);
            }

            

            if(b < y && bb[b] == c[z]){
                dp[a][b+1] = min(dp[a][b+1], dp[a][b]);
            }

            if(a < x) dp[a+1][b] = min(dp[a+1][b], dp[a][b]+1);
            if(b < y) dp[a][b+1] = min(dp[a][b+1], dp[a][b]+1);
            
        }
    }

    cout << dp[x][y];
    
}

signed main() {
    bismillah
    int t = 1;
    cin >> t;
    while(t--) {
        solve();
        cout << "\n";
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <string>

using namespace std;



int main() {

    int t;

    cin >> t;

    while (t--) {

        string s;

        cin >> s;

        int n = s.size();

        int sum=0;

        int twos=0;

        int threes=0;

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

            sum =(sum+ (s[i] - '0'))%9;

            if((s[i] - '0')%9==2){

                twos++;

            }

            if((s[i] - '0')%9==3){

                threes++;

            }

        }

        if(sum%9==0){

            cout<<"YES"<<endl;

            continue;

        }

        else if(sum%9==1){

            if(twos>0 && threes>1){

                cout<<"YES"<<endl;

                continue;

            }

        }    

        else if(sum%9==2){

            if(twos>=8 || (twos>=5 && threes>=1) || (twos>=2 && threes>=2)){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==3){

            if(threes>0 || twos>=3){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==4){

            if(twos>=7 || (twos>=4 && threes>=1) || (twos>=1 && threes>=2)){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==5){

            if(twos>=2){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==6){

            if(twos>=6 || (twos>=3 && threes>=1) || (twos>=0 && threes>=2)){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==7){

            if(twos>0){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==8){

            if(twos>=5 || (twos>=2 && threes>=1)){

                cout<<"YES"<<endl;

                continue;

            }

        }

        cout<<"NO"<<endl;   

    }

}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 8):
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set =tree<T, null_type, less_equal<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define int long long
#define pb push_back
#define in insert

#define sortva(ans) sort(ans.begin(), ans.end());
#define sortvd(ans) sort(ans.rbegin(), ans.rend());

const int MOD = 1e9+7;

void printVec(vector<int> &ans){
    for(int i=0;i<ans.size();++i) cout<<ans[i]<<" ";
    cout<<"\n";
}
 

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

    vector<int> v(n+1);
    vector<int> pos(n+1);
    for(int i = 1; i <= n ; i++){
        cin >> v[i];
        pos[v[i]] = i;
    }

    vector<int> check(n+1);
    vector<int> posele(n+1);
    for(int i = 1; i <= n ; i++){
        check[i] = i;
        posele[i] = i;
    }

    vector<pair<int,int>> ans;
    for(int i = 1; i <= n; i++){
        if(pos[v[i]] <= check[v[i]]){
            vector<pair<int,int>> temp;
            for(int j = check[v[i]] + 1; j <= n; j++){
                ans.pb({posele[j], v[i]});
                temp.pb({posele[j], v[i]});
            }
            reverse(temp.begin(), temp.end());
            for(auto x : temp){
                ans.pb({x.second, x.first});
            }
            for(int j = check[v[i]] - 1; j >= i; j--){
                ans.pb({v[i], posele[j]});
                check[j] += 1;
            }
            check[v[i]] = i;
            for(int j = 1; j <= n; j++){
                posele[check[j]] = j;
            }
        }
    }

    cout << ans.size() << "\n";
    for(auto x : ans){
        cout << x.first << " " << x.second << "\n";
    }

    
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){solve();}
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 14):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl "\n"
#define float long double
#define int long long int
#define ll long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define PI 3.141592653589793238462643383279
#define all(v) (v).begin(), (v).end() 
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
void solve(){
    string a,b,c;
    cin>>a>>b>>c;
    int n=a.size(),m=b.size(),sz=c.size();
    vector<vector<int>> dp(sz+1,vector<int> (n+1,1e9));
    dp[0][0]=0;
    for(int i=1;i<=sz;i++){
        for(int j=0;j<=n;j++){
            if(i-j<=m)dp[i][j]=min(dp[i-1][j]+!(b[i-j-1]==c[i-1]),dp[i][j]);
            if(j>0)dp[i][j]=min(dp[i-1][j-1]+!(a[j-1]==c[i-1]),dp[i][j]);
        }
    }
    cout<<dp[sz][n]<<endl;
}
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl "\n"
#define float long double
#define int long long int
#define ll long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define PI 3.141592653589793238462643383279
#define all(v) (v).begin(), (v).end() 
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
void solve(){
    string a,b,c;
    cin>>a>>b>>c;
    int n=a.size(),m=b.size(),sz=c.size();
    vector<vector<int>> dp(sz+1,vector<int> (n+1,1e9));
    dp[0][0]=0;
    for(int i=1;i<=sz;i++){
        for(int j=0;j<=n;j++){
            if(i-j<=m && i-j>0)dp[i][j]=min(dp[i-1][j]+!(b[i-j-1]==c[i-1]),dp[i][j]);
            if(j>0)dp[i][j]=min(dp[i-1][j-1]+!(a[j-1]==c[i-1]),dp[i][j]);
        }
    }
    cout<<dp[sz][n]<<endl;
}
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl "\n"
#define float long double
#define int long long int
#define ll long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define PI 3.141592653589793238462643383279
#define all(v) (v).begin(), (v).end() 
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
void solve(){
    string a,b,c;
    cin>>a>>b>>c;
    int n=a.size(),m=b.size(),sz=c.size();
    vector<vector<int>> dp(sz+1,vector<int> (n+1,1e9));
    dp[0][0]=0;
    for(int i=1;i<=sz;i++){
        for(int j=0;j<=n;j++){
            if(i-j<=m)dp[i][j]=min(dp[i-1][j]+!(b[i-j-1]==c[i-1]),dp[i][j]);
            dp[i][j]=min(dp[i-1][j-1]+!(a[j-1]==c[i-1]),dp[i][j]);
        }
    }
    cout<<dp[sz][n]<<endl;
}
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl "\n"
#define float long double
#define int long long int
#define ll long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define PI 3.141592653589793238462643383279
#define all(v) (v).begin(), (v).end() 
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
void solve(){
    string a,b,c;
    cin>>a>>b>>c;
    int n=a.size(),m=b.size(),sz=c.size();
    vector<vector<int>> dp(sz+1,vector<int> (n+1,1e9));
    dp[0][0]=0;
    for(int i=1;i<=sz;i++){
        for(int j=0;j<=n;j++){
            if(i-j<=m)dp[i][j]=min(dp[i-1][j]+!(b[i-j-1]==c[i-1]),dp[i][j]);
            dp[i][j]=min(dp[i-1][j-1]+!(a[j-1]==c[i-1]),dp[i][j]);
        }
    }
    cout<<dp[sz][n]<<endl;
}
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Submission (verdict: Runtime error on test 14):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl "\n"
#define float long double
#define int long long int
#define ll long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define PI 3.141592653589793238462643383279
#define all(v) (v).begin(), (v).end() 
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
void solve(){
    string a,b,c;
    cin>>a>>b>>c;
    int n=a.size(),m=b.size(),sz=c.size();
    vector<vector<int>> dp(sz+1,vector<int> (n+1,1e9));
    dp[0][0]=0;
    for(int i=1;i<=sz;i++){
        for(int j=0;j<=n;j++){
            if(i-j<=m)dp[i][j]=min(dp[i-1][j]+!(b[i-j-1]==c[i-1]),dp[i][j]);
            if(j>0)dp[i][j]=min(dp[i-1][j-1]+!(a[j-1]==c[i-1]),dp[i][j]);
        }
    }
    cout<<dp[sz][n]<<endl;
}
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 14):
#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;
        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;
}

Submission (verdict: Accepted):
#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;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 14):
#include<bits/stdc++.h>
using namespace std;


#define md : 1000000007;



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

    vector<int> vec(n);

    unordered_map<int,int> mp;

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

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

Submission (verdict: Wrong answer on test 2):
#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;
}