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


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

// Function to compute the Greatest Common Divisor (GCD)
ll gcd(ll x, ll y) {
    return y == 0 ? x : gcd(y, x % y);
}

// Function to compute the Least Common Multiple (LCM)
ll lcm(ll x, ll y) {
    return (x / gcd(x, y)) * y;
}
vector<int>gra[100];
void solve(int n,int m)
{
    vector<int>v(n+1,0);
    for(int i = 0;i<m;i++)
    {
        int x,y;
        cin>> x >> y;
        v[x]++,v[y]++;
    }
    int cen = 0, cnted=0;
    for(int i = 1;i<=n;i++)
    {
        if(v[i]==1)cnted++;
        else if(v[i]==m)cen++;
    }
    if(cen==1&&cnted==n-1)
    {
        cout << "star topology";
        return ;
    }
    bool bus = (m==n-1);
    int one = 0;
    int two = 0;
    for(int i= 1;i<=n;i++)
    {
        if(v[i]==1)one++;
        else if(v[i]==2)two++;
        else
        {
            bus = false;
            break;
        }
    }
    if(one==2&& two==n-2&& bus)
    {
        cout << "bus topology";
        return ;
    }
    bool ring = (n==m);
    for(int i = 1;i<=n;i++)
    {
        if(v[i]!=2)
        {
            ring = false;
            break;

        }

    }
    if(ring)
    {
        cout << "ring topology ";
        return ;
    }
    cout << "unknown topology ";

}

int main() {

    int t;
    cin >>  t;
    while(t--)
    {
        int n,l,r;
        cin>> n >> l >> r;
        int a[n];
        for(int &i:a)cin>>i;
        sort(a,a+n);
        int k  = r-l;
        int sum =0;
        for(int i = 0;i<=k;i++)
        {
            sum+=a[i];
        }
        cout << sum<< endl;
    }



    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 8):
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
const int N=4e5+5;

void solve(){
	string s;
	cin>>s;
	int tp=s.size()-1;
	string ans=s;
	while(1){
		int cnt=0;
		for(int i=s.size()-1;i>0;--i){
			if(s[i]>s[i-1]+1){
				s[i]--;
				cnt++;
				swap(s[i],s[i-1]);
			}
		}
	if(!cnt)break;
	}
	
	cout<<s<<'\n';
}

int main( ){
	ios::sync_with_stdio(0),cin.tie(0);
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
const int N=4e5+5;

void solve(){
	string s;
	cin>>s;
	int tp=s.size()-1;
	string ans=s;
	while(1){
		int cnt=0;
		for(int i=1;i<s.size();++i){
			if(s[i]>s[i-1]+1){
				s[i]--;
				cnt++;
				swap(s[i],s[i-1]);
			}
		}
		if(!cnt)break;
	}
	
	cout<<s<<'\n';
}

int main( ){
	ios::sync_with_stdio(0),cin.tie(0);
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 8):
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
const int N=4e5+5;

void solve(){
	string s;
	cin>>s;
	int tp=s.size()-1;
	string ans=s;
	while(1){
		int cnt=0;
		for(int i=s.size()-1;i>0;--i){
			
		if(s[i]>s[i-1]+1){
			s[i]--;
			cnt++;
			swap(s[i],s[i-1]);
		}
	}
	ans=max(ans,s);
	if(!cnt)break;
	}
	
	cout<<s<<'\n';
}

int main( ){
	ios::sync_with_stdio(0),cin.tie(0);
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}

Submission (verdict: Time limit exceeded on test 8):
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
const int N=4e5+5;

void solve(){
	string s;
	cin>>s;
	int tp=s.size()-1;
	string ans=s;
	while(1){
		int cnt=0;
		for(int i=s.size()-1;i>0;--i){
			if(s[i]>s[i-1]+1){
				s[i]--;
				cnt++;
				swap(s[i],s[i-1]);
			}
		}
	if(!cnt)break;
	}
	
	cout<<s<<'\n';
}

int main( ){
	ios::sync_with_stdio(0),cin.tie(0);
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 8):
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
const int N=4e5+5;

void solve(){
	string s;
	cin>>s;
	int tp=s.size()-1;
	string ans=s;
	while(1){
		int cnt=0;
		for(int i=s.size()-1;i>0;--i){
			
		if(s[i]>s[i-1]+1){
			s[i]--;
			cnt++;
			swap(s[i],s[i-1]);
		}
	}
	ans=max(ans,s);
	if(!cnt)break;
	}
	
	cout<<s<<'\n';
}

int main( ){
	ios::sync_with_stdio(0),cin.tie(0);
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int dp[1001][1001];
int f(string &a,string &b,string &c,int i,int j){
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(i==a.length()&&j==b.length())
    return dp[i][j]=0;
    if(i>a.length()||j>b.length())
    return 1e5;
    int min_one=INT_MAX;
    if(i!=a.length()&&a[i]==c[i+j])
    min_one=min(min_one,f(a,b,c,i+1,j));
    if(j!=b.length()&&b[j]==c[i+j])
    min_one=min(min_one,f(a,b,c,i,j+1));
    min_one=min(min_one,1+min(f(a,b,c,i+1,j),f(a,b,c,i,j+1)));
    return dp[i][j]=min_one;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        for(int i=0;i<1001;i++){
            for(int j=0;j<1001;j++){
                dp[i][j]=-1;
            }
        }
    }
}

Submission (verdict: Wrong answer on test 17):
#include<bits/stdc++.h>
using namespace std;
int dp[1001][1001];
int f(string &a,string &b,string &c,int i,int j){
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(i==a.length()&&j==b.length())
    return dp[i][j]=0;
    if(i>a.length()||j>b.length())
    return 1e5;
    int min_one=INT_MAX;
    if(i!=a.length()&&a[i]==c[i+j])
    min_one=min(min_one,f(a,b,c,i+1,j));
    if(j!=b.length()&&b[j]==c[i+j])
    min_one=min(min_one,f(a,b,c,i,j+1));
    min_one=min(min_one,1+min(f(a,b,c,i+1,j),f(a,b,c,i,j+1)));
    return dp[i][j]=min_one;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        for(int i=0;i<1001;i++){
            for(int j=0;j<1001;j++){
                dp[i][j]=-1;
            }
        }
        cout<<f(a,b,c,0,0)<<endl;
    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 17):
#include<bits/stdc++.h>
using namespace std;
int dp[2001][2001];
int f(string &a,string &b,string &c,int i,int j){
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(i==a.length()&&j==b.length())
    return dp[i][j]=0;
    if(i>a.length()||j>b.length())
    return 1e5;
    int min_one=INT_MAX;
    if(i!=a.length()&&a[i]==c[i+j])
    min_one=min(min_one,f(a,b,c,i+1,j));
    if(j!=b.length()&&b[j]==c[i+j])
    min_one=min(min_one,f(a,b,c,i,j+1));
    min_one=min(min_one,1+min(f(a,b,c,i+1,j),f(a,b,c,i,j+1)));
    return dp[i][j]=min_one;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        for(int i=0;i<1001;i++){
            for(int j=0;j<1001;j++){
                dp[i][j]=-1;
            }
        }
        cout<<f(a,b,c,0,0)<<endl;
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int dp[2001][2001];
int f(string &a,string &b,string &c,int i,int j){
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(i==a.length()&&j==b.length())
    return dp[i][j]=0;
    if(i>a.length()||j>b.length())
    return 1e5;
    int min_one=INT_MAX;
    if(i!=a.length()&&a[i]==c[i+j])
    min_one=min(min_one,f(a,b,c,i+1,j));
    if(j!=b.length()&&b[j]==c[i+j])
    min_one=min(min_one,f(a,b,c,i,j+1));
    min_one=min(min_one,1+min(f(a,b,c,i+1,j),f(a,b,c,i,j+1)));
    return dp[i][j]=min_one;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        for(int i=0;i<2001;i++){
            for(int j=0;j<2001;j++){
                dp[i][j]=-1;
            }
        }
        cout<<f(a,b,c,0,0)<<endl;
    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 17):
#include<bits/stdc++.h>
using namespace std;
int dp[1001][1001];
int f(string &a,string &b,string &c,int i,int j){
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(i==a.length()&&j==b.length())
    return dp[i][j]=0;
    if(i>a.length()||j>b.length())
    return 1e5;
    int min_one=INT_MAX;
    if(i!=a.length()&&a[i]==c[i+j])
    min_one=min(min_one,f(a,b,c,i+1,j));
    if(j!=b.length()&&b[j]==c[i+j])
    min_one=min(min_one,f(a,b,c,i,j+1));
    min_one=min(min_one,1+min(f(a,b,c,i+1,j),f(a,b,c,i,j+1)));
    return dp[i][j]=min_one;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        for(int i=0;i<1001;i++){
            for(int j=0;j<1001;j++){
                dp[i][j]=-1;
            }
        }
        cout<<f(a,b,c,0,0)<<endl;
    }
}

Submission (verdict: Wrong answer on test 17):
#include<bits/stdc++.h>
using namespace std;
int dp[2001][2001];
int f(string &a,string &b,string &c,int i,int j){
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(i==a.length()&&j==b.length())
    return dp[i][j]=0;
    if(i>a.length()||j>b.length())
    return 1e5;
    int min_one=INT_MAX;
    if(i!=a.length()&&a[i]==c[i+j])
    min_one=min(min_one,f(a,b,c,i+1,j));
    if(j!=b.length()&&b[j]==c[i+j])
    min_one=min(min_one,f(a,b,c,i,j+1));
    min_one=min(min_one,1+min(f(a,b,c,i+1,j),f(a,b,c,i,j+1)));
    return dp[i][j]=min_one;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        for(int i=0;i<1001;i++){
            for(int j=0;j<1001;j++){
                dp[i][j]=-1;
            }
        }
        cout<<f(a,b,c,0,0)<<endl;
    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int dp[1001][1001];
int f(string &a,string &b,string &c,int i,int j){
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(i>=a.length()||j>=b.length())
    return 1e5;
    int min_one=INT_MAX;
    if(a[i]==c[i+j])
    min_one=min(min_one,f(a,b,c,i+1,j));
    if(b[j]==c[i+j])
    min_one=min(min_one,f(a,b,c,i,j+1));
    min_one=min(min_one,1+min(f(a,b,c,i+1,j),f(a,b,c,i,j+1)));
    return dp[i][j]=min_one;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        for(int i=0;i<1001;i++){
            for(int j=0;j<1001;j++){
                dp[i][j]=-1;
            }
        }
        cout<<f(a,b,c,0,0)<<endl;
    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int dp[1001][1001];
int f(string &a,string &b,string &c,int i,int j){
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(i>=a.length()||j>=b.length())
    return 1e5;
    int min_one=INT_MAX;
    if(a[i]==c[i+j])
    min_one=min(min_one,f(a,b,c,i+1,j));
    if(b[j]==c[i+j])
    min_one=min(min_one,f(a,b,c,i,j+1));
    min_one=min(min_one,1+min(f(a,b,c,i+1,j),f(a,b,c,i,j+1)));
    return dp[i][j]=min_one;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        for(int i=0;i<1001;i++){
            for(int j=0;j<1001;j++){
                dp[i][j]=-1;
            }
        }
        cout<<f(a,b,c,0,0)<<endl;
    }
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int dp[1001][1001];
int f(string &a,string &b,string &c,int i,int j){
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(i==a.length()&&j==b.length())
    return dp[i][j]=0;
    if(i>a.length()||j>b.length())
    return 1e5;
    int min_one=INT_MAX;
    if(i!=a.length()&&a[i]==c[i+j])
    min_one=min(min_one,f(a,b,c,i+1,j));
    if(j!=b.length()&&b[j]==c[i+j])
    min_one=min(min_one,f(a,b,c,i,j+1));
    min_one=min(min_one,1+min(f(a,b,c,i+1,j),f(a,b,c,i,j+1)));
    return dp[i][j]=min_one;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        for(int i=0;i<1001;i++){
            for(int j=0;j<1001;j++){
                dp[i][j]=-1;
            }
        }
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


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

// segmentr tree template
// https://atcoder.jp/contests/abc382/submissions/60341342

#define ll long long 
#define lld long double
#define pll pair<long long, long long>
#define vll vector<ll>
#define vvll vector<vll>
#define vlld vector<lld>
#define vpll vector<pair<ll, ll>>
#define forn(i, n) for (int i = 1; i <= int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second
#define YES cout << "Yes\n"
#define NO cout << "No\n"
#define nl "\n"
#define mod 1000000007
// #define mod 998244353 


ll mod_add(ll a, ll b ) {a = a % mod; b = b % mod; return (((a + b) % mod) + mod) % mod;}
ll mod_mul(ll a, ll b ) {a = a % mod; b = b % mod; return (((a * b) % mod) + mod) % mod;}
ll power(ll a , ll b) { if(b == 0) return 1;ll res = power(a , b>>1);if(b & 1) return (res * res % mod) * a % mod;return res * res % mod;}
ll expo(ll a, ll b) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}


void solve() {   

    int n; cin>>n;
    vll v(n+10), vis(n+10,0);
    vpll ans;

    for( int i=1;i<=n;i++ ) {
        cin>>v[i];
    }

    for( int i=1;i<=n;i++ ) {
        vis[v[i]] = 1;
        for( int j=1;j<=n;j++ ) {
            if( v[i] == j ) continue;
            if( v[i] < j and vis[j] == 0  ) {
                ans.pb({j,v[i]});
                ans.pb({v[i],j});
            }
            if( v[i] < j and vis[j] == 1 ) {
                ans.pb({j,v[i]});
            }
        }
    }

    cout << ans.size() << nl;
    for( auto it : ans ) {
        cout << it.ff << " " << it.ss << nl ;
    }
    
}


void main2( ) {
     
    //  freopen("hps.in", "r", stdin);
    // freopen("hps.out", "w", stdout);

#ifndef ONLINE_JUDGE
     freopen("i1.txt" , "r" , stdin);
     freopen("output.txt", "w", stdout);
#endif

    int tt = 1;
    // cin >> tt;

    // genfact() ; 
    
    for( int i=1;i<=tt;i++ )  {
        // cout << "Case #" << i << ": " ; 
        solve(); 
    } 

}
 
// static void run_with_stack_size(void (*func)(void), size_t stsize) {
//     char *stack, *send;
//     stack = (char *)malloc(stsize);
//     send = stack + stsize - 16;
//     send = (char *)((uintptr_t)send / 16 * 16);
//     asm volatile(
//         "mov %%esp, (%0)\n"
//         "mov %0, %%esp\n"
//         :
//         : "r"(send));
//     func();
//     asm volatile("mov (%0), %%esp\n" : : "r"(send));
//     free(stack);
// }

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(0);

    // run_with_stack_size( main2 , 512 * 512 * 512 );
    
    main2() ; 

    return 0 ; 

   
}
Problem: 2050D - Digital string maximization
Language: PyPy 3

Previous submission (verdict: Wrong answer on test 1):
def recursive(a,begin):
    if begin==len(a):
        return
    max_val = a[begin]
    max_index = begin
    for i in range(begin, min(len(a), begin+8)):
        if max_val<(a[i] - (i-begin)):
            max_val= a[i]-i+begin
            max_index = i
    while max_index !=begin:
        a[max_index], a[max_index-1] = a[max_index-1],a[max_index]-1
        max_index-=1
def solve():
    n = input()
    a = list(map(int,n))
    begin = 0
    while begin<len(a):
        recursive(a,begin)
        begin+=1
    for i in a:
        print(i,end='')
x = int(input())
for i in range(x):
    solve()

Submission (verdict: Wrong answer on test 1):
def recursive(a,begin):
    if begin==len(a):
        return
    max_val = a[begin]
    max_index = begin
    for i in range(begin, min(len(a), begin+8)):
        if max_val<(a[i] - (i-begin)):
            max_val= a[i]-i+begin
            max_index = i
    while max_index !=begin:
        a[max_index], a[max_index-1] = a[max_index-1],a[max_index]-1
        max_index-=1
def solve():
    n = input()
    a = list(map(int,n))
    begin = 0
    while begin<len(a):
        recursive(a,begin)
        begin+=1
    for i in a:
        print(i,end='')
    print('\n')
x = int(input())
for i in range(x):
    solve()
Problem: 2050D - Digital string maximization
Language: PyPy 3

Previous submission (verdict: Wrong answer on test 3):
def recursive(a,begin):
    if begin==len(a):
        return
    max_val = a[begin]
    max_index = begin
    for i in range(begin, min(len(a), begin+8)):
        if max_val<(a[i] - (i-begin)):
            max_val= a[i]-i+begin
            max_index = i
    while max_index !=begin:
        a[max_index], a[max_index-1] = a[max_index-1],a[max_index]-1
        max_index-=1
def solve():
    n = input()
    a = list(map(int,n))
    begin = 0
    while begin<len(a):
        recursive(a,begin)
        begin+=1
    print(''.join(map(str, a)))
x = int(input())
for i in range(x):
    solve()

Submission (verdict: Accepted):
def recursive(a,begin):
    if begin==len(a):
        return
    max_val = a[begin]
    max_index = begin
    for i in range(begin, min(len(a), begin+9)):
        if max_val<(a[i] - (i-begin)):
            max_val= a[i]-i+begin
            max_index = i
    while max_index !=begin:
        a[max_index], a[max_index-1] = a[max_index-1],a[max_index]-1
        max_index-=1
def solve():
    n = input()
    a = list(map(int,n))
    begin = 0
    while begin<len(a):
        recursive(a,begin)
        begin+=1
    print(''.join(map(str, a)))
x = int(input())
for i in range(x):
    solve()
Problem: 2050D - Digital string maximization
Language: PyPy 3


Submission (verdict: Wrong answer on test 1):
def recursive(a,begin):
    if begin==len(a):
        return
    max_val = a[begin]
    max_index = begin
    for i in range(begin, min(len(a), begin+8)):
        if max_val<(a[i] - (i-begin)):
            max_val= a[i]-i+begin
            max_index = i
    while max_index !=begin:
        a[max_index], a[max_index-1] = a[max_index-1],a[max_index]-1
        max_index-=1
def solve():
    n = input()
    a = list(map(int,n))
    begin = 0
    while begin<len(a):
        recursive(a,begin)
        begin+=1
    for i in a:
        print(i,end='')
x = int(input())
for i in range(x):
    solve()
Problem: 2050D - Digital string maximization
Language: PyPy 3

Previous submission (verdict: Wrong answer on test 1):
def recursive(a,begin):
    if begin==len(a):
        return
    max_val = a[begin]
    max_index = begin
    for i in range(begin, min(len(a), begin+8)):
        if max_val<(a[i] - (i-begin)):
            max_val= a[i]-i+begin
            max_index = i
    while max_index !=begin:
        a[max_index], a[max_index-1] = a[max_index-1],a[max_index]-1
        max_index-=1
def solve():
    n = input()
    a = list(map(int,n))
    begin = 0
    while begin<len(a):
        recursive(a,begin)
        begin+=1
    for i in a:
        print(i,end='')
    print('\n')
x = int(input())
for i in range(x):
    solve()

Submission (verdict: Wrong answer on test 3):
def recursive(a,begin):
    if begin==len(a):
        return
    max_val = a[begin]
    max_index = begin
    for i in range(begin, min(len(a), begin+8)):
        if max_val<(a[i] - (i-begin)):
            max_val= a[i]-i+begin
            max_index = i
    while max_index !=begin:
        a[max_index], a[max_index-1] = a[max_index-1],a[max_index]-1
        max_index-=1
def solve():
    n = input()
    a = list(map(int,n))
    begin = 0
    while begin<len(a):
        recursive(a,begin)
        begin+=1
    print(''.join(map(str, a)))
x = int(input())
for i in range(x):
    solve()
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 16):
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<climits>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<queue>
#define ll long long int
using namespace std;

int solve(string a,string b,string c,int i,int j,int s,vector<vector<vector<int> > >&dp){
    if(i==a.size() && j==b.size()){
        if(s==1){
            if(a[i-1]!=c[i+j+1-2]){
                return dp[i][j][s]=1;
            }
            return  dp[i][j][s]=0;
        }
        if(b[j-1]!=c[i+j+1-2]){
            return  dp[i][j][s]=1;
        }
        return  dp[i][j][s]=0;
        
    }
    if(dp[i][j][s]!=-1){
        return dp[i][j][s];
    }
    if(s==1){
        int cmp=i+j+1-2;
        int add=0;
        if(a[i-1]!=c[cmp]){
            add=1;
        }
        int c1=1e9,c2=1e9;
        if(i+1<=a.size()-1+1){
            c1=add+solve(a,b,c,i+1,j,1,dp);
        }

        if(j+1<=b.size()-1+1){
            c2=add+solve(a,b,c,i,j+1,0,dp);
        }

        return  dp[i][j][s]=min(c1,c2);

        }
        int cmp=i+j+1-2;
        int add=0;
        if(b[j-1]!=c[cmp]){
            add=1;
        }
        int c1=1e9,c2=1e9;
        if(i+1<=a.size()-1+1){
            c1=add+solve(a,b,c,i+1,j,1,dp);
        }

        if(j+1<=b.size()-1+1){
            c2=add+solve(a,b,c,i,j+1,0,dp);
        }

        return  dp[i][j][s]=min(c1,c2);


    





}

int main(){
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int t=1;
     cin>>t;
     while(t--){
        string a;
        cin>>a;

        string b;
        cin>>b;

        string c;
        cin>>c;
        int n1=a.size();
        int n2=b.size();
        
        vector<vector<vector<int> > >dp1(n1+1,vector<vector<int> >(n2+1,vector<int>(2,-1)));
         vector<vector<vector<int> > >dp2(n1+1,vector<vector<int> >(n2+1,vector<int>(2,-1)));

        int ans1=solve(a,b,c,1,0,1,dp1);
        int ans2=solve(a,b,c,0,1,0,dp2);

        cout<<min(ans1,ans2)<<endl;


      
     
       
       
       
        




        
     }


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


Submission (verdict: Wrong answer on test 2):
#include<iostream>

#include <cmath>

#include <bits/stdc++.h>

using namespace std;

int main(){

    int t;

    cin>>t;

    vector<int> ans;

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        long long sum=0;

        vector<int> vec(n,0);

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

            cin>>vec[i];

        }

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

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

            sum+=vec[i];

        }

        ans.push_back(sum);

    }

    for(auto num:ans) cout<<num<<endl;

    return 0;

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

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

#include <cmath>

#include <bits/stdc++.h>

using namespace std;

int main(){

    int t;

    cin>>t;

    vector<int> ans;

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        long long sum=0;

        vector<int> vec(n,0);

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

            cin>>vec[i];

        }

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

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

            sum+=vec[i];

        }

        ans.push_back(sum);

    }

    for(auto num:ans) cout<<num<<endl;

    return 0;

}



Submission (verdict: Wrong answer on test 8):
#include<iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    vector<int> ans;
    while(t--){
        int n,l,r,x;
        cin>>n>>l>>r;
        vector<int> vec(n,0);
        vector<int> help(n,0);
        for(int i=0;i<n;i++){
            cin>>x;
            vec[i]=x;
            help[i]=x;
        }
        sort(vec.begin(), vec.begin()+r);
        sort(help.begin()+(l-1), help.end());
        int i=0, j=l-1;
        long long sum1=0, sum2=0;
        while(i<=(r-l)) sum1+=vec[i++];
        while(j<r) sum2+=help[j++];
        ans.push_back(min(sum1, sum2));
        
    }
    for(auto num:ans) cout<<num<<endl;
    return 0;
}