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

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

inline bool divBy9(long long n){
	return n%9 == 0;
}


bool Recur(int ind, string n, long long sum,vector<vector<int>>& dp){
	if(divBy9(sum))
		return true;
	if(ind>= n.length())
		return false;
	if(dp[ind][sum % 9] != -1)
		return dp[ind][sum%9];

	int num = n[ind] - '0';
	bool change = false;
	if(num<=3)
		change = Recur(ind+1, n, sum - num + num*num, dp);
	bool notChange = Recur(ind+1, n, sum, dp);

	return dp[ind][sum%9] = change || notChange;
}

int main() {
	int t;
	cin>>t;
	while(t--){
		string n;
		cin>>n;

		long long SUM =0;
		for(int i=0; i< n.length(); i++)
			SUM+=( n[i] - '0');

		vector<vector<int>> dp(n.length(), vector<int>(9, -1));
		bool res = Recur(0, n, SUM, dp);
		if(res)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		
	}
    return 0;	
}

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

int main() {
	int t;
	cin>>t;
	while(t--){
		string n;
		cin>>n;
		int sum = 0;
		for(char c: n)
			sum+= c - '0';

		vector<bool> dp(9, false);
		dp[sum%9] = true;

		for(char c: n){
			int num = c - '0';
			vector<bool> newDP(9, false);
			for(int i=0; i<9; i++){
				if(!dp[i])
					continue;

				newDP[i] = true;

				if(num<=3){
					int newMod = (i - num + num*num + 9)%9;
					newDP[newMod] = true;
				}
			}

			dp = newDP;
		}

		if(dp[0] == true)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;

	}
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

int divBy9(long long n){
	if(n%9 == 0)
		return 1;
	return 0;
}

int Recur(int ind, string n, long long sum,vector<vector<int>>& dp){
	if(divBy9(sum))
		return 1;
	if(ind>= n.length())
		return 0;
	if(dp[ind][sum] != -1)
		return dp[ind][sum];

	int num = n[ind] - '0';
	int change = 0;
	if(num<=3)
		change = Recur(ind+1, n, sum - num + num*num, dp);
	int notChange = Recur(ind+1, n, sum, dp);

	return dp[ind][sum] = change || notChange;
}
int main() {
	int t;
	cin>>t;
	while(t--){
		string n;
		cin>>n;

		long long SUM =0;
		for(int i=0; i< n.length(); i++)
			SUM+=( n[i] - '0');

		vector<vector<int>> dp(n.length()+1, vector<int>(100000, -1));
		int res = Recur(0, n, SUM, dp);
		if(res)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		
	}
    return 0;	
}

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

inline bool divBy9(long long n){
	return n%9 == 0;
}


bool Recur(int ind, string n, long long sum,vector<vector<int>>& dp){
	if(divBy9(sum))
		return true;
	if(ind>= n.length())
		return false;
	if(dp[ind][sum % 9] != -1)
		return dp[ind][sum%9];

	int num = n[ind] - '0';
	bool change = false;
	if(num<=3)
		change = Recur(ind+1, n, sum - num + num*num, dp);
	bool notChange = Recur(ind+1, n, sum, dp);

	return dp[ind][sum%9] = change || notChange;
}

int main() {
	int t;
	cin>>t;
	while(t--){
		string n;
		cin>>n;

		long long SUM =0;
		for(int i=0; i< n.length(); i++)
			SUM+=( n[i] - '0');

		vector<vector<int>> dp(n.length(), vector<int>(9, -1));
		bool res = Recur(0, n, SUM, dp);
		if(res)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		
	}
    return 0;	
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

bool divBy9(long long n){
	if(n%9 == 0)
		return true;
	return false;
}

bool Recur(int ind, string n, long long sum){
	if(divBy9(sum))
		return true;
	if(ind>= n.length())
		return false;

	int num = n[ind] - '0';
	bool change = false;
	if(num<=3)
		change = Recur(ind+1, n, sum - num + num*num);
	bool notChange = Recur(ind+1, n, sum);

	return change || notChange;
}
int main() {
	int t;
	cin>>t;
	while(t--){
		string n;
		cin>>n;

		long long SUM =0;
		for(int i=0; i< n.length(); i++)
			SUM+=( n[i] - '0');

		bool res = Recur(0, n, SUM);
		if(res)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		
	}
    return 0;	
}

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

int divBy9(long long n){
	if(n%9 == 0)
		return 1;
	return 0;
}

int Recur(int ind, string n, long long sum,vector<vector<int>>& dp){
	if(divBy9(sum))
		return 1;
	if(ind>= n.length())
		return 0;
	if(dp[ind][sum] != -1)
		return dp[ind][sum];

	int num = n[ind] - '0';
	int change = 0;
	if(num<=3)
		change = Recur(ind+1, n, sum - num + num*num, dp);
	int notChange = Recur(ind+1, n, sum, dp);

	return dp[ind][sum] = change || notChange;
}
int main() {
	int t;
	cin>>t;
	while(t--){
		string n;
		cin>>n;

		long long SUM =0;
		for(int i=0; i< n.length(); i++)
			SUM+=( n[i] - '0');

		vector<vector<int>> dp(n.length()+1, vector<int>(100000, -1));
		int res = Recur(0, n, SUM, dp);
		if(res)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		
	}
    return 0;	
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

bool divBy9(long long n){
	if(n%9 == 0)
		return true;
	return false;
}

bool Recur(int ind, string n, long long sum){
	if(divBy9(sum))
		return true;
	if(ind>= n.length())
		return false;

	int num = n[ind] - '0';
	bool change = false;
	if(num<=3)
		change = Recur(ind+1, n, sum - num + num*num);
	bool notChange = Recur(ind+1, n, sum);

	return change || notChange;
}
int main() {
	int t;
	cin>>t;
	while(t--){
		string n;
		cin>>n;

		long long SUM =0;
		for(int i=0; i< n.length(); i++)
			SUM+=( n[i] - '0');

		bool res = Recur(0, n, SUM);
		if(res)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		
	}
    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;
int main(){
    int t;cin>>t;
    while(t--){
        int l,r;cin>>l>>r;
        int a=0,b=0,c=0;
        for(int i=30;i>=0;i--){
            int x=1<<i;
            if((x&l)!=(x&r)){
                a+=x;
                b+=x-1;
            }
            else if(x&r){
                a+=x;
                b+=x;
            }
        }
        for(int i=l;i<=r;i++){
            if(i!=a && i!=b){
                c=i;
                break;
            }
        }
        cout<<a<<" "<<b<<" "<<c<<"\n";
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;cin>>t;
    while(t--){
        int l,r;cin>>l>>r;
        int a=0,b=0,c=0;
        for(int i=30;i>=0;i--){
            int x=1<<i;
            if((x&l)!=(x&r)){
                a+=x;
                b+=x-1;
            }
            else if(x&r){
                a+=x;
                b+=x;
                break;
            }
        }
        for(int i=l;i<=r;i++){
            if(i!=a && i!=b){
                c=i;
                break;
            }
        }
        cout<<a<<" "<<b<<" "<<c<<"\n";
    }
    return 0;
}
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;
int main(){
    int t;cin>>t;
    while(t--){
        int l,r;cin>>l>>r;
        int a=0,b=0,c=0;
        for(int i=30;i>=0;i--){
            int x=1<<i;
            if((x&l)!=(x&r)){
                a+=x;
                b+=x-1;
            }
            else if(x&r){
                a+=x;
                b+=x;
            }
        }
        for(int i=l;i<=r;i++){
            if(i!=a && i!=r){
                c=i;
                break;
            }
        }
        cout<<a<<" "<<b<<" "<<c<<"\n";
    }
    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;
int main(){
    int t;cin>>t;
    while(t--){
        int l,r;cin>>l>>r;
        int a=0,b=0,c=0;
        for(int i=30;i>=0;i--){
            int x=1<<i;
            if((x&l)!=(x&r)){
                a+=x;
                b+=x-1;
            }
            else if(x&r){
                a+=x;
                b+=x;
                break;
            }
        }
        for(int i=l;i<=r;i++){
            if(i!=a && i!=b){
                c=i;
                break;
            }
        }
        cout<<a<<" "<<b<<" "<<c<<"\n";
    }
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;cin>>t;
    while(t--){
        int l,r;cin>>l>>r;
        int a=0,b=0,c=0;
        for(int i=30;i>=0;i--){
            int x=1<<i;
            if((x&l)!=(x&r)){
                a+=x;
                b+=x-1;
                break;
            }
            else if(x&r){
                a+=x;
                b+=x;
            }
        }
        for(int i=l;i<=r;i++){
            if(i!=a && i!=b){
                c=i;
                break;
            }
        }
        cout<<a<<" "<<b<<" "<<c<<"\n";
    }
    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;
int main(){
    int t;cin>>t;
    while(t--){
        int l,r;cin>>l>>r;
        int a=0,b=0,c=0;
        for(int i=30;i>=0;i--){
            int x=1<<i;
            if((x&l)!=(x&r)){
                a+=x;
                b+=x-1;
            }
            else if(x&r){
                a+=x;
                b+=x;
            }
        }
        for(int i=l;i<=r;i++){
            if(i!=a && i!=r){
                c=i;
                break;
            }
        }
        cout<<a<<" "<<b<<" "<<c<<"\n";
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;cin>>t;
    while(t--){
        int l,r;cin>>l>>r;
        int a=0,b=0,c=0;
        for(int i=30;i>=0;i--){
            int x=1<<i;
            if((x&l)!=(x&r)){
                a+=x;
                b+=x-1;
            }
            else if(x&r){
                a+=x;
                b+=x;
            }
        }
        for(int i=l;i<=r;i++){
            if(i!=a && i!=b){
                c=i;
                break;
            }
        }
        cout<<a<<" "<<b<<" "<<c<<"\n";
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
/*

    author : abhishrestha

*/

#include <bits/stdc++.h>

using namespace std;



#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

const long long MOD = 1e9 + 7;

const long long N = 1e7;

#define no cout << "NO" << endl

#define yes cout << "YES" << endl

#define int long long

#define endl "\n"



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

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

#define maxx(vector) (*max_element((vector).begin(), (vector).end()))

#define minn(vector) (*min_element((vector).begin(), (vector).end()))



#ifndef abhishrestha

#define debug(x) cerr << #x << " "; _print(x); cerr << endl;

#else 

#define debug(x)

#endif



void _print(int t) {cerr << t;}

void _print(string t) {cerr << t;}

void _print(char t) {cerr << t;}

void _print(double t) {cerr << t;}



template <class T, class V> void _print(pair <T, V> p);

template <class T> void _print(vector <T> v);

template <class T> void _print(set <T> v);

template <class T, class V> void _print(map <T, V> v);

template <class T> void _print(multiset <T> v);

template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}

template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}

template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}

template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}

template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}







/*





<------------------------------MAIN CODE STARTS HERE-------------------------------->





*/ 



void solve() {

    int n , l , r;

    cin >> n >> l >> r;



    vector<int> arr(n);

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

        cin >> arr[i];

    }

    vector<int> arr2 = arr;

    int cnt = r - l + 1;

    l--;

    r--;

    int cnt2 = cnt, sum = 0;

    sort(arr.begin() , arr.begin() + r);

    int i = 0;

    while(cnt--) {

        sum = sum + arr[i];

        i++;

    }

    i = l;

    int ans = sum;

    sum = 0;

    cnt = cnt2;



    sort(arr2.begin() + l , arr2.end());

    while (cnt--) {

        sum = sum + arr2[i];

        i++;

    }

    ans = min (ans , sum);

    cout << ans << endl;

}



int32_t main() {

#ifndef abhishrestha

    freopen("Error.txt", "w", stderr);

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

#endif

    FAST_IO;

    int tt = 1;

    cin >> tt;

    for( int tc = 1; tc <= tt; tc++ ) {

        solve();

    }

    return 0;

}
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;

void solve(){
	int n;cin>>n;
	vector<vector<int>> adj(n+1);
	vector<int> edges(n+1);
	for(int i=0; i<n-1; i++){
		int a,b;cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
		edges[a]++;
		edges[b]++;
	}
	if(n==2){
		cout<<0<<endl;
		return ;
	}
	long long max = -1,node=-1;;
	for(int i=1; i<=n; i++){
		if(edges[i] > max){
			node = i;
			max = edges[i];
		}
	}
	for(auto it: adj[node]){
		edges[it]--;
	}
	
	long long max2=-1,node2=-1;
	for(int i=1; i<=n; i++){
		if(edges[i]>max2 && i != node){
			node2=i;
			max2=edges[i];
		} 
	}
	cout<<max+max2-1<<endl;
}

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

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

void solve(){
	int n;cin>>n;
	vector<vector<int>> adj(n+1);
	vector<int> edges(n+1);
	for(int i=0; i<n-1; i++){
		int a,b;cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
		edges[a]++;
		edges[b]++;
	}
	if(n==2){
		cout<<0<<endl;
		return ;
	}
	long long max = -1,node=-1;;
	for(int i=1; i<=n; i++){
		if(edges[i] > max){
			node = i;
			max = edges[i];
		}
	}
	for(auto it: adj[node]){
		if(edges[it] == max){
			cout<<max*2-1<<endl;
			return ;
		}
		edges[it]--;
	}
	
	long long max2=-1,node2=-1;
	for(int i=1; i<=n; i++){
		if(edges[i]>max2 && i != node){
			node2=i;
			max2=edges[i];
		} 
	}
	cout<<max+max2-1<<endl;
}

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


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

void solve(){
	int n;cin>>n;
	vector<vector<int>> adj(n+1);
	vector<int> edges(n+1);
	for(int i=0; i<n-1; i++){
		int a,b;cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
		edges[a]++;
		edges[b]++;
	}
	if(n==2){
		cout<<0<<endl;
		return ;
	}
	long long max = -1,node=-1;;
	for(int i=1; i<=n; i++){
		if(edges[i] > max){
			node = i;
			max = edges[i];
		}
	}
	for(auto it: adj[node]){
		edges[it]--;
	}
	
	long long max2=-1,node2=-1;
	for(int i=1; i<=n; i++){
		if(edges[i]>max2 && i != node){
			node2=i;
			max2=edges[i];
		} 
	}
	cout<<max+max2-1<<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;

void solve(){
	int n;cin>>n;
	vector<vector<int>> adj(n+1);
	vector<int> edges(n+1);
	for(int i=0; i<n-1; i++){
		int a,b;cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
		edges[a]++;
		edges[b]++;
	}
	if(n==2){
		cout<<0<<endl;
		return ;
	}
	long long max = -1,node=-1;;
	for(int i=1; i<=n; i++){
		if(edges[i] > max){
			node = i;
			max = edges[i];
		}
	}
	for(auto it: adj[node]){
		if(edges[it] == max){
			cout<<max*2-1<<endl;
			return ;
		}
		edges[it]--;
	}
	
	long long max2=-1,node2=-1;
	for(int i=1; i<=n; i++){
		if(edges[i]>max2 && i != node){
			node2=i;
			max2=edges[i];
		} 
	}
	cout<<max+max2-1<<endl;
}

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

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

void solve(){
	int n;cin>>n;
	vector<vector<int>> adj(n+1);
	vector<int> edges(n+1);
	for(int i=0; i<n-1; i++){
		int a,b;cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
		edges[a]++;
		edges[b]++;
	}
	if(n==2){
		cout<<0<<endl;
		return ;
	}
	long long max = -1,node=-1;;
	for(int i=1; i<=n; i++){
		if(edges[i] > max){
			node = i;
			max = edges[i];
		}
	}
	bool flag = false;
	for(auto it: adj[node]){
		if(edges[it] == max){
			
			if(flag){
			cout<<max*2-1<<endl;
			return ;}flag = true;
		}
		edges[it]--;
	}
	long long max2=-1,node2=-1;
	for(int i=1; i<=n; i++){
		if(edges[i]>max2 && i != node){
			node2=i;
			max2=edges[i];
		} 
	}
	cout<<max+max2-1<<endl;
}

int main(){
	int t;cin>>t;
	while(t--){
		solve();
	}
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

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

    // Limit to at most the last 8 numbers in [l, r]
    long long start = max(l, r - 7);
    vector<long long> candidates;
    for (long long x = start; x <= r; x++) {
        candidates.push_back(x);
    }

    // Brute-force all distinct triples from candidates
    long long maxValue = -1;
    array<long long, 3> bestTriple = {l, l + 1, l + 2}; // Default triple

    int size = candidates.size();
    for (int i = 0; i < size; i++) {
        for (int j = i + 1; j < size; j++) {
            for (int k = j + 1; k < size; k++) {
                long long a = candidates[i];
                long long b = candidates[j];
                long long c = candidates[k];
                long long value = (a ^ b) + (b ^ c) + (a ^ c);

                if (value > maxValue) {
                    maxValue = value;
                    bestTriple = {a, b, c};
                }
            }
        }
    }

    // Output the best triple found
    cout << bestTriple[0] << " " << bestTriple[1] << " " << bestTriple[2] << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;
    while (t--) {
        long long l, r;
        cin >> l >> r;

        // Gather at most the last 8 numbers in [l, r].
        long long start = max(l, r - 7);
        vector<long long> cand;
        for (long long x = start; x <= r; x++) {
            cand.push_back(x);
        }

        // Brute force all distinct triples among these candidates.
        long long bestVal = -1;
        array<long long,3> bestTriple = {l, l+1, l+2}; // just a valid placeholder
        int sz = (int)cand.size();
        for (int i = 0; i < sz; i++) {
            for (int j = i + 1; j < sz; j++) {
                for (int k = j + 1; k < sz; k++) {
                    long long a = cand[i], b = cand[j], c = cand[k];
                    long long val = (a ^ b) + (b ^ c) + (a ^ c);
                    if (val > bestVal) {
                        bestVal = val;
                        bestTriple = {a, b, c};
                    }
                }
            }
        }

        // Output any triple that maximizes the expression.
        cout << bestTriple[0] << " "
             << bestTriple[1] << " "
             << bestTriple[2] << "\n";
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

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

    // Gather up to the last 8 numbers in [l, r].
    // (You could use 4 or 5 instead of 8; any small constant > 3 works fine.)
    long long start = max(l, r - 7);
    vector<long long> cand;
    for (long long x = start; x <= r; x++) {
        cand.push_back(x);
    }

    // Brute force all distinct triples among these candidates
    long long bestVal = -1; 
    array<long long, 3> bestTriple = {l, l+1, l+2}; // placeholder

    int sz = (int)cand.size();
    for (int i = 0; i < sz; i++) {
        for (int j = i + 1; j < sz; j++) {
            for (int k = j + 1; k < sz; k++) {
                long long a = cand[i], b = cand[j], c = cand[k];
                long long val = (a ^ b) + (b ^ c) + (a ^ c);
                if (val > bestVal) {
                    bestVal = val;
                    bestTriple = {a, b, c};
                }
            }
        }
    }

    // Output the triple that gave the maximum value
    cout << bestTriple[0] << " "
         << bestTriple[1] << " "
         << bestTriple[2] << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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


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

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

    // Limit to at most the last 8 numbers in [l, r]
    long long start = max(l, r - 7);
    vector<long long> candidates;
    for (long long x = start; x <= r; x++) {
        candidates.push_back(x);
    }

    // Brute-force all distinct triples from candidates
    long long maxValue = -1;
    array<long long, 3> bestTriple = {l, l + 1, l + 2}; // Default triple

    int size = candidates.size();
    for (int i = 0; i < size; i++) {
        for (int j = i + 1; j < size; j++) {
            for (int k = j + 1; k < size; k++) {
                long long a = candidates[i];
                long long b = candidates[j];
                long long c = candidates[k];
                long long value = (a ^ b) + (b ^ c) + (a ^ c);

                if (value > maxValue) {
                    maxValue = value;
                    bestTriple = {a, b, c};
                }
            }
        }
    }

    // Output the best triple found
    cout << bestTriple[0] << " " << bestTriple[1] << " " << bestTriple[2] << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    return 0;
}