ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 1):

t = int(input())

for x in range(t):
    n = int(input())
    edges = []
    adj_list = []

    for y in range(n+1):
        adj_list.append([])

    for e in range(n-1):
        a,b = list(map(int, input().split(" ")))
        
        adj_list[a].append(b)
        adj_list[b].append(a)


    for i in range(2):
        most_edges = 0
        most_edges_node = 1
        for node in range(1, n+1):
            if adj_list[node] != None:
                if len(adj_list[node]) >= most_edges:
                    most_edges = len(adj_list[node])
                    most_edges_node = node

        for node in adj_list[most_edges_node]:
            adj_list[node].remove(most_edges_node)

        adj_list[most_edges_node] = None

    count_cc = 0
    connected = {}
    v = 1
    for node in range(1, n+1):
        print(node, adj_list[node])
        if adj_list[node] != None and not node in connected:
            queue = [node]

            while len(queue) > 0:
                curr = queue.pop()
                connected[curr] = count_cc
                for adj_node in adj_list[curr]:
                    if not adj_node in connected:
                        queue.append(adj_node)
                        connected[adj_node] = count_cc

            count_cc += 1

    print(count_cc)


Submission (verdict: Wrong answer on test 4):

t = int(input())

for x in range(t):
    n = int(input())
    edges = []
    adj_list = []

    for y in range(n+1):
        adj_list.append([])

    for e in range(n-1):
        a,b = list(map(int, input().split(" ")))
        
        adj_list[a].append(b)
        adj_list[b].append(a)


    for i in range(2):
        most_edges = 0
        most_edges_node = 1
        for node in range(1, n+1):
            if adj_list[node] != None:
                if len(adj_list[node]) >= most_edges:
                    most_edges = len(adj_list[node])
                    most_edges_node = node

        for node in adj_list[most_edges_node]:
            adj_list[node].remove(most_edges_node)

        adj_list[most_edges_node] = None

    count_cc = 0
    connected = {}
    v = 1
    for node in range(1, n+1):
        if adj_list[node] != None and not node in connected:
            queue = [node]

            while len(queue) > 0:
                curr = queue.pop()
                connected[curr] = count_cc
                for adj_node in adj_list[curr]:
                    if not adj_node in connected:
                        queue.append(adj_node)
                        connected[adj_node] = count_cc

            count_cc += 1

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

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
using namespace std;

long long int pow(int r,int n){
  long long int ans=1;
  while(n>0){
    ans*=r;
    n--;
  }
  return ans;
}

int main() {
  int t;
  cin>>t;
  for(int i=0;i<t;i++){
    long long int l,r;
    cin>>l>>r;
    int b=r,count=0,sum=0;
    while(b>0){
      b=b/2;
      count++;
    }
    count--;
    while(count>0){
      if(l == pow(2,count) - 1){
        cout<<l<<" "<<l+1<<" "<<l+2<<endl;
        break;
      }
      else if(r-l==2){
        cout<<r<<" "<<r-1<<" "<<l<<endl;
        break;
      }
      else if(pow(2,count) - 2 >= l && pow(2,count) <= r){
        cout<<pow(2,count) + sum<<" "<<pow(2,count) - 1 + sum<<" "<<pow(2,count) - 2 + sum<<endl;
        break;
      }
      else if(pow(2,count) - 2 >= l && pow(2,count) > r){
        count--;
      }
      else{
        l-=pow(2,count);
        r-=pow(2,count);
        sum+=pow(2,count);
        count--;
      }
    }
  }
}


Submission (verdict: Accepted):
#include <iostream>
using namespace std;

long long int pow(int r,int n){
  long long int ans=1;
  while(n>0){
    ans*=r;
    n--;
  }
  return ans;
}

int main() {
  int t;
  cin>>t;
  for(int i=0;i<t;i++){
    long long int l,r;
    cin>>l>>r;
    int b=r,count=0,sum=0;
    while(b>0){
      b=b/2;
      count++;
    }
    count--;
    while(count>0){
      long long int f=pow(2,count);
      if(l == f - 1){
        cout<<l + sum<<" "<<l + 1 + sum<<" "<<l + 2 + sum<<endl;
        break;
      }
      else if(r-l==2){
        cout<<r + sum<<" "<<r - 1 + sum<<" "<<l + sum<<endl;
        break;
      }
      else if(f - 2 >= l && f <= r){
        cout<<f + sum<<" "<<f - 1 + sum<<" "<<f - 2 + sum<<endl;
        break;
      }
      else if(f - 2 >= l && f > r){
        count--;
      }
      else{
        l-=f;
        r-=f;
        sum+=f;
        count--;
      }
    }
  }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
using namespace std;

long long int pow(int r,int n){
  long long int ans=1;
  while(n>0){
    ans*=r;
    n--;
  }
  return ans;
}

int main() {
  int t;
  cin>>t;
  for(int i=0;i<t;i++){
    long long int l,r;
    cin>>l>>r;
    int b=r,count=0,sum=0;
    while(b>0){
      b=b/2;
      count++;
    }
    count--;
    while(1){
      if(pow(2,count) - 2 >= l){
        cout<<pow(2,count) + sum<<" "<<pow(2,count) - 1 + sum<<" "<<pow(2,count) - 2 + sum<<endl;
        break;
      }
      else{
        l-=pow(2,count);
        r-=pow(2,count);
        sum+=pow(2,count);
        count--;
      }
    }
  }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
using namespace std;

long long int pow(int r,int n){
  long long int ans=1;
  while(n>0){
    ans*=r;
    n--;
  }
  return ans;
}

int main() {
  int t;
  cin>>t;
  for(int i=0;i<t;i++){
    long long int l,r;
    cin>>l>>r;
    int b=r,count=0,sum=0;
    while(b>0){
      b=b/2;
      count++;
    }
    count--;
    while(count>0){
      if(r-l==2){
        cout<<r<<" "<<r-1<<" "<<l<<endl;
        break;
      }
      else if(pow(2,count) - 2 >= l && pow(2,count) <= r){
        cout<<pow(2,count) + sum<<" "<<pow(2,count) - 1 + sum<<" "<<pow(2,count) - 2 + sum<<endl;
        break;
      }
      else if(pow(2,count) - 2 >= l && pow(2,count) > r){
        count--;
      }
      else{
        l-=pow(2,count);
        r-=pow(2,count);
        sum+=pow(2,count);
        count--;
      }
    }
  }
}


Submission (verdict: Wrong answer on test 2):
#include <iostream>
using namespace std;

long long int pow(int r,int n){
  long long int ans=1;
  while(n>0){
    ans*=r;
    n--;
  }
  return ans;
}

int main() {
  int t;
  cin>>t;
  for(int i=0;i<t;i++){
    long long int l,r;
    cin>>l>>r;
    int b=r,count=0,sum=0;
    while(b>0){
      b=b/2;
      count++;
    }
    count--;
    while(count>0){
      if(l == pow(2,count) - 1){
        cout<<l<<" "<<l+1<<" "<<l+2<<endl;
        break;
      }
      else if(r-l==2){
        cout<<r<<" "<<r-1<<" "<<l<<endl;
        break;
      }
      else if(pow(2,count) - 2 >= l && pow(2,count) <= r){
        cout<<pow(2,count) + sum<<" "<<pow(2,count) - 1 + sum<<" "<<pow(2,count) - 2 + sum<<endl;
        break;
      }
      else if(pow(2,count) - 2 >= l && pow(2,count) > r){
        count--;
      }
      else{
        l-=pow(2,count);
        r-=pow(2,count);
        sum+=pow(2,count);
        count--;
      }
    }
  }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
using namespace std;

long long int pow(int r,int n){
  long long int ans=1;
  while(n>0){
    ans*=r;
    n--;
  }
  return ans;
}

int main() {
  int t;
  cin>>t;
  for(int i=0;i<t;i++){
    long long int l,r;
    cin>>l>>r;
    int b=r,count=0,sum=0;
    while(b>0){
      b=b/2;
      count++;
    }
    count--;
    while(1){
      if(pow(2,count) - 2 >= l){
        cout<<pow(2,count) + sum<<" "<<pow(2,count) - 1 + sum<<" "<<pow(2,count) - 2 + sum<<endl;
        break;
      }
      else{
        l-=pow(2,count);
        r-=pow(2,count);
        sum+=pow(2,count);
        count--;
      }
    }
  }
}


Submission (verdict: Wrong answer on test 2):
#include <iostream>
using namespace std;

long long int pow(int r,int n){
  long long int ans=1;
  while(n>0){
    ans*=r;
    n--;
  }
  return ans;
}

int main() {
  int t;
  cin>>t;
  for(int i=0;i<t;i++){
    long long int l,r;
    cin>>l>>r;
    int b=r,count=0,sum=0;
    while(b>0){
      b=b/2;
      count++;
    }
    count--;
    while(count>0){
      if(r-l==2){
        cout<<r<<" "<<r-1<<" "<<l<<endl;
        break;
      }
      else if(pow(2,count) - 2 >= l && pow(2,count) <= r){
        cout<<pow(2,count) + sum<<" "<<pow(2,count) - 1 + sum<<" "<<pow(2,count) - 2 + sum<<endl;
        break;
      }
      else if(pow(2,count) - 2 >= l && pow(2,count) > r){
        count--;
      }
      else{
        l-=pow(2,count);
        r-=pow(2,count);
        sum+=pow(2,count);
        count--;
      }
    }
  }
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#define int long long

#define vi vector<int>

#define all(x) (x).begin(), (x).end()

#define MOD 1000000007

istream& operator>>(istream &io, vi &v)

{

    for (int i = 0; i < v.size(); i++)

        io >> v[i];

    return io;

}

void print(vi& vec)

{

   for(auto it:vec)

   {

        cout << it << ' ' ;

   }

   cout << endl;

}



void sieve() 

{

}



void done_boss()

{

    string str;

    unordered_map<int,int>mpp;

    cin>>str;

    int sum=0;

    for(auto it:str)

    {

        sum+=(it-'0');

        if(it=='1'||it=='2'||it=='3') mpp[it-'0']++;

    }

    if(sum%9==0)

    {

        cout << "Yes"<<endl;

        return;

    }



    for(auto it:mpp)

    {

        int cnt=it.second;

        while(cnt--)

        {

            if(it.first==1)sum++;

            else if(it.first==2) sum+=2;

            else sum+=6;

            if(sum%9==0)

            {

                // cout << sum<<" ok"<<endl;

                cout << "Yes"<<endl;

                return;

            }   

        }

    }

    cout <<"No"<<endl;    

}



int32_t main() 

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    sieve();

    int t;

    cin >> t;

    while (t--) 

    {

        done_boss();

    }



    return 0;

}

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

using namespace std;

#define int long long

#define vi vector<int>

#define all(x) (x).begin(), (x).end()

#define MOD 1000000007

istream& operator>>(istream &io, vi &v)

{

    for (int i = 0; i < v.size(); i++)

        io >> v[i];

    return io;

}

void print(vi& vec)

{

   for(auto it:vec)

   {

        cout << it << ' ' ;

   }

   cout << endl;

}



void sieve() 

{

}



void done_boss()

{

    string str;

    unordered_map<int,int>mpp;

    cin>>str;

    int sum=0;

    for(auto it:str)

    {

        sum+=(it-'0');

        if(it=='2'||it=='3') mpp[it-'0']++;

    }

    if(sum%9==0)

    {

        cout << "Yes"<<endl;

        return;

    }



    for(auto it:mpp)

    {

        int cnt=it.second;

        while(cnt--)

        {

            if(it.first==2) sum+=2;

            else sum+=6;

            if(sum%9==0)

            {

                // cout << sum<<" ok"<<endl;

                cout << "Yes"<<endl;

                return;

            }   

        }

    }

    cout <<"No"<<endl;    

}



int32_t main() 

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    sieve();

    int t;

    cin >> t;

    while (t--) 

    {

        done_boss();

    }



    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

#define int long long

#define vi vector<int>

#define all(x) (x).begin(), (x).end()

#define MOD 1000000007

istream& operator>>(istream &io, vi &v)

{

    for (int i = 0; i < v.size(); i++)

        io >> v[i];

    return io;

}

void print(vi& vec)

{

   for(auto it:vec)

   {

        cout << it << ' ' ;

   }

   cout << endl;

}



void sieve() 

{

}



void done_boss()

{

    string str;

    unordered_map<int,int>mpp;

    cin>>str;

    int sum=0;

    for(auto it:str)

    {

        sum+=(it-'0');

        if(it=='1'||it=='2'||it=='3') mpp[it-'0']++;

    }

    if(sum%9==0)

    {

        cout << "Yes"<<endl;

        return;

    }



    for(auto it:mpp)

    {

        int cnt=it.second;

        while(cnt--)

        {

            if(it.first==1)sum++;

            else if(it.first==2) sum+=2;

            else sum+=6;

            if(sum%9==0)

            {

                // cout << sum<<" ok"<<endl;

                cout << "Yes"<<endl;

                return;

            }   

        }

    }

    cout <<"No"<<endl;    

}



int32_t main() 

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    sieve();

    int t;

    cin >> t;

    while (t--) 

    {

        done_boss();

    }



    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#define int long long

#define vi vector<int>

#define all(x) (x).begin(), (x).end()

#define MOD 1000000007

istream& operator>>(istream &io, vi &v)

{

    for (int i = 0; i < v.size(); i++)

        io >> v[i];

    return io;

}

void print(vi& vec)

{

   for(auto it:vec)

   {

        cout << it << ' ' ;

   }

   cout << endl;

}



void sieve() 

{

}



void done_boss()

{

    string str;

    unordered_map<int,int>mpp;

    cin>>str;

    int sum=0;

    for(auto it:str)

    {

        sum+=(it-'0');

        if(it=='2'||it=='3') mpp[it-'0']++;

    }

    if(sum%9==0)

    {

        cout << "Yes"<<endl;

        return;

    }



    for(auto it:mpp)

    {

        int cnt=it.second;

        while(cnt--)

        {

            if(it.first==2) sum+=2;

            else sum+=6;

            if(sum%9==0)

            {

                // cout << sum<<" ok"<<endl;

                cout << "Yes"<<endl;

                return;

            }   

        }

    }

    cout <<"No"<<endl;    

}



int32_t main() 

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    sieve();

    int t;

    cin >> t;

    while (t--) 

    {

        done_boss();

    }



    return 0;

}

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

using namespace std;

#define int long long

#define vi vector<int>

#define all(x) (x).begin(), (x).end()

#define MOD 1000000007

istream& operator>>(istream &io, vi &v)

{

    for (int i = 0; i < v.size(); i++)

        io >> v[i];

    return io;

}

void print(vi& vec)

{

   for(auto it:vec)

   {

        cout << it << ' ' ;

   }

   cout << endl;

}



void sieve() 

{

}



void done_boss()

{

    string str;

    unordered_map<int,int>mpp;

    cin>>str;

    int sum=0;

    for(auto it:str)

    {

        sum+=(it-'0');

        if(it=='2'||it=='3') mpp[it-'0']++;

    }

    int two=mpp[2];

    int three=mpp[3];



    for(int i=0; i<=two; i++)

    {

        for (int j=0; j<=three; j++)

        {

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

            {

                cout <<"Yes"<<endl;

                return;

            }

        }

    }

    cout <<"No"<<endl;    

}



int32_t main() 

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    sieve();

    int t;

    cin >> t;

    while (t--) 

    {

        done_boss();

    }



    return 0;

}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
istream& operator>>(istream &io, vi &v)
{
    for (int i = 0; i < v.size(); i++)
        io >> v[i];
    return io;
}
void print(vi& vec)
{
   for(auto it:vec)
   {
        cout << it << ' ' ;
   }
   cout << endl;
}

void sieve() 
{
}

void done_boss()
{
    int n;
    cin>>n;
    
    vi arr(n);
    cin>>arr;
    int maxi=accumulate(all(arr),0LL);

    int m=n;
    int sum=0;
    for(int j=1; j<=n-1; j++)
    {
        for(int i=1; i<m; i++)
        {
            arr[i-1]=arr[i]-arr[i-1];
        }
        m--;
        sum=abs(arr[0]);
    }
    cout << max(maxi,sum)<<endl;
}

int32_t main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    sieve();
    int t;
    cin >> t;
    while (t--) 
    {
        done_boss();
    }

    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
istream& operator>>(istream &io, vi &v)
{
    for (int i = 0; i < v.size(); i++)
        io >> v[i];
    return io;
}
void print(vi& vec)
{
   for(auto it:vec)
   {
        cout << it << ' ' ;
   }
   cout << endl;
}

void sieve() 
{
}

void done_boss()
{
    int n;
    cin>>n;
    
    vi arr(n);
    cin>>arr;
    int maxi=accumulate(all(arr),0LL);
    if(n==1)
    {
        cout << arr[0]<<endl;
        return;
    }
    int m=n;
    int sum=0;
    for(int j=1; j<=n-1; j++)
    {
        for(int i=1; i<m; i++)
        {
            arr[i-1]=arr[i]-arr[i-1];
        }
        m--;
    }
    sum=abs(arr[0]);
    cout << max(maxi,sum)<<endl;
}

int32_t main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    sieve();
    int t;
    cin >> t;
    while (t--) 
    {
        done_boss();
    }

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
istream& operator>>(istream &io, vi &v)
{
    for (int i = 0; i < v.size(); i++)
        io >> v[i];
    return io;
}
void print(vi& vec)
{
   for(auto it:vec)
   {
        cout << it << ' ' ;
   }
   cout << endl;
}

void sieve() 
{
}

void done_boss()
{
    int n;
    cin>>n;
    
    vi arr(n);
    cin>>arr;
    int maxi=accumulate(all(arr),0LL);

    int m=n;
    int sum=0;
    for(int j=1; j<=n-1; j++)
    {
        for(int i=1; i<m; i++)
        {
            arr[i-1]=arr[i]-arr[i-1];
        }
        m--;
        sum=abs(arr[0]);
    }
    cout << max(maxi,sum)<<endl;
}

int32_t main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    sieve();
    int t;
    cin >> t;
    while (t--) 
    {
        done_boss();
    }

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
istream& operator>>(istream &io, vi &v)
{
    for (int i = 0; i < v.size(); i++)
        io >> v[i];
    return io;
}
void print(vi& vec)
{
   for(auto it:vec)
   {
        cout << it << ' ' ;
   }
   cout << endl;
}

void sieve() 
{
}

void done_boss()
{
    int n;
    cin>>n;
    
    vi arr(n);
    cin>>arr;
    int maxi=accumulate(all(arr),0LL);
    if(n==1)
    {
        cout << arr[0]<<endl;
        return;
    }
    int m=n;
    int sum=0;
    for(int j=1; j<=n-1; j++)
    {
        for(int i=1; i<m; i++)
        {
            arr[i-1]=arr[i]-arr[i-1];
        }
        m--;
    }
    sum=abs(arr[0]);
    cout << max(maxi,sum)<<endl;
}

int32_t main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    sieve();
    int t;
    cin >> t;
    while (t--) 
    {
        done_boss();
    }

    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
istream& operator>>(istream &io, vi &v)
{
    for (int i = 0; i < v.size(); i++)
        io >> v[i];
    return io;
}
void print(vi& vec)
{
   for(auto it:vec)
   {
        cout << it << ' ' ;
   }
   cout << endl;
}

void sieve() 
{
}

void done_boss()
{
    int n;
    cin>>n;
    
    vi arr(n);
    cin>>arr;
    int maxi=accumulate(all(arr),0LL);
    if(n==1)
    {
        cout << arr[0]<<endl;
        return;
    }
    int m=n;

    for(int j=1; j<=n-1; j++)
    {
        int csum=0;
        for(int i=1; i<m; i++)
        {
            arr[i-1]=arr[i]-arr[i-1];
            csum+=arr[i-1];
        }
        maxi=max(maxi,abs(csum));
        m--;
    }
    
    cout << max(maxi,abs(arr[0]))<<endl;
}

int32_t main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    sieve();
    int t;
    cin >> t;
    while (t--) 
    {
        done_boss();
    }

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


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

int T, l[40], r[40], lenl, lenr;

int main () {
	scanf("%d", &T);
	while (T--) {
		memset(l, 0, sizeof(l)), memset(r, 0, sizeof(r)), lenl = lenr = 0;
		int x, y, L, R;
		scanf("%d%d", &x, &y);
		L = x, R = y;
		while (x)
			l[++lenl] = x & 1, x >>= 1;
		while (y)
			r[++lenr] = y & 1, y >>= 1;
		lenl = lenr;
		int sum = 0, len = lenr, id = 0;
		for (int i = len, base = (1 << len); i; i--, base >>= 1) {
			if (l[i] != r[i]) {
				id = len - i + 1;
				break;
			}
			sum += base;
		}
		int a = sum + (1 << (len - id)), b = a - 1;
		for (int i = R; i >= L; i--)
			if (i != a && i != b) {
				printf("%d %d %d\n", a, b, i);
				break;
			}
	}
	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;

int T, l[40], r[40], lenl, lenr;

int main () {
	scanf("%d", &T);
	while (T--) {
		memset(l, 0, sizeof(l)), memset(r, 0, sizeof(r)), lenl = lenr = 0;
		int x, y, L, R;
		scanf("%d%d", &x, &y);
		L = x, R = y;
		while (x)
			l[++lenl] = x & 1, x >>= 1;
		while (y)
			r[++lenr] = y & 1, y >>= 1;
		lenl = lenr;
		int sum = 0, len = lenr, id = 0;
		for (int i = len, base = (1 << len); i; i--, base >>= 1) {
			if (l[i] != r[i]) {
				id = i - 1;
				break;
			}
			sum += base;
		}
		int a = sum + (1 << id), b = a - 1;
		for (int i = R; i >= L; i--)
			if (i != a && i != b) {
				printf("%d %d %d\n", a, b, i);
				break;
			}
	}
	return 0;
}


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

int T, l[40], r[40], lenl, lenr;

int main () {
	scanf("%d", &T);
	while (T--) {
		memset(l, 0, sizeof(l)), memset(r, 0, sizeof(r)), lenl = lenr = 0;
		int x, y, L, R;
		scanf("%d%d", &x, &y);
		L = x, R = y;
		while (x)
			l[++lenl] = x & 1, x >>= 1;
		while (y)
			r[++lenr] = y & 1, y >>= 1;
		lenl = lenr;
		int sum = 0, len = lenr;
		for (int i = len; i; i--) {
			if (l[i] != r[i]) {
				int a = sum + (1 << (i - 1)), b = a - 1;
				printf("%d %d ", a, b);
				if (a > L && b > L)
					printf("%d\n", L);
				else
					printf("%d\n", R);
				break;
			}
			sum += (1 << (i - 1)) * l[i];
		}
	}
	return 0;
}