Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 109 ms):
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() 
{
    int t;
    cin >> t;
    while(t--)
    {
        ll l, r, dummy;
        cin >> l >> r;
        ll z = log2(r);
        dummy = 0;
        if(l < pow(2, z) && r >= pow(2, z))
        {
            //if(l == pow(2, z)) cout << l << " " << r << " " << l + 1;
            if(l == pow(2, z) - 1) cout << (ll) l << " " << (ll) pow(2, z) << " " << (ll) r;
            else if(l != pow(2, z)) cout << (ll) pow(2, z) << " "  << (ll)(pow(2, z) - 1) << " " <<  (ll) l;
        }
        else
        {
            ll a = l; 
            ll c = r;
            z = pow(2, z);
            //cout << z << endl;
            while(z <= a && z < c)
            {
                dummy += z;
                a -= z;
                c -= z;
                z = log2(c);
                z = pow(2, z);
            }
            //cout << z << endl;
            //if(z == a) cout << z + dummy << " " << z + dummy - 1 << " " << a + ;
            if(z == c) cout << z + dummy << " " << z - 1 + dummy << " " << a + dummy;
            else
            {
                if(z - 1 == a) cout << z + dummy << " " << z - 1 + dummy<< " " << c + dummy;
                else cout << z + dummy << " " << z - 1 + dummy<< " " << a + dummy;
            }
        }
        cout << endl;
    }
    return 0;
}

Solution 2 (runtime: 77 ms):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl "\n"
#define Y cout << "YES" << endl
#define N cout << "NO" << endl
#define Al cout << "ALICE" << endl
#define Bo cout << "BOB" << endl
#define int long long
#define pb push_back
#define popb pop_back
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vpii vector<pair<int, int>>
#define vpiii vector<pair<pair<int, int>, int>>
#define mii map<int, int>
#define si set<int>
#define pii pair<int, int>
#define piii pair<pair<int, int>, int>
#define all(x) x.begin(), x.end()
#define INT_MAX LLONG_MAX
#define INT_MIN LLONG_MIN
#define cnt continue
#define lb lower_bound
#define ub upper_bound
#define SUM(x) accumulate(x.begin(), x.end(), 0LL)
#define pminus cout << -1 << endl
using namespace std;
#define printl(x) cout << x << endl
#define xl cout << endl
#define read(a)      \
   for (auto &i : a) \
   cin >> i
#define printa(a)            \
   for (auto &i : a)         \
      std::cout << i << " "; \
   std::cout << "\n"
#define print(x) cout << x << " "
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> pbdsp;
const int M = (int)(1e9 + 7);

/*----------------------debugger-----------------------------*/
#ifndef ONLINE_JUDGE
#define dbg(x)          \
   cerr << #x << " : "; \
   __print__d(x);       \
   cerr << endl;
#else
#define dbg(x)
#endif

void __print__d(int x) { cerr << x; }
void __print__d(char x) { cerr << x; }
void __print__d(string x) { cerr << x; }
void __print__d(double x) { cerr << x; }
void __print__d(float x) { cerr << x; }
void __print__d(bool x) { cerr << x; }
template <class T>
void __print__d(vector<T> v)
{
   cerr << " [ ";
   for (T i : v)
   {
      __print__d(i);
      cerr << ' ';
   }
   cerr << "] ";
}
template <class P1, class P2>
void __print__d(pair<P1, P2> x)
{
   cerr << " { ";
   __print__d(x.first);
   cerr << " -> ";
   __print__d(x.second);
   cerr << " } " << endl;
}
template <class T>
void __print__d(set<T> v)
{
   cerr << " [ ";
   for (T i : v)
   {
      __print__d(i);
      cerr << ' ';
   }
   cerr << "] ";
}
template <class T>
void __print__d(multiset<T> v)
{
   cerr << " [ ";
   for (T i : v)
   {
      __print__d(i);
      cerr << ' ';
   }
   cerr << "] ";
}
template <class T>
void __print__d(map<T, T> v)
{
   cerr << " [ ";
   for (pair<T, T> i : v)
   {
      __print__d(i);
      cerr << ' ';
   }
   cerr << "] ";
}

int meth(int x)
{
   for (int i = 0;; i++)
   {
      if ((1 << i) > x)
      {
         return i - 1;
      }
   }
}
void f(int l, int r, int extra)
{
   if (r - l == 2)
   {
      print(r + extra);
      print(l + extra);
      print(l + 1 + extra);
      xl;
      return;
   }
   int hp2 = meth(r);
   int term = 1 << hp2;
   // dbg(term);
   int terml = 1 << (hp2 - 1);
   if (term == r)
   {
      print(term + extra);
      print(term - 1 + extra);
      print(term - 2 + extra);
      xl;
      return;
   }
   else if (term == l)
   {
      // print(term + extra);
      // print(r + extra);
      // print(r - 1 + extra);
      f(l - term, r - term, extra + term);
      // xl;
      return;
   }
   else if (term < l)
   {
      f(l - term, r - term, extra + term);
      return;
   }
   else if (term - 1 == l)
   {
      print(term + extra);
      print(term - 1 + extra);
      print(term + 1 + extra);
      xl;
      return;
   }
   else
   {
      print(term + extra);
      print(term - 1 + extra);
      print(r + extra);
      xl;
      return;
   }
}
/*----------------------maincode-----------------------------*/
int32_t main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int t;
   cin >> t;
   while (t--)
   {
      int l, r;
      cin >> l >> r;
      f(l, r, 0);
   }
}