ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
int _, n, ans, sum, a[51];
int main() {
	scanf("%d", &_);
	for (; _--; ) {
		ans = 0;
		scanf("%d", &n);
		for (int i = 1; i <= n; i++)
			scanf("%d", &a[i]), ans += a[i];
		for (; --n; ) {
			sum = 0;
			for (int i = 1; i <= n; i++)
				a[i] -= a[i + 1], sum += a[i];
			ans = max(ans, abs(sum));
		}
		printf("%d\n", ans);
	}
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
int _, n;
ll ans, sum, a[51];
int main() {
	scanf("%d", &_);
	for (; _--; ) {
		ans = 0;
		scanf("%d", &n);
		for (int i = 1; i <= n; i++)
			scanf("%lld", &a[i]), ans += a[i];
		for (int i = 1; i < n; i++) {
			sum = 0;
			for (int j = 1; i + j <= n; j++)
				a[j] -= a[j + 1], sum += a[j];
			if (sum < 0)
				sum *= -1;
			ans = max(ans, sum);
		}
		printf("%lld\n", ans);
	}
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
int _, n, ans, sum, a[51];
int main() {
	scanf("%d", &_);
	for (; _--; ) {
		sum = 0;
		scanf("%d", &n);
		for (int i = 1; i <= n; i++)
			scanf("%d", &a[i]), sum += a[i];
		if (n == 1) {
			printf("%d\n", a[1]);
			continue;
		}
		ans = abs(sum);
		for (; n > 1; --n) {
			sum = 0;
			for (int i = 1; i < n; i++)
				sum += (a[i] = a[i + 1] - a[i]);
			ans = max(ans, abs(sum));
		}
		printf("%d\n", ans);
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 2):
#include<bits/stdc++.h>
using namespace std;
void output(){
    int n;
    cin>>n;
    deque <int> d(n);
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        d.push_back(k);
    }
    while(d.size()!=1){
        if(d[0]>d[1]){
            cout<<"NO";
            return;
        }
        else if(d[0]<d[1]){
            d[1]-=d[0];
            d.pop_front();
        }
        else{
            d.pop_front();
            d.pop_front();
        }
    }
    cout<<"YES";
    
}

int main(){
    int t;
    cin>>t;
    while(t!=0){
        output();
        cout<<'\n';
        t--;
    }
    return 0;
  }

Submission (verdict: Runtime error on test 2):
#include<bits/stdc++.h>
using namespace std;
void output(){
   long long int n;
    cin>>n;
    deque <long long int> d(n);
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        d.push_back(k);
    }
    while(d.size()!=1){
        if(d[0]>d[1]){
            cout<<"NO";
            return;
        }
        else if(d[0]<d[1]){
            d[1]-=d[0];
            d.pop_front();
        }
        else{
            d.pop_front();
            d.pop_front();
        }
    }
    cout<<"YES";
    
}

int main(){
    int t;
    cin>>t;
    while(t!=0){
        output();
        cout<<'\n';
        t--;
    }
    return 0;
  }
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Runtime error on test 2):
#include<bits/stdc++.h>
using namespace std;
void output(){
    int n;
    cin>>n;
    deque <int> d(n);
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        d.push_back(k);
    }
    while(d.size()!=1){
        if(d[0]>d[1]){
            cout<<"NO";
            return;
        }
        else if(d[0]<d[1]){
            d[1]-=d[0];
            d.pop_front();
        }
        else{
            d.pop_front();
            d.pop_front();
        }
    }
    cout<<"YES";
    
}

int main(){
    int t;
    cin>>t;
    while(t!=0){
        output();
        cout<<'\n';
        t--;
    }
    return 0;
  }
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 2):
#include<bits/stdc++.h>
using namespace std;
void output(){
   long long int n;
    cin>>n;
    deque <long long int> d(n);
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        d.push_back(k);
    }
    while(d.size()!=1){
        if(d[0]>d[1]){
            cout<<"NO";
            return;
        }
        else if(d[0]<d[1]){
            d[1]-=d[0];
            d.pop_front();
        }
        else{
            d.pop_front();
            d.pop_front();
        }
    }
    cout<<"YES";
    
}

int main(){
    int t;
    cin>>t;
    while(t!=0){
        output();
        cout<<'\n';
        t--;
    }
    return 0;
  }

Submission (verdict: Runtime error on test 2):
#include<bits/stdc++.h>
using namespace std;
void output(){
   long long int n;
    cin>>n;
    deque <long long int> d;
    for(int i=0;i<n;i++){
        long long int k;
        cin>>k;
        d.push_back(k);
    }
    while(d.size()!=1){
        if(d[0]>d[1]){
            cout<<"NO";
            return;
        }
        else if(d[0]<d[1]){
            d[1]-=d[0];
            d.pop_front();
        }
        else{
            d.pop_front();
            d.pop_front();
        }
    }
    cout<<"YES";
    
}

int main(){
    int t;
    cin>>t;
    while(t!=0){
        output();
        cout<<'\n';
        t--;
    }
    return 0;
  }
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 2):
#include<bits/stdc++.h>
using namespace std;
void output(){
   long long int n;
    cin>>n;
    deque <long long int> d;
    for(int i=0;i<n;i++){
        long long int k;
        cin>>k;
        d.push_back(k);
    }
    while(d.size()!=1){
        if(d[0]>d[1]){
            cout<<"NO";
            return;
        }
        else if(d[0]<d[1]){
            d[1]-=d[0];
            d.pop_front();
        }
        else{
            d.pop_front();
            d.pop_front();
        }
    }
    cout<<"YES";
    
}

int main(){
    int t;
    cin>>t;
    while(t!=0){
        output();
        cout<<'\n';
        t--;
    }
    return 0;
  }

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
void output(){
   long long int n;
    cin>>n;
    deque <long long int> d;
    for(int i=0;i<n;i++){
        long long int k;
        cin>>k;
        d.push_back(k);
    }
    while(d.size()>1){
        if(d[0]>d[1]){
            cout<<"NO";
            return;
        }
        else if(d[0]<d[1]){
            d[1]-=d[0];
            d.pop_front();
        }
        else{
            d.pop_front();
            d.pop_front();
        }
    }
    cout<<"YES";
    
}

int main(){
    int t;
    cin>>t;
    while(t!=0){
        output();
        cout<<'\n';
        t--;
    }
    return 0;
  }
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


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

int main() {
    int test_cases;
    cin >> test_cases;
    while (test_cases-- > 0) {
        string s;
        cin >> s;
        int sum=0;
        for(int i=0;i<s.length();i++){
            sum+=s[i];
        }
        int count_2=0;
        int count_3=0;
        for(int i=0;i<s.length();i++){
            if(s[i]=='2'){
                count_2++;
            }
            if(s[i]=='3'){
                count_3++;
            }
        }
        if(sum%9==0){
            cout << "YES" << endl;
            continue;
        }
        else if(sum%9==1){
            if(count_2>=2||(count_2>=1&&count_3>=1)){
                cout << "YES" << endl;
            }
            else{
                cout << "NO" << endl;
            }
            continue;
        }
        else if(sum%9==2){
            if(count_2>=8||(count_2>=2&&count_3>=2)||(count_2>=5&&count_3>=1)){
                cout << "YES" << endl;
            }
            else{
                cout << "NO" << endl;
            }
            continue;
        }
        else if(sum%9==3){
            if(count_2>=3||count_3>=1){
                cout << "YES" << endl;
            }
            else{
                cout << "NO" << endl;
            }
            continue;
        }
        else if(sum%9==4){
            if(count_2>=7||(count_2>=1&&count_3>=2)||(count_2>=4&&count_3>=1)){
                cout << "YES" << endl;
            }
            else{
                cout << "NO" << endl;
            }
            continue;
        }
        else if(sum%9==5){
            if(count_2>=2){
                cout << "YES" << endl;
            }
            else{
                cout << "NO" << endl;
            }
            continue;
        }
        else if(sum%9==6){
            if(count_2>=6||(count_2>=3&&count_3>=1)||count_3>=2){
                cout << "YES" << endl;
            }
            else{
                cout << "NO" << endl;
            }
            continue;
        }
        else if(sum%9==7){
            if(count_2>=1){
                cout << "YES" << endl;
            }
            else{
                cout << "NO" << endl;
            }
            continue;
        }
        else if(sum%9==8){
            if(count_2>=5||(count_2>=2&&count_3>=1)){
                cout << "YES" << endl;
            }
            else{
                cout << "NO" << endl;
            }
            continue;
        }
    }
}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)


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

using namespace std;

#define fastio() ios::sync_with_stdio(false);cin.tie(nullptr);

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

#define rall(v) (v).rbegin(), (v).rend()

#define pb push_back

#define fi first

#define se second

#define ll long long

const long long LINF = 1e18;

const int MOD = 1000000007;  

#define debug(x) cerr << #x << '=';_print(x);cerr << endl;

void _print(int x) { cerr << x; }

void _print(long long x) { cerr << x; }

void _print(double x) { cerr << x; }

void _print(char x) { cerr << x; }

void _print(const string &x) { cerr << x; }

void _print(bool x) { cerr << (x ? '1' : '0'); }

template <typename T>

void _print(const vector<T> &v)

{cerr << '[';for (const auto &i : v){_print(i);cerr << ' ';}cerr << ']';}

template <typename T>

void _print(const set<T> &s){cerr << '{';for (const auto &i : s){_print(i);cerr << ' ';}cerr << '}';}

template <typename K, typename V>

void _print(const map<K, V> &m){cerr << '{'<<endl;for (const auto &p : m){cerr << '(';_print(p.first);cerr << ':';_print(p.second);cerr << ')';}cerr << endl<<'}';}

template <typename T1, typename T2>

void _print(const pair<T1, T2> &p){cerr << '(';_print(p.first);cerr << ',';_print(p.second);cerr << ')';}

ll mod_add(ll&a,ll&b,ll m) {return (a+b)%m;}

ll mod_mul(ll&a,ll&b, ll m) {return (a*b)%m;}

ll mod_sub(ll&a,ll&b,ll m) {return ((a-b)%m+m)%m;}

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

ll binExpo(ll a,ll n) {ll res=1;while(n) {if(n&1) {res=(res*a)%MOD;}a=(a*a)%MOD; n>>=1;}return res;}

ll modInv(ll a,ll mod) {return binExpo(a,mod-2);}

int N;

vector<ll>fact(N+2,0);

void calcFact() {fact[0]=1;fact[1]=1;for(ll i=2;i<=N;i++){fact[i]=mod_mul(fact[i-1],i,MOD);}}

ll ncr(ll n,ll r) {ll numr=fact[n];ll den=mod_mul(fact[n-r],fact[r],MOD);ll ans=(modInv(den,MOD)*numr)%MOD;return ans;}

/*<------------------------------------------------------------------------>*/

void solve() {

    ll n;

    cin>>n;

    string s;

    cin>>s;

    bool ok=1;

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

        if(s[i]=='.') continue;

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

            if(s[i]=='p' and  s[j]=='s') {

                ok=0;

                cout<<"NO"<<endl;

                return ;

            }

            if(s[j]=='p' and  s[i]=='s') {

                if(n-i+1 >= j+1) {

                    if(i>0) {

                        cout<<"NO"<<endl;

                        return ;

                    }

                }

            }



        }

    }

    cout<<"YES"<<endl;



}

int main()

{

    fastio()

    ll int t;

    cin >> t;

    while(t--) solve();

    return 0;

}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
#define int long long
using namespace std;

void test() {
    
    int n;
    cin >> n;
    
    if (n == 1) {
    	cout << n << '\n';
    	return;
	}
    
    vector <int> a(n);
	int sum = 0;
    
    
    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    	sum += a[i];
	}
	
	int ans = abs(sum);
	
	for (int i = 1; i < n; i++) {
		
		vector <int> t;
		sum = 0;
		
		for (int i = 1; i < a.size(); i++) {
			t.push_back(a[i] - a[i - 1]);
			sum += a[i] - a[i - 1];
		}
		
		a = t;
		
		ans = max(ans, abs(sum));
		
	}
	
	cout << ans << '\n';    
    return;
}

signed main() {
	
	int t;
	cin >> t;
	while (t--) test();
	
}


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

void test() {
    
    int n;
    cin >> n;
    
    vector <int> a(n);
	int sum = 0;
    
    
    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    	sum += a[i];
	}
	
    if (n == 1) {
    	cout << a[0] << '\n';
    	return;
	}
	
	int ans = abs(sum);
	
	
	while (a.size() > 1) {
		
		vector <int> t;
		sum = 0;
		
		for (int i = 1; i < a.size(); i++) {
			t.push_back(a[i] - a[i - 1]);
			sum += a[i] - a[i - 1];
		}
		
		a = t;
		
		ans = max(ans, abs(sum));
		
	}
	
	cout << ans << '\n';    
    return;
}

signed main() {
	
	int t;
	cin >> t;
	while (t--) test();
	
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

void test() {
    
    int n;
    cin >> n;
    
    vector <int> a(n);
	int sum = 0;
    
    
    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    	sum += a[i];
	}
	
    if (n == 1) {
    	cout << a[0] << '\n';
    	return;
	}
	
	int ans = abs(sum);
	
	
	while (a.size() > 1) {
		
		vector <int> t;
		sum = 0;
		
		for (int i = 1; i < a.size(); i++) {
			t.push_back(a[i] - a[i - 1]);
			sum += a[i] - a[i - 1];
		}
		
		a = t;
		
		ans = max(ans, abs(sum));
		
	}
	
	cout << ans << '\n';    
    return;
}

signed main() {
	
	int t;
	cin >> t;
	while (t--) test();
	
}


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

void test() {
    
    int n;
    cin >> n;
    
    vector <int> a(n);
	int sum = 0;
    
    
    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    	sum += a[i];
	}
	
	int ans = sum;
	
	
	while (a.size() > 1) {
		
		vector <int> t;
		sum = 0;
		
		for (int i = 1; i < a.size(); i++) {
			t.push_back(a[i] - a[i - 1]);
			sum += a[i] - a[i - 1];
		}
		
		a = t;
		
		ans = max(ans, abs(sum));
		
	}
	
	cout << ans << '\n';    
    return;
}

signed main() {
	
	int t;
	cin >> t;
	while (t--) test();
	
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
#define int long long
using namespace std;

void test() {
    
    int n;
    cin >> n;
    
    if (n == 1) {
    	cout << n << '\n';
    	return;
	}
    
    vector <int> a(n);
	int sum = 0;
    
    
    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    	sum += a[i];
	}
	
	int ans = abs(sum);
	
	for (int i = 1; i < n; i++) {
		
		vector <int> t;
		sum = 0;
		
		for (int i = 1; i < a.size(); i++) {
			t.push_back(a[i] - a[i - 1]);
			sum += a[i] - a[i - 1];
		}
		
		a = t;
		
		ans = max(ans, abs(sum));
		
	}
	
	cout << ans << '\n';    
    return;
}

signed main() {
	
	int t;
	cin >> t;
	while (t--) test();
	
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 16):
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int helper(int index1,int index2,int index3,int n,int m,int k,string &a,string&b,string &c,unordered_map<string,int>&mp){
    if(index1==n&&index2==m){
        return 0;
    }
    int taken=INT_MAX;
    int taken2=INT_MAX;
    string temp=to_string(index1)+"*"+to_string(index2)+"*"+to_string(index3);
    if(mp.find(temp)!=mp.end()){
        return mp[temp];
    }
    if(index1<n){
        if(a[index1]==c[index3]){
            taken=helper(index1+1,index2,index3+1,n,m,k,a,b,c,mp);
        }
        else taken=1+helper(index1+1,index2,index3+1,n,m,k,a,b,c,mp);
    }
    if(index2<m){
          if(b[index2]==c[index3]){
            taken2=helper(index1,index2+1,index3+1,n,m,k,a,b,c,mp);
        }
        else taken2=1+helper(index1,index2+1,index3+1,n,m,k,a,b,c,mp);
    }
    return mp[temp]=min(taken,taken2);
}
 void solve(){
string a,b,c;
cin >> a >> b >> c;
int n=a.size();
int m=b.size();
int k=c.size();
unordered_map<string,int>mp;
int ans=helper(0,0,0,n,m,k,a,b,c,mp);
cout << ans << endl;
 }
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int helper(int index1,int index2,int index3,int n,int m,int k,string &a,string&b,string &c,unordered_map<string,int>&mp){
    if(index1==n&&index2==m){
        return 0;
    }
    int taken=INT_MAX;
    int taken2=INT_MAX;
    string temp=to_string(index1)+"*"+to_string(index2);
    if(mp.find(temp)!=mp.end()){
        return mp[temp];
    }
    if(index1<n){
        if(a[index1]==c[index3]){
            taken=helper(index1+1,index2,index3+1,n,m,k,a,b,c,mp);
        }
        else taken=1+helper(index1+1,index2,index3+1,n,m,k,a,b,c,mp);
    }
    if(index2<m){
          if(b[index2]==c[index3]){
            taken2=helper(index1,index2+1,index3+1,n,m,k,a,b,c,mp);
        }
        else taken2=1+helper(index1,index2+1,index3+1,n,m,k,a,b,c,mp);
    }
    return mp[temp]=min(taken,taken2);
}
 void solve(){
string a,b,c;
cin >> a >> b >> c;
int n=a.size();
int m=b.size();
int k=c.size();
unordered_map<string,int>mp;
int ans=helper(0,0,0,n,m,k,a,b,c,mp);
cout << ans << endl;
 }
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int helper(int index1,int index2,int index3,int n,int m,int k,string &a,string&b,string &c){
    if(index1==n&&index2==m){
        return 0;
    }
    int taken=INT_MAX;
    int taken2=INT_MAX;
    if(index1<n){
        if(a[index1]==c[index3]){
            taken=helper(index1+1,index2,index3+1,n,m,k,a,b,c);
        }
        else taken=1+helper(index1+1,index2,index3+1,n,m,k,a,b,c);
    }
    if(index2<m){
          if(b[index2]==c[index3]){
            taken2=helper(index1,index2+1,index3+1,n,m,k,a,b,c);
        }
        else taken2=1+helper(index1,index2+1,index3+1,n,m,k,a,b,c);
    }
    return min(taken,taken2);
}
 void solve(){
string a,b,c;
cin >> a >> b >> c;
int n=a.size();
int m=b.size();
int k=c.size();
int ans=helper(0,0,0,n,m,k,a,b,c);
cout << ans << endl;
 }
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int helper(int index1,int index2,int index3,int n,int m,int k,string &a,string&b,string &c){
    if(index1==n&&index2==m){
        return 0;
    }
    int taken=INT_MAX;
    int taken2=INT_MAX;
    if(index1<n){
        if(a[index1]==c[index3]){
            taken=helper(index1+1,index2,index3+1,n,m,k,a,b,c);
        }
        else taken=1+helper(index1+1,index2,index3+1,n,m,k,a,b,c);
    }
    if(index2<m){
          if(b[index2]==c[index3]){
            taken2=helper(index1,index2+1,index3+1,n,m,k,a,b,c);
        }
        else taken2=1+helper(index1,index2+1,index3+1,n,m,k,a,b,c);
    }
    return min(taken,taken2);
}
 void solve(){
string a,b,c;
cin >> a >> b >> c;
int n=a.size();
int m=b.size();
int k=c.size();
int ans=helper(0,0,0,n,m,k,a,b,c);
cout << ans << endl;
 }
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 16):
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int helper(int index1,int index2,int index3,int n,int m,int k,string &a,string&b,string &c,unordered_map<string,int>&mp){
    if(index1==n&&index2==m){
        return 0;
    }
    int taken=INT_MAX;
    int taken2=INT_MAX;
    string temp=to_string(index1)+"*"+to_string(index2)+"*"+to_string(index3);
    if(mp.find(temp)!=mp.end()){
        return mp[temp];
    }
    if(index1<n){
        if(a[index1]==c[index3]){
            taken=helper(index1+1,index2,index3+1,n,m,k,a,b,c,mp);
        }
        else taken=1+helper(index1+1,index2,index3+1,n,m,k,a,b,c,mp);
    }
    if(index2<m){
          if(b[index2]==c[index3]){
            taken2=helper(index1,index2+1,index3+1,n,m,k,a,b,c,mp);
        }
        else taken2=1+helper(index1,index2+1,index3+1,n,m,k,a,b,c,mp);
    }
    return mp[temp]=min(taken,taken2);
}
 void solve(){
string a,b,c;
cin >> a >> b >> c;
int n=a.size();
int m=b.size();
int k=c.size();
unordered_map<string,int>mp;
int ans=helper(0,0,0,n,m,k,a,b,c,mp);
cout << ans << endl;
 }
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
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;

typedef long long ll;

const int MOD = 1e9 + 7;

vector<ll> factorial, inverse;

ll power(ll base, ll exp)

{

    ll res = 1;

    while (exp > 0)

    {

        if (exp % 2 == 1)

        {

            res = (res * base) % MOD;

        }

        base = (base * base) % MOD;

        exp /= 2;

    }

    return res;

}

void precompute(int n)

{

    factorial.resize(n + 1);

    inverse.resize(n + 1);

    factorial[0] = 1;

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

    {

        factorial[i] = (factorial[i - 1] * i) % MOD;

    }

    inverse[n] = power(factorial[n], MOD - 2);

    for (int i = n - 1; i >= 0; i--)

    {

        inverse[i] = (inverse[i + 1] * (i + 1)) % MOD;

    }

}

ll nCr(int n, int r)

{

    if (r > n || r < 0)

    {

        return 0;

    }

    return (factorial[n] * inverse[r] % MOD * inverse[n - r] % MOD) % MOD;

}



ll f(ll i,ll j,string a,string b,string s,ll n,ll m,vector<vector<ll>>&dp)

{

    if(dp[i][j]!=-1)

    {

        return dp[i][j];

    }

    if(i==n)

    {

        ll count=0;

        while(j!=m)

        {

            if(s[i+j]!=b[j])

            {

                count++;

            }

            j++;

        }

        return count;

    }

    if(j==m)

    {

        ll count=0;

        while(i!=n)

        {

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

            {

                count++;

            }

            i++;

        }

        return count;

    }

    if(s[i+j]==a[i])

    {

        if(s[i+j]!=b[j])

        return dp[i][j]=min(f(i+1,j,a,b,s,n,m,dp),f(i,j+1,a,b,s,n,m,dp)+1);        

    }

    if(s[i+j]==b[j])

    {

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

        return dp[i][j]=min(f(i,j+1,a,b,s,n,m,dp),f(i+1,j,a,b,s,n,m,dp)+1);

        if(s[i+j]==a[i])

        return dp[i][j]=min(f(i,j+1,a,b,s,n,m,dp),f(i+1,j,a,b,s,n,m,dp));

    }

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

    {

        if(s[i+j]!=b[j])

        return dp[i][j]=min(f(i,j+1,a,b,s,n,m,dp)+1,f(i+1,j,a,b,s,n,m,dp)+1);

    }

}

void solve()

{

    string a;

    string b;

    string s;

    cin>>a;

    cin>>b;

    cin>>s;

    ll n=a.length();

    ll m=b.length();

    vector<vector<ll>>dp(n+1,vector<ll>(m+1,-1));

    cout<<f(0,0,a,b,s,n,m,dp)<<endl;

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    ll t;

    cin >> t;

    while (t--)

    {

        solve();

    }

}