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

Solution 1 (runtime: 77 ms):
/*
*/
///PROBLEM LINK -> xxx
#include <bits/stdc++.h>
using namespace std;
// this  5 lines   policy based data structures
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class T> using PBDS = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//......... macros.........

#define Faster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define nl cout<<endl
#define sp <<" "
//
typedef long long ll;

// ........ constant.......
const long long  inf=1e18;
const long long mod = 1000000007;
const double Pi =  3.1415926535897932384626433832795;
int dx[] = {0, 0, -1, 1, -1, -1, 1, 1};  // Change in x for up, down, left, right, diagonal up-left, diagonal up-right, diagonal down-left, diagonal down-right
int dy[] = {-1, 1, 0, 0, -1, 1, -1, 1};  // Change in y for up, down, left, right, diagonal up-left, diagonal up-right, diagonal down-left, diagonal down-right
//.......global.........
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif


ll distanceOf2Point(int x1, int y1, int x2, int y2)
{
    return 1ll * (x2 - x1) * (x2 - x1) + 1ll * (y2 - y1) * (y2 - y1);
}

bool is_prime(ll n)// for prime
{
    if (n == 1)return false;
    if (n == 2)return true;
    if (n % 2 == 0)return false;
    for (ll i = 3; i * i <= n; i++)if (n % i == 0)return false;
    return true;
}



vector<long long> bia(long long n)// des to bainarry
{
    vector<long long> ans;
    while (n > 0)
    {
        ans.push_back(n & 1);
        n = n >> 1;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

long long bia_to_desi(vector<long long> ar)
{
    long long sum = 0;
    reverse(ar.begin(), ar.end());
    for (long long i = 0; i < ar.size(); i++) if (ar[i]) sum += (1LL << i);
    return sum;
}

int clock_wise(int n,int len,int src)
{
    len%=n;
    if(src+len>n)
    {
        int now = n;
        len-=n-src;
        if(len>0)
        {
            now = 1;
            len--;
        }
        if(len>0)
        {
            return len+1;
        }
        return now;
    }
    return src+len;
}


int counter_clock_wise(int n,int len,int src)
{
    len%=n;
    if(src-len<1)
    {
        int now = 1;
        len-=src-1;
        if(len>0)
        {
            now = n;
            len-=1;
            if(len>0)now = n-len;
            return now;
        }
    }
    return src - len;
}

vector<ll> prifix_sum(vector<ll>ar)// prifix_sum
{
    ll n= ar.size();
    vector<ll>ans(n);
    ans[0]=ar[0];
    for(ll i=1; i<n; i++)ans[i]=ar[i]+ans[i-1];
    return ans;
}

vector<ll>su_fix_sum(vector<ll>ar)// su_fix_sum
{
    ll n= ar.size();
    vector<ll>ans(n);
    ans[n-1]=ar[n-1];
    for(ll i=n-2; i>=0; i--)ans[i]=ar[i]+ans[i+1];
    return ans;
}

bool customCompare(pair<pair<int,int>,int> a, pair<pair<int,int>,int>& b)
{
    return (a.first.second - a.first.first) <= (b.first.second - b.first.first);
}




// the code stars from here....................

void TEST_CASES()
{
    ll l,r;
    cin>>l>>r;
    vector<long long>  abi= bia(r);
    vector<long long>  bbi= bia(l);
    debug(abi)
    debug(bbi)
    reverse(bbi.begin(),bbi.end());
    while(bbi.size()!=abi.size())bbi.push_back(0);
    reverse(bbi.begin(),bbi.end());
    ll ind;
    for(ll i=0;i<abi.size();i++)if(abi[i]!=bbi[i]){ind=i;break;}
    for(int i=ind+1;i<abi.size();i++){abi[i]=0;bbi[i]=1;}
    reverse(bbi.begin(),bbi.end());
    while(bbi.size() && bbi.back()==0)bbi.pop_back();
    reverse(bbi.begin(),bbi.end());
    ll a=bia_to_desi(abi);
    ll b=bia_to_desi(bbi);
    for(ll i=l;i<=r;i++)if(i!=a && i!=b){cout<<a<<" "<<b<<" "<<i<<endl;return; }




}




int32_t main()
{
#ifndef LOKAL
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
/// extra code if i need




///
    int t=1;
  cin>>t;
    while(t--)TEST_CASES();
    return 0;
}


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

void init_code(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

string bin(int n){
    string str;
    while(n){
        int dig = n%2;
        dig += '0';
        str += dig;
        n /= 2;
    }
    int m = str.size();
    string s;
    for(int i = m-1; i > -1; i--){
        s += str[i];
    }

    return s;
}

int log_2(int n){
    if(n<=0)return 0;
    int ans = 0;
    while(n != 1){
        ans++;
        n /= 2;
    }
    return ans;
}

int pow_2(int n){
    int ans = 1;
    for(int i = 0; i < n; i++){
        ans *= 2;
    }
    return ans;
}

int main(){
    init_code();
    int t;
    cin>>t;
    while(t--){
        int l,r;
        cin>>l>>r;
        if(r == l+2){
            cout<<l<<" "<<l+1<<" "<<r<<endl;
            continue;
        }
        if(l == 0){
            int j = log_2(r);
            if(j == 1){
                cout<<0<<" "<<1<<" "<<2<<endl;
                continue;
            }
            cout<<pow_2(j-1)<<" "<<pow_2(j)-1<<" "<<pow_2(j)<<endl;
            continue;
        }
        if(l == 1){
            int j = log_2(r);
            if(j == 1){
                cout<<1<<" "<<2<<" "<<3<<endl;
                continue;
            }
            cout<<pow_2(j-1)<<" "<<pow_2(j)-1<<" "<<pow_2(j)<<endl;
            continue;
        }
        int i = log_2(l);
        int j = log_2(r);
        // cout<<i<<" "<<j<<endl;
        if(j > i+1){
            cout<<pow_2(j)-2<<" "<<pow_2(j)-1<<" "<<pow_2(j)<<endl;
            continue;
        }
        if(j == i+1){
            if(l == pow_2(j)-1){
                cout<<l<<" "<<pow_2(j)<<" "<<r<<endl;
                continue;
            }
            cout<<l<<" "<<pow_2(j)-1<<" "<<pow_2(j)<<endl;
            continue;
        }
        // cout<<pow_2(i)<<endl;
        if(j == i){
            if(l == pow_2(i)){
                int j_prime = log_2(r-l);
                if(j_prime == 1){
                    cout<<l<<" "<<l+1<<" "<<l+2<<endl;
                    continue;
                }
                cout<<l+pow_2(j_prime-1)<<" "<<l+pow_2(j_prime)-1<<" "<<l+pow_2(j_prime)<<endl;
                continue;
            }
            // int j_prime = log_2(r-pow_2(i));
            string s, k;
            s = bin(l);
            k = bin(r);
            // cout<<s<<endl<<k<<endl;
            int m = s.size();
            // cout<<m<<endl;
            int idx = -1;
            int left = 0;
            for(int p = 0; p < m; p++){
                if(s[p] == '1'){
                    left += pow_2(m-p-1);
                }
                if(s[p] != k[p]){
                    idx = p;
                    break;
                }
            }
            // cout<<left<<" "<<idx<<endl;
            int re = 1, id = -1;
            for(int p = idx+1; p < m; p++){
                if(k[p] != '0'){
                    re = 0;
                    id = p;
                    break;
                }
            }
            int j_prime = m - idx - 1;
            // cout<<j_prime<<" "<<pow_2(j_prime)<<" "<<re<<" "<<id<<endl;
            if(re == 1){
                cout<<left+pow_2(j_prime)-2<<" "<<left+pow_2(j_prime)-1<<" "<<left+pow_2(j_prime)<<endl;
                continue;
            }
            cout<<left+pow_2(j_prime)-1<<" "<<left+pow_2(j_prime)<<" "<<left+pow_2(j_prime)+1<<endl;
            continue;
        }
    }
}