Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 16):
//=======================^========================================================^=======================\\
 
/*
* * * * * * * * *     * * * * * *       * * * * * *       * * * * * * * *   * * *       * * *
 * * * * * * * * *   * * * * * * * *   * * * * * * * *    * * * * * * * *   * * *       * * *
 * * *       * * *   * * *     * * *   * * *     * * *    * * * * * * * *   * * *       * * *
 * * *       * * *   * * *     * * *   * * *     * * *         * * *        * * *       * * *
 * * *       * * *   * * *     * * *   * * *     * * *         * * *        * * *       * * *
 * * * * * * * * *   * * * * * * * *   * * * * * * * *         * * *        * * * * * * * * *
 * * * * * * * * *   * * * * * * * *   * * * * * * *           * * *        * * * * * * * * *
 * * * * * * * * *   * * * * * * * *   * * * * *               * * *        * * * * * * * * *
 * * *               * * *     * * *   * * * * * *             * * *        * * *       * * *
 * * *               * * *     * * *   * * *  * * *            * * *        * * *       * * *
 * * *               * * *     * * *   * * *   * * *           * * *        * * *       * * *
 * * *               * * *     * * *   * * *    * * *          * * *        * * *       * * *
 * * *               * * *     * * *   * * *     * * *         * * *        * * *       * * *
 
*/
 
//=======================^========================================================^=======================\\
 
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include <climits>
#include<bits/stdc++.h>
#include<numeric>
#include<string.h>
#include<ctype.h>
#include<set>
#include<deque>
#include<queue>
#include<vector>
#include <algorithm>
#include<map>
#include<unordered_map>
#define test ll t;cin>>t;while(t--)
#define ll long long int
#define lld long double
#define f first
#define all(v)  v.begin(),v.end()
#define s second
#define inarr ll n;cin>>n;ll arr[n+1];fi(0,n) cin>>arr[i]
#define inarrk ll n,k;cin>>n>>k;ll arr[n+1];fi(0,n) cin>>arr[i]
#define setfor for(auto it: s1)
#define parthparekh ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fi(l,ans2) for(ll i = l; i < ans2; i++)
#define fj(l,ans2) for(ll j = l; j < ans2; j++)
#define fk(l,ans2) for(ll k = l; k < ans2; k++)
#define fm(l,ans2) for(ll m = l; m < ans2; m++)
#define fk(l,ans2) for(ll k = l; k < ans2; k++)
#define fir(ans2,l) for(ll i=ans2;i>=l;i--)
#define fjr(ans2,l) for(ll j=ans2;j>=l;j--)
const ll MOD=1e9+7;
const ll MOD2= 998244353;
const ll inf=1e18;
const ll N=1e6+100;
#define pb push_back
#define em emplace_back
#define yy cout<<"YES\n"
#define YY cout<<"Yes\n"
#define nn cout<<"NO\n"
#define NN cout<<"No\n"
using namespace std;
 
//=======================^========================================================^=======================
// vector<ll> adj[200001];
vector<bool> isprime(N,1);
// vector<ll> vis(200001,0),degree(200001,0),color(200001,-1),pathvis(200001,0);
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
//=======================^========================================================^=======================
 
ll factorial(ll n){
    ll ans=1;
    fi(1,n+1)
    ans*=i;
    return ans;
}
 
vector<ll> decToBinary(ll n) {
    vector<ll> v(32);
    ll i=31;
    while(n>0&&i>=0) {
        v[i]=n%2;
        n/=2;
        i--;
    }
    return v;
}
 
void sieve() {
    isprime[0] = isprime[1] = false;
    for (ll i = 2; i * i < N; ++i) {
        if (isprime[i]) {
            for (ll j = i * i; j < N; j += i) {
                isprime[j] = false;
            }
        }
    }
}

bool isPrimeLarge(ll num) {
    if (num < N) return isprime[num];
    if (num < 2 || (num > 2 && num % 2 == 0)) return false;
    for (ll i = 2; i * i <= num; ++i) {
        if (num % i == 0) return false;
    }
    return true;
}
 
ll power(ll base,ll exponent){
    ll ans=1;
    base%=MOD;
    while(exponent>0) {
        if(exponent&1)
        ans=(ans*base)%MOD;
        exponent>>=1;
        base=(base*base)%MOD;
    }
    return ans;
}

ll parth(vector<vector<ll> > &dp,ll i,ll j,ll k,string a,string b,string c){
    if(i==a.length() && j==b.length())
    return 0;

    if(dp[i][j]!=-1)
    return dp[i][j];

    ll ans=INT_MAX;
    if(i<a.length())
    ans=min(ans,!(a[i]==c[k])+parth(dp,i+1,j,k+1,a,b,c));
    if(j<b.length())
    ans=min(ans,!(b[j]==c[k])+parth(dp,i,j+1,k+1,a,b,c));

    return dp[i][j]=ans;
}

int main()
{
    parthparekh;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    freopen("Error.txt", "w", stderr);
    #endif
    ll t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        ll n=a.length(),m=b.length();
        vector<vector<ll> > dp(n+1,vector<ll>(m+1,-1));
        cout<<parth(dp,0,0,0,a,b,c)<<endl;
    }
}

Submission (verdict: Time limit exceeded on test 16):
//=======================^========================================================^=======================\\
 
/*
* * * * * * * * *     * * * * * *       * * * * * *       * * * * * * * *   * * *       * * *
 * * * * * * * * *   * * * * * * * *   * * * * * * * *    * * * * * * * *   * * *       * * *
 * * *       * * *   * * *     * * *   * * *     * * *    * * * * * * * *   * * *       * * *
 * * *       * * *   * * *     * * *   * * *     * * *         * * *        * * *       * * *
 * * *       * * *   * * *     * * *   * * *     * * *         * * *        * * *       * * *
 * * * * * * * * *   * * * * * * * *   * * * * * * * *         * * *        * * * * * * * * *
 * * * * * * * * *   * * * * * * * *   * * * * * * *           * * *        * * * * * * * * *
 * * * * * * * * *   * * * * * * * *   * * * * *               * * *        * * * * * * * * *
 * * *               * * *     * * *   * * * * * *             * * *        * * *       * * *
 * * *               * * *     * * *   * * *  * * *            * * *        * * *       * * *
 * * *               * * *     * * *   * * *   * * *           * * *        * * *       * * *
 * * *               * * *     * * *   * * *    * * *          * * *        * * *       * * *
 * * *               * * *     * * *   * * *     * * *         * * *        * * *       * * *
 
*/
 
//=======================^========================================================^=======================\\
 
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include <climits>
#include<bits/stdc++.h>
#include<numeric>
#include<string.h>
#include<ctype.h>
#include<set>
#include<deque>
#include<queue>
#include<vector>
#include <algorithm>
#include<map>
#include<unordered_map>
#define test ll t;cin>>t;while(t--)
#define ll long long int
#define lld long double
#define f first
#define all(v)  v.begin(),v.end()
#define s second
#define inarr ll n;cin>>n;ll arr[n+1];fi(0,n) cin>>arr[i]
#define inarrk ll n,k;cin>>n>>k;ll arr[n+1];fi(0,n) cin>>arr[i]
#define setfor for(auto it: s1)
#define parthparekh ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fi(l,ans2) for(ll i = l; i < ans2; i++)
#define fj(l,ans2) for(ll j = l; j < ans2; j++)
#define fk(l,ans2) for(ll k = l; k < ans2; k++)
#define fm(l,ans2) for(ll m = l; m < ans2; m++)
#define fk(l,ans2) for(ll k = l; k < ans2; k++)
#define fir(ans2,l) for(ll i=ans2;i>=l;i--)
#define fjr(ans2,l) for(ll j=ans2;j>=l;j--)
const ll MOD=1e9+7;
const ll MOD2= 998244353;
const ll inf=1e18;
const ll N=1e6+100;
#define pb push_back
#define em emplace_back
#define yy cout<<"YES\n"
#define YY cout<<"Yes\n"
#define nn cout<<"NO\n"
#define NN cout<<"No\n"
using namespace std;
 
//=======================^========================================================^=======================
// vector<ll> adj[200001];
vector<bool> isprime(N,1);
// vector<ll> vis(200001,0),degree(200001,0),color(200001,-1),pathvis(200001,0);
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
//=======================^========================================================^=======================
 
ll factorial(ll n){
    ll ans=1;
    fi(1,n+1)
    ans*=i;
    return ans;
}
 
vector<ll> decToBinary(ll n) {
    vector<ll> v(32);
    ll i=31;
    while(n>0&&i>=0) {
        v[i]=n%2;
        n/=2;
        i--;
    }
    return v;
}
 
void sieve() {
    isprime[0] = isprime[1] = false;
    for (ll i = 2; i * i < N; ++i) {
        if (isprime[i]) {
            for (ll j = i * i; j < N; j += i) {
                isprime[j] = false;
            }
        }
    }
}

bool isPrimeLarge(ll num) {
    if (num < N) return isprime[num];
    if (num < 2 || (num > 2 && num % 2 == 0)) return false;
    for (ll i = 2; i * i <= num; ++i) {
        if (num % i == 0) return false;
    }
    return true;
}
 
ll power(ll base,ll exponent){
    ll ans=1;
    base%=MOD;
    while(exponent>0) {
        if(exponent&1)
        ans=(ans*base)%MOD;
        exponent>>=1;
        base=(base*base)%MOD;
    }
    return ans;
}

ll parth(vector<vector<ll> > &dp,ll i,ll j,string a,string b,string c){
    if(i==a.length() && j==b.length())
    return 0;

    if(dp[i][j]!=-1)
    return dp[i][j];

    ll ans=INT_MAX,k=i+j;
    if(i<a.length())
    ans=min(ans,!(a[i]==c[k])+parth(dp,i+1,j,a,b,c));
    if(j<b.length())
    ans=min(ans,!(b[j]==c[k])+parth(dp,i,j+1,a,b,c));

    return dp[i][j]=ans;
}

int main()
{
    parthparekh;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    freopen("Error.txt", "w", stderr);
    #endif
    ll t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        ll n=a.length(),m=b.length();
        vector<vector<ll> > dp(n+1,vector<ll>(m+1,-1));
        cout<<parth(dp,0,0,a,b,c)<<endl;
    }
}