ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: Java 8

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

public class Cirno {
    static Scanner sc = new Scanner(System.in);

    static BigInteger bsum = BigInteger.valueOf(Integer.MIN_VALUE);

    static void diffFinder(BigInteger arr[]) {
        BigInteger sum = BigInteger.ZERO;

        for (int i = 0; i < arr.length; i++) {
            sum = sum.add(arr[i]);
        }
        sum = sum.abs();
        if (sum.compareTo(bsum) > 0) {
            bsum = sum;
        }

        if (arr.length <= 1)
            return;
        else {
            BigInteger sys[] = new BigInteger[arr.length - 1];

            for (int i = 0; i < arr.length - 1; i++) {
                sys[i] = arr[i + 1].subtract(arr[i]);
            }

            diffFinder(sys);
        }
    }

    public static void main(String[] args) {
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            BigInteger arr[] = new BigInteger[n];
            for (int i = 0; i < n; i++) {
                arr[i] = BigInteger.valueOf(sc.nextInt());
            }
            if (n == 1) {
                System.out.println(arr[0]);
            } else {
                diffFinder(arr);
                System.out.println(bsum);
                bsum = BigInteger.valueOf(Integer.MIN_VALUE);
            }
        }
    }
}


Submission (verdict: Time limit exceeded on test 2):
import java.math.BigInteger;
import java.util.*;

public class Cirno {
    static Scanner sc = new Scanner(System.in);

    static BigInteger bsum = BigInteger.valueOf(Integer.MIN_VALUE);

    static void diffFinder(BigInteger arr[]) {
        BigInteger sum = BigInteger.ZERO;

        for (int i = 0; i < arr.length; i++) {
            sum = sum.add(arr[i]);
        }
        //sum = sum.abs();
        if (sum.compareTo(bsum) > 0) {
            bsum = sum;
        }

        if (arr.length <= 1)
            return;
        else {
            BigInteger sys[] = new BigInteger[arr.length - 1];
            BigInteger revsys[] = new BigInteger[arr.length - 1];

            for (int i = 0; i < arr.length - 1; i++) {
                sys[i] = arr[i + 1].subtract(arr[i]);
            }

            for (int i = 0, j=arr.length-1; i < arr.length - 1 && j>0; i++, j--) {
                revsys[i] = arr[j - 1].subtract(arr[j]);
            }

            diffFinder(sys);
            diffFinder(revsys);
        }
    }

    public static void main(String[] args) {
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            BigInteger arr[] = new BigInteger[n];
            for (int i = 0; i < n; i++) {
                arr[i] = BigInteger.valueOf(sc.nextInt());
            }
            if (n == 1) {
                System.out.println(arr[0]);
            } else {
                diffFinder(arr);
                System.out.println(bsum);
                bsum = BigInteger.valueOf(Integer.MIN_VALUE);
            }
        }
    }
}
Problem: 2062C - Cirno and Operations
Language: Java 8

Previous submission (verdict: Time limit exceeded on test 2):
import java.math.BigInteger;
import java.util.*;

public class Cirno {
    static Scanner sc = new Scanner(System.in);

    static BigInteger bsum = BigInteger.valueOf(Integer.MIN_VALUE);

    static void diffFinder(BigInteger arr[]) {
        BigInteger sum = BigInteger.ZERO;

        for (int i = 0; i < arr.length; i++) {
            sum = sum.add(arr[i]);
        }
        //sum = sum.abs();
        if (sum.compareTo(bsum) > 0) {
            bsum = sum;
        }

        if (arr.length <= 1)
            return;
        else {
            BigInteger sys[] = new BigInteger[arr.length - 1];
            BigInteger revsys[] = new BigInteger[arr.length - 1];

            for (int i = 0; i < arr.length - 1; i++) {
                sys[i] = arr[i + 1].subtract(arr[i]);
            }

            for (int i = 0, j=arr.length-1; i < arr.length - 1 && j>0; i++, j--) {
                revsys[i] = arr[j - 1].subtract(arr[j]);
            }

            diffFinder(sys);
            diffFinder(revsys);
        }
    }

    public static void main(String[] args) {
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            BigInteger arr[] = new BigInteger[n];
            for (int i = 0; i < n; i++) {
                arr[i] = BigInteger.valueOf(sc.nextInt());
            }
            if (n == 1) {
                System.out.println(arr[0]);
            } else {
                diffFinder(arr);
                System.out.println(bsum);
                bsum = BigInteger.valueOf(Integer.MIN_VALUE);
            }
        }
    }
}


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

public class Cirno {
    static Scanner sc = new Scanner(System.in);

    static BigInteger bsum = BigInteger.valueOf(Integer.MIN_VALUE);
    static boolean c = true;

    static void diffFinder(BigInteger arr[]) {
        BigInteger sum = BigInteger.ZERO;

        for (int i = 0; i < arr.length; i++) {
            sum = sum.add(arr[i]);
        }
        if (c)
            c = false;
        else
            sum = sum.abs();
        if (sum.compareTo(bsum) > 0) {
            bsum = sum;
        }

        if (arr.length <= 1)
            return;
        else {
            BigInteger sys[] = new BigInteger[arr.length - 1];

            for (int i = 0; i < arr.length - 1; i++) {
                sys[i] = arr[i + 1].subtract(arr[i]);
            }

            diffFinder(sys);
        }
    }

    public static void main(String[] args) {
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            BigInteger arr[] = new BigInteger[n];
            for (int i = 0; i < n; i++) {
                arr[i] = BigInteger.valueOf(sc.nextInt());
            }
            if (n == 1) {
                System.out.println(arr[0]);
            } else {
                diffFinder(arr);
                System.out.println(bsum);
                c = true;
                bsum = BigInteger.valueOf(Integer.MIN_VALUE);
            }
        }
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<iomanip>
#include<cstring>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<climits>
#include<array>
#include<queue>
#include<bitset>

#define int long long
#define cd(n,d) std::cout<<std::fixed<<std::setprecision((n))<<(d) 
#define ms(a,b) std::memset((a),(b),sizeof(a))
#define mc(a,b) std::memcpy((a),(b),sizeof(b))
#define all(v) (v).begin(),(v).end()
#define fill(v,x) std::fill((v).begin(),(v).end(),(x))
#define iota(v,x) std::iota((v).begin(),(v).end(),(x))
#define cln std::cout<<"\n"
#define eb emplace_back
#define pb pop_back
#define ef emplace_front
#define pf pop_front 
#define FOR(i,x,y) for(int i=(x);i<=(y);i++)
#define FOR0(i,x,y) for(int i=(x);i<(y);i++)
#define _FOR(i,x,y) for(int i=(x);i>=(y);i--)
#define _FOR0(i,x,y) for(int i=(x);i>(y);i--)
#define F first
#define S second

void solve(){
	int l,r;
	std::cin>>l>>r;
	int a=l,b=r,c=0;
	int o=std::log2(r);
	bool flag=true;
	int t=0;
	_FOR(i,o,0){
		int x=l>>i&1,y=r>>i&1;
		if(x==y){
			if(flag){
				b|=x<<i;
			}else{
				b|=(x^1)<<i;
			}
		}else{
			if(flag){
				_FOR(j,i,0){
					if((l>>j&1)==(r>>j&1)){
						t=l>>j&1;
						break;
					}
					b|=t<<i;
					flag=0;
				}
			}else{
				b|=(t^1)<<i;
			}
		}
	}
	std::cout<<a<<" "<<b<<" "<<c<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int T=1;
	std::cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define ll long long
unordered_set<ll>sett;
int main()
{
    ll t;
    cin>>t;
    for(ll k1=1;k1<=t;k1++)
    {
        ll i,j,k,cnt1=0,cnt2=0,l,r;
        cin>>l>>r;
        ll base=r;
        while(base>0) base/=2,cnt1++;
        for(i=cnt1;i>=1;i--)
        {
            base=pow(2,i-1);
            ll x=r/base;
            x*=base;
            if(x>=l)
            {
                cout<<x<<" "<<x-1<<" ";
                if(pow(2,i-1)!=r) cout<<r<<endl;
                else cout<<l<<endl;
                break;
            }
        }
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define ll long long
unordered_set<ll>sett;
int main()
{
    ll t;
    cin>>t;
    for(ll k1=1;k1<=t;k1++)
    {
        ll i,j,k,cnt1=0,cnt2=0,l,r;
        cin>>l>>r;
        ll base=r;
        while(base>0) base/=2,cnt1++;
        for(i=cnt1;i>=1;i--)
        {
            base=pow(2,i-1);
            ll x=r/base;
            x*=base;
            if(x>=l)
            {
                cout<<x<<" "<<x-1<<" ";
                if(pow(2,i-1)!=r) cout<<r<<endl;
                else cout<<l<<endl;
                break;
            }
        }
    }
}

Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define ll long long
unordered_set<ll>sett;
int main()
{
    ll t;
    cin>>t;
    for(ll k1=1;k1<=t;k1++)
    {
        ll i,j,k,cnt1=0,cnt2=0,l,r;
        cin>>l>>r;
        ll base=r;
        while(base>0) base/=2,cnt1++;
        for(i=cnt1;i>=1;i--)
        {
            base=pow(2,i-1);
            ll x=r/base;
            x*=base;
            if(x>l)
            {
                if(x!=r) cout<<x<<" "<<x-1<<" "<<x+1<<endl;
                else cout<<x<<" "<<x-1<<" "<<x-2<<endl;
                break;
            }
        }
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<iomanip>
#include<cstring>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<climits>
#include<array>
#include<queue>
#include<bitset>

#define int long long
#define cd(n,d) std::cout<<std::fixed<<std::setprecision((n))<<(d) 
#define ms(a,b) std::memset((a),(b),sizeof(a))
#define mc(a,b) std::memcpy((a),(b),sizeof(b))
#define all(v) (v).begin(),(v).end()
#define fill(v,x) std::fill((v).begin(),(v).end(),(x))
#define iota(v,x) std::iota((v).begin(),(v).end(),(x))
#define cln std::cout<<"\n"
#define eb emplace_back
#define pb pop_back
#define ef emplace_front
#define pf pop_front 
#define FOR(i,x,y) for(int i=(x);i<=(y);i++)
#define FOR0(i,x,y) for(int i=(x);i<(y);i++)
#define _FOR(i,x,y) for(int i=(x);i>=(y);i--)
#define _FOR0(i,x,y) for(int i=(x);i>(y);i--)
#define F first
#define S second

void solve(){
	int l,r;
	std::cin>>l>>r;
	int a=l,b=r,c=0;
	int o=std::log2(r);
	bool flag=true;
	int t=0;
	_FOR(i,o,0){
		int x=l>>i&1,y=r>>i&1;
		if(x==y){
			if(flag){
				b|=x<<i;
			}else{
				b|=(x^1)<<i;
			}
		}else{
			if(flag){
				_FOR(j,i,0){
					if((l>>j&1)==(r>>j&1)){
						t=l>>j&1;
						break;
					}
					b|=t<<i;
					flag=0;
				}
			}else{
				b|=(t^1)<<i;
			}
		}
	}
	std::cout<<a<<" "<<b<<" "<<c<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int T=1;
	std::cin>>T;
	while(T--){
		solve();
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define ll long long
unordered_set<ll>sett;
int main()
{
    ll t;
    cin>>t;
    for(ll k1=1;k1<=t;k1++)
    {
        ll i,j,k,cnt1=0,cnt2=0,l,r;
        cin>>l>>r;
        ll base=r;
        while(base>0) base/=2,cnt1++;
        for(i=cnt1;i>=1;i--)
        {
            base=pow(2,i-1);
            ll x=r/base;
            x*=base;
            if(x>l)
            {
                if(x!=r) cout<<x<<" "<<x-1<<" "<<x+1<<endl;
                else cout<<x<<" "<<x-1<<" "<<x-2<<endl;
                break;
            }
        }
    }
}

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

#define int long long
#define debug(x) std::cerr<<"The "<<#x<<" = "<<x<<'\n';

using i128 = __int128;
using i64 = long long;
using u64 = unsigned long long;

constexpr int N = 1e6 + 5;
constexpr int mod = 998244353;
constexpr i64 INF = 0x7fffffffffffffffLL;

void solve() {
    int l, r;
    std::cin >> l >> r;
    int now = 0;
    for (int i = 30; i >= 0; i--) {
        if ((l >> i & 1) != (r >> i & 1)) {
            int x = (1LL << i) - 1, y = 0;
            x += now, y += now + (1LL << i);
            std::cout << x << " " << y << " " << ((x != l && y != l) ? l : r) << '\n';
            return ;
        }
        now += ((l >> i & 1) ? (1LL << i) : 0);
    }
}

signed main() {
    std::ios::sync_with_stdio(false),
    std::cin.tie(0),
    std::cout.tie(0);
    int T = 1;
    std::cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

using namespace std;



typedef long long ll;

typedef vector<ll> vi;

typedef vector<vi> vvi;

typedef vector<char> vc;

typedef vector<vc> vvc;

typedef vector<pair<ll,ll>> vii;

typedef pair<ll,ll> ii;



#define M 1000000007

#define pb push_back

const ll N = 1e5;



#define f(i, a, b) for (ll i = a; i < b; i++)

#define lb(a,b) lower_bound(a.begin(),a.end(),b)

#define ub(a,b) upper_bound(a.begin(),a.end(),b)



// Binary Exponentiation Function

ll be(ll a, ll b, ll m) {

    ll ans = 1;

    while (b > 0) {

        if (b & 1) {

            ans = (ans * 1LL * a) % m;

        }

        a = (a * 1LL * a) % m;

        b >>= 1;

    }

    return ans;

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll t;

    cin >> t;

    f(i, 0, t) {

        // Put all effort in your logic

        ll n;

        cin>>n;

        vi ans;

        while(n>0){

            ll rem=n%10;

            ans.pb(rem);

            n=n/10;

        }

        reverse(ans.begin(),ans.end());

        ll s=0;

        ll to=0,th=0;

        f(i,0,ans.size()){

           s+=ans[i];

           if(ans[i]==2) to++;

           else if(ans[i]==3) th++;

        }

        bool cond=true;

        for(ll i=0;i<=min((ll)10,to);i++){

            for(ll j=0;j<=min(th,ll(10));j++){

                if((s+(i*2)+(j*6))%9==0){

                    cond=false;

                    break;

                }

            }

        }

        if(!cond) cout<<"YES"<<endl;

        else{

            cout<<"NO"<<endl;

        }

    }

}

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

using namespace std;



typedef long long ll;

typedef vector<ll> vi;

typedef vector<vi> vvi;

typedef vector<char> vc;

typedef vector<vc> vvc;

typedef vector<pair<ll,ll>> vii;

typedef pair<ll,ll> ii;



#define M 1000000007

#define pb push_back

const ll N = 1e5;



#define f(i, a, b) for (ll i = a; i < b; i++)

#define lb(a,b) lower_bound(a.begin(),a.end(),b)

#define ub(a,b) upper_bound(a.begin(),a.end(),b)



// Binary Exponentiation Function

ll be(ll a, ll b, ll m) {

    ll ans = 1;

    while (b > 0) {

        if (b & 1) {

            ans = (ans * 1LL * a) % m;

        }

        a = (a * 1LL * a) % m;

        b >>= 1;

    }

    return ans;

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll t;

    cin >> t;

    f(i, 0, t) {

        // Put all effort in your logic

      string sp;

      cin>>sp;

      ll s=0;

      ll to=0,th=0;

      for(char ch:sp){

        ll num=ch-'0';

        s+=num;

        if(num==2) to++;

        if(num==3) th++; 

      }

        bool cond=true;

        for(ll i=0;i<=to;i++){

            for(ll j=0;j<=th;j++){

                if((s+(i*2)+(j*6))%9==0){

                    cond=false;

                    break;

                }

            }

        }

        if(!cond) cout<<"YES"<<endl;

        else{

            cout<<"NO"<<endl;

        }

    }

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


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

using namespace std;



typedef long long ll;

typedef vector<ll> vi;

typedef vector<vi> vvi;

typedef vector<char> vc;

typedef vector<vc> vvc;

typedef vector<pair<ll,ll>> vii;

typedef pair<ll,ll> ii;



#define M 1000000007

#define pb push_back

const ll N = 1e5;



#define f(i, a, b) for (ll i = a; i < b; i++)

#define lb(a,b) lower_bound(a.begin(),a.end(),b)

#define ub(a,b) upper_bound(a.begin(),a.end(),b)



// Binary Exponentiation Function

ll be(ll a, ll b, ll m) {

    ll ans = 1;

    while (b > 0) {

        if (b & 1) {

            ans = (ans * 1LL * a) % m;

        }

        a = (a * 1LL * a) % m;

        b >>= 1;

    }

    return ans;

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll t;

    cin >> t;

    f(i, 0, t) {

        // Put all effort in your logic

        ll n;

        cin>>n;

        vi ans;

        while(n>0){

            ll rem=n%10;

            ans.pb(rem);

            n=n/10;

        }

        reverse(ans.begin(),ans.end());

        ll s=0;

        ll to=0,th=0;

        f(i,0,ans.size()){

           s+=ans[i];

           if(ans[i]==2) to++;

           else if(ans[i]==3) th++;

        }

        bool cond=true;

        for(ll i=0;i<=to;i++){

            for(ll j=0;j<=th;j++){

                if((s+(i*2)+(j*6))%9==0){

                    cond=false;

                    break;

                }

            }

        }

        if(!cond) cout<<"YES"<<endl;

        else{

            cout<<"NO"<<endl;

        }

    }

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

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

using namespace std;



typedef long long ll;

typedef vector<ll> vi;

typedef vector<vi> vvi;

typedef vector<char> vc;

typedef vector<vc> vvc;

typedef vector<pair<ll,ll>> vii;

typedef pair<ll,ll> ii;



#define M 1000000007

#define pb push_back

const ll N = 1e5;



#define f(i, a, b) for (ll i = a; i < b; i++)

#define lb(a,b) lower_bound(a.begin(),a.end(),b)

#define ub(a,b) upper_bound(a.begin(),a.end(),b)



// Binary Exponentiation Function

ll be(ll a, ll b, ll m) {

    ll ans = 1;

    while (b > 0) {

        if (b & 1) {

            ans = (ans * 1LL * a) % m;

        }

        a = (a * 1LL * a) % m;

        b >>= 1;

    }

    return ans;

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll t;

    cin >> t;

    f(i, 0, t) {

        // Put all effort in your logic

      string sp;

      cin>>sp;

      ll s=0;

      ll to=0,th=0;

      for(char ch:sp){

        ll num=ch-'0';

        s+=num;

        if(num==2) to++;

        if(num==3) th++; 

      }

        bool cond=true;

        for(ll i=0;i<=to;i++){

            for(ll j=0;j<=th;j++){

                if((s+(i*2)+(j*6))%9==0){

                    cond=false;

                    break;

                }

            }

        }

        if(!cond) cout<<"YES"<<endl;

        else{

            cout<<"NO"<<endl;

        }

    }

}

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

using namespace std;



typedef long long ll;

typedef vector<ll> vi;

typedef vector<vi> vvi;

typedef vector<char> vc;

typedef vector<vc> vvc;

typedef vector<pair<ll,ll>> vii;

typedef pair<ll,ll> ii;



#define M 1000000007

#define pb push_back

const ll N = 1e5;



#define f(i, a, b) for (ll i = a; i < b; i++)

#define lb(a,b) lower_bound(a.begin(),a.end(),b)

#define ub(a,b) upper_bound(a.begin(),a.end(),b)



// Binary Exponentiation Function

ll be(ll a, ll b, ll m) {

    ll ans = 1;

    while (b > 0) {

        if (b & 1) {

            ans = (ans * 1LL * a) % m;

        }

        a = (a * 1LL * a) % m;

        b >>= 1;

    }

    return ans;

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll t;

    cin >> t;

    f(i, 0, t) {

        // Put all effort in your logic

      string sp;

      cin>>sp;

      ll s=0;

      ll to=0,th=0;

      for(char ch:sp){

        ll num=ch-'0';

        s+=num;

        if(num==2) to++;

        if(num==3) th++; 

      }

        bool cond=true;

        for(ll i=0;i<=min(to,(ll)10);i++){

            for(ll j=0;j<=min(th,(ll)10);j++){

                if((s+(i*2)+(j*6))%9==0){

                    cond=false;

                    break;

                }

            }

        }

        if(!cond) cout<<"YES"<<endl;

        else{

            cout<<"NO"<<endl;

        }

    }

}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int t;
int l, r;

void solve() {
    cin >> l >> r;
    int x = r;

    int k = 0;
    for (int i = 0; i <= 30; i++) {
        if (x & (1 << i)) {
            k = i;
        }
    }
    int y = 0;
    for (int i = 0; i <= k; i++) {
        if ((x & (1 << i)) == 0) {
            y |= (1 << i);
        }
    }

    // if (y < l)
    y |= l;

    if (y + 1 >= r) {
        cout << x << " " << y << " " << y - 1 << "\n";
    } else {
        cout << x << " " << y << " " << y + 1 << "\n";
    }
}

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


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int t;
int l, r;

void solve() {
    cin >> l >> r;
    // int x = r;

    int k = 0;
    for (int i = 0; i <= 30; i++) {
        if (r & (1 << i)) {
            k = i;
        }
    }
    int base = 0;
    int start = -1;
    for (int i = k; i >= 0; i--) {
        if ((r & (1 << i)) != 0 && (l & (1 <<i)) != 0) {
            base |= (1 << i);
        } else if (r & (1 << i)) {
            start = i;
            break;
        }
    }

    int x = base + (1 << start);
    int y = base + (1 << start) - 1;
    int z = 0;
    if (x + 1 > r) {
        z = y - 1;
    } else {
        z = x + 1;
    }

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

}

int main() {
    cin >> t;
    while (t--) solve();
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int t;
int l, r;

void solve() {
    cin >> l >> r;
    int x = r;

    int k = 0;
    for (int i = 0; i <= 30; i++) {
        if (x & (1 << i)) {
            k = i;
        }
    }
    int y = 0;
    for (int i = 0; i <= k; i++) {
        if ((x & (1 << i)) == 0) {
            y |= (1 << i);
        }
    }

    if (y < l)
        y |= l;

    if (y + 1 >= r) {
        cout << x << " " << y << " " << y - 1 << "\n";
    } else {
        cout << x << " " << y << " " << y + 1 << "\n";
    }
}

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