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

Solution 1 (runtime: 999 ms):
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
const int maxsize = 1e3 + 7;
char a[maxsize], b[maxsize], c[maxsize * 2];
int lena, lenb, lenc;
int dp[maxsize * 2][maxsize];
int main()
{
	int T;
	scanf("%d", &T);
	while (T--) {
		scanf("%s%s%s", a, b, c);
		lena = strlen(a); lenb = strlen(b); lenc = strlen(c);
		fill(dp[0], dp[0] + maxsize * maxsize * 2, maxsize * 2);
		for (int i = 0; i < maxsize; i++) dp[0][i] = 0;
		for (int i = 1; i <= lenc; i++) {
			for (int j = 0; j <= lena; j++) {
				if ((i - j) < 0 || (i - j) > lenb) continue;
				if (i - j - 1 >= 0) dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] == b[i - j - 1] ? 0 : 1));
				if (j - 1 >= 0) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (a[j - 1] == c[i - 1] ? 0 : 1));
			}
		}
		printf("%d\n", dp[lenc][lena]);
	}
	return 0;
}

Solution 2 (runtime: 140 ms):
/*
    Author : Krish Italiya
    Date : 08-12-2024
//  _         _     _         _ _        _ _
// | | ___ __(_)___| |__     (_) |_ __ _| (_)_   _  __ _
// | |/ / '__| / __| '_ \    | | __/ _` | | | | | |/ _` |
// |   <| |  | \__ \ | | |   | | || (_| | | | |_| | (_| |
// |_|\_\_|  |_|___/_| |_|___|_|\__\__,_|_|_|\__, |\__,_|____ _____
//                      |_____|              |___/     |_____|_____|
*/
#include <bits/stdc++.h>
using namespace std;

#define ull unsigned long long 
#define ll long long int
#define lld long double
#define vll vector<ll>
#define UB(v,x) distance(v.begin(),upper_bound(all(v),(x)))
#define LB(v,x) distance(v.begin(),lower_bound(all(v),(x)))
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define mpll map<ll, ll>
#define ld long double
#define f(i, x, n) for (int i = x; i < n; i++)
#define rf(i, x, n) for (int i = x; i >= n; i--)
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a)   (ll)a.size()
#define pi (3.141592653589)
#define prDouble(x) cout<<fixed<<setprecision(6)<<x
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e) max(a,max(b,max(c,max(d,e))))
#define min5(a,b,c,d,e) min(a,min(b,min(c,min(d,e))))
bool isprime(int number){if (number <= 1)return false;if (number == 2)return true;if (number % 2 == 0) return false;int boundary = (int)floor(sqrt(number));for (int i = 3; i <= boundary; i += 2)if (number % i == 0)return false;return true;}
#define slow ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
const ll mod = (ll)1e9+7;


ll fun(ll ia,ll ib,string &s,string &a,string &b,vector<vector<ll>> &dp){
    if(ia>=a.size() and ib>=b.size()){
        return 0;
    }
    if(dp[ia][ib]!=-1)return dp[ia][ib];
    ll ans = LONG_LONG_MAX;
    if(ia<a.size()){
        if(s[ia+ib]==a[ia]){
            ans = min(ans,fun(ia+1,ib,s,a,b,dp));
        }
        else{
            ans = min(ans,1+fun(ia+1,ib,s,a,b,dp));
        }
    }
    if(ib<b.size()){
        if(s[ia+ib]==b[ib]){
            ans = min(ans,fun(ia,ib+1,s,a,b,dp));
        }
        else{
            ans = min(ans,1+fun(ia,ib+1,s,a,b,dp));
        }
    }
    return dp[ia][ib]=ans;
}

void solve(){
    string a,b,c;
    cin>>a>>b>>c;
    ll n= a.size()+b.size();
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,-1));
    cout<<fun(0,0,c,a,b,dp)<<endl;
}          


int main()
{
    slow;
    ll tt = 1;
    cin>>tt;    
    while (tt--)
    {
        solve();
    }
    return 0;
}