ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;

int mod = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> tree(n + 1);
    set<pair<int, int>> s;
    vector<pair<int, int>> edges;

    for (int i = 1; i < n; i++) {
        int x, y;
        cin >> x >> y;
        tree[x].push_back(y);
        tree[y].push_back(x);
        s.insert({x, y});
        edges.push_back({x, y});
    }

    int ans = 0;

    // First pass over adjacent nodes
    for (auto val : edges) {
        int x = val.first;
        int y = val.second;
        ans = max(ans, (int)(tree[x].size() + tree[y].size() - 2));
    }

    // Second pass for non-adjacent pairs
    vector<pair<int, int>> b;
    for (int i = 1; i <= n; i++) {
        b.push_back({(int)tree[i].size(), i});
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int u = b[i].second, v = b[j].second;
            if (s.find({u, v}) == s.end() && s.find({v, u}) == s.end()) {
                ans = max(ans, (int)(tree[u].size() + tree[v].size() - 1));
            }
        }
    }

    cout << ans << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}


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

int mod = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> tree(n + 1);
    set<pair<int, int>> s;
    vector<pair<int, int>> edges;

    for (int i = 1; i < n; i++) {
        int x, y;
        cin >> x >> y;
        tree[x].push_back(y);
        tree[y].push_back(x);
        s.insert({x, y});
        edges.push_back({x, y});
    }

    int ans = 0;

    // First pass over adjacent nodes
    for (auto val : edges) {
        int x = val.first;
        int y = val.second;
        ans = max(ans, (int)(tree[x].size() + tree[y].size() - 2));
    }
    vector<pair<int, int>> b;
    for (int i = 1; i <= n; i++) {
        b.push_back({(int)tree[i].size(), i});
    }
   sort(b.begin(),b.end());
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int u = b[i].second, v = b[j].second;
            if (s.find({u, v}) == s.end() && s.find({v, u}) == s.end()) {
                ans = max(ans, (int)(tree[u].size() + tree[v].size() - 1));
                break;
            }
        }
    }

    cout << ans << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

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

int mod = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> tree(n + 1);
    set<pair<int, int>> s;
    vector<pair<int, int>> edges;

    for (int i = 1; i < n; i++) {
        int x, y;
        cin >> x >> y;
        tree[x].push_back(y);
        tree[y].push_back(x);
        s.insert({x, y});
        edges.push_back({x, y});
    }

    int ans = 0;

    // First pass over adjacent nodes
    for (auto val : edges) {
        int x = val.first;
        int y = val.second;
        ans = max(ans, (int)(tree[x].size() + tree[y].size() - 2));
    }
    vector<pair<int, int>> b;
    for (int i = 1; i <= n; i++) {
        b.push_back({(int)tree[i].size(), i});
    }
   sort(b.begin(),b.end());
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int u = b[i].second, v = b[j].second;
            if (s.find({u, v}) == s.end() && s.find({v, u}) == s.end()) {
                ans = max(ans, (int)(tree[u].size() + tree[v].size() - 1));
                break;
            }
        }
    }

    cout << ans << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}


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

int mod = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> tree(n + 1);
    set<pair<int, int>> s;
    vector<pair<int, int>> edges;

    for (int i = 1; i < n; i++) {
        int x, y;
        cin >> x >> y;
        tree[x].push_back(y);
        tree[y].push_back(x);
        s.insert({x, y});
        edges.push_back({x, y});
    }

    int ans = 0;

    // First pass over adjacent nodes
    for (auto val : edges) {
        int x = val.first;
        int y = val.second;
        ans = max(ans, (int)(tree[x].size() + tree[y].size() - 2));
    }
    vector<pair<int, int>> b;
    for (int i = 1; i <= n; i++) {
        b.push_back({(int)tree[i].size(), i});
    }
   sort(b.begin(),b.end());
   reverse(b.begin(),b.end());
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int u = b[i].second, v = b[j].second;
            if (s.find({u, v}) == s.end() && s.find({v, u}) == s.end()) {
                ans = max(ans, (int)(tree[u].size() + tree[v].size() - 1));
                break;
            }
        }
    }

    cout << ans << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;

int mod = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> tree(n + 1);
    set<pair<int, int>> s;
    vector<pair<int, int>> edges;

    for (int i = 1; i < n; i++) {
        int x, y;
        cin >> x >> y;
        tree[x].push_back(y);
        tree[y].push_back(x);
        s.insert({x, y});
        edges.push_back({x, y});
    }

    int ans = 0;

    // First pass over adjacent nodes
    for (auto val : edges) {
        int x = val.first;
        int y = val.second;
        ans = max(ans, (int)(tree[x].size() + tree[y].size() - 2));
    }

    // Second pass for non-adjacent pairs
    vector<pair<int, int>> b;
    for (int i = 1; i <= n; i++) {
        b.push_back({(int)tree[i].size(), i});
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int u = b[i].second, v = b[j].second;
            if (s.find({u, v}) == s.end() && s.find({v, u}) == s.end()) {
                ans = max(ans, (int)(tree[u].size() + tree[v].size() - 1));
            }
        }
    }

    cout << ans << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
// typedef vector<int> vi; 
// typedef vector<vector<int>> vvi; 
// typedef vector<long long> vl; 
// typedef vector<vector<long long>> vvl;
// typedef vector<bool> vb; 
// typedef vector<vector<bool>> vvb; 
// typedef map<int, int> mii; 
// typedef map<long long, long long> mll;
// typedef pair<int, int> pii; 
// typedef pair<long long, long long> pll;
// typedef unsigned long long ull; 
// typedef long double ld; 
// typedef long long ll;
typedef long long ll;
#define f(i,a,b) for(int i = a; i < b ; i++)
#define geti(n) int n; cin >> n;
#define getll(n) long long int n; cin >> n;
#define gets(s) string s; cin >>s;
#define getv(v,n) vector<int> v(n) ; f(i, 0 ,n) cin >> v[i];
#define srt(v) sort(v.begin(), v.end());
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
void Solve() 
{
    string s;
    cin>>s;
    vector<long long> v(s.size());
    long long n = s.size();
    for(long long i = 0; i<s.size(); i++){
        v[i] = (s[i] - '0');
    }
    for(long long i = 0; i<n; i++){
        long long max = v[i];
        long long ind = i;
        for(long long j = i; j<min(n, j+9); j++){
            long long mx = v[j] - (j - i);
            if(mx > max){
                max = mx;
                ind = j;
            }
        }
        for(long long k = ind; k>i; k--){
            v[k] = v[k-1];
        }
        v[i] = max;
        cout<<max;
    }
    cout<<endl;
}

int32_t main() 
{
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    for(int i = 0; i < t; i++) 
    {
        Solve();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured:"  << elapsed.count() * 1e-9 << ",seconds."; 
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
// typedef vector<int> vi; 
// typedef vector<vector<int>> vvi; 
// typedef vector<long long> vl; 
// typedef vector<vector<long long>> vvl;
// typedef vector<bool> vb; 
// typedef vector<vector<bool>> vvb; 
// typedef map<int, int> mii; 
// typedef map<long long, long long> mll;
// typedef pair<int, int> pii; 
// typedef pair<long long, long long> pll;
// typedef unsigned long long ull; 
// typedef long double ld; 
// typedef long long ll;
typedef long long ll;
#define f(i,a,b) for(int i = a; i < b ; i++)
#define geti(n) int n; cin >> n;
#define getll(n) long long int n; cin >> n;
#define gets(s) string s; cin >>s;
#define getv(v,n) vector<int> v(n) ; f(i, 0 ,n) cin >> v[i];
#define srt(v) sort(v.begin(), v.end());
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
void Solve() 
{
    string s;
    cin>>s;
    vector<long long> v(s.size());
    long long n = s.size();
    // for(long long i = 0; i<s.size(); i++){
    //     v[i] = (s[i] - '0');
    // }
    for(long long i = 0; i<n; i++){
        long long max = s[i] - '0';
        long long ind = i;
        for(long long j = i; j<min(n, j+9); j++){
            long long mx = s[i] - '0' - (j - i);
            if(mx > max){
                max = mx;
                ind = j;
            }
        }
        for(long long k = ind; k>i; k--){
            s[k] = s[k-1];
        }
        s[i] = max + '0';
    }
    cout<<s<<endl;
}

int32_t main() 
{
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    for(int i = 0; i < t; i++) 
    {
        Solve();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured:"  << elapsed.count() * 1e-9 << ",seconds."; 
    return 0;
}

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

using namespace std;

void solve() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        int best = s[i] - '0', pos = i;
        for (int j = i; j < min(i + 10, (int) s.size()); j++) {
            if (s[j] - '0' - (j - i) > best) {
                best = s[j] - '0' - (j - i);
                pos = j;
            }
        }
        while (pos > i) {
            swap(s[pos], s[pos - 1]);
            pos--;
        }
        s[i] = char(best + '0');
    }
    cout << s;
}

int main() {
    int TESTS = 1; cin >> TESTS;
    while (TESTS --> 0) {
        solve();
        cout << '\n';
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n" 
#define ull unsigned long long
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define lowbit(x) (x & -(x))
#define INF 0x3f3f3f3f
#define ls(p) p << 1
#define rs(p) p << 1 | 1
const double eps = 1e-6;
const double PI = acos(double(-1));
const ull base = 131;
const double C = 0.5772156649;
const int mod = 1000007;
const int N = 2e5 + 7;
unordered_map<int, int> mp;
vector<int> G[N];
void solve()
{
    int n;
    cin >> n;
    mp.clear();
    for (int i = 1; i <= n;i++){
        G[i].clear();
    }
    int p = 0, res = 0;
    for (int i = 1; i < n; i++)
    {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
        mp[u]++;
        mp[v]++;
        if(res<mp[u]){
            res = mp[u];
            p = u;
        }
        if(res<mp[v]){
            res = mp[v];
            p = v;
        }
    }
    int ans = res;
    for(auto w:G[p]){
        mp[w]--;
    }
    mp[p] = 0;
    int maxn = 0;
    for (int i = 1; i <= n; i++)
    {
        maxn = max(maxn, mp[i]);
    }
    ans = ans + maxn - 1;
    cout << ans << endl;
}
int main()
{
    IOS;
    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n" 
#define ull unsigned long long
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define lowbit(x) (x & -(x))
#define INF 0x3f3f3f3f
#define ls(p) p << 1
#define rs(p) p << 1 | 1
const double eps = 1e-6;
const double PI = acos(double(-1));
const ull base = 131;
const double C = 0.5772156649;
const int mod = 1000007;
const int N = 2e5 + 7;
unordered_map<int, int> mp;
vector<int> G[N];
void solve()
{
    int n;
    cin >> n;
    mp.clear();
    for (int i = 1; i <= n;i++){
        G[i].clear();
    }
    int p = 0, res = 0;
    for (int i = 1; i < n; i++)
    {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
        mp[u]++;
        mp[v]++;
        if(res<mp[u]){
            res = mp[u];
            p = u;
        }
        if(res<mp[v]){
            res = mp[v];
            p = v;
        }
    }
    int ans = res;
    for(auto w:G[p]){
        mp[w]--;
    }
    mp[p] = 0;
    int maxn = 0;
    for (int i = 1; i <= n; i++)
    {
        maxn = max(maxn, mp[i]);
    }
    ans = ans + maxn - 1;
    cout << ans << endl;
}
int main()
{
    IOS;
    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n" 
#define ull unsigned long long
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define lowbit(x) (x & -(x))
#define INF 0x3f3f3f3f
#define ls(p) p << 1
#define rs(p) p << 1 | 1
const double eps = 1e-6;
const double PI = acos(double(-1));
const ull base = 131;
const double C = 0.5772156649;
const int mod = 1000007;
const int N = 2e5 + 7;
unordered_map<int, int> mp;
vector<int> G[N];
int a[N],b[N];
void solve()
{
    int n;
    cin >> n;
    mp.clear();
    for (int i = 1; i <= n;i++){
        G[i].clear();
    }
    int res = 0;
    for (int i = 1; i < n; i++)
    {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
        mp[u]++;
        mp[v]++;
        res = max(res, max(mp[u], mp[v]));
    }
    int k = 0;
    for (int i = 1; i <= n; i++)
    {
        a[i] = mp[i];
        if(mp[i]==res){
            b[++k] = i;
        }
    }
    sort(a + 1, a + n + 1);
    int maxn=0;
    for (int i = 1; i <= k; i++)
    {
        priority_queue<int> q;
        for(auto w:G[b[i]]){
            q.push(mp[w]);
        }
        int kk = n - 1;
        while(!q.empty()&&a[kk]==q.top()){
            kk--;
            q.pop();
        }
        maxn = max(maxn, res + a[kk] - 1);
    }
    cout << maxn << endl;
}
int main()
{
    IOS;
    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while (t>0){
        t--;
        string s;
        cin>>s;
        int sum=0;
        int n=s.length();
        int two=0,three=0;
        for (int i=0;i<n;i++){
            sum=sum + (int)s[i]-48;
            if (s[i]=='2'){
                two+=1;
            }else if(s[i]=='3'){
                three+=1;
            }
        }
        if (sum%9==0){
            cout<<"YES"<<endl;
        }
        else{
            int f=0;
            for (int i=0;i<min(100000,two);i++){
                for (int j=0;j<min(100000,three);j++){
                    long long m=i*2+j*6;
                    if (m%9==9-sum%9){
                        f=1;
                        break;
                    } 
                }
            }
            if (f){
                cout<<"yes"<<endl;
            }else{
                cout<<"no"<<endl;
            }
    }
}
}

Submission (verdict: Accepted):
#include<iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while (t>0){
        t--;
        string s;
        cin>>s;
        int sum=0;
        int n=s.length();
        int two=0,three=0;
        for (int i=0;i<n;i++){
            sum=sum + (int)s[i]-48;
            if (s[i]=='2'){
                two+=1;
            }else if(s[i]=='3'){
                three+=1;
            }
        }
        if (sum%9==0){
            cout<<"YES"<<endl;
        }
        else{
            int f=0;
            for (int i=0;i<=min(100000,two);i++){
                for (int j=0;j<=min(100000,three);j++){
                    long long m=i*2+j*6;
                    if (m%9==9-sum%9){
                        f=1;
                        break;
                    } 
                }
            }
            if (f){
                cout<<"yes"<<endl;
            }else{
                cout<<"no"<<endl;
            }
    }
}
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while (t>0){
        t--;
        string s;
        cin>>s;
        int sum=0;
        int n=s.length();
        int two=0,three=0;
        for (int i=0;i<n;i++){
            sum=sum + (int)s[i]-48;
            if (s[i]=='2'){
                two+=1;
            }else if(s[i]=='3'){
                three+=1;
            }
        }
        if (sum%9==0){
            cout<<"YES"<<endl;
        }
        else{
            int b=9-sum%9;
            if (b%2==0){
                if (b==8 &&((two>=1 && three>=1) || (two>=4))){
                    cout<<"YES"<<endl;
                }else if (b==6 && ((three>=1)||(two>=3))){
                    cout<<"YES"<<endl;
                }else if (b==4 && two>=2){
                    cout<<"YES"<<endl;
                }else if (b==2 && two>=1){
                    cout<<"YES"<<endl;
                }else{
                    cout<<"NO"<<endl;
                }
            }else{
                b=b+9;
                if (b==16 && two>=2){
                    if ((three==1 && two>=5)|| (three>1)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else if (b==14 && two>=1){
                    if ((three==1 && two>=4)|| (three>=2)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else if (b==12){
                    if ((three==1 && two>=3) || (three>=2)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else if (b==10 && two>=2){
                    if ((three==1)|| (two>=5)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else {
                    cout<<"NO"<<endl;
                }
            }
        }
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while (t>0){
        t--;
        string s;
        cin>>s;
        int sum=0;
        int n=s.length();
        int two=0,three=0;
        for (int i=0;i<n;i++){
            sum=sum + (int)s[i]-48;
            if (s[i]=='2'){
                two+=1;
            }else if(s[i]=='3'){
                three+=1;
            }
        }
        if (sum%9==0){
            cout<<"YES"<<endl;
        }
        else{
            int f=0;
            for (int i=0;i<min(100000,two);i++){
                for (int j=0;j<min(100000,three);j++){
                    long long m=i*2+j*6;
                    if (m%9==9-sum%9){
                        f=1;
                        break;
                    } 
                }
            }
            if (f){
                cout<<"yes"<<endl;
            }else{
                cout<<"no"<<endl;
            }
    }
}
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while (t>0){
        t--;
        string s;
        cin>>s;
        int sum=0;
        int n=s.length();
        int two=0,three=0;
        for (int i=0;i<n;i++){
            sum=sum + (int)s[i]-48;
            if (s[i]=='2'){
                two+=1;
            }else if(s[i]=='3'){
                three+=1;
            }
        }
        if (sum%9==0){
            cout<<"YES"<<endl;
        }
        else{
            int b=9-sum%9;
            if (b%2==0){
                if (b==8 &&( (two>=1 && three>=1) || two>=4)){
                    cout<<"YES"<<endl;
                }else if (b==6 && (three>=1||two>=3)){
                    cout<<"YES"<<endl;
                }else if (b==4 && two>=2){
                    cout<<"YES"<<endl;
                }else if (b==2 && two>=1){
                    cout<<"YES"<<endl;
                }else{
                    cout<<"NO"<<endl;
                }
            }else{
                b=b+9;
                if (b==16 && two>=2){
                    if ((three==1 && two>=5)|| (three>1)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else if (b==14 && two>=1){
                    if ((three==1 && two>=4)|| (three>2)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else if (b==12){
                    if ((three==1 && two>=3)|| (three>=2)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else if (b==10 && two>=2){
                    if ((three==1)|| (two>=5)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else {
                    cout<<"NO"<<endl;
                }
            }
        }
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
//https://codeforces.com/problemset/problem/2057/C
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int t;
ll l, r;

#define BackR(i, from, to) for (int i= from; i>=to; i--)
#define PreR(i, from, to) for (int i=from; i<to; i++)

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin>>t;
    while(t--) {
        cin>>l>>r;
        if (r-l==2) {
            cout<<l<<" "<<r-1<<" "<<r<<"\n";
            continue;
        }

        //��l��r�������������ǰ׺
        ll pre = 0ll;
        BackR(i, 30, 0) {
            //��λ����ȴ����ҵ����ǰ׺
            if (((l>>i)&1) != ((r>>i)&1)) {
                ll a = pre + (1ll<<i), b = a-1;
                cout<<a<<" "<<b<<" "<<(a!=l&&b!=l ? l : r)<<"\n";
                break;
            }
            if ((l>>i)&1) pre += 1ll<<i; 
            
        }

    }

}