Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 124 ms):
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define ins insert
#define F first
#define S second
#define ll long long
#define ulli unsigned long long int
#define ld long double
#define dgb(x) cout << #x << " : " << x << "\n"

using namespace std ;
const ll MAX = 2e5 + 10 ;
// ******MATH******

const ll mod = 1e9 + 7 ;

ll mul ( ll a , ll b ) {
	return ( (a%mod)*(b%mod) )%mod ;
}

ll binpow ( ll a , ll b ) {
	ll ans = 1 ;
	while ( b ) {
		if ( b%2 ) ans = mul ( a , ans ) ;
		a = mul ( a , a ) ;
		b/=2 ;
	}
	return ans ;
}

ll inv ( ll a , ll b ) {
	return binpow ( a , b - 2 ) ;
}

ll lcm ( ll a , ll b ) {
	return (a*b)/__gcd ( a , b ) ;
}

// ******MATH******

ll pp ( char a , char b ) {
	if ( a == b ) {
		return 0 ;
	}
	return 1 ;
}

int main () {
	ios_base::sync_with_stdio ( 0 ) ; cin.tie ( 0 ) ; cout.tie ( 0 ) ;
	int tt = 1 , juan = 1 ;
	cin >> tt ;
	while ( tt -- ) {
		string a , b , c , aux1 , aux2 , aux3 ;
		cin >> aux1 >> aux2 >> aux3 ;
		a = "?";
		b = a ;
		c = a ;
		a += aux1 ;
		b += aux2 ;
		c += aux3 ;
		const ll frondy = 1e15 ;
		vector < vector < ll > > dp1 ( a.size() + 10 , vector < ll > ( b.size() + 10 , frondy ) ) , dp2 ( b.size() + 10 , vector < ll > ( a.size() + 10 , frondy ) )  ;
		
		dp1 [ 0 ] [ 0 ] = dp2 [ 0 ] [ 0 ] = 0 ;
		for ( int i = 1 ; i < c.size() ; i ++ ) {
//			dgb ( i ) ;
			for ( int j = 0 ; j <= i ; j ++ ) {
//				dgb ( j ) ;
				if ( j < a.size() and (i-j) < b.size() ) {
					if ( j > 0 ) {
						dp1 [ j ] [ i - j ] = min ( dp1 [ j ] [ i - j ] , dp1 [ j - 1 ] [ i - j ] + pp ( a [ j ] , c [ i ] ) ) ;
//						dgb ( dp1 [ j ] [ i - j ] ) ;
						dp1 [ j ] [ i - j ] = min ( dp1 [ j ] [ i - j ] , dp2 [ i - j ] [ j - 1 ] + pp ( a [ j ] , c [ i ] ) ) ;
//						dgb ( pp ( a [ j ] , c [ i ] ) ) ;
//						dgb ( dp1 [ j - 1 ] [ i - j ] ) ;
//						dgb ( dp2 [ i - j ] [ j - 1 ] ) ;
//						dgb ( dp1 [ j ] [ i - j ] ) ;
					}
				} 
				if ( j < b.size() and (i-j) < a.size() ) {
					if ( j > 0 ) {
						dp2 [ j ] [ i - j ] = min ( dp2 [ j ] [ i - j ] , dp2 [ j - 1 ] [ i - j ] + pp ( b [ j ] , c [ i ] ) ) ;
						dp2 [ j ] [ i - j ] = min ( dp2 [ j ] [ i - j ] , dp1 [ i - j ] [ j - 1 ] + pp ( b [ j ] , c [ i ] ) ) ;
//						dgb ( dp2 [ j ] [ i - j ] ) ;
					}
				}
			}
		}
		cout << min ( dp1 [ a.size() - 1 ] [ b.size() - 1 ] , dp2 [ b.size() - 1 ] [ a.size() - 1 ] ) ;
		
		if ( tt > 0 ) cout << "\n" ;
	}
	return 0 ;
}

 

Solution 2 (runtime: 93 ms):
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

// template <typename Type, typename ComparatorFn = less<Type>>
// using ordered_set = tree<Type, null_type, ComparatorFn, rb_tree_tag, tree_order_statistics_node_update>;
// //ordered_set<int, greater_equal<int>> st
// template<typename Type, typename ComparatorFn>
// bool ordered_set_erase(ordered_set<Type, ComparatorFn> &st, Type val) {
// 	if (st.lower_bound(val) == st.upper_bound(val)) return false;
// 	st.erase(st.find_by_order(st.order_of_key(val)));
// 	return true;
// }

// methods -> *find_by_order, order_of_key
// comparators -> less, less_equal, greater, greater_equal

//random No
// mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count()); //use by rng()
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;++i)
#define REPI(i,a,b) for(ll i=a;i>=b;--i)
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define all(a) (a).begin(),(a).end()
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define yes {cout<<'Y'<<'E'<<'S'<<endl; return;}
#define no {cout << 'N' << 'O' << endl; return;}
#define endl "\n"
#define Ka_chow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x)                cout<<#x<<": "<<x<<"\n"
#define db2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<"\n"
#define db3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"\n"
#define db4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<"\n"
#define db5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<"\n"
const int M = 1e9 + 7;
const int N = 1e6 + 7;
#define inf 1000000000000000000
vector<bool> sv(N + 1, true);
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
int prod(const int& a, const int& b)
{
	return ((ll)(a)) * b % M;
}
int sum(const int& a, const int& b)
{
	int c = a + b;
	return c >= M ? c - M : c;
}
int power(int a, int b) {
	int ans = 1;
	a = a % M;
	while (b) {
		if (b & 1) ans = (ans * 1LL * a) % M;
		a = (a * 1LL * a) % M;
		b >>= 1;
	}
	return ans;
}

void seive() {
	sv[0] = false, sv[1] = false;

	for (int i = 2; i * i <= N; ++i) {
		if (sv[i]) {
			for (int j = i * i; j <= N; j += i) sv[j] = 0;
		}
	}
}
void _print(vector<int> v) {
	for (auto &e : v) cout << e << " ";
	cout << endl;
}
vi prefixSum(vi v, bool fl) {
	vi ans;
	int sum = 0;
	if (fl) {
		for (auto &e : v) {
			sum += e;
			ans.eb(sum);
		}
	} else {
		REPI(i, v.size() - 1, 0) {
			sum += v[i];
			ans.eb(sum);
		}
	}
	return ans;
}

//32 r loop logabi 10^9 le & 64 r logabi 10^18 le

void Blue() {
	// Think Twice Code Once
	string a, b, c;
	cin >> a >> b >> c;
	vector<vector<int>> dp(a.size() + 1, vi(b.size() + 1, INT_MAX));

	REPI(i, a.size(), 0) {
		REPI(j, b.size(), 0) {
			if (i + j == c.size()) dp[i][j] = 0;
			else {
				if (i < a.size()) dp[i][j] = min(dp[i][j], (a[i] != c[i + j]) + dp[i + 1][j]);
				if (j < b.size()) dp[i][j] = min(dp[i][j], (b[j] != c[i + j]) + dp[i][j + 1]);
			}
		}
	}

	cout << dp[0][0] << endl;
}

signed main() {
	Ka_chow
	// seive();
	tc(t)
	Blue();
}

/*
ॐ নমঃ শিৱায়
 */