ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 311 ms):

import sys,random,bisect,math
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

for _ in range(int(input())):
    l,r=mi()
    a=-1
    for i in range(31):
        if(1<<i >r):
            a=i
            break
    
    num=1<<(a-1)
    rbin=bin(r)[2:]



    # i=a-2
    # while(num-1<l or num-1>r):
    #     num+=(1<<i)
    #     i-=1
    # print(num-1,num,num+1)
    num=0
    o=0
    for i in range(len(rbin)):
        if(rbin[i]=="1"):
            num+=(1<<(len(rbin)-i-1))
        
        if(num-1>=l and num!=r):
            o=1
            break

        elif(num-2>=l):
            o=2
            break
    
    if(o==1):
        out=[num-1,num,num+1]
    else:
        out=[num-2,num-1,num]
    print(*out)





    
        




Solution 2 (runtime: 234 ms):
t=int(input())
for i in range(t):
    l,r=map(int,input().split())
    a=bin(l)[2::]
    b=bin(r)[2::]
    i=32
    c=0
    while True:
        if(((1<<i)&r)!=0):
            c=max(c,i)
            if(((1<<i)&l)==0):
                break
        i-=1
    top_bits = l & ~((1 << i) - 1)
    x = top_bits | (1 << i)

    y = top_bits | ((1 << i) - 1)


    if(((y+1)<=r) and ((y+1)!=x) and ((y+1)>=l)):
        print(y,x,y+1)
    elif((x+1)<=r ):
        print(y,x,x+1)
    elif(y!=l):
        print(l,x,y)
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 311 ms):

import sys,random,bisect,math
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

for _ in range(int(input())):
    l,r=mi()
    a=-1
    for i in range(31):
        if(1<<i >r):
            a=i
            break
    
    num=1<<(a-1)
    rbin=bin(r)[2:]



    # i=a-2
    # while(num-1<l or num-1>r):
    #     num+=(1<<i)
    #     i-=1
    # print(num-1,num,num+1)
    num=0
    o=0
    for i in range(len(rbin)):
        if(rbin[i]=="1"):
            num+=(1<<(len(rbin)-i-1))
        
        if(num-1>=l and num!=r):
            o=1
            break

        elif(num-2>=l):
            o=2
            break
    
    if(o==1):
        out=[num-1,num,num+1]
    else:
        out=[num-2,num-1,num]
    print(*out)





    
        




Solution 2 (runtime: 187 ms):
if __name__ == "__main__":
    t = int(input())
    while t > 0:
        l, r = list(map(int, input().split()))
        ans = 0
        for i in range(30, -1, -1):
            if (r & (1 << i)) != 0 and (l & (1 << i)) != 0:
                ans |= (1 << i)  # Set the i-th bit in `ans`
            elif (r & (1 << i)) != 0:
                for j in range(i-1, -1, -1):
                    if (r & (1 << j)) == 0 and (l & (1 << j)) != 0:
                        continue
                    else:
                        if (r & (1 << j)) != 0:
                            ans |= (1 << i)
                        else:
                            for k in range(i - 1, j - 1, -1):
                                ans |= (1 << k)

                        for k in range(j - 1, -1, -1):
                            if (r & (1 << k)) == 0 and (l & (1 << k)) == 0:
                                ans |= (1 << k)
                            elif (r & (1 << k)) != 0 and (l & (1 << k)) != 0:
                                 continue
                            else:
                                ans |= (1 << k)
                        break
                    # print(i, j)
                break
        print(f"{l} {ans} {r}")
        t -= 1
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 311 ms):

import sys,random,bisect,math
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

for _ in range(int(input())):
    l,r=mi()
    a=-1
    for i in range(31):
        if(1<<i >r):
            a=i
            break
    
    num=1<<(a-1)
    rbin=bin(r)[2:]



    # i=a-2
    # while(num-1<l or num-1>r):
    #     num+=(1<<i)
    #     i-=1
    # print(num-1,num,num+1)
    num=0
    o=0
    for i in range(len(rbin)):
        if(rbin[i]=="1"):
            num+=(1<<(len(rbin)-i-1))
        
        if(num-1>=l and num!=r):
            o=1
            break

        elif(num-2>=l):
            o=2
            break
    
    if(o==1):
        out=[num-1,num,num+1]
    else:
        out=[num-2,num-1,num]
    print(*out)





    
        




Solution 2 (runtime: 202 ms):
def read_list():
    return list(map(int, input().split()))


def f(a, b, c):
    return (a ^ b) + (b ^ c) + (c ^ a)


class Solution:
    def solve(self):
        l, r = tuple(read_list())
        L = l
        R = r
        lb = []
        rb = []
        for _ in range(32):
            lb.append(l % 2)
            l //= 2
            rb.append(r % 2)
            r //= 2
        for i in range(31, -1, -1):
            if lb[i] != rb[i]:
                assert lb[i] == 0 and rb[i] == 1
                X = L | ((1 << i) - 1)
                if L < X:
                    print(L, X, X + 1)
                else:
                    print(X, X + 1, X + 2)
                break


if __name__ == "__main__":
    tests = int(input())
    for _ in range(tests):
        Solution().solve()
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 311 ms):

import sys,random,bisect,math
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

for _ in range(int(input())):
    l,r=mi()
    a=-1
    for i in range(31):
        if(1<<i >r):
            a=i
            break
    
    num=1<<(a-1)
    rbin=bin(r)[2:]



    # i=a-2
    # while(num-1<l or num-1>r):
    #     num+=(1<<i)
    #     i-=1
    # print(num-1,num,num+1)
    num=0
    o=0
    for i in range(len(rbin)):
        if(rbin[i]=="1"):
            num+=(1<<(len(rbin)-i-1))
        
        if(num-1>=l and num!=r):
            o=1
            break

        elif(num-2>=l):
            o=2
            break
    
    if(o==1):
        out=[num-1,num,num+1]
    else:
        out=[num-2,num-1,num]
    print(*out)





    
        




Solution 2 (runtime: 155 ms):
a = int(input()) 
for i in range(a):
    l, r = map(int, input().split()) 
    x = r - l + 1
    y = 1 
    while y<x:
        y *= 2 
    f1 = l - (l%y) 
    if l & y == r & y:
        l1 = l %y
        r1 = r %y 
        x1 = y - l1 - 1
        y1 = l1
        if x1 > r1:
            x1 = y - r1 - 1 
            y1 = r1 
        z1 = r1 
        while z1 == x1 or z1 == y1:
            z1 -= 1 
        print(x1+f1, y1+f1, z1+f1,sep = " ")
    else:
        x1 = f1 + y - 1 
        x2 = r - (r%y)
        x3 = r 
        while x3 == x1 or x3 == x2:
            x3 -= 1 
        print(x1,x2,x3, sep = " ")
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 311 ms):

import sys,random,bisect,math
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

for _ in range(int(input())):
    l,r=mi()
    a=-1
    for i in range(31):
        if(1<<i >r):
            a=i
            break
    
    num=1<<(a-1)
    rbin=bin(r)[2:]



    # i=a-2
    # while(num-1<l or num-1>r):
    #     num+=(1<<i)
    #     i-=1
    # print(num-1,num,num+1)
    num=0
    o=0
    for i in range(len(rbin)):
        if(rbin[i]=="1"):
            num+=(1<<(len(rbin)-i-1))
        
        if(num-1>=l and num!=r):
            o=1
            break

        elif(num-2>=l):
            o=2
            break
    
    if(o==1):
        out=[num-1,num,num+1]
    else:
        out=[num-2,num-1,num]
    print(*out)





    
        




Solution 2 (runtime: 171 ms):
//[amzad]: {{amjadimran004}}
#include <bits/stdc++.h>
using namespace std;
 
#define cY    cout << "YES"  << '\n'
#define cN    cout<<"NO"<<'\n'
#define ll    long long
#define ull   unsigned ll
#define ld    long double
#define pii   pair<int,int>
#define pll   pair<ll,ll>
#define vi    vector<int>
#define vll   vector<ll>
#define vvi   vector<vi>
#define vvll  vector<vll>
#define endl  '\n'
 
#define loop(a,b)    for(int i=(a);i<(b);i++)
#define rloop(a,b)   for(int i=(a);i>=(b);i--)
#define each(a,x)    for(auto &a:(x))
 
#define min3(a,b,c)  min( (a), min( (b), (c) ) )
#define max3(a,b,c)  max( (a), max( (b),(c) ) )
 
constexpr ll MOD = 1e9+7;
constexpr ld EPS = 1e-9;
 
struct HASH {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED = chrono::steady_clock::now()
                                   .time_since_epoch().count();
    return splitmix64(x + FIXED);
  }
};
 
void fastIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
  cout.precision(20); cout.setf(ios::fixed);
}
 
#ifdef DEBUG
#define d_print(...) { cout << "[" << #__VA_ARGS__ << "]: "; \
                     dbg_out(__VA_ARGS__); }
template <typename... Args>
void dbg_out(Args... args) {
  ((cout << args << " "), ...); cout << endl;
}
#else
#define d_print(...)
#endif
 
void solve() {
  int l, r;
  cin >> l >> r;
  int k = 31 - __builtin_clz(l ^ r);
  int a = l | ((1 << k) - 1);
  int b = a + 1;
  int c = (a == l ? r : l);
  cout << a << ' ' << b << ' ' << c << endl;
}
 
int main(){
  fastIO();
  int t = 1;
  cin >> t;
  while(t--) {
    solve();
  }
  return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 311 ms):

import sys,random,bisect,math
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

for _ in range(int(input())):
    l,r=mi()
    a=-1
    for i in range(31):
        if(1<<i >r):
            a=i
            break
    
    num=1<<(a-1)
    rbin=bin(r)[2:]



    # i=a-2
    # while(num-1<l or num-1>r):
    #     num+=(1<<i)
    #     i-=1
    # print(num-1,num,num+1)
    num=0
    o=0
    for i in range(len(rbin)):
        if(rbin[i]=="1"):
            num+=(1<<(len(rbin)-i-1))
        
        if(num-1>=l and num!=r):
            o=1
            break

        elif(num-2>=l):
            o=2
            break
    
    if(o==1):
        out=[num-1,num,num+1]
    else:
        out=[num-2,num-1,num]
    print(*out)





    
        




Solution 2 (runtime: 202 ms):
#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;
}
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 311 ms):

import sys,random,bisect,math
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

for _ in range(int(input())):
    l,r=mi()
    a=-1
    for i in range(31):
        if(1<<i >r):
            a=i
            break
    
    num=1<<(a-1)
    rbin=bin(r)[2:]



    # i=a-2
    # while(num-1<l or num-1>r):
    #     num+=(1<<i)
    #     i-=1
    # print(num-1,num,num+1)
    num=0
    o=0
    for i in range(len(rbin)):
        if(rbin[i]=="1"):
            num+=(1<<(len(rbin)-i-1))
        
        if(num-1>=l and num!=r):
            o=1
            break

        elif(num-2>=l):
            o=2
            break
    
    if(o==1):
        out=[num-1,num,num+1]
    else:
        out=[num-2,num-1,num]
    print(*out)





    
        




Solution 2 (runtime: 124 ms):
import sys
input = sys.stdin.readline

S = lambda: input()
I = lambda: int(input())
M = lambda: map(int, input().split())

for _ in range(I()):
    l, r = M()
    n = l ^ r
    k = n.bit_length() - 1
    a = l | ((1 << k) - 1)
    b = a + 1
    c = l if a == r or b == r else r
    print(a, b, c)
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 311 ms):

import sys,random,bisect,math
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

for _ in range(int(input())):
    l,r=mi()
    a=-1
    for i in range(31):
        if(1<<i >r):
            a=i
            break
    
    num=1<<(a-1)
    rbin=bin(r)[2:]



    # i=a-2
    # while(num-1<l or num-1>r):
    #     num+=(1<<i)
    #     i-=1
    # print(num-1,num,num+1)
    num=0
    o=0
    for i in range(len(rbin)):
        if(rbin[i]=="1"):
            num+=(1<<(len(rbin)-i-1))
        
        if(num-1>=l and num!=r):
            o=1
            break

        elif(num-2>=l):
            o=2
            break
    
    if(o==1):
        out=[num-1,num,num+1]
    else:
        out=[num-2,num-1,num]
    print(*out)





    
        




Solution 2 (runtime: 436 ms):

// "Oyyyy...she has a gold which is black"


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;


#define endl "\n"
#define int long long




void solve() { 
    int l,r; cin>>l>>r; 
    int k; 
    for (int i=30;i>=0;i--) {
        if ((r&(1LL<<i))!=(l&(1LL<<i))) {
            k=i; 
            break;
        }
    }
    //cout<<k<<endl;
    int x=0; 
    for (int i=30;i>=k;i--) {
        if (r&(1LL<<i)) {
            x+=(1LL<<i);
        }
    }
    int y=x-1; 
    cout<<x<<" "<<y<<" "; 
    if (y==l) {
        cout<<r<<endl;
    }
    else {
        cout<<l<<endl;
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
        
    
    int tc=1; 
    cin>>tc; 
    while (tc--) {
        solve();
    }
    
 
    return 0;

}   
 


/* 

        “What is happening is actually terrifying. I mean what happened to me all on a sudden?”

                         
                                                                                                              
*/
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 311 ms):

import sys,random,bisect,math
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

for _ in range(int(input())):
    l,r=mi()
    a=-1
    for i in range(31):
        if(1<<i >r):
            a=i
            break
    
    num=1<<(a-1)
    rbin=bin(r)[2:]



    # i=a-2
    # while(num-1<l or num-1>r):
    #     num+=(1<<i)
    #     i-=1
    # print(num-1,num,num+1)
    num=0
    o=0
    for i in range(len(rbin)):
        if(rbin[i]=="1"):
            num+=(1<<(len(rbin)-i-1))
        
        if(num-1>=l and num!=r):
            o=1
            break

        elif(num-2>=l):
            o=2
            break
    
    if(o==1):
        out=[num-1,num,num+1]
    else:
        out=[num-2,num-1,num]
    print(*out)





    
        




Solution 2 (runtime: 327 ms):
for _ in range(int(input())):
    b, a = map(int, input().split())
    k = (1 << ((a^b).bit_length()-1)) - 1
    if (b|k == b):
        m = (b|k)+2
    else:
        m = (b | k) -1
    print(b | k, m, (b | k) +1)
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 187 ms):
res = []

def Solve():
    l,r = map(int, input().split())
    lll, rrr = l, r
    ll = []
    rr = []
    while r > 0:
        ll.append(l % 2)
        rr.append(r % 2)
        r //= 2
        l //= 2
    ind = -1
    for index in range(len(ll)):
        if ll[index] != rr[index]:
            ind = index
    pp = [0] * ind + rr[ind:]
    p = 0
    for x in pp[::-1]:
        p = 2*p + x
    res = [p, p - 1]
    while rrr in res:
        rrr -= 1
    res.append(rrr)
    return res

for _ in range(int(input())):
    res.append(Solve())

for a in res:
    print(*a)

Solution 2 (runtime: 202 ms):
test = int(input())
def calcule(a, b, c):
    return (a^b)+(a^c)+(b^c)
for i in range(test):
    l, r = list(map(int, input().split()))
    #l, r  = "{:31b}".format(l), "{:31b}".format(r)
    dernierBit = (l^r).bit_length()-1
    maxi = 2**32-1
    maxi = maxi^(2**(dernierBit)-1)
    chiffre = maxi&r
    if chiffre-2 <l:
        print(chiffre, chiffre-1, chiffre+1)
    else:
        print(chiffre, chiffre-1, chiffre-2)
    # print(bin(l))
    # print(bin(r))
    # print(dernierBit)
    # a, b, c = 2**dernierBit, 2**dernierBit-1, 2**dernierBit-2
    # print(a, b, c)
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 187 ms):
res = []

def Solve():
    l,r = map(int, input().split())
    lll, rrr = l, r
    ll = []
    rr = []
    while r > 0:
        ll.append(l % 2)
        rr.append(r % 2)
        r //= 2
        l //= 2
    ind = -1
    for index in range(len(ll)):
        if ll[index] != rr[index]:
            ind = index
    pp = [0] * ind + rr[ind:]
    p = 0
    for x in pp[::-1]:
        p = 2*p + x
    res = [p, p - 1]
    while rrr in res:
        rrr -= 1
    res.append(rrr)
    return res

for _ in range(int(input())):
    res.append(Solve())

for a in res:
    print(*a)

Solution 2 (runtime: 171 ms):
import sys
# input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

for _ in range(ni()):
    l, r = na()
    L = 0
    X = 0
    R = 0
    FLAG = 0
    for i in range(30, -1, -1):
        ll = l >> i & 1
        rr = r >> i & 1
        if FLAG:
            L |= 1 << i
        elif ll == rr:
            L |= ll << i
            R |= rr << i
            X |= ll << i
        else:
            R |= 1 << i
            FLAG = 1
    # assert l <= L <= r and l <= R <= r and l <= L ^ 1 <= r
    # assert (L ^ 1 != R)
    if l <= L ^ 1 <= r and L^1 != R:
        print(L, L^1, R)
    elif l <= R ^ 1 <= r and R^1 != L:
        print(L, R^1, R)
    else:
        assert False
    #print(bin(L), bin(L^1), bin(R))
    # print(print(bin(L^R)))
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 187 ms):
res = []

def Solve():
    l,r = map(int, input().split())
    lll, rrr = l, r
    ll = []
    rr = []
    while r > 0:
        ll.append(l % 2)
        rr.append(r % 2)
        r //= 2
        l //= 2
    ind = -1
    for index in range(len(ll)):
        if ll[index] != rr[index]:
            ind = index
    pp = [0] * ind + rr[ind:]
    p = 0
    for x in pp[::-1]:
        p = 2*p + x
    res = [p, p - 1]
    while rrr in res:
        rrr -= 1
    res.append(rrr)
    return res

for _ in range(int(input())):
    res.append(Solve())

for a in res:
    print(*a)

Solution 2 (runtime: 218 ms):
t = int(input())

while t > 0:
    t -= 1
    l, r = map(int, input().split())

    ans = 0
    a, b, c = 0, 0, 0

    for i in range(30, -1, -1):
        b1 = 1 if (l & (1 << i)) else 0
        b2 = 1 if (r & (1 << i)) else 0

        if b1 == b2:
            ans += b1 * (1 << i)
        else:
            a = ans + (1 << i)
            b = a - 1
            break

    for i in range(l, r + 1):
        if i != a and i != b:
            c = i
            break

    print(a, b, c)
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 187 ms):
res = []

def Solve():
    l,r = map(int, input().split())
    lll, rrr = l, r
    ll = []
    rr = []
    while r > 0:
        ll.append(l % 2)
        rr.append(r % 2)
        r //= 2
        l //= 2
    ind = -1
    for index in range(len(ll)):
        if ll[index] != rr[index]:
            ind = index
    pp = [0] * ind + rr[ind:]
    p = 0
    for x in pp[::-1]:
        p = 2*p + x
    res = [p, p - 1]
    while rrr in res:
        rrr -= 1
    res.append(rrr)
    return res

for _ in range(int(input())):
    res.append(Solve())

for a in res:
    print(*a)

Solution 2 (runtime: 187 ms):
t = int(input())

for _ in range(t):
    l,r = map(int,input().split())
    k = (l ^ r).bit_length() - 1
    a = l|(2**k-1)
    b = a + 1
    for c in range(l,r+1):
        if c != a and c!= b:
            print(a,b,c)
            break
Problem: 2057C - Trip to the Olympiad
Language: python

Solution 1 (runtime: 187 ms):
res = []

def Solve():
    l,r = map(int, input().split())
    lll, rrr = l, r
    ll = []
    rr = []
    while r > 0:
        ll.append(l % 2)
        rr.append(r % 2)
        r //= 2
        l //= 2
    ind = -1
    for index in range(len(ll)):
        if ll[index] != rr[index]:
            ind = index
    pp = [0] * ind + rr[ind:]
    p = 0
    for x in pp[::-1]:
        p = 2*p + x
    res = [p, p - 1]
    while rrr in res:
        rrr -= 1
    res.append(rrr)
    return res

for _ in range(int(input())):
    res.append(Solve())

for a in res:
    print(*a)

Solution 2 (runtime: 171 ms):
import collections
import decimal
import math
import random
import time
import sys
from heapq import heappop, heappush
from collections import deque
from decimal import Decimal
import queue
import os
from copy import deepcopy
from collections import Counter

mod = 10 ** 9 + 7
# mod = 998244353
INF = 1 << 90


def solve(test_case):
    l, r = map(int, sys.stdin.readline().split())

    p = 0

    for i in range(32, -1, -1):
        if ((l & (1 << i)) != 0) != ((r & (1 << i)) != 0):
            p += (1 << i)
            break

        p += (1 << i) * int((l & (1 << i)) != 0)

    if p - 1 > l:
        res = [p, p - 1, p - 2]
    elif p - 1 == l:
        res = [p + 1, p, p - 1]
    else:
        res = [p + 2, p + 1, p]

    sys.stdout.write(' '.join(map(str, res)) + '\n')

    return


if __name__ == '__main__':
    multitest = 1
    if multitest:
        t = int(sys.stdin.readline())
        for _ in range(t):
            solve(_)
    else:
        solve(0)