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

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define pii pair <int, int>
#define fi first
#define se second

using namespace std;
const int N = 1e3 + 5;
const int inf = 1e18;
const int mod = 1e9 + 7;

int t;
int dp[N][N];
string a, b, c;

void solve()
{
    memset(dp, 0, sizeof(dp));

    cin >> a >> b >> c;

    a = ' ' + a;
    b = ' ' + b;
    c = ' ' + c;

    for(int i = 0; i < a.size(); i++){
        for(int j = 0; j < b.size(); j++){
            if(i == 0 && j == 0)
                continue;
            if(i == 0){
                if(b[j] == c[i + j])
                    dp[i][j] = dp[i][j - 1] + 1;
//                cout << i << " " << j << endl;
//                cout << a[i] << " " << b[j] << " " << c[i + j] << " " << dp[i][j] << endl;
                continue;
            }
            if(j == 0){
                if(a[i] == c[i + j])
                    dp[i][j] = dp[i - 1][j] + 1;
//                cout << i << " " << j << endl;
//                cout << a[i] << " " << b[j] << " " << c[i + j] << " " << dp[i][j] << endl;
                continue;
            }
            if(a[i] == c[i + j])
                dp[i][j] = max(dp[i][j], dp[i - 1][j] + 1);
            if(b[j] == c[i + j])
                dp[i][j] = max(dp[i][j], dp[i][j - 1] + 1);
            dp[i][j] = max({dp[i][j], dp[i - 1][j], dp[i][j - 1]});
//            cout << i << " " << j << endl;
//            cout << a[i] << " " << b[j] << " " << c[i + j] << " " << dp[i][j] << endl;
        }
    }

    cout << a.size() + b.size() - 2 - dp[a.size() - 1][b.size() - 1] << endl;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	freopen("E.inp", "r", stdin);
//	freopen("E.out", "w", stdout);

	cin >> t;
	while(t--){
        solve();
	}

	return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define pii pair <int, int>
#define fi first
#define se second

using namespace std;
const int N = 2e3 + 5;
const int inf = 1e18;
const int mod = 1e9 + 7;

int t;
int dp[N][N];
string a, b, c;

void solve()
{
    memset(dp, 0, sizeof(dp));

    cin >> a >> b >> c;

    a = ' ' + a;
    b = ' ' + b;
    c = ' ' + c;

    for(int i = 0; i < a.size(); i++){
        for(int j = 0; j < b.size(); j++){
            if(i == 0 && j == 0)
                continue;
            if(i == 0){
                if(b[j] == c[i + j])
                    dp[i][j] = dp[i][j - 1] + 1;
//                cout << i << " " << j << endl;
//                cout << a[i] << " " << b[j] << " " << c[i + j] << " " << dp[i][j] << endl;
                continue;
            }
            if(j == 0){
                if(a[i] == c[i + j])
                    dp[i][j] = dp[i - 1][j] + 1;
//                cout << i << " " << j << endl;
//                cout << a[i] << " " << b[j] << " " << c[i + j] << " " << dp[i][j] << endl;
                continue;
            }
            if(a[i] == c[i + j])
                dp[i][j] = max(dp[i][j], dp[i - 1][j] + 1);
            if(b[j] == c[i + j])
                dp[i][j] = max(dp[i][j], dp[i][j - 1] + 1);
            dp[i][j] = max({dp[i][j], dp[i - 1][j], dp[i][j - 1]});
//            cout << i << " " << j << endl;
//            cout << a[i] << " " << b[j] << " " << c[i + j] << " " << dp[i][j] << endl;
        }
    }

    cout << a.size() + b.size() - 2 - dp[a.size() - 1][b.size() - 1] << endl;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	freopen("E.inp", "r", stdin);
//	freopen("E.out", "w", stdout);

	cin >> t;
	while(t--){
        solve();
	}

	return 0;
}