ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: c++17 

Solution 1 (runtime: 1389 ms):
#include<bits/stdc++.h>
using namespace std;

//JAY SHREE KRISHNA
// --------------------------------------
#define ll long long
#define ld long double
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define pp pop_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
// -------------------------------------

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t=1;		
    while(t--){
        int n;
        cin>>n;

        vector<int> nums(n,0);
        for(int i=0;i<n;i++) cin>>nums[i];

        vector<int> vis(n+1,0);
        vector<pair<int,int>> ans;
        for(int i=0;i<n;i++){
            vis[nums[i]]++;
            for(int j=nums[i];j<=n;j++){
                if(!vis[j]){
                    ans.push_back({j,nums[i]});
                }
            }
            for(int j=n;j>=1;j--){
                if(!vis[j]){
                    ans.push_back({nums[i],j});
                }
            }
        }

        cout<<ans.size()<<endl;
        for(auto it:ans){
            cout<<it.first<<" "<<it.second<<endl;
        }
    }
    return 0;
}

Solution 2 (runtime: 1233 ms):
#include<bits/stdc++.h>
using namespace std;

int main() {
    int n; cin >> n;
    
    vector<int> aPos(n+1);
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++) {aPos[i] = i; a[i] = i;}

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

    vector<pair<int, int>> ans;

    for(int i = n; i > 0; i--) {
        int curPos = aPos[c[i]];
        while(curPos != 1) {
            int temp = aPos[c[i]];
            aPos[c[i]] = aPos[a[curPos - 1]];
            aPos[a[curPos - 1]] = temp;

            temp = a[curPos - 1];
            a[curPos - 1] = a[curPos];
            a[curPos] = temp;

            ans.push_back({a[curPos - 1], a[curPos]});
            curPos--;
        }

        while(curPos != n && cPos[a[curPos + 1]] < cPos[c[i]]) {
            int temp = aPos[c[i]];
            aPos[c[i]] = aPos[a[curPos + 1]];
            aPos[a[curPos +1]] = temp;

            temp = a[curPos + 1];
            a[curPos + 1] = a[curPos];
            a[curPos] = temp;

            ans.push_back({a[curPos], a[curPos + 1]});
            curPos++;
        }
    }
    cout << ans.size() << endl;
    for(auto &[x, y] : ans) {
        cout << x << ' ' << y << endl;
    }
}
Problem: 2052A - Adrenaline Rush
Language: c++17 

Solution 1 (runtime: 249 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
const ll N = 1e5 + 1, M = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    set<int> st;
    for (int i = 0; i < n; i++)
    cin >> a[i], st.insert(i + 1);
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; i++)
    {
        for (int j = a[i] + 1; j <= n; j++)
        {
            if (st.count(j))
            {
                ans.push_back({j, a[i]});
            }
        }
        for (int j = n; j > a[i]; j--)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        for (int j = a[i] - 1; j >= 1; j--)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        st.erase(a[i]);
    }
    cout << (int)ans.size() << "\n";
    for (auto &x : ans)
    cout << x.first << " " << x.second << "\n";
}

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


Solution 2 (runtime: 327 ms):
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n; cin >> n;
    int arr[n];
    int orig[n+2];
    int inds[n];

    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        orig[i] = i+1;
        inds[orig[i]] = i;
    }

    int count = 0;
    vector <int> firsts;
    vector <int> seconds;

    for (int i = 0; i < n-1; i++) {
        int ind = inds[arr[i]];
        //cout << "starting ind: " << ind << "\n";
        while (ind != n-1) {
            //cout << orig[ind] << " " << orig[ind+1] << "\n";
            int a = orig[ind]; int b = orig[ind+1];
            orig[ind+1]=a; orig[ind]=b;
            //cout << orig[ind] << " " << orig[ind+1] << "\n";
            firsts.push_back(orig[ind]);
            inds[orig[ind]] = ind;
            inds[orig[ind+1]] = ind+1;
            seconds.push_back(orig[ind+1]);
            ind++; count++;
            //cout << ind << "\n";
        }
        while (ind != i) {
            //cout << orig[ind-1] << " " << orig[ind] << "\n";
            int a = orig[ind]; int b = orig[ind-1];
            orig[ind-1]=a; orig[ind]=b;
            //cout << orig[ind-1] << " " << orig[ind] << "\n";
            firsts.push_back(orig[ind-1]);
            seconds.push_back(orig[ind]);
            inds[orig[ind]] = ind;
            inds[orig[ind-1]] = ind-1;
            ind--; count++;
            //cout << ind << "\n";
        }
    }

    //cout << "STARTING\n";

    cout << count << "\n";
    for (int i = 0; i < count; i++) {
        cout << firsts[i] << " " << seconds[i] << "\n";
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 109 ms):
#include <bits/stdc++.h>

#define ll long long
#define int long long
#define pb push_back
#define ppb pop_back
#define mp make_pair

using namespace std;

void solve() {
    int l, r;
    cin >> l >> r;

    int ans = 0;
    int a, b, c;
    for (int bit = 30; bit >= 0; bit--) {

        int b1 = 0, b2 = 0;
        if (l & (1 << bit)) b1 = 1;
        if (r & (1 << bit)) b2 = 1;

        if (b1 == b2) 
            ans += b1 * (1 << bit);
        else {

            a = ans + (1 << bit);
            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() {
    int t = 1;
    cin >> t;

    while (t--)
        solve();

    return 0;    
}

Solution 2 (runtime: 124 ms):
#include<bits/stdc++.h>
using namespace std;

void solve()
{
	long long l,r;
	cin>>l>>r;

	long long a=0, b=0, c=0;

	for(long long i=30; i>=0; i--)
	{
		long long bl=0,br=0;

		if(l & ((long long)pow(2,i)))
		{
			bl=1;
		}

		if(r & ((long long)pow(2,i)))
		{
			br=1;
		}

		if(bl==br)
		{
			a += (bl) * ((long long)pow(2,i));
            b += (bl) * ((long long)pow(2,i));
		}
		else
		{
		  //  cout<<a<<" "<<b<<endl;
		    
		    for(long long j=i-1;j>=0;j--)
		    {
		        a += ((long long)pow(2,j));
		    }
		    b+=((long long)pow(2,i));
		    
		    break;
		}

	}
	c=l;
	if(c==a) c=r;
	
	cout<<a<<" "<<c<<" "<<b<<endl;


}


int main()
{
	long long tstCase;
	cin>>tstCase;
	while(tstCase--) solve();
	return 0;
}
Problem: 2050C - Uninteresting Number
Language: c++17 

Solution 1 (runtime: 61 ms):
// 1

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

const long long MOD = 1e9+7;
const int N = 1e6 + 10;
#define MIN_IN(A) *(std::min_element(A.begin(), A.end()))
#define MAX_IN(A) *(std::max_element(A.begin(), A.end()))
#define MAX_AT(A) (std::max_element(A.begin(), A.end()) - A.begin())
#define MIN_AT(A) (std::min_element(A.begin(), A.end()) - A.begin())
#define pb push_back
#define SORT(A) std::sort(A.begin(), A.end())
#define RSORT(A) std::sort(A.rbegin(), A.rend())
#define REVERSE(A) std::reverse(A.begin(), A.end())
#define VECIN(A,n) for(int i = 0; i < n; i++) { cin >> A[i]; }
#define VECIN1(A,n) for(int i = 1; i <=n; i++) { cin >> A[i]; }
#define VECOUT(A) for(int i = 0; i < A.size(); i++) { cout << A[i] << " "; } cout << endl;
#define COUT(A) cout << A << endl;
#define ll long long
#define ull unsigned long long
#define D double
#define UI unsigned int
#define Y1 cout<<"yes"<<endl
#define N1 cout<<"no"<<endl


ll power(ll x, ll y) {
    ll res = 1;
    x = x % MOD; 
    while (y > 0) {  
        if (y & 1) 
            res = (res * x) % MOD;  
        y = y >> 1;
        x = (x * x) % MOD;   
    } 
    return res; 
}

ll __gcd(ll a, ll b) { 
    if (b == 0) 
    { 
        return a; 
    } 
    return __gcd(b, a % b); 
}

ll __LCM(ll a, ll b){
    return (a * b) / __gcd(a, b);
}

ll xorn(int n){
    if(n % 4 == 0) return n;
    if(n % 4 == 3) return 0;
    if(n % 4 == 1) return 1;
    return n ^ 1;
}

bool ispalindrome(string s){
    int si = s.size();
    for(int i = 0; i < si / 2; i++){
        if(s[i] != s[si - 1 - i]) return false;
    }
    return true;
}

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

    ll no2=0,no3=0,sum=0;

    for(auto e:n)
    {
        if(e=='2') no2++;
        else if(e=='3') no3++;
        sum+=int(e)-48;
    }

    // cout<<sum<<" "<<no2<<" "<<no3<<endl;

    for(int i=0;i<=no2;i++)
    {
        for(int j=0;j<=no3;j++)
        {
            
            if((sum+2*i+6*j)%9==0) 
            {
                COUT("yes");
                return;
            }
        }
    }
    COUT("NO");

}

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


Solution 2 (runtime: 77 ms):
#include<bits/stdc++.h>



using namespace std;



#define ll long long



void solve(){

    string s;

    cin>>s;

    int c2 = 0, c3 = 0, sum = 0;

    for(int i=0; i<s.size(); i++){

        if(s[i] == '2')c2++;

        else if(s[i] == '3')c3++;

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

    }

    function<bool()> check = [&]() -> bool {

        for(int i=0; i<=min(c2, 9); i++){

            for(int j=0; j<=min(c3, 9); j++){

                if((sum+2*i+6*j) % 9 == 0)return true;

            }

        }

        return false;

    };

    cout<<(check() ? "YES" : "NO")<<"\n";

}



int main(){

    int t;

    cin>>t;

    while(t--){

        solve();

    }

}
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 171 ms):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int t,n,l,r;
ll a, center[200100], al[200100], ar[200100];
int ncenter, nal, nar;
int main(){
	cin>>t;
	while(t--){
		cin>>n>>l>>r;
		ncenter= 1;
		nal = 1;
		nar = 1;
		for(int i=1;i<=n;i++){
			if(i<l){
				cin>>al[nal];
				nal++;
			}
			else if(i>r){
				cin>>ar[nar];
				nar++;
			}
			else{
				cin>>center[ncenter];
				ncenter++;
			}
		}
		sort(al+1, al+nal);
		sort(ar+1, ar+nar);
		sort(center+1, center+ncenter);
		for(int i=1;i<ncenter;i++)center[i]+=center[i-1];
		for(int i=1;i<nal;i++)al[i]+=al[i-1];
		for(int i=1;i<nar;i++)ar[i]+=ar[i-1];
		ll best = center[ncenter-1];
		nal = min(nal, ncenter);
		nar = min(nar, ncenter);
		ncenter--;
		nal--;
		nar--;
		for(int i=0;i<=nal;i++)best = min(best, al[i]+center[ncenter-i]);
		for(int i=0;i<=nar;i++)best = min(best, ar[i]+center[ncenter-i]);
		cout<<best<<endl;
	}
}

Solution 2 (runtime: 202 ms):
#include <bits/stdc++.h>
#include <string>
#include <stack>
#include <list>
#include <string>
#include <queue>
#include <limits.h>
#include <random>
#include <cmath>
#define ll long long

using namespace std;

// cout consecutive occuring element in vector
// vector<int> cnt = {1};
// for(int i=1; i<n; i++){
// 	if (a[i] == a[i-1]){
// 		cnt.back()++;
// 	} else {
// 		cnt.emplace_back(1);
// 	}
// }

void solve()
{
    int n, l, r;
    cin >> n >> l >> r;
    vector<ll> a(n);
    for(ll i=0; i<n; i++){
    	cin >> a[i];
    }
    sort(a.begin() + (l - 1), a.begin() + r);
    sort(a.begin(), a.begin() + (l - 1));
    sort(a.begin() + r, a.end());
    ll range_sum = accumulate(a.begin() + (l - 1), a.begin() + r, 0LL);

   	ll i=0;
   	ll j=r-1;
   	ll k=r;
  
   	ll left_sum=range_sum;
   	while(j >= l-1 && i < l-1){
   		if (a[j] > a[i]){
   			left_sum=left_sum - a[j] + a[i];
	   		j--;
	   		i++;	
   		}else{
   			i++;
   		}
   	}

   	j=r-1;
   	ll right_sum=range_sum;
   	while(j >= l-1 && k < n){
   		if (a[j] > a[k]){
   			right_sum=right_sum - a[j] + a[k];
	   		j--;
	   		k++;	
   		}else{
   			k++;
   		}
   	}

   	if(left_sum > right_sum){
   		cout << right_sum <<endl;
   	}else{
   		cout << left_sum << endl;
   	}

    
}

int main(){
	int tc;
	cin >> tc;
	while (tc--){
		solve();
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: c++17 

Solution 1 (runtime: 640 ms):
/*
CF2061D
30.1.25.
*/

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

#define _line << "\n"
#define _space << " " <<
#define ll long long


int main(){

    /*ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);*/

    int t; cin >> t;

    while (t--){
        priority_queue<int> a,b;
        int n,m; cin >> n >> m;
        for (int i=0; i<n; i++){
            int x; cin >> x;
            a.push(x);
        }
        for (int j=0; j<m; j++){
            int x; cin >> x;
            b.push(x);
        }

        if (m>n){
            cout << "no" _line; continue;
        }

        int z=1;
        while (!a.empty() || !b.empty()){
            if (a.empty() || b.empty() || b.size()>a.size()) {
                z=0;
                cout << "no" _line; break;
            }
            if (a.top()==b.top()){
                a.pop(); b.pop();
            }
            else {
                int x=b.top(); b.pop();
                //cout << x _space b.size() _line;
                if (x==1){
                    z=0;
                    cout << "no" _line; break;
                }
                if (x%2){
                    b.push(x/2);
                    b.push(x/2+1);
                }
                else {
                    b.push(x/2);
                    b.push(x/2);
                }
            }
        }

        if (z) cout << "yes" _line;

    }

}


Solution 2 (runtime: 828 ms):
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;

int n, m;

void solve(){
	map<int, int, greater<int>> a, b;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		a[x]++;
	}
	for(int i = 0; i < m; i++){
		int x;
		cin >> x;
		b[x]++;
	}
	int op = 0;
	while(op < (n-m)){
		if(a.empty() && b.empty()){
			cout << "Yes\n";
			return;
		}
		if(a.begin()->first > b.begin()->first){
			cout << "No\n";
			return;
		}
		else if(a.begin()->first == b.begin()->first){
			int *freqA = &a.begin()->second;
			int *freqB = &b.begin()->second;
			int mini = min(*freqA, *freqB);
			*freqA -= mini;
			*freqB -= mini;
			if(*freqA == 0){
				a.erase(a.begin());
			}
			if(*freqB == 0){
				b.erase(b.begin());
			}
		}
		else{
			int elem = b.begin()->first;
			int freq = b.begin()->second;
			int x = elem/2;
			int y = (elem+1)/2;
			b.erase(b.begin());
			b[x] += freq;
			b[y] += freq;
			op++;
		}
		// cout << "b elems are : \n";
		// for(auto [x, y] : b){
		// 	cout << x << " " << y << '\n';
		// }
		// cout << "b elems end\n";
	}

	if(a.size() != b.size()){
		cout << "No\n";
		return;
	}
	else{
		for(auto [x, y] : a){
			if(b[x] != y){
				cout << "No\n";
				return;
			}
		}
	}
	cout << "Yes\n";
}
 
int main(){
	int t = 1;
	cin >> t;
	
	while(t--){
		solve();
	}
 
	return 0;
}
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 109 ms):
#include <cstdio>

#include <cctype>

#include <cstring>

#include <algorithm>

using namespace std;



#define x first

#define y second

#define db double

#define pb push_back

#define int long long

#define max(a,b) (((a) > (b)) ? (a) : (b))

#define min(a,b) (((a) < (b)) ? (a) : (b))



const int MAXN = 1e5 + 5;

const int inf = 2147483627;

const int mod = 998244353;



template <typename T> inline void read (T &x) {

	x = 0; T f = 1; char ch = getchar ();

	while (!isdigit (ch)) { if (ch == '-') f = -1; ch = getchar (); }

	while (isdigit (ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar ();

	x *= f;

}



template <typename T, typename... Arp> inline void read (T &x, Arp &...arp) {

	read(x), read(arp...);

}





int t;

int n, l, r, a[MAXN], b[MAXN];



signed main () {

//	freopen (".in", "r", stdin);

//	freopen (".out", "w", stdout);

	read (t);

	for (; t; --t) {

		read (n, l, r);

		for (int i = 1; i <= n; ++i) 

			read (a[i]), b[i] = a[i];

		int ans = 0, sum = 0;

		for (int i = l; i <= r; ++i) ans += a[i];

		sort (a + 1, a + r + 1), sum = 0;

		for (int i = 1; i <= r - l + 1; ++i) sum += a[i];

		for (int i = 1; i <= n; ++i) a[i] = b[i];

		ans = min (ans, sum);

		sort (a + l, a + n + 1), sum = 0;

		for (int i = 1; i <= r - l + 1; ++i) sum += a[l + i - 1];

		for (int i = 1; i <= n; ++i) a[i] = b[i];

		ans = min (ans, sum);

		printf ("%lld\n", ans);

	}

	return 0;

}





Solution 2 (runtime: 186 ms):
#include <bits/stdc++.h>

using namespace std;



int main() 

{

    int t;

    cin>>t;

    while(t--){

      int n,l,r;

      cin>>n>>l>>r;

      

      l--;

      

      vector<int>arr(n);

      for(auto &it:arr)cin>>it;

      

      vector<int>left(arr.begin(),arr.begin()+r);

      vector<int>right(arr.begin()+l,arr.end());

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

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

      

      // cout<<"Left=> ";

      // for(auto it:left)cout<<it<<" ";

      // cout<<"Right=> ";

      // for(auto it:right)cout<<it<<" ";

      

      cout<<min(accumulate(left.begin(),left.begin()+r-l,0LL),accumulate(right.begin(),right.begin()+r-l,0LL))<<endl;

      

    }

}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 108 ms):
#include<bits/stdc++.h>
using namespace std;

#define int long long 
int _solve(int i , int j , string &a , string & b , string& c,  vector<vector<int>>&dp)
{
    int n = a.size(); int m = b.size();
    if(i == n && j == m)
    {
        return 0;
    }


    if(dp[i][j]!=-1) return dp[i][j];
    int apick = 1e9;
    int bpick = 1e9;
    if(i <  n)
    {
        int nothit = (a[i] !=c[i+j]);
        apick = nothit + _solve(i+1 , j , a , b , c , dp);
    }
    if(j < m)
    {
        int nothit = (b[j] != c[i+j]);
        bpick = nothit+  _solve(i, j+1 , a , b , c , dp);
    }
    return dp[i][j] = min(apick , bpick);
}
void solve()
{
  string a , b, c;
  cin>>a>>b>>c;
  int n = a.size();
  int m = b.size();
  int k = c.size();
  vector<vector<int>>dp(n+1 , vector<int>(m+1 , -1));

  int ans = _solve(0 , 0 , a , b , c , dp);
  cout<<ans;
}

int32_t main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
        cout<<endl;
    }
    return 0;
}

Solution 2 (runtime: 93 ms):
#include<iostream>
#include<string>
#include<vector> 
#include<climits>
using namespace std;


int util(int i,int j,int k,string& a,string& b,string& c,int cnt,vector<vector<int>>& dp,int bit){
    if(k==c.size()){
        return 0;
    }
    if(dp[i][j]!=-1) return dp[i][j];
    int x=INT_MAX,y=INT_MAX;
    if(i<a.size()){
        if(a[i]==c[k]){
            x=util(i+1,j,k+1,a,b,c,cnt,dp,bit);
        }
        else{
            x=1+util(i+1,j,k+1,a,b,c,cnt+1,dp,bit);
        }
    }

    if(j<b.size()){
        if(b[j]==c[k]){
            y=util(i,j+1,k+1,a,b,c,cnt,dp,bit);
        }
        else{
            y=1+util(i,j+1,k+1,a,b,c,cnt+1,dp,bit);
        }
    }


    return dp[i][j]=min(x,y);
}


int main(){
    int T;
    cin>>T;
    for(int t=0;t<T;t++){
       string a="";
       string b="";
       string c="";
       cin>>a;
       cin>>b;
       cin>>c;
       vector<vector<int>> dp(c.size(),vector<int>(b.size()+1,-1));
       int res=util(0,0,0,a,b,c,0,dp,0);
       cout<<res<<endl;
       
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 62 ms):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
using lli = long long;
lli mod = 1e9 + 7;
#define int lli

void solve(){
    int l,r;
    cin>>l>>r;
    int ltemp = l;
    int rtemp = r;

    int ans = -1;
    int i=0;
    while(l || r){
        if((l&1)!=(r&1)){
            ans = max(ans, i);
        }
        l=l>>1;
        r=r>>1;
        i++;
    }

    //cout<<ans<<endl;

    int num1 = 1<<ans;
    for(int i=30; i>ans; i--){
        if((rtemp>>i)&1){
            num1|=(1<<i);
        }
    }
    int num2 = num1-1;
    

    if(num1<rtemp){
        cout<<num2<<" "<<num1<<" "<<rtemp<<endl;
    }else{
        cout<<num2<<" "<<num1<<" "<<ltemp<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

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

Solution 2 (runtime: 93 ms):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define mi map<int, int>
#define umi unordered_map<int, int>
#define si set<int>
#define ms multiset<int>
#define usi unordered_set<int>
#define lb lower_bound
#define ub upper_bound
template <class T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;
template <class T>
using max_pq = priority_queue<T>;
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define prDouble(x) cout << fixed << setprecision(6) << x
void if_Solution_Hack_karne_aya_hai_next_sem_fail_hoga()
{
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    for (int i = 30; i >= 0; i--)
    {
        if ((l & (1 << i)) == (r & (1 << i)))
        {
            a |= l & (1 << i);
            b |= l & (1 << i);
            c |= l & (1 << i);
        }
        else
        {
            a |= (1 << i);
            b |= (1 << i) - 1;

            for (int j = l; j <= r; j++)
            {
                if (j != a && j != b)
                {
                    c = j;
                    break;
                }
            }
            break;
        }
    }
    cout << a << " " << b << " " << c << endl;
}
signed main()
{
    fast_io;
    int t = 1;
    cin >> t;
    while (t--)
    {
        if_Solution_Hack_karne_aya_hai_next_sem_fail_hoga();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Solution 1 (runtime: 233 ms):
/*B. Gorilla and the Exam*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5+10;
void solve(){
    int n,k;cin >> n >> k;
    map<int,int> mp1;
    for(int i = 0; i < n; i++) {
        int x;cin >> x;
        mp1[x]++;
    }
    vector<int> vc;
    for(auto t : mp1){
        vc.push_back(t.second);   
    }
    sort(vc.begin(),vc.end());
    int size = mp1.size();
    for(int i = 0; i < vc.size(); i++){
        if(k >= vc[i]){
            k -= vc[i];
            size--;
        }
        else break;
    }
    cout << max(1,size) << "\n";
}
int main(){
    int t = 1;cin >> t;
    while(t--){
        solve();
    }
}

Solution 2 (runtime: 78 ms):
#include <bits/stdc++.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long int ll;
typedef  long double ld;
 
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007


    ll n,k;
ll a[100005];

vll vals;
int main() {
    ios :: sync_with_stdio(false); cin.tie(0);
    bool take_t = true;

    ll t;

 
    //rep(i,1,2300) cout<<i << " " << pre[i] << '\n';
    
   if(take_t) cin>>t;
    else t = 1;
    rep(i,1,t) {
        cin>>n>>k;
        rep(i,1,n) {
            cin>>a[i];
        }
        sort(a+1,a+n+1);
        vals.clear();
        rep(i,1,n) {
            ll st = i;
            while(st <= n && a[st] == a[i]) st++;
            st--;
            vals.push_back(st-i+1);
            i=st;
        }
        
        sort(vals.begin(), vals.end());
        
        ll ans = vals.size();
        if(ans > 1) {
            ll ps = 0,tot=0;
            while(ps < vals.size()) {
                if(ps == vals.size()- 1) break;
                tot += vals[ps];
                if(tot > k) break;
                ps++;
                ans--;
            }
        }
        cout<<ans<<'\n';
    }
    
}