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 int
#define pb push_back
#define _mp make_pair
#define vt vector
#define MAXN 200002
using namespace std;
typedef long long LL;
ll mod=1e9+7;
//     f[0]=f[1]=inv[0]=inv[1]=1;
// for(int i=2;i<MAXN;i++) f[i]=(LL)f[i-1]*i%mod,inv[i]=(LL)(mod-mod/i)*inv[mod%i]%mod;
// for(int i=1;i<MAXN;i++) inv[i]=(LL)inv[i-1]*inv[i]%mod;
ll f[MAXN],inv[MAXN];

ll C(const int n,const int m){return n<m?0:(LL)f[n]*inv[m]%mod*inv[n-m]%mod;}
void dfs(vector<int> vec[], int start, vector<int> &vis, vt<int> &ans)
{
    vis[start] = 1;
    ans.pb(start);
    for (int i = 0; i < vec[start].size(); i++)
    {
        int val = vec[start][i];
        if (vis[val] == 0)
        {
            dfs(vec, val, vis, ans);
        }
    }
    return;
}
ll power(ll num, ll p)
{
    if (p == 0)
        return 1;
    if (p == 1)
        return num;
    ll n = power(num, p / 2);
    if (p % 2 == 0)
        return (n * n)%(998244353) ;
    return (num*((n*n)%(998244353)))%(998244353);
}
ll fact(ll val)
{
    if (val <= 1)
        return 1;
    return (val * fact(val - 1));
}
ll ncr(ll n, ll r)
{
    if (n < r)
        return 0;
    ll p = 1, k = 1;
    if ((n - r) < r)
        r = n - r;

    if (r != 0)
    {
        while (r)
        {
            p = (p * n)%mod;
            k = (k * r)%mod;
            ll m = __gcd(p, k);
            p /= m;
            k /= m;
            n--;
            r--;
        }
    }
    else
        p = 1;
    return p;
}
// bool cmp(pair<int,int> v1, pair<int,int> v2)
// {
//     if(v1.first==v2.first)return v1.second>v2.second;
//     return v1.first<v2.first;
// }
bool isFact(ll n)
{
  for (ll i = 1;; i++) {
    if (n % i == 0) {
      n /= i;
    }
    else {
      break;
    }
  }
 
  if (n == 1LL) {
    return true;
  }
  else {
    return false;
  }
}
int lcs(string s, string t, int m, int n)
{
    if (m==0||n==0)return 0;
    if (s[m-1]==t[n-1])return 1 + lcs(s, t, m - 1, n - 1);
    else return max(lcs(s, t, m, n - 1),lcs(s, t, m - 1, n));
}
pair<ll,ll> maxSubArraySum(vector<ll>&a, int size)
{
    ll max_so_far = 0, max_ending_here = 0;
     int num=0,mx_len=0;
    for (int i = 0; i < size; i++) {
        max_ending_here = (max_ending_here + a[i]);
        num++;
        if (max_so_far < max_ending_here)
            {max_so_far = max_ending_here;mx_len=num;}
        else{
            max_ending_here=0;num=0;
        }
    }
    if(mx_len==size)max_so_far=0;
    return {max_so_far,mx_len};
}
bool isPrime(ll N){
    int flag = 1;

    double sqroot = sqrt(N);

    // Iterate from 2 to sqrt(n)
    for (int i = 2; i <= sqroot; i++) {

        // If n is divisible by any number between 2 and
        // sqrt(n), it is not prime
        if (N % i == 0) {
            flag = 0;
            break;
        }
    }
    return flag;
}
void rev(int start,int ind,int end,vt<int>&vec){
int val=ind+1;
while(val>0){
    for(int i=start;i<end;i++)swap(vec[i],vec[i+1]);
    val--;
}
}
int gcdExtended(ll a, ll b, ll* x, ll* y)
{

    // Base Case
    if (a == 0) {
        *x = 0, *y = 1;
        return b;
    }

    // To store results of recursive call
    ll x1, y1;
    int gcd = gcdExtended(b % a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b / a) * x1;
    *y = x1;

    return gcd;
}
ll modInverse(ll A, ll M)
{
    ll x, y;
    ll g = gcdExtended(A, M, &x, &y);
    if (g != 1)
        return -1;
    else {

        // m is added to handle negative x
        ll res = (x % M + M) % M;
        return res;
    }
}



// bool fun(int a,int b,int X,int Y){
//     double dis1=
// }
ll dfs(int node,vt<int>tree[],vt<int>&v){
    if(tree[node].size()==0)return v[node];
    ll val=1e16;
    for(int i=0;i<tree[node].size();i++){
        val=min(val,dfs(tree[node][i],tree,v));
    }
    return val+v[node];
}
bool dfs(vt<ll>tree[],int node,ll val,vt<ll>&v){
   if(tree[node].size()==0&&v[node]<val)return false;
   if(node==1)val=max(0LL,val-v[node]);
   else if(v[node]<val) val=min((ll)1e15,val+val-v[node]);

   for(auto u:tree[node]){
    if(!dfs(tree,u,val,v))return false;
   }
   return true;
}
bool cmp(pair<int,int>a,pair<int,int>b){
    if(a.second<b.second)return true;
    else return a.first<b.first;
}
int countAndMerge(vector<int>& arr, int l, int m, int r) {
  
    // Counts in two subarrays
    int n1 = m - l + 1, n2 = r - m;

    // Set up two vectors for left and right halves
    vector<int> left(n1), right(n2);
    for (int i = 0; i < n1; i++)
        left[i] = arr[i + l];
    for (int j = 0; j < n2; j++)
        right[j] = arr[m + 1 + j];

    // Initialize inversion count (or result) and merge two halves
    int res = 0;
    int i = 0, j = 0, k = l;
    while (i < n1 && j < n2) {

        // No increment in inversion count if left[] has a 
        // smaller or equal element
        if (left[i] <= right[j]) 
            arr[k++] = left[i++];
      
        // If right is smaller, then it is smaller than n1-i 
          // elements because left[] is sorted
        else {
            arr[k++] = right[j++];
            res += (n1 - i);
        }
    }

    // Merge remaining elements
    while (i < n1)
        arr[k++] = left[i++];
    while (j < n2)
        arr[k++] = right[j++];

    return res;
}

// Function to count inversions in the array
ll countInv(vector<int>& arr, int l, int r){
    ll res = 0;
    if (l < r) {
        int m = (r + l) / 2;

        // Recursively count inversions in the left and 
        // right halves
        res += countInv(arr, l, m);
        res += countInv(arr, m + 1, r);

        // Count inversions such that greater element is in 
          // the left half and smaller in the right half
        res += countAndMerge(arr, l, m, r);
    }
    return res;
}

ll inversionCount(vector<int>& arr) {
      int n = arr.size();
      return countInv(arr, 0, n-1);
}
pair<bool,int> fun(int mid,vt<int>& a,vt<int>& b,int k,int n){
    int cnt=0;
    int buy=0;
    for(int i=0;i<n;i++){
        if(mid<=a[i])buy++;
        else if(mid<=b[i]){cnt++;buy++;}
    }
    if(cnt>k)return {false,buy};
    return {true,buy};
}
ll fun(vt<pair<int,int>>&v1,int n){
    vt<ll>suma(n),sumb(n);
   suma[0]=v1[0].first;
   sumb[0]=v1[0].second;
   for(int i=1;i<n;i++)suma[i]=suma[i-1]+v1[i].first;
   for(int i=1;i<n;i++)sumb[i]=sumb[i-1]+v1[i].second;
   ll val=INT_MIN;
   for(int i=0;i<n;i++){
    ll ans=suma[i]+(sumb[n-1]-sumb[i])+v1[i].second;
    val=max(val,ans);
   }
   return val;
}
pair<int,int> fun(string s,int l,int r,int l_b,int r_b){
    int n=s.size();
    for(int i=l;i<=r;i++){
      bool a=(s[n-(r-i)-1]==s[i]);
      bool b=(s[n-(r-i)-1]==s[i-r+r_b]);
      if(a&&(!b))return {l_b,r_b};
      if((!a)&&b)return {l,r};
    }
    return {l_b,r_b};
}
class N{
    public:
    int x,y,sum,d,val;
};

bool check(string a,string b){
    for(int i=0;i<4;i++){
        if(a[i]!=b[i])return false;
    }
    return true;
}
bool c(ll v){
    while(v>0){
        int d=v%10;
        if(d==4)return true;
        v/=10;
    }
    return false;
}
void _solve1()
{
    int t;cin>>t;
    while(t--){
        int l,r;
        cin>>l>>r;
        int a,b,c;
        a=b=c=0;
        int ind=0;
        for(int i=29;i>=0;i--){
            if((r&(1<<i))&&(l&(1<<i))){
                a|=(1<<i);
                b|=(1<<i);
            }
            else if((r&(1<<i))&&(l&(1<<i))==0){
                ind=i;break;
            }
        }
        for(int i=ind;i>=0;i--){
            if(i==ind){
                a|=(1<<i);
            }
            else{
                b|=(1<<i);
                // c|=(1<<i);
            }
        }
        c=l;
        // cout<<((a^b)+(b^c)+(c^a))<<'\n';
        cout<<a<<" "<<b<<" "<<(c)<<'\n';
        
    }
}
void _solve2(){
int a=134,b=132,c=137;
cout<<((a^b)+(b^c)+(c^a))<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _solve1();
    // _solve2();
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define _mp make_pair
#define vt vector
#define MAXN 200002
using namespace std;
typedef long long LL;
ll mod=1e9+7;
//     f[0]=f[1]=inv[0]=inv[1]=1;
// for(int i=2;i<MAXN;i++) f[i]=(LL)f[i-1]*i%mod,inv[i]=(LL)(mod-mod/i)*inv[mod%i]%mod;
// for(int i=1;i<MAXN;i++) inv[i]=(LL)inv[i-1]*inv[i]%mod;
ll f[MAXN],inv[MAXN];

ll C(const int n,const int m){return n<m?0:(LL)f[n]*inv[m]%mod*inv[n-m]%mod;}
void dfs(vector<int> vec[], int start, vector<int> &vis, vt<int> &ans)
{
    vis[start] = 1;
    ans.pb(start);
    for (int i = 0; i < vec[start].size(); i++)
    {
        int val = vec[start][i];
        if (vis[val] == 0)
        {
            dfs(vec, val, vis, ans);
        }
    }
    return;
}
ll power(ll num, ll p)
{
    if (p == 0)
        return 1;
    if (p == 1)
        return num;
    ll n = power(num, p / 2);
    if (p % 2 == 0)
        return (n * n)%(998244353) ;
    return (num*((n*n)%(998244353)))%(998244353);
}
ll fact(ll val)
{
    if (val <= 1)
        return 1;
    return (val * fact(val - 1));
}
ll ncr(ll n, ll r)
{
    if (n < r)
        return 0;
    ll p = 1, k = 1;
    if ((n - r) < r)
        r = n - r;

    if (r != 0)
    {
        while (r)
        {
            p = (p * n)%mod;
            k = (k * r)%mod;
            ll m = __gcd(p, k);
            p /= m;
            k /= m;
            n--;
            r--;
        }
    }
    else
        p = 1;
    return p;
}
// bool cmp(pair<int,int> v1, pair<int,int> v2)
// {
//     if(v1.first==v2.first)return v1.second>v2.second;
//     return v1.first<v2.first;
// }
bool isFact(ll n)
{
  for (ll i = 1;; i++) {
    if (n % i == 0) {
      n /= i;
    }
    else {
      break;
    }
  }
 
  if (n == 1LL) {
    return true;
  }
  else {
    return false;
  }
}
int lcs(string s, string t, int m, int n)
{
    if (m==0||n==0)return 0;
    if (s[m-1]==t[n-1])return 1 + lcs(s, t, m - 1, n - 1);
    else return max(lcs(s, t, m, n - 1),lcs(s, t, m - 1, n));
}
pair<ll,ll> maxSubArraySum(vector<ll>&a, int size)
{
    ll max_so_far = 0, max_ending_here = 0;
     int num=0,mx_len=0;
    for (int i = 0; i < size; i++) {
        max_ending_here = (max_ending_here + a[i]);
        num++;
        if (max_so_far < max_ending_here)
            {max_so_far = max_ending_here;mx_len=num;}
        else{
            max_ending_here=0;num=0;
        }
    }
    if(mx_len==size)max_so_far=0;
    return {max_so_far,mx_len};
}
bool isPrime(ll N){
    int flag = 1;

    double sqroot = sqrt(N);

    // Iterate from 2 to sqrt(n)
    for (int i = 2; i <= sqroot; i++) {

        // If n is divisible by any number between 2 and
        // sqrt(n), it is not prime
        if (N % i == 0) {
            flag = 0;
            break;
        }
    }
    return flag;
}
void rev(int start,int ind,int end,vt<int>&vec){
int val=ind+1;
while(val>0){
    for(int i=start;i<end;i++)swap(vec[i],vec[i+1]);
    val--;
}
}
int gcdExtended(ll a, ll b, ll* x, ll* y)
{

    // Base Case
    if (a == 0) {
        *x = 0, *y = 1;
        return b;
    }

    // To store results of recursive call
    ll x1, y1;
    int gcd = gcdExtended(b % a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b / a) * x1;
    *y = x1;

    return gcd;
}
ll modInverse(ll A, ll M)
{
    ll x, y;
    ll g = gcdExtended(A, M, &x, &y);
    if (g != 1)
        return -1;
    else {

        // m is added to handle negative x
        ll res = (x % M + M) % M;
        return res;
    }
}



// bool fun(int a,int b,int X,int Y){
//     double dis1=
// }
ll dfs(int node,vt<int>tree[],vt<int>&v){
    if(tree[node].size()==0)return v[node];
    ll val=1e16;
    for(int i=0;i<tree[node].size();i++){
        val=min(val,dfs(tree[node][i],tree,v));
    }
    return val+v[node];
}
bool dfs(vt<ll>tree[],int node,ll val,vt<ll>&v){
   if(tree[node].size()==0&&v[node]<val)return false;
   if(node==1)val=max(0LL,val-v[node]);
   else if(v[node]<val) val=min((ll)1e15,val+val-v[node]);

   for(auto u:tree[node]){
    if(!dfs(tree,u,val,v))return false;
   }
   return true;
}
bool cmp(pair<int,int>a,pair<int,int>b){
    if(a.second<b.second)return true;
    else return a.first<b.first;
}
int countAndMerge(vector<int>& arr, int l, int m, int r) {
  
    // Counts in two subarrays
    int n1 = m - l + 1, n2 = r - m;

    // Set up two vectors for left and right halves
    vector<int> left(n1), right(n2);
    for (int i = 0; i < n1; i++)
        left[i] = arr[i + l];
    for (int j = 0; j < n2; j++)
        right[j] = arr[m + 1 + j];

    // Initialize inversion count (or result) and merge two halves
    int res = 0;
    int i = 0, j = 0, k = l;
    while (i < n1 && j < n2) {

        // No increment in inversion count if left[] has a 
        // smaller or equal element
        if (left[i] <= right[j]) 
            arr[k++] = left[i++];
      
        // If right is smaller, then it is smaller than n1-i 
          // elements because left[] is sorted
        else {
            arr[k++] = right[j++];
            res += (n1 - i);
        }
    }

    // Merge remaining elements
    while (i < n1)
        arr[k++] = left[i++];
    while (j < n2)
        arr[k++] = right[j++];

    return res;
}

// Function to count inversions in the array
ll countInv(vector<int>& arr, int l, int r){
    ll res = 0;
    if (l < r) {
        int m = (r + l) / 2;

        // Recursively count inversions in the left and 
        // right halves
        res += countInv(arr, l, m);
        res += countInv(arr, m + 1, r);

        // Count inversions such that greater element is in 
          // the left half and smaller in the right half
        res += countAndMerge(arr, l, m, r);
    }
    return res;
}

ll inversionCount(vector<int>& arr) {
      int n = arr.size();
      return countInv(arr, 0, n-1);
}
pair<bool,int> fun(int mid,vt<int>& a,vt<int>& b,int k,int n){
    int cnt=0;
    int buy=0;
    for(int i=0;i<n;i++){
        if(mid<=a[i])buy++;
        else if(mid<=b[i]){cnt++;buy++;}
    }
    if(cnt>k)return {false,buy};
    return {true,buy};
}
ll fun(vt<pair<int,int>>&v1,int n){
    vt<ll>suma(n),sumb(n);
   suma[0]=v1[0].first;
   sumb[0]=v1[0].second;
   for(int i=1;i<n;i++)suma[i]=suma[i-1]+v1[i].first;
   for(int i=1;i<n;i++)sumb[i]=sumb[i-1]+v1[i].second;
   ll val=INT_MIN;
   for(int i=0;i<n;i++){
    ll ans=suma[i]+(sumb[n-1]-sumb[i])+v1[i].second;
    val=max(val,ans);
   }
   return val;
}
pair<int,int> fun(string s,int l,int r,int l_b,int r_b){
    int n=s.size();
    for(int i=l;i<=r;i++){
      bool a=(s[n-(r-i)-1]==s[i]);
      bool b=(s[n-(r-i)-1]==s[i-r+r_b]);
      if(a&&(!b))return {l_b,r_b};
      if((!a)&&b)return {l,r};
    }
    return {l_b,r_b};
}
class N{
    public:
    int x,y,sum,d,val;
};

bool check(string a,string b){
    for(int i=0;i<4;i++){
        if(a[i]!=b[i])return false;
    }
    return true;
}
bool c(ll v){
    while(v>0){
        int d=v%10;
        if(d==4)return true;
        v/=10;
    }
    return false;
}
void _solve1()
{
    int t;cin>>t;
    while(t--){
        int l,r;
        cin>>l>>r;
        int a,b,c;
        a=b=c=0;
        int ind=0;
        for(int i=29;i>=0;i--){
            if((r&(1<<i))&&(l&(1<<i))){
                a|=(1<<i);
                b|=(1<<i);
            }
            else if((r&(1<<i))&&(l&(1<<i))==0){
                ind=i;break;
            }
        }
        for(int i=ind;i>=0;i--){
            if(i==ind){
                a|=(1<<i);
            }
            else{
                b|=(1<<i);
                // c|=(1<<i);
            }
        }
        c=l;
        if(c==b)c++;
        if(c==a)c++;
        // cout<<((a^b)+(b^c)+(c^a))<<'\n';
        cout<<a<<" "<<b<<" "<<(c)<<'\n';
        
    }
}
void _solve2(){
int a=134,b=132,c=137;
cout<<((a^b)+(b^c)+(c^a))<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _solve1();
    // _solve2();
}