ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
    while(t--){
        int i,j,k,r,l,n,m;
        cin>>l>>r;
        int a[2][30];
        for(i=0 ; i < 30; i++)
        {
            a[0][i]=0;
            a[1][i]=0;
        }
i=0;
int l1=l,r1=r;
        while(l){
            a[0][i]=l&1;
            l=l>>1;
            i++;
        }
i=0;
        while(r){
            a[1][i]=r&1;
            r=r>>1;
            i++;
        }
l=0;
        for(i=29;i>=0;i--){
            if(a[0][i]!=a[1][i]){
                j=pow(2,i);
                k=j-1;
                break;
            }
        }
if(k>l1)l=l1;
else l=j+1;

        cout<<j<<" "<<k<<" "<<l<<endl;
    }
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
    while(t--){
        int i,j,k,r,l,n,m;
        cin>>l>>r;
        int a[2][30];
        for(i=0 ; i < 30; i++)
        {
            a[0][i]=0;
            a[1][i]=0;
        }
i=0;
int l1=l,r1=r;
        while(l){
            a[0][i]=l&1;
            l=l>>1;
            i++;
        }
i=0;
        while(r){
            a[1][i]=r&1;
            r=r>>1;
            i++;
        }
l=0;
int x=0;
        for(i=29;i>=0;i--){
            if(a[0][i]!=a[1][i]){
                j=x+pow(2,i);
                k=j-1;
                break;
            }
            else if(a[0][i]==1) x+=pow(2,i);
        }
if(k>l1)l=l1;
else l=j+1;

        cout<<j<<" "<<k<<" "<<l<<endl;
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
    while(t--){
        int i,j,k,r,l,n,m;
        cin>>l>>r;
        int a[2][30];
        for(i=0 ; i < 30; i++)
        {
            a[0][i]=0;
            a[1][i]=0;
        }
i=0;
int l1=l,r1=r;
        while(l){
            a[0][i]=l&1;
            l=l>>1;
            i++;
        }
i=0;
        while(r){
            a[1][i]=r&1;
            r=r>>1;
            i++;
        }
l=0;
int x=0;
        for(i=29;i>=0;i--){
            if(a[0][i]!=a[1][i]){
                j=x+pow(2,i);
                k=j-1;
                break;
            }
            else if(a[0][i]==1) x+=pow(2,i);
        }
if(k>l1)l=l1;
else l=j+1;

        cout<<j<<" "<<k<<" "<<l<<endl;
    }
}

Submission (verdict: Accepted):
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
using namespace std;
#define ll long long
int main()
{
    ll t;
    cin>>t;
    for(ll k1=1;k1<=t;k1++)
    {
        ll i,j,k,cnt1=0,cnt2=0,l,r;
        cin>>l>>r;
        ll base=r;
        while(base>0) base/=2,cnt1++;
        ll a=pow(2,cnt1-1),b=a-1,c=a-2;
        if(a!=l)
        {
            if(c>=l) cout<<a<<" "<<b<<" "<<c<<endl;
            else 
            {
                c=a+1;
                cout<<a<<" "<<b<<" "<<c<<endl;
            }
        }
        else 
        {
            base=r-l;
            while(base>0) base/=2,cnt2++;
            b=a+pow(2,cnt2-1);
            c=b-1;
            cout<<a<<" "<<b<<" "<<c<<endl;
        }
    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 16):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl "\n"
#define int long long
#define pb push_back
#define cy cout <<"YES"<< endl
#define cn cout <<"NO"<< endl
#define all(x) x.begin(),x.end()
#define fastread std::ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int MOD = 1e18+7;
int ceil_div(int a, int b) { return a%b==0 ? a/b : a/b+1;}
int gcd(int a, int b) { if(a==0LL) { return b;} return gcd(b%a, a);}
int lcm(int a, int b) {return a*b/gcd(a,b);}

bool sorted(pair<int,int> &a, pair<int,int> &b) {
    if(a.first == b.first) 
        return a.second < b.second; // ascending
    return a.first > b.first; // descending
}

int exp(int a, int b) {
    if(b==0) return 1;
    int half_power = exp(a,b/2);
    a %= MOD;
    if(b%2==0) return half_power * half_power % MOD;
    else return half_power * half_power % MOD * (a%MOD) % MOD;
}

void SieveOfEratosthenes(int n) {
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));
    for (int p = 2; p * p <= n; p++) {
        if (prime[p] == true) {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
}

int isPrime(int n) {
    for(int i=2; i*i<=n; i++) {
        if(n%i ==0)
            return false;
    }
    return true;
}

int fn(string a, string b, int i) {
    int count = 0;
    for(int j=i; j>=0; j--) {
        if(a[j] != b[j])
            count++;
    }
    return count;
}

int cf(string a, string b, string c, int n, int m, int i, vector<vector<int>> &dp) {
    if(i < 0)
        return 0;
    if(n < 0)
        return fn(b,c,m);
    if(m < 0)
        return fn(a,c,n);
    if(dp[n][m] != -1)
        return dp[n][m];
    int res = 1e9;
    if(a[n] == c[i] && b[m] == c[i])
        res = min(cf(a,b,c,n-1,m,i-1,dp), cf(a,b,c,n,m-1,i-1,dp));
    else if(a[n] == c[i])
        res = min(cf(a,b,c,n-1,m,i-1,dp), 1+cf(a,b,c,n,m-1,i-1,dp));
    else if(b[m] == c[i])
        res = min(cf(a,b,c,n,m-1,i-1,dp), 1+cf(a,b,c,n-1,m,i-1,dp));
    else 
        res = min(1+cf(a,b,c,n-1,m,i-1,dp), 1+cf(a,b,c,n,m-1,i-1,dp));
    return dp[n][m] = res;
}

void solve() {
    string a; cin >> a;
    string b; cin >> b;
    string c; cin >> c;
    int n = a.size();
    int m = b.size();
    int i = c.size();
    vector<vector<int>> dp(n+1, vector<int>(m+1, -1));
    cout << cf(a,b,c,n-1,m-1,i-1,dp) << endl;;
}

signed main() {
    fastread
    int t = 1; cin >> t;
    while(t--) {
        solve();
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):

#include <bits/stdc++.h>
#define int long long
using namespace std;
 
const int MOD = 1e9 + 7;
const int mod=998244353;
 
int32_t main() {
    
    //int t; cin>>t;
    //for (int i=1;i<=t;i++) {
        int n;cin>>n;
        int c[n];
        for(int i=0;i<n;i++){cin>>c[i];}
        vector<int>temp(n,0);
        for(int i=0;i<n;i++){
            temp[i]=i+1;
        }
        int ans=0;
        vector<pair<int,int>>v;
        for(int i=0;i<n;i++){
            int no=c[i];
            int ind=-1;
            for(int j=0;j<n;j++){
                if(temp[j]==no)ind=j;
            }
            int re=n-1-ind;
            ans+=2*re;
            ans+=(ind-i);
            if(i==ind)continue;
            for(int j=ind+1;j<n;j++){
                v.push_back({temp[j],no});
            }

            for(int j=n-1;j>=ind+1;j--){
                v.push_back({no,temp[j]});
            }

            for(int j=ind-1;j>=i;j--){
                v.push_back({no,temp[j]});
            }

            for(int j=i+1;j<=ind;j++){
                temp[j]=temp[j-1];
            }
            temp[i]=no;
        }
        cout<<ans<<endl;
        for(auto it:v){
            cout<<it.first<<" "<<it.second<<endl;
        }
    //}
    return 0;
}

Submission (verdict: Wrong answer on test 5):

#include <bits/stdc++.h>
#define int long long
using namespace std;
 
const int MOD = 1e9 + 7;
const int mod=998244353;
 
int32_t main() {
    
    //int t; cin>>t;
    //for (int i=1;i<=t;i++) {
        int n;cin>>n;
        int c[n];
        for(int i=0;i<n;i++){cin>>c[i];}
        vector<int>temp(n,0);
        for(int i=0;i<n;i++){
            temp[i]=i+1;
        }
        int ans=0;
        vector<pair<int,int>>v;
        for(int i=0;i<n;i++){
            int no=c[i];
            int ind=-1;
            for(int j=0;j<n;j++){
                if(temp[j]==no)ind=j;
            }
            int re=n-1-ind;
            ans+=2*re;
            ans+=(ind-i);
            
            for(int j=ind+1;j<n;j++){
                v.push_back({temp[j],no});
            }

            for(int j=n-1;j>=ind+1;j--){
                v.push_back({no,temp[j]});
            }

            for(int j=ind-1;j>=i;j--){
                v.push_back({no,temp[j]});
            }

            for(int j=i+1;j<=ind;j++){
                temp[j]=temp[j-1];
            }
            temp[i]=no;
        }
        cout<<ans<<endl;
        for(auto it:v){
            cout<<it.first<<" "<<it.second<<endl;
        }
    //}
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 5):

#include <bits/stdc++.h>
#define int long long
using namespace std;
 
const int MOD = 1e9 + 7;
const int mod=998244353;
 
int32_t main() {
    
    //int t; cin>>t;
    //for (int i=1;i<=t;i++) {
        int n;cin>>n;
        int c[n];
        for(int i=0;i<n;i++){cin>>c[i];}
        vector<int>temp(n,0);
        for(int i=0;i<n;i++){
            temp[i]=i+1;
        }
        int ans=0;
        vector<pair<int,int>>v;
        for(int i=0;i<n;i++){
            int no=c[i];
            int ind=-1;
            for(int j=0;j<n;j++){
                if(temp[j]==no)ind=j;
            }
            int re=n-1-ind;
            ans+=2*re;
            ans+=(ind-i);
            
            for(int j=ind+1;j<n;j++){
                v.push_back({temp[j],no});
            }

            for(int j=n-1;j>=ind+1;j--){
                v.push_back({no,temp[j]});
            }

            for(int j=ind-1;j>=i;j--){
                v.push_back({no,temp[j]});
            }

            for(int j=i+1;j<=ind;j++){
                temp[j]=temp[j-1];
            }
            temp[i]=no;
        }
        cout<<ans<<endl;
        for(auto it:v){
            cout<<it.first<<" "<<it.second<<endl;
        }
    //}
    return 0;
}

Submission (verdict: Accepted):

#include <bits/stdc++.h>
#define int long long
using namespace std;
 
const int MOD = 1e9 + 7;
const int mod=998244353;
 
int32_t main() {
    
    //int t; cin>>t;
    //for (int i=1;i<=t;i++) {
        int n;cin>>n;
        int c[n];
        for(int i=0;i<n;i++){cin>>c[i];}
        vector<int>temp(n,0);
        for(int i=0;i<n;i++){
            temp[i]=i+1;
        }
        int ans=0;
        vector<pair<int,int>>v;
        for(int i=0;i<n;i++){
            int no=c[i];
            int ind=-1;
            for(int j=0;j<n;j++){
                if(temp[j]==no)ind=j;
            }
            int re=n-1-ind;
            ans+=2*re;
            ans+=(ind-i);
            //cout<<ans<<" ";
            for(int j=ind+1;j<n;j++){
                v.push_back({temp[j],no});
            }

            for(int j=n-1;j>=ind+1;j--){
                v.push_back({no,temp[j]});
            }

            for(int j=ind-1;j>=i;j--){
                v.push_back({no,temp[j]});
            }

            for(int j=ind;j>=i+1;j--){
                temp[j]=temp[j-1];
            }
            temp[i]=no;
            // if(i==0){
            //     for(auto it:temp)cout<<it<<" ";
            //     cout<<endl;
            // }
        }
        cout<<ans<<endl;
        for(auto it:v){
            cout<<it.first<<" "<<it.second<<endl;
        }
    //}
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):

#include <bits/stdc++.h>
#define int long long
using namespace std;
 
const int MOD = 1e9 + 7;
const int mod=998244353;
 
int32_t main() {
    
    //int t; cin>>t;
    //for (int i=1;i<=t;i++) {
        int n;cin>>n;
        int c[n];
        for(int i=0;i<n;i++){cin>>c[i];}
        vector<int>temp(n,0);
        for(int i=0;i<n;i++){
            temp[i]=i+1;
        }
        int ans=0;
        vector<pair<int,int>>v;
        for(int i=0;i<n;i++){
            int no=c[i];
            int ind=-1;
            for(int j=0;j<n;j++){
                if(temp[j]==no)ind=j;
            }
            int re=n-1-ind;
            ans+=2*re;
            ans+=(ind-i);
            if(i==ind)continue;
            for(int j=ind+1;j<n;j++){
                v.push_back({temp[j],no});
            }

            for(int j=n-1;j>=ind+1;j--){
                v.push_back({no,temp[j]});
            }

            for(int j=ind-1;j>=i;j--){
                v.push_back({no,temp[j]});
            }

            for(int j=i+1;j<=ind;j++){
                temp[j]=temp[j-1];
            }
            temp[i]=no;
        }
        cout<<ans<<endl;
        for(auto it:v){
            cout<<it.first<<" "<<it.second<<endl;
        }
    //}
    return 0;
}
Problem: 2050E - Three Strings
Language: Java 21

Previous submission (verdict: Wrong answer on test 2):
import java.util.Arrays;
import java.util.Scanner;

public class ThreeStrings {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int t= sc.nextInt();
        for (int i = 0; i < t; i++) {
            String a = sc.next();
            String b = sc.next();
            String c = sc.next();

            int lenA = a.length();
            int lenB = b.length();
            int lenC = c.length();

            long dp[][] = new long[lenA + 10][lenB + 10];

            for(long [] x : dp ) Arrays.fill( x , -1 );

            System.out.println(rec( 0 , 0 , dp , lenA , lenB , a , b, c));
        }
    }

    static long rec ( int x , int y , long dp[][] , int lenA , int lenB , String a , String b, String c){

        if ( x == lenA ){
            long add = 0;
            for(int i = y ; i < lenB ;i++){
                if ( b.charAt(i) != c.charAt( x + y )) add ++ ;
            }
            return add ;
        }
        if ( y == lenB ){
            long add = 0;
            for(int i = x ; i < lenA ;i++){
                if ( a.charAt(i) != c.charAt( x + y )) add ++ ;
            }
            return add ;
        }
        if ( dp[x][y] != -1) return dp[x][y];
        long ans1 = (a.charAt( x ) == c.charAt( x + y ) ? 0 : 1 ) + rec( x + 1 , y , dp , lenA , lenB , a, b, c);
        long ans2 = (b.charAt( y ) == c.charAt( x + y ) ? 0 : 1 ) + rec( x  , y + 1 , dp , lenA , lenB , a, b, c);

        return dp[x][y] = Math.min(ans1 , ans2);
    }
}


Submission (verdict: Accepted):
import java.util.Arrays;
import java.util.Scanner;

public class ThreeStrings {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int t= sc.nextInt();
        for (int i = 0; i < t; i++) {
            String a = sc.next();
            String b = sc.next();
            String c = sc.next();

            int lenA = a.length();
            int lenB = b.length();
            int lenC = c.length();

            long dp[][] = new long[lenA + 10][lenB + 10];

            for(long [] x : dp ) Arrays.fill( x , -1 );

            System.out.println(rec( 0 , 0 , dp , lenA , lenB , a , b, c));
        }
    }

    static long rec ( int x , int y , long dp[][] , int lenA , int lenB , String a , String b, String c){

        if ( x == lenA ){
            long add = 0;
            for(int i = y ; i < lenB ;i++){
                if ( b.charAt(i) != c.charAt( x + i )) add ++ ;
            }
            return add ;
        }
        if ( y == lenB ){
            long add = 0;
            for(int i = x ; i < lenA ;i++){
                if ( a.charAt(i) != c.charAt( i + y )) add ++ ;
            }
            return add ;
        }
        if ( dp[x][y] != -1) return dp[x][y];
        long ans1 = (a.charAt( x ) == c.charAt( x + y ) ? 0 : 1 ) + rec( x + 1 , y , dp , lenA , lenB , a, b, c);
        long ans2 = (b.charAt( y ) == c.charAt( x + y ) ? 0 : 1 ) + rec( x  , y + 1 , dp , lenA , lenB , a, b, c);

        return dp[x][y] = Math.min(ans1 , ans2);
    }
}
Problem: 2050E - Three Strings
Language: Java 21

Previous submission (verdict: Wrong answer on test 2):
import java.util.Arrays;
import java.util.Scanner;

public class ThreeStrings {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int t= sc.nextInt();
        for (int i = 0; i < t; i++) {
            String a = sc.next();
            String b = sc.next();
            String c = sc.next();

            int lenA = a.length();
            int lenB = b.length();
            int lenC = c.length();

            long dp[][] = new long[lenA + 1][lenB + 1];

            for(long [] x : dp ) Arrays.fill( x , -1 );

            System.out.println(rec( 0 , 0 , dp , lenA , lenB , a , b, c));
        }
    }

    static long rec ( int x , int y , long dp[][] , int lenA , int lenB , String a , String b, String c){

        if ( x == lenA ){
            long add = 0;
            for(int i = y ; i < lenB ;i++){
                if ( b.charAt(i) != c.charAt( x + y )) add ++ ;
            }
            return add ;
        }
        if ( y == lenB ){
            long add = 0;
            for(int i = x ; i < lenA ;i++){
                if ( a.charAt(i) != c.charAt( x + y )) add ++ ;
            }
            return add ;
        }
        if ( dp[x][y] != -1) return dp[x][y];
        long ans1 = (a.charAt( x ) == c.charAt( x + y ) ? 0 : 1 ) + rec( x + 1 , y , dp , lenA , lenB , a, b, c);
        long ans2 = (b.charAt( y ) == c.charAt( x + y ) ? 0 : 1 ) + rec( x  , y + 1 , dp , lenA , lenB , a, b, c);

        return dp[x][y] = Math.min(ans1 , ans2);
    }
}


Submission (verdict: Wrong answer on test 2):
import java.util.Arrays;
import java.util.Scanner;

public class ThreeStrings {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int t= sc.nextInt();
        for (int i = 0; i < t; i++) {
            String a = sc.next();
            String b = sc.next();
            String c = sc.next();

            int lenA = a.length();
            int lenB = b.length();
            int lenC = c.length();

            long dp[][] = new long[lenA + 10][lenB + 10];

            for(long [] x : dp ) Arrays.fill( x , -1 );

            System.out.println(rec( 0 , 0 , dp , lenA , lenB , a , b, c));
        }
    }

    static long rec ( int x , int y , long dp[][] , int lenA , int lenB , String a , String b, String c){

        if ( x == lenA ){
            long add = 0;
            for(int i = y ; i < lenB ;i++){
                if ( b.charAt(i) != c.charAt( x + y )) add ++ ;
            }
            return add ;
        }
        if ( y == lenB ){
            long add = 0;
            for(int i = x ; i < lenA ;i++){
                if ( a.charAt(i) != c.charAt( x + y )) add ++ ;
            }
            return add ;
        }
        if ( dp[x][y] != -1) return dp[x][y];
        long ans1 = (a.charAt( x ) == c.charAt( x + y ) ? 0 : 1 ) + rec( x + 1 , y , dp , lenA , lenB , a, b, c);
        long ans2 = (b.charAt( y ) == c.charAt( x + y ) ? 0 : 1 ) + rec( x  , y + 1 , dp , lenA , lenB , a, b, c);

        return dp[x][y] = Math.min(ans1 , ans2);
    }
}
Problem: 2050E - Three Strings
Language: Java 21


Submission (verdict: Wrong answer on test 2):
import java.util.Arrays;
import java.util.Scanner;

public class ThreeStrings {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int t= sc.nextInt();
        for (int i = 0; i < t; i++) {
            String a = sc.next();
            String b = sc.next();
            String c = sc.next();

            int lenA = a.length();
            int lenB = b.length();
            int lenC = c.length();

            long dp[][] = new long[lenA + 1][lenB + 1];

            for(long [] x : dp ) Arrays.fill( x , -1 );

            System.out.println(rec( 0 , 0 , dp , lenA , lenB , a , b, c));
        }
    }

    static long rec ( int x , int y , long dp[][] , int lenA , int lenB , String a , String b, String c){

        if ( x == lenA ){
            long add = 0;
            for(int i = y ; i < lenB ;i++){
                if ( b.charAt(i) != c.charAt( x + y )) add ++ ;
            }
            return add ;
        }
        if ( y == lenB ){
            long add = 0;
            for(int i = x ; i < lenA ;i++){
                if ( a.charAt(i) != c.charAt( x + y )) add ++ ;
            }
            return add ;
        }
        if ( dp[x][y] != -1) return dp[x][y];
        long ans1 = (a.charAt( x ) == c.charAt( x + y ) ? 0 : 1 ) + rec( x + 1 , y , dp , lenA , lenB , a, b, c);
        long ans2 = (b.charAt( y ) == c.charAt( x + y ) ? 0 : 1 ) + rec( x  , y + 1 , dp , lenA , lenB , a, b, c);

        return dp[x][y] = Math.min(ans1 , ans2);
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repl(i, n) for (ll i = 0; i < n; i++)
#define repr(i,x1,x2) for(ll i=x1; i<x2; ++i)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
int main(){
    IOS;
    int t;
    cin>>t;
    while (t--){
        int l , r;
        cin>>l>>r;
        int a = l;
        int b = r;
        bool flag = false;
        for (int i=31 ; i>=0 ; i--){
            if (flag){
                a = a | (1<<i);
                b = b & (~(1<<i));
            }
            bool temp1 = (l>>i)&1;
            bool temp2 = (r>>i)&1;
            if (temp1 != temp2){
                flag = true;
            }
        }
        int c = 1;
        for (int i=l; i<=r ; i++){
            if (i!=a && i!=b){
                c = i;
                break;
            }
        }
        cout<<a<<b<<c<<endl;
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repl(i, n) for (ll i = 0; i < n; i++)
#define repr(i,x1,x2) for(ll i=x1; i<x2; ++i)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
int main(){
    IOS;
    int t;
    cin>>t;
    while (t--){
        int l , r;
        cin>>l>>r;
        int a = l;
        int b = r;
        bool flag = false;
        for (int i=31 ; i>=0 ; i--){
            if (flag){
                a = a | (1<<i);
                b = b & (~(1<<i));
            }
            bool temp1 = (l>>i)&1;
            bool temp2 = (r>>i)&1;
            if (temp1 != temp2){
                flag = true;
            }
        }
        int c = 1;
        for (int i=l; i<=r ; i++){
            if (i!=a && i!=b){
                c = i;
                break;
            }
        }
        cout<<a<<" "<<b<<" "<<c<<endl;
    }
    return 0;
}