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

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define ull unsigned long long
using namespace std;
ll mll= LLONG_MAX;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll numx[105];
ll numy[105];
ll numz[105];
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll t;
    cin>>t;
    while(t--)
    {
        ll x,y,xx,yy;
        cin>>x>>y;
        xx=x;
        yy=y;
        ll len=0;
        while(yy!=0)
        {
            len++;
            numy[len]=yy%2;
            yy/=2;
        }
        ll cur=0;
        while(xx!=0)
        {
            cur++;
            numx[cur]=xx%2;
            xx/=2;
        }
        ll sum=0;
        for(ll i=len;i>=1;i--)
        {
            if(numx[i]==1&&numy[i]==1)
            {
                numz[i]=1;
            }
            else if(numy[i]==1&&numx[i]==0)
            {
                sum++;
                numz[i]=0;
            }
            else if(numx[i]==0&&numy[i]==0)
            {
                if(sum>=1)
                {
                    sum--;
                    numz[i]=1;
                }
                else
                {
                    numz[i]=0;
                }
            }
            else
            {
                numz[i]=1;
            }
        }
        ll z=0;
        ll ans=1;
        for(ll i=1;i<=len;i++)
        {
            z+=(numz[i])*ans;
            ans*=2;
        }
        cout<<x<<" "<<y<<" "<<z<<"\n";
    }
}

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

string calc(int n)
{
	string ans = "";
	while (n)
	{
		ans += to_string(n % 2);
		n >>= 1;
	}
	reverse(ans.begin(), ans.end());
	return ans;
}
int recover(string str)
{
	int ans = 0ll;
	int now = 1;
	for (int i = str.size() - 1; i >= 0; -- i)
	{
		ans += (str[i] - '0')  * now;
		now <<= 1; 
	}
	return ans;
}
int sum(int a, int b, int c)
{
 	int ans = (a ^ b) + (b ^ c) + (c ^ a) ;
 	return ans ;
}
void solve()
{
	int ans1 = 0, ans2 = 0;
	int l, r; cin >> l >> r;
	int rr = r;
	int ll = l;
	int cnt1 = 0, cnt2= 0;
	string str1, str2;
	str1 = calc(l);
	str2 = calc(r);
//	cout << st2
	while (l) 
	{
		l >>= 1;
		++ cnt1;
	}
	while (r)
	{
		r >>= 1;
		++ cnt2;
	}
	int cnt = cnt2 - cnt1;
	while(cnt--) str1 = "0" + str1;
	string str_ans;
	int f = 0;
	int len = str2.size();
	int now = 0;
	for (int i = 0; i < str2.size(); ++ i)
	{
		if (str2[i] == '1') ++ now;
	}
//	cout << now << " " << len << '\n';
	if (ll == 0 && now == len)
	{
//		cout << "!!!!!!!\n";
		cout << 1 << " " << 2 << " " << rr - 3 << '\n';
		return;
	}
	for (int i = 0; i < len; ++ i)
	{
		if (!f && str1[i] == str2[i])
		{
			str_ans += str1[i];
		}
		else
		{
			f = 1;
			if (str1[i] == str2[i]) 
			{
				if (str1[i] == '0') str_ans += "1";
				else str_ans += "0";
			}
			else str_ans += str1[i];
		}
	}
//	cout << str1 << "\n"; cout << 6
//	cout << recover(str_ans)<<" "<< recover(str1)<<" "<< recover(str2) << '\n';
////	cout << str_ans << '\n';
//	
//	for (int i = 0; i < len; ++ i)
//	{
//		if (str_ans[i] > str2[i])  str_ans[i] = '0';
//		else if (str_ans[i] == str2[i]) continue;
//		else break;
//	}
//	ans1 = sum(recover(str_ans), recover(str1),recover(str1));
////	cout << ans1 << '\n';
//	string ans_str;
	if (str_ans > str1)
	{
		cout << recover(str1)<<" "<< recover(str_ans)<<" "<< recover(str2) << '\n';	
		return;
	}
	str_ans = "";
	f = 0;
//	// ++++++++++++++++++++++++++++++ //
	for (int i = 0; i < len; ++ i)
	{
		if (!f && str1[i] == str2[i])
		{
			str_ans += str1[i];
		}
		else
		{
			f = 1;
			if (str1[i] == str2[i]) 
			{
				if (str1[i] == '0') str_ans += "1";
				else str_ans += "0";
			}
			else str_ans += str2[i];
//			if (str2[i] == '1') ans_str += '0';
//			else ans_str += '1';
		}
	}
//	cout << str_ans << '\n';
	cout << recover(str1)<<" "<< recover(str_ans)<<" "<< recover(str2) << '\n';
//	for (int i = 0; i < len; ++ i)
//	{
//		if (ans_str[i] < str1[i])  str_ans[i] = '1';
//		else if (ans_str[i] == str1[i]) continue;
//		else break;
//	}
//	ans2 = sum(recover(ans_str), recover(str2), recover(str2));
//	
//	if (ans2 > ans1) cout << recover(ans_str)<<" "<< recover(str2)<<" "<< recover(str2) << '\n';
//	else cout<<recover(str_ans)<<" "<< recover(str1)<<" "<<recover(str1) << '\n';
	
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int tes = 1;
	cin >> tes;
	while (tes--) solve();
	return 0;
}