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

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


#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define inf 1e9
#define nline "\n"
#define pb push_back
#define ppb pop_back
// #define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcountll
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b)    for(int i{a};i<b;i++);


typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}


//01111
//10000
//



void solve() {
    ll l = 0 , r = 0;
    cin >> l >> r;
    ll y = 1;
    int bit = 0;
    while (y <=  r) {
        y = y * 2;
        bit++;
    }
    bit--;
    ll val = (1LL << bit);
    if (val > l && val <= r) {
        cout << val << " " << val - 1 << " ";
        if (l == val - 1) {
            cout << r << nline;
        }
        else cout << l << nline;
    }
    else {
        int bit = 0;
        for (int i = 30; i >= 0; i--) {
            int lbit = ((l & (1LL << i)) != 0);
            int rbit =  ((r & (1LL << i)) != 0);
            if (lbit != rbit) {
                bit = i;
                break;
            }
        }
        ll y = (l >> bit);
        y <<= bit;
        debug(y)
        debug(bit)
        debug(1LL << bit)
        ll gg =  (1LL << bit) + y;
        debug(gg)
        cout << gg << " " << gg - 1 << " ";
        if (gg - 1  == l ) {
            cout << r << nline;
        }
        else cout << l << nline;
    }
}
// 1000100
// 1100010

int main() {
#ifndef ONLINE_JUDGE
    freopen("error.txt", "w", stderr);
    freopen("output.txt", "w", stdout);
    freopen("input.txt", "r", stdin);
#endif
    fastio();
    int t{1};
    cin >> t;
    while (t--) solve();
}

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

const int N =33;

int le[N],ri[N];

void solve()
{
	int l,r;cin>>l>>r;
	for(int i=31;i>=0;--i){
		if(l>>i&1) le[i]=1;
		else le[i]=0;
	}
	for(int i=31;i>=0;--i){
		if(r>>i&1) ri[i]=1;
		else ri[i]=0;
	}
	int res=0;
	for(int i=30;i>=0;--i){
		if(le[i]!=ri[i]){
			res=i;
			break ;
		}
	}
	bool flag=true;
	for(int i=res-1;i>=0;--i){
		if(ri[i]){
			flag=false;
		}
	}
	if(flag){
		int a=0,b=0,c=0;
		for(int i=0;i<=32;++i){
			if(i<res&&i) a+=pow(2,i);
			if(i<res) b+=pow(2,i);
			if(i==res) c+=pow(2,i);
			if(i>res){
				if(le[i]) a+=pow(2,i),b+=pow(2,i),c+=pow(2,i);
			}
		}
		cout<<a<<' '<<b<<' '<<c<<'\n';
	}else{
		int a=0,b=0,c=0;
		for(int i=0;i<=32;++i){
			if(i<res) a+=pow(2,i);
			if(i==res) b+=pow(2,i),c+=pow(2,i);
			if(i<res&&i==0) c+=pow(2,i);
			if(i>res){
				if(le[i]) a+=pow(2,i),b+=pow(2,i),c+=pow(2,i);
			}
		}
		cout<<a<<' '<<b<<' '<<c<<'\n';
	}
}

signed main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int _;cin>>_;
	while(_--) solve();
	return 0;
}