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

Solution 1 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int T, l, r;
void solve() {
    cin >> l >> r;
    bitset <32> x(l), y(r), ans(0);
    int tp = 31;
    for (; ~tp; tp --) if (x[tp] ^ y[tp]) break;
    for (int i = 31; i > tp; i --) ans[i] = x[i];
    for (int i = tp; ~i; i --) {
        if (!(x[i] ^ y[i])) ans[i] = x[i] ^ 1;
    }
    for (int i = tp; ~i; i --) {
        if (x[i] ^ y[i]) {
            ans[i] = 1;
            if (ans.to_ulong() >= y.to_ulong()) ans[i] = 0;
        }
    }
    int a = x.to_ulong(), b = ans.to_ulong(), c = y.to_ulong();
    cout << a << ' ' << b << ' ' << c << '\n';
}
int32_t main() {
    cin.tie(NULL) -> sync_with_stdio(false);
    for (cin >> T; T --; ) solve();
    return 0;
}

Solution 2 (runtime: 62 ms):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
int const mod = 1e9 + 7; // 998244353
#define setbits(x) __builtin_popcountll(x)
#define msb(x) (63 - __builtin_clzll(x))
#define lsb(x) (__builtin_ffsll(x) - 1)
#define f(i, n) for (int i = 0; i < n; i++)
#define f1(i, n) for (int i = 1; i <= n; i++)
const long double eps = 1e-9;
long double pie = 3.14159265358979323846264338327950;
#define ff first;
#define ss second;
#define fsort(v) sort(v.begin(), v.end())
#define rsort(v) sort(v.begin(), v.end(), greater<int>())
#define rev(v) reverse(v.begin(), v.end())
#define max_ele(v) *max_element(v.begin(), v.end())
#define min_ele(v) *min_element(v.begin(), v.end())

/*----------------------------------------------------------------------------------------------*/

int hcf(int a, int b)
{
    if (a % b == 0)
        return b;
    return hcf(b, a % b);
}

int lcm(int a, int b)
{
    return (a * b) / (hcf(a, b));
}

/*----------------------------------------------------------------------------------------------*/
/*  DSU  */

class DSU
{
    vector<int> par, sz;

public:
    DSU(int n)
    {
        par.resize(n + 1);
        sz.resize(n + 1, 1);
        for (int i = 0; i <= n; i++)
            par[i] = i;
    }

    int findUpar(int node)
    {
        if (par[node] == node)
            return node;
        return par[node] = findUpar(par[node]);
    }

    void unionbysize(int u, int v)
    {
        int upar_u = findUpar(u);
        int upar_v = findUpar(v);
        if (upar_u == upar_v)
            return;
        if (sz[upar_u] >= sz[upar_v])
        {
            par[upar_v] = upar_u;
            sz[upar_u] += sz[upar_v];
        }
        else
        {
            par[upar_u] = upar_v;
            sz[upar_v] += sz[upar_u];
        }
    }
};

/*----------------------------------------------------------------------------------------------*/

int binexp(int a, int b)
{
    if (b == 0)
        return 1;
    int res = binexp(a, b / 2);
    if (b % 2 == 0)
        return res * res;
    else
        return res * res * a;
}

int binexpm(int a, int b, int M)
{
    if (b == 0)
        return 1;
    int res = binexpm(a, b / 2, M);
    if (b % 2 == 0)
        return ((res % M) * (res % M)) % M;
    else
        return (((res % M) * (res % M) % M) * (a % M)) % M;
}

/*----------------------------------------------------------------------------------------------*/
// for ncr and factorial with modulo M
// const int N1=3*1e5;
// int fact[N1+1];
// int inv[N1+1];
// int ncr(int n, int r){
//     if(r>n) return 0;
//     int temp = fact[n];
//     temp = (temp*inv[r]) % mod;
//     temp = (temp*inv[n-r]) % mod;
//     return temp;
// }
/*----------------------------------------------------------------------------------------------*/

int32_t main()
{

    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // Sieve approach:

    // int N=1e6;
    // int spf[N+1];
    // f(i,N+1) spf[i]=i;
    // for(int i=2;i<N+1;i++){
    //     if(spf[i]==i){
    //         for(int j=i*i;j<N+1;j+=i){
    //            if(spf[j] == j) spf[j]=i;
    //         }
    //     }
    // }

    // int N=1e6;
    // bool isprime[N+1];
    // isprime[0]=0;
    // isprime[1]=0;
    // for(int i=2; i*i<=N; i++)
    // {
    //   if(isprime[i]==1){
    //      for(int j=i*i; j<=N; j+=i)
    //        {
    //           isprime[j]=0;
    //        }
    //    }
    //}

    // vector<int> primes;
    // for(int i=2;i<N+1;i++) if(isprime[i]) primes.push_back(i);

    // fact[0]=1;
    // f1(i,N1) fact[i] = (fact[i-1]*i) % mod;
    // f(i,N1+1) inv[i] = binexpm(fact[i], mod-2, mod);

    /* Code Starts here */

    /*
            be carefull at the time of coding.......
                first think what's your logic.......
                    keep in mind about time complexity and keep patience.....
                        patience is more important than your practice........
    */
    int t;
    cin >> t;
    while (t--)
    {
        int l, r;
        cin >> l >> r;
        int a = 0, b = 0, c = 0;
        int ans = 0;
        for (int i = 30; i >= 0; i--)
        {
            bool flag1 = 0, flag2 = 0;
            if (r & (1ll << i))
            {
                flag1 = 1;
            }
            if (l & (1ll << i))
            {
                flag2 = 1;
            }
            if (flag1 == flag2)
            {
                ans += flag1 * (1ll << i);
            }
            else
            {
                ans += (1ll << i);
                a = ans;
                b = a - 1;
                break;
            }
        }
        for (int i = l; i <= r; i++)
        {
            if (i != a && i != b)
            {
                c = i;
                break;
            }
        }
        cout << a << ' ' << b << ' ' << c << '\n';
    }
    return 0;
}