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

Previous submission (verdict: Wrong answer on test 1):
#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;
   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);
      xl;
      return;
   }
   else if (term < l)
   {
      f(l - term, r - term, extra + term);
      return;
   }
   else if (term - 1 >= l)
   {
      print(term + extra);
      print(r + extra);
      print(term - 1 + extra);
      xl;
      return;
   }
   else
   {
      print(r - 1 + extra);
      print(r + extra);
      print(term - 1 + 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);
   }
}

Submission (verdict: Wrong answer on test 2):
#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;
   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 + 2 + 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);
   }
}