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 lli long long int
int main()
{
    lli t;
    cin >> t;
    while (t--)
    {
        lli left, right;
        cin >> left >> right;
        // if leading_zeros_left==leading_zeros_right-->choose one number as first odd second number as right and greedy approach to choose third
        // else -->first number as (set bit 1 after min leading zeros and all zeros after that ->and seoond num as first-1 and greedy to choose third)
        // cout << __builtin_clzll(left) << " " << __builtin_clzll(right) << endl;
        if (__builtin_clzll(left) == __builtin_clzll(right))
        {
            lli first_difference = __builtin_clzll(left ^ right);
            bitset<64> b;
            b[63 - first_difference] = 1;
            bitset<64> b1(left);
            b = (b) | (b1);
            lli first = b.to_ullong();
            lli second = first - 1;
            lli third;
            if (first == left)
            {
                third = right;
            }
            else
            {
                third = left;
            }
            cout << first << " " << second << " " << third << endl;
        
        }
        else
        {
            lli max_leading = __builtin_clzll(right);
            bitset<64> b;
            b[63 - max_leading] = 1;
            lli first = b.to_ullong();
            lli second = first - 1;
            lli maxi = -1;
            lli third;
            for (lli i = left; i <= right; i++)
            {
                if (i != first && i != second)
                {
                    if (((first ^ i) + (second ^ i)) > maxi)
                    {
                        maxi = (first ^ i) + (second ^ i);
                        third = i;
                        break;
                    }
                }
            }
            cout << first << " " << second << " " << third << endl;
        }
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
    lli t;
    cin >> t;
    while (t--)
    {
        lli left, right;
        cin >> left >> right;
        // if leading_zeros_left==leading_zeros_right-->choose one number as first odd second number as right and greedy approach to choose third
        // else -->first number as (set bit 1 after min leading zeros and all zeros after that ->and seoond num as first-1 and greedy to choose third)
        // cout << __builtin_clzll(left) << " " << __builtin_clzll(right) << endl;
        if (__builtin_clzll(left) == __builtin_clzll(right))
        {
            // cout << "came here" << endl;
            lli first_difference = __builtin_clzll(left ^ right);
            bitset<64> b(left);
            b[63 - first_difference] = 1;
            for (lli i = 0; i < 63 - first_difference; i++)
            {
                b[i] = 0;
            }
            bitset<64> b1(left);
            for (lli i = 0; i < 63 - first_difference; i++)
            {
                b1[i] = 1;
            }
            b1[63 - first_difference] = 0;
            lli first = b.to_ullong();
            lli second = b1.to_ullong();
            lli third;
            for (lli i = left; i <= right; i++)
            {
                if (i != first && i != second)
                {
                    third = i;
                    break;
                }
            }
            cout << first << " " << second << " " << third << endl;
        }
        else
        {
            lli max_leading = __builtin_clzll(right);
            bitset<64> b;
            b[63 - max_leading] = 1;
            lli first = b.to_ullong();
            lli second = first - 1;
            lli maxi = -1;
            lli third;
            for (lli i = left; i <= right; i++)
            {
                if (i != first && i != second)
                {
                    if (((first ^ i) + (second ^ i)) > maxi)
                    {
                        maxi = (first ^ i) + (second ^ i);
                        third = i;
                        break;
                    }
                }
            }
            cout << first << " " << second << " " << third << endl;
        }
    }
}