Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

#define zeeldadhaniya1895               \
    ios_base::sync_with_stdio(0);       \
    cin.tie(0);                         \
    cout.tie(0);

// Define types
#define int long long int
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double

// Input macros
#define ii(n) \
    int n;    \
    cin >> n;
#define iarr(arr, n)           \
    int arr[n];                 \
    for (int i = 0; i < n; i++) \
        cin >> arr[i];
#define oarr(arr, n)          \
    for (int i = 0; i < n; i++) \
        cout << arr[i] << " ";
#define ivec(v, n)          \
    vi v(n);                    \
    for (int i = 0; i < n; i++) \
        cin >> v[i];

// Vector macros
#define vec(T) vector<T>
#define veci vector<int>
#define vecll vector<ll>
#define vecs vector<string>
#define vecveci vector<vector<int>>
#define vecvecll vector<vector<ll>>
#define vecvecs vector<vector<string>>

// Pair macros
#define p(A, B) pair<A, B>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define ff first
#define ss second

// Push-Pop macros
#define pb push_back
#define pf push_front
#define pob pop_back

// Loop macros
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define loop(i, in, n) for (int i = in; i < n; i++)
#define loopr(i, in, n) for (int i = in; i >= n; i--)
#define loopll(i, in, n) for (ll i = in; i < n; i++)

// Unique all
#define makeUnique(c) c.resize(unique(all(c)) - c.begin())

// Cout macros
#define check(n, k) cout << n << " " << k << endl;

// Short-Cuts
#define endl "\n"
#define p0(x) cout << (x) << " "
#define i1(A, a) \
    A a;         \
    cin >> a
#define i2(A, a, b) \
    A a, b;         \
    cin >> a >> b
#define i3(A, a, b, c) \
    A a, b, c;         \
    cin >> a >> b >> c
#define i4(A, a, b, c, d) \
    A a, b, c, d;         \
    cin >> a >> b >> c >> d
#define i5(A, a, b, c, d, e) \
    A a, b, c, d, e;         \
    cin >> a >> b >> c >> d >> e
#define i6(A, a, b, c, d, e, f) \
    A a, b, c, d, e, f;         \
    cin >> a >> b >> c >> d >> e >> f


// Extra macros
#define MOD 1000000007
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define TESTS     \
    long long t; \
    cin >> t;    \
    while (t--)
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
#define EPS 1e-9
#define inf 1e18

// All 8 neighbours
int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[8] = {0, 0, 1, -1, 1, -1, 1, -1};

int invertBits(int k) {
    int mask = 0;
    while (k > 0) {
       mask = (mask << 1) | 1;
       k--;
    }
    return mask;
}

void solve()
{
    int l,r;
    cin >> l >> r;
    int k=32;
    while(k--)
    {int p=(1<<k)&l;
    int q=(1<<k)&r;
        if(p!=q)
        {
            break;
        }
    }
    int x=l&((1<<k+1)-1);
    int y=r&(1<<k+1)-1;
    int z=l>>k+1;
    z=z<<k+1;
if(k+1==2){cout<<l<<" "<<l+1<<" "<<r<<endl;return;}
    int mask=invertBits(k+1);

    if(((~x)&mask)==y)
    {//cout<<1<<endl;
        cout<<l<<" "<<l+1<<" "<<r<<endl;
    }
    else if((((~y)&mask)|z)<l)
     {//cout<<2<<endl;
    //     cout<<mask<<endl;
        cout<<l<<" "<<l+1<<" "<<(((~x)&mask)|z)<<endl;
    }
    else
    {//cout<<3<<endl;
        cout<<r<<" "<<(((~y)&mask)|z)<<" "<<(((~y)&mask)|z)+1<<endl;
    }
}

signed main()
{
    zeeldadhaniya1895

     TESTS  
    {
        solve();
    }

    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

#define zeeldadhaniya1895               \
    ios_base::sync_with_stdio(0);       \
    cin.tie(0);                         \
    cout.tie(0);

// Define types
#define int long long int
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double

// Input macros
#define ii(n) \
    int n;    \
    cin >> n;
#define iarr(arr, n)           \
    int arr[n];                 \
    for (int i = 0; i < n; i++) \
        cin >> arr[i];
#define oarr(arr, n)          \
    for (int i = 0; i < n; i++) \
        cout << arr[i] << " ";
#define ivec(v, n)          \
    vi v(n);                    \
    for (int i = 0; i < n; i++) \
        cin >> v[i];

// Vector macros
#define vec(T) vector<T>
#define veci vector<int>
#define vecll vector<ll>
#define vecs vector<string>
#define vecveci vector<vector<int>>
#define vecvecll vector<vector<ll>>
#define vecvecs vector<vector<string>>

// Pair macros
#define p(A, B) pair<A, B>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define ff first
#define ss second

// Push-Pop macros
#define pb push_back
#define pf push_front
#define pob pop_back

// Loop macros
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define loop(i, in, n) for (int i = in; i < n; i++)
#define loopr(i, in, n) for (int i = in; i >= n; i--)
#define loopll(i, in, n) for (ll i = in; i < n; i++)

// Unique all
#define makeUnique(c) c.resize(unique(all(c)) - c.begin())

// Cout macros
#define check(n, k) cout << n << " " << k << endl;

// Short-Cuts
#define endl "\n"
#define p0(x) cout << (x) << " "
#define i1(A, a) \
    A a;         \
    cin >> a
#define i2(A, a, b) \
    A a, b;         \
    cin >> a >> b
#define i3(A, a, b, c) \
    A a, b, c;         \
    cin >> a >> b >> c
#define i4(A, a, b, c, d) \
    A a, b, c, d;         \
    cin >> a >> b >> c >> d
#define i5(A, a, b, c, d, e) \
    A a, b, c, d, e;         \
    cin >> a >> b >> c >> d >> e
#define i6(A, a, b, c, d, e, f) \
    A a, b, c, d, e, f;         \
    cin >> a >> b >> c >> d >> e >> f


// Extra macros
#define MOD 1000000007
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define TESTS     \
    long long t; \
    cin >> t;    \
    while (t--)
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
#define EPS 1e-9
#define inf 1e18

// All 8 neighbours
int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[8] = {0, 0, 1, -1, 1, -1, 1, -1};

int invertBits(int k) {
    int mask = 0;
    while (k > 0) {
       mask = (mask << 1) | 1;
       k--;
    }
    return mask;
}

void solve()
{
    int l,r;
    cin >> l >> r;
    int k=32;
    while(k--)
    {int p=(1<<k)&l;
    int q=(1<<k)&r;
        if(p!=q)
        {
            break;
        }
    }
    int x=l&((1<<k+1)-1);
    int y=r&(1<<k+1)-1;
    int z=l>>k+1;
    z=z<<k+1;
if(k+1==2){cout<<l<<" "<<l+1<<" "<<r<<endl;return;}
    int mask=invertBits(k+1);

    if(((~x)&mask)==y)
    {
        // cout<<1<<endl;
        cout<<l<<" "<<l+1<<" "<<r<<endl;
    }
    else if((((~y)&mask)|z)<l)
    {
    //  cout<<2<<endl;
    //  cout<<mask<<endl;
        cout<<l<<" "<<l+1<<" "<<(((~x)&mask)|z)<<endl;
    }
    else
    {
        // cout<<3<<endl;
        // cout<<mask<<endl;   
        cout<<r<<" "<<(((~y)&mask)|z)<<" "<<(((~y)&mask)|z)-1<<endl;
    }
}

signed main()
{
    zeeldadhaniya1895

     TESTS  
    {
        solve();
    }

    return 0;
}