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

Code 1:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
// # define int long long
#define f(x, a, b) for (ll x = a; x < b; x++)
#define fm(x, a, b) for (int x = a; x > b; x--)
#define ll long long
#define pb push_back

long long gcd(long long a, ll b)
{
  return b == 0 ? a : gcd(b, a % b);
}

long long lcm(ll a, ll b)
{
  return (a / gcd(a, b)) * b;
}

int help(vector<vector<int>>& dp,string& a,string& b,string& c,int i,int j,int n,int m, int o){
    if (i==n){
        int ans=0;
        f(k,j,m){
            if (c[n+k]!=b[k]){ans+=1;}
        }
        return ans;
    }
    if (j==m){
        int ans=0;
        f(k,i,n){
            if (c[m+k]!=a[k]){ans+=1;}
        }
        return ans;
    }
    if (a[i]==c[i+j]){
        if (b[j]==c[i+j]){
            int x=help(dp,a,b,c,i+1,j,n,m,o);
            int y=help(dp,a,b,c,i,j+1,n,m,o);
            dp[i][j]=min(x,y);
        }
        else{
            int x=help(dp,a,b,c,i+1,j,n,m,o);
            int y=help(dp,a,b,c,i,j+1,n,m,o)+1;
            dp[i][j]=min(x,y);
        }
    }
    else if (b[j]==c[i+j]){
            int x=help(dp,a,b,c,i+1,j,n,m,o)+1;
            int y=help(dp,a,b,c,i,j+1,n,m,o);
            dp[i][j]=min(x,y);
    }
    else{
        int x=help(dp,a,b,c,i+1,j,n,m,o)+1;
        int y=help(dp,a,b,c,i,j+1,n,m,o)+1;
        dp[i][j]=min(x,y);
    }
    return dp[i][j];
}

int main()
{
  int t;
  t = 1;
  cin >> t;
  while (t--)
  {
   	string a,b,c; cin>>a>>b>>c;
   	int n=a.size(),m=b.size(),o=c.size();
   	vector<vector<int>> dp(n,vector<int>(m,-1));
   	int ans=help(dp,a,b,c,0,0,n,m,o);
   	cout<<ans<<endl;
  }
  return 0;
}


Code 2:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
// # define int long long
#define f(x, a, b) for (ll x = a; x < b; x++)
#define fm(x, a, b) for (int x = a; x > b; x--)
#define ll long long
#define pb push_back

long long gcd(long long a, ll b)
{
  return b == 0 ? a : gcd(b, a % b);
}

long long lcm(ll a, ll b)
{
  return (a / gcd(a, b)) * b;
}

int help(vector<vector<int>>& dp,string& a,string& b,string& c,int i,int j,int n,int m, int o){
    if (i==n){
        int ans=0;
        f(k,j,m){
            if (c[n+k]!=b[k]){ans+=1;}
        }
        return ans;
    }
    if (j==m){
        int ans=0;
        f(k,i,n){
            if (c[m+k]!=a[k]){ans+=1;}
        }
        return ans;
    }
    if (dp[i][j]!=-1){return dp[i][j];}
    if (a[i]==c[i+j]){
        if (b[j]==c[i+j]){
            int x=help(dp,a,b,c,i+1,j,n,m,o);
            int y=help(dp,a,b,c,i,j+1,n,m,o);
            dp[i][j]=min(x,y);
        }
        else{
            int x=help(dp,a,b,c,i+1,j,n,m,o);
            int y=help(dp,a,b,c,i,j+1,n,m,o)+1;
            dp[i][j]=min(x,y);
        }
    }
    else if (b[j]==c[i+j]){
            int x=help(dp,a,b,c,i+1,j,n,m,o)+1;
            int y=help(dp,a,b,c,i,j+1,n,m,o);
            dp[i][j]=min(x,y);
    }
    else{
        int x=help(dp,a,b,c,i+1,j,n,m,o)+1;
        int y=help(dp,a,b,c,i,j+1,n,m,o)+1;
        dp[i][j]=min(x,y);
    }
    return dp[i][j];
}

int main()
{
  int t;
  t = 1;
  cin >> t;
  while (t--)
  {
   	string a,b,c; cin>>a>>b>>c;
   	int n=a.size(),m=b.size(),o=c.size();
   	vector<vector<int>> dp(n,vector<int>(m,-1));
   	int ans=help(dp,a,b,c,0,0,n,m,o);
   	cout<<ans<<endl;
  }
  return 0;
}


Answer: 2