Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 124 ms):
#include<bits/stdc++.h>
using namespace std;

int tim , here;
long long two[31] , l , r , arr[2][31] , ans , uno , dos , tres , lol;

int main() {
   // std::ios::sync_with_stdio(false);
   // std::cin.tie(nullptr);
    two[0] = 1;
    for( int z = 1; z <= 30; z++ ) {
        two[z] = two[z - 1] * (long long)2;
    }
    cin >> tim;
    for( int p = 0; p < tim; p++ ) {
        cin >> l >> r;
        lol = l;
        for( int z = 30; z >= 0; z-- ) {
            arr[0][z] = 0;
            arr[1][z] = 0;
            if( two[z] <= l ) {
                arr[0][z] = 1;
                l -= two[z];
            }
            if( two[z] <= r ) {
                arr[1][z] = 1;
                r -= two[z];
            }
        }
        ans = 0;
        uno = 0;
        dos = 0;
        tres = 0;
        for( int z = 0; z <= 30; z++ ) {
            if( arr[1][z] == 1 && arr[0][z] == 0 ) {
                 here = z;
            }
        }
        for( int z = 30; z > here; z-- ) {
            if( arr[1][z] == 1 ) {
            uno += two[z];
            dos += two[z];
            }
        }
        uno += two[here];
        for( int z = here - 1; z >= 0; z-- ) {
             dos += two[z];
        }
        if( lol == dos ) lol++;
        if( lol == uno ) lol++;
        cout << uno << " " << dos << " " << lol << "\n";
    }

    return 0;
}


/*#include<bits/stdc++.h>
using namespace std;
int tim , n , q , one , two;
pair<long long , int> a[200001] , b[200001];
map<int , int> aa , bb;
long long ans , ek , dui , vag = 998244353;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr); std::cout.tie(nullptr);
    cin >> tim;
    for( int p = 0; p < tim; p++ ) {
         cin >> n >> q;
         aa.clear();
         bb.clear();
         for( int z = 0; z < n; z++ ) {
            cin >> a[z].first;
            a[z].second = z;
         }
         for( int z = 0; z < n; z++ ) {
            cin >> b[z].first;
            b[z].second = z;
         }
         sort( a , a + n );
         sort( b , b + n );
         ans = 1;
         for( int z = 0; z < n; z++ ) {
            aa[a[z].second] = z;
            bb[b[z].second] = z;
            ans = ans * min( a[z].first , b[z].first );
         }
         cout << ans << " ";
         for( int z = 0; z < q; z++ ) {
            cin >> one >> two; // one a naki b two kon index;
            if( one == 1 ) {
                two--;
                two = aa[two];
                ans = ans / min( a[two].first , b[two].first );
                a[two].first++;
                 ans = ans * min( a[two].first , b[two].first );
                while( two < n - 1 && a[two].first > a[two + 1].first ) {
                    ans = ans / min( a[two].first , b[two].first );
                    ans = ans / min( a[two + 1].first , b[two + 1].first );
                    swap(aa[a[two].second] , aa[a[two + 1].second] );
                    swap( a[two].first , a[two + 1].first );
                    ans = ans * min( a[two].first , b[two].first );
                    ans = ans * min( a[two + 1].first , b[two + 1].first );
                    two++;
                }
            }
            else{
                two--;
                two = bb[two];
                ans = ans / min( a[two].first , b[two].first );
                b[two].first++;
                 ans = ans * min( a[two].first , b[two].first );
                while( two < n - 1 && b[two].first > b[two + 1].first ) {
                    ans = ans / min( a[two].first , b[two].first );
                    ans = ans / min( a[two + 1].first , b[two + 1].first );
                    swap(bb[b[two].second] , bb[b[two + 1].second] );
                    swap( b[two].first , b[two + 1].first );
                    ans = ans * min( a[two].first , b[two].first );
                    ans = ans * min( a[two + 1].first , b[two + 1].first );
                    two++;
                }
            }
           // for( int z = 0; z < n; z++ ) cout << a[z].first << " ";
           // cout << "\n";
            //for( int z = 0; z < n; z++ ) cout << b[z].first << " ";
           // cout << "\n";
            cout << ans << " ";
         }
         cout << "\n";
    }
} */





Solution 2 (runtime: 155 ms):
#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;

long long cal(vector<int> C)
{
    long long res = 0;
    for (int i = 0; i <= C.size() - 1; i++)
    {
        if (C[i] == 1)
            res += pow(2, i);
    }
    return res;
}
void sol()
{
    int l, r;
    cin >> l >> r;
    vector<int> A, B;
    int ll = l, rr = r;
    while (ll)
    {
        if (ll % 2 == 1)
            A.push_back(1);
        else A.push_back(0);
        ll /= 2;
    }
    while (rr)
    {
        if (rr % 2 == 1)
            B.push_back(1);
        else B.push_back(0);
        rr /= 2;
    }
    while (A.size() < B.size())
    {
        A.push_back(0);
    }
    vector<int>a, b, c;
    bool f = false;
    for (int i = B.size() - 1; i >= 0; i--)
    {
        if (A[i] != B[i])
        {
            vector<int> C;
            for (int j = 0; j <= i - 1; j++)
            {
                C.push_back(0);
            }
            C.push_back(1);
            for (int j = i + 1; j <= A.size() - 1; j++)
            {
                C.push_back(A[j]);
            }
            long long tmp = cal(C);
            if (r - tmp >= 1)
            {
                a.push_back(0);
                b.push_back(1);
                c.push_back(1);
                for (int k = 1; k < i; k++)
                {
                    a.push_back(0);
                    b.push_back(0);
                    c.push_back(1);
                }
                a.push_back(1);
                b.push_back(1);
                c.push_back(0);
            }
            else if (tmp - l >= 1)
            {
                a.push_back(0);
                b.push_back(1);
                c.push_back(0);
                for (int k = 1; k < i; k++)
                {
                    a.push_back(0);
                    b.push_back(1);
                    c.push_back(1);
                }
                a.push_back(1);
                b.push_back(0);
                c.push_back(0);
            }
            for (i = i + 1; i <= B.size() - 1; i++)
            {
                a.push_back(B[i]);
                b.push_back(B[i]);
                c.push_back(B[i]);
            }
            break;
        }
    }
    cout << cal(a) << ' ' << cal(b) << ' ' << cal(c) << '\n';
}

int main()
{
    int t; cin >> t;
    while (t--)
    {
        sol();
    }
    return 0;
}