Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

const long long mod = 1e9 + 7;
const int MaxN = 30 + 5;

long long l, r;

void Inp()
{
    cin >> l >> r;
}

struct State
{
    long long a, b, c;

    State() = default;

    State(long long _a, long long _b, long long _c)
    {
        a = _a;
        b = _b;
        c = _c;
    }

    bool operator < (const State& other) const
    {
        if (this->a == other.a)
        {
            if (this->b == other.b)
            {
                return this->c < other.c;
            }
            return this->b < other.b;
        }
        return this->a < other.a;
    }
};

long long F[8][8][MaxN];
State track[8][8][MaxN];

pair<long long, State> DPDigit(int i, int maskl, int maskr)
{
    if (i < 0)
    {
        return make_pair(0, State(0, 0, 0));
    }
    if (F[maskl][maskr][i] != -1)
    {
        return make_pair(F[maskl][maskr][i], track[maskl][maskr][i]);
    }
    F[maskl][maskr][i] = 0;
    pair<long long, State> res = make_pair(0, State(0, 0, 0));
    int bitl = (l >> i) & 1, bitr = (r >> i) & 1;
    for (int x = 0; x < 2; x++)
    {
        for (int y = 0; y < 2; y++)
        {
            for (int z = 0; z < 2; z++)
            {
                if ((((maskl & 1) || x >= bitl) && ((maskr & 1) || (x <= bitr)))
                    && (((maskl & 2) || y >= bitl) && ((maskr & 2) || (y <= bitr)))
                    && (((maskl & 4) || z >= bitl) && ((maskr & 4) || (z <= bitr))))
                {
                    int newl = (((maskl | (x > bitl)) | ((y > bitl) << 1)) | ((z > bitl) << 2));
                    int newr = (((maskr | (x < bitr)) | ((y < bitr) << 1)) | ((z < bitr) << 2));
                    pair<long long, State> p = DPDigit(i - 1, newl, newr);
                    long long cur = p.first + ((x ^ y) << i) + ((y ^ z) << i) + ((z ^ x) << i);
                    State now(p.second.a ^ (x << i), p.second.b ^ (y << i), p.second.c ^ (z << i));
                    res = max(res, make_pair(cur, now));
                }
            }
        }
    }
    F[maskl][maskr][i] = res.first;
    track[maskl][maskr][i] = res.second;
    return res;
}

void Exc()
{
    memset(F, -1, sizeof(F));
    pair<long long, State> res =  DPDigit(31, 0, 0);
    cout << res.second.a << " " << res.second.b << " " << res.second.c << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int test = 1;
    cin >> test;
    for (int x = 1; x <= test; x++)
    {
        Inp();
        Exc();
    }
    return 0;
}


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

using namespace std;

const long long mod = 1e9 + 7;
const int MaxN = 30 + 5;

long long l, r;

void Inp()
{
    cin >> l >> r;
}

void Exc()
{
    int p = 0;
    for (int x = 31; x >= 0; x--)
    {
        if (((l >> x) & 1) != ((r >> x) & 1))
        {
            p = x;
            break;
        }
    }
    l &= ((1ll << (p + 1)) - 1);
    r &= ((1ll << (p + 1)) - 1);
    long long b = (1ll << p) - 1;
    if (l == b)
    {
        cout << b + 1 << " " << b + 2 << " " << b << "\n";
    }
    else
    {
        cout << b + 1 << " " << b << " " << b - 1 << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int test = 1;
    cin >> test;
    for (int x = 1; x <= test; x++)
    {
        Inp();
        Exc();
    }
    return 0;
}