Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

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

#define int long long
 
#define fileopen(a, b) freopen(((std::string)a + ".inp").c_str(), "r", stdin); freopen(((std::string)b + ".out").c_str(), "w", stdout);
#define fileopen1(a) freopen(((std::string)a + ".inp").c_str(), "r", stdin); freopen(((std::string)a + ".out").c_str(), "w", stdout);
 
#ifdef PICHU_LOCAL_DEF
	#include <chrono>
#endif
 
using namespace std;

const int MAXN = 2e3 + 5;
int dp[MAXN][MAXN];

signed main() {
	cin.tie(0)->sync_with_stdio(0);

	#ifdef PICHU_LOCAL_DEF
		chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
	#endif

	int t;
	cin >> t;

	while (t--) {
		string a, b;
		cin >> a >> b;

		string c;
		cin >> c;

		int na = a.size(), nb = b.size();

		a = "a" + a;
		b = "a" + b;
		c = "a" + c;

		for (int i = 0; i <= na; i++)
			for (int j = 0; j <= na + nb; j++) 
				dp[i][j] = 1e18;

		dp[0][0] = 0;

		for (int i = 0; i <= na; i++) {
			for (int j = 0; j <= na + nb; j++) {
				// i chars from a, j chars from c, minimum change
				// k chars from b
				int k = j - i;
				if (i > 0 && j > 0 && c[j] == a[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
				if (j > 0 && k > 0 && c[j] == b[k]) dp[i][j] = min(dp[i][j], dp[i][j - 1]);
				if (i > 0 && j > 0) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + 1);
				if (j > 0 && k > 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
			}
		}

		cout << dp[na][na + nb] << '\n';
	}		

	#ifdef PICHU_LOCAL_DEF
		chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
		std::cout << std::endl;
		std::cout << "Time difference = " << chrono::duration_cast<chrono::milliseconds> (end - begin).count() << "[ms]" << std::endl;
	#endif
}

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

#define int long long
 
#define fileopen(a, b) freopen(((std::string)a + ".inp").c_str(), "r", stdin); freopen(((std::string)b + ".out").c_str(), "w", stdout);
#define fileopen1(a) freopen(((std::string)a + ".inp").c_str(), "r", stdin); freopen(((std::string)a + ".out").c_str(), "w", stdout);
 
#ifdef PICHU_LOCAL_DEF
	#include <chrono>
#endif
 
using namespace std;

const int MAXN = 2e3 + 5;
int dp[MAXN][MAXN];

signed main() {
	cin.tie(0)->sync_with_stdio(0);

	#ifdef PICHU_LOCAL_DEF
		chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
	#endif

	int t;
	cin >> t;

	while (t--) {
		string a, b;
		cin >> a >> b;

		string c;
		cin >> c;

		int na = a.size(), nb = b.size();

		a = "x" + a;
		b = "x" + b;
		c = "x" + c;

		for (int i = 0; i <= na; i++)
			for (int j = 0; j <= na + nb; j++) 
				dp[i][j] = 1e18;

		dp[0][0] = 0;

		for (int i = 0; i <= na; i++) {
			for (int j = 0; j <= na + nb; j++) {
				// i chars from a, j chars from c, minimum change
				// k chars from b
				int k = j - i;
				if (i > 0 && j > 0 && c[j] == a[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
				if (j > 0 && k > 0 && c[j] == b[k]) dp[i][j] = min(dp[i][j], dp[i][j - 1]);
				if (i > 0 && j > 0) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + 1);
				if (j > 0 && k > 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
			}
		}

		cout << dp[na][na + nb] << '\n';
	}		

	#ifdef PICHU_LOCAL_DEF
		chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
		std::cout << std::endl;
		std::cout << "Time difference = " << chrono::duration_cast<chrono::milliseconds> (end - begin).count() << "[ms]" << std::endl;
	#endif
}