Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
/*
 ---------------------------------------
( If you don't fail at least 90% of the )
( time, you're not aiming high enough.  )
(                                       )
( - Alan Kay                            )
 ---------------------------------------
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set_increasing1 tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set_increasing2 tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set_decreasing1 tree<int, null_type,greater<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_set_decreasing2 tree<int, null_type,greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define               ff      first
#define               ss      second
#define cost (ll)1000000000000
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
typedef long long ll;
typedef   vector <int> vi;
typedef   vector <long long int> vl;

constexpr int mod = 1000000007;
constexpr int inf = 1E9;
long long fac[200005], finv[200005], inv[200005];

void COMinit() // need to call from main function
{
    fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
    for (int i = 2; i < 200005; i++)
    {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

long long COM(int n, int k)
{
    if (n < k) return 0;
    if (n < 0 | k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int countDigit(long long n) {
  return floor(log10(n) + 1);
}
ll check_power_of_two(ll x)
{
    bool px;
    px = (x&(x-1));
    return px; // px =0, yes; otherwise no
}
//::::::::::::::::::::::::::::::::::::::::::::

/*

0. First of all, look at the given constrain
1. Think Greedy
2. Think Brute Force
3. Think solution in reverse order
4. precompute in main function
5. binary search
6. Think DP [ check constraints carefully ]
7. Check base cases for DP and prove solution for Greedy
8. Think Graph
9. priority_queue<ll>a
10. multiset<ll>
*/

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

    ll k = l ^ r;

    ll a =0, b=0, c=0;

    bool f=0;

    for(ll i= 29; i>=0; i--)
    {
        if(f)
        {
            b += 1ll*(1<<i);
            continue;
        }
        if((k >> i)&1)
        {
            f=1;
            a += 1ll*(1<<i);
        }
        else
        {
            if((l>>i)&1)
            {
                ll m = 1 <<i;
                a += m;
                b += m;
                c += m;
            }
        }
    }
    cout << a << ' ' << b << ' ' << c << endl;
}
int main()
{
    ll t;
    cin >> t;
    while(t--)
        solve();
}




Submission (verdict: Accepted):
/*
 ---------------------------------------
( If you don't fail at least 90% of the )
( time, you're not aiming high enough.  )
(                                       )
( - Alan Kay                            )
 ---------------------------------------
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set_increasing1 tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set_increasing2 tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set_decreasing1 tree<int, null_type,greater<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_set_decreasing2 tree<int, null_type,greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define               ff      first
#define               ss      second
#define cost (ll)1000000000000
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
typedef long long ll;
typedef   vector <int> vi;
typedef   vector <long long int> vl;

constexpr int mod = 1000000007;
constexpr int inf = 1E9;
long long fac[200005], finv[200005], inv[200005];

void COMinit() // need to call from main function
{
    fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
    for (int i = 2; i < 200005; i++)
    {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

long long COM(int n, int k)
{
    if (n < k) return 0;
    if (n < 0 | k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int countDigit(long long n) {
  return floor(log10(n) + 1);
}
ll check_power_of_two(ll x)
{
    bool px;
    px = (x&(x-1));
    return px; // px =0, yes; otherwise no
}
//::::::::::::::::::::::::::::::::::::::::::::

/*

0. First of all, look at the given constrain
1. Think Greedy
2. Think Brute Force
3. Think solution in reverse order
4. precompute in main function
5. binary search
6. Think DP [ check constraints carefully ]
7. Check base cases for DP and prove solution for Greedy
8. Think Graph
9. priority_queue<ll>a
10. multiset<ll>
*/

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

    ll k = l ^ r;

    ll a =0, b=0, c=0;

    bool f=0;

    for(ll i= 29; i>=0; i--)
    {
        if(f)
        {
            b += 1ll*(1<<i);
            continue;
        }
        if((k >> i)&1)
        {
            f=1;
            a += 1ll*(1<<i);
        }
        else
        {
            if((l>>i)&1)
            {
                ll m = 1 <<i;
                a += m;
                b += m;
            }
        }
    }
    for(ll i=l; i<=r; i++)
    {
        if(i != a && i != b)
        {
            c = i;
            break;
        }
    }
    cout << a << ' ' << b << ' ' << c << endl;
}
int main()
{
    ll t;
    cin >> t;
    while(t--)
        solve();
}