ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        int three = 0, two = 0;
        int ans = 0;
        int n = s.size();

        int all_three = 1;

        for(int i = 0; i<n; i++){
            if(s[i] == '2'){
                two++;
            }
            else if(s[i] == '3'){
                three++;
            }
            ans += s[i] - '0';
            if(s[i]!='3') all_three = 0;
        }
        if(all_three){
            cout << "YES\n";
            continue;
        }
        int val;
        if(ans<9){
            val = 9-ans; 
        }
        else{
            val = min(9 - ans%9, ans%9);
        }
        if(ans%9 == 0){
            cout << "YES\n";
        }
        else if(val == 2 or val == 4 or val == 6 or val == 8){
            if(val == 2 and two>=1){
                cout << "YES\n";
            }
            else if(val == 4 and two>=2){
                cout << "YES\n";
            }
            else if(val == 6 and  three>=1){
                cout << "YES\n";
            }
            else if(val == 8 and two>=3){
                cout << "YES\n";
            }
            else{
                cout << "NO\n";
            }
        }   
        else{
            cout << "NO\n";
        }
        // cout << s << "\nAns: " << ans << " val : " << val << "\n";
    }
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        int three = 0, two = 0;
        int ans = 0;
        int n = s.size();

        int all_three = 1;

        for(int i = 0; i<n; i++){
            if(s[i] == '2'){
                two++;
            }
            else if(s[i] == '3'){
                three++;
            }
            ans += s[i] - '0';
            if(s[i]!='3') all_three = 0;
        }
        if(all_three){
            cout << "YES\n";
            continue;
        }
        int anss = ans;
        int val = 0;
        while(anss%9!=0){
            val++;
            anss++;
        }
        if(ans%9 == 0){
            cout << "YES\n";
        }
        else if(val<=8 and val%2 == 0){
            if(val == 2 and two>=1){
                cout << "YES\n";
            }
            else if(val == 4 and two>=2){
                cout << "YES\n";
            }
            else if(val == 6 and  three>=1){
                cout << "YES\n";
            }
            else if(val == 8 and two>=3){
                cout << "YES\n";
            }
            else{
                cout << "NO\n";
            }
        }
        else if(val%2==1){
            val+=9;
            if(val<= (two*2)+(three*6)){
                cout << "YES\n";
            }
            else{
                cout << "NO\n";
            }
        }
        else{
            cout << "NO\n";
        }
        // cout << s << "\nAns: " << ans << " val : " << val << "\n";
    }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        int three = 0, two = 0;
        int ans = 0;
        int n = s.size();

        int all_three = 1;

        for(int i = 0; i<n; i++){
            if(s[i] == '2'){
                two++;
            }
            else if(s[i] == '3'){
                three++;
            }
            ans += s[i] - '0';
            if(s[i]!='3') all_three = 0;
        }
        if(all_three){
            cout << "YES\n";
            continue;
        }
        int val;
        if(ans<9){
            val = 9-ans; 
        }
        else{
            val = min(9 - ans%9, ans%9);
        }
        if(ans%9 == 0){
            cout << "YES\n";
        }
        else if(val == 2 or val == 4 or val == 6 or val == 8){
            if(val == 2 and two>=1){
                cout << "YES\n";
            }
            else if(val == 4 and two>=2){
                cout << "YES\n";
            }
            else if(val == 6 and  three>=1){
                cout << "YES\n";
            }
            else if(val == 8 and two>=3){
                cout << "YES\n";
            }
            else{
                cout << "NO\n";
            }
        }   
        else{
            cout << "NO\n";
        }
        // cout << s << "\nAns: " << ans << " val : " << val << "\n";
    }
}
Problem: 2050D - Digital string maximization
Language: PyPy 3-64

Previous submission (verdict: Time limit exceeded on test 7):
for _ in range(int(input())):
    s = list(map(int, list(input())))
    n = len(s)
    prev_max = s[0]
    prev_max_i = 0

    for i in range(1, n):
        if s[i] == 0:
            continue
        for j in range(prev_max_i, i):
            if s[j] + (i - j) >= 9:
                prev_max_i = j
                prev_max = s[j]
            if s[j] < s[i] - (i - j):
                temp = s[i]
                s.insert(j, s[i] - (i - j))
                s.pop(i + 1)
                # prev_max_i = j
                # prev_max = s[j]
                break

        # print(s)

    for i in range(n):
        print(s[i], end='')
    print()

Submission (verdict: Time limit exceeded on test 7):
for _ in range(int(input())):
    s = list(map(int, list(input())))
    n = len(s)
    # prev_max = s[0]
    # prev_max_i = 0

    for i in range(1, n):
        if s[i] == 0:
            continue
        for j in range(max(0, i - 9), i):
            # if s[j] + (i - j) >= 9:
            #     prev_max_i = j
            #     prev_max = s[j]
            if s[j] < s[i] - (i - j):
                s.insert(j, s[i] - (i - j))
                s.pop(i + 1)
                # prev_max_i = j
                # prev_max = s[j]
                break

        # print(s)

    for i in range(n):
        print(s[i], end='')
    print()
Problem: 2050D - Digital string maximization
Language: PyPy 3-64

Previous submission (verdict: Time limit exceeded on test 7):
for _ in range(int(input())):
    s = list(map(int, list(input())))
    n = len(s)
    # prev_max = s[0]
    # prev_max_i = 0

    for i in range(1, n):
        if s[i] == 0:
            continue
        for j in range(max(0, i - 9), i):
            # if s[j] + (i - j) >= 9:
            #     prev_max_i = j
            #     prev_max = s[j]
            if s[j] < s[i] - (i - j):
                s.insert(j, s[i] - (i - j))
                s.pop(i + 1)
                # prev_max_i = j
                # prev_max = s[j]
                break

        # print(s)

    for i in range(n):
        print(s[i], end='')
    print()

Submission (verdict: Accepted):
for _ in range(int(input())):
    s = list(map(int, list(input())))
    n = len(s)
    

    for i in range(1, n):
        if s[i] == 0:
            continue
        for j in range(max(0, i - 9), i):
            if s[j] < s[i] - (i - j):
                new_head_value = s[i] - (i - j)
                idx = i - 1
                while idx != j - 1:
                    s[idx], s[idx + 1] = s[idx + 1], s[idx]
                    idx -= 1
                s[j] = new_head_value
                break


    for i in range(n):
        print(s[i], end='')
    print()
Problem: 2050D - Digital string maximization
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 2):
for _ in range(int(input())):
    s = list(map(int, list(input())))
    n = len(s)
    prev_max = s[0]
    prev_max_i = 0

    for i in range(1, n):
        if s[i] == 0:
            continue
        for j in range(prev_max_i, i):
            if s[j] < s[i] - (i - j):
                temp = s[i]
                s.insert(j, s[i] - (i - j))
                s.pop(i + 1)
                prev_max_i = j
                prev_max = s[j]
                break

        # print(s)

    for i in range(n):
        print(s[i], end='')
    print()
Problem: 2050D - Digital string maximization
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
for _ in range(int(input())):
    s = list(map(int, list(input())))
    n = len(s)
    prev_max = s[0]
    prev_max_i = 0

    for i in range(1, n):
        if s[i] == 0:
            continue
        for j in range(prev_max_i, i):
            if s[j] < s[i] - (i - j):
                temp = s[i]
                s.insert(j, s[i] - (i - j))
                s.pop(i + 1)
                prev_max_i = j
                prev_max = s[j]
                break

        # print(s)

    for i in range(n):
        print(s[i], end='')
    print()

Submission (verdict: Time limit exceeded on test 7):
for _ in range(int(input())):
    s = list(map(int, list(input())))
    n = len(s)
    prev_max = s[0]
    prev_max_i = 0

    for i in range(1, n):
        if s[i] == 0:
            continue
        for j in range(prev_max_i, i):
            if s[j] + (i - j) >= 9:
                prev_max_i = j
                prev_max = s[j]
            if s[j] < s[i] - (i - j):
                temp = s[i]
                s.insert(j, s[i] - (i - j))
                s.pop(i + 1)
                # prev_max_i = j
                # prev_max = s[j]
                break

        # print(s)

    for i in range(n):
        print(s[i], end='')
    print()
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
// # define int long long
#define f(x, a, b) for (ll x = a; x < b; x++)
#define fm(x, a, b) for (int x = a; x > b; x--)
#define ll long long
#define pb push_back

long long gcd(long long a, ll b)
{
  return b == 0 ? a : gcd(b, a % b);
}

long long lcm(ll a, ll b)
{
  return (a / gcd(a, b)) * b;
}

int help(vector<vector<int>>& dp,string& a,string& b,string& c,int i,int j,int n,int m, int o){
    if (i==n){
        int ans=0;
        f(k,j,m){
            if (c[n+k]!=b[k]){ans+=1;}
        }
        return ans;
    }
    if (j==m){
        int ans=0;
        f(k,i,n){
            if (c[m+k]!=a[k]){ans+=1;}
        }
        return ans;
    }
    if (a[i]==c[i+j]){
        if (b[j]==c[i+j]){
            int x=help(dp,a,b,c,i+1,j,n,m,o);
            int y=help(dp,a,b,c,i,j+1,n,m,o);
            dp[i][j]=min(x,y);
        }
        else{
            int x=help(dp,a,b,c,i+1,j,n,m,o);
            int y=help(dp,a,b,c,i,j+1,n,m,o)+1;
            dp[i][j]=min(x,y);
        }
    }
    else if (b[j]==c[i+j]){
            int x=help(dp,a,b,c,i+1,j,n,m,o)+1;
            int y=help(dp,a,b,c,i,j+1,n,m,o);
            dp[i][j]=min(x,y);
    }
    else{
        int x=help(dp,a,b,c,i+1,j,n,m,o)+1;
        int y=help(dp,a,b,c,i,j+1,n,m,o)+1;
        dp[i][j]=min(x,y);
    }
    return dp[i][j];
}

int main()
{
  int t;
  t = 1;
  cin >> t;
  while (t--)
  {
   	string a,b,c; cin>>a>>b>>c;
   	int n=a.size(),m=b.size(),o=c.size();
   	vector<vector<int>> dp(n,vector<int>(m,-1));
   	int ans=help(dp,a,b,c,0,0,n,m,o);
   	cout<<ans<<endl;
  }
  return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

#define ll long long

#define mod 1000000007

using namespace std;



int main() {

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

// your code goes here

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int>v(n);

for(int i=0; i<n; i++){

cin>>v[i];

}

if(v[0]>=v[1]){

cout<<"YES"<<endl;

}else{

cout<<"NO"<<endl;

}

}

return 0;

}

Submission (verdict: Wrong answer on test 10):
#include <bits/stdc++.h>

#define ll long long

#define mod 1000000007

using namespace std;



int main() {

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

// your code goes here

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int>v(n);

for(int i=0; i<n; i++){

cin>>v[i];

}

if(v[0]>=v[1]){

cout<<"NO"<<endl;

continue;

}

bool flag=true;

int a=v[1]-v[0];

v[1]=a;

for(int i=1; i<n-1; i++){

if(v[i]>v[i+1]){

flag=false;

break;

}else{

v[i+1]-=v[i];

}

}

if(flag){

cout<<"YES"<<endl;

}else{

cout<<"NO"<<endl;

}

}

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 10):
#include <bits/stdc++.h>

#define ll long long

#define mod 1000000007

using namespace std;



int main() {

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

// your code goes here

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int>v(n);

for(int i=0; i<n; i++){

cin>>v[i];

}

if(v[0]>=v[1]){

cout<<"NO"<<endl;

continue;

}

bool flag=true;

int a=v[1]-v[0];

v[1]=a;

for(int i=1; i<n-1; i++){

if(v[i]>v[i+1]){

flag=false;

break;

}else{

v[i+1]-=v[i];

}

}

if(flag){

cout<<"YES"<<endl;

}else{

cout<<"NO"<<endl;

}

}

return 0;

}

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

#define ll long long

#define mod 1000000007

using namespace std;



int main() {

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

// your code goes here

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int>v(n);

for(int i=0; i<n; i++){

cin>>v[i];

}

if(v[0]>v[1]){

cout<<"NO"<<endl;

continue;

}

bool flag=true;

int a=v[1]-v[0];

v[1]=a;

for(int i=1; i<n-1; i++){

if(v[i]>v[i+1]){

flag=false;

break;

}else{

v[i+1]-=v[i];

}

}

if(flag){

cout<<"YES"<<endl;

}else{

cout<<"NO"<<endl;

}

}

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

#define ll long long

#define mod 1000000007

using namespace std;



int main() {

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

// your code goes here

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int>v(n);

for(int i=0; i<n; i++){

cin>>v[i];

}

if(v[0]>=v[1]){

cout<<"YES"<<endl;

}else{

cout<<"NO"<<endl;

}

}

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: Java 8

Previous submission (verdict: Wrong answer on test 1):
import java.util.*;



public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt(); // Number of test cases

        

        while (t-- > 0) {

            int n = sc.nextInt(); // Length of sequence

            int[] a = new int[n];

            

            for (int i = 0; i < n; i++) {

                a[i] = sc.nextInt();

            }

            

            boolean possible = true;

            

            // We need to ensure that after applying the operation, the sequence is non-decreasing

            for (int i = n - 2; i >= 0; i--) {

                if (a[i] > a[i + 1]) {

                    int minVal = Math.min(a[i], a[i + 1]);

                    a[i] -= minVal;

                    a[i + 1] -= minVal;

                    

                    // If a[i] is still greater than a[i+1], it's impossible

                    if (a[i] > a[i + 1]) {

                        possible = false;

                        break;

                    }

                }

            }

            

            System.out.println(possible ? "YES" : "NO");

        }

        

        sc.close();

    }

}



Submission (verdict: Accepted):
import java.util.*;



public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt(); // Number of test cases

        

        while (t-- > 0) {

            int n = sc.nextInt(); // Length of sequence

            int[] a = new int[n];

            

            for (int i = 0; i < n; i++) {

                a[i] = sc.nextInt();

            }



            // Simulating the operation

            boolean possible = true;

            for (int i = 0; i < n - 1; i++) {

                int minValue = Math.min(a[i], a[i + 1]);

                a[i] -= minValue;

                a[i + 1] -= minValue;

            }



            // Check if the array is now non-decreasing

            for (int i = 0; i < n - 1; i++) {

                if (a[i] > a[i + 1]) {

                    possible = false;

                    break;

                }

            }



            System.out.println(possible ? "YES" : "NO");

        }



        sc.close();

    }

}
Problem: 2060D - Subtract Min Sort
Language: Java 8

Previous submission (verdict: Wrong answer on test 1):
import java.util.*;



public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt(); // Number of test cases

        

        while (t-- > 0) {

            int n = sc.nextInt(); // Length of sequence

            int[] a = new int[n];

            

            for (int i = 0; i < n; i++) {

                a[i] = sc.nextInt();

            }

            

            boolean possible = true;

            

            for (int i = 0; i < n - 1; i++) {

                if (a[i] > a[i + 1]) {

                    possible = false;

                    break;

                }

            }

            

            System.out.println(possible ? "YES" : "NO");

        }

        

        sc.close();

    }

}



Submission (verdict: Wrong answer on test 1):
import java.util.*;



public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt(); // Number of test cases

        

        while (t-- > 0) {

            int n = sc.nextInt(); // Length of sequence

            int[] a = new int[n];

            

            for (int i = 0; i < n; i++) {

                a[i] = sc.nextInt();

            }

            

            boolean possible = true;

            

            // We need to ensure that after applying the operation, the sequence is non-decreasing

            for (int i = n - 2; i >= 0; i--) {

                if (a[i] > a[i + 1]) {

                    int minVal = Math.min(a[i], a[i + 1]);

                    a[i] -= minVal;

                    a[i + 1] -= minVal;

                    

                    // If a[i] is still greater than a[i+1], it's impossible

                    if (a[i] > a[i + 1]) {

                        possible = false;

                        break;

                    }

                }

            }

            

            System.out.println(possible ? "YES" : "NO");

        }

        

        sc.close();

    }

}
Problem: 2060D - Subtract Min Sort
Language: Java 8


Submission (verdict: Wrong answer on test 1):
import java.util.*;



public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt(); // Number of test cases

        

        while (t-- > 0) {

            int n = sc.nextInt(); // Length of sequence

            int[] a = new int[n];

            

            for (int i = 0; i < n; i++) {

                a[i] = sc.nextInt();

            }

            

            boolean possible = true;

            

            for (int i = 0; i < n - 1; i++) {

                if (a[i] > a[i + 1]) {

                    possible = false;

                    break;

                }

            }

            

            System.out.println(possible ? "YES" : "NO");

        }

        

        sc.close();

    }

}
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;
typedef long long int ll;
 
void solve(){
    int l,r;cin>>l>>r;
    int pos=0;
    for(int i=30;i>=0;i--){
        if((l&(1<<i)) != (r&(1<<i)) ){
            pos = i; break;
        }
    }
    int a=l|((1<<pos)-1);
    int b=a+1;
    int c=r;
    if(c==a || c==b)c--;
    if(c==a || c==b)c--;
    cout<<a<<" "<<b<<" "<<c<<endl;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t=1;   cin>>t;
    while(t--)solve();
}

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

void solve() {
  ll l, r;
  cin >> l >> r;

  ll diff = r ^ l;
  int k = 63 - __builtin_clzll(diff);
  ll d = 1LL << k;

  ll low_mult = ((l + d - 1) / d) * d;
  ll high_mult = (r / d) * d;

  ll x;
  if (l == 0)
    x = high_mult;
  else
    x = low_mult;

  ll y;
  if (x - 1 >= l)
    y = x - 1;
  else
    y = x + 1;

  ll z = -1;
  for (ll i = l; i <= r; i++) {
    if (i == x || i == y)
      continue;
    z = i;
    break;
  }

  cout << x << " " << y << " " << z << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
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;
typedef long long int ll;
 
void solve(){
    ll l,r;cin>>l>>r;
    ll pos=0;
    for(ll i=30;i>=0;i--){
        if(l&(1LL<<i) != r&(1LL<<i) ){
            pos = i; break;
        }
    }
    ll a=l|((1LL<<pos)-1);
    ll b=a+1;
    ll c=r;
    if(c==a || c==b)c--;
    if(c==a || c==b)c--;
    cout<<a<<" "<<b<<" "<<c<<endl;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t=1;   cin>>t;
    while(t--)solve();
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
void solve(){
    int l,r;cin>>l>>r;
    int pos=0;
    for(int i=30;i>=0;i--){
        if((l&(1<<i)) != (r&(1<<i)) ){
            pos = i; break;
        }
    }
    int a=l|((1<<pos)-1);
    int b=a+1;
    int c=r;
    if(c==a || c==b)c--;
    if(c==a || c==b)c--;
    cout<<a<<" "<<b<<" "<<c<<endl;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t=1;   cin>>t;
    while(t--)solve();
}
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;
typedef long long int ll;
 
void solve(){
    int l,r;cin>>l>>r;
    int pos=0;
    for(int i=30;i>=0;i--){
        if(l&(1<<i) != r&(1<<i) ){
            pos = i; break;
        }
    }
    int a=l|((1<<pos)-1);
    int b=a+1;
    int c=r;
    if(c==a || c==b)c--;
    if(c==a || c==b)c--;
    cout<<a<<" "<<b<<" "<<c<<endl;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t=1;   cin>>t;
    while(t--)solve();
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
void solve(){
    ll l,r;cin>>l>>r;
    ll pos=0;
    for(ll i=30;i>=0;i--){
        if(l&(1LL<<i) != r&(1LL<<i) ){
            pos = i; break;
        }
    }
    ll a=l|((1LL<<pos)-1);
    ll b=a+1;
    ll c=r;
    if(c==a || c==b)c--;
    if(c==a || c==b)c--;
    cout<<a<<" "<<b<<" "<<c<<endl;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t=1;   cin>>t;
    while(t--)solve();
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
void solve(){
    int l,r;cin>>l>>r;
    int pos=0;
    for(int i=30;i>=0;i--){
        if(l&(1<<i) != r&(1<<i) ){
            pos = i; break;
        }
    }
    int a=l|((1<<pos)-1);
    int b=a+1;
    int c=r;
    if(c==a || c==b)c--;
    if(c==a || c==b)c--;
    cout<<a<<" "<<b<<" "<<c<<endl;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t=1;   cin>>t;
    while(t--)solve();
}