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;
#define E 1e-9
#define PI 3.141592653589793238462
#define PB push_back
#define F find
#define S second
#define EB emplace_back
#define MP make_pair
#define INF 1e18
#define MOD 1000000007
#define SZ(a) int((a).size())
#define setbits(a) (__builtin_popcountll(a))
#define right(a) (__builtin_ctzll(a))
#define left(a) (__builtin_clzll(a))
#define parity(a) (__builtin_parityll(a))
#define msb(a) (__lg(a))
#define lsb(a) ((ll)(log2(a & -a)))
typedef std::numeric_limits<double> dbl;
typedef long long ll;
#define REP(i, a, b) for (ll i = a; i < b; i++)
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;

ll power(ll a, ll n)
{
    ll ans = 1ll;
    while (n > 0)
    {
        int last_bit = (n & 1ll);
        if (last_bit)
        {
            ans = ans * a;
        }
        a = a * a;
        n = n >> 1ll;
    }
    return ans;
}

class DSU
{
private:
    vector<ll> Parent, Rank;

public:
    DSU(int n)
    {
        Parent.resize(n);
        Rank.resize(n, 0);
        for (int i = 0; i < n; i++)
        {
            Parent[i] = i;
            Rank[i] = 1;
        }
    }

    void Init(ll n)
    {
        REP(i, 0, n)
        {
            Parent[i] = i;
            Rank[i] = 1;
        }
    }

    ll Root(ll x)
    {
        if (Parent[x] != x)
            Parent[x] = Root(Parent[x]);
        return Parent[x];
    }

    void Union(ll x, ll y)
    {
        ll rx = Root(x), ry = Root(y);
        if (rx == ry)
            return;
        if (Rank[rx] > Rank[ry])
        {
            Parent[ry] = rx;
            Rank[rx] += Rank[ry];
        }
        else
        {
            Parent[rx] = ry;
            Rank[ry] += Rank[rx];
        }
    }

    ll getRank(ll x)
    {
        return this->Rank[x];
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    while (t--)
    {
        ll l, r;
        cin >> l >> r;
        ll x = 0ll, flag = 0ll;
        for (ll i = msb(r); i >= 0; i--)
        {
            if ((l & (1ll << i)) && (r & (1ll << i)))
            {
                if (!flag)
                    x += (1ll << i);
            }
            else if ((l & (1ll << i)) || (r & (1ll << i)))
            {
                if (flag)
                    x += (1ll << i);
                else
                    flag = 1ll;
            }
            else
            {
                if (flag)
                    x += (1ll << i);
            }
        }
        cout << l << " " << x << " " << r << '\n';
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define E 1e-9
#define PI 3.141592653589793238462
#define PB push_back
#define F find
#define S second
#define EB emplace_back
#define MP make_pair
#define INF 1e18
#define MOD 1000000007
#define SZ(a) int((a).size())
#define setbits(a) (__builtin_popcountll(a))
#define right(a) (__builtin_ctzll(a))
#define left(a) (__builtin_clzll(a))
#define parity(a) (__builtin_parityll(a))
#define msb(a) (__lg(a))
#define lsb(a) ((ll)(log2(a & -a)))
typedef std::numeric_limits<double> dbl;
typedef long long ll;
#define REP(i, a, b) for (ll i = a; i < b; i++)
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;

ll power(ll a, ll n)
{
    ll ans = 1ll;
    while (n > 0)
    {
        int last_bit = (n & 1ll);
        if (last_bit)
        {
            ans = ans * a;
        }
        a = a * a;
        n = n >> 1ll;
    }
    return ans;
}

class DSU
{
private:
    vector<ll> Parent, Rank;

public:
    DSU(int n)
    {
        Parent.resize(n);
        Rank.resize(n, 0);
        for (int i = 0; i < n; i++)
        {
            Parent[i] = i;
            Rank[i] = 1;
        }
    }

    void Init(ll n)
    {
        REP(i, 0, n)
        {
            Parent[i] = i;
            Rank[i] = 1;
        }
    }

    ll Root(ll x)
    {
        if (Parent[x] != x)
            Parent[x] = Root(Parent[x]);
        return Parent[x];
    }

    void Union(ll x, ll y)
    {
        ll rx = Root(x), ry = Root(y);
        if (rx == ry)
            return;
        if (Rank[rx] > Rank[ry])
        {
            Parent[ry] = rx;
            Rank[rx] += Rank[ry];
        }
        else
        {
            Parent[rx] = ry;
            Rank[ry] += Rank[rx];
        }
    }

    ll getRank(ll x)
    {
        return this->Rank[x];
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    while (t--)
    {
        ll l, r;
        cin >> l >> r;
        ll x = 0ll, flag = 0ll;
        for (ll i = msb(r); i >= 0; i--)
        {
            if ((l & (1ll << i)) && (r & (1ll << i)))
            {
                if (!flag)
                    x += (1ll << i);
            }
            else if ((r & (1ll << i)))
            {
                if (!flag)
                {
                    x += (1ll << i);
                    flag = 1ll;
                }
            }
            else if(!(l & (1ll << i)))
            {
                if (flag)
                    x += (1ll << i);
            }
        }
        cout << l << " " << x << " " << r << '\n';
    }
    return 0;
}