Problem: 2057C - Trip to the Olympiad
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 1):
########################################################################################################################
# -----------------------------------------------AUTHOR: shank_555-----------------------------------------------------#
########################################################################################################################
import time
from bisect import bisect_left,bisect_right
import functools
import math
import os
import random
import re
import sys
import threading
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import cmp_to_key, lru_cache, reduce
from heapq import heapify, heappop, heappush, heappushpop, nlargest, nsmallest
from io import BytesIO, IOBase
from itertools import accumulate, combinations, permutations
from operator import add, iand, ior, itemgetter, mul, xor
from string import ascii_lowercase, ascii_uppercase
from typing import *
import collections
import heapq
import itertools
class SafeCounter(Counter):
    """
    A Counter subclass that obfuscates keys using a random 64-bit integer to prevent hash collision attacks.
    
    Only supports integer keys by default. Other key types can be supported by converting them to integers.
    """
    def __init__(self, *args, r64=None, **kwargs):
        self.r64 = r64 or random.getrandbits(64)  # Generate a 64-bit random integer if not provided
        super().__init__(*args, **kwargs)

    def _transform_key(self, key):
        """Apply an XOR-based transformation to the key."""
        if not isinstance(key, int):
            raise TypeError(f"SafeCounter only supports integer keys, got {type(key)}.")
        return key ^ self.r64

    def __setitem__(self, key, value):
        transformed_key = self._transform_key(key)
        super().__setitem__(transformed_key, value)

    def __delitem__(self, key):
        transformed_key = self._transform_key(key)
        super().__delitem__(transformed_key)

    def __getitem__(self, key):
        transformed_key = self._transform_key(key)
        return super().__getitem__(transformed_key)

    def __contains__(self, key):
        transformed_key = self._transform_key(key)
        return super().__contains__(transformed_key)
def input(): return sys.stdin.readline().rstrip("\r\n")
alphabets = list("abcdefghijklmnopqrstuvwxyz")
vowels = list("aeiou")
MOD1 = int(1e9 + 7)
MOD2 = 998244353
INF = int(1e17)
I = lambda: input()
II = lambda: int(input())
MII = lambda: map(int, input().split())
LI = lambda: list(input().split())
LII = lambda: list(map(int, input().split()))
LGMII = lambda: map(lambda x: int(x) - 1, input().split())
LGLII = lambda: list(map(lambda x: int(x) - 1, input().split()))
inf = float('inf')
def solve():
    a = 0
    b = 0
    l,r = LII()
    n = r.bit_length()
    for i in range(n,-1,-1):
        b1 = 1 if l & (1 << i) else 0
        b2 = 1 if r & (1 << i) else 0
        if b1==b2:        
            a+=b1*(1<<i)
            continue
        else:
            a =  a + (1<<i)
            b = a - 1
            break
    c = 0
    for i in range(l,r + 1):
        if i!=a and i!=b:
            c = i
            break
    print(a ,b, c)
for _ in range(II()):
    t  = solve()
    #print(t)
    #print("YES" if t else "NO")
    #print("NO" if t else "NO")


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;

pair<long long, long long> findMaxXORPairEfficient(long long l, long long r) {
    long long x = l ^ r;
    int k = 0;
    while (x) {
        k++;
        x >>= 1;
    }
    long long maxXor = ((long long)1 << k) - 1;
    long long partner = r ^ maxXor;
    if (partner >= l && partner <= r)
        return {partner, r};
    partner = l ^ maxXor;
    if (partner >= l && partner <= r)
        return {l, partner};
    return {l, r};
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        long long l, r,third;
        cin >> l >> r;
        pair<long long, long long> result = findMaxXORPairEfficient(l, r);
        if(result.first!=l){third=l;} else{if(result.second!=r){third=r;}else{third=(l+r)/2;}}
        cout << result.first <<" "<< third<<" "<< result.second <<endl;
    }
    return 0;
}