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

Solution 1 (runtime: 77 ms):
#include<iostream>
#include<bits/stdc++.h>

using namespace std;
#define ll long long 

const long long mod=1e9 + 7;
ll PRIME = 53;



bool sortbysec(const pair<int,int> &a,  const pair<int,int> &b){ return (a.second < b.second);}
ll mod_expo(ll a, ll b) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;} // (a^b)%mod
ll mminv(ll a) {return mod_expo(a, mod-2);}
ll mod_add(ll a, ll b) {a = a % mod; b = b % mod; return (((a + b) % mod) + mod) % mod;}
ll mod_mul(ll a, ll b) {a = a % mod; b = b % mod; return (((a * b) % mod) + mod) % mod;}
ll mod_sub(ll a, ll b) {a = a % mod; b = b % mod; return (((a - b) % mod) + mod) % mod;}
ll mod_div(ll a, ll b) {a = a % mod; b = b % mod; return (mod_mul(a, mminv(b)) + mod) % mod;}  //only for prime m

ll nCr(ll n,ll r) {if (r==0 || n==0) return 1; ll fac[n+1];fac[0]=1; for(int i = 1; i<n+1 ; i++)
fac[i]=(fac[i-1]*i)%mod;return(fac[n]*mminv(fac[r])%mod*mminv(fac[n-r])%mod)%mod;} 
//  to calculate a pow b


long long binpow(long long a, long long b) {long long res = 1; while (b > 0) {    if (b & 1)        res = res * a;   a = a * a; b >>= 1; }   return res;} 
//  to calculate a pow b %m

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;}
int cntdigit(ll n){int c=0; while(n!=0){    n/=10;     c++;  }  return c; }
 //decimal to binary conviersion
 string DecimalToBinary( ll int num){ string str="";  while(num){   if(num & 1)      str+='1';   else  str+='0';  num>>=1; }  reverse(str.begin(),str.end());  return str;} 
//binary to decimal conversion
ll int BinaryToDecimal(string num){ ll int dec_value = 0;  int base = 1;  int len = num.length();  for (int i=len-1;i>=0;i--){    if (num[i] == '1')        dec_value += base;      base = base * 2;  }  return dec_value; }
// to check no is pow of two or not 
  bool isPowerOfTwo(int n){ if (n == 0)   return false;return (ceil(log2(n)) == floor(log2(n)));}
  
// Graph Grid //
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

bool isPrime(int num) {
    if (num <= 1) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;
    for (int i = 3; i <= sqrt(num); i += 2) {
        if (num % i == 0) return false;
    }
    return true;
}   


 
  int rec(int i,int j,string &a,string &b,string &c,vector<vector<int> > &dp){
      if(i==a.size()&& j==b.size()) return 0;  
       
       if(dp[i][j]!=-1) return dp[i][j];
      
      if(i==a.size()){ 
        if(c[i+j]!=b[j]) return 1+rec(i,j+1,a,b,c,dp);
        else return rec(i,j+1,a,b,c,dp);
           
      } 
      if(j==b.size()){
           if(c[i+j]!=a[i]) return 1+rec(i+1,j,a,b,c,dp);
           else return rec(i+1,j,a,b,c,dp);
      }
      int picka=0,pickb=0;
        if(a[i]==c[i+j]) picka=rec(i+1,j,a,b,c,dp);
        else picka=1+rec(i+1,j,a,b,c,dp); 

        if(b[j]==c[i+j]) pickb=rec(i,j+1,a,b,c,dp);
        else pickb=1+rec(i,j+1,a,b,c,dp);  
        dp[i][j]=min(picka,pickb);
        return min(picka,pickb);

  }

void solve()
{       
  string a ,b,c;
    cin>>a>>b>>c;
     vector<vector<int> > dp(a.size()+1,vector<int>(b.size()+1,-1));
      int ans=rec(0,0,a,b,c,dp);
        cout<<ans<<endl;
         
             
}



int main(){
   int t;
   cin>>t; 

//    t=1; 
   while(t--){ 
       solve();
   
   }
} 

Solution 2 (runtime: 62 ms):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve() {
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.size(), m = b.size();
    int dp[n + 1][m + 1];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) dp[i][j] = INT_MAX;
    }
    dp[0][0] = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (i < n && i+j<c.size()) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + ( c[i + j] != a[i]));
            }
            if (j < m && i + j < c.size()) {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (c[i + j] != b[j]));
            }
        }
    }
    cout << dp[n][m] << endl;
    return;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}