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

Previous submission (verdict: Wrong answer on test 17):
#pragma GCC optimize(2)
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cctype>
#include<vector>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>
#define se second
#define fi first
#define pb push_back
#define ins insert
#define all(x) x.begin(),x.end()
using namespace std;  
typedef long long ll; 
typedef unsigned long long ull;
inline bool cmp_v(ll a,ll b){return a>b;}
inline ll gcd(ll a ,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a ,ll b){return a*b/gcd(a,b);}
inline ll qk_pow(ll x,ll n){
    if(n==0)return 1;
    ll r=1;
    while(n--){
        if(n&1)r*=x;
        n>>=1;
        x*=x;
    }return r;
}
inline void swap_(ll &a,ll &b){
    a^=b^=a^=b;return ;
}
inline ll max_(ll a, ll b ){return a>b?a:b;}
inline ll min_(ll a, ll b ){return a>b?b:a;}
const int mod = 100000007;
const ll I = 10000007;
//================================================
//Please 键入 您的 code :
void solve(){
    string a,b,c;
    cin>>a>>b>>c;
    ll n=c.size();
    vector<vector<ll>>dp(n+1,vector<ll>(n+1,n+1));
    dp[0][0]=0;
    ll ans=1e3;
    for(ll f = 0;f<=a.size();f++)
        for(ll d =0;d<=b.size();d++){ 
            if(f<a.size())dp[f+1][d]=min_(dp[f+1][d],dp[f][d]+(a[f]!=c[f+d]));
            if(d<b.size())dp[f][d+1]=min_(dp[f][d+1],dp[f][d]+(b[d]!=c[f+d]));
           }
    for(ll f = 0;f<=a.size();f++){
        ll d =n-f;
        if(d>=0&&d<=b.size())ans=min_(dp[f][d],ans);
    }cout<<ans<<"\n";
}









//================================================
int main() {  
    ios::sync_with_stdio(false);  
    cin.tie(0);  
    cout.tie(0);  
    ll t;  
    t=1;
    cin >> t;
    while (t--) {  
        solve();  
    }  
    return 0;  
}

Submission (verdict: Accepted):
#pragma GCC optimize(2)
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cctype>
#include<vector>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>
#define se second
#define fi first
#define pb push_back
#define ins insert
#define all(x) x.begin(),x.end()
using namespace std;  
typedef long long ll; 
typedef unsigned long long ull;
inline bool cmp_v(ll a,ll b){return a>b;}
inline ll gcd(ll a ,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a ,ll b){return a*b/gcd(a,b);}
inline ll qk_pow(ll x,ll n){
    if(n==0)return 1;
    ll r=1;
    while(n--){
        if(n&1)r*=x;
        n>>=1;
        x*=x;
    }return r;
}
inline void swap_(ll &a,ll &b){
    a^=b^=a^=b;return ;
}
inline ll max_(ll a, ll b ){return a>b?a:b;}
inline ll min_(ll a, ll b ){return a>b?b:a;}
const int mod = 100000007;
const ll I = 10000007;
//================================================
//Please 键入 您的 code :
void solve(){
    string a,b,c;
    cin>>a>>b>>c;
    ll n=c.size();
    vector<vector<ll>>dp(n+1,vector<ll>(n+1,n+1));
    dp[0][0]=0;
    ll ans=n+1;
    for(ll f = 0;f<=a.size();f++)
        for(ll d =0;d<=b.size();d++){ 
            if(f<a.size())dp[f+1][d]=min_(dp[f+1][d],dp[f][d]+(a[f]!=c[f+d]));
            if(d<b.size())dp[f][d+1]=min_(dp[f][d+1],dp[f][d]+(b[d]!=c[f+d]));
           }
    for(ll f = 0;f<=a.size();f++){
        ll d =n-f;
        if(d>=0&&d<=b.size())ans=min_(dp[f][d],ans);
    }cout<<ans<<"\n";
}









//================================================
int main() {  
    ios::sync_with_stdio(false);  
    cin.tie(0);  
    cout.tie(0);  
    ll t;  
    t=1;
    cin >> t;
    while (t--) {  
        solve();  
    }  
    return 0;  
}