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

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
#define all(c) c.begin(),c.end()
#define sz(c) ll(c.size())
#define ll long long
#define tr(a,it) for(auto it=a.begin(); it!=a.end(); it++)
#define present(c, x)(c.find(x) != c.end())
#define cpresent(c, x)(find(all(c), x) != c.end())
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define inf 10e9
#define MOD 1000000007
#define MAXN 1
#define loop(i,s,e) for(ll i=s; i<e; i++)
#define revloop(i,s,e) for(ll i=s; i>=e; i--)
#define newl cout << endl
 
using namespace std;
 
/////////////////////////////////////////////////////////////////////////////////////
 
// DEBUG GG
 
#define debug(x)     \
  cout << #x << " "; \
  _print(x);         \
  cout << endl;
 
void _print(int x) { cout << x; }
 
void _print(char x) { cout << x; }
 
void _print(string s) { cout << s; }
 
void _print(ll x) { cout << x; }
 
void _print(bool a) { cout << a; }
 
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
  cout << "{";
  _print(p.first);
  cout << ",";
  _print(p.second);
  cout << "}";
}
template <class T>
void _print(vector<T> v) {
  cout << "[ ";
  for (T i : v) {
    _print(i);
    cout << " ";
  }
  cout << "]";
}
 
template <class T>
void _print(set<T> st) {
  cout << "[ ";
  for (T i : st) {
    _print(i);
    cout << " ";
  }
  cout << "]";
}
 
template <class T>
void _print(multiset<T> v) {
  cout << "[ ";
  for (T i : v) {
    _print(i);
    cout << " ";
  }
  cout << "]";
}
 
template <class T, class V>
void _print(map<T, V> v) {
  cout << "[ ";
  for (auto i : v) {
    _print(i);
    cout << " ";
  }
  cout << "]";
}
 
/////////////////////////////////////////////////////////////////////////////////////
 
ll cyclen(ll i, ll n) {
    return (i % n + (i % n == 0) * n);
}
 
ll power(ll a, ll b, ll mod){
    ll p = 1;
    while(b > 0){
        if(b & 1)
            p = (p * a) % mod;
        a = (a * a) % mod;
        b = b >> 1;
    }
    return p;
}
 
ll gcd(ll a, ll b){
    if(!(a % b)) return b;
    return gcd(b, a % b);
}
 
ll inv_mod(ll n, ll mod){
    ll pow = mod - 2;
    return power(n, pow, mod);   
}
 
ll MSB(ll n)
{
    ll ans = 0;
    while (n) {
        ans++;
        n /= 2;
    }
    return ans;
}
ll func(ll i, ll j, string a, string b, string c, vvll& dp){
    ll index = i + j;
    if(dp[i][j] != -1)
        return dp[i][j];
    if(index >= c.length())
        return dp[i][j] = 0;
    ll p = 1e18, q = 1e18, r = 1e18, s = 1e18;
    if(i < a.length() && a[i] == c[index]){
        p  = func(i + 1, j, a, b, c, dp);
    }
    if(j < b.length() && b[j] == c[index]){
        q  = func(i, j + 1, a, b, c, dp);
    }
    r  = 1 + func(i + 1, j, a, b, c, dp);
    s  = 1 + func(i, j + 1, a, b, c, dp);
    return dp[i][j] = min({p,q,r,s});
}
void solve(int tc) {
    string a, b, c; 
    cin >> a >> b >> c; 
    vvll dp(1001,vll(1001,-1));
    loop(i,0,1001){
        loop(j,0,1001){
            dp[i][j]=-1;
        }
    }
    cout<<func(0,0,a,b,c,dp)<<endl;
}

 
int main() {
    ios::sync_with_stdio(0); 
    cin.tie(0);
    int t; 
    cin >> t;
    int tc = 0;
    while (t--) {
        tc++; 
        solve(tc);
    }
    
    return 0;
}


Submission (verdict: Compilation error):
#include <bits/stdc++.h>
#define all(c) c.begin(),c.end()
#define sz(c) ll(c.size())
#define ll long long
#define tr(a,it) for(auto it=a.begin(); it!=a.end(); it++)
#define present(c, x)(c.find(x) != c.end())
#define cpresent(c, x)(find(all(c), x) != c.end())
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define inf 10e9
#define MOD 1000000007
#define MAXN 1
#define loop(i,s,e) for(ll i=s; i<e; i++)
#define revloop(i,s,e) for(ll i=s; i>=e; i--)
#define newl cout << endl
 
using namespace std;
 
/////////////////////////////////////////////////////////////////////////////////////
 
// DEBUG GG
 
#define debug(x)     \
  cout << #x << " "; \
  _print(x);         \
  cout << endl;
 
void _print(int x) { cout << x; }
 
void _print(char x) { cout << x; }
 
void _print(string s) { cout << s; }
 
void _print(ll x) { cout << x; }
 
void _print(bool a) { cout << a; }
 
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
  cout << "{";
  _print(p.first);
  cout << ",";
  _print(p.second);
  cout << "}";
}
template <class T>
void _print(vector<T> v) {
  cout << "[ ";
  for (T i : v) {
    _print(i);
    cout << " ";
  }
  cout << "]";
}
 
template <class T>
void _print(set<T> st) {
  cout << "[ ";
  for (T i : st) {
    _print(i);
    cout << " ";
  }
  cout << "]";
}
 
template <class T>
void _print(multiset<T> v) {
  cout << "[ ";
  for (T i : v) {
    _print(i);
    cout << " ";
  }
  cout << "]";
}
 
template <class T, class V>
void _print(map<T, V> v) {
  cout << "[ ";
  for (auto i : v) {
    _print(i);
    cout << " ";
  }
  cout << "]";
}
 
/////////////////////////////////////////////////////////////////////////////////////
 
ll cyclen(ll i, ll n) {
    return (i % n + (i % n == 0) * n);
}
 
ll power(ll a, ll b, ll mod){
    ll p = 1;
    while(b > 0){
        if(b & 1)
            p = (p * a) % mod;
        a = (a * a) % mod;
        b = b >> 1;
    }
    return p;
}
 
ll gcd(ll a, ll b){
    if(!(a % b)) return b;
    return gcd(b, a % b);
}
 
ll inv_mod(ll n, ll mod){
    ll pow = mod - 2;
    return power(n, pow, mod);   
}
 
ll MSB(ll n)
{
    ll ans = 0;
    while (n) {
        ans++;
        n /= 2;
    }
    return ans;
}
lvoid solve(int tc) {
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.length(), m = b.length(), l = c.length();
    vvll dp(n + 1, vll(m + 1, 1e18));
    dp[0][0] = 0;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            int index = i + j;
            if (index >= l) continue;

            if (i < n && a[i] == c[index]) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            }
            if (j < m && b[j] == c[index]) {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
            }
            if (i < n) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
            }
            if (j < m) {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1);
            }
        }
    }

    cout << dp[n][m] << endl;
}


 
int main() {
    ios::sync_with_stdio(0); 
    cin.tie(0);
    int t; 
    cin >> t;
    int tc = 0;
    while (t--) {
        tc++; 
        solve(tc);
    }
    
    return 0;
}