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 pii pair<int,int>
#define pss pair<string,string>
#define fi first
#define se second
#define pb push_back
#define pbb pair<bool,bool>
#define un unsigned
#define ull unsigned long long
#define	int_INF 0x3f3f3f3f
#define LL long long
#define ll_INF 0x3f3f3f3f3f3f3f3f
#define lb long double
#define db double
#define re return
#define pll pair<ll,ll>
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define debug(a) cout<<"debug: "<<(#a)<<" = "<<a<<'\n'
#define cer(a) cerr<<#a<<'='<<(a)<<"@ line"<<__LINE__<<endl
#define cer2(a,b) cerr<<#a<<'='<<(a)<<','<<#b<<'='<<(b)<<"@ line"<<__LINE__<<endl
#define cer3(a,b,c) cerr<<#a<<'='<<(a)<<','<<#b<<'='<<(b)<<','<<#c<<'='<<(c)<<','<<"@ line"<<__LINE__<<endl
#define pdd pair<db,db>
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define KV(x) #x << " = " << x << ";"
#define DEBUG DebugLine(__LINE__)
#define bitCount(x) __builtin_popcount(x)
#define i128 __int128
using namespace std;
const int maxn=2e5+100;
const ll mode=998244353;
const ll mode2=1e9+7;
const ll inf=9223372036854775807;
const db eps=1e-6;
typedef pair<int,int> hashv;
mt19937 mrand(random_device{}()); 
hashv operator + (hashv a,hashv b) {
	int c1=a.fi+b.fi,c2=a.se+b.se;
	if (c1>=mode) c1-=mode;
	if (c2>=mode2) c2-=mode2;
	return mp(c1,c2);
}

hashv operator - (hashv a,hashv b) {
	int c1=a.fi-b.fi,c2=a.se-b.se;
	if (c1<0) c1+=mode;
	if (c2<0) c2+=mode2;
	return mp(c1,c2);
}

hashv operator * (hashv a,hashv b) {
	return mp(1ll*a.fi*b.fi%mode,1ll*a.se*b.se%mode2);
}
int rnd(int x) { return mrand() % x;}
struct DebugLine {
  explicit DebugLine(int lineno) { std::cerr << lineno << "L "; }
 
  ~DebugLine() { std::cerr << std::endl; }
 
  template <typename T> DebugLine &operator<<(T &&v) {
    std::cerr << std::forward<T>(v);
    return *this;
  }
};
double PI = 3.141592653;
double my_cos(double x){
    return cos(x*PI / 180.0);
}
double my_sin(double x){
    return sin(x*PI / 180.0);
}
double my_tan(double x){
    return tan(x*PI / 180.0);
}
ll n,m,a[maxn];
ll sum,ans;
string str;
vector<int>vt;
int vis[maxn]; 
ll ksm(ll a,ll b,ll p)
{
	ll res=1ll;
	while(b)
	{
		if(b&1)
		res=res*a%p;
		b>>=1;
		a=a*a%p;
	}
	return res;
}
struct Hash_char{
    const ll mod=998244353, base=131;
    ll p[maxn], g[maxn];
    void getp(){
        p[0]=1;
        for(int i=1; i<maxn; i++){
            p[i]=p[i-1]*base%mod;
        }
    }
    LL Hash(char s[]){
        int len=strlen(s+1);
        g[0]=0, g[1]=s[1];
        for(int i=2; i<=len; i++){
            g[i]=(g[i-1]*base+s[i])%mod;
        }
        return g[len];
    }
    LL getLR(int l, int r){//µÃµ½s[l]-s[r]µÄhashÖµ 
        if(l>r) return 0;
        LL ans=((g[r]-g[l-1]*p[r-l+1])%mod+mod)%mod;
        return ans;
    }
    
 
}T[2];
LL strfz(int pos, int l, int r){//pos:Õý·´´®,·­×ªl, r¡£ 
    LL ans=T[pos].getLR(1, l-1)*T[pos].p[n-l+1]%T[pos].mod;
    LL res=T[pos^1].getLR(n-r+1, n-r+1+r-l)*T[pos].p[n-r]%T[pos].mod;
    ans=ans+res+T[pos].getLR(r+1, n);
    return ans%T[pos].mod;
}

template<const int T>
struct ModInt {
    const static int mod = T;
    int x;
    ModInt(int x = 0) : x(x % mod) {}
    ModInt(long long x) : x(int(x % mod)) {} 
    int val() { return x; }
    ModInt operator + (const ModInt &a) const { int x0 = x + a.x; return ModInt(x0 < mod ? x0 : x0 - mod); }
    ModInt operator - (const ModInt &a) const { int x0 = x - a.x; return ModInt(x0 < 0 ? x0 + mod : x0); }
    ModInt operator * (const ModInt &a) const { return ModInt(1LL * x * a.x % mod); }
    ModInt operator / (const ModInt &a) const { return *this * a.inv(); }
    bool operator == (const ModInt &a) const { return x == a.x; };
    bool operator != (const ModInt &a) const { return x != a.x; };
    void operator += (const ModInt &a) { x += a.x; if (x >= mod) x -= mod; }
    void operator -= (const ModInt &a) { x -= a.x; if (x < 0) x += mod; }
    void operator *= (const ModInt &a) { x = 1LL * x * a.x % mod; }
    void operator /= (const ModInt &a) { *this = *this / a; }
    friend ModInt operator + (int y, const ModInt &a){ int x0 = y + a.x; return ModInt(x0 < mod ? x0 : x0 - mod); }
    friend ModInt operator - (int y, const ModInt &a){ int x0 = y - a.x; return ModInt(x0 < 0 ? x0 + mod : x0); }
    friend ModInt operator * (int y, const ModInt &a){ return ModInt(1LL * y * a.x % mod);}
    friend ModInt operator / (int y, const ModInt &a){ return ModInt(y) / a;}
    friend ostream &operator<<(ostream &os, const ModInt &a) { return os << a.x;}
    friend istream &operator>>(istream &is, ModInt &t){return is >> t.x;}
 
    ModInt pow(int64_t n) const {
        if(n == 0) return 1;
        ModInt res(1), mul(x);
        while(n){
            if (n & 1) res *= mul;
            mul *= mul;
            n >>= 1;
        }
        return res;
    }
     
    ModInt inv() const {
        int a = x, b = mod, u = 1, v = 0;
        while (b) {
            int t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        if (u < 0) u += mod;
        return u;
    }
     
};
using mint = ModInt<1000000007>;
ll ecgcd(ll a,ll b,ll& x,ll& y)
{
    if(b==0)
    {
        x=1,y=0;
        return a;
    }
    ll d=ecgcd(b,a%b,y,x);
    y-=a/b*x;
    return d;
}
//class manacherWrapper
//{
//    private:
//        int l_;
//        string s_;
//    public:
//        std::vector<int> p;
//        std::vector<int> b;
//        std::vector<int> s;
//        explicit manacherWrapper(string str)
//        {
//            auto l = str.size();
//            //rebuild
//            l_ = l;
//            s_.resize(((l_ + 1) << 1) | 1);
//            p.resize(((l_ + 1) << 1) | 1);
//            b.resize(l_);
//            s.resize(l_ + 1);
// 
//            s_[0] = '$', s_[1] = '#';
// 
//            for (int i = 0; i < l_; ++i)
//                s_[(i + 1) << 1] = str[i], s_[((i + 1) << 1) | 1] = '#';
//            l_ = (l_ + 1) << 1;
//            //calc p
//            int mx = 0, id;
//            for (int i = 0; i < l_; ++i)
//            {
//                if (mx > i)p[i] = std::min(p[(id << 1) - i], mx - i);
//                else p[i] = 1;
//                for (; s_[i - p[i]] == s_[i + p[i]]; p[i]++);
//                if (p[i] + i > mx)
//                {
//                    mx = p[i] + i;
//                    id = i;
//                }
//            }
//            //calc b and s
//            for (int i = 0; i < l; ++i)
//            {
//                auto lp = get(i);
//                b[i - (lp >> 1)] = std::max(b[i - (lp >> 1)], lp);
//                s[i - (lp >> 1)]++, s[i + 1]--;
//                if (i + 1 >= l)break;
//                lp = get(i, i + 1);
//                if (lp > 0)
//                {
//                    b[i + 1 - (lp >> 1)] = std::max(b[i + 1 - (lp >> 1)], lp);
//                    s[i + 1 - (lp >> 1)]++, s[i + 1]--;
//                }
//            }
//            for (int i = 1; i < l; ++i)
//            {
//                b[i] = std::max(b[i], b[i - 1] - 2);
//                s[i] += s[i - 1];
//            }
//        }
// 
//        int get(int pos)
//        {
//            return (int) p[(pos + 1) << 1] - 1;
//        }
// 
//        int get(int posl, int posr)
//        {
//            return (int) p[((posl + 1) << 1) | 1] - 1;
//        }
// 
//        int longestBegin(int begin)
//        {
//            return b[begin];
//        }
// 
//        int totalBegin(int begin)
//        {
//            return s[begin];
//        }
// 
//        bool isPalindrome(int l,int r)
//        {
//            if (l > r)std::swap(l, r);
//            auto mid = (l + r) >> 1;
//            auto len = (r - l + 1);
//            return len & 1 ? get(mid) >= len : get(mid, mid + 1) >= len;
//        }
//};
//void scan(__int128 &x){//input
//	x = 0;
//	int f = 1;
//	char ch;
//	if((ch = getchar()) == '-'){
//		f = -1;
//	}else{
//		x = x * 10 + (ch - '0');
//	}
//	while((ch = getchar()) >= '0' && ch <= '9'){
//		x = x * 10 + (ch - '0');
//	}
//	x *= f;
//}
//void print(__int128 x){//output 
//	if(x < 0){
//		x = -x;
//		putchar('-');
//	}
//	if(x > 9){
//		print(x/10);//recursion
//	}
//	putchar(x%10+'0');
//}
struct DSU {
    std::vector<int> f, siz;
    DSU() {}
    DSU(int n) : f(n), siz(n, 1) { std::iota(f.begin(), f.end(), 0); }
    int find(int x) {
        while (x != f[x]) x = f[x] = f[f[x]];
        return x;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    bool merge(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        siz[x] += siz[y];
        f[y] = x;
        return true;
    }
    int size(int x) { return siz[find(x)]; }
};
void solve()
{ 	
   ll l,r;
   cin>>l>>r;
   ll v1=r,v2=0,v3=0;
   int mx=log2(r);
   for(int i=mx;i>=0;i--)
   {
   	 int x=(v1>>i)&1;
   	 if(x==0)
   	 v2+=(1ll<<i);
   }
   v2=max(v2,l);
   v2=min(v2,r);
   for(int i=mx;i>=0;i--)
   {
   	  int x1=(v1>>i)&1;
   	  int x2=(v2>>i)&1;
   	  if(x1==0&&x2==0)
   	  v3+=(1ll<<i);
   }
   v3=max(v3,l);
   v3=min(v3,r);
   cout<<v1<<" "<<v2<<" "<<v3<<'\n';
//   cer((8^7)+(8^8)+(8^7));
}
int main(){
	#ifndef ONLINE_JUDGE
		freopen("C:\\Users\\JIAJIEASHI\\Desktop\\in.cpp","r",stdin);
	//	freopen("out.cpp","w",stdout);
	#endif
    ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int _;
	_=1;
	cin>>_;
	while(_--) 
    solve();
	return 0;
/* 
1.ÉîºôÎü£¬²»Òª½ôÕÅ£¬ÂýÂý¶ÁÌâ£¬¶ÁÃ÷°×Ìâ£¬ÌâÄ¿ÍùÍù±ÈÄãÏëµÄ¼òµ¥¡£
2.±©Á¦Ã¶¾Ù:Ã¶¾ÙÊ²Ã´£¬ÊÇ·ñ¿ÉÒÔÊ¹ÓÃÒ»Ð©¼¼ÇÉ¼Ó¿ìÃ¶¾ÙËÙ¶È£¨Ô¤´¦Àí¡¢Ç°×ººÍ¡¢Êý¾Ý½á¹¹¡¢ÊýÂÛ·Ö¿é£©¡£
3.Ì°ÐÄ:ÐèÒªÅÅÐò»òÊ¹ÓÃÊý¾Ý½á¹¹£¨pq£©Âð£¬ÕâÃ´Ì°ÐÄÒ»¶¨×îÓÅÂð¡£
4.¶þ·Ö£ºÂú×ãµ¥µ÷ÐÔÂð£¬ÔõÃ´¶þ·Ö£¬ÈçºÎÈ·¶¨¶þ·Öº¯Êý·µ»ØÖµÊÇÊ²Ã´¡£
5.Î»ÔËËã£º°´Î»Ì°ÐÄ£¬»¹ÊÇÓëÎ»ÔËËã±¾ÉíµÄÐÔÖÊÓÐ¹Ø¡£
6.ÊýÑ§Ìâ£ººÍ×î´ó¹«ÒòÊý¡¢ÖÊÒò×Ó¡¢È¡Ä£ÊÇ·ñÓÐ¹Ø¡£
7.dp£ºÔõÃ´Éè¼Æ×´Ì¬£¬×´Ì¬×ªÒÆ·½³ÌÊÇÊ²Ã´£¬³õÌ¬ÊÇÊ²Ã´£¬Ê¹ÓÃÑ­»·»¹ÊÇ¼ÇËÑ×ªÒÆ¡£
8.ËÑË÷£ºdfs »¹ÊÇ bfs £¬ËÑË÷µÄÊ±ºò×´Ì¬ÊÇÊ²Ã´£¬ÐèÒª¼ÇÒä»¯Âð¡£
9.Ê÷ÉÏÎÊÌâ£ºÊÇÊ÷ÐÎdp¡¢Ê÷ÉÏÌ°ÐÄ¡¢»òÕßÊÇÔÚÊ÷ÉÏËÑË÷¡£
10.Í¼ÂÛ£ºÒÀ¿¿Ê²Ã´ÑùµÄ¹ØÏµ½¨Í¼£¬ÊÇÇó»·Í³¼Æ½á¹û»¹ÊÇ×î¶ÌÂ·¡£
11.×éºÏÊýÑ§£ºÓÐ¼¸ÖÖÖµ£¬Ã¿ÖÖÖµÈçºÎ±»×é³É£¬ÈÝ³â¹ØÏµÊÇÊ²Ã´¡£
12.½»»¥Ìâ£ºlog(n)´ÎÈçºÎ¶þ·Ö£¬2*n ´ÎÈçºÎÍ¨¹ý n ´ÎÇó³öÒ»Ð©Öµ£¬ÔÙ¸ù¾ÝÊ£Óà´ÎÊýÇó´ð°¸¡£
13.Èç¹ûÒÔÉÏ¼¸ÖÖ¶¼²»ÊÇ£¬¶à°ëÊÇÓÐÒ»¸ö point ÄãÃ»ÓÐ×¢Òâµ½£¬¼Ç×¡ÕýÄÑÔò·´¡£
*/ 
}

Submission (verdict: Wrong answer on test 1):

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>

// Converts decimal to a 32-bit binary array
vll decimalToBinary(int n)
{
    vll binary(32, 0);
    for (int i = 31; i >= 0; i--)
    {
        binary[i] = n % 2;
        n /= 2;
    }
    return binary;
}

// Converts binary array back to decimal
ll binaryArrayToDecimal(vll binary)
{
    ll decimal = 0;
    for (int i = 0; i < 32; i++)
    {
        decimal = (decimal << 1) | binary[i];
    }
    return decimal;
}

int main()
{

    ll t;
    cin >> t;

    while (t--)
    {
        ll l, r;
        cin >> l >> r;

        vll rr = decimalToBinary(r);
        vll aa(32, 0);
        bool lucky = false;

        for (int i = 0; i < 32; i++)
        {
            if (rr[i] == 0 && !lucky)
            {
                aa[i] = 0;
                continue;
            }
            if (rr[i] == 0)
            {
                aa[i] = 1;
            }
            else
            {
                aa[i] = 0;
            }
            lucky = true;
        }

        ll a = -1;
        if (binaryArrayToDecimal(aa) >= l && binaryArrayToDecimal(aa) < r)
        {
            a = binaryArrayToDecimal(aa);
        }
        else
        {

            ll an = binaryArrayToDecimal(aa);
            if (an < l)
            {
                a = l;
            }
            else
            {
                a = r - 1;
            }
        }

        ll c = -1, mx = -1;
        for (int i = max(l, r - 100000); i < r; i++)
        {
            if (i != a)
            {
                ll p = (r ^ i) + (i ^ a);
                if (p > mx)
                {
                    mx = p;
                    c = i;
                }
            }
        }

        cout << a << " " << c << " " << r << endl;
    }

    return 0;
}