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

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

#define ull unsigned long long int
#define ll long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define cv(x) vector<long long int> x
#define cvn(x, n, val) vector<long long int> x(n, val)
#define fl(i, x) for( int i = 0; i < x; i++ )
#define pv(v) for( auto i: v){ cout<<i<<'	';}

string decimaltobinary(ll n){
    if(n == 0) return "0"; // Edge case: decimal 0 is binary 0
    string bin = "";
    while(n > 0){
        bin = to_string(n % 2) + bin; // Prepend to keep correct order
        n /= 2;
    }
    return bin;
}

ll binarytodecimal(string bin){
    // cout<<endl;
    // cout<<"bin is: "<<bin<<endl;
    ll dec = 0;
    for(int i = bin.length() - 1, mul = 1; i >= 0; i--, mul *= 2){
        dec += (mul * (bin[i] - '0'));
        // cout<<"dec is: "<<dec<<endl;
    }
    return dec;
}


int main(){
    int t;
    cin>>t;
    while(t--){
        ll l, r;
        cin>>l>>r;
        string binl = decimaltobinary(l);
        string binr = decimaltobinary(r);
        if(binl.length() != binr.length()){
            int diff = (binr.length() - binl.length());
            for( int i = 0; i < diff; i++ ){
                binl = "0" + binl;
            }
        }
        // cout<<"binl is: "<<binl<<" and binr is: "<<binr<<endl;
        int pos = 0;
        for( int i = 0; i < binr.length(); i++ ){
            if(binl[i] != binr[i]){
                pos = i;
                break;
            }
        }
        string ans1 = "", ans2 = "", ans3 = "";
        for( int i = 0; i < pos; i++ ){
            ans1 += binl[i];
            ans2 += binr[i];
            ans3 += binr[i];
        }
        ans1 += '1';
        ans2 += '0';
        //first making ans1 and ans2
        for( int i = pos + 1; i < binr.length(); i++ ){
            ans1 += '0';
            ans2 += '1';
        }
        // cout<<"ans1 is: "<<ans1<<" ans2 is: "<<ans2<<endl;
        //now making ans3
        if(ans1 != binr){
            ans3 = binr;
            cout<<binarytodecimal(ans1)<<" "<<binarytodecimal(ans2)<<" "<<binarytodecimal(ans3)<<endl;
            // cout<<"went 1"<<endl;
            continue;
        }
        else if(ans2 != binl){
            ans3 = binl;
            cout<<binarytodecimal(ans1)<<" "<<binarytodecimal(ans2)<<" "<<binarytodecimal(ans3)<<endl;
            // cout<<"went 2"<<endl;
            continue;
        }
        
    }
    return 0;
}

Solution 2 (runtime: 61 ms):
// Problem: C. Trip to the Olympiad
// URL: https://codeforces.com/problemset/problem/2057/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repeat(l,r,x) for(int x = (l) ; x < (r) ; x++)
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back(x) 

int t , l , r , a , b;

signed main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> t;
	while(t--)
	{
		cin >> l >> r;
		if(l + 2 == r)
		{
			cout << l << " " << l+1 << " " << l+2 << "\n";
			continue;
		}
		a = b = 0;
		int i = (1<<30);
		while((l&i) == (r&i))
		{
			b = a += (l&i);
			i >>= 1;
		}
		while(i)
		{
			if(a + i > r || b + i - 2 < l)b += i;
			else a += i;
			i >>= 1;
		}
		cout << a << " " << b << " " << (b^1) << "\n";
	}
	return 0;
}