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

Solution 1 (runtime: 93 ms):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl "\n"
#define float long double
#define int long long int
#define ll long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define PI 3.141592653589793238462643383279
#define all(v) (v).begin(), (v).end() 
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
void solve(){
    string a,b,c;
    cin>>a>>b>>c;
    int n=a.size(),m=b.size(),sz=c.size();
    vector<vector<int>> dp(sz+1,vector<int> (n+1,1e9));
    dp[0][0]=0;
    for(int i=1;i<=sz;i++){
        for(int j=0;j<=n;j++){
            if(i-j<=m && i-j>0)dp[i][j]=min(dp[i-1][j]+!(b[i-j-1]==c[i-1]),dp[i][j]);
            if(j>0)dp[i][j]=min(dp[i-1][j-1]+!(a[j-1]==c[i-1]),dp[i][j]);
        }
    }
    cout<<dp[sz][n]<<endl;
}
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Solution 2 (runtime: 124 ms):
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
#define rep(i, a, b) for (long long i = a; i < b; i++)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define all(x) (x).begin(), (x).end()
//#ifndef ONLINE_JUDGE
//#include "debug.h"
//#endif
#define int long long
#define double long double
const int mod = 1e9+7;
int inf = 1e18;


int helper(vector<vector<int>> &dp,int i,int j,string &a,
string &b,string &c) {
    // cout<<i<<" "<<j<<endl;
    int k = (int)c.length() - ((int)a.length() - i+(int)b.length() - j);
    if(k<=0) return dp[i][j] = 0;
    if(dp[i][j]!=-1) return dp[i][j];
    if(i<=0) {
        if(c[k-1]==b[j-1]) {
            return dp[i][j] = helper(dp,i,j-1,a,b,c);
        }
        else return dp[i][j] = 1 + helper(dp,i,j-1,a,b,c);
    }
    if(j<=0) {
        if(c[k-1]==a[i-1]) {
            return dp[i][j] = helper(dp,i-1,j,a,b,c);
        }
        else return dp[i][j] = 1 + helper(dp,i-1,j,a,b,c);
    }
    // int ans = 1e9;
    // if(c[k-1]==b[j-1]  and c[k-1]==a[i-1]) return dp[i][j] = min(helper())
    
        int ans1 = helper(dp,i-1,j,a,b,c);
        int ans2=   helper(dp,i,j-1,a,b,c);
    if(c[k-1]==b[j-1] and c[k-1]==a[i-1]) return dp[i][j] = min(ans1,ans2);
    if(c[k-1]==b[j-1]) {
        return dp[i][j] = min(1 + ans1,ans2);
    }
    if(c[k-1]==a[i-1]) {
        return dp[i][j] = min(ans1,1 + ans2);
    }
    return dp[i][j] = 1 + min(ans1,ans2);


    

}
void solve()
{
    string a,b,c;
    cin>>a>>b>>c;
    int n = a.length(),m = b.length(), l = c.length();
    vector<vector<int>> dp(n+1,vector<int>(m+1,-1));  
    cout<<helper(dp,n,m,a,b,c)<<endl;  

}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int t = 1;
    cin>>t;

    while(t--) solve();
}