Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
// #define mod 1000000007
// #define mod  998244353

typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>,
__gnu_pbds::rb_tree_tag, 
__gnu_pbds::tree_order_statistics_node_update> ordered_set;

typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less_equal<int>,
__gnu_pbds::rb_tree_tag, 
__gnu_pbds::tree_order_statistics_node_update> ordered_multiset;

// class SegmentTree{
//     vector<vector<ll>>val;
//     ll size;
//     SegmentTree(vector<vector<ll>>&given, ll n){
//         val.resize(2*n);
//         size = n;
//         createTree(0,0,n,given);
//     }
//     void createTree(ll x, ll l, ll r, vector<vector<ll>>&given){
//         if(l+1==r){
//             val[x] = {given[l][1], given[l][1]};
//             return;
//         }
//         else if(l>=r)return;
//         ll mini = INT_MAX, ll maxi = INT_MIN;
//         for(int i=l;i<r;++i){
//             maxi = max(maxi, given[i][1]);
//             mini = min(mini, given[i][1]);
//         }
//         val[x] = {mini,maxi};
//         ll mid = l + (r-l)/2;
//         createTree(2*x+1,l,mid,given);
//         createTree(2*x+2,mid,r,given);
//     }
    
//     vector<ll> query(ll x, ll l, ll r, vector<ll>&range){
//         if(l>=r)return {INT_MAX, INT_MIN};
//         if(l==range[0] && r==range[1])return val[x];
//         ll mid = l + (r-l)/2;
//         vector<ll>left = query(2*x+1,l,mid,range);
//         vector<ll>right = query(2*x+2,mid,r,range);
//         return {min(left[0],right[0]), max(left[1],right[1])};
//     }
// };

class DisjSet {
public:
    vector<ll>parent,rank;
    DisjSet(ll n){
        rank.resize(n,0);
        parent.resize(n,0);
        makeSet();
    }
    void makeSet(){
        for (ll i = 0; i < parent.size(); i++) {
            parent[i] = i;
        }
    }
    ll find(ll x){
        if (parent[x] != x)parent[x] = find(parent[x]);
        return parent[x];
    }
 
    void Union(ll x, ll y, vector<ll>&given){
        ll xset = find(x);
        ll yset = find(y);

        if (xset == yset){
            return;
        }
        if (rank[xset] < rank[yset]) {
            parent[xset] = yset;
            
        }
        else if (rank[xset] > rank[yset]) {
            parent[yset] = xset;
        }
        else {
            parent[yset] = xset;
            rank[xset] = rank[xset] + 1;
        }
    }
};

ll pown(ll x, ll n, ll mod = 998244353){
    if(n==0)return 1;
    if(n==1)return x%mod;
    if(n%2==1)return ((x%mod) * (pown(((x%mod)*(x%mod))%mod,n/2)%mod))%mod;
    return pown(((x%mod)*(x%mod))%mod,n/2)%mod;
}

ll gcd1(ll a, ll b){
    return b==0? a : gcd1(b, a%b);
}


ll logn(ll x, ll n){
    ll count=0;
    while(x>1){
        x/=n;
        count++;
    }
    return count;
}


// ll solver(ll i, vector<vector<vector<ll>>>&given, ll k,vector<vector<ll>>&dp){
//     if(k<=0)return 0;
//     if(i==given.size())return INT_MAX;
//     if(dp[i][k]!=-1)return dp[i][k];
//     ll ans = INT_MAX;
//     for(int x=0;x<given[i].size();++x){
//         ll curr = given[i][x][0] + solver(i+1,given,k-given[i][x][1],dp);
//         ans = min(ans, curr);
//     }
//     return dp[i][k] = ans;
// }

// void djikstra(ll start, vector<ll>&val, vector<ll>&dist, vector<vector<vector<ll>>>&grpah){
//     priority_queue<vector<ll>,vector<vector<ll>>, greater<vector<ll>>>pq;
//     pq.push({0,start,val[start]});
//     while(!pq.empty()){
//         ll currNode = pq.top()[1];
//         ll travelled = pq.top()[0];
//         bool horse = pq.top()[2] || val[currNode];
//         pq.pop();
//         for(int j=0;j<graph[currNode].size();++j){
//             ll nextNode = graph[currNode][j][0];
//             ll distance = graph[currNode][j][1];
//             if(travelled)distance/=2;
//             if(dist[nextNode] < travelled + distance){
//                 dist[nextNode] = travelled + distance;
//                 pq.push({dist[nextNode], nextNode, horse});
//             }
//         }
//     }
// }



void solve(ll l, ll r){
    ll a = l;
    ll b = 0;
    for(int i=28;i>=0;--i){
        if(b + (1<<i) > r)continue;
        else if(b + (1<<i) - 1 < l)b+=(1<<i);
        else{
            if((a ^ (1<<i))>a)b+=(1<<i);
            else continue;
        }
    }
    ll c = a;
    while(c==a || c==b)c++;
    cout<<a<<" "<<b<<" "<<c<<endl;
}



int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt", "r", stdin);
    //     freopen("out.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    // vector<ll>facts(1e6+1,1);
    // for(int i=2;i<=1e6;++i)facts[i]=2;
    // for(int i=3;i*i<=1e6;i+=2){
    //     if(facts[i]==i){
    //         for(int j=i*i;j<=1e6;j+=i){
    //             if(facts[j]==j)facts[j]=i;
    //         }
    //     }
    // }
    // 
    ll t;cin>>t;
    while(t--){
        ll l,r;cin>>l>>r;
        solve(l,r);
    }
    return 0;
}