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


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

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

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;
        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];
        }
        cout << uno << " " << dos << " " << l << "\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";
    }
} */