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

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int le[31];
int re[31];
int third[31];
int main()
{int t;
    cin>>t;
    while(t--){int l,r;
    cin>>l>>r;
    int i=30;
    int point;
    for(int j=l;j>0;j=j/2){le[i]=j%2;i--;}
    i=30;
    for(int j=r;j>0;j=j/2){re[i]=j%2;i--;}
    for(int k=0;k<31;k=k+1){if(le[k]!=re[k]){point=k;break;}else third[k]=le[k];}
    int careful=0;
    for(int k=point;k<31;k=k+1)
    {if(careful==0){if(re[k]==1 && le[k]==0)third[k]=0;
      else  if(re[k]==0 )third[k]=1;
      else if(re[k]==1 && le[k]==1){re[k]=0;third[k]=1;careful=1;}}
      else{
        if(re[k]==0)third[k]=1;
        else third[k]=0;
      }}
      long long int num1,num2;
      int v=0;
      for(int i=0;i<31;i=i+1)if(v==0){if(re[i]==0)num1=0;else {num1=1;v=1;}}
      else {
        if(re[i]==0)num1*=2;else num1=num1*2+1;
      }
       v=0;
      for(int i=0;i<31;i=i+1)if(v==0){if(third[i]==0)num2=0;else {num2=1;v=1;}}
      else {
        if(third[i]==0)num2*=2;else num2=num2*2+1;
      }
cout<<num1<<' '<<num2<<' ';
for(int k=l;k<=r;k=k+1)if(k!=num1 && k!=num2){cout<<k<<endl;break;}
}}


Submission (verdict: Accepted):
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
#include <fstream>
#include <iostream>
using namespace std;
// using namespace chrono;
// using namespace __gnu_pbds;
string pi1 = "314159265358979323846264338327";
#define mod (int)(998244353)
#define pi 2*asin(1)
// Big two primes
#define _USE_MATH_DEFINES
#define X 1001100011100001111ll
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define int long long
#define ld long double
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define ll long long
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define tc(t) int t; cin >> t; while (t--)
#define pb push_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int>
#define fi first
#define se second
#define endl "\n"
#define vpp vector<pair<int,int>>
// #define ii pair<int, int>
#define vii vector<ii>
// #define sz(s) (int)((s).size())
#define bits(n) __builtin_popcount(n)
#define _USE_MATH_DEFINES
#define takein(arr,n) for(int i=0; i<n; i++){cin>>arr[i];}
#define p(x) cout<<x<<endl
#define re return
#define mod1 998244353
#define fr(i,a,b) for(int i = a;i < b;i++)
const int p1 = 1000000007;
string str = string(100, '0');
class DSU
{
    public:

        vector<ll> rank, parent, size;

        DSU(ll n)
        {
            rank.resize(n + 1, 0);
            parent.resize(n + 1);
            size.resize(n + 1, 1);

            for (ll i = 1; i <= n; i++) { parent[i] = i; }
        }

        void unionByRank(ll x, ll y)
        {
            ll par_x = findPar(x);
            ll par_y = findPar(y);

            if (par_x == par_y) { return; }

            if (rank[par_x] < rank[par_y])
            {
                parent[par_x] = par_y;
            }
            else
                if (rank[par_y] < rank[par_x])
                {
                    parent[par_y] = par_x;
                }
                else
                {
                    parent[par_x] = par_y;
                    rank[par_y]++;
                }
        }

        void unionBySize(ll x, ll y)
        {
            ll par_x = findPar(x);
            ll par_y = findPar(y);

            if (par_x == par_y) { return; }

            if (size[par_x] < size[par_y])
            {
                parent[par_x] = par_y;
                size[par_y] += size[par_x];
            }
            else
            {
                parent[par_y] = par_x;
                size[par_x] += size[par_y];
            }
        }

        ll findPar(ll x)
        {
            if (parent[x] != x) { parent[x] = findPar(parent[x]); }

            return parent[x];
        }

};

void transform(int& c, vector<int>& arr, int n)
{
    c = (c - arr[c] + n) % n;
}

const int MAXN = (int)((1e5) + 100);
void __print(int x)
{
    cerr << x;
}
void __print(unsigned x)
{
    cerr << x;
}
void __print(unsigned long x)
{
    cerr << x;
}
void __print(unsigned long long x)
{
    cerr << x;
}
void __print(float x)
{
    cerr << x;
}
void __print(double x)
{
    cerr << x;
}
void __print(long double x)
{
    cerr << x;
}
void __print(char x)
{
    cerr << '\'' << x << '\'';
}
void __print(const char* x)
{
    cerr << '\"' << x << '\"';
}
void __print(const string& x)
{
    cerr << '\"' << x << '\"';
}
void __print(bool x)
{
    cerr << (x ? "true" : "false");
}

template<typename T, typename V>
void __print(const pair<T, V>& x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template<typename T>
void __print(const T& x)
{
    int f = 0;
    cerr << '{';

    for (auto& i : x) { cerr << (f++ ? "," : ""), __print(i); }

    cerr << "}";
}
void _print()
{
    cerr << "]\n";
}
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);

    if (sizeof...(v)) { cerr << ", "; }

    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// ================================== take ip/op like vector,pairs directly!==================================
template<typename typC, typename typD> istream& operator>>(istream& cin,
        pair<typC, typD>& a)
{
    return cin >> a.first >> a.second;
}
template<typename typC> istream& operator>>(istream& cin, vector<typC>& a)
{
    for (auto& x : a) { cin >> x; }

    return cin;
}
template<typename typC, typename typD> ostream& operator<<(ostream& cout,
        const pair<typC, typD>& a)
{
    return cout << a.first << ' ' << a.second;
}
template<typename typC, typename typD> ostream& operator<<(ostream& cout,
        const vector<pair<typC, typD>>& a)
{
    for (auto& x : a) { cout << x << '\n'; }

    return cout;
}
template<typename typC> ostream& operator<<(ostream& cout,
        const vector<typC>& a)
{
    int n = a.size();

    if (!n) { return cout; }

    cout << a[0];

    for (int i = 1; i < n; i++) { cout << ' ' << a[i]; }

    return cout;
}
// ===================================END Of the input module ==========================================

int gcd(int a, int b) //Ecluid Algo
{
    if (a == 0) { return b; }

    return gcd(b % a, a);
}
int lcm(int a, int b)
{
    return (a / gcd(a, b)) * b;
}
int max(int a, int b)
{
    if (a > b) { return a; }
    else { return b; }
}
int min(int a, int b)
{
    if (a < b) { return a; }
    else { return b; }
}

int smallestPositiveDivisor(int n)
{
    for (int i = 2; i * i <= n; ++i)
    {
        if (n % i == 0) { return i; }
    }

    return 0;
}
int smallestPositiveDivisor1(int n, int a)
{
    for (int i = 2; i * i <= n; ++i)
    {
        if (n % i == 0 and i != a) { return i; }
    }

    return 0;
}

int get_hash(string s)
{
    int h = 0;

    for (auto i : s)
    {
        h = (h * 31 + (i - 'a' + 1)) % mod;
    }

    return h;
}

int binpow(int val, int deg, int m)
{
    if (!deg) { return 1 % m; }

    if (deg & 1) { return binpow(val, deg - 1, m) * val % m; }

    long long res = binpow(val , deg >> 1, m);
    return (res * res) % m;
}

int N1 = 1e6 + 1;
int spf[(int)(1e6 + 1)];
void Spf()  //Smallest Prime Factor and Check if it is prime or not
{
    for (int i = 2; i <= N1; i++) { spf[i] = i; }

    for (int i = 2; i * i <= N1; i++)
    {
        if (spf[i] != i) { continue; }

        for (int j = i * i; j <= N1; j += i)
        {
            if (spf[j] == j) { spf[j] = i; }
        }
    }
}

//finding the ncr
int fact[(int)(1e6 + 1)];

void facto() //o(nlog(mod))
{
    fact[0] = 1;
    for1(i, N1)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
}

int ncr(int n, int r)
{
    if (n == r) { return 1; }

    if (r > n) { return 0; }

    int numo = fact[n];
    int denoinv = (fact[r] * fact[n - r]) % mod;
    denoinv = binpow(denoinv, mod - 2, mod);
    return (numo * denoinv) % mod;
}

// standard input and output template
template<typename... T>
void in(T& ... args)
{
    ((cin >> args), ...);
}

template<typename... T>
void out(T&& ... args)
{
    ((cout << args << " "), ...);
}

template<typename... T>
void outl(T&& ... args)
{
    ((cout << args << endl), ...);
}
int complement(int m, int x)
{
    return (x - (m % x)) % x;
}


//find_by_order(k) : K-th element in a set (counting from zero), order_of_key (k) : Number of items strictly smaller than k
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
bool isPrime(int n)
{
    if (n <= 1)
    {
        return false;
    }

    if (n == 2) { return 1; }

    // Check from 2 to square root of n
    for (int i = 2; i <= sqrt(n); i++)
        if (n % i == 0)
        {
            return false;
        }

    return true;
}
void get2(vector<int>& a, vector<int>& b, map<int, int>& mp, int& ans, int& n,
          int& m, int f, int s, int& n1)
{
    int bp = min(s, m / f);
    int rm = m - bp * f;
    int bn = 0;

    if (n1 > 0)
    {
        bn = min(n1, rm / (f + 1));
        rm -= bn * (f + 1);
    }

    // get3(a, b, mp, ans, n, m, f, s, n1, rm, bn, bp);
}
int cbrt(int x)
{
    int lo = 1, hi = min(2000000ll, x);

    while (hi - lo > 1)
    {
        int mid = (lo + hi) / 2;

        if (mid * mid * mid < x)
        {
            lo = mid;
        }
        else { hi = mid; }
    }

    if (hi * hi * hi <= x) { return hi; }
    else { return lo; }
}

const int dx[4] = { -1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int N = (int)(5 * 1e5 + 10);
const int maxsize = N;
//vector<int>adj[N];
int fen[10];


// Function to update any index
void update(int ind, int val)
{
    for (int i = ind; i < maxsize; i += i & -i)
    {
        fen[i] += val;
    }
}


//ternary search
void getTer()
{
    auto f = [](double x) -> double
    {
        return -x * x + 2 * x + 4;
    };
    const double EPS = 1e-9;
    double l = 0, r = 1e9;

    while (r - l > EPS)
    {
        double m1 = l + (r - l) / 3;
        double m2 = r - (r - l) / 3;

        if (f(m1) < f(m2)) { l = m1; }
        else { r = m2; }
    }

    p(l);
}

// Function to get the prefix sum or suffix sum
int sum(int ind)
{
    int ans = 0;

    for (int i = ind; i > 0 ; i -= i & -i)
    {
        ans += fen[i];
    }

    return ans;
}

int getMinElements(vector<int> arr, int k)
{
    // sort(all(arr));
    int n = arr.size();
    int l = 0, r = n - 1, cnt = 0;

    while (l <= r)
    {
        int mid = (l + r) / 2;

        if (arr[mid] <= k)
        {
            cnt = mid + 1;
            l = mid + 1;
        }
        else
        {
            r = mid - 1;
        }
    }

    return cnt;
}

int getDivisors(int n)
{
    int cnt = 0;

    for (int i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            cnt++;
            n /= i;
        }
    }

    if (n > 1) { cnt++; }

    return cnt;
}
bool isPower(int n)
{
    while (n > 1 && n % 2 == 0)
    {
        n /= 2;
    }

    return n == 1;
}
bool isDec(vector<int>& arr)
{
    for (int i = 1; i < arr.size(); i++)
    {
        if (arr[i - 1] <= arr[i])
        {
            return false;
        }
    }

    return true;
}

bool check_perfect_cube(int x)
{
    int tmp = cbrt(x);

    while (tmp * tmp * tmp > x)
    {
        tmp--;
    }

    while (tmp * tmp * tmp < x)
    {
        tmp++;
    }

    if (tmp * tmp * tmp == x)
    {
        return true;
    }

    return false;
}
int getMaxElements(vector<int> arr, int k)
{
    //sort(all(arr), greater<int>());
    int n = arr.size();
    int l = 0, r = n - 1, cnt = 0;

    while (l <= r)
    {
        int mid = (l + r) / 2;

        if (arr[mid] >= k)
        {
            cnt = mid + 1;
            l = mid + 1;
        }
        else
        {
            r = mid - 1;
        }
    }

    return cnt;
}
void get(string& s, int& n, int& cnt, vector<int>& p1, vector<int>& dp)
{
    for1(j, n)
    {
        dp[p1[j - 1] + n] = (dp[p1[j - 1] + n] % mod + j % mod) % mod;
        cnt = (cnt % mod + (dp[p1[j] + n] * (n - j + 1)) % mod) % mod;
    }
}
int modInverse(int A, int M)
{
    int m0 = M;
    int y = 0, x = 1;

    if (M == 1)
    {
        return 0;
    }

    while (A > 1)
    {
        int q = A / M;
        int t = M;
        M = A % M, A = t;
        t = y;
        y = x - q * y;
        x = t;
    }

    if (x < 0)
    {
        x += m0;
    }

    return x;
}

void getDivisors(int n, vector<int>& a)
{
    for (int i = 1; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            if (n / i == i)
            {
                a.pb(i);
            }
            else
            {
                a.pb(i);
                a.pb(n / i);
            }
        }
    }

    sort(all(a));
}
void division(int a, int b)
{
    // e ^ ln(x) = x;
    // a/b = e ^ ln(a) / e ^ ln(b);
    // a/b = e ^ (ln(a) - ln(b));
    int isNagative = (a < 0) ^ (b < 0);
    a = abs(a);
    b = abs(b);
    int ans = exp(log(a) - log(b)) + 0.0000001;

    if (isNagative) { ans = ~ans + 1; }

    cout << ans << endl;
}
void swapMsbToLsb(int n)
{
    // case 1 -> it both bits are 1 then the answer remains same
    // case 2 -> if MSB is 1 and LSB is 0 -> 000101 => n = n - (1<<MSB) + 1
    int LSB = n & 1;

    if (LSB)
    {
        p(n);
        re;
    }

    int posMsb = (int)log2(n);
    n = n - (1 << posMsb) + 1;
    p(n);
}
/*
                                            Main code:)
    ---------------------------------------------------------------------------------------------------------
*/

void solve()
{
    int l,r;
    cin>>l>>r;
    int prev = 0;
    for(int i=30; i>=0; i--){
        if((l & (1<<i)) ^ (r & (1<<i))){
            int a = prev + (1<<i);
            int b = a-1;
            int c = b-1;
            if(a+1 <= r) c = a+1;
            cout<<a<<" "<<b<<" "<<c<<endl;
            re;
        }
        else{
            prev += (l & (1<<i));
        }
    }
}

signed main()
{
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    fio;
    // Spf();
    // facto();
    srand(time(NULL));
    int t = 1;
    cin >> t;

    while (t--)
    {
        //cout << "test-> " << t << endl;
        solve();
    }
}