ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050B - Transfusion
Language: c++17 

Solution 1 (runtime: 359 ms):
#include <iostream>
#include "vector"
using namespace std;

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

    for(int i = 0; i < n; i++){
        int m;
        long long  int sum = 0;
        cin >> m;
        vector<long long int> data(m);
        for(int j = 0; j < m; j++){
            cin>>data[j];
            sum += data[j];
        }
        if(sum % m != 0) {
            cout << "NO" << endl;
            continue;
        }
        long long int averge = sum / m;
        long long int odd_number = m / 2 ;
        long long int odd_averge = 0;
        long long int even_averge = 0;
        for(int k = 0;k < m; k++ ){
            if(k % 2 == 0){
                even_averge += data[k];
            }
            else{
                odd_averge += data[k];
            }
        }
        if(even_averge == averge *(m - odd_number) && odd_averge == averge * odd_number){
            cout<<"YES"<<endl;
        } else{
            cout<<"NO"<<endl;
        }

    }




    return 0;

}


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

using namespace std;

using ll = long long;

using ld = long double;

using vi = vector<int>;

using vll = vector<ll>;

using pii = pair<int, int>;

using pll = pair<ll, ll>;

using vpii = vector<pii>;

void fast_io() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

}



int main() {

    fast_io();

    

	int tc;

	cin>>tc;

	while(tc--){

	    int n;

	    cin>>n;

	    vi a(n,0);

	    ll total = 0;

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

	        cin>>a[i];

	        total += a[i];

	    }

	    

	    ll esum=0,osum=0;

	    ll epos=n/2,opos=(n+1)/2;

	    

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

	        if(i%2 == 0) osum += a[i]; 

	        else esum += a[i];

	    }

	    ll x = total/n;

	    if(osum == opos * x && esum == epos * x)

            cout << "YES\n";

        else

            cout << "NO\n";

	    

	    

	}



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

Solution 1 (runtime: 46 ms):
#include<bits/stdc++.h>
using namespace std;
ifstream fin("window.in");
ofstream fout("window.out");
void solve(){
    int l,r;
    cin>>l>>r;
    int b(30),prc(0);
    while(((1<<b)&l)==((1<<b)&r))prc+=((1<<b)&r),b--;
    if(prc+(1<<b)==r)cout<<prc+(1<<b)<<" "<<prc+(1<<b)-1<<" "<<prc+(1<<b)-2<<"\n";
    else cout<<prc+(1<<b)<<" "<<prc+(1<<b)-1<<" "<<prc+(1<<b)+1<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long t;
    cin>>t;
    while(t--)solve();
    return 0;
}


Solution 2 (runtime: 61 ms):
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops") 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;

#define endll '\n'

#define all(x) (x).begin(), (x).end()
#define maxeq(a, b) a = max<decltype(a)>(a, b)
#define mineq(a, b) a = min<decltype(a)>(a, b)

#define MOD ll(1e9+7)
#define inf int(1e9+1)
#define INF ll(1e18+1)
#define EPS ld(1e-9)

template <typename T>
inline void fillv(vector<T>& v, int n) {
    for (int i = 0; i < n; ++i) {
        std::cin >> v[i];
    }
}
template <typename T, typename U>
inline void fillv(vector<pair<T, U>>& v, int n, bool inv = false){
	if(inv){
		for(int i = 0 ; i < n; ++i){
			cin >> v[i].second >> v[i].first;
		}
		return;
	}
	for (int i = 0; i < n; ++i) {
        cin >> v[i].first >> v[i].second;
    }
	return;
}

inline void open(string name){
    freopen((name + ".in").c_str(), "r", stdin);
	freopen((name + ".out").c_str(), "w", stdout);
}

//comment to enable debugging
#define dbg(x)

#ifndef dbg
#define dbg(x) cerr << __LINE__ << ": " << #x << "=" << x << endl;
//edit for specific DS
#include <alldebug.h>
#endif

void solve(int num_tc)
{
    int l, r;
    cin >> l >> r;
    ll mask = 0;
    for(int i = 30; i >= 0; i--){
        if((l & (1 << i)) ^ (r & (1 << i))){
            mask += (1 << i);
            break;
        }
        if((l & (1 << i)) == 0){
            continue;
        }
        mask += (1 << i);
    }
    dbg(bitset<6>(l).to_string());
    dbg(bitset<6>(r).to_string());
    dbg(bitset<6>(mask).to_string());
    cout << mask << " " << (mask - 1) << " " << (mask == r ? l : r) << endll;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);  

    ll T = 1;
    cin >> T;
    for(ll t = 0; t < T; t++){
        solve(t+1);
    }
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 62 ms):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define PII pair<int, int>
#define cout_ cout << "*"
const int N = 2e5 + 5, M = 5005;
const int mod = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;
// mt19937_64 rng {chrono::steady_clock::now().time_since_epoch().count()};

void solve()
{
    int l,r;
    cin>>l>>r;
    int high=0;
    while((1<<high)<=r) high++;
    high--;
    int a=0,b=0,c=0;
    for(int i=high;i>=0;i--){
        if(((r>>i)&1)&&((l>>i)&1)) a+=1<<i,b+=1<<i,c+=1<<i;
        else if(((r>>i)%2==0)&&((l>>i)%2==0)) continue;
        else {
            if((a+(1<<i)+1)<=r){
                cout<<a+(1<<i)+1<<" "<<b+(1<<i)<<" "<<c+(1<<i)-1<<endl;
                return ;
            }
            else {
                cout<<a+(1<<i)<<" "<<b+(1<<i)-1<<" "<<c+(1<<i)-2<<endl;
                return ;
            }
        }
    }
}

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

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




void Solve()
{

    int a, b;
    cin >> a >> b;
if(a > b) swap(a,b);
bitset<52> bitsA(a);
bitset<52> bitsB(b);
string sA;
string sB;
int index = -1;
for(int i = 51 ; i >= 0 ; i--){
    if(bitsA[i] != bitsB[i]){
        index = i;
        break;
    }
}
string ans;

for(int i = index ; i >= 0 ; i--){
    sA += bitsA[i] + '0';
    sB += bitsB[i] + '0';
    ans += !(bitsA[i] & bitsB[i]) + '0';
}


for(int i = index ; i >= 0 ; i--){
    if(sA != sB){
        string cur = ans;
        cur[i] = '0';
        if(cur < sB && cur > sA){
            ans = cur;
        }
    }
}


bitset<52> bitsC(a);

for(int i = 0 ; i <= index ; i++){
    bitsC[i] = ans[index - i] -'0';
}
cout<<a<<" "<<bitsC.to_ullong()<< " " <<b<<endl;


}


int32_t main(){

   int t;
   cin >> t;
   for(int i = 0 ; i <t ; i++){
    Solve();
   }
}
Problem: 2050D - Digital string maximization
Language: c++17 

Solution 1 (runtime: 937 ms):
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){

    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int n=s.length();
        set<pair<char,int>>st;
        for(int i=0;i<n;i++)st.insert({s[i],n-i});
        string org=s;
        while(st.size()){
            auto it=*st.begin();
            char val=it.first;
            int index=n-it.second;
            int i=index;
            st.erase(it);
            if (index==n-1 || s[index+1]=='0')continue;
            int original=(s[index]-'0')*10+s[index+1]-'0';
            int rev=((s[index+1]-'0')-1)*10+(s[index]-'0');
            if (rev>original){
                st.erase({s[index+1],index+1});
                swap(s[index],s[index+1]);
                s[i]=((s[i]-'0')-1)+'0';
                st.insert({s[i],n-i});
                st.insert({s[i+1],n-(i+1)});
            }
            // cout<<s<<endl;
        }
        while(org!=s){
            org=s;
            for(int i=0;i<n;i++)st.insert({s[i],n-i});
            while(st.size()){
                auto it=*st.begin();
                char val=it.first;
                int index=n-it.second;
                int i=index;
                st.erase(it);
                if (index==n-1 || s[index+1]=='0')continue;
                int original=(s[index]-'0')*10+s[index+1]-'0';
                int rev=((s[index+1]-'0')-1)*10+(s[index]-'0');
                if (rev>original){
                    st.erase({s[index+1],index+1});
                    swap(s[index],s[index+1]);
                    s[i]=((s[i]-'0')-1)+'0';
                    st.insert({s[i],n-i});
                    st.insert({s[i+1],n-(i+1)});
                }
                // cout<<s<<endl;
            }
        }
        cout<<s<<endl;
    }
    

  return 0;
}

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

void Insert(deque<int>&V,int k){
    V.push_back(k);
    int n = V.size(),i = n - 2;
    while(i >= 0){
        if(V[i] + 1 < V[i + 1]){swap(V[i],V[i + 1]);V[i]--;i--;}
        else break;
    }
    return;
}

int main() {
	// your code goes here
	int t;cin>>t;
	while(t--){
	    string s;cin>>s;
	    priority_queue<pair<int,int>>Q;
	    deque<int>P;int n = s.size();
	    string res = "";
	    for(int i = 0;i < n;i++)Insert(P,s[i] - '0');
	    for(int i = 0;i < n;i++){
	        res += P.front() + '0';
	        P.pop_front();
	    }
	    cout<<res<<endl;
	}

}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 46 ms):
#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;


typedef tree<int,null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> oset;
typedef long long ll;
typedef double dl;

#define endl "\n"
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);




void solve()
{
    ll n ;
    cin >> n ;
    ll a[n];
    for(ll i=0; i<n; i++)cin >> a[i];
    ll ans = accumulate(a,a+n,0ll);
    vector<ll> v ;
    while(n>1)
    {
        for(int i=0; i<n-1; i++)
        {
            v.push_back(a[i+1]-a[i]);

        }
        ans = max(ans, abs(accumulate(v.begin(),v.end(),0ll)));
        for(int i=0; i<n-1; i++)
        {
           a[i]=v[i];

        }
        v.clear();
        n--;


    }
    cout << ans << endl;


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



    return 0;
}



Solution 2 (runtime: 46 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define ull unsigned ll

void Mohamady() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
ll sum(vector<ll> a) {
	ll ret = 0;
	for (int i = 0; i < a.size(); ++i) {
		ret += a[i];
	}
	 return ret;
}
void Solve() {
	int n; cin >> n;
	ll mx = 0;
	vector<ll> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		mx += v[i];
	}
	if (n == 1) {
		return void(cout << v.front() << "\n");
	}
	for (int i = 0; i < n - 1; ++i) {
		for (int j = 0; j < v.size() - 1; ++j) {
			v[j] = v[j + 1] - v[j];
		}
		v.pop_back();
		mx = max(mx, abs(sum(v)));
	}
	cout << mx << "\n";
}
// 7.72568
int main() {
	Mohamady();
	int t = 1;
	cin >> t;
	while (t--) Solve();
}
Problem: 2050D - Digital string maximization
Language: c++17 

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

#define ll long long int

using namespace std;

void solve()
{
    string s;
    cin >> s;
    ll count;
    while (1)
    {
        count = 0;
        for (int i = 1; i < s.size(); i++)
        {
            if ((s[i] - '0') - 1 > (s[i - 1] - '0'))
            {
                count++;
                s[i] -= 1;
                swap(s[i - 1], s[i]);
            }
        }
        if (count == 0)
            break;
    }
    cout << s << endl;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}

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

using namespace std;

using ll = long long;

using pll = pair<long, long>;

using pii = pair<int, int>;



int s[200020];

int n;



void solve() {

  string temp;

  cin >> temp;

  n = temp.size();



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

    s[i] = temp[i] - '0';

  }



  int p = n - 1;

  while (p > 0) {

    int new_p = p;

    while (new_p > 0 && s[new_p] > s[new_p - 1] + 1) {

      int temp = s[new_p];

      s[new_p] = s[new_p - 1];

      s[new_p - 1] = temp - 1;



      new_p--;

    }

    if (new_p == p) {

      p--;

    } else if (p != n - 1) {

      p += 1;

    }

  }



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

    cout << s[i];

  }

  cout << endl;

}



signed main() {

  int t;

  cin >> t;

  while (t > 0) {

    solve();

    t--;

  }

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

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

#define int long long
#define pll pair <long long, long long>
#define f first
#define s second
#define all(a) a.begin(), a.end()
#define inf 1e18
#define rall(a) a.rbegin(), a.rend()

using namespace std;

template<typename T>
ostream &operator<<(ostream &stream, vector<T> &vec) {
    for (auto &b: vec) stream << b << " ";
    return stream;
}

template<typename T>
istream &operator>>(istream &stream, vector<T> &vec) {
    for (auto &b: vec) stream >> b;
    return stream;
}

void solve() {
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.size(), m = b.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, inf));
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        dp[i][0] = dp[i - 1][0] + (a[i - 1] != c[i - 1]);
    }
    for (int i = 1; i <= m; i++) {
        dp[0][i] = dp[0][i - 1] + (b[i - 1] != c[i - 1]);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            dp[i][j] = min({dp[i][j - 1] + (b[j - 1] != c[i + j - 1]),
                            dp[i - 1][j] + (a[i - 1] != c[i + j - 1])});
        }
    }

    cout << dp[n][m] << endl;
}

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

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        string a, b, c;

        cin >> a >> b >> c;

        int n = a.length(), m = b.length();

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

        dp[0][0]=0;

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

            for(int j = 0; j <= m; j++){

                if(i>=1){

                    dp[i][j]=dp[i-1][j]+(a[i-1]!=c[i+j-1]);

                }if(j>=1){

                    dp[i][j]=min(dp[i][j-1]+(b[j-1]!=c[i+j-1]),dp[i][j]);

                }

            }

        }

        cout << dp[n][m]<<'\n';

    }

}
Problem: 2050D - Digital string maximization
Language: c++17 

Solution 1 (runtime: 78 ms):
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int T;
string s; 
int main(){
	cin>>T;
	while(T--){
		cin>>s;
		int len=s.size();
		for(int i=1;i<len;i++){
			int t=i;
			while(s[t]!='0' && t>0 && s[t]-1>s[t-1]){
				s[t]-=1;//��-1�Ĳ��� 
				swap(s[t],s[t-1]);//���� 
				t--;//t��λ�������ƶ� 
			}
		}
		cout<<s<<endl;  
	}
	return 0;
}



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

using namespace std;

#define pip pair<ll, pair<ll,ll>>

#define pii pair<ll, ll>

#define ll long long

#define f(i, n) for (ll i = 0; i < n; i++)



void solve() {

    string s;

	cin >> s;

	ll n = s.length();

	vector<ll> v(n);

	f(i, n){

		v[i] = s[i] - '0';

	}



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

		int j = i;

		while(j > 0){

			if(v[j]-1 > v[j-1]){

				ll x = v[j-1];

				v[j-1] = v[j]-1;

				v[j] = x;

			} else break;

			j--;

		}

	}

	f(i, n){

		cout << v[i] << "";

	}

	cout << "\n";

	return;

}



signed main() {

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);



    ll t;

    cin >> t;

    while (t--) {

		solve();

    }

    return 0;

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

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




int main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t;
	cin>>t;
	while(t--){
		int n;
        cin>>n;
        int arr[n];
        for(int i =0;i<n;i++){
            cin>>arr[i];
        }
        int od_,ev_;
        if(n%2 == 0){
            od_ = n/2;
            ev_ = n/2;
        }
        else{
            od_ = n/2 + 1;
            ev_ = n/2;
        }
        long long int od =0;
        long long int ev =0;
        for(int i =0;i<n;i++){
            if((i + 1)%2 == 0){
                ev += arr[i];
            }
            else{
                od += arr[i];
            }
        }
        if ((od/od_) == (ev/ev_) && od%od_ == 0 && ev%ev_ == 0){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }

	}

	
	return 0;
}
	
	

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

using namespace std;



int main() {

    int t;

    cin >> t;

    

    while (t--) {

        int n;

        cin >> n;



        long long sumo = 0, sume = 0;

        long long sizeo = 0, sizee = 0;

        

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

            int x;

            cin >> x;

            if (i % 2 == 0) {

                sume += x;

                sizee++;

            } else {

                sumo += x;

                sizeo++;

            }

        }



        if (sizeo == 0 || sizee == 0) {

            cout << "no" << endl; 

            // If one group is empty, they can't be equal

            

        }

        else if(sume%sizee!=0 || sumo%sizeo !=0 ){

            cout<<"NO"<<endl;

        }

        

        

        

        else if ((double)sume / sizee == (double)sumo / sizeo) {

            cout << "yes" << endl;

        } else {

            cout << "no" << endl;

        }

    }

    

    return 0;

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

Solution 1 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 9;

int n, m;
int dp[N][N];
string A, B, C;

int cur(int i, int j) {
    if(i == n && j == m) return 0;
    int &ret = dp[i][j];
    if(ret != -1) return ret;
    ret = 1e9 + 1;

    if(i + 1 <= n) ret = min(ret, cur(i + 1, j) + 1 - (A[i] == C[i + j]));
    if(j + 1 <= m) ret = min(ret, cur(i, j + 1) + 1 - (B[j] == C[i + j]));

    return ret;
}

void solveTc() {
    cin >> A >> B >> C;
    n = A.size(), m = B.size();

    A = ' ' + A;
    B = ' ' + B;
    C = ' ' + C;

    for(int i = 0; i <= n; ++i) 
        for(int j = 0; j <= m; ++j)
            dp[i][j] = 1e9 + 1;
    dp[0][0] = 0;

    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= m; ++j) {
            if(i == 0 && j == 0) continue;

            if(i > 0) dp[i][j] = min(dp[i][j], dp[i - 1][j] + (A[i] == C[i + j] ? 0 : 1));
            if(j > 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (B[j] == C[i + j] ? 0 : 1));
        }
    }
    
    // cout << n << ' ' << m << '\n';
    // cout << dp[0][1] << '\n';
    cout << dp[n][m] << '\n';
}

int main() {
    int tc;
    cin >> tc;
    while(tc--) solveTc();
}

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

using namespace std;



void solve(){

    string a, b, c;

    cin >> a;

    cin >> b;

    cin >> c;

    long long int i = 0;

    long long int j = 0;

    long long int m = a.size();

    long long int n = b.size();

    vector<vector<long long int>>memo(m+1,vector<long long int>(n+1,0));

    long long int one = 1;

    for(i=m-1;i>=0;i--){

        if(a[i]==c[n+i]){

            memo[i][n] = memo[i+1][n];

        }

        else{

            memo[i][n] = memo[i+1][n]+1;

        }

    }

    for(j=n-1;j>=0;j--){

        if(b[j]==c[m+j]){

            memo[m][j] = memo[m][j+1];

        }

        else{

            memo[m][j] = memo[m][j+1]+1;

        }

    }

    for(i=m-1;i>=0;i--){

        for(j=n-1;j>=0;j--){

            long long int temp = INT_MAX;

            if(a[i]==c[i+j]){

                temp = min(temp,memo[i+1][j]);

            }

            if(b[j]==c[i+j]){

                temp = min(temp,memo[i][j+1]);

            }

            if(a[i]!=c[i+j]){

                temp = min(temp,one+memo[i+1][j]);

            }

            if(b[j]!=c[i+j]){

                temp = min(temp,one+memo[i][j+1]);

            }

            memo[i][j] = temp;

        }

    }

    cout << memo[0][0] << endl;

}

int main(){

    long long int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

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

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

#define ll long long
#define vtr vector<ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define arg sort(v.begin(),v.end())
#define Lrg sort(v.rbegin(),v.rend())
#define lm(a,b) for(int i=a; i<b; i++)
#define tst int t; cin >> t; while(t--)
#define nl

using namespace std;
void slayer()
{
    ll l,r;
    cin >> l >> r;
    ll pos;
    for(int i=30; i>=0; i--){
        if((l&(1LL<<i))!=(r&(1LL<<i))){
            pos=i;
            break;
        }
    }
    ll a=l|((1LL<<pos)-1);
    ll b=a+1;
    ll c=r;
    if(c==a || c==b)c--;
    if(c==a || c==b)c--;
    cout << a << " " << b << " " << c << endl;
}
int main()
{
    tst{
        slayer();
    }

    return 0;
}



Solution 2 (runtime: 108 ms):
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define fi first
#define se second
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define cntbit __builtin_popcountll
#define pii pair<int, int>
#define vii vector<pair<int, int>>
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace std;
const int N = 200010; 
const int inf = 1ll<<62;
const int mod = 998244353;
void chkmax(int &a,int b){
    a = max(a, b);
}
void chkmin(int &a,int b){
	a = min(a, b);
}
void add(int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}
void sub(int &a,int b){
	a -= b;
	if(a < 0) a += mod;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int qmi(int a, int b) {
    int res = 1;
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
vector<int> con(int x){
	vector<int> r;
	while(x){
		r.pb(x&1);
		x/=2;
	}
	reverse(all(r));
	return r;
}
int g(int a,int b,int c){
	return (a^b)+(a^c)+(b^c); 
}
void solve(){
	int l,r;
	cin>>l>>r;
	int base=0;
	vector<int> L=con(l);
	vector<int> R=con(r);
	if(L.size()<R.size()){
		vector<int> nl;
		int di=R.size()-L.size();
		while(di--) nl.pb(0);
		for(auto x:L) nl.pb(x);
		L=nl;
	}
	
//	for(auto x:L)
//		cout<<x;
//	cout<<endl;
//	for(auto x:R)
//		cout<<x;
//	cout<<endl;
	
	int s=0,sum=0,val=1,len=R.size();
	rep(i,0,len-1){
		val*=2;
	}
	//cout<<val<<endl;
	while(s<len&&L[s]==R[s]){
		s++;
		if(L[s-1]==1) sum+=val;
		val/=2;
	}
	int lef=len-s;
	int num=1;
	rep(i,0,lef-1) num*=2;
	int a=-1,b=-1,c=-1;
	if(l-sum<=num-2){
		a=(sum+num);
		b=(sum+num-1);
		c=(sum+num-2);
		cout<<(sum+num)<<" "<<(sum+num-1)<<" "<<(sum+num-2)<<endl;
		//cout<<sum<<' '<<num<<endl;
		int res=g(a,b,c);
		//cout<<res<<endl;
	}else{
		a=(sum+num);
		b=(sum+num+1);
		c=(sum+num-1);
		cout<<(sum+num)<<" "<<(sum+num+1)<<" "<<(sum+num-1)<<endl;
		//int res=g(a,b,c);
		//cout<<res<<endl;
	}
	
}
signed main() {
	
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout<<fixed<<setprecision(12);
    int T = 1;cin>>T;
    while (T--) {
        solve(); 
    }

}