ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: c++17 

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

using namespace std;

const int N = 2e5+10, mod = 1e9+7;

#define int long long

#define Inf 0x3f3f3f3f

typedef pair<int, int> PII;

int gcd(int a, int b)

{

    if (b == 0)

        return a;

    return gcd(b, a % b);

}

int lcm(int a, int b)

{

    return a / gcd(a, b) * b;

}







void solve()

{ 

 

 int n; 

 cin >> n;

 vector<int> a(n + 1);

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

 {

   cin >> a[i];

 }

 int f = 1;

 if(a[1] > a[2])

 {

   f = 0;

 }

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

 {

   if(a[i] <= a[i + 1 ])

   {

     int x = min(a[i],a[i + 1]);

     a[i] = 0;

     a[i + 1] -= x;

   }

   else if(a[i + 1] < a[i] ){

     int x = min(a[i - 1],a[i]);

     a[i] -= x;

     a[i - 1] -= x;

     if(a[i + 1] < a[i])

     {

      f= 0;

     }



   }

  }

 if(f) cout << "YES\n";

 else cout << "NO\n"; 



}

signed main()

{ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t; cin >> t;

    while(t--)

    {

      solve();

    }

}

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

using namespace std;



int main() {

    int t;

    cin >> t;

    while (t--) {

        int n;

        cin >> n;

        int a[n];

        vector<vector<int>> v(n);   

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

            cin >> a[i];

        }

        if (n > 1 && a[0] > a[1]) {

            cout << "NO" << endl;

            continue;

        }

        bool b = false;

        int c = 0;

        v[0].push_back(a[0]);

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

            if (a[i - 1] <= a[i] && b == false) {

                v[c].push_back(a[i]);

                b = true;

            }

            else if (b == true) {

                if (a[i] >= a[i - 1])

                    v[c].push_back(a[i]);

                else {

                    b = false;

                    c++;

                    v[c].push_back(a[i]);

                }

            }

            else {

                c++;

                v[c].push_back(a[i]);

            }

        }

        int sum = 0;

        bool poss = true;



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

            sum = 0;

            for (int j = 0; j < v[i].size(); j++) {

                if (j % 2 == 0)

                    sum += v[i][j];

                else

                    sum -= v[i][j];

            }

            sum=pow(-1,v[i].size()+1)*sum;

        

            if (!v[i + 1].empty() && sum <= v[i + 1][0]) {

                poss = true;

                v[i + 1][0] = v[i + 1][0] - sum;

            }

            else {

                poss = false;

                break;

            }

        }

        cout << (poss ? "YES" : "NO") << endl;

    }

    return 0;

}
Problem: 2049C - MEX Cycle
Language: c++17 

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

using namespace std;

#define endl '\n'

typedef long long int ll;

typedef unsigned long long ull;

const ll INF = (1ll << 61);

const ll inf = 1e9;

const ll MOD=1e9 + 7;

const ll M=998244353;

 

 

 

ll gcd(ll a, ll b) {

    return b ? gcd (b, a % b) : a;

}

 

ll lcm(ll a,ll b){

  return ((a*b)/gcd(a,b));

}



ll fact[2000001];



void factfun(){

  fact[0] = fact[1] = 1;

  for(ll i=2;i<=2000000;i++){

    fact[i] = (fact[i-1]%MOD * i%MOD)%MOD;

  }

}



ll expo(ll a,ll n){

   ll ans = 1;

   while(n > 0){

    if(n & 1ll){

      ans = ans * a % MOD;

    }

    a = a * a % MOD;

    n >>= 1;

   }

   return ans;

}



ll fermatNCr(ll a,ll b){

   return ((fact[a]%MOD * expo(fact[b],MOD - 2)%MOD * expo(fact[a - b],MOD - 2)%MOD)%MOD);

}







void solve(){

   ll n,x,y;

   cin>>n>>x>>y;

   x--,y--;

   vector<ll>arr(n);

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

    if(cnt % 2 == 0)arr[i] = 0;

    else arr[i] = 1;

    i = (i+1)%n;

   }



   if(n % 2 == 1 || (x - y)% 2 == 0)arr[x] = 2;



   for(auto x : arr)cout<<x<<" ";

    cout<<endl;

}

 

 

 

 

 

int main(){

 

   ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    /*#ifndef ONLINE_JUDGE

     freopen("input.txt","r",stdin);

     freopen("output.txt","w",stdout);

    #endif*/

    



      ll testcase;

      //testcase = 1;

      cin>>testcase;

     

      while(testcase--){       

        solve();

      }

 

}



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

using namespace std;

typedef long long ll;

bool compareByFirst(const pair<int, int>& a, const pair<int, int>& b) {

    return a.first < b.first;

}

int findMex(int a, int b, int c) {

    set<int> s = {a, b, c}; // Store unique numbers

    

    for (int i = 0; ; i++) { // Check from 0 upwards

        if (s.find(i) == s.end()) return i;

    }

}

void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	

	vector<int>a(n);

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

		a[i]=1;

		}

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

		a[i]=0;

		}

	if(n%2==1){

		a[n-1]=2;

		}

	if((y-x)%2==0){

		if(n%2==1 && y-1==n-2){

			swap(a[n-1],a[n-2]);

			}

		else{

			a[y-1]=2;

			}

		}

	for(auto t:a){

		cout<<t<<" ";

		}

	cout<<endl;

	}



int main(){

	int t;

	cin>>t;

	while(t--){

		solve();

		}

	}
Problem: 2050B - Transfusion
Language: c++17 

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

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

    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);

        long long sum1 = 0, sum2 = 0, ctr1 = 0, ctr2 = 0;

        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            if (i % 2 == 0)
            {
                sum1 += a[i];
                ctr1++;
            }
            else
            {
                sum2 += a[i];
                ctr2++;
            }
        }

        if ((sum1 * ctr2) == (sum2 * ctr1) && (sum1 + sum2) % (ctr1 + ctr2) == 0)
        {
            cout << "YES\n";
        }
        else
        {
            cout << "NO\n";
        }
    }

    return 0;
}


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

using namespace std;



int main() {

    int t;

    cin>>t;

    

    while(t--)

    {

        long long int n;

        cin>>n;

        

        long long int a[n];

        

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

        {

            cin>>a[i];

        }

        

        long long int sum=0;

        

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

        {

            sum+=a[i];

        }

        

  

        

        if(sum%n==0)

        {

            long long int value = sum/n;

            long long int cnt1=0;

            long long int cnt2=0;

            

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

            {

                if(i%2==0)

                {

                   

                   cnt1+=a[i]-value; 

                }

                else

                {

                    cnt2+=a[i]-value;

                }

            }

            

            if(cnt1==0&&cnt2==0)

            {

            cout<<"YES"<<"\n";

            }

            else

            {

                cout<<"NO"<<"\n";

            }

        }

        else

        {

            cout<<"NO"<<"\n";

        }

    }

}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 327 ms):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        vector<int>arr(n);
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        int flag = 1;
        for(int i=0;i<n-1;i++)
        {
            if(arr[i] > arr[i+1])
            {
                flag = 0;
                break;
            }
            else
            {
                int sub = min(arr[i], arr[i+1]);
                int temp = arr[i];
                arr[i] -= temp;
                arr[i+1] -= temp;
            }
        }
        if(flag) cout<<"YES"<<"\n";
        else cout<<"NO"<<"\n";
    }
    return  0;
}

Solution 2 (runtime: 359 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,n) for(ll i=0;i<n;i++)  
#define el endl
// 1 2 3 2 2 2 3 3 3 1 2 3


void solve(){
    ll n;
    cin>>n;
    vector<ll>v(n);
    for(ll &x:v)cin>>x;
        bool t=true;
    for(ll i=1;i<n;i++){
        if(v[i-1]>v[i]){
            t=false;
        }
    }
    if(t){cout<<"YES"<<el;return;}

    // auto maja=[&](ll i){
    //    ll m=min(v[i-1],v[i]);
    //    v[i-1]-=m;
       
    //    v[i]-=m;

    // };
    for(int i=1;i<n;i++){

        ll m=min(v[i-1],v[i]);
       v[i-1]-=m;
       
       v[i]-=m;
    }
     is_sorted(v.begin(),v.end())?cout<<"YES":cout<<"NO";
      cout<<el;
}
int main(){
    ll x;cin>>x;
    while(x--){ solve();}
}
Problem: 2063C - Remove Exactly Two
Language: c++17 

Solution 1 (runtime: 1108 ms):
#include <bits/stdc++.h>
using namespace std;
#define F(i, s, e) for(int i = s; i < e; i++)
#define vi vector<int>
#define pb push_back
#define int int_fast64_t
#define sp <<' '<<
#define pii pair<int, int>
#define fi first
#define se second
#define line cout<<"---------------------------------\n";

const int inf = 1e15;
const int N = 2e5+5;
const int mod = 998244353;

vi adj[N];

void solve() {
    int n;
    cin >> n;
    F(i, 0, n) adj[i].clear();
    F(i, 0, n-1) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    multiset<int, greater<int>> cnt;

    F(i, 0, n) cnt.insert(adj[i].size());

    int ans = 0;
    F(i, 0, n) {
        cnt.erase(cnt.find(adj[i].size()));
        for(int nei : adj[i]) cnt.erase(cnt.find(adj[nei].size())), cnt.insert(adj[nei].size() - 1);
        ans = max(ans, (int) adj[i].size() + *cnt.begin() - 1);
        for(int nei : adj[i]) cnt.erase(cnt.find(adj[nei].size() - 1)), cnt.insert(adj[nei].size());
        cnt.insert(adj[i].size());
    }

    cout << ans << endl;
}

int32_t main() {
    #ifdef Local
        freopen("io.in", "r", stdin);
        freopen("io.out", "w", stdout);
    #endif

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

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

bool comp(pair<int,int> &a, pair<int,int> &b){
    return a.first > b.first;
}

void solve(){
    int n;
    cin>>n;
    
    set<pair<int,int>> edges;
    vector<int> degree(n+1,0);
    
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        
        edges.insert({u,v});
        edges.insert({v,u});
        
        degree[u]++;
        degree[v]++;
    }
    
    // to sort vertices based on their degree..
    vector<pair<int,int>> degree_i;
    
    for(int i=1;i<=n;i++){
        degree_i.push_back({degree[i],i});
    }
    
    sort(degree_i.begin(),degree_i.end(),comp);
    
    
    int ans = 0;
    
    // first case when for every vertex find first non adjcent vertex in sorted array 
    // that will maximize ans, as our degree formual .. 
    for(int i=0;i<n;i++){
        int ind_i = degree_i[i].second;
        int d_i = degree_i[i].first;
        for(int j=i+1;j<n;j++){
            int ind_j = degree_i[j].second;
            int d_j = degree_i[j].first;
            if(edges.find(make_pair(ind_i,ind_j))==edges.end()){
                ans = max(ans,d_i + d_j - 1);
                break;
            }
        }
    }
    
    // for adjcent vertices find max and based on formula ..
    for(auto e:edges){
        int u = e.first;
        int v = e.second;
        
        ans = max(ans, degree[u]+degree[v] - 2);
    }
    
    cout<<ans<<"\n";
}
int main(){
    int t;
    cin>>t;
    
    while(t--){
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: c++17 

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

int main(){
    int test;
    cin >> test;
    for (int i=0; i<test;i++){
        int n;
        vector<int> arr;
        cin >> n;
        for (int j=0; j<n; j++){
            int x;
            cin >> x;
            arr.push_back(x);
        }
        vector<int> sarr = arr;
        sort(sarr.begin(), sarr.end());
        bool possible = true;
        if (arr == sarr){
            cout << "YES" << "\n";
        }
        else {
            if (n<=2) {
                if (arr == sarr) cout << "YES" << "\n";
                else cout << "NO" << "\n";
            }
            else{
            for(int j=0;j<n-2;j++){
                if (arr[j+1]-arr[j] >= 0 && arr[j+1]-arr[j] <= arr[j+2]){
                    arr[j+1] -= arr[j];
                    arr[j] =0;
                }
                else {
                    cout << "NO" << "\n";
                    possible = false;
                    break;
                }
            }
            if (possible == true) cout << "YES" << "\n";    
        }
        }
    }
}

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

using namespace std;

#define int long long

const int inf = LONG_LONG_MAX;

const int mod = 998244353;

const int mxn = 2e5 + 10;



#define read(xx) {\

	xx = 0;\

	long long ff = 1;\

	char cc = getchar();\

	while(cc < '0' || cc > '9'){\

		if(cc == '-') ff = -1;\

		cc = getchar();\

	}\

	while(cc >= '0' && cc <= '9'){\

		xx = (xx<<1) + (xx<<3) + (cc^48);\

		cc = getchar();\

	}\

	xx *= ff;\

}

inline void write(int x);



int t;

int n;

int umy[mxn];



inline void solve(){

	read(n);

	int ans = 0;

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

		read(umy[i]); 

	}

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

		int mid = min(umy[i], umy[i+1]);

		umy[i] -= mid; 

		umy[i+1] -= mid;

	} 

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

//		cout << umy[i] << " ";

//	}

//	cout << endl;

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

		if(umy[i] < umy[i-1]){

			puts("NO");

			return ;

		}

	}

	puts("YES");

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

//		umy[i] = 0;

//	}

}



// 1 9 5 3 5 9 9 3 

// 4 



signed main(){

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

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

	

	cin.tie(0);

	read(t);

	while(t--){

		solve();

	}

	

	return 0;

}





// 1 2 2 2 1 1 1 

 

inline void write(int x){

	if(x < 0) x = -x, putchar('-');

	if(x < 10) putchar(x + '0');

	else write(x/10), putchar((x%10)+'0'); 

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

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

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        // unordered_map<int, int> freq;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }

        sort(a.begin(),a.end());
        int c=1;
        vector<int>cnt;
        
        for(int i=0;i<n-1;i++){
                if(a[i]==a[i+1]){
                    c++;
                }
                else{
                    cnt.push_back(c);
                    c=1;
                }
        }
        cnt.push_back(c);
        if(cnt.size()==1 || k>=n){
            cout<<1<<endl;
            continue;
        }
        sort(cnt.begin(),cnt.end());
        int ans = cnt.size();
        for(int i=0;i<cnt.size();i++){
            if(k>=cnt[i]){
                k=k-cnt[i];
                ans--;
            }
            else{
                // ans=cnt.size()-i;
                break;
            }
        }

        cout<<ans<<endl;
        
    }
    return 0;
}


Solution 2 (runtime: 109 ms):
#include <bits/stdc++.h>
using namespace std;
double eps = 1e-6;
#define ll long long int
#define mod 1000000009
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pb push_back
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl

typedef vector<ll> vec;
typedef vector<pair<int, int>> vecp;
typedef map<ll, ll> mp;

void solve()
{
    int n, k;
    cin >> n >> k;
    vec v(n), v1;
    map<int, int> m;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        m[v[i]]++;
    }
    for (auto it : m)
    {
        v1.push_back(it.second);
    }
    sort(all(v1));

    int i = 0, t = 0, u = v1.size();
    while (k >= v1[i] && i<u)
    {
        k -= v1[i];
        i++;
        t++;
    }
    cout << max(1, u - t) << endl;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: c++17 

Solution 1 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        string n;
        cin >> n;
        int two = 0;
        int three = 0;
        long long sum = 0;
        for (int i = 0; i < n.length(); i++)
        {
            if (n[i] == '2')
                two++;
            else if (n[i] == '3')
                three++;

            sum += (n[i] - '0');
            // for optimation
            sum = sum % 9;
        }
        if (sum % 9 == 0)
        {
            cout << "YES" << endl;
        }
        else
        {
            bool f = false;
            for (int i = 0; i <= three; i++)
            {
                for (int j = 0; j <= two; j++)
                {
                    long long temp = sum;
                    temp += (6 * i) + (2 * j);
                    if (temp % 9 == 0)
                    {
                        f = true;
                        break;
                    }
                }
            }
            if (f)
                cout << "YES" << endl;
            else
                cout << "NO" << endl;
        }
    }
    return 0;
}

Solution 2 (runtime: 62 ms):
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
using ll = long long;
int a[N];
void solve()
{
    string s;cin>>s;
    for(int i = 0;i < s.size();++ i)
    {
        a[i] = s[i] - '0';
    }
    vector<int> m(4);
    m[2] = 0;
    m[3] = 0;
    ll res = 0;
    for(int i = 0;i < s.size();++ i)
    {   
        res += a[i];
        if(a[i] == 2)m[2] ++;
        if(a[i] == 3)m[3] ++;
    }
    for(int i = 0;i <= m[2];++ i)
        for(int j = 0;j <= m[3];++ j)
        {
            // cout<<"i = "<<i<<' '<<"j = "<<j<<' ';
            // cout<<"ans = "<<res + 2*i + 3*j<<' ';
            if((res + 2*i + 6*j) % 9 == 0)
            {
                cout<<"YES"<<'\n';
                return;
            }
        }
    cout<<"NO"<<'\n';
}
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int _;cin>>_;
    while(_--)solve();
    return 0;
}
Problem: 2050D - Digital string maximization
Language: c++17 

Solution 1 (runtime: 77 ms):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+12;
ll m,n,t,d[maxn],r[maxn];

int main()
{
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        for(int i=0;i<s.size();i++)
        {
            int max=s[i]-48,maxj=i;
            for(int j=i+1;j<s.size()&&j<=i+9;j++)
            {
                if(char(s[j]-j+i)>s[i] && int(s[j]-j+i-48)>max)
                {
                    max=int(s[j]-j+i-48);
                    maxj=j;
                    //cout<<maxj<<" ";
                }
            }
            s[maxj]=char(max+48);
            for(int j=maxj;j>i;j--)
            {
                swap(s[j],s[j-1]);
            }
        }
        cout<<s<<endl;
    }
    return 0;
}



Solution 2 (runtime: 515 ms):
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
   ll t;
   cin>>t;
   while(t--){
       string s;
       cin>>s;
       
       vector<int>ans;
       ll max=-10;
       ll indx=0;
       while(s.size()>0){
         ll m=s.size();
         ll cons=9;
         ll n=min(m,cons);
           for(ll j=0;j<n;j++){
              if(s[j]-'0'-j>max){
                  max=s[j]-'0'-j;
                  indx=j;
              }
              else{
                continue;
              }
               }
               if(max>=0){
               ans.push_back(max);}
               if(max<0){
                 ans.push_back(0);
               }
               
               s.erase(s.begin()+indx);
               max=-10;
               }
               for(int i=0;i<ans.size();i++){
                   cout<<ans[i];
               }
               cout<<endl;
   }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 2e5 + 5;
string s;
ll n, m;
ll a[N], b[N];
vector<pair<ll, ll>> v;
void sp() {
    ll l, r;
    cin >> l >> r;
    ll sum = 0;
    while (1) {
        if (l == r - 2) {
            cout << l + sum << " " << l + sum + 1 << " " << l + sum + 2 << endl;
            return;
        }
        ll ans = 1;
        while (ans * 2 <= r) {
            ans *= 2;
        }
        if (ans <= l) {
            sum += ans;
            r -= ans;
            l -= ans;
        } else {
            cout <<ans+sum<<" "<<ans+sum-1<<" "<<(ans==r?l:r)+sum<<endl;
            return ;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll __ = 1;
    cin >> __;
    while (__--)
        sp();
    return 0;
}

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

using namespace std;

int main(){
    int t;
    int a, c;

    cin >> t;

    while(t--){
        cin >> a >> c;

        int b;
        for(int _xor = (a^c); _xor; _xor -= b) b = (_xor & -_xor);
        b = c - c%b;

        if(b == c)
            cout << a << " " << b-1 << " " << b << '\n';
        else
            cout << b-1 << " " << b << " " << c << '\n';
    }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

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

int main(){
    int t;
    cin>>t;
    while(t--){
         ll l, r;
    cin >> l >> r;
    ll ans = 0;
    ll a, b, c;
    for (int i = 30; i >= 0; i--)
    {
        ll b1 = 0;
        ll 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 (ll i = l; i <= r; i++)
    {
        if (i != a && i != b)
        {
            c = i;
            break;
        }
    }
    cout << a << " " << b << " " << c << endl;
    }
}

Solution 2 (runtime: 62 ms):
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define int long long
// #define mkp make_pair
#define txt freopen("kout.in", "r", stdin), freopen("kout.out", "w", stdout);
const int N = 200100, K = 20;

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

    int x = 0;
    for(int i = 30; i >= 0; i--)
    {
        if(r < (1ll << i))
            continue;
        else if(l >= (1ll << i))
        {
            l -= (1ll << i);
            r -= (1ll << i);
            x |= (1ll << i);
            continue;
        }
        
        int a = (1ll << i), b = a - 1, c = a - 2;
        if(c < l)
            c = a + 1;
        cout << (a | x) << ' ' << (b | x) << ' ' << (c | x) << '\n';
        return;    
    }


    

}   

signed main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T = 1;
    for (cin >> T; T--; solve());
}
/*

*/