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

Previous submission (verdict: Wrong answer on test 1):
#include <bits\stdc++.h>

using namespace std;
typedef long long ll;

ll binary_to_ll(string s){
    ll n = 0;
    for (int i = 0; i < s.size(); i++)
    {
        n *= 2;
        n += (s[i]-'0');
    }
    return n;
}


int main(void){
    // ios::sync_with_stdio(false), cin.tie(nullptr);
    int t; cin >> t;
    while (t--)
    {
        ll l,r; cin >> l >> r;
        if(l-r == 2){
            cout << l << " " << l+1 << " " << l+2 << endl;
            continue;
        }
        ll a=r-2,b=r-1,c=r;
        string temp = bitset<64>(r).to_string();
        int size = 64-temp.find('1');
        string masked = string(size,'0');
        // for (int i = l; i <= r; i++)
        // {
        //     cout << i << ": " << bitset<64>(i).to_string() << endl;
        // }

        string l_str = bitset<64>(r).to_string();
        string r_str = bitset<64>(l).to_string();

        int distinct_bit = 0;
        string a_Str = "";
        for (int i = 0; i < 64; i++)
        {
            if(l_str[i] != r_str[i]){
                distinct_bit = i;
                break;
            }else{
                a_Str += l_str[i];
            }
        }

        a = binary_to_ll(a_Str+"0"+string(63-distinct_bit,'1'));
        b = a+1;
        if(min(r,a+b) != b){
            c = min(r,a+b);
        }else{
            c = max(l,1LL);
        }


        // for (int i = 0; i < masked.size(); i++)
        // {
        //     masked[i] = '1';
        //     ll toFind = binary_to_ll(masked);
        //     if(toFind <= r && toFind >= l+2){
        //         a = toFind;
        //         b = a-1;
        //         c = a-2;
        //         break;
        //     }
        // }
        // cout << "?" << (a^b)+(b^c)+(c^a) << endl;
        // ll a1[3];
        // for (int i = 0; i < 3; i++)
        // {
        //     cin >> a1[i];
        // }
        // cout << "?" << (a1[0]^a1[1])+(a1[2]^a1[1])+(a1[2]^a1[0]) << endl;
        cout << a << " " << b << " " << c << " \n";
    }
    return 0;
}
// auto print = [](std::ostream& os, auto... args) {
// ((os << args << " "), ...) << std::endl; // Fold expression
// };
// print(std::cout, a, b, c);

/*

i want to find three numbers such that most of their bits don't match, right? yes!

let's try this with only 2 numbers

0 and 8


0001
0010
0011

0100
0101
0110
0111
1000

0 and 8 will give me the highest xor if only two numbers are to be considered

0 and 8, the other highest needs to be considered now


a*(b+c) + b*c - this wont work


*/

Submission (verdict: Accepted):
#include <bits\stdc++.h>

using namespace std;
typedef long long ll;

ll binary_to_ll(string s){
    ll n = 0;
    for (int i = 0; i < s.size(); i++)
    {
        n *= 2;
        n += (s[i]-'0');
    }
    return n;
}


int main(void){
    // ios::sync_with_stdio(false), cin.tie(nullptr);
    int t; cin >> t;
    while (t--)
    {
        ll l,r; cin >> l >> r;
        if(r-l == 2){
            cout << l << " " << l+1 << " " << l+2 << endl;
            continue;
        }
        ll a=r-2,b=r-1,c=r;
        string temp = bitset<64>(r).to_string();
        int size = 64-temp.find('1');
        string masked = string(size,'0');
        // for (int i = l; i <= r; i++)
        // {
        //     cout << i << ": " << bitset<64>(i).to_string() << endl;
        // }

        string l_str = bitset<64>(r).to_string();
        string r_str = bitset<64>(l).to_string();

        int distinct_bit = 0;
        string a_Str = "";
        for (int i = 0; i < 64; i++)
        {
            if(l_str[i] != r_str[i]){
                distinct_bit = i;
                break;
            }else{
                a_Str += l_str[i];
            }
        }

        a = binary_to_ll(a_Str+"0"+string(63-distinct_bit,'1'));
        b = a+1;
        if(min(r,a+b) != b){
            c = min(r,a+b);
        }else{
            c = max(l,1LL);
        }


        // for (int i = 0; i < masked.size(); i++)
        // {
        //     masked[i] = '1';
        //     ll toFind = binary_to_ll(masked);
        //     if(toFind <= r && toFind >= l+2){
        //         a = toFind;
        //         b = a-1;
        //         c = a-2;
        //         break;
        //     }
        // }
        // cout << "?" << (a^b)+(b^c)+(c^a) << endl;
        // ll a1[3];
        // for (int i = 0; i < 3; i++)
        // {
        //     cin >> a1[i];
        // }
        // cout << "?" << (a1[0]^a1[1])+(a1[2]^a1[1])+(a1[2]^a1[0]) << endl;
        cout << a << " " << b << " " << c << " \n";
    }
    return 0;
}
// auto print = [](std::ostream& os, auto... args) {
// ((os << args << " "), ...) << std::endl; // Fold expression
// };
// print(std::cout, a, b, c);

/*

i want to find three numbers such that most of their bits don't match, right? yes!

let's try this with only 2 numbers

0 and 8


0001
0010
0011

0100
0101
0110
0111
1000

0 and 8 will give me the highest xor if only two numbers are to be considered

0 and 8, the other highest needs to be considered now


a*(b+c) + b*c - this wont work


*/