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

Previous submission (verdict: Wrong answer on test 2):
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <utility>
#include <limits.h>
#include <climits>
#include <numeric>
#include <map>
#include <unordered_map>
#include <cfloat>
#define ll long long
#define int long long
#define DEBUG false
using namespace std;


void debug(string s) {
    if (DEBUG) cout << s << endl;
}

void debug(int s) {
    if (DEBUG) cout << s << endl;
}

void debug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
}

//flat debug of vector of vectors
void fdebug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j];
            if (j != v[i].size() - 1) {
                cout << " ";
            }
        }
        cout << "; ";
    }
    cout << endl;
}


void debug(vector<int> & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        cout << v[i] << " ";
    }
    cout << endl;
}


class Solution {
    int l, r;
public:
    void init() {
        cin >> l >> r;
    }

    ll solve() {
        init();
        int a = 0;
        int b = 0;
        int c = 0;

        for (int i = 30; i >= 0; --i) {
            int li = (l >> i) & 1;
            int ri = (r >> i) & 1;
            if (li != ri) {
                if (r > (1 << i)) {
                    a += (1 << i) + 1;
                    b += (1 << i);
                    c += (1 << i) - 1;
                } else {
                    a += (1 << i);
                    b += (1 << i) - 1;
                    c += (1 << i) - 2;
                }
                break;
            } else if (li == 1) {
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
            }
        }
        
        cout << a << " " << b << " " << c << endl;
        return 0;
    }

};


signed main()
{
    std::ios_base::sync_with_stdio (false);
    std::cin.tie(NULL);
    int n;
    cin >> n;
    Solution sol;
    for(int i = 1; i != n + 1; ++i) {
        //cout << fixed << setprecision(0) << sol.solve() << "\n";
        sol.solve();
    }

    return 0;
}


Submission (verdict: Accepted):
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <utility>
#include <limits.h>
#include <climits>
#include <numeric>
#include <map>
#include <unordered_map>
#include <cfloat>
#define ll long long
#define int long long
#define DEBUG false
using namespace std;


void debug(string s) {
    if (DEBUG) cout << s << endl;
}

void debug(int s) {
    if (DEBUG) cout << s << endl;
}

void debug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
}

//flat debug of vector of vectors
void fdebug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j];
            if (j != v[i].size() - 1) {
                cout << " ";
            }
        }
        cout << "; ";
    }
    cout << endl;
}


void debug(vector<int> & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        cout << v[i] << " ";
    }
    cout << endl;
}


class Solution {
    int l, r;
public:
    void init() {
        cin >> l >> r;
    }

    ll solve() {
        init();
        int a = 0;
        int b = 0;
        int c = 0;

        for (int i = 30; i >= 0; --i) {
            int li = (l >> i) & 1;
            int ri = (r >> i) & 1;
            if (li != ri) {
                if (r > (1 << i)) {
                    a += (1 << i) + 1;
                    b += (1 << i);
                    c += (1 << i) - 1;
                } else {
                    a += (1 << i);
                    b += (1 << i) - 1;
                    c += (1 << i) - 2;
                }
                break;
            } else if (li == 1) {
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
                l -= (1 << i);
                r -= (1 << i);
            }
        }
        
        cout << a << " " << b << " " << c << endl;
        return 0;
    }

};


signed main()
{
    std::ios_base::sync_with_stdio (false);
    std::cin.tie(NULL);
    int n;
    cin >> n;
    Solution sol;
    for(int i = 1; i != n + 1; ++i) {
        //cout << fixed << setprecision(0) << sol.solve() << "\n";
        sol.solve();
    }

    return 0;
}