ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> PII;
#define endl "\n"
#define ft first
#define sd second
#define pb push_back
const int MOD = 1e9 + 7;
const int INF = 1e18;
bool cmp1(PII x,PII y){
    return x.first < y.first;
}
bool cmp2(PII x,PII y){
    return x.second > y.second;
}
void solve() {
    int n; cin>>n;
    vector<int>a(n + 1);
    vector<PII>ans;
    for(int i = 1;i <= n;i++) cin>>a[i];
    for(int i = 1;i <= n;i++){
        vector<PII> v1,v2;
        for(int j = i + 1;j <= n;j++){
            if(a[j] > a[i]){
                v1.pb({a[j],a[i]});
            }
            else v2.pb({a[i],a[j]});
        }
        sort(v1.begin(),v1.end());
        for(auto & [x,y] : v1)
        {
            ans.pb({x,y});
            swap(x,y);
        }
        sort(v1.begin(),v1.end(),cmp2);
        for(auto & [x,y] : v1)
        {
            ans.pb({x,y});
        }
//        cout<<"begin ======="<<endl;
//        for(auto [x,y] : v2)
//            cout<<x<<' '<<y<<endl;
//        sort(v2.begin(),v2.end(),cmp2);
//        for(auto [x,y] : v2)
//            cout<<x<<' '<<y<<endl;
//        cout<<"end ==========="<<endl;
        for(auto & [x,y] : v2)
        {
            ans.pb({x,y});
        }

    }
    cout<<ans.size()<<endl;
    for(auto [x,y] : ans)
        cout<<x<<' '<<y<<endl;
    return ;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
//    cin>>T;
    while(T--)
        solve();
    return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> PII;
#define endl "\n"
#define ft first
#define sd second
#define pb push_back
const int MOD = 1e9 + 7;
const int INF = 1e18;
bool cmp1(PII x,PII y){
    return x.first < y.first;
}
bool cmp2(PII x,PII y){
    return x.second > y.second;
}
void solve() {
    int n; cin>>n;
    vector<int>a(n + 1);
    vector<PII>ans;
    for(int i = 1;i <= n;i++) cin>>a[i];
    for(int i = 1;i <= n;i++){
        vector<PII> v1,v2;
        for(int j = i + 1;j <= n;j++){
            if(a[j] > a[i]){
                v1.pb({a[j],a[i]});
            }
            else v2.pb({a[i],a[j]});
        }
        sort(v1.begin(),v1.end());
        for(auto & [x,y] : v1)
        {
            ans.pb({x,y});
            swap(x,y);
        }
        sort(v1.begin(),v1.end(),cmp2);
        for(auto & [x,y] : v1)
        {
            ans.pb({x,y});
        }
//        cout<<"begin ======="<<endl;
//        for(auto [x,y] : v2)
//            cout<<x<<' '<<y<<endl;
        sort(v2.begin(),v2.end(),cmp2);
//        for(auto [x,y] : v2)
//            cout<<x<<' '<<y<<endl;
//        cout<<"end ==========="<<endl;
        for(auto & [x,y] : v2)
        {
            ans.pb({x,y});
        }

    }
    cout<<ans.size()<<endl;
    for(auto [x,y] : ans)
        cout<<x<<' '<<y<<endl;
    return ;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
//    cin>>T;
    while(T--)
        solve();
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> PII;
#define endl "\n"
#define ft first
#define sd second
#define pb push_back
const int MOD = 1e9 + 7;
const int INF = 1e18;
void solve() {
    int n; cin>>n;
    vector<int>a(n + 1);
    vector<PII>ans;
    for(int i = 1;i <= n;i++) cin>>a[i];
    for(int i = 1;i <= n;i++){
        vector<PII> v;
        for(int j = i + 1;j <= n;j++){
            v.pb({a[i],a[j]});
        }
        sort(v.begin(),v.end());
        for(auto [x,y] : v){
            if(x < y) {
                ans.pb({y,x});
            }
            ans.pb({x,y});
        }
    }
    cout<<ans.size()<<endl;
    for(auto [x,y] : ans)
        cout<<x<<' '<<y<<endl;
    return ;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
//    cin>>T;
    while(T--)
        solve();
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


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

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--)
    {
      string str;
      cin >> str;
      for(int i=0;i<str.length();i++)
      {
        for(int j=0;j<str.length()-1;j++)
        {
          if(str[j] < str[j+1] && abs(str[j] - str[j+1]) > 1)
          { 
            int x = (int)(str[j+1] - '0');
            str[j+1] = (--x) + '0';
            swap(str[j],str[j+1]);
            
          }
        }
      }
      cout << str <<'\n';
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--)
    {
      string str;
      cin >> str;
      for(int i=0;i<str.length();i+=2)
      {
        for(int j=0;j<str.length()-1;j++)
        {
          if(str[j] < str[j+1] && abs(str[j] - str[j+1]) > 1)
          { 
            int x = (int)(str[j+1] - '0');
            str[j+1] = (--x) + '0';
            swap(str[j],str[j+1]);
            
          }
        }
      }
      cout << str <<'\n';
    }
    return 0;
}

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

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--)
    {
      string str;
      cin >> str;
      for(int i=1;i<str.length();i++)
      {
        int x = i - 1;
        int y = i;
        while((x >= 0) && (str[y] > 0) && (str[y] - str[x] > 1))
        {
          str[y]--;
          swap(str[x],str[y]);
          x--;
          y--;
        }

      }
      cout << str <<'\n';
    }
    
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--)
    {
      string str;
      cin >> str;
      for(int i=0;i<str.length();i++)
      {
        for(int j=0;j<str.length()-1;j++)
        {
          if(str[j] < str[j+1] && abs(str[j] - str[j+1]) > 1)
          { 
            int x = (int)(str[j+1] - '0');
            str[j+1] = (--x) + '0';
            swap(str[j],str[j+1]);
            
          }
        }
      }
      cout << str <<'\n';
    }
    return 0;
}

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

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--)
    {
      string str;
      cin >> str;
      for(int i=0;i<str.length();i+=2)
      {
        for(int j=0;j<str.length()-1;j++)
        {
          if(str[j] < str[j+1] && abs(str[j] - str[j+1]) > 1)
          { 
            int x = (int)(str[j+1] - '0');
            str[j+1] = (--x) + '0';
            swap(str[j],str[j+1]);
            
          }
        }
      }
      cout << str <<'\n';
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

void solve(){
    int n, l, r;
    cin >> n >> l >> r;

    vector<int> arr(n+1);
    for (int i = 1; i <= n; i++)
    cin >> arr[i];

    vector<int> A, B, C;
    for (int i = 1; i < l; i++)
    A.push_back(arr[i]);

    int tot = 0;
    for (int i = l; i <= r; i++){
        B.push_back(arr[i]);
        tot += arr[i];
    }

    for (int i = r+1; i <= n; i++)
    C.push_back(arr[i]);

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    int i = B.size() - 1;
    int cur = tot, ans =  tot;
    for (int num: A){
        if(num > B[i] || i < 0) break;
        cur -= B[i];
        cur += num;
        i--;
    }
    ans = min(ans, cur);

    i = B.size()-1;
    cur = tot;
    for (int num: C){
        if (num > B[i] || i < 0) break;
        cur -= B[i];
        cur += num;
        i--;
    }
    ans = min(ans, cur);
    cout << ans << "\n";
}

int main(){
    cin.tie(0)->sync_with_stdio(0);
    // freopen("sample.in", "r", stdin);

    int t;
    cin >> t;

    while(t--)
    solve();
    return 0;
}

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

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

    vector<ll> arr(n+1);
    for (int i = 1; i <= n; i++)
    cin >> arr[i];

    vector<ll> A, B, C;
    for (int i = 1; i < l; i++)
    A.push_back(arr[i]);

    ll tot = 0;
    for (int i = l; i <= r; i++){
        B.push_back(arr[i]);
        tot += arr[i];
    }

    for (int i = r+1; i <= n; i++)
    C.push_back(arr[i]);

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    int i = B.size() - 1;
    ll cur = tot, ans =  tot;
    for (int num: A){
        if(num > B[i] || i < 0) break;
        cur -= B[i];
        cur += num;
        i--;
    }
    ans = min(ans, cur);

    i = B.size()-1;
    cur = tot;
    for (int num: C){
        if (num > B[i] || i < 0) break;
        cur -= B[i];
        cur += num;
        i--;
    }
    ans = min(ans, cur);
    cout << ans << "\n";
}

int main(){
    cin.tie(0)->sync_with_stdio(0);
    // freopen("sample.in", "r", stdin);

    int t;
    cin >> t;

    while(t--)
    solve();
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

using namespace std;

using ll = long long int;



void solve(){

    int n, l, r;

    cin >> n >> l >> r;



    vector<int> arr(n+1);

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

    cin >> arr[i];



    vector<int> A, B, C;

    for (int i = 1; i < l; i++)

    A.push_back(arr[i]);



    int tot = 0;

    for (int i = l; i <= r; i++){

        B.push_back(arr[i]);

        tot += arr[i];

    }



    for (int i = r+1; i <= n; i++)

    C.push_back(arr[i]);



    sort(A.begin(), A.end());

    sort(B.begin(), B.end());

    sort(C.begin(), C.end());



    int i = B.size() - 1;

    int cur = tot, ans =  tot;

    for (int num: A){

        if(num > B[i]) break;

        cur -= B[i];

        cur += num;

        i--;

    }

    ans = min(ans, cur);



    i = B.size()-1;

    cur = tot;

    for (int num: C){

        if (num > B[i]) break;

        cur -= B[i];

        cur += num;

        i--;

    }

    ans = min(ans, cur);

    cout << ans << "\n";

}



int main(){

    cin.tie(0)->sync_with_stdio(0);

    // freopen("sample.in", "r", stdin);



    int t;

    cin >> t;



    while(t--)

    solve();

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;

using ll = long long int;



void solve(){

    int n, l, r;

    cin >> n >> l >> r;



    vector<int> arr(n+1);

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

    cin >> arr[i];



    vector<int> A, B, C;

    for (int i = 1; i < l; i++)

    A.push_back(arr[i]);



    int tot = 0;

    for (int i = l; i <= r; i++){

        B.push_back(arr[i]);

        tot += arr[i];

    }



    for (int i = r+1; i <= n; i++)

    C.push_back(arr[i]);



    sort(A.begin(), A.end());

    sort(B.begin(), B.end());

    sort(C.begin(), C.end());



    int i = B.size() - 1;

    int cur = tot, ans =  tot;

    for (int num: A){

        if(num > B[i]) break;

        cur -= B[i];

        cur += num;

        i--;

    }

    ans = min(ans, cur);



    i = B.size()-1;

    cur = tot;

    for (int num: C){

        if (num > B[i]) break;

        cur -= B[i];

        cur += num;

        i--;

    }

    ans = min(ans, cur);

    cout << ans << "\n";

}



int main(){

    cin.tie(0)->sync_with_stdio(0);

    // freopen("sample.in", "r", stdin);



    int t;

    cin >> t;



    while(t--)

    solve();

    return 0;

}

Submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

void solve(){
    int n, l, r;
    cin >> n >> l >> r;

    vector<int> arr(n+1);
    for (int i = 1; i <= n; i++)
    cin >> arr[i];

    vector<int> A, B, C;
    for (int i = 1; i < l; i++)
    A.push_back(arr[i]);

    int tot = 0;
    for (int i = l; i <= r; i++){
        B.push_back(arr[i]);
        tot += arr[i];
    }

    for (int i = r+1; i <= n; i++)
    C.push_back(arr[i]);

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    int i = B.size() - 1;
    int cur = tot, ans =  tot;
    for (int num: A){
        if(num > B[i] || i < 0) break;
        cur -= B[i];
        cur += num;
        i--;
    }
    ans = min(ans, cur);

    i = B.size()-1;
    cur = tot;
    for (int num: C){
        if (num > B[i] || i < 0) break;
        cur -= B[i];
        cur += num;
        i--;
    }
    ans = min(ans, cur);
    cout << ans << "\n";
}

int main(){
    cin.tie(0)->sync_with_stdio(0);
    // freopen("sample.in", "r", stdin);

    int t;
    cin >> t;

    while(t--)
    solve();
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#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 int long long
#define float double

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define inp(x) \
    int x;     \
    cin >> x;

#define pb push_back
#define fr(i, b) for (int i = 0; i < (int)(b); i++)
#define scanarr                 \
    int a[n];                   \
    for (int i = 0; i < n; i++) \
    cin >> a[i]
#define sz(a) (int)(a.size())
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define lower(a, b) lower_bound((a).begin(), (a).end(), (int)(b))
#define upper(a, b) upper_bound((a).begin(), (a).end(), (int)(b))
#define lower_ind(a, b) lower_bound((a).begin(), (a).end(), (int)(b)) - (a).begin()
#define upper_ind(a, b) upper_bound((a).begin(), (a).end(), (int)(b)) - (a).begin()

typedef vector<int> vi;
typedef set<int> si;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef map<char, int> mci;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key

void solve()
{
    string a;
    string b;
    string c;
    cin >> a >> b >> c;
    int n = a.size();
    int m = b.size();
    vector dp(n + 1, vector(m + 1, 0));
    for (int i = 1; i <= m; i++)
    {
        if (b[i - 1] != c[i - 1])
        {
            dp[0][i] = dp[0][i - 1] + 1;
        }
        else
        {
            dp[0][i] = dp[0][i - 1];
        }
    }
    for (int i = 1; i <= n; i++)
    {
        dp[i][0] = dp[i - 1][0];
        if (a[i - 1] != c[i - 1])
        {
            dp[i][0] += 1;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            int flag = 0;
            if (a[i - 1] == c[i + j - 1])
            {
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1] + 1);
                flag = 1;
            }
            if (b[j - 1] == c[i + j - 1])
            {
                if (flag == 1)
                {
                    dp[i][j] = min(dp[i][j], dp[i][j - 1]);
                }
                else
                {
                    dp[i][j] = dp[i][j - 1];
                }
            }
            if (a[i - 1] != c[i + j - 1] && b[j - 1] != c[i + j - 1])
            {
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1;
            }
        }
    }
    cout << dp[n][m] << endl;
}

signed main()
{
    fast;
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
Problem: 2050B - Transfusion
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while (t--)
    {
        long long int n;
        long long int sum1;
        long long int sum2;
        long long int sum3;
        long long int sum4;
        cin>>n;
        vector<long long int> arr(n);
        bool answer = true;
        for (long long int i = 0; i < n; i++)
        {
            cin>>arr[i];
        }
        long long int even;
        long long int odd;
        if (n==3)
        {
            if (((arr[0] +1 ==arr[1])&&(arr[1]+1==arr[2])) || ((arr[0]-1 == arr[1]) && (arr[1]-1 == arr[2])))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (n ==4)
        {
            if ((arr[0]+arr[2] == arr[1] + arr[3]) && ((arr[0]+arr[2])%2 == 0))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (n==5)
        {
            if (((arr[1]+arr[3])%2 == 0) && ((arr[0]+arr[2]+arr[4])%3 == 0)&& ((arr[0] +arr[2]+arr[4])/3 == (arr[1]+arr[3])/2))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (n==6)
        {
            if ((arr[0] +arr[2]+arr[4] == arr[1]+arr[3]+arr[5]) && ((arr[1]+arr[3]+arr[5])%3 == 0))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
        }
        else if (n==7)
        {
            if ((arr[0] +arr[2]+arr[4] == arr[1]+arr[3]+arr[5]) && (arr[0] +arr[2]+arr[4] == arr[2]+arr[4]+arr[6])&&((arr[1]+arr[3]+arr[5])%3 == 0))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
        }
                
        else{
        if (n%2 == 0)
        {
            even = n;
            odd= n-1;
        }
        else
        {
            even=n-1;
            odd=n;
        }
        for (int i = 0; i <=even-6 ; i=i+2)
        {
            sum1 = arr[i] + arr[i+2] + arr[i+4];
            sum2 = arr[i+2] + arr[i+6] + arr[i+4];
            if (sum1 != sum2)
            {
                answer=false;
                break;
            }
            
        }
        if (answer==true)
        {
            for (int i = 1; i <=odd-6 ; i=i+2)
            {
            sum3 = arr[i] + arr[i+2] + arr[i+4];
            sum4 = arr[i+2] + arr[i+6] + arr[i+4];
            if (sum3 != sum4)
            {
                answer=false;
                break;
            }
            }
        }
        
        if ((answer==true) && (sum1 == sum3))
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }}
    }
    
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100050;
ll gcd(ll x,ll y){
	if(y==0) return x;
	else return gcd(y,x%y);
}
ll a[50]={0};
void solve(){
	ll l,r;
	stack<ll>st;
	scanf("%lld %lld",&l,&r);
	ll x=0;
	ll rr=r;
	while(rr>1){
		st.push(rr%2);
		rr/=2;
		x++;
	}
	st.push(1);
	int a1=0;
	while(!st.empty()){a[++a1]=st.top();st.pop();}
	int p=1;
	ll ans=0;
	while(x>=0){
		if(a[p]==1){
			ans+=(1<<x);
		}
		p++;
		if(ans<=r&&ans-2>=l){
			printf("%lld %lld %lld",ans,ans-1,ans-2);
			break;
		}else{
			x--;
		}
	}
//	cout<<"\n"<<(ans ^ (ans-1))+((ans-1) ^ (ans-2))+(ans ^(ans-2))<<"\n";
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--){
		solve();
		printf("\n");
	}
	return 0;
}
/*

*/


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100050;
ll gcd(ll x,ll y){
	if(y==0) return x;
	else return gcd(y,x%y);
}
ll a[50]={0};
void solve(){
	ll l,r;
	stack<ll>st;
	scanf("%lld %lld",&l,&r);
	ll x=0;
	ll rr=r;
	while(rr>1){
		st.push(rr%2);
		rr/=2;
		x++;
	}
	ll xx=x;
	st.push(1);
	int a1=0;
	while(!st.empty()){a[++a1]=st.top();st.pop();}
	int p=1;
	ll ans=0;
	ll sum1=0;
	while(x>=0){
		if(a[p]==1){
			ans+=(1<<x);
		}
		p++;
		if(ans<=r&&ans-2>=l){
			sum1=(ans ^ (ans-1))+((ans-1) ^ (ans-2))+(ans ^(ans-2));
//			printf("%lld %lld %lld",ans,ans-1,ans-2);
			break;
		}else{
			x--;
		}
	}
//	cout<<"\n"<<(ans ^ (ans-1))+((ans-1) ^ (ans-2))+(ans ^(ans-2))<<"\n";
	ll ans2=0;
	ll sum2=0;
	x=xx;
	p=1;
	while(x>=0){
		if(a[p]==1){
			ans2+=(1<<x);
		}
		p++;
		if(ans2+1<=r&&ans2-1>=l){
//			printf("%lld %lld %lld",ans+1,ans-1,ans-1);
			sum2=(ans2 ^ (ans2-1))+((ans2-1) ^ (ans2+1))+(ans2 ^(ans2+1));
			break;
		}else{
			x--;
		}
	}
	ll ans3=0;
	ll sum3=0;
	x=xx;
	p=1;
	while(x>=0){
		if(a[p]==1){
			ans3+=(1<<x);
		}
		p++;
		if(ans3+2<=r&&ans3>=l){
//			printf("%lld %lld %lld",ans+1,ans-1,ans-1);
			sum3=(ans3 ^ (ans3+1))+((ans3+1) ^ (ans3+2))+(ans3 ^(ans3+2));
			break;
		}else{
			x--;
		}
	}
	if(sum3>=sum1&&sum3>=sum2){
		printf("%lld %lld %lld",ans3+1,ans3,ans3+2);
	}else if(sum2>=sum1&&sum2>=sum3){
		printf("%lld %lld %lld",ans2+1,ans2-1,ans2);
	}else{
		printf("%lld %lld %lld",ans,ans-1,ans-2);
	}
//	printf("\n%lld\n",max(max(sum1,sum2),sum3));
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--){
		solve();
		printf("\n");
	}
	return 0;
}
/*

*/
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;
typedef long long ll;
const int N=100050;
ll gcd(ll x,ll y){
	if(y==0) return x;
	else return gcd(y,x%y);
}
ll a[50]={0};
void solve(){
	ll l,r;
	stack<ll>st;
	scanf("%lld %lld",&l,&r);
	ll x=0;
	ll rr=r;
	while(rr>1){
		st.push(rr%2);
		rr/=2;
		x++;
	}
	st.push(1);
	int a1=0;
	while(!st.empty()){a[++a1]=st.top();st.pop();}
	int p=1;
	ll ans=0;
	while(x){
		if(a[p]==1){
			ans+=(1<<x);
		}
		p++;
		if(ans<=r&&ans-1>=l){
			printf("%lld %lld %lld",ans,ans,ans-1);
			break;
		}else{
			x--;
		}
	}
//	cout<<"\n"<<(ans ^ ans)+(ans ^ (ans-1))*2<<"\n";
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--){
		solve();
		printf("\n");
	}
	return 0;
}
/*

*/


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100050;
ll gcd(ll x,ll y){
	if(y==0) return x;
	else return gcd(y,x%y);
}
ll a[50]={0};
void solve(){
	ll l,r;
	stack<ll>st;
	scanf("%lld %lld",&l,&r);
	ll x=0;
	ll rr=r;
	while(rr>1){
		st.push(rr%2);
		rr/=2;
		x++;
	}
	st.push(1);
	int a1=0;
	while(!st.empty()){a[++a1]=st.top();st.pop();}
	int p=1;
	ll ans=0;
	while(x){
		if(a[p]==1){
			ans+=(1<<x);
		}
		p++;
		if(ans<=r&&ans-2>=l){
			printf("%lld %lld %lld",ans,ans-1,ans-2);
			break;
		}else{
			x--;
		}
	}
//	cout<<"\n"<<(ans ^ (ans-1))+((ans-1) ^ (ans-2))+(ans ^(ans-2))<<"\n";
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--){
		solve();
		printf("\n");
	}
	return 0;
}
/*

*/