Problem: 2057C - Trip to the Olympiad
Language: java

Solution 1 (runtime: 421 ms):
// package prectice;

import java.lang.reflect.Array;
import java.math.BigInteger;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;
import java.util.regex.Pattern;
import java.util.stream.Stream;




public class P1 {
	
	public static BigInteger factorial(int n) {
        BigInteger fact = BigInteger.ONE;
        for (int i = 1; i <= n; i++) {
            fact = fact.multiply(BigInteger.valueOf(i));
        }
        return fact;
    }
	

    // Method to calculate nCr using BigInteger
	
    public static int nCr(int n, int r) {
        if (r > n) {
            return 0;
        }
        BigInteger numerator = factorial(n);
        BigInteger denominator = factorial(r).multiply(factorial(n - r));
        BigInteger result = numerator.divide(denominator);
        return result.intValue();  // Cast to int
    }
    
    public static long gcd(long a,long b) {
    	if(b == 0) {
    		return a;
    	}
    	return gcd(b,a%b);
    }
    
	public static void dfs(List<List<Integer>> edge,int u,int p,int[] d,int[] s) {
	    	
		s[u] = 1;
		for(int v : edge.get(u)) {
			if(v == p) {
				continue;
			}
			d[v] = d[u]+1;
			dfs(edge,v,u,d,s);
			s[u] += s[v];
		}
	    	
	}
	
	public static void dfs2(List<List<Integer>> edge,int u,int p,int sd,int[] s,int[] ans,int n) {
		
		ans[u] = sd;
		
		for(int v : edge.get(u)) {
			if(v == p) {
				continue;
			}
			int sdv = sd + n - 2*s[v];
			dfs2(edge,v,u,sdv,s,ans,n);
		}
		
	}
	
	public static long f(long n,int k) {
		if((n+1)/2 >= k && n != 1) {
			return f((n+1)/2,k);
		}
		return n;
	}

    	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		
//		StringBuilder ansf = new StringBuilder("");

		
		while(t-- > 0) {
			
			int n = sc.nextInt();
			int m = sc.nextInt();
			
			int nn = n;
			int mm = m;
		
			int[] ar1 = new int[30];
			int[] ar2 = new int[30];
			
			for(int i=29;i>=0;i--) {
				ar1[i] = n%2;
				n/=2;
				ar2[i] = m%2;
				m/=2;
			}
			
			int ans = -1;
			for(int i=0;i<30;i++) {
				if(ar1[i] != ar2[i]) {
					ans = i;
					break;
				}
			}
			
			int a = 0;
			int b = 0;
			for(int i=0;i<30;i++) {
				if(i < ans) {
					a  = a*2 + ar1[i];
					b  = b*2 + ar1[i];
				}
				else if(i == ans) {
					a = a*2 + 1;
					b = b*2;
				}
				else {
					b = b*2 + 1;
					a = a*2;
				}
			}
			
			int c = 0;
			for(int i=nn;i<=mm;i++) {
				if(i != a && i != b) {
					c = i;
					break;
				}
			}
			
			System.out.println(a + " " + b + " " + c);
			
			
		}
		
	}
	
}





Solution 2 (runtime: 265 ms):
#include<bits/stdc++.h>
using namespace std;

#define int long long

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vbl = vector<bool>;
using vpii = vector<pii>;
template<class T> using vv = vector<vector<T>>;

#define pb emplace_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define siz(v) (int)(size(v))

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (b); i--)
#define rept(a) rep(_, 1, a)

#define watch(x) cout << (#x) << ':' << (x) << '\n';
#define watch2(x, y) cout << (#x) << ':' << (x) << ',' << (#y) << ':' << (y) << '\n';

template<class T> bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os << '{' << p.first << ',' << p.second << '}';
}
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	for (auto &x : v) os << x << ' ';
	return os;
}

const int inf = 1e9;
const ll llinf = 4e18;

void orz()
{
    int l, r; cin >> l >> r;
    rrep(i, 30, 0){
        if ((l>>i)^(r>>i)){
            cout << (1<<i) << ' ' << ((1<<i)-1) << ' ' << ((1<<i)-2 < l ? (1<<i)+1 : (1<<i)-2) << '\n';
            return;
        }
    }
}

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin.exceptions(cin.failbit);

    int t = 1; cin >> t;
    while (t--) orz();

    return 0;
}