ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 1):
#include "bits/stdc++.h"

using namespace std;

int n, m;
multiset < int > a, b;

bool transform(int x) {
    if (x < 2) {
        return false;
    }
    int x1 = x / 2;
    int x2 = x - x1;
    bool px1 = false;
    bool px2 = false;
    if (a.find(x1) != a.end()) {
        a.erase(a.find(x1));
        px1 = true;
    }
    else {
        px1 = transform(x1);
    }
    if (a.find(x2) != a.end()) {
        a.erase(a.find(x2));
        px2 = true;
    }
    else {
        px2 = transform(x2);
    }
    return px1 && px2;
}

int main() {
    int t;
    scanf("%d", & t);
    while (t--) {
        scanf("%d %d", & n, & m);
        a.clear();
        b.clear();
        for (int i = 1; i <= n; i++) {
            int ai;
            scanf("%d", & ai);
            a.insert(ai);
        }
        for (int i = 1; i <= m; i++) {
            int bi;
            scanf("%d", & bi);
            if (a.find(bi) != a.end()) {
                a.erase(a.find(bi));
            }
            else {
                b.insert(bi);
            }
        }
        bool poss = true;
        for (auto it: b) {
            if (!transform(it)) {
                poss = false;
                break;
            }
        }
        if (b.empty() && !a.empty()) {
            poss = false;
        }
        if (poss) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    return 0;
}

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

using namespace std;

int n, m;
multiset < int > a, b;

bool transform(int x) {
    if (x < 2) {
        return false;
    }
    int x1 = x / 2;
    int x2 = x - x1;
    bool px1 = false;
    bool px2 = false;
    if (a.find(x1) != a.end()) {
        a.erase(a.find(x1));
        px1 = true;
    }
    else {
        px1 = (int) a.size() > 1 && transform(x1);
    }
    if (a.find(x2) != a.end()) {
        a.erase(a.find(x2));
        px2 = true;
    }
    else {
        px2 = (int) a.size() > 1 && transform(x2);
    }
    return px1 && px2;
}

int main() {
    int t;
    scanf("%d", & t);
    while (t--) {
        scanf("%d %d", & n, & m);
        a.clear();
        b.clear();
        for (int i = 1; i <= n; i++) {
            int ai;
            scanf("%d", & ai);
            a.insert(ai);
        }
        for (int i = 1; i <= m; i++) {
            int bi;
            scanf("%d", & bi);
            if (a.find(bi) != a.end()) {
                a.erase(a.find(bi));
            }
            else {
                b.insert(bi);
            }
        }
        bool poss = true;
        for (auto it: b) {
            if (!transform(it)) {
                poss = false;
                break;
            }
        }
        if (b.empty() && !a.empty()) {
            poss = false;
        }
        if (poss) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"

using namespace std;

int n, m;
multiset < int > a, b;

bool transform(int x) {
    if (x < 2) {
        return false;
    }
    int x1 = x / 2;
    int x2 = x - x1;
    bool px1 = false;
    bool px2 = false;
    if (a.find(x1) != a.end()) {
        a.erase(a.find(x1));
        px1 = true;
    }
    else {
        px1 = (int) a.size() > 1 && transform(x1);
    }
    if (a.find(x2) != a.end()) {
        a.erase(a.find(x2));
        px2 = true;
    }
    else {
        px2 = (int) a.size() > 1 && transform(x2);
    }
    return px1 && px2;
}

int main() {
    int t;
    scanf("%d", & t);
    while (t--) {
        scanf("%d %d", & n, & m);
        a.clear();
        b.clear();
        for (int i = 1; i <= n; i++) {
            int ai;
            scanf("%d", & ai);
            a.insert(ai);
        }
        for (int i = 1; i <= m; i++) {
            int bi;
            scanf("%d", & bi);
            if (a.find(bi) != a.end()) {
                a.erase(a.find(bi));
            }
            else {
                b.insert(bi);
            }
        }
        bool poss = true;
        for (auto it: b) {
            if (!transform(it)) {
                poss = false;
                break;
            }
        }
        if (b.empty() && !a.empty()) {
            poss = false;
        }
        if (poss) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 5):
#include "bits/stdc++.h"

using namespace std;

int n, m;
multiset < int > a, b;

bool transform(int x) {
    if (x < 2) {
        return false;
    }
    int x1 = x / 2;
    int x2 = x - x1;
    bool px1 = false;
    bool px2 = false;
    if (a.find(x1) != a.end()) {
        a.erase(a.find(x1));
        px1 = true;
    }
    else {
        px1 = (int) a.size() > 1 && transform(x1);
    }
    if (a.find(x2) != a.end()) {
        a.erase(a.find(x2));
        px2 = true;
    }
    else {
        px2 = (int) a.size() > 1 && transform(x2);
    }
    return px1 && px2;
}

int main() {
    int t;
    scanf("%d", & t);
    while (t--) {
        scanf("%d %d", & n, & m);
        a.clear();
        b.clear();
        for (int i = 1; i <= n; i++) {
            int ai;
            scanf("%d", & ai);
            a.insert(ai);
        }
        for (int i = 1; i <= m; i++) {
            int bi;
            scanf("%d", & bi);
            if (a.find(bi) != a.end()) {
                a.erase(a.find(bi));
            }
            else {
                b.insert(bi);
            }
        }
        bool poss = true;
        for (auto it: b) {
            if (!transform(it)) {
                poss = false;
                break;
            }
        }
        if (!a.empty()) {
            poss = false;
        }
        if (poss) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 1):
#include "bits/stdc++.h"

using namespace std;

int n, m;
multiset < int > a, b;

bool transform(int x) {
    if (x < 2) {
        return false;
    }
    int x1 = x / 2;
    int x2 = x - x1;
    bool px1 = false;
    bool px2 = false;
    if (a.find(x1) != a.end()) {
        a.erase(a.find(x1));
        px1 = true;
    }
    else {
        px1 = transform(x1);
    }
    if (a.find(x2) != a.end()) {
        a.erase(a.find(x2));
        px2 = true;
    }
    else {
        px2 = transform(x2);
    }
    return px1 && px2;
}

int main() {
    int t;
    scanf("%d", & t);
    while (t--) {
        scanf("%d %d", & n, & m);
        a.clear();
        b.clear();
        for (int i = 1; i <= n; i++) {
            int ai;
            scanf("%d", & ai);
            a.insert(ai);
        }
        for (int i = 1; i <= m; i++) {
            int bi;
            scanf("%d", & bi);
            if (a.find(bi) != a.end()) {
                a.erase(a.find(bi));
            }
            else {
                b.insert(bi);
            }
        }
        bool poss = true;
        for (auto it: b) {
            if (!transform(it)) {
                poss = false;
                break;
            }
        }
        if (b.empty() && !a.empty()) {
            poss = false;
        }
        if (poss) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include "bits/stdc++.h"

using namespace std;

int n, m;
multiset < int > a, b;

bool transform(int x) {
    if (x < 2) {
        return false;
    }
    int x1 = x / 2;
    int x2 = x - x1;
    bool px1 = false;
    bool px2 = false;
    if (a.find(x1) != a.end()) {
        a.erase(a.find(x1));
        px1 = true;
    }
    else {
        px1 = (int) a.size() > 1 && transform(x1);
    }
    if (a.find(x2) != a.end()) {
        a.erase(a.find(x2));
        px2 = true;
    }
    else {
        px2 = (int) a.size() > 1 && transform(x2);
    }
    return px1 && px2;
}

int main() {
    int t;
    scanf("%d", & t);
    while (t--) {
        scanf("%d %d", & n, & m);
        a.clear();
        b.clear();
        for (int i = 1; i <= n; i++) {
            int ai;
            scanf("%d", & ai);
            a.insert(ai);
        }
        for (int i = 1; i <= m; i++) {
            int bi;
            scanf("%d", & bi);
            if (a.find(bi) != a.end()) {
                a.erase(a.find(bi));
            }
            else {
                b.insert(bi);
            }
        }
        bool poss = true;
        for (auto it: b) {
            if (!transform(it)) {
                poss = false;
                break;
            }
        }
        if (!a.empty()) {
            poss = false;
        }
        if (poss) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    return 0;
}

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

using namespace std;

int n, m;
multiset < int > a, b;

int main() {
    int t;
    scanf("%d", &t);
    while ( t-- ) {
        scanf("%d %d", &n, &m);
        a.clear();
        b.clear();
        for(int i = 1 ; i <= n ; i++) {
            int ai;
            scanf("%d", &ai);
            a.insert(ai);
        }
        for(int i = 1 ; i <= m ; i++) {
            int bi;
            scanf("%d", &bi);
            b.insert(bi);
        }
        bool poss = true;
        int msplit = 0;
        while(!b.empty() && !a.empty()) {
            int ma = *a.rbegin();
            int mb = *b.rbegin();
            if(ma > mb) {
                poss = false;
                break;
            }
            else if(ma == mb) {
                a.erase(a.find(ma));
                b.erase(b.find(mb));
            }
            else {
                if(msplit > (n - m)) {
                    poss = false;
                    break;
                }
                int u = mb / 2;
                int v = mb - u;
                b.erase(b.find(mb));
                b.insert(u);
                b.insert(v);
                msplit++;
            }
        }
        if(!a.empty() || !b.empty()) {
            poss = false;
        }
        if(poss) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<long> a(n);
        for (int i = 0; i < n; i++){
            cin >> a[i];
        }
        long S = 0;
        for (int i = 0; i < n; i++){
            if(i % 2 == 0)
                S += a[i];
            else
                S -= a[i];
        }
 
        bool p = false;
        if(n % 2 == 0){
            if(S <= 0 && S >= -a[n-1])
                p = true;
        } else {
            if(S >= 0 && S <= a[n-1])
                p = true;
        }
 
        cout << (p ? "YES" : "NO") << "\n";
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    while(t--){
        int n; 
        cin >> n;
        vector<long> a(n);
        for (int i = 0; i < n; i++){
            cin >> a[i];
        }
        bool sorted = true;
        for (int i = 1; i < n; i++){
            if(a[i-1] > a[i]){
                sorted = false;
                break;
            }
        }
        if(sorted){
            cout << "YES" << "\n";
            continue;
        }
        long S = 0;
        for (int i = 0; i < n; i++){
            if(i % 2 == 0)
                S += a[i];
            else
                S -= a[i];
        }
        
        bool p = false;
        if(n % 2 == 1){
            if(S >= 0 && S <= a[n-1])
                p = true;
        } else {
            if(a[0] <= a[1] && (S >= -a[n-1] && S <= 0))
                p = true;
        }
        
        cout << (p ? "YES" : "NO") << "\n";
    }
    return 0;
}


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

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

    int t;
    cin >> t;
    while(t--){
        int n; 
        cin >> n;
        vector<long> a(n);
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }

        bool p = true;
        for(int i = n - 1; i >= 1; i--){
            if(a[i-1] > a[i]){
                long x = a[i-1] - a[i];
                int id = i - 2; 
                
                if(id < 0){  
                    p = false;
                    break;
                }

                a[id] -= x;  
                a[i-1] = a[i];   

                if(a[id] < 0){  
                    p = false;
                    break;
                }
            }
        }

        if(p){
            for(int i = 0; i + 1 < n; i++){
                if(a[i] > a[i+1]){
                    p = false;
                    break;
                }
            }
        }

        cout << (p ? "YES\n" : "NO\n");
    }

    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<long> a(n);
        for (int i = 0; i < n; i++){
            cin >> a[i];
        }
        long S = 0;
        for (int i = 0; i < n; i++){
            if(i % 2 == 0)
                S += a[i];
            else
                S -= a[i];
        }
 
        bool p = false;
        if(n % 2 == 0){
            if(S <= 0 && S >= -a[n-1])
                p = true;
        } else {
            if(S >= 0 && S <= a[n-1])
                p = true;
        }
 
        cout << (p ? "YES" : "NO") << "\n";
    }
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    while(t--){
        int n; 
        cin >> n;
        vector<long> a(n);
        for (int i = 0; i < n; i++){
            cin >> a[i];
        }
        bool sorted = true;
        for (int i = 1; i < n; i++){
            if(a[i-1] > a[i]){
                sorted = false;
                break;
            }
        }
        if(sorted){
            cout << "YES" << "\n";
            continue;
        }
        long S = 0;
        for (int i = 0; i < n; i++){
            if(i % 2 == 0)
                S += a[i];
            else
                S -= a[i];
        }
        
        bool p = false;
        if(n % 2 == 1){
            if(S >= 0 && S <= a[n-1])
                p = true;
        } else {
            if(a[0] <= a[1] && (S >= -a[n-1] && S <= 0))
                p = true;
        }
        
        cout << (p ? "YES" : "NO") << "\n";
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


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

using namespace std;



#ifdef LOCAL

#include "debug.h"

#else

#define debug()

#define db(x)

#endif



#define INF 1e18

#define endl '\n'

#define ff first

#define ss second

#define pb push_back

#define int long long

#define mod 1000000007

#define pii  2 * acos(0.0)

#define double long double

#define sz(x) ((int)(x).size())

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

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

#define deci(x) cout << fixed << setprecision(x);

#define rmv(x,a) x.erase(remove(x.begin(),x.end(),a),x.end())

#define unq(x) {x.erase(unique(x.begin(),x.end()),x.end());}

#define shera() ios_base::sync_with_stdio(1);cin.tie(NULL);cout.tie(NULL)

template<typename T1>istream &operator>>(istream &cin, vector<T1>&a) {for (auto&x : a)cin >> x; return cin;}





int32_t main() {

    shera();

    debug();



    int tc; tc = 1;

    cin >> tc;

    for (int ii = 1; ii <= tc; ii++) {



        int n, m ; cin >> n >> m;

        vector<int>a(n); cin >> a;

        vector<int>b(m); cin >> b;

        map<int, int>mp;

        priority_queue<int, vector<int>, greater<int>>as;



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

            mp[b[i]]++;

        }



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

            if (!mp[a[i]]) {

                as.push(a[i]);

            }

            else {

                mp[a[i]]--;

            }

        }

        db(as)



        while (!as.empty()) {

            int x1 = as.top();

            as.pop();

            db(x1)

            if (mp[x1] ) {

                mp[x1]--;

                continue;

            }

            if (as.empty()) {

                as.push( x1);

                break;

            }

            int x2 = as.top();

            as.pop();



            if (x2 - x1 > 1)break;

            as.push(x2 + x1);

        }

        bool ok = 0;

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

            if (mp[b[i]])ok = 1;

        }



        if (!ok && as.empty())cout << "Yes" << endl;

        else cout << "No" << endl;













    }



    return 0;

}
Problem: 2057B - Gorilla and the Exam
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; 
typedef pair<int,int> PII;
const int N=1e5+10;
PII a[N];
int n,k;
void solve(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		a[i].first=0;
	}
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		a[x].first++;
		a[x].second=x;
	}
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(k>=a[i].first){
			k=k-a[i].first;
		}else{
			ans=n-i+1;
			break;
		}
	}
	printf("%d\n",max(ans,1));
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) solve();
} 


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
typedef pair<int,int> PII;
const int N=1e5+10;
int n,k;
void solve(){
	scanf("%d%d",&n,&k);
	map<int,int> mp;
	int mx=0;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		mp[x]++;
	}
	vector<int> v;
	for(auto &a:mp) v.push_back(a.second);
	sort(v.begin(),v.end());
	for(int i=0;i<v.size()-1;i++,k-=v[i]){
		if(k<v[i]){
			printf("%d\n",v.size()-i);
			return;
		}
	}
	puts("1");
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) solve();
}
Problem: 2057B - Gorilla and the Exam
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; 
typedef pair<int,int> PII;
const int N=1e5+10;
int n,k;
void solve(){
	scanf("%d%d",&n,&k);
	map<int,int> mp;
	int mx=0;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		mp[x]++;
	}
	vector<int> v;
	for(auto &a:mp) v.push_back(a.second);
	sort(v.begin(),v.end());
	for(int i=0;i<v.size()-1;i++,k-=v[i]){
		if(k<v[i]){
			printf("%d\n",v.size()-i);
			return;
		}
	}
	puts("1");
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) solve();
} 


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
typedef pair<int,int> PII;
const int N=1e5+10;
int n,k;
void solve(){
	scanf("%d%d",&n,&k);
	map<int,int> mp;
	int mx=0;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		mp[x]++;
	}
	vector<int> v;
	for(auto &a:mp) v.push_back(a.second);
	sort(v.begin(),v.end());
	int m=v.size();
	for(int i=0;i<m-1;i++){
		if(k<v[i]){
			printf("%d\n",m-i);
			return;
		}
		k-=v[i];
	}
	puts("1");
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) solve();
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
typedef pair<int,int> PII;
const int N=1e5+10;
PII a[N];
int n,k;
void solve(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		a[i].first=0;
	}
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		a[x].first++;
		a[x].second=x;
	}
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(k>=a[i].first){
			k=k-a[i].first;
		}else{
			ans=n-i+1;
			break;
		}
	}
	printf("%d\n",max(ans,1));
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) solve();
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 6):
#include<bits/stdc++.h>


using namespace std;
typedef long long LL;
#define int long long
typedef pair<int,int> PII;	
const int N=2000010;
void solve(){
	string a,b,x;
	cin>>a>>b>>x;
	x="."+x;
	a="."+a;
	b="."+b;
	std::vector<vector<int>>dp(a.size()+10,vector<int>(b.size()+10,1e18));
	int n=x.size();
	dp[0][0]=0;
	for(int i=1;i<n;i++){
		// if(i<b.size())dp[0][i]=min(dp[0][i],dp[0][i-1]+(b[i]!=x[i]));
		for(int j=1;j<=min(i,(int)a.size()-1);j++){
			dp[j][i-j]=min(dp[j][i-j],dp[j-1][i-j]+1);
			if(x[i]==a[j]){
				dp[j][i-j]=min(dp[j][i-j],dp[j-1][i-j]);
			}

		}
		for(int j=1;j<=min(i,(int)b.size()-1);j++){
			dp[i-j][j]=min(dp[i-j][j],dp[i-j][j-1]+1);
			if(x[i]==b[j]){
				dp[i-j][j]=min(dp[i-j][j],dp[i-j][j-1]);
			}

		}
		// cout<<dp[0][1]<<" "<<dp[1][0]<<"\n";
	}
	cout<<dp[a.size()-1][b.size()-1]<<"\n";
}
signed main(){
	 ios::sync_with_stdio(0);
    cin.tie(0) , cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
    }
}


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


using namespace std;
typedef long long LL;
#define int long long
typedef pair<int,int> PII;	
const int N=2000010;
void solve(){
	string a,b,x;
	cin>>a>>b>>x;
	x="."+x;
	a="."+a;
	b="."+b;
	std::vector<vector<int>>dp(x.size()+10,vector<int>(x.size()+10,1e18));
	int n=x.size();
	dp[0][0]=0;
	for(int i=1;i<n;i++){
		// if(i<b.size())dp[0][i]=min(dp[0][i],dp[0][i-1]+(b[i]!=x[i]));
		for(int j=1;j<=min(i,(int)a.size()-1);j++){
			dp[j][i-j]=min(dp[j][i-j],dp[j-1][i-j]+1);
			if(x[i]==a[j]){
				dp[j][i-j]=min(dp[j][i-j],dp[j-1][i-j]);
			}

		}
		for(int j=1;j<=min(i,(int)b.size()-1);j++){
			dp[i-j][j]=min(dp[i-j][j],dp[i-j][j-1]+1);
			if(x[i]==b[j]){
				dp[i-j][j]=min(dp[i-j][j],dp[i-j][j-1]);
			}

		}
		// cout<<dp[0][1]<<" "<<dp[1][0]<<"\n";
	}
	cout<<dp[a.size()-1][b.size()-1]<<"\n";
}
signed main(){
	 ios::sync_with_stdio(0);
    cin.tie(0) , cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
    }
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Runtime error on test 6):
#include<bits/stdc++.h>


using namespace std;
typedef long long LL;
#define int long long
typedef pair<int,int> PII;	
const int N=2000010;
int a[N],res[N],res2[N];
	int n,m;
void solve(){
	string a,b,x;
	cin>>a>>b>>x;
	x="."+x;
	a="."+a;
	b="."+b;
	std::vector<vector<int>>dp(a.size()+10,vector<int>(b.size()+10,1e18));
	int n=x.size();
	dp[0][0]=0;
	for(int i=1;i<n;i++){
		// if(i<b.size())dp[0][i]=min(dp[0][i],dp[0][i-1]+(b[i]!=x[i]));
		for(int j=1;j<=min(i,(int)a.size()-1);j++){
			dp[j][i-j]=min(dp[j][i-j],dp[j-1][i-j]+1);
			if(x[i]==a[j]){
				dp[j][i-j]=min(dp[j][i-j],dp[j-1][i-j]);
			}

		}
		for(int j=1;j<=min(i,(int)b.size()-1);j++){
			dp[i-j][j]=min(dp[i-j][j],dp[i-j][j-1]+1);
			if(x[i]==b[j]){
				dp[i-j][j]=min(dp[i-j][j],dp[i-j][j-1]);
			}

		}
		// cout<<dp[0][1]<<" "<<dp[1][0]<<"\n";
	}
	cout<<dp[a.size()-1][b.size()-1]<<"\n";
}
signed main(){
	 ios::sync_with_stdio(0);
    cin.tie(0) , cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
    }
}