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

Solution 1 (runtime: 93 ms):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>v5;
long long power(long long A, long long B)
{
    if (B == 0)
        return 1;
 
    long long res = power(A, B / 2);
 
    if (B % 2)
        return res * res * A;
    else
        return res * res;
}
bool is_prime(int n){
   if(n==1){
       return 0;
   }
   bool b = true;
   for(int i=2;i*i<=n;i++){
       if(n%i==0){
           b = false;
           break;
       }
   }
   return b;
}
 void primeFactors(ll n)
{
     while(n%2==0){
         v5.push_back(2);
          n=(n/2);
     }
       for (int i = 3; i*i <= n; i = i+2){
            while (n%i == 0){
                  v5.push_back(i);
                n = n/i;
               }
               }
         if (n > 2){
            v5.push_back(n);
         }
}
bool cmp(pair<ll,ll> &a, pair<ll,ll> &b){
     if(a.first!=b.first){
         if(a.first>b.first) return true;
          return false;
     }
     else{
           if(a.second<b.second) return true;
           return false;
     }
}
ll factorial(ll n) 
{ 
    if (n == 0) 
        return 1; 
    return n * factorial(n - 1); 
} 
void bin(ll n)
{
    for(int i=31;i>=0;i--){
         cout<<((n>>i)&1);
    }
    cout<<endl;
    
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = LONG_LONG_MIN, max_ending_here = 0;
 
    for (int i = 0; i < size; i++) {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;
 
        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}

  int f(int i,int j,int n,int m,string &a,string &b,string &c,vector<vector<int>>&dp){
               if(i==n && j==m) return 0;
               if(dp[i][j]!=-1)  return dp[i][j];
             int ans=c.size();
               if(i<n) ans=min(ans,f(i+1,j,n,m,a,b,c,dp)+(a[i]!=c[i+j]));
               if(j<m) ans=min(ans,f(i,j+1,n,m,a,b,c,dp)+(b[j]!=c[i+j]));
              
             return  dp[i][j]=ans;

  }
        
  int main(){
ios_base::sync_with_stdio(false);
int t;
cin>>t;
while(t--){
      string a,b,c;
      cin>>a>>b>>c;
      int n=a.size();
      int m=b.size();
      vector<vector<int>>dp(n+1,vector<int>(m+1,-1));
      cout<<f(0,0,n,m,a,b,c,dp)<<endl;




  }



  }

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

using namespace std;

#define Fast_IO                       \

    ios_base::sync_with_stdio(false); \

    cin.tie(NULL);                    \

    cout.tie(NULL);

#define int long long int

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)



/* ***********  My code start here *********** */



int32_t main()

{

    Fast_IO



#ifndef ONLINE_JUDGE

        freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);

#endif

    clock_t danger_close = clock();



    int t;

    cin >> t;

    while (t--)

    {

        string a = "", b = "", c = "";

        cin >> a >> b >> c;

        int x = a.size(), y = b.size();

        int dp[x+2][y+2];

        for(int i = 0; i <= x+1; i++)

            for(int j = 0; j <= y+1; j++)

                dp[i][j] = 0;

        for(int i = 1; i <= x; i++)

        {

            if(a[i-1] == c[i-1])

                dp[i][0] = dp[i-1][0];

            else

                dp[i][0] = dp[i-1][0] + 1;

        }

        for(int i = 1; i <= y; i++)

        {

            if(b[i-1] == c[i-1])

                dp[0][i] = dp[0][i-1];

            else

                dp[0][i] = dp[0][i-1] + 1;

        }

        for(int i = 1; i <= x; i++)

        {

            for(int j = 1; j <= y; j++)

            {

                int m1, m2;

                if(a[i-1] == c[i+j-1])

                    m1 = dp[i-1][j];

                else

                    m1 = dp[i-1][j] + 1;

                if(b[j-1] == c[i+j-1])

                    m2 = dp[i][j-1];

                else

                    m2 = dp[i][j-1] + 1;

                dp[i][j] = min(m1, m2);

            }

        }

        cout << dp[x][y] << endl;

    }

    debug("Total Time: %.3f\n", (double)(clock() - danger_close) / CLOCKS_PER_SEC);

    return 0;

}