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

Previous submission (verdict: Time limit exceeded on test 16):
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p){return os << '(' << p.first << ", " << p.second << ')';}
template<typename C,typename D = typename enable_if <!is_same<C, string>::value,typename C::value_type>::type>
ostream &operator<<(ostream &os, const C &v){os << '{';string sep;
    for (const D &x : v)os << sep << x, sep = ", ";return os << '}';}
void dbg_out(){cerr << endl;}
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T){cerr << ' ' << H;dbg_out(T...);}
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

#define PII pair<int,int>
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define ll long long
const int mod = 1e9+7;
const int N = 2e3+1000;

int n,m;
string a,b,c;
vector<vector<int>> f;

void solve(){
    cin >> a >> b >> c;
    n=a.length();m=b.length();
    a=" "+a;b=" "+b;c=" "+c;
    dbg(n,m);
    f.resize(n+2);
    for(int i=0;i<=n+1;i++) vector<int>(m+2,inf).swap(f[i]);


    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0&&j==0) f[i][j]=0;
            else if(i==0){
                f[i][j]=f[i][j-1]+(b[j]!=c[i+j]);
            }else if(j==0){
                f[i][j]=f[i-1][j]+(a[i]!=c[i+j]);
            }else{
                f[i][j]=min(f[i-1][j]+(a[i]!=c[i+j]),f[i][j-1]+(b[j]!=c[i+j]));
            }
        }
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            cerr << f[i][j] << " ";
        }
        cerr << "\n";
    }
    cout << f[n][m];
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("zin.txt","r",stdin);
    freopen("zout.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);std::cin.tie(0);


    int _=1;
    cin >> _;
    // while(cin >> ){
    while(_--){
        solve();
        if(_) cout << "\n";
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p){return os << '(' << p.first << ", " << p.second << ')';}
template<typename C,typename D = typename enable_if <!is_same<C, string>::value,typename C::value_type>::type>
ostream &operator<<(ostream &os, const C &v){os << '{';string sep;
    for (const D &x : v)os << sep << x, sep = ", ";return os << '}';}
void dbg_out(){cerr << endl;}
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T){cerr << ' ' << H;dbg_out(T...);}
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

#define PII pair<int,int>
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define ll long long
const int mod = 1e9+7;
const int N = 2e3+1000;

int n,m;
string a,b,c;
vector<vector<int>> f;

void solve(){
    cin >> a >> b >> c;
    n=a.length();m=b.length();
    a=" "+a;b=" "+b;c=" "+c;
    dbg(n,m);
    f.resize(n+2);
    for(int i=0;i<=n+1;i++) vector<int>(m+2,inf).swap(f[i]);


    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0&&j==0) f[i][j]=0;
            else if(i==0){
                f[i][j]=f[i][j-1]+(b[j]!=c[i+j]);
            }else if(j==0){
                f[i][j]=f[i-1][j]+(a[i]!=c[i+j]);
            }else{
                f[i][j]=min(f[i-1][j]+(a[i]!=c[i+j]),f[i][j-1]+(b[j]!=c[i+j]));
            }
        }
    }
    // for(int i=0;i<=n;i++){
    //     for(int j=0;j<=m;j++){
    //         cerr << f[i][j] << " ";
    //     }
    //     cerr << "\n";
    // }
    cout << f[n][m];
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("zin.txt","r",stdin);
    freopen("zout.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);std::cin.tie(0);


    int _=1;
    cin >> _;
    // while(cin >> ){
    while(_--){
        solve();
        if(_) cout << "\n";
    }
}