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

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define print(vec) for(auto &x : vec) {cout << x << ' ';} cout << endl;
const ll mod = 998244353;
using namespace std;

// Function to calculate XOR sum
ll so(ll a, ll b, ll c) {
    return (a ^ b) + (a ^ c) + (b ^ c);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll t;
    cin >> t;
    
    while (t--) {
        ll n, m;
        cin >> n >> m;

        ll bestXor = LLONG_MIN;
        vll ans(3);

        ll l = n, r = m;

        while (r - l > 1) {
            ll mid = l + (r - l) / 2;

            ll xorMid = so(n, mid, m);
            if (xorMid > bestXor) {
                bestXor = xorMid;
                ans = {n, mid, m};
            }

            if (so(n, mid + 1, m) >= so(n, mid , m)) {
                l = mid;
            } else if (so(n, mid - 1, m) >= so(n, mid , m)){
                r = mid;
            }
            else{
                break;
            }
        }

        print(ans);
    }
    
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define t(ok) ok?cout<< YES<<endl:cout<<NO<<endl;
#define vll vector<long long>
#define vpll vector <pair<ll,ll>>
#define mll map<long long, long long>
#define all(x) x.begin(), x.end()
#define forn(i,n) for(int i = 0; i < n; i++)
#define mii map<int, int>
#define vc vector<char>
#define py cout << "YES" << endl
#define pn cout << "NO" << endl
#define vb vector<bool>
#define invec for (int i=0;i<n;i++) {cin>>v[i];} 
#define print_arr(vec, sz) for(int zwzq = 0; zwzq < sz ; zwzq++){cout << vec[zwzq] << ' ';}cout << endl;
#define fori(i, a, c) for(int i = a ; i < c ; i++)
#define ford(i, n, a) for (int i = n ; i >= a ; i--)
#define print(vec) for(int zwzq = 0; zwzq < vec.size() ; zwzq++){cout << vec[zwzq] << ' ';}cout << endl;
#define print_pair(vec) for(int zwzq = 0; zwzq < vec.size() ; zwzq++){cout << '[' <<vec[zwzq].first << ',' << vec[zwzq].second << ']' << ' ';}cout << endl;
const ll mod = 998244353;
using namespace std;
long long mod_sub(long long a, long long b, long long m){a = a % m; b = b % m;return (((a - b) % m) + m) % m;}
long long powermod(long long x, long long y, long long p){
    long long res = 1;
    x = x % p;
    if (x == 0){return 0;}
    while (y > 0){
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
   return res;
}
ll convert_to_binary (string a){
    ll ans =0LL;
    for ( int i=30;i>=0;i--){
        if (a[i]=='1'){
            ans += pow(2,30-i);
        }
    }
    return ans;
}

//for first see soln,for second try reverse or smaller optimal method, BIT question write one or two example in bit then solve
int main(){

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    ll t;
    cin >> t;
    while (t--){


ll n, m;
    cin  >> n >> m;
    ll nnn,mmm;
    nnn = n;
    mmm = m;
    string nn="";
    string mm="";
    for ( int i=0;i<31;i++){
        if (n&1){
            nn += '1';
        }
        else{nn += '0';}
        if (m&1){
            mm += '1';
        }
        else{mm += '0';}
        n = n/2;
        m = m/2;
    }
    reverse(all(nn));
    reverse(all(mm));
    // cout<<nn<<" "<<mm<<endl;
    string a,b;
    bool done = false;
    for (int i=0;i<mm.size();i++){
        if (done){
            a += '1';
            b += '0';
        }
        else if (nn[i]==mm[i]){
            a += nn[i];
            b += mm[i];
        }
        else{
            b += '1';
            a += '0';
            done = true;
        }
        
    }
        ll c ;
        for ( ll i = nnn;i<=mmm;i++){
            if (i!=convert_to_binary(a) && i!=convert_to_binary(b)){
                c=i;break;
            }
        }
        cout<<convert_to_binary(a)<<" "<<c<<" "<<convert_to_binary(b)<<endl;

    }
    return 0;
}