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

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
 
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define int long long
#define PI pair<int,int>
#define pb push_back
#define f first
#define s second
#define endl '\n'
#define dbgl(x) cout << #x << " = " << x << "####" << endl;
#define dbg(x) cout << #x << " = " << x << " ";

const int INF = 1e16;
const int MAX = 1e3+10;

int memo[MAX][MAX];

string a, b, c;

int dp(int ia, int ib){
	if(ia == a.size() and ib == b.size()) return 0;
	if(memo[ia][ib] != -1) return memo[ia][ib];

	if(ia == a.size()){
		if(b[ib] == c[ia+ib]) return memo[ia][ib] = dp(ia, ib+1);
		return memo[ia][ib] = dp(ia, ib+1) + 1;
	}

	if(ib == b.size()){
		if(a[ia] == c[ia+ib]) return memo[ia][ib] = dp(ia+1, ib);
		return memo[ia][ib] = dp(ia+1, ib) + 1;
	}

	if(a[ia] == c[ia+ib]) return memo[ia][ib] = min(dp(ia+1, ib), dp(ia, ib+1) + 1);
	if(b[ib] == c[ia+ib]) return memo[ia][ib] = min(dp(ia+1, ib) + 1, dp(ia, ib+1));
	return memo[ia][ib] = min(dp(ia+1, ib) + 1, dp(ia, ib+1) + 1);
}

int32_t main(){ _
    int t; cin >> t;
	while(t--){
		cin >> a >> b >> c;
		memset(memo, -1, sizeof(memo));
		int ans = dp(0, 0);
		cout << ans << endl;
	}
    
}   

/* makefile
CXX = g++
CPXXFLAGS = -fsanitize=address,undefined -fno-omit-frame-pointer -g -Wall -Wshadow -std=c++17 -Wno-unused-result -Wno-sign-compare -Wno-char-subscripts #-fuse-ld=gold

q:	
		cp makefiletemp.cpp $(f).cpp
		touch $(f).txt
		code $(f).txt        
		code $(f).cpp
		clear
compile: 
		g++ -g $(f).cpp $(CXXFLAGS) -o $(f)
exe:
		./$(f) < $(f).txt

runc: compile
comp: compile exe

clearexe:
		find . -maxdepth 1 -type f -executable -exec rm {} +
cleartxt:
		find . -type f -name "*.txt" -exec rm -f {} \; 
clear: clearexe cleartxt
		clear
*/

Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
 
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define int long long
#define PI pair<int,int>
#define pb push_back
#define f first
#define s second
#define endl '\n'
#define dbgl(x) cout << #x << " = " << x << "####" << endl;
#define dbg(x) cout << #x << " = " << x << " ";

const int INF = 1e16;
const int MAX = 1e3+100;

int memo[MAX][MAX];

string a, b, c;

int dp(int ia, int ib){
	if(ia == a.size() and ib == b.size()) return 0;
	if(memo[ia][ib] != -1) return memo[ia][ib];

	if(ia == a.size()){
		if(b[ib] == c[ia+ib]) return memo[ia][ib] = dp(ia, ib+1);
		return memo[ia][ib] = dp(ia, ib+1) + 1;
	}

	if(ib == b.size()){
		if(a[ia] == c[ia+ib]) return memo[ia][ib] = dp(ia+1, ib);
		return memo[ia][ib] = dp(ia+1, ib) + 1;
	}

	if(a[ia] == c[ia+ib]) return memo[ia][ib] = min(dp(ia+1, ib), dp(ia, ib+1) + 1);
	if(b[ib] == c[ia+ib]) return memo[ia][ib] = min(dp(ia+1, ib) + 1, dp(ia, ib+1));
	return memo[ia][ib] = min(dp(ia+1, ib) + 1, dp(ia, ib+1) + 1);
}

int32_t main(){ _
    int t; cin >> t;
	while(t--){
		cin >> a >> b >> c;
		memset(memo, -1, sizeof(memo));
		int ans = dp(0, 0);
		cout << ans << endl;
	}
    
}   

/* makefile
CXX = g++
CPXXFLAGS = -fsanitize=address,undefined -fno-omit-frame-pointer -g -Wall -Wshadow -std=c++17 -Wno-unused-result -Wno-sign-compare -Wno-char-subscripts #-fuse-ld=gold

q:	
		cp makefiletemp.cpp $(f).cpp
		touch $(f).txt
		code $(f).txt        
		code $(f).cpp
		clear
compile: 
		g++ -g $(f).cpp $(CXXFLAGS) -o $(f)
exe:
		./$(f) < $(f).txt

runc: compile
comp: compile exe

clearexe:
		find . -maxdepth 1 -type f -executable -exec rm {} +
cleartxt:
		find . -type f -name "*.txt" -exec rm -f {} \; 
clear: clearexe cleartxt
		clear
*/