ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: python

Solution 1 (runtime: 187 ms):
for q in range(int(input())):
    n,k=list(map(int,input().split(' ')))
    a=list(map(int,input().split(' ')))
    b=set(a)
    d={}
    for i in b:
        d[i]=0
    for i in a:
        d[i]+=1
    l=[]
    for i in d:
        l.append(d[i])
    pre=0
    ans=len(l)
    l.sort()
    for i in range(len(l)):
        if(pre+l[i]<=k):
            pre+=l[i]
            ans-=1
    print(max(ans,1))

Solution 2 (runtime: 249 ms):
t = int(input())
while t:
	t -= 1
	n, k =  map(int, input().split())
	ordem = {}
	array = list(map(int, input().split()))
	array.sort()
	freq = []

	prev = array[0]
	count = 0
	for num in array:
		if num != prev:
			freq.append(count)
			count = 0
		count += 1
		prev = num		
	freq.append(count)
	freq.sort()
	
	sum = 0
	count = 0
	for num in freq:
		sum += num
		if k >= sum:
			count += 1
		else:
			break
	
	print(max(1, len(freq)-count))
Problem: 2057B - Gorilla and the Exam
Language: python

Solution 1 (runtime: 187 ms):
for q in range(int(input())):
    n,k=list(map(int,input().split(' ')))
    a=list(map(int,input().split(' ')))
    b=set(a)
    d={}
    for i in b:
        d[i]=0
    for i in a:
        d[i]+=1
    l=[]
    for i in d:
        l.append(d[i])
    pre=0
    ans=len(l)
    l.sort()
    for i in range(len(l)):
        if(pre+l[i]<=k):
            pre+=l[i]
            ans-=1
    print(max(ans,1))

Solution 2 (runtime: 249 ms):
for _ in range(int(input())):
  n, k = list(map(int, input().split()))
  a = list(map(int, input().split()))
  
  a.sort()
  # store the freq of nums
  cnt = [1]
  for i in range(1, n):
    if a[i] == a[i-1]:
      cnt[-1] += 1
    else:
      cnt.append(1)
  
  # sort the cnts to check with k and convert them to min
  cnt.sort()
  m = len(cnt)
  flag = False
  for i in range(m-1):
    if cnt[i] > k:
      # we can't change any ai so
      print(m-i)
      flag = True
      break
    
    k -= cnt[i]
  
  if flag == False:
    print(1)
Problem: 2057B - Gorilla and the Exam
Language: python

Solution 1 (runtime: 312 ms):
import bisect
t=int(input())
for i in range(t):
    n,k=map(int,input().split())
    l=list(map(int,input().split()))
    l.sort()
    f=[]
    c=1
    for i in range(1,n):
        if(l[i]==l[i-1]):
            c+=1
        else:
            f.append(c)
            c=1
    f.append(c)
    f.sort()
    x=0

    pf=[]
    for j in f:
        x+=j
        pf.append(x)
    v=bisect.bisect_left(pf,k)
    y=0
    #print(pf,v)
    if(v==n):
        print(1)
    elif(v==0):
        if(k!=0):
            if(k<pf[0]):
                y=1
                print(max(1,len(f)-1-v+y))
            else:
                print(max(1,len(f)-1-v))
        else:
            print(len(f))
    elif(k<pf[v]):
        y=1
        print(len(f)-1-v+y)
    
    else:
        print(max(1,len(f)-1-v))





    



Solution 2 (runtime: 187 ms):
import sys
from collections import Counter

input = sys.stdin.readline
output = sys.stdout.write
str_input = lambda: input().strip()
int_input = lambda: int(input())
multi_int_input = lambda: map(int, input().split())
list_input = lambda: list(map(int, input().split()))
P1 = lambda X: result_array.append(f"{X}\n")
P2 = lambda X,Y: result_array.append(f"{X} {Y}\n")
P3 = lambda X,Y,Z: result_array.append(f"{X} {Y} {Z}\n")
PA = lambda X: result_array.append(f"{' '.join(map(str,X))}\n")


def solve(test_case):
    N,K = multi_int_input()
    arr = list_input()

    check = Counter()
    for i in arr:
        check[str(i)] += 1
    check = sorted(check.values(),reverse=True)

    while check:
        if check[-1] <= K:
            K -= check.pop()
        else:
            break
    
    P1(max(1,len(check)))


tc = 1
tc = int_input()
result_array = []
for test_case in range(1,tc+1):
    solve(test_case)
output(''.join(result_array))
Problem: 2057B - Gorilla and the Exam
Language: python

Solution 1 (runtime: 312 ms):
import bisect
t=int(input())
for i in range(t):
    n,k=map(int,input().split())
    l=list(map(int,input().split()))
    l.sort()
    f=[]
    c=1
    for i in range(1,n):
        if(l[i]==l[i-1]):
            c+=1
        else:
            f.append(c)
            c=1
    f.append(c)
    f.sort()
    x=0

    pf=[]
    for j in f:
        x+=j
        pf.append(x)
    v=bisect.bisect_left(pf,k)
    y=0
    #print(pf,v)
    if(v==n):
        print(1)
    elif(v==0):
        if(k!=0):
            if(k<pf[0]):
                y=1
                print(max(1,len(f)-1-v+y))
            else:
                print(max(1,len(f)-1-v))
        else:
            print(len(f))
    elif(k<pf[v]):
        y=1
        print(len(f)-1-v+y)
    
    else:
        print(max(1,len(f)-1-v))





    



Solution 2 (runtime: 249 ms):
t = int(input())
while t:
	t -= 1
	n, k =  map(int, input().split())
	ordem = {}
	array = list(map(int, input().split()))
	array.sort()
	freq = []

	prev = array[0]
	count = 0
	for num in array:
		if num != prev:
			freq.append(count)
			count = 0
		count += 1
		prev = num		
	freq.append(count)
	freq.sort()
	
	sum = 0
	count = 0
	for num in freq:
		sum += num
		if k >= sum:
			count += 1
		else:
			break
	
	print(max(1, len(freq)-count))
Problem: 2057B - Gorilla and the Exam
Language: python

Solution 1 (runtime: 312 ms):
import bisect
t=int(input())
for i in range(t):
    n,k=map(int,input().split())
    l=list(map(int,input().split()))
    l.sort()
    f=[]
    c=1
    for i in range(1,n):
        if(l[i]==l[i-1]):
            c+=1
        else:
            f.append(c)
            c=1
    f.append(c)
    f.sort()
    x=0

    pf=[]
    for j in f:
        x+=j
        pf.append(x)
    v=bisect.bisect_left(pf,k)
    y=0
    #print(pf,v)
    if(v==n):
        print(1)
    elif(v==0):
        if(k!=0):
            if(k<pf[0]):
                y=1
                print(max(1,len(f)-1-v+y))
            else:
                print(max(1,len(f)-1-v))
        else:
            print(len(f))
    elif(k<pf[v]):
        y=1
        print(len(f)-1-v+y)
    
    else:
        print(max(1,len(f)-1-v))





    



Solution 2 (runtime: 249 ms):
for _ in range(int(input())):
  n, k = list(map(int, input().split()))
  a = list(map(int, input().split()))
  
  a.sort()
  # store the freq of nums
  cnt = [1]
  for i in range(1, n):
    if a[i] == a[i-1]:
      cnt[-1] += 1
    else:
      cnt.append(1)
  
  # sort the cnts to check with k and convert them to min
  cnt.sort()
  m = len(cnt)
  flag = False
  for i in range(m-1):
    if cnt[i] > k:
      # we can't change any ai so
      print(m-i)
      flag = True
      break
    
    k -= cnt[i]
  
  if flag == False:
    print(1)
Problem: 2057B - Gorilla and the Exam
Language: python

Solution 1 (runtime: 187 ms):
import sys
from collections import Counter

input = sys.stdin.readline
output = sys.stdout.write
str_input = lambda: input().strip()
int_input = lambda: int(input())
multi_int_input = lambda: map(int, input().split())
list_input = lambda: list(map(int, input().split()))
P1 = lambda X: result_array.append(f"{X}\n")
P2 = lambda X,Y: result_array.append(f"{X} {Y}\n")
P3 = lambda X,Y,Z: result_array.append(f"{X} {Y} {Z}\n")
PA = lambda X: result_array.append(f"{' '.join(map(str,X))}\n")


def solve(test_case):
    N,K = multi_int_input()
    arr = list_input()

    check = Counter()
    for i in arr:
        check[str(i)] += 1
    check = sorted(check.values(),reverse=True)

    while check:
        if check[-1] <= K:
            K -= check.pop()
        else:
            break
    
    P1(max(1,len(check)))


tc = 1
tc = int_input()
result_array = []
for test_case in range(1,tc+1):
    solve(test_case)
output(''.join(result_array))

Solution 2 (runtime: 249 ms):
t = int(input())
while t:
	t -= 1
	n, k =  map(int, input().split())
	ordem = {}
	array = list(map(int, input().split()))
	array.sort()
	freq = []

	prev = array[0]
	count = 0
	for num in array:
		if num != prev:
			freq.append(count)
			count = 0
		count += 1
		prev = num		
	freq.append(count)
	freq.sort()
	
	sum = 0
	count = 0
	for num in freq:
		sum += num
		if k >= sum:
			count += 1
		else:
			break
	
	print(max(1, len(freq)-count))
Problem: 2057B - Gorilla and the Exam
Language: python

Solution 1 (runtime: 187 ms):
import sys
from collections import Counter

input = sys.stdin.readline
output = sys.stdout.write
str_input = lambda: input().strip()
int_input = lambda: int(input())
multi_int_input = lambda: map(int, input().split())
list_input = lambda: list(map(int, input().split()))
P1 = lambda X: result_array.append(f"{X}\n")
P2 = lambda X,Y: result_array.append(f"{X} {Y}\n")
P3 = lambda X,Y,Z: result_array.append(f"{X} {Y} {Z}\n")
PA = lambda X: result_array.append(f"{' '.join(map(str,X))}\n")


def solve(test_case):
    N,K = multi_int_input()
    arr = list_input()

    check = Counter()
    for i in arr:
        check[str(i)] += 1
    check = sorted(check.values(),reverse=True)

    while check:
        if check[-1] <= K:
            K -= check.pop()
        else:
            break
    
    P1(max(1,len(check)))


tc = 1
tc = int_input()
result_array = []
for test_case in range(1,tc+1):
    solve(test_case)
output(''.join(result_array))

Solution 2 (runtime: 249 ms):
for _ in range(int(input())):
  n, k = list(map(int, input().split()))
  a = list(map(int, input().split()))
  
  a.sort()
  # store the freq of nums
  cnt = [1]
  for i in range(1, n):
    if a[i] == a[i-1]:
      cnt[-1] += 1
    else:
      cnt.append(1)
  
  # sort the cnts to check with k and convert them to min
  cnt.sort()
  m = len(cnt)
  flag = False
  for i in range(m-1):
    if cnt[i] > k:
      # we can't change any ai so
      print(m-i)
      flag = True
      break
    
    k -= cnt[i]
  
  if flag == False:
    print(1)
Problem: 2057B - Gorilla and the Exam
Language: python

Solution 1 (runtime: 249 ms):
t = int(input())
while t:
	t -= 1
	n, k =  map(int, input().split())
	ordem = {}
	array = list(map(int, input().split()))
	array.sort()
	freq = []

	prev = array[0]
	count = 0
	for num in array:
		if num != prev:
			freq.append(count)
			count = 0
		count += 1
		prev = num		
	freq.append(count)
	freq.sort()
	
	sum = 0
	count = 0
	for num in freq:
		sum += num
		if k >= sum:
			count += 1
		else:
			break
	
	print(max(1, len(freq)-count))


Solution 2 (runtime: 249 ms):
for _ in range(int(input())):
  n, k = list(map(int, input().split()))
  a = list(map(int, input().split()))
  
  a.sort()
  # store the freq of nums
  cnt = [1]
  for i in range(1, n):
    if a[i] == a[i-1]:
      cnt[-1] += 1
    else:
      cnt.append(1)
  
  # sort the cnts to check with k and convert them to min
  cnt.sort()
  m = len(cnt)
  flag = False
  for i in range(m-1):
    if cnt[i] > k:
      # we can't change any ai so
      print(m-i)
      flag = True
      break
    
    k -= cnt[i]
  
  if flag == False:
    print(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: 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)
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):
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: 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):
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: 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: 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: 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):
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: 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):
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)
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: 186 ms):
t=int(input())
for ii in range (0,t):
    l, r = map(int, input().split())
    k = 0
    for i in range(30, -1, -1):
        if ((l >> i) & 1) ^ ((r >> i) & 1):
            k = i
            break
    a = (1 << k) - 1 | l
    b = a + 1
    c = r if a == l else l
    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: 233 ms):
for _ in range(int(input())):
    l, r = map(int, input().split())

    ls = list(bin(l)[2:])
    lr = list(bin(r)[2:])

    a,b,c = -1,-1,-1

    while(len(ls) < len(lr)):
        ls.insert(0, '0')

    n = len(ls)
    mode = False
    lsb = False
    for i in range(n):
        if mode:
            if ls_val == '1':
                ls[i] = '0'
                lsb = True
            elif lr_val == '1':
                lr[i] = '0'
        if not mode:
            if ls[i] != lr[i]:
                mode = True
                ls_val = ls[i]
                lr_val = lr[i]

    if lsb:
        lss = ''.join(c for c in ls)
        a = int(lss, base=2)
    else:
        lrr = ''.join(c for c in lr)
        a = int(lrr, base=2)

    b = a - 1

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

    print(a, b, c)