ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049C - MEX Cycle
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
// #pragma GCC optimize(2)

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define endl '\n'

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



const int INF = 1e9;     // 无穷大

const int INFLL = 1e18;  // 长整型无穷大

const int MOD = 1e9 + 7; // 模数

// -9.2e18 ~ 9.2e18



void solve()

{

    int n, num1, num2;

    cin >> n >> num1 >> num2;

    vector<int> v(n + 1, 0);

    v[num1] = 0;

    v[num2] = 2;

    bool ok = 1;

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

    {



        if (v[i] == 0)

        {

            v[i] = ok;

            ok = !ok;

        }

    }

    ok = 1;

    for (int i = num1 - 1; i >= 1; i--)

    {

        if (v[i] == 0)

        {

            v[i] = ok;

            ok = !ok;

        }

    }

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

    {

        cout << v[i] << ' ';

    }

}



signed main()

{

    cin.tie(nullptr)->ios::sync_with_stdio(false);

    cout << setiosflags(ios::fixed) << setprecision(2);

    int TT = 1;

    cin >> TT;

    while (TT--)

    {

        solve();

        cout << endl;

    }

}

Submission (verdict: Wrong answer on test 1):
// #pragma GCC optimize(2)

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define endl '\n'

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



const int INF = 1e9;     // 无穷大

const int INFLL = 1e18;  // 长整型无穷大

const int MOD = 1e9 + 7; // 模数

// -9.2e18 ~ 9.2e18



void solve()

{

    int n, num1, num2;

    cin >> n >> num1 >> num2;

    vector<int> v(n + 1, 0);

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

    {

        v[(num1 + i) % n] = i % 2;

    }

    if (n % 2 == 1 or (num1 - num2) % 2 == 0)

    {

        v[num1] = 2;

    }

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

    {

        cout << v[i] << ' ';

    }

}



signed main()

{

    cin.tie(nullptr)->ios::sync_with_stdio(false);

    cout << setiosflags(ios::fixed) << setprecision(2);

    int TT = 1;

    cin >> TT;

    while (TT--)

    {

        solve();

        cout << endl;

    }

}
Problem: 2049C - MEX Cycle
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
// #pragma GCC optimize(2)

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define endl '\n'

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



const int INF = 1e9;     // 无穷大

const int INFLL = 1e18;  // 长整型无穷大

const int MOD = 1e9 + 7; // 模数

// -9.2e18 ~ 9.2e18



void solve()

{

    int n, num1, num2;

    cin >> n >> num1 >> num2;

    vector<int> v(n + 1, 0);

    v[num1] = 0;

    v[num2] = 2;

    bool ok = 1;

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

    {



        if (v[i] == 0)

        {

            v[i] = ok;

            ok = !ok;

        }

    }

    ok = 1;

    for (int i = num1 - 1; i >= 1; i--)

    {

        if (v[i] == 0)

        {

            v[i] = ok;

            ok = !ok;

        }

    }

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

    {

        cout << v[i] << ' ';

    }

}



signed main()

{

    cin.tie(nullptr)->ios::sync_with_stdio(false);

    cout << setiosflags(ios::fixed) << setprecision(2);

    int TT = 1;

    cin >> TT;

    while (TT--)

    {

        solve();

        cout << endl;

    }

}
Problem: 2049C - MEX Cycle
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
// #pragma GCC optimize(2)

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define endl '\n'

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



const int INF = 1e9;     // 无穷大

const int INFLL = 1e18;  // 长整型无穷大

const int MOD = 1e9 + 7; // 模数

// -9.2e18 ~ 9.2e18



void solve()

{

    int n, num1, num2;

    cin >> n >> num1 >> num2;

    vector<int> v(n + 1, 0);

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

    {

        v[(num1 + i) % n] = i % 2;

    }

    if (n % 2 == 1 or (num1 - num2) % 2 == 0)

    {

        v[num1] = 2;

    }

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

    {

        cout << v[i] << ' ';

    }

}



signed main()

{

    cin.tie(nullptr)->ios::sync_with_stdio(false);

    cout << setiosflags(ios::fixed) << setprecision(2);

    int TT = 1;

    cin >> TT;

    while (TT--)

    {

        solve();

        cout << endl;

    }

}

Submission (verdict: Accepted):
// #pragma GCC optimize(2)

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define endl '\n'

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



const int INF = 1e9;     // 无穷大

const int INFLL = 1e18;  // 长整型无穷大

const int MOD = 1e9 + 7; // 模数

// -9.2e18 ~ 9.2e18



void solve()

{

    int n, x, y;

    cin >> n >> x >> y;

    x--, y--;

    vector<int> ans(n);

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

    {

        ans[(x + i) % n] = i % 2;

    }

    if (n % 2 or (x - y) % 2 == 0)

    {

        ans[x] = 2;

    }

    for (auto &&x : ans)

    {

        cout << x << ' ';

    }

}



signed main()

{

    cin.tie(nullptr)->ios::sync_with_stdio(false);

    cout << setiosflags(ios::fixed) << setprecision(2);

    int TT = 1;

    cin >> TT;

    while (TT--)

    {

        solve();

        cout << endl;

    }

}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Runtime error on test 2):
// #pragma GCC optimize(2)

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define endl '\n'

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



constexpr int MOD = 1e9 + 7;

// -9.2e18 ~ 9.2e18



void solve()

{

    int n, m;

    cin >> n >> m;

    vector<int> a(n), b(m);

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

    {

        cin >> a[i];

    }

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

    {

        cin >> b[i];

    }



    priority_queue<int, vector<int>> pqa, pqb;

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

    {

        pqa.push(a[i]);

    }

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

    {

        pqb.push(b[i]);

    }

    int k = n - m;

    while (pqa.size() and k)

    {

        auto amax = pqa.top();

        pqa.pop();

        auto bmax = pqb.top();

        pqb.pop();



        if (amax == bmax)

        {

            continue;

        }

        else if (amax > bmax)

        {

            cout << "No";

            return;

        }

        else

        {

            pqa.push(amax);

            auto num1 = bmax / 2, num2 = (bmax + 1) / 2;

            pqb.push(num1);

            pqb.push(num2);

        }

        k--;

    }



    while (pqa.size() and pqb.size())

    {

        auto amax = pqa.top();

        pqa.pop();

        auto bmax = pqb.top();

        pqb.pop();



        if (amax == bmax)

        {

            continue;

        }

        else

        {

            cout << "No";

            return;

        }

    }

    cout << (pqa.size() or pqb.size() ? "No" : "Yes");

}



signed main()

{

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

    cout << setiosflags(ios::fixed) << setprecision(2);

    int TT = 1;

    cin >> TT;

    while (TT--)

    {

        solve();

        cout << endl;

    }

}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


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

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

    int n;
    int k;
    cin >> n >> k;

    int a;
    map< int , int > mpp;
    for(int i=0;i<n;i++){
      cin >> a;
      mpp[a]++;

    }

    vector<int>ans;

    for(auto it:mpp){
      ans.push_back(it.second);
    }

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

    int s= ans.size();
    int mini=s;
    for(int i=0;i<s;i++){
      k-=ans[i];
      if(k<0){
        break;
      }
      s--;
    }

    cout << s << endl;
  }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

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

    int n;
    int k;
    cin >> n >> k;

    int a;
    map< int , int > mpp;
    for(int i=0;i<n;i++){
      cin >> a;
      mpp[a]++;

    }

    vector<int>ans;

    for(auto it:mpp){
      ans.push_back(it.second);
    }

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

    int s= ans.size();
    int mini=s;
    for(int i=0;i<s;i++){
      k-=ans[i];
      if(k<=0){
        break;
      }
      mini--;
    }

    cout << mini << endl;
  }
}


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

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

    int n;
    int k;
    cin >> n >> k;

    int a;
    map< int , int > mpp;
    for(int i=0;i<n;i++){
      cin >> a;
      mpp[a]++;

    }

    vector<int>ans;

    for(auto it:mpp){
      ans.push_back(it.second);
    }

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

    int s= ans.size();
    int mini=s;
    for(int i=0;i<s;i++){
      k-=ans[i];
      if(k<0){
        break;
      }
      mini--;
    }

    cout << max(mini,1) << endl;
  }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

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

    int n;
    int k;
    cin >> n >> k;

    int a;
    map< int , int > mpp;
    for(int i=0;i<n;i++){
      cin >> a;
      mpp[a]++;

    }

    vector<int>ans;

    for(auto it:mpp){
      ans.push_back(it.second);
    }

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

    int s= ans.size();
    int mini=s;
    for(int i=0;i<s;i++){
      k-=ans[i];
      if(k<=0){
        break;
      }
      s--;
    }

    cout << s << endl;
  }
}


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

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

    int n;
    int k;
    cin >> n >> k;

    int a;
    map< int , int > mpp;
    for(int i=0;i<n;i++){
      cin >> a;
      mpp[a]++;

    }

    vector<int>ans;

    for(auto it:mpp){
      ans.push_back(it.second);
    }

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

    int s= ans.size();
    int mini=s;
    for(int i=0;i<s;i++){
      k-=ans[i];
      if(k<0){
        break;
      }
      mini--;
    }

    cout << mini << endl;
  }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

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

    int n;
    int k;
    cin >> n >> k;

    int a;
    map< int , int > mpp;
    for(int i=0;i<n;i++){
      cin >> a;
      mpp[a]++;

    }

    vector<int>ans;

    for(auto it:mpp){
      ans.push_back(it.second);
    }

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

    int s= ans.size();
    int mini=s;
    for(int i=0;i<s;i++){
      k-=ans[i];
      if(k<0){
        break;
      }
      mini--;
    }

    cout << mini << endl;
  }
}


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

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

    int n;
    int k;
    cin >> n >> k;

    int a;
    map< int , int > mpp;
    for(int i=0;i<n;i++){
      cin >> a;
      mpp[a]++;

    }

    vector<int>ans;

    for(auto it:mpp){
      ans.push_back(it.second);
    }

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

    int s= ans.size();
    int mini=s;
    for(int i=0;i<s;i++){
      k-=ans[i];
      if(k<=0){
        break;
      }
      mini--;
    }

    cout << mini << endl;
  }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

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

    int n;
    int k;
    cin >> n >> k;

    int a;
    map< int , int > mpp;
    for(int i=0;i<n;i++){
      cin >> a;
      mpp[a]++;

    }

    vector<int>ans;

    for(auto it:mpp){
      ans.push_back(it.second);
    }

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

    int s= ans.size();
    int mini=s;
    for(int i=0;i<s;i++){
      k-=ans[i];
      if(k<0){
        break;
      }
      s--;
    }

    cout << s << endl;
  }
}


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

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

    int n;
    int k;
    cin >> n >> k;

    int a;
    map< int , int > mpp;
    for(int i=0;i<n;i++){
      cin >> a;
      mpp[a]++;

    }

    vector<int>ans;

    for(auto it:mpp){
      ans.push_back(it.second);
    }

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

    int s= ans.size();
    int mini=s;
    for(int i=0;i<s;i++){
      k-=ans[i];
      if(k<=0){
        break;
      }
      s--;
    }

    cout << s << endl;
  }
}
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 alsammany ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x) cout<<#x<<" = "<<x<<endl
#define debugg(x, y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<< endl
#define vvi(r, c) vvi(r, vi(c))
#define vin(v) for(auto &i:(v))cin>>i
#define rall(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end()
#define F first
#define S second
template <typename T> void display(const T& container) { cout << "{ "; for (const auto& element : container) { cout << element << " "; } cout << "}" << endl; } template <typename K, typename V> void display(const map<K, V>& container) { for (const auto& pair : container) { cout << "\n[" << pair.first << "]: "; display(pair.second); } }
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<pair<int,int>> vp; // vp vec(n, make_pair(0, 0));
typedef vector<vector<int>> vvi;
// struct Triple{ int first; int second; int index; };
// sort(vec.begin(), vec.end(), [](const Triple& a, const Triple& b) {return a.first < b.first;});

void Solve(){
    string s; cin>>s;
    ll sum = 0;
    for(auto e:s){
        int num = e - '0';
        sum += num;
    }

    if(sum % 9 == 0) {cout<<"YES"; return;}

    sort(all(s));
    
    for(auto e:s){
        if(e == '2') sum+=2;
        if(e == '3') sum+=6;

        if(sum % 9 == 0) {cout<<"YES"; return;}
    }
    cout<<"NO";
    
}   

int main(){
    alsammany
    int t; cin >> t; while(t--){
        Solve();
        cout << endl;
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
 
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...)
#endif


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//find_by_order(k): It returns to an iterator to the kth element (counting from zero)
//order_of_key(k): order_of_key(k) : It returns to the number of items that are strictly smaller than our item k
template<typename T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

// https://codeforces.com/problemset/problem/2052/A
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> c(n+1), idx(n+1), at(n+1);
    ordered_set<int> os;
    for (int i = 1; i <= n; i++){
        cin >> c[i];
        at[c[i]] = i;
    }
    iota(idx.begin(), idx.end(), 0);
    vector<pair<int,int>> ans;
    for (int i = n; i >= 1; i--){
        int curr = c[i] - os.order_of_key(c[i]);
        // dbg(curr, idx[curr], at[c[i]], c[i]);
        // dbg(idx);
        assert(curr <= at[c[i]] && idx[curr] == c[i]);
        //already in the right spot
        if (at[c[i]] == curr){
            if (curr - 1 >= 1 && (ans.empty() || ans.back() != make_pair(idx[curr-1], idx[curr]))){
                ans.push_back({idx[curr], idx[curr-1]});
                ans.push_back({idx[curr-1], idx[curr]});
            }
        }        
        else {
            int it = at[c[i]] - curr;
            while(it--){
                ans.push_back({idx[curr+1], idx[curr]});
                swap(idx[curr], idx[curr+1]);
                curr++;
            }
        }
        os.insert(c[i]);   
    }
    cout << ans.size() << '\n';
    for (auto &[x,y] : ans){
        cout << x << " " << y << '\n';
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define v(n) vector<ll> v(n)
#define inp(n) for(ll i=0;i<n;++i){ cin>>v[i]; }
#define op(n) for(ll i=0;i<v.size();++i){ cout<<v[i]<<" ";}
#define yes cout<<"Yes"
#define no cout<<"No"
#define br break
#define cnti continue
#define nl cout<<endl
#define all v.begin(),v.end()

 int gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b);}

 int power(ll a,ll b){if(b==0) return 1;ll res =power(a,b/2);
    if(b&1){
        return a*res*res;
    }else{
        return res*res;
    }
 }

 bool prime(ll n){
     bool t = true;
     for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){
            t=false;
            break;
        }
     }
     return t;
 }
ll min(ll a,ll b){
    return a>b ? b: a;
}

const int n1=1e9+7;

bool isBinaryString(const string& str) {
    return all_of(str.begin(), str.end(), [](char c) { return c == '0' || c == '1'; });
}
void solve(){

 ll n,k;cin>>n>>k;
 vector<ll> a;

map<ll,ll> m;
 for(int i=0;i<n;i++){
    ll p;cin>>p;
    a.push_back(p);
    m[p]++;
 }
//  nl;
// for(auto it: m){
//     cout<<it.first<<" "<<it.second;nl;
// }

map<ll,ll> am;
for(auto it: m){
    am[it.second]++;
}
// nl;
// for(auto it:am){
//     cout<<it.first<<" "<<it.second;nl;
// }

ll ans=m.size();
for(auto it: am){
   ll x=it.first;
   if(k>0){
        if(k>x*it.second){
            ans-=x*it.second;
            k-=x*it.second;
        }else{
            if(k==x*it.second){
                ans-=it.second;
                k=0;
            }else{
                ans-=(k/x);
                k=0;
            }
        }
   }else{
    if(ans==0){
        cout<<"1";nl;return ;
    }else{
        cout<<ans;nl;return ;
    }
   }
}
if(ans==0){
    cout<<"1";nl;return ;
}else{
    cout<<ans;nl;return ;
}

}
    


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
   ll t;cin>>t;
  while(t--) solve();
  return 0;
   }
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#ifdef AMAN_MAC
#include "debug.h"
#else
#define debug(...)
#endif

using namespace __gnu_pbds;using namespace std;
#define int int64_t

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T, typename R> using ordered_map = tree<T, R, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int M = 1e9 + 7;
template <typename T> std::istream& operator>>(std::istream& in, std::vector<T>& vec) { for(auto &v : vec) in>>v;return in;}
template <typename T> std::ostream& operator<<(std::ostream& out,std::vector<T>& vec) { for(auto &v : vec) out<<v<<" ";return out;}
int mul(int a, int b) { return ((a % M) * (b % M)) % M; }int madd(int a, int b) { return (a % M + b % M) % M; }
int mpow(int a, int b) { int pow = a, res = 1; while (b) { if (b & 1)res = mul(res, pow);pow = mul(pow, pow);b >>= 1; }return res; }
int minv(int a) { return mpow(a, M - 2); }int mdiv(int a, int b) { return mul(a, minv(b)); }int msub(int a, int b) { return (a % M - b % M + M) % M; }
int binlog(int a,int b){ int cnt=0; while(a>=b){a/=b; cnt++; } return cnt; }
void solve() {
    int l,r;
    cin>>l>>r;
    int p = 1;
    while(p*2<=r-l)p*=2;
    int a = (r/p)*p;
    cout<<a<<" "<<a-1<<" "<<a-2;
}

int32_t main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t; cin >> t; for(int i = 0;i < t; i++ ) { solve(); cout << "\n";}
    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;

int main(){
    int t;
    cin>>t;
    while(t--){
        int l,r;
        cin>>l>>r;
        string s=bitset<32>(l).to_string();
        string p=bitset<32>(r).to_string();
        string a="";
        string b="";
        string c="";
        int pick=0;
        for(int i=0;i<32;i++){
            if(s[i]==p[i]){
                a+=s[i];
                b+=s[i];
                c+=s[i];
            }
            else{
                if(s[i]=='1'){
                    a+='0';
                    b+='1';
                }
                else{
                    a+='1';
                    b+='0';
                }
                pick=i;
                break;
                
            }
            
        }
        for(int i=pick+1;i<32;i++){
            if(a[i-1]=='1'){
                a+='0';
                b+='1';
                c+='0';
            }
            else{
                a+='1';
                b+='0';
                c+='1';
            }
        }
        bitset<32>fa(a);
        bitset<32>fb(b);
        bitset<32>fc(c);
        unsigned long aa=fa.to_ulong();
        unsigned long ab=fb.to_ulong();
        unsigned long ac=fc.to_ulong();
        // int xori=aa^ab+ab^ac+aa^ac;
        // cout<<xori<<endl;
        cout<<aa<<" "<<ab<<" "<<ac<<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;

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

        long long a = r, b = r - 1, c = r - 2;

        // Precomputed XOR results for selected numbers
        long long max_sum = (a ^ b) + (b ^ c) + (a ^ c);
        
        // Explore combination including `l` for edge cases
        long long alt_a = r, alt_b = r - 1, alt_c = l;
        long long sum_alt = (alt_a ^ alt_b) + (alt_b ^ alt_c) + (alt_a ^ alt_c);

        if (sum_alt > max_sum) {
            a = alt_a; b = alt_b; c = alt_c;
            max_sum = sum_alt;
        }

        // Output the best combination found
        cout << a << " " << b << " " << c << endl;
    }
    return 0;
}


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

int main(){
    int t;
    cin>>t;
    while(t--){
         ll l, r;
    cin >> l >> r;
    ll ans = 0;
    ll a, b, c;
    for (int i = 30; i >= 0; i--)
    {
        ll b1 = 0;
        ll b2 = 0;
        if (l & (1ll << i))
        {
            b1 = 1;
        }
        if (r & (1ll << i))
        {
            b2 = 1;
        }
        if (b1 == b2)
        {
            ans += b1 * (1ll << i);
        }
        else
        {
            a = ans + (1ll << i);
            b = a - 1;
            break;
        }
    }
    for (ll i = l; i <= r; i++)
    {
        if (i != a && i != b)
        {
            c = i;
            break;
        }
    }
    cout << a << " " << b << " " << c << endl;
    }
}