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

Previous submission (verdict: Wrong answer on test 1):
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <iostream>
#define int long long
#define end "\n"
using namespace std;
const int N = 2e6+10;
int r1[N], l1[N];
int a1[N], b1[N], c1[N];

void slove()
{
	int l, r, cnt = 0, b = 0;
	cin >> l >> r;
	if(r - l == 2)
	{
		cout << r << " " << r - 1 << " " << l << endl;
		return ;
	}
		
 	int a = 0, c = l;
	while(1)
	{
		if(r == 0)
			break;
		cnt ++;
		int t = r % 2;
		r1[cnt] = t;
		t = l % 2;
		l1[cnt] = t;
		r /= 2, l /= 2;
	}
	
	int f = 0;
	for(int i = cnt; i>= 1; i --)
	{

		if(r1[i] != l1[i])
		{
			f = i;
			break;
		}
		a1[i] = r1[i];
		b1[i] = r1[i];
	}
	int x = 1;
	a1[f] = 1;
	b1[f] = 0;
	for(int i = f - 1; i >= 1; i --)
	{
		a1[i] = 0;
		b1[i] = 1;
	}
	
	for(int i = 1; i <= cnt; i ++)
	{
		a += a1[i] * x;
		b += b1[i] * x;
		x *= 2;
		
	}

	cout << a << " " << b << " "  << c << endl;

		
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cout << fixed << setprecision(10);
	
	int T = 1; 
	cin >> T;
	while(T--)
	{
		slove();
	}
}


Submission (verdict: Accepted):
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <iostream>
#define int long long
#define end "\n"
using namespace std;
const int N = 2e6+10;
int a1[N], b1[N], c1[N];

void slove()#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <iostream>
#define int long long
#define end "\n"
using namespace std;
const int N = 2e6+10;
int r1[N], l1[N];
int a1[N], b1[N], c1[N];

void slove()
{
	int l, r, cnt = 0, b = 0;
	cin >> l >> r;
	int n = l, m = r;
 	int a = 0;
	while(1)
	{
		if(r == 0)
			break;
		cnt ++;
		int t = r % 2;
		r1[cnt] = t;
		t = l % 2;
		l1[cnt] = t;
		r /= 2, l /= 2;
	}
	
	int f = 0;
	for(int i = cnt; i>= 1; i --)
	{

		if(r1[i] != l1[i])
		{
			f = i;
			break;
		}
		a1[i] = r1[i];
		b1[i] = r1[i];
	}
	int x = 1;
	a1[f] = 1;
	b1[f] = 0;
	for(int i = f - 1; i >= 1; i --)
	{
		a1[i] = 0;
		b1[i] = 1;
	}
	
	for(int i = 1; i <= cnt; i ++)
	{
		a += a1[i] * x;
		b += b1[i] * x;
		x *= 2;
		
	}

	if (b == n) cout << a << " " << b << " " << m << "\n";
    else cout << n << " " << a << " " << b << "\n";


		
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cout << fixed << setprecision(10);
	
	int T = 1; 
	cin >> T;
	while(T--)
	{
		slove();
	}
}

{
	int l, r, cnt = 0, b = 0;
	cin >> l >> r;
	int a = r, c = l;
	while(1)
	{
		if(r == 0)
			break;
		cnt ++;
		int t = r % 2;
		a1[cnt] = t;
		t = l % 2;
		c1[cnt] = t;
		r /= 2, l /= 2;
	}
	
	int f = 0;
	for(int i = cnt; i>= 1; i --)
	{

		if(a1[i] != c1[i])
		{
			if(f == 0)
			{

				b1[i] = c1[i];
				f ++;
				
			}
			else
			{
				b1[i] = a1[i];
			}
		}
		if(a1[i] == c1[i])
		{
			if(f != 0)
				b1[i] = a1[i] ^ 1;
			else
				b1[i] = a1[i];
		}
	}
	int x = 1;
	for(int i = 1; i <= cnt; i ++)
	{
		
		b += x * b1[i];
		x *= 2;
	}
//	cout << (a^b) + (b^c) + (a^c) << endl;
	cout << a << " " << b << " " << c << endl;
		
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cout << fixed << setprecision(10);
	
	int T = 1; 
	cin >> T;
	while(T--)
	{
		slove();
	}
}