Problem: 2050E - Three Strings
Language: c++23 

Code 1:
#include<bits/stdc++.h>
using namespace std;

//#include <random>
//mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());

//indexed-set

//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
//less_equal
//auto x = s.find_by_order(pos);
//int x = s.order_of_key(value)

//gp_hash_table

//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
//#pragma comment(linker, "/STACK: 2000000")
typedef __int128 lll;

#define ll long long
#define ld long double
#define watch(x) cout << (#x) << " is " << (x) << endl
#define PI 3.1415926535897932384626433832795
#define EULER 2.7182818284590452353602874713
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sz(x) (int((x).size()))

const ll mod = 1e9 + 7;
const ll INF = 1e18 ;
const ll MIN = -1e18 ;
const ll MAXII = 200005 ;

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> void dbg(vector<T> v){for (auto x : v) cout << x << " "; cout << endl;}
template<typename T> void dbgg(pair<T, T> p){cout << p.F << " " << p.S << endl;}


string to_upper(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A'; return a; }
string to_lower(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A'; return a; }
bool prime(ll a) { if (a==1) return 0; for (int i=2;i*i<=a;++i) if (a%i==0) return 0; return 1; }
ll inv(ll N) {if (N == 1) return 1; return (mod - ((mod / N) * inv(mod % N)) % mod) % mod;}
void yes() { cout<<"YES\n"; }
void no() { cout<<"NO\n"; }
//ll getRandomNumber(ll l, ll r) {return uniform_int_distribution<ll>(l, r)(rng);}
void star() { cout<<"***************************************\n"; }


//struct custom_hash {
//  static uint64_t splitmix64(uint64_t x) {
//    x += 0x9e3779b97f4a7c15;
//    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//    return x ^ (x >> 31);
//  }
//  size_t operator()(uint64_t x) const {
//    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
//    return splitmix64(x + FIXED_RANDOM);
//  }
//};
//const int mod = 1e9+7;
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

//gp_hash_table<ll, int, custom_hash> mp;

const int N = 2e3+5;
/*vector<vector<int>>adj(N);
vector<bool>vis(N);
int dfs(int i){
        vis[i]=true;
        for(auto k : adj[i]){
            if(!vis[k]) dfs(k);
        }
}*/

int n , m ;
ll dp[N][N];
string s ; 
    string a , b,c; 
ll ans ; 
void work(int i , int j , int cost , int flag){
    int idx = i+j; 
    ll loc = cost;
    if(flag){

        if(s[idx]!=a[i]) loc++;

        if(dp[i][j]<=loc) return;
        dp[i][j]=min(dp[i][j],loc);
        
    } 
    else {
        if(s[idx]!=b[j]) loc++;
        if(dp[i][j]<=loc) return; 
        dp[i][j]=min(dp[i][j],loc);
    }
    if(i<n){
        
        ll nxt = dp[i][j]+(s[idx+1]==a[i+1]? 0 : 1);

        if(nxt<dp[i+1][j]){

            work(i+1,j,loc,1);
        }
    }
    if(j<m){
        ll nxt = dp[i][j]+(s[idx+1]==b[j+1] ? 0 : 1);
      //  cout<<nxt<<" "<<i<<" "<<j<<" "<<idx<<" this: "<<endl;
        if(nxt<dp[i][j+1]){
            work(i,j+1,loc,0);
        }
    }
    if(i==n && j==m) {
        //cout<<"yes"<<endl;
        ans = min( ans,dp[n][m]);
    }
    return;


}





void solve() {
    cin>>a>>b>>c;
     ans = INF;
    n= a.size(),m=b.size();
    a='#'+a;
    b='#'+b;
    c='#'+c;
    s=c;
    dp[0][0]=0;
    for(int i=0;i<=n;i++) for(int j=0;j<=m;j++) dp[i][j]=INF;
    
    work(0,0,0,1);
    cout<<ans<<endl;


}



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    int tc = 1;
    cin >> tc;
    //memset(primes, 0, sizeof(primes));
//    sieve();


    while(tc--) {
        solve();
    }
}

Code 2:
#include<bits/stdc++.h>
using namespace std;

//#include <random>
//mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());

//indexed-set

//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
//less_equal
//auto x = s.find_by_order(pos);
//int x = s.order_of_key(value)

//gp_hash_table

//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
//#pragma comment(linker, "/STACK: 2000000")
typedef __int128 lll;

#define ll long long
#define ld long double
#define watch(x) cout << (#x) << " is " << (x) << endl
#define PI 3.1415926535897932384626433832795
#define EULER 2.7182818284590452353602874713
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sz(x) (int((x).size()))

const ll mod = 1e9 + 7;
const ll INF = 1e18 ;
const ll MIN = -1e18 ;
const ll MAXII = 200005 ;

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> void dbg(vector<T> v){for (auto x : v) cout << x << " "; cout << endl;}
template<typename T> void dbgg(pair<T, T> p){cout << p.F << " " << p.S << endl;}


string to_upper(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A'; return a; }
string to_lower(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A'; return a; }
bool prime(ll a) { if (a==1) return 0; for (int i=2;i*i<=a;++i) if (a%i==0) return 0; return 1; }
ll inv(ll N) {if (N == 1) return 1; return (mod - ((mod / N) * inv(mod % N)) % mod) % mod;}
void yes() { cout<<"YES\n"; }
void no() { cout<<"NO\n"; }
//ll getRandomNumber(ll l, ll r) {return uniform_int_distribution<ll>(l, r)(rng);}
void star() { cout<<"***************************************\n"; }


//struct custom_hash {
//  static uint64_t splitmix64(uint64_t x) {
//    x += 0x9e3779b97f4a7c15;
//    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//    return x ^ (x >> 31);
//  }
//  size_t operator()(uint64_t x) const {
//    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
//    return splitmix64(x + FIXED_RANDOM);
//  }
//};
//const int mod = 1e9+7;
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

//gp_hash_table<ll, int, custom_hash> mp;

const int N = 2e3+5;
/*vector<vector<int>>adj(N);
vector<bool>vis(N);
int dfs(int i){
        vis[i]=true;
        for(auto k : adj[i]){
            if(!vis[k]) dfs(k);
        }
}*/

int n , m ;
ll dp[N][N];
string s ; 
string a , b,c; 
ll work(int i , int j ){
    int idx = i+j-1; 
    if(dp[i][j]!=-1) return dp[i][j];
    if(i<=n && j<=m){
        ll val = (a[i]!=s[idx] ? 1 :0);
        ll ans =work(i+1,j)+val;
        val = (b[j]!=s[idx] ? 1 :0);
        ans = min(ans ,work(i,j+1)+val);
        dp[i][j]=ans;
        
    }
    else if(i<=n){
        ll val = (a[i]!=s[idx] ? 1 :0);
        ll ans =val+work(i+1,j);
        dp[i][j]=ans;
    }
    else if(j<=m){
         ll val = (b[j]!=s[idx] ? 1 :0);
         ll ans = val+work(i,j+1);
         dp[i][j]=ans;
    }
    else return 0;
    //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    return dp[i][j];

}





void solve() {
    cin>>a>>b>>c;
    n= a.size(),m=b.size();
    a='#'+a;
    b='#'+b;
    c='#'+c;
    s=c;
    for(int i=0;i<=n+2;i++) for(int j=0;j<=m+2;j++) dp[i][j]=-1;
    
    cout<<work(1,1)<<endl;

}



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    int tc = 1;
    cin >> tc;
    //memset(primes, 0, sizeof(primes));
//    sieve();


    while(tc--) {
        solve();
    }
}4

Answer: 2