ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


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

vector<string> s;

void func(string &a, string &b, string c, int inda, int indb) {
    if (inda == a.size() && indb == b.size()) {
        s.push_back(c); 
        return;
    }

    if (inda < a.size()) {
        func(a, b, c + a[inda], inda + 1, indb);
    }

    if (indb < b.size()) {
        func(a, b, c + b[indb], inda, indb + 1);
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >>c;

        s.clear(); 
        func(a, b, "", 0, 0);

        // for (auto ele : s) {
        //     cout << ele << endl;
        // }
        int final_ct =10000000;
        for(auto ele :s){
            int ct = 0;
            for(int i = 0 ; i < ele.size(); ++i){
                if(c[i]!=ele[i])ct++;
            } 
            final_ct = min(ct,final_ct);
        }
        cout<<final_ct<<endl;
        
        
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

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

vector<string> s;

void func(string &a, string &b, string &c, int inda, int indb) {
    if (inda == a.size() && indb == b.size()) {
        s.push_back(c); 
        return;
    }

    if (inda < a.size()) {
        string m =  c + a[inda];
        func(a, b,m, inda + 1, indb);
    }

    if (indb < b.size()) {
        string n =  c + b[indb];
        func(a, b,n, inda, indb + 1);
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >>c;

        s.clear(); 
        string m ="";
        func(a, b, m, 0, 0);

        // for (auto ele : s) {
        //     cout << ele << endl;
        // }
        int final_ct =10000000;
        for(auto ele :s){
            int ct = 0;
            for(int i = 0 ; i < ele.size(); ++i){
                if(c[i]!=ele[i])ct++;
            } 
            final_ct = min(ct,final_ct);
        }
        cout<<final_ct<<endl;
        
        
    }
    return 0;
}


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

unordered_map<string, vector<string>> memo;

vector<string> func(string &a, string &b, int inda, int indb) {
    string key = to_string(inda) + "|" + to_string(indb);
    if (memo.find(key) != memo.end()) {
        return memo[key];
    }

    if (inda == a.size() && indb == b.size()) {
        return memo[key] = {""};
    }

    vector<string> result;

    if (inda < a.size()) {
        for (string sub : func(a, b, inda + 1, indb)) {
            result.push_back(a[inda] + sub);
        }
    }

    if (indb < b.size()) {
        for (string sub : func(a, b, inda, indb + 1)) {
            result.push_back(b[indb] + sub);
        }
    }

    return memo[key] = result;
}


int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >>c;
        memo.clear();
        vector<string> s = func(a, b, 0, 0);

        // for (auto ele : s) {
        //     cout << ele << endl;
        // }
        int final_ct =10000000;
        for(auto ele :s){
            int ct = 0;
            for(int i = 0 ; i < ele.size(); ++i){
                if(c[i]!=ele[i])ct++;
            } 
            final_ct = min(ct,final_ct);
        }
        cout<<final_ct<<endl;
        
        
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>v5;
long long power(long long A, long long B)
{
    if (B == 0)
        return 1;
 
    long long res = power(A, B / 2);
 
    if (B % 2)
        return res * res * A;
    else
        return res * res;
}
bool is_prime(int n){
   if(n==1){
       return 0;
   }
   bool b = true;
   for(int i=2;i*i<=n;i++){
       if(n%i==0){
           b = false;
           break;
       }
   }
   return b;
}
 void primeFactors(ll n)
{
     while(n%2==0){
         v5.push_back(2);
          n=(n/2);
     }
       for (int i = 3; i*i <= n; i = i+2){
            while (n%i == 0){
                  v5.push_back(i);
                n = n/i;
               }
               }
         if (n > 2){
            v5.push_back(n);
         }
}
bool cmp(pair<ll,ll> &a, pair<ll,ll> &b){
     if(a.first!=b.first){
         if(a.first>b.first) return true;
          return false;
     }
     else{
           if(a.second<b.second) return true;
           return false;
     }
}
ll factorial(ll n) 
{ 
    if (n == 0) 
        return 1; 
    return n * factorial(n - 1); 
} 
void bin(ll n)
{
    for(int i=31;i>=0;i--){
         cout<<((n>>i)&1);
    }
    cout<<endl;
    
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = LONG_LONG_MIN, max_ending_here = 0;
 
    for (int i = 0; i < size; i++) {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;
 
        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}

  int f(int i,int j,int n,int m,string &a,string &b,string &c,vector<vector<int>>&dp){
               if(i==n && j==m) return 0;
               if(dp[i][j]!=-1)  return dp[i][j];
             int ans=c.size();
               if(i<n) ans=min(ans,f(i+1,j,n,m,a,b,c,dp)+(a[i]!=c[i+j]));
               if(j<m) ans=min(ans,f(i,j+1,n,m,a,b,c,dp)+(b[j]!=c[i+j]));
              
             return  dp[i][j]=ans;

  }
        
  int main(){
ios_base::sync_with_stdio(false);
int t;
cin>>t;
while(t--){
      string a,b,c;
      cin>>a>>b>>c;
      int n=a.size();
      int m=b.size();
      vector<vector<int>>dp(n,vector<int>(m,-1));
      cout<<f(0,0,n-1,m-1,a,b,c,dp)<<endl;




  }



  }
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
// Source: https://usaco.guide/general/io
 
#include <bits/stdc++.h>
#include <sys/types.h>
using namespace std;
#define MAXN 200010
#define MOD 998244353
typedef long long ll;
typedef pair<ll, ll> pi;

bool solve(ll cur, map<ll, int> &mp, ll total) {
    if (mp[cur] >= total) {
        mp[cur] -= total;
        return true;
    } else if (cur == 1) return false;
    else {
        if (cur % 2 == 1) {
            return solve(cur/2, mp, total) & solve((cur+1)/2, mp, total);
        } else return solve(cur/2, mp, total*2);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tt; cin >> tt;
    while (tt--) {
        int n, m; cin >> n >> m;
        vector<ll> b(m);
        map<ll, int> mp;
        for (int i = 0; i < n; i++) {
            ll x; cin >> x;
            mp[x]++;
        }
        for (int i = 0; i < m; i++) cin >> b[i];
        // so first we remove all odd and even numbers which exist in both a and b
        // and we notice making a number is a unique procedure
        // which it is of course
        // and we can determine the procedure in log(x_i) time ~32 for 10^9
        // thus we just do this until we cant or we can
        bool pos = true;
        for (int i = 0; i < m; i++) {
            ll x = b[i];
            pos = solve(x, mp, 1);
            if (!pos) break;
        }
        for (auto const &[k, v] : mp) {
            if (v != 0) pos = false;
        }
        if (pos) cout << "YES" << "\n";
        else cout << "NO" << "\n";
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n,k;
	cin>>n>>k;
	map<int,int> mp;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		mp[x]++;
	}
	vector<pair<int,int>> pr;// frequncy and key;
	for(auto &it: mp)
	{
		pr.push_back({it.second,it.first});
	}
  int cnt=0;
  sort(pr.begin(),pr.end());
  for(auto &p: pr)
  {
  	if(k>0)
  	{
  		if(p.first<=k)
  		{
  			cnt++;
  			k-=p.first;

  		}
  		else
  		{
  			cnt++;
  			k=0;
  			break;
  		}
  	}
  	else
  	{
  		break;
  	}
  }
  if(cnt>=pr.size()) cout<<"1\n";
  else
 cout<<pr.size()-cnt<<endl;
	}
	


}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n,k;
	cin>>n>>k;
	map<int,int> mp;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		mp[x]++;
	}
	if(n==k) cout<<"1\n";
	else
	{
		vector<pair<int,int>> pr;// frequncy and key;
	for(auto &it: mp)
	{
		pr.push_back({it.second,it.first});
	}
  int cnt=0;
  sort(pr.begin(),pr.end());
  for(auto &p: pr)
  {
  	if(k>0)
  	{
  		if(p.first<=k)
  		{
  			cnt++;
  			k-=p.first;

  		}
  		else
  		{
  			cnt++;
  			k=0;
  			break;
  		}
  	}
  	else
  	{
  		break;
  	}
  }

 cout<<pr.size()-cnt<<endl;
	}
	}
	
	


}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n,k;
	cin>>n>>k;
	map<int,int> mp;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		mp[x]++;
	}
	vector<int> ar;
	for(auto &it: mp)
	{
		ar.push_back(it.second);
	}
	int i;
	sort(ar.begin(),ar.end());
	for(i=0;i<ar.size();i++)
	{
      if(ar[i]<=k)
      {
      	k=k-ar[i];
      }
      else 
      break;
	}
	int ans=ar.size()-i;
	cout<<max(1,ans)<<endl;

	}
	
	


}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n,k;
	cin>>n>>k;
	map<int,int> mp;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		mp[x]++;
	}
	vector<pair<int,int>> pr;// frequncy and key;
	for(auto &it: mp)
	{
		pr.push_back({it.second,it.first});
	}
  int cnt=0;
  sort(pr.begin(),pr.end());
  for(auto &p: pr)
  {
  	if(k>0)
  	{
  		if(p.first<=k)
  		{
  			cnt++;
  			k-=p.first;

  		}
  		else
  		{
  			cnt++;
  			k=0;
  			break;
  		}
  	}
  	else
  	{
  		break;
  	}
  }
  if(cnt>=pr.size()) cout<<"1\n";
  else
 cout<<pr.size()-cnt<<endl;
	}
	


}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n,k;
	cin>>n>>k;
	map<int,int> mp;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		mp[x]++;
	}
	if(n==k) cout<<"1\n";
	else
	{
		vector<pair<int,int>> pr;// frequncy and key;
	for(auto &it: mp)
	{
		pr.push_back({it.second,it.first});
	}
  int cnt=0;
  sort(pr.begin(),pr.end());
  for(auto &p: pr)
  {
  	if(k>0)
  	{
  		if(p.first<=k)
  		{
  			cnt++;
  			k-=p.first;

  		}
  		else
  		{
  			cnt++;
  			k=0;
  			break;
  		}
  	}
  	else
  	{
  		break;
  	}
  }

 cout<<pr.size()-cnt<<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>
using namespace std;
void solve(){
long long l,r;
	cin>>l>>r;
	long long k=l^r;
	cout<<k<<endl;
	long long u=0;
	while(k!=0){
		k=k/2;
		u=u+1;
	}
	u=u-1;
	cout<<u<<endl;;
	long long o=(long long)pow(2,u);
	long long s=r-(r%o);
	if(l%o==o-1){
		cout<<s+1<<" "<<s<<" "<<s-1<<endl;
	}else{
		cout<<s<<" "<<s-1<<" "<<s-2<<endl;
	}
}
int main(){
	int t;
	cin>>t;
	while(t){
		solve();
		t--;
	}
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
void solve(){
long long l,r;
	cin>>l>>r;
	long long k=l^r;
	long long u=0;
	while(k!=0){
		k=k/2;
		u=u+1;
	}
	u=u-1;
	long long o=(long long)pow(2,u);
	long long s=r-(r%o);
	if(l%o==o-1){
		cout<<s+1<<" "<<s<<" "<<s-1<<endl;
	}else{
		cout<<s<<" "<<s-1<<" "<<s-2<<endl;
	}
}
int main(){
	int t;
	cin>>t;
	while(t){
		solve();
		t--;
	}
}
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;
void solve(){
long long l,r;
	cin>>l>>r;
	long long k=l^r;
	long long u=(int)(log10(k)/log10(2));
	cout<<u<<endl;
	long long o=(long long)pow(2,u);
	long long s=r-(r%o);
	if(l%o==o-1){
		cout<<s+1<<" "<<s<<" "<<s-1<<endl;
	}else{
		cout<<s<<" "<<s-1<<" "<<s-2<<endl;
	}
}
int main(){
	int t;
	cin>>t;
	while(t){
		solve();
		t--;
	}
}


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
void solve(){
long long l,r;
	cin>>l>>r;
	long long k=l^r;
	long long u=(int)(log10(k)/log10(2));
	long long o=(long long)pow(2,u);
	long long s=r-(r%o);
	if(l%o==o-1){
		cout<<s+1<<" "<<s<<" "<<s-1<<endl;
	}else{
		cout<<s<<" "<<s-1<<" "<<s-2<<endl;
	}
}
int main(){
	int t;
	cin>>t;
	while(t){
		solve();
		t--;
	}
}
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;
void solve(){
long long l,r;
	cin>>l>>r;
	long long k=l^r;
	long long u=log10(k)/log10(2);
	long long o=(long long)pow(2,u);
	long long s=r-(r%o);
	if(l%o==o-1){
		cout<<s+1<<" "<<s<<" "<<s-1<<endl;
	}else{
		cout<<s<<" "<<s-1<<" "<<s-2<<endl;
	}
}
int main(){
	int t;
	cin>>t;
	while(t){
		solve();
		t--;
	}
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
void solve(){
long long l,r;
	cin>>l>>r;
	long long k=l^r;
	long long u=(int)(log10(k)/log10(2));
	cout<<u<<endl;
	long long o=(long long)pow(2,u);
	long long s=r-(r%o);
	if(l%o==o-1){
		cout<<s+1<<" "<<s<<" "<<s-1<<endl;
	}else{
		cout<<s<<" "<<s-1<<" "<<s-2<<endl;
	}
}
int main(){
	int t;
	cin>>t;
	while(t){
		solve();
		t--;
	}
}
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;
void solve(){
long long l,r;
	cin>>l>>r;
	long long k=l^r;
	long long u=(int)(log10(k)/log10(2));
	long long o=(long long)pow(2,u);
	long long s=r-(r%o);
	if(l%o==o-1){
		cout<<s+1<<" "<<s<<" "<<s-1<<endl;
	}else{
		cout<<s<<" "<<s-1<<" "<<s-2<<endl;
	}
}
int main(){
	int t;
	cin>>t;
	while(t){
		solve();
		t--;
	}
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
void solve(){
long long l,r;
	cin>>l>>r;
	long long k=l^r;
	cout<<k<<endl;
	long long u=0;
	while(k!=0){
		k=k/2;
		u=u+1;
	}
	u=u-1;
	cout<<u<<endl;;
	long long o=(long long)pow(2,u);
	long long s=r-(r%o);
	if(l%o==o-1){
		cout<<s+1<<" "<<s<<" "<<s-1<<endl;
	}else{
		cout<<s<<" "<<s-1<<" "<<s-2<<endl;
	}
}
int main(){
	int t;
	cin>>t;
	while(t){
		solve();
		t--;
	}
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
void solve(){
long long l,r;
	cin>>l>>r;
	long long k=l^r;
	long long u=log10(k)/log10(2);
	long long o=(long long)pow(2,u);
	long long s=r-(r%o);
	if(l%o==o-1){
		cout<<s+1<<" "<<s<<" "<<s-1<<endl;
	}else{
		cout<<s<<" "<<s-1<<" "<<s-2<<endl;
	}
}
int main(){
	int t;
	cin>>t;
	while(t){
		solve();
		t--;
	}
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pb push_back
#define vll vector<ll>
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define vpll vector<pair<ll,ll>>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define f(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define map_ map<ll,ll>
#define shit ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define MOD 1000000007
vll prime(200001,1);
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b); }
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i;return res;}
ll ncr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
ll no_of_dig(ll n){ string s = to_string(n); return s.size(); }
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll powerLL(ll x, ll n){ll result = 1;while (n) {if (n & 1)result = result * x % MOD;n = n / 2;x = x * x % MOD;}return result;}
bool isPrime(ll n){if (n <= 1)return false;for (ll i = 2; i <= sqrt(n); i++)if (n % i == 0)return false;return true;}
void solve(){    
    ll n; cin >> n;
    ll Count_2 = 0, Count_3 = 0;
    if (n%9 == 0) {
        cout<<"YES"<<endl;
        return;
    }
    ll number = n;
    while (number > 0) {
        int digit = number % 10;
        if (digit == 2) {
            Count_2++;
        } else if (digit == 3) {
            Count_3++;
        }
        number /= 10;
    }
    Count_2 = min (Count_2,(ll) 8);
    Count_3 = min (Count_3,(ll) 2);
    ll temp = 0;
    f(i, Count_2+1) {
        f(j, Count_3+1) {
            temp = i*2 + j*6;
            if ((n + temp) % 9 == 0) {
                cout<<"YES"<<endl;
                return;
            }
        }
    }
    cout<<"NO"<<endl;
    
} 

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


Submission (verdict: Time limit exceeded on test 1):
#include <iostream>
#include <bitset>

using namespace std;

// Function to count the number of ones in the binary representation
int countOnes(int n) {
    return bitset<32>(n).count(); // Using bitset to count '1's
}

// Function to find the number with maximum ones and zeros in range [l, r]
void findMaxOnesAndZeros(int l, int r) {
    int maxOnes = -1;
    int numberWithMaxOnes = l;
    int maxZeros = -1;
    int numberWithMaxZeros = l;

    // Check powers of two and their combinations
    for (int power = 1; power <= r; power *= 2) {
        if (power >= l) {
            int onesCount = countOnes(power);
            if (onesCount > maxOnes || (onesCount == maxOnes && power < numberWithMaxOnes)) {
                maxOnes = onesCount;
                numberWithMaxOnes = power;
            }
        }

        // Check numbers formed by consecutive ones followed by zeros
        for (int i = 1; i <= 31; ++i) { // Up to 31 bits for numbers <= 10^9
            int candidate = (1 << i) - 1; // This gives us a number with i consecutive ones
            if (candidate <= r && candidate >= l) {
                int onesCount = countOnes(candidate);
                if (onesCount > maxOnes || (onesCount == maxOnes && candidate < numberWithMaxOnes)) {
                    maxOnes = onesCount;
                    numberWithMaxOnes = candidate;
                }
            }
        }
    }

    // Check for zeros in the range [l, r]
    for (int num = l; num <= r; ++num) {
        int zerosCount = 32 - countOnes(num); // Total bits (32) - number of '1's
        if (zerosCount > maxZeros || (zerosCount == maxZeros && num < numberWithMaxZeros)) {
            maxZeros = zerosCount;
            numberWithMaxZeros = num;
        }
    }
    // cout<<(numberWithMaxZeros^numberWithMaxOnes)+(numberWithMaxOnes^l)+(numberWithMaxZeros^l)<<endl;
    cout<<numberWithMaxZeros<<" "<<numberWithMaxOnes<<" "<<l<<endl;
}

int main() {
    int t; cin>>t;
    while(t--){
        int l,r; cin>>l>>r;
        findMaxOnesAndZeros(l, r);
    }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 1):
#include <iostream>
#include <bitset>

using namespace std;

// Function to count the number of ones in the binary representation
int countOnes(int n) {
    return bitset<32>(n).count(); // Using bitset to count '1's
}

// Function to find the number with maximum ones and zeros in range [l, r]
void findMaxOnesAndZeros(int l, int r) {
    int maxOnes = -1;
    int numberWithMaxOnes = l;
    int maxZeros = -1;
    int numberWithMaxZeros = l;

    // Check powers of two and their combinations
    for (int power = 1; power <= r; power *= 2) {
        if (power >= l) {
            int onesCount = countOnes(power);
            if (onesCount > maxOnes || (onesCount == maxOnes && power < numberWithMaxOnes)) {
                maxOnes = onesCount;
                numberWithMaxOnes = power;
            }
        }

        // Check numbers formed by consecutive ones followed by zeros
        for (int i = 1; i <= 31; ++i) { // Up to 31 bits for numbers <= 10^9
            int candidate = (1 << i) - 1; // This gives us a number with i consecutive ones
            if (candidate <= r && candidate >= l) {
                int onesCount = countOnes(candidate);
                if (onesCount > maxOnes || (onesCount == maxOnes && candidate < numberWithMaxOnes)) {
                    maxOnes = onesCount;
                    numberWithMaxOnes = candidate;
                }
            }
        }
    }

    // Check for zeros in the range [l, r]
    for (int num = l; num <= r; ++num) {
        int zerosCount = 32 - countOnes(num); // Total bits (32) - number of '1's
        if (zerosCount > maxZeros || (zerosCount == maxZeros && num < numberWithMaxZeros)) {
            maxZeros = zerosCount;
            numberWithMaxZeros = num;
        }
    }
    // cout<<(numberWithMaxZeros^numberWithMaxOnes)+(numberWithMaxOnes^l)+(numberWithMaxZeros^l)<<endl;
    cout<<numberWithMaxZeros<<" "<<numberWithMaxOnes<<" "<<l<<endl;
}

int main() {
    int t; cin>>t;
    while(t--){
        int l,r; cin>>l>>r;
        findMaxOnesAndZeros(l, r);
    }

    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
typedef vector<long long int> vi;
#define ll long long
#define mp make_pair
#define yes cout << "YES" << "\n"
#define no cout << "NO" << "\n"

string decimalToBinary(ll decimal_number){
    bitset<64> binary(decimal_number);
    return binary.to_string();
}

ll binaryToDecimal(string &binary_string){
    bitset<64> binary(binary_string);
    return binary.to_ullong();
}

void solve() {
    ll l,r;
    cin>>l>>r;
    string a,b;
    a = decimalToBinary(l);
    b = decimalToBinary(r);
    ll x,y,z;
    for(ll i=0; i<a.size(); i++){
        if(a[i]!=b[i]) {
            x=i;
        }
    }
    for(ll i=x+1; i<a.size(); i++) b[i]='0';
    x = binaryToDecimal(b);
    y = x-1;
    z = l;
    cout<<x<<" "<<y<<" "<<z<<endl;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    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<bits/stdc++.h>
using namespace std;
typedef vector<long long int> vi;
#define ll long long
#define mp make_pair
#define yes cout << "YES" << "\n"
#define no cout << "NO" << "\n"

string decimalToBinary(ll decimal_number){
    bitset<64> binary(decimal_number);
    return binary.to_string();
}

ll binaryToDecimal(string &binary_string){
    bitset<64> binary(binary_string);
    return binary.to_ullong();
}

void solve() {
    ll l,r;
    cin>>l>>r;
    string a,b;
    a = decimalToBinary(l);
    b = decimalToBinary(r);
    ll x,y,z;
    for(ll i=0; i<a.size(); i++){
        if(a[i]!=b[i]) {
            x=i;
        }
    }
    for(ll i=x+1; i<a.size(); i++) b[i]='0';
    x = binaryToDecimal(b);
    y = x-1;
    z = l;
    cout<<x<<" "<<y<<" "<<z<<endl;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    cin>>t;
    while(t--) solve();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
typedef vector<long long int> vi;
#define ll long long
#define mp make_pair
#define yes cout << "YES" << "\n"
#define no cout << "NO" << "\n"

string decimalToBinary(ll decimal_number){
    bitset<64> binary(decimal_number);
    return binary.to_string();
}

ll binaryToDecimal(string &binary_string){
    bitset<64> binary(binary_string);
    return binary.to_ullong();
}

void solve() {
    ll l,r;
    cin>>l>>r;
    string a,b;
    a = decimalToBinary(l);
    b = decimalToBinary(r);
    ll x,y,z;
    for(ll i=0; i<a.size(); i++){
        if(a[i]!=b[i]) {
            x=i;
        }
    }
    for(ll i=x+1; i<a.size(); i++) b[i]='0';
    x = binaryToDecimal(b);
    y = x-1;
    z = x-2;
    if(z<l) z= x+1;
    cout<<x<<" "<<y<<" "<<z<<endl;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    cin>>t;
    while(t--) solve();
    return 0;
}