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

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

using namespace std;

using ll = long long;
const long long MOD = 1000000007;

#define all(c) (c).begin(), (c).end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 2e5 + 10;
const ll INF = 1e18;

int solve(int i, int j, string &a, string &b, vector<vector<int>> &dp) {
    if (i == a.size() || j == b.size()) return 0;
    if (~dp[i][j]) return dp[i][j];
    int ret = 0;
    if (a[i] == b[j]) ret = max(ret, solve(i + 1, j + 1, a, b, dp) + 1);
    ret = max(ret, solve(i + 1, j, a, b, dp));
    ret = max(ret, solve(i, j + 1, a, b, dp));
    return dp[i][j]= ret;
}
vector<bool> vis(MAXN);
int cnt;
void print(int i, int j, string &a, string &b, vector<vector<int>>&dp) {
    if (i == a.size() || j == b.size()) return;
    int opt = solve(i, j, a, b, dp);
    if (a[i] == b[j] && opt == solve(i + 1, j + 1, a, b, dp) + 1) {
		vis[i] = true;
        return print(i + 1, j + 1, a, b, dp);
    }
    if (opt == solve(i + 1, j, a, b, dp)) return print(i + 1, j, a, b, dp);
    return print(i, j + 1, a, b, dp);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int tc;
    cin >> tc;
    while (tc--) {
        string a, b, c;
        cin >> a >> b >> c;
		int n = a.size(), m = b.size();
		ll dp[n + 1][m + 1];
		memset(dp, n + m + 1, sizeof(dp));
		dp[0][0] = 0;
		for(int i = 0; i <=n; i++){
			for(int j = 0; j <=m; j++){
				int k = i + j;
				if(i < n){
					int cnt = c[k] != a[i];
					dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cnt);
				}
				if(j < m){
					int cnt = c[k] != b[j];
					dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cnt);
				}
			}
		}
		cout << dp[n][m] <<endl;
	}

    return 0;
}



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

using namespace std;

using ll = long long;
const long long MOD = 1000000007;

#define all(c) (c).begin(), (c).end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 2e5 + 10;
const ll INF = 1e18;

int solve(int i, int j, string &a, string &b, vector<vector<int>> &dp) {
    if (i == a.size() || j == b.size()) return 0;
    if (~dp[i][j]) return dp[i][j];
    int ret = 0;
    if (a[i] == b[j]) ret = max(ret, solve(i + 1, j + 1, a, b, dp) + 1);
    ret = max(ret, solve(i + 1, j, a, b, dp));
    ret = max(ret, solve(i, j + 1, a, b, dp));
    return dp[i][j]= ret;
}
vector<bool> vis(MAXN);
int cnt;
void print(int i, int j, string &a, string &b, vector<vector<int>>&dp) {
    if (i == a.size() || j == b.size()) return;
    int opt = solve(i, j, a, b, dp);
    if (a[i] == b[j] && opt == solve(i + 1, j + 1, a, b, dp) + 1) {
		vis[i] = true;
        return print(i + 1, j + 1, a, b, dp);
    }
    if (opt == solve(i + 1, j, a, b, dp)) return print(i + 1, j, a, b, dp);
    return print(i, j + 1, a, b, dp);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int tc;
    cin >> tc;
    while (tc--) {
        string a, b, c;
        cin >> a >> b >> c;
		int n = a.size(), m = b.size();
		ll dp[n + 1][m + 1];
		memset(dp, n + m + 1, sizeof(dp));
		dp[0][0] = 0;
		for(int i = 0; i <=n; i++){
			for(int j = 0; j <=m; j++){
				int k = i + j;
				if(i < n){
					ll cnt = c[k] != a[i];
					dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cnt);
				}
				if(j < m){
					ll cnt = c[k] != b[j];
					dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cnt);
				}
			}
		}
		cout << dp[n][m] <<endl;
	}

    return 0;
}