ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solve(int n, int l,int r, vector<int>&a){
  vector<int>nums1,nums2;
  vector<int>v=a;
  sort(v.begin(),v.end());
  ll ans=0;
  int i=0;
  while(i<r-l+1){
    ans+=v[i];
    i++;
  }
  return ans;
}
int main() {
    int t;
    cin >> t;
    while (t--) {
       int n,l,r;
       cin>>n>>l>>r;
       vector<int>a(n);
       for(int i=0;i<n;i++)
          cin>>a[i];
          
      int ans = solve(n,l,r,a);
      cout<<ans<<endl;
    }
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solve(int n, int l,int r, vector<int>&a){
   l--; r--;
   vector<int>x,y;
   for(int i=0;i<=r;i++){
     x.push_back(a[i]);
   }
   for(int i=l;i<n;i++){
      y.push_back(a[i]);
   }
   sort(x.begin(),x.end());
   sort(y.begin(),y.end());
   int s1,s2=0;
   for(int i=0;i<(r-l+1);i++){
     s1+=x[i];
     s2+=y[i];
   }
   return min(s1,s2);
}
int main() {
    int t;
    cin >> t;
    while (t--) {
       int n,l,r;
       cin>>n>>l>>r;
       vector<int>a(n);
       for(int i=0;i<n;i++)
          cin>>a[i];
          
      int ans = solve(n,l,r,a);
      cout<<ans<<endl;
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;

typedef long long ll;

ll solve(int n, int l,int r, vector<int>&a){

   l--; r--;

   vector<int>x,y;

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

     x.push_back(a[i]);

   }

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

      y.push_back(a[i]);

   }

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

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

   ll s1=0,s2=0;

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

     s1+=x[i];

     s2+=y[i];

   }

   return min(s1,s2);

}

int main() {

    int t;

    cin >> t;

    while (t--) {

       int n,l,r;

       cin>>n>>l>>r;

       vector<int>a(n);

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

          cin>>a[i];

          

      int ans = solve(n,l,r,a);

      cout<<ans<<endl;

    }

    return 0;

}





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

using namespace std;

typedef long long ll;

ll solve(ll n, ll l,ll r, vector<ll>&a){

   l--; r--;

   vector<ll>x,y;

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

     x.push_back(a[i]);

   }

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

      y.push_back(a[i]);

   }

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

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

   ll s1=0,s2=0;

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

     s1+=x[i];

     s2+=y[i];

   }

   return min(s1,s2);

}

int main() {

    int t;

    cin >> t;

    while (t--) {

       ll n,l,r;

       cin>>n>>l>>r;

       vector<ll>a(n);

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

          cin>>a[i];

          

      ll ans = solve(n,l,r,a);

      cout<<ans<<endl;

    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solve(int n, int l,int r, vector<int>&a){
   l--; r--;
   vector<int>x,y;
   for(int i=0;i<=r;i++){
     x.push_back(a[i]);
   }
   for(int i=l;i<n;i++){
      y.push_back(a[i]);
   }
   sort(x.begin(),x.end());
   sort(y.begin(),y.end());
   int s1=0,s2=0;
   for(int i=0;i<(r-l+1);i++){
     s1+=x[i];
     s2+=y[i];
   }
   return min(s1,s2);
}
int main() {
    int t;
    cin >> t;
    while (t--) {
       int n,l,r;
       cin>>n>>l>>r;
       vector<int>a(n);
       for(int i=0;i<n;i++)
          cin>>a[i];
          
      int ans = solve(n,l,r,a);
      cout<<ans<<endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

ll solve(int n, int l,int r, vector<int>&a){

   l--; r--;

   vector<int>x,y;

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

     x.push_back(a[i]);

   }

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

      y.push_back(a[i]);

   }

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

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

   ll s1=0,s2=0;

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

     s1+=x[i];

     s2+=y[i];

   }

   return min(s1,s2);

}

int main() {

    int t;

    cin >> t;

    while (t--) {

       int n,l,r;

       cin>>n>>l>>r;

       vector<int>a(n);

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

          cin>>a[i];

          

      int ans = solve(n,l,r,a);

      cout<<ans<<endl;

    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solve(int n, int l,int r, vector<int>&a){
  vector<int>nums1,nums2;
  vector<int>v=a;
  sort(v.begin(),v.end());
  ll ans=0;
  int i=0;
  while(i<r-l+1){
    ans+=v[i];
    i++;
  }
  return ans;
}
int main() {
    int t;
    cin >> t;
    while (t--) {
       int n,l,r;
       cin>>n>>l>>r;
       vector<int>a(n);
       for(int i=0;i<n;i++)
          cin>>a[i];
          
      int ans = solve(n,l,r,a);
      cout<<ans<<endl;
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
//197->817->861
//185->815
//11555->10321>10-121.
//33
int main(){
	   long long int t;
       cin >> t;
       while(t--){
           string a;
           cin>>a;
           int n=a.size();
           for(int ind=0;ind<n;ind++){
               int mm=INT_MIN;
               int ii=ind;
               for(int i=ind;i<n;i++){
                   if(mm<int(a[i]-'0')-i+ind){
                       mm=int(a[i]-'0')-i+ind;
                       ii=i;
                   }
                
               }
                 cout<<mm;
              for(int i=ii;i>ind;i--){
                  swap(a[i-1],a[i]);
              }
           }
           cout<<endl;
           
       }
       
}
   

	



Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
//197->817->861
//185->815
//11555->10321>10-121.
//33
int main(){
	   long long int t;
       cin >> t;
       while(t--){
           string a;
           cin>>a;
           int n=a.size();
           for(int ind=0;ind<n;ind++){
               int mm=INT_MIN;
               char mxx=a[ind];
               int ii=ind;
               for(int i=ind;i<n;i++){
                   if(mm<int(a[i]-'0')-i+ind){
                       mm=int(a[i]-'0')-i+ind;
                       ii=i;
                       //mxx=a[ii];
                   }
                
               }
                 if (ii != ind) {
                a = a.substr(0, ind) + char(mm+'0') + a.substr(ind, ii - ind) + a.substr(ii + 1);
            }
           }
           cout<<a<<endl;
           
       }
       
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
//197->817->861
//185->815
//11555->10321>10-121.
//33
int main(){
	   long long int t;
       cin >> t;
       while(t--){
           string a;
           cin>>a;
           int n=a.size();
           for(int ind=0;ind<n;ind++){
               int mm=INT_MIN;
               char mxx=a[ind];
               int ii=ind;
               for(int i=ind;i<n;i++){
                   if(mm<int(a[i]-'0')-i+ind){
                       mm=int(a[i]-'0')-i+ind;
                       ii=i;
                       //mxx=a[ii];
                   }
                
               }
                 if (ii != ind) {
                a = a.substr(0, ind) + char(mm+'0') + a.substr(ind, ii - ind) + a.substr(ii + 1);
            }
           }
           cout<<a<<endl;
           
       }
       
}
   

	



Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
//197->817->861
//185->815
//11555->10321>10-121.
//33
int main(){
	   long long int t;
       cin >> t;
       while(t--){
           string a;
           cin>>a;
           int n=a.size();
           for(int ind=0;ind<n;ind++){
               int mm=INT_MIN;
               int ii=ind;
               for(int i=ind;i<n;i++){
                   if(mm<int(a[i]-'0')-i+ind){
                       mm=int(a[i]-'0')-i+ind;
                       ii=i;
                   }
                
               }
                 cout<<mm;
             if(ii!=ind){ for(int i=ii;i>ind;i--){
                  swap(a[i-1],a[i]);
              }}
           }
           cout<<endl;
           
       }
       
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
//197->817->861
//185->815
//11555->10321>10-121.
//33
int main(){
	   long long int t;
       cin >> t;
       while(t--){
           string a;
           cin>>a;
           int n=a.size();
           for(int ind=0;ind<n;ind++){
               int mm=INT_MIN;
               int ii=ind;
               for(int i=ind;i<n;i++){
                   if(mm<int(a[i]-'0')-i+ind){
                       mm=int(a[i]-'0')-i+ind;
                       ii=i;
                   }
                
               }
                 cout<<mm;
             if(ii!=ind){ for(int i=ii;i>ind;i--){
                  swap(a[i-1],a[i]);
              }}
           }
           cout<<endl;
           
       }
       
}
   

	



Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
//197->817->861
//185->815
//11555->10321>10-121.
//33
int main(){
	   long long int t;
       cin >> t;
       while(t--){
           string x;
           cin>>x;
           int n=x.size();
		for(int i=0;i<n-1;i++){
			if(x[i]<x[i+1]-1){
				swap(x[i],x[i+1]);
				x[i]--;
				if(i>=1)
				i-=2;
			}
		}
		cout<<x<<endl;
           
       }
       
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
//197->817->861
//185->815
//11555->10321>10-121.
//33
int main(){
	   long long int t;
       cin >> t;
       while(t--){
           string a;
           cin>>a;
           int n=a.size();
           for(int ind=0;ind<n;ind++){
               int mm=INT_MIN;
               int ii=ind;
               for(int i=ind;i<n;i++){
                   if(mm<int(a[i]-'0')-i+ind){
                       mm=int(a[i]-'0')-i+ind;
                       ii=i;
                   }
                
               }
                 cout<<mm;
              for(int i=ii;i>ind;i--){
                  swap(a[i-1],a[i]);
              }
           }
           cout<<endl;
           
       }
       
}
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;
#define int long long
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int x,j,y;
        cin>>x>>y;
        if((y-x)==2)
        {
            cout<<y<<" "<<y-1<<" "<<y-2<<endl;
            continue;
        }
        int k=0;
        for(int i=30;i>=0;i--)
        {
            if(((1<<i)&y)!=0)
            {
                j=i;
                break;
            }
        }
        for(int i=j;i>=0;i--)
        {
            if(((1<<i)&x)!=0 && ((1<<i)&y)!=0)
            {
                k+=(1<<i);
            }
            else
            {
                break;
            }
        }
        x=x-k;
        y=y-k;
        int a,b,c;
        for(int i=30;i>=0;i--)
        {
            if((1<<i)>=x && (1<<i)<=y)
            {
                a=1<<i;
                b=a-1;
                c=a-2;
                if(c<x)
                {
                    c=y;
                }
                break;
            }
        }
        cout<<k+a<<" "<<k+b<<" "<<k+c<<endl;
        // " "<<((a^b)+(b^c)+(c^a))<<
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int x,j,y;
        cin>>x>>y;
        if((y-x)==2)
        {
            cout<<y<<" "<<y-1<<" "<<y-2<<endl;
            continue;
        }
        int k=0;
        for(int i=30;i>=0;i--)
        {
            if(((1<<i)&y)!=0)
            {
                j=i;
                break;
            }
        }
        for(int i=j;i>=0;i--)
        {
            if(((1<<i)&x)==((1<<i)&y) )
            {
                if(((1<<i)&x)!=0)
                {
                    k+=(1<<i);
                }
            }
            else
            {
                break;
            }
        }
        x=x-k;
        y=y-k;
        int a,b,c;
        for(int i=30;i>=0;i--)
        {
            if((1<<i)>=x && (1<<i)<=y)
            {
                a=1<<i;
                b=a-1;
                c=a-2;
                if(c<x)
                {
                    c=y;
                }
                break;
            }
        }
        cout<<k+a<<" "<<k+b<<" "<<k+c<<endl;
        // " "<<((a^b)+(b^c)+(c^a))<<
    }
    return 0;
}
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;
#define int long long
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int x,j,y;
        cin>>x>>y;
        // if((y-x)==2)
        // {
        //     cout<<y<<" "<<y-1<<" "<<y-2<<endl;
        //     continue;
        // }
        int k=0;
        for(int i=30;i>=0;i--)
        {
            if(((1<<i)&y)!=0)
            {
                j=i;
                break;
            }
        }
        for(int i=j;i>=0;i--)
        {
            if(((1<<i)&x)!=0 && ((1<<i)&y)!=0)
            {
                k+=(1<<i);
            }
            else
            {
                break;
            }
        }
        x=x-k;
        y=y-k;
        int a,b,c;
        for(int i=30;i>=0;i--)
        {
            if((1<<i)>=x && (1<<i)<=y)
            {
                a=1<<i;
                b=a-1;
                c=a-2;
                if(c<x)
                {
                    c=y;
                }
                break;
            }
        }
        cout<<k+a<<" "<<k+b<<" "<<k+c<<endl;
        // " "<<((a^b)+(b^c)+(c^a))<<
    }
    return 0;
}
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;
#define int long long
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int x,j,y;
        cin>>x>>y;
        // if((y-x)==2)
        // {
        //     cout<<y<<" "<<y-1<<" "<<y-2<<endl;
        //     continue;
        // }
        int k=0;
        for(int i=30;i>=0;i--)
        {
            if(((1<<i)&y)!=0)
            {
                j=i;
                break;
            }
        }
        for(int i=j;i>=0;i--)
        {
            if(((1<<i)&x)!=0 && ((1<<i)&y)!=0)
            {
                k+=(1<<i);
            }
            else
            {
                break;
            }
        }
        x=x-k;
        y=y-k;
        int a,b,c;
        for(int i=30;i>=0;i--)
        {
            if((1<<i)>=x && (1<<i)<=y)
            {
                a=1<<i;
                b=a-1;
                c=a-2;
                if(c<x)
                {
                    c=y;
                }
                break;
            }
        }
        cout<<k+a<<" "<<k+b<<" "<<k+c<<endl;
        // " "<<((a^b)+(b^c)+(c^a))<<
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int x,j,y;
        cin>>x>>y;
        if((y-x)==2)
        {
            cout<<y<<" "<<y-1<<" "<<y-2<<endl;
            continue;
        }
        int k=0;
        for(int i=30;i>=0;i--)
        {
            if(((1<<i)&y)!=0)
            {
                j=i;
                break;
            }
        }
        for(int i=j;i>=0;i--)
        {
            if(((1<<i)&x)!=0 && ((1<<i)&y)!=0)
            {
                k+=(1<<i);
            }
            else
            {
                break;
            }
        }
        x=x-k;
        y=y-k;
        int a,b,c;
        for(int i=30;i>=0;i--)
        {
            if((1<<i)>=x && (1<<i)<=y)
            {
                a=1<<i;
                b=a-1;
                c=a-2;
                if(c<x)
                {
                    c=y;
                }
                break;
            }
        }
        cout<<k+a<<" "<<k+b<<" "<<k+c<<endl;
        // " "<<((a^b)+(b^c)+(c^a))<<
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

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

// #define int long long
string a,b,c;
int dp[2010][1010];
int rec(int level, int level1)
{
    if(level == a.size() + b.size()) return 0;
    if(dp[level][level1]!=-1) return dp[level][level1];
    
    int ans = 1e9;
    if(level1 < a.size() && c[level] == a[level1])
    {
        ans = rec(level+1,level1+1);
    }
    if(level-level1 < b.size() && c[level] == b[level-level1])
    {
        ans = rec(level+1,level1);
    }
    else
    {
        if(level1< a.size()) ans = min(ans,1+rec(level+1,level1+1));
        if(level - level1 < b.size()) ans = min(ans,1+rec(level+1,level1));
    }
    
    // cout << ans << endl;
    
    return dp[level][level1] = ans;
}

int main() {
	// your code goes here
	int t; cin >> t; while(t--)
	{
	    memset(dp,-1,sizeof(dp));
	    cin >> a >> b >> c;
	    cout << rec(0,0) << endl;
	    
	}
	

}

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

// #define int long long
string a,b,c;
int dp[2010][1010];
int rec(int level, int level1)
{
    if(level == a.size() + b.size()) return 0;
    if(dp[level][level1]!=-1) return dp[level][level1];
    
    int ans = 1e9;
    if(level1 < a.size() && c[level] == a[level1])
    {
        ans = rec(level+1,level1+1);
        // ans = min(ans,1+rec(level+1,))
    }
    if(level-level1 < b.size() && c[level] == b[level-level1])
    {
        ans = rec(level+1,level1);
    }
    if(level1< a.size()) ans = min(ans,1+rec(level+1,level1+1));
    if(level - level1 < b.size()) ans = min(ans,1+rec(level+1,level1));
    
    // cout << ans << endl;
    
    return dp[level][level1] = ans;
}

int main() {
	// your code goes here
	int t; cin >> t; while(t--)
	{
	    memset(dp,-1,sizeof(dp));
	    cin >> a >> b >> c;
	    cout << rec(0,0) << endl;
	    
	}
	

}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


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

// #define int long long
string a,b,c;
int dp[2010][1010];
int rec(int level, int level1)
{
    if(level == a.size() + b.size()) return 0;
    if(dp[level][level1]!=-1) return dp[level][level1];
    
    int ans = 1e9;
    if(level1 < a.size() && c[level] == a[level1])
    {
        ans = rec(level+1,level1+1);
    }
    if(level-level1 < b.size() && c[level] == b[level-level1])
    {
        ans = rec(level+1,level1);
    }
    else
    {
        if(level1< a.size()) ans = min(ans,1+rec(level+1,level1+1));
        if(level - level1 < b.size()) ans = min(ans,1+rec(level+1,level1));
    }
    
    // cout << ans << endl;
    
    return dp[level][level1] = ans;
}

int main() {
	// your code goes here
	int t; cin >> t; while(t--)
	{
	    memset(dp,-1,sizeof(dp));
	    cin >> a >> b >> c;
	    cout << rec(0,0) << endl;
	    
	}
	

}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

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

// #define int long long
string a,b,c;
int dp[2010][1010];
int rec(int level, int level1)
{
    if(level == a.size() + b.size()) return 0;
    if(dp[level][level1]!=-1) return dp[level][level1];
    
    int ans = 1e9;
    if(level1 < a.size() && c[level] == a[level1])
    {
        ans = rec(level+1,level1+1);
        // ans = min(ans,1+rec(level+1,))
    }
    if(level-level1 < b.size() && c[level] == b[level-level1])
    {
        ans = rec(level+1,level1);
    }
    if(level1< a.size()) ans = min(ans,1+rec(level+1,level1+1));
    if(level - level1 < b.size()) ans = min(ans,1+rec(level+1,level1));
    
    // cout << ans << endl;
    
    return dp[level][level1] = ans;
}

int main() {
	// your code goes here
	int t; cin >> t; while(t--)
	{
	    memset(dp,-1,sizeof(dp));
	    cin >> a >> b >> c;
	    cout << rec(0,0) << endl;
	    
	}
	

}

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

// #define int long long
string a,b,c;
int dp[2010][1010];
int rec(int level, int level1)
{
    if(level == a.size() + b.size()) return 0;
    if(dp[level][level1]!=-1) return dp[level][level1];
    
    int ans = 1e9;
    if(level1 < a.size() && c[level] == a[level1])
    {
        ans = rec(level+1,level1+1);
        ans = min(ans,1+rec(level+1,level1+1));
    }
    if(level-level1 < b.size() && c[level] == b[level-level1])
    {
        ans = min(ans,rec(level+1,level1));
        ans = min(ans,1+rec(level+1,level1));
    }
    if(level1<a.size()) ans = min(ans,1+rec(level+1,level1+1));
    if(level - level1 < b.size()) ans = min(ans,1+rec(level+1,level1));
    
    // cout << ans << endl;
    
    return dp[level][level1] = ans;
}

int main() {
	// your code goes here
	int t; cin >> t; while(t--)
	{
	    memset(dp,-1,sizeof(dp));
	    cin >> a >> b >> c;
	    cout << rec(0,0) << endl;
	    
	}
	

}