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

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

void solve()
{
    int l, r;
    cin >> l >> r;

    for (int i = 30; i >= 0; i--)
    {
        // Find the first differing bit
        if (((l >> i) & 1) != ((r >> i) & 1))
        {
            int a = (1 << i);     // Only the i-th bit set
            a |= (l & ~((1 << i) - 1)); // Set the i-th bit and clear lower bits

            int b = a - 1;        // Previous number
            int c = -1;

            // Find a distinct `c` in range [l, r] that isn't `a` or `b`
            for (int j = l; j <= r; j++)
            {
                if (j != a && j != b)
                {
                    c = j;
                    break;
                }
            }

            // Print the result
            cout << a << " " << b << " " << c << endl;
            return;
        }
    }

    // If no differing bits are found
    cout << "-1 -1 -1" << endl;
}

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

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

    return 0;
}


Solution 2 (runtime: 62 ms):
#undef _GLIBCXX_DEBUG
#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;
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define debug(...)
#define debugArr(...)
#endif
#define ll long long
#define mod 1000000007
#define endl "\n"
#define pandeji "abhigyan"
#define Sum(a) accumulate(a.begin(),a.end(),0)
#define Sort(a) sort(a.begin(),a.end())
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,R,L) for (int i = R; i > L; i--)
#define FFE(i,R,L) for (int i = R; i >= L; i--)
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set_pair;
    
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        int l,r;
        cin>>l>>r;
        int a = r,b,c;
        int ans = 0;
        int msb = log2(r);
        bitset<30>bl(l);
        bitset<30>bt;
        bitset<30>br(r);
        FFE(i,msb,0){
            if(br[i]){
                bt.reset(i);
                if(bt.to_ulong() < l) bt.set(i);
            }
            else{
                bt.set(i);
            }
            if(bt.to_ulong() >= r) bt.reset(i);
        }
        b = bt.to_ulong();
        bool st = 0;
        FFE(i,msb,0){
            if(!br[i] && !bt[i]){
                st = 1;
                bl.set(i);
                if(bl.to_ulong() == b) bl.reset(i);
            }
            else{
                if(st) bl.reset(i);
                if(bl.to_ulong() == b){
                    st = 1;
                    bl.set(i);
                }
            }
            if(bl.to_ulong() < l) bl.set(i);
            if(bl.to_ulong() > r) bl.reset(i);
        }
        c = bl.to_ulong();
    
        cout<<a<<" "<<b<<" "<<c<<endl;
    }
    return 0;
}