ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        unordered_map<int, int> freq;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            freq[a[i]]++;
        }
        vector<int> frequencies;
        for (auto it : freq) {
            frequencies.push_back(it.second);
        }
        sort(frequencies.begin(), frequencies.end());

        if (k >= n) {
            cout << 1 << endl;
            continue;
        }

        int uniqueCount = frequencies.size();
        for (int f : frequencies) {
            if (k >= f) {
                k -= f;  // Use `k` to reduce this frequency
                uniqueCount--;  
            } else {
                break;  // No more reductions possible
            }
        }

        cout << uniqueCount << endl;
    }
    return 0;
}


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;
        vector<int> a(n);
        // unordered_map<int, int> freq;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }

        sort(a.begin(),a.end());
        int c=1;
        vector<int>cnt;
        
        for(int i=0;i<n-1;i++){
                if(a[i]==a[i+1]){
                    c++;
                }
                else{
                    cnt.push_back(c);
                    c=1;
                }
        }
        if(cnt.size()==1 || k>=n){
            cout<<1<<endl;
            continue;
        }
        sort(cnt.begin(),cnt.end());
        int ans = 0;
        for(int i=0;i<cnt.size();i++){
            if(k>0){
                k=k-cnt[i];
            }
            else{
                ans=cnt.size()-i;
                break;
            }
        }

        cout<<ans+1<<endl;
        
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef long double ld;
typedef vector<vector<ll>> VI;
ll mod = 1e9 + 7;
const ll INF = 5e18;

vi inputVector(int n)
{
  vi vec(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> vec[i];
  }
  return vec;
}
vi inputVector2(int n)
{
  vi vec(n + 1);
  for (int i = 1; i <= n; ++i)
  {
    cin >> vec[i];
  }
  return vec;
}
VI input2D(ll n, ll m)
{
  VI vec(n, vi(m));
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      cin >> vec[i][j];
    }
  }
  return vec;
}
ll power(ll x, ll y)
{
  ll res = 1;
  while (y > 0)
  {
    if (y % 2 == 1)
      res = ((res % mod) * (x % mod)) % mod;

    y = y >> 1;
    x = ((x % mod) * (x % mod)) % mod;
  }
  return res % mod;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll t;
  cin >> t;
  while (t--)
  {
    ll n;
    cin >> n;
    VI adj(n + 1);
    vi in(n + 1, 0);
    for (ll i = 1; i < n; i++)
    {
      ll x, y;
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
      in[x]++;
      in[y]++;
    }
    ll ans = 0, node = 0;
    for (ll i = 1; i <= n; i++)
    {
      if (in[i] > in[node])
      {
        node = i;
      }
    }
    ans += in[node];
    in[node] = 0;
    for (auto it : adj[node])
    {
      in[it]--;
    }
    ans--;
    node = 0;
    for (ll i = 1; i <= n; i++)
    {
      if (in[i] > in[node])
      {
        node = i;
      }
    }
    ans += in[node];
    cout << ans << endl;
  }
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#include <queue>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rem(i, n) for (ll i = n - 1; i >= 0; i--)
#define ll long long
#define vl vector<ll>
#define pi pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define mi 1000001

/*
For using ordered_set :

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
1. *s.find_by_order(k) --> Returns the element present at index k.
2.  s.order_of_key(k) -->  Returns the number of elements smaller than k.
*/

// #define vli(n) vector<ll> v;for (ll i = 0; i < n; i++){ ll a; cin >> a;v.pb(a);}
// #define vli(n, m)  vector<vector<ll>> v;  for (ll i = 0; i < n; i++){ vector<ll> temp;for (ll j = 0; j < m; j++){ll a;cin >> a; temp.pb(a);}v.pb(temp);}
// vector<vector<vector<ll>>>arr(n+1,vector<vector<ll>>(n+1,vector<ll>(n+1,0)));
// vector<vector<ll>>arr(n+1,vector<ll>(n+1,0));
// sort(v.begin(),v.end(), greater<ll>());


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll q;
    cin >> q;
    while (q--)
    {
      ll n,m;
      cin>>n>>m;
      map<ll,ll>mp;
      priority_queue<ll,vector<ll>,greater<ll>>pq;
      vector<int> v;for (ll i = 0; i < n; i++){ int a; cin >> a;v.pb(a);pq.push(a);}
      vector<int> v1;for (ll i = 0; i < m; i++){ int a; cin >> a;v1.pb(a);mp[a]++;}
      while(pq.size()>=1 && mp.size()>0)
      {
        ll x=pq.top();
        if(mp.find(x)!=mp.end())
        {
            mp[x]--;
            if(mp[x]<=0)mp.erase(x);
            pq.pop();
            continue;
        }
        pq.pop();
        if(pq.size()>0)
        {
            ll y=pq.top();
            if(mp.find(y)!=mp.end())
            {
              mp[y]--;
              if(mp[y]<=0)mp.erase(y);
              pq.pop();
              if(y-x<=1)pq.push(x);
              continue;
            }
            pq.pop();
            if(y-x<=1)
            {
                pq.push(x+y);
            }
            else pq.push(y);
        }

      }
    //   cout<<mp.size()<<endl;
      if(mp.size()==0 && pq.size()==0)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
      
    }
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

#define int long long

int dynam(string a,string b,string c,int n,int m,vector<vector<int>> &dp,int d,int e){

    if (dp[n][m]!=-1){return dp[n][m];}

    if (n==0){

        int ans=0;

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

            // if (m==3){cout<<b[d-m+i]<<c[d+e-m+i]<<d<<endl;}

            if (b[d-m+i]!=c[d+e-m+i]){ans++;}

        }

        dp[n][m]=ans;

        return ans;

    }

    if (m==0){

        int ans=0;

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

            if (a[e-n+i]!=c[d+e-n+i]){ans++;}

        }

        dp[n][m]=ans;

        return ans;

    }

    int alpha,beta=0;

    alpha=dynam(a,b,c,n-1,m,dp,d,e);

    beta=dynam(a,b,c,n,m-1,dp,d,e);

    // cout<<"for n="<<n<<" and m="<<m<<" alpha="<<alpha<<" beta="<<beta<<endl;

    alpha+=(a[e-n]!=c[d+e-n-m]);

    // cout<<a[e-n]<<c[d+e-n-m];

    beta+=(b[d-m]!=c[d+e-m-n]);

    // cout<<b[d-m]<<c[d+e-m-n];

    // cout<<"for n="<<n<<" and m="<<m<<" alpha="<<alpha<<" beta="<<beta<<endl;

    dp[n][m]=min(alpha,beta);

    return dp[n][m];

}

void solve(){

    int t;

    cin>>t;

    while(t--){

        string a,b,c;

        cin>>a>>b>>c;

        vector<vector<int>> dp(a.size()+1,vector<int>(b.size()+1,-1));

        cout<<dynam(a,b,c,a.size(),b.size(),dp,b.size(),a.size())<<endl;

        // for (int i=0;i<=a.size();i++){

        //     for (int j=0;j<=b.size();j++){

        //         cout<<dp[i][j]<<" ";

        //     }

        //     cout<<endl;

        // }

    }

}

#undef int

int main(){

    solve();

    return 0;

}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

int dynam(string a,string b,string c,int n,int m,vector<vector<int>> &dp,int d,int e){

    if (dp[n][m]!=-1){return dp[n][m];}

    int alpha,beta=0;

    alpha=dynam(a,b,c,n-1,m,dp,d,e);

    beta=dynam(a,b,c,n,m-1,dp,d,e);

    // cout<<"for n="<<n<<" and m="<<m<<" alpha="<<alpha<<" beta="<<beta<<endl;

    alpha+=(a[e-n]!=c[d+e-n-m]);

    // cout<<a[e-n]<<c[d+e-n-m];

    beta+=(b[d-m]!=c[d+e-m-n]);

    // cout<<b[d-m]<<c[d+e-m-n];

    // cout<<"for n="<<n<<" and m="<<m<<" alpha="<<alpha<<" beta="<<beta<<endl;

    dp[n][m]=min(alpha,beta);

    return dp[n][m];

}

void solve(){

    int t;

    cin>>t;

    while(t--){

        string a,b,c;

        cin>>a>>b>>c;

        vector<vector<int>> dp(a.size()+1,vector<int>(b.size()+1,-1));

        dp[0][0]=0;

        for (int i=1;i<=a.size();i++){

            dp[i][0]=dp[i-1][0]+(a[a.size()-i]!=c[c.size()-i]);

        }

        for (int i=1;i<=b.size();i++){

            dp[0][i]=dp[0][i-1]+(b[b.size()-i]!=c[c.size()-i]);

        }

        cout<<dynam(a,b,c,a.size(),b.size(),dp,b.size(),a.size())<<endl;

        // for (int i=0;i<=a.size();i++){

        //     for (int j=0;j<=b.size();j++){

        //         cout<<dp[i][j]<<" ";

        //     }

        //     cout<<endl;

        // }

    }

}

int main(){

    solve();

    return 0;

}

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

using namespace std;

int dynam(string a,string b,string c,int n,int m,vector<vector<int>> &dp,int d,int e){

    if (dp[n][m]!=-1){return dp[n][m];}

    int alpha,beta=0;

    alpha=dynam(a,b,c,n-1,m,dp,d,e);

    beta=dynam(a,b,c,n,m-1,dp,d,e);

    // cout<<"for n="<<n<<" and m="<<m<<" alpha="<<alpha<<" beta="<<beta<<endl;

    alpha+=(a[e-n]!=c[d+e-n-m]);

    // cout<<a[e-n]<<c[d+e-n-m];

    beta+=(b[d-m]!=c[d+e-m-n]);

    // cout<<b[d-m]<<c[d+e-m-n];

    // cout<<"for n="<<n<<" and m="<<m<<" alpha="<<alpha<<" beta="<<beta<<endl;

    dp[n][m]=min(alpha,beta);

    return dp[n][m];

}

void solve(){

    int t;

    cin>>t;

    while(t--){

        string a,b,c;

        cin>>a>>b>>c;

        vector<vector<int>> dp(a.size()+1,vector<int>(b.size()+1,-1));

        dp[0][0]=0;

        for (int i=1;i<=a.size();i++){

            dp[i][0]=dp[i-1][0]+(a[a.size()-i]!=c[c.size()-i]);

        }

        for (int i=1;i<=b.size();i++){

            dp[0][i]=dp[0][i-1]+(b[b.size()-i]!=c[c.size()-i]);

        }

        for (int i=1;i<=a.size();i++){

            for (int j=1;j<=b.size();j++){

                dp[i][j]=min(dp[i-1][j]+(a[a.size()-i]!=c[c.size()-(i+j)]),dp[i][j-1]+(b[b.size()-j]!=c[c.size()-(i+j)]));

            }

        }

        cout<<dp[a.size()][b.size()]<<endl;

        // for (int i=0;i<=a.size();i++){

        //     for (int j=0;j<=b.size();j++){

        //         cout<<dp[i][j]<<" ";

        //     }

        //     cout<<endl;

        // }

    }

}

int main(){

    solve();

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
//

//Created by xll.

//

#include<bits/stdc++.h>

#define int long long

#define fi first

#define se second

using namespace std;



typedef pair<int,int> PII;



const int N = 200010;

const int inf=1e18;



void solve()

{

    int n,l,r;

    cin>>n>>l>>r;

    vector<int> a[3];

    int mi=inf;

    vector<vector<int>> s(3,vector<int>(n+1));

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

    {

        int x;cin>>x;

        a[0].push_back(x);

        mi=min(mi,x);

    }

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

    {

        int x;cin>>x;

        a[1].push_back(x);

        mi=min(mi,x);

    }

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

    {

        int x;cin>>x;

        a[2].push_back(x);

        mi=min(mi,x);

    }

    for(int i=0;i<3;i++)sort(a[i].begin(),a[i].end());

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

    {

        for(int j=0;j<a[i].size();j++)

        {

            if(!j)s[i][j]=a[i][j];

            else s[i][j]=s[i][j-1]+a[i][j];

        }

    }

    int ans=s[1][a[1].size()-1];

    int m=a[1].size()-1;

    //cout<<"ans=="<<ans<<'\n';

    for(int i=0;i<a[0].size();i++)

    {

        if(m-i-1>=0){

            ans=min(ans,s[1][m-i-1]+s[0][i]);

            //cout<<"i1=="<<i<<'\n'<<" res=="<<s[1][m-i-1]+s[0][i]<<'\n';

        }

    }



    for(int i=0;i<a[2].size();i++)

    {

        if(m-i-1>=0){

            ans=min(ans,s[1][m-i-1]+s[2][i]);

            //cout<<"i2=="<<i<<'\n'<<" res=="<<s[1][m-i-1]+s[2][i]<<'\n';

        }

    }

    if(m==0)cout<<mi<<'\n';

    else cout<<ans<<'\n';



}



signed main() 

{

    std::ios::sync_with_stdio(false);

    cin.tie(0); 

    cout.tie(0);

    int T;

    cin >> T;



    while(T --)

    {

        solve();

    }

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
//
//Created by xll.
//
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;

typedef pair<int,int> PII;

const int N = 200010;
const int inf=1e18;

void solve()
{
    int n,l,r;
    cin>>n>>l>>r;
    vector<int> a[3];
    int mi=inf;
    vector<vector<int>> s(3,vector<int>(n+1));
    for(int i=1;i<=l-1;i++)
    {
        int x;cin>>x;
        a[0].push_back(x);
        mi=min(mi,x);
    }
    for(int i=l;i<=r;i++)
    {
        int x;cin>>x;
        a[1].push_back(x);
    }
    for(int i=r+1;i<=n;i++)
    {
        int x;cin>>x;
        a[2].push_back(x);
        mi=min(mi,x);
    }
    for(int i=0;i<3;i++)sort(a[i].begin(),a[i].end());
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<a[i].size();j++)
        {
            if(!j)s[i][j]=a[i][j];
            else s[i][j]=s[i][j-1]+a[i][j];
        }
    }
    int ans=s[1][a[1].size()-1];
    int m=a[1].size()-1;
    if(m==0){
        cout<<mi<<'\n';
        return;
    }
    //cout<<"ans=="<<ans<<'\n';
    for(int i=0;i<a[0].size();i++)
    {
        if(m-i-1>=0){
            ans=min(ans,s[1][m-i-1]+s[0][i]);
        }
    }

    for(int i=0;i<a[2].size();i++)
    {
        if(m-i-1>=0){
            ans=min(ans,s[1][m-i-1]+s[2][i]);
           
        }
    }
    if(m==0)cout<<mi<<'\n';
    else cout<<ans<<'\n';

}

signed main() 
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
    int T;
    cin >> T;

    while(T --)
    {
        solve();
    }
}

Submission (verdict: Accepted):
//
//Created by xll.
//
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;

typedef pair<int,int> PII;

const int N = 200010;
const int inf=1e18;

void solve()
{
    int n,l,r;
    cin>>n>>l>>r;
    vector<int> a(n+1);

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

    vector<int> v1,v2;
    for(int i=1;i<=r;i++)v1.push_back(a[i]);
    for(int i=l;i<=n;i++)v2.push_back(a[i]);
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    int s1=0,s2=0;
    for(int i=0;i<r-l+1;i++)
    {
        s1+=v1[i];
        s2+=v2[i];
    }
    cout<<min(s1,s2)<<'\n';
}

signed main() 
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
    int T;
    cin >> T;

    while(T --)
    {
        solve();
    }
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, l, r) for(int i=l;i<=r;i++)
const int MX = 1e3 + 5;
string a,b,c;
int dfs(int i=0,int j=0,int k=0){ 
    if(k == c.size()) return 0;
    int ans = 1e9;
    
    if(i < a.size() && a[i] == c[k]){
        ans = min(ans,dfs(i+1,j,k+1));
    }
    if(j < b.size() && b[j] == c[k]){
        ans = min(ans,dfs(i,j+1,k+1));
    }
    ans = min(ans,1+min(dfs(i+1,j,k+1),dfs(i,j+1,k+1)));
    return ans;
}
void solve(){
    cin>>a>>b>>c;
   
    cout<<dfs()<<"\n";
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, l, r) for(int i=l;i<=r;i++)
const int MX = 1e3 + 5;
string a,b,c;
int dfs(int i=0,int j=0,int k=0){ 
    if(k == c.size()) return 0;
    int ans = 1e9;
    
    if(i < a.size() && a[i] == c[k]){
        ans = min(ans,dfs(i+1,j,k+1));
    }
    if(j < b.size() && b[j] == c[k]){
        ans = min(ans,dfs(i,j+1,k+1));
    }
    if(i < a.size()){
        ans = min(ans,1+dfs(i+1,j,k+1));
    }
    if(j <b.size()){
        ans = min(ans,1+dfs(i,j+1,k+1));
    }
    return ans;
}
void solve(){
    cin>>a>>b>>c;
   
    cout<<dfs()<<"\n";
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, l, r) for(int i=l;i<=r;i++)
const int MX = 1e3 + 5;
string a,b,c;
int dfs(int i=0,int j=0,int k=0){ 
    if(k == c.size()) return 0;
    int ans = 1e9;
    
    if(i < a.size() && a[i] == c[k]){
        ans = min(ans,dfs(i+1,j,k+1));
    }
    if(j < b.size() && b[j] == c[k]){
        ans = min(ans,dfs(i,j+1,k+1));
    }
    ans = min(ans,1+min(dfs(i+1,j,k+1),dfs(i,j+1,k+1)));
    return ans;
}
void solve(){
    cin>>a>>b>>c;
   
    cout<<dfs()<<"\n";
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, l, r) for(int i=l;i<=r;i++)
const int MX = 1e3 + 5;
string a,b,c;
int dfs(int i=0,int j=0,int k=0){ 
    if(k == c.size()) return 0;
    int ans = 1e9;
    
    if(i < a.size() && a[i] == c[k]){
        ans = min(ans,dfs(i+1,j,k+1));
    }
    if(j < b.size() && b[j] == c[k]){
        ans = min(ans,dfs(i,j+1,k+1));
    }
    if(i < a.size()){
        ans = min(ans,1+dfs(i+1,j,k+1));
    }
    if(j <b.size()){
        ans = min(ans,1+dfs(i,j+1,k+1));
    }
    return ans;
}
void solve(){
    cin>>a>>b>>c;
   
    cout<<dfs()<<"\n";
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, l, r) for(int i=l;i<=r;i++)
const int MX = 1e3 + 5;
int mem[MX][MX];
string a,b,c;
int dfs(int i=0,int j=0){ 
    int ans = 1e9;
    if(mem[i][j] != -1) return mem[i][j];
    if(i==a.size()){
        ans = 0;
        for(int k=j;k<b.size();k++) ans += (b[k] != c[i+k]);
    }
    else if(j==b.size()){
        ans = 0;
        for(int k=i;k<a.size();k++) ans += (a[k] != c[k+j]);
    }
    else ans = min(dfs(i+1,j) + (a[i] != c[i+j]),dfs(i,j+1) + (b[j] != c[i+j]));
    mem[i][j] = ans;
    return ans;
}
void solve(){
    cin>>a>>b>>c;
    for(int i=0;i<=a.size();i++){
        for(int j=0;j<=b.size();j++){
            mem[i][j] = -1;
        }
    }
    cout<<dfs()<<"\n";
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, l, r) for(int i=l;i<r;i++)
#define for0(i, r, l) for(int i=r;i>l;i--)
#define all(a) a.begin(),a.end()


void solve(){
    int l,r;
    cin>>l>>r;
    int t1 = 0, t2 = 0,t3 = 0;
    int t = __lg(r);
    for0(i,t,-1){
        if(t1 + (1<<i) <= r){
            t1 += (1<<i);
            if(t2 + (1<<i) - 1 < l){
                t2 += (1<<i);
            }
            if(t3 + (1<<i) - 1 < l){
                t3 += (1<<i);
            }
        }else if(t2 + (1<<i) <= r){
            t2 += (1<<i);
            if(t1 + (1<<i) - 1 < l){
                t1 += (1<<i);
            }
            if(t3 + (1<<i) - 1 < l){
                t3 += (1<<i);
            }
        }else if(t3 + (1<<i) <= r){
            t3 += (1<<i);
            if(t1 + (1<<i) - 1 < l){
                t1 += (1<<i);
            }
            if(t2 + (1<<i) - 1 < l){
                t2 += (1<<i);
            }
        }
    }
    cout<<t1<<" "<<t2<<" "<<t3<<"\n";

}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, l, r) for(int i=l;i<r;i++)
#define for0(i, r, l) for(int i=r;i>l;i--)
#define all(a) a.begin(),a.end()


void solve(){
    int l,r;
    cin>>l>>r;
    vector a(3,0);
    int y = __lg(r);
    for0(i,y,-1){
        sort(all(a));
        int t = 1<<i;
        if(a[0]+t<=r){
            a[0]+=t;
        }
        if(a[1]+t-1 < l){
            a[1]+=t;
        }
        if(a[2]+t-1 < l){
            a[2]+=t;
        }
    }
    sort(all(a));
    if(a[1] == a[2]) a[1]++;
    cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<"\n";
    //cout<<(a[0] ^ a[1]) + (a[1] ^ a[2]) + (a[0] ^ a[2])<<"\n";
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, l, r) for(int i=l;i<r;i++)
#define for0(i, r, l) for(int i=r;i>l;i--)
#define all(a) a.begin(),a.end()


void solve(){
    int l,r;
    cin>>l>>r;
    int t1 = 0, t2 = 0;
    int t = __lg(r);
    for0(i,t,-1){
        if(t1 + (1<<i) <= r){
            t1 += (1<<i);
            if(t2 + (1<<i) - 1 < l){
                t2 += (1<<i);
            }
        }else if(t2 + (1<<i) <= r){
            t2 += (1<<i);
            if(t1 + (1<<i) - 1 < l){
                t1 += (1<<i);
            }
        }
    }
    for(int i=l;i<=r;i++){
        if(i != t1 && i != t2){
            cout<<t1<<" "<<t2<<" "<<i<<"\n";
            //cout<<(t1^t2) + (t1^i) + (t2^i)<<"\n";
            return;
        }
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, l, r) for(int i=l;i<r;i++)
#define for0(i, r, l) for(int i=r;i>l;i--)
#define all(a) a.begin(),a.end()


void solve(){
    int l,r;
    cin>>l>>r;
    int t1 = 0, t2 = 0,t3 = 0;
    int t = __lg(r);
    for0(i,t,-1){
        if(t1 + (1<<i) <= r){
            t1 += (1<<i);
            if(t2 + (1<<i) - 1 < l){
                t2 += (1<<i);
            }
            if(t3 + (1<<i) - 1 < l){
                t3 += (1<<i);
            }
        }else if(t2 + (1<<i) <= r){
            t2 += (1<<i);
            if(t1 + (1<<i) - 1 < l){
                t1 += (1<<i);
            }
            if(t3 + (1<<i) - 1 < l){
                t3 += (1<<i);
            }
        }else if(t3 + (1<<i) <= r){
            t3 += (1<<i);
            if(t1 + (1<<i) - 1 < l){
                t1 += (1<<i);
            }
            if(t2 + (1<<i) - 1 < l){
                t2 += (1<<i);
            }
        }
    }
    cout<<t1<<" "<<t2<<" "<<t3<<"\n";

}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
    return 0;
}