Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 16):
/**
    @author: ddi4z
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

// integer vectors
typedef vector<int> vi;
typedef vector<ll> vll;

// vectors of vectors of integers
typedef vector<vi> vvi;
typedef vector<vll> vvll;

// pairs of integers
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

// vector of pairs of integers
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// stack of integers
typedef stack<int> si;

// stack of pairs of integers
typedef stack<pii> spii;

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fori(i, s, n) for(int i = s; i < n; ++i)
#define forll(i, s, n) for(ll i = s; i < n; ++i)
#define rfori(i, s, n) for(int i = s; i >= n; --i)
#define rforll(i, s, n) for(ll i = s; i >= n; --i)

const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;

#define DBG(X) cerr << #X << " = " << X << endl;
#define RAYA cerr << " ========================= " << endl;

// order statistics

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;
//ordered_set order;


int mod(int a, int m) {return ((a%m) + m) % m;}

string a, b, c;

map<string, ll> memo;

ll dp(ll i,ll j){
    string s = to_string(i) + "," + to_string(j);
    if (memo.count(s)) return memo[s];
    if (i < a.size() && j == b.size()) return memo[s] = (a[i] != c[i + j]) + dp(i + 1, j);
    if (i == a.size() && j < b.size()) return memo[s] = (b[j] != c[i + j]) + dp(i, j + 1);
    if (i == a.size() && j == b.size()) return 0;
    ll res = min((a[i] != c[i + j]) + dp(i + 1, j), 
                (b[j] != c[i + j]) + dp(i, j + 1));
    return memo[s] = res;
}


int main() {
    ll TT;
    scanf("%lld", &TT);
    while(TT--) {
        cin >> a >> b >> c;
        memo.clear();
        printf("%lld\n", dp(0,0));
    }
    return 0;
}

Submission (verdict: Accepted):
/**
    @author: ddi4z
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

// integer vectors
typedef vector<int> vi;
typedef vector<ll> vll;

// vectors of vectors of integers
typedef vector<vi> vvi;
typedef vector<vll> vvll;

// pairs of integers
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

// vector of pairs of integers
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// stack of integers
typedef stack<int> si;

// stack of pairs of integers
typedef stack<pii> spii;

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fori(i, s, n) for(int i = s; i < n; ++i)
#define forll(i, s, n) for(ll i = s; i < n; ++i)
#define rfori(i, s, n) for(int i = s; i >= n; --i)
#define rforll(i, s, n) for(ll i = s; i >= n; --i)

const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;

#define DBG(X) cerr << #X << " = " << X << endl;
#define RAYA cerr << " ========================= " << endl;

// order statistics

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;
//ordered_set order;


int mod(int a, int m) {return ((a%m) + m) % m;}

string a, b, c;
vvll memo;

ll dp(ll i,ll j){
   
    if (memo[i][j]!=INF) return memo[i][j];
    if (i < a.size() && j == b.size()) return memo[i][j] = (a[i] != c[i + j]) + dp(i + 1, j);
    if (i == a.size() && j < b.size()) return memo[i][j] = (b[j] != c[i + j]) + dp(i, j + 1);
    if (i == a.size() && j == b.size()) return 0;
    ll res = min((a[i] != c[i + j]) + dp(i + 1, j), 
                (b[j] != c[i + j]) + dp(i, j + 1));
    return memo[i][j] = res;
}


int main() {
    ll TT;
    scanf("%lld", &TT);
    while(TT--) {
        cin >> a >> b >> c;
        memo.assign(a.size() + 1, vll(b.size() + 1, INF));
        
        printf("%lld\n", dp(0,0));
    }
    return 0;
}