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

Solution 1 (runtime: 92 ms):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int p=1e9+7;
    bool valid(int k,int m){
        if(k>=1 && k<=m){
            return true;
        }
        return false;
    }
  long long  binpow(long long  a,  long long b) {
    long long ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = (ans) * (a);
        a = (a*a);
        b >>= 1;
    }
    return ans;
}
int modulo(int m){
    if(m<0){
       return (p-(abs(m))%p)%p;
    }
    else{
        return m%p;
    }
}
vector<int> printDivisors(int n) 
{ 
    vector<int>vec;

    for (int i = 1; i <= sqrt(n); i++) 
    { 
        if (n % i == 0) 
        { 
            // If divisors are equal,  
            // print only one 
            if (n / i == i) 
                vec.push_back(i);
  
            // Otherwise print both 
            else {
               vec.push_back(i);
               vec.push_back(n/i); }
        } 
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end()); 
    return vec;
}
bool check(vector<string>&vec,int i,int j){
int n=vec.size();
int m=vec[0].size();
if(i<n && i>=0 && j<m && j>=0){
    return true;
}
return false;
}
bool comp(const pair<int, int>& a, const pair<int, int>& b) {
        if(a.first==b.first){
            return a.second<b.second;
        }
        return a.first>b.first;
    }
void findsubsets(int i, int j, const string &a, const string &b, string &curr, vector<string> &result) {

    if (i == a.length()) {
        int originalSize = curr.length();
        curr.append(b.substr(j));
        result.push_back(curr);
        curr.resize(originalSize);
        return;
    }
    
    
    if (j == b.length()) {
        int originalSize = curr.length();
        curr.append(a.substr(i));
        result.push_back(curr);
        curr.resize(originalSize);
        return;
    }
    
  
    curr.push_back(a[i]);
    findsubsets(i + 1, j, a, b, curr, result);
    curr.pop_back();
    
    
    curr.push_back(b[j]);
    findsubsets(i, j + 1, a, b, curr, result);
    curr.pop_back();
}
 
 
 
int32_t main(){
int tests;
cin>>tests;
while(tests--){
   string a,b,c;
   cin>>a>>b>>c;
   vector<string>vec;
   int m=a.size();
   int n=b.size();
   int len=a.size()+b.size();
   vector<vector<int>>dp(m+1,vector<int>(n+1,INT_MAX));
  
   dp[0][0]=0;
   for(int i=0;i<=m;i++){
    for(int j=0;j<=n;j++){
        if(i==0 && j==0){
            continue;
        }
        int ans1=INT_MAX;
        int ans2=INT_MAX;
         if(i>=1){
         ans1=a[i-1]==c[i+j-1]?dp[i-1][j]:dp[i-1][j]+1;}
         if(j>=1){
         ans2=b[j-1]==c[i+j-1]?dp[i][j-1]:dp[i][j-1]+1;}
        dp[i][j]=min(ans1,ans2);
    }
   }
   cout<<dp[m][n]<<endl;
   
   
   


   
   
    
    
  
  }
 

    
    
    

   
   
}

    

    
   


Solution 2 (runtime: 108 ms):
#include <bits/stdc++.h>
using namespace std;
#define nline "\n"
#define set_bits(x) __builtin_popcountll(x)
#define int long long

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--)
    {
        string p, q, r;
        cin >> p >> q >> r;
        int n = p.length();
        int m = q.length();
        vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
        for (int i = n; i >= 0; i--)
        {
            for (int j = m; j >= 0; j--)
            {
                int l = i + j;
                if (i == n)
                {
                    int count = 0;
                    for (int k = j; k < m; k++, l++)
                    {
                        if (q[k] != r[l])
                            count++;
                    }
                    dp[i][j] = count;
                    continue;
                }
                if (j == m)
                {
                    int count = 0;
                    for (int k = i; k < n; k++, l++)
                    {
                        if (p[k] != r[l])
                            count++;
                    }
                    dp[i][j] = count;
                    continue;
                }
                int option1 = (p[i] == r[l] ? dp[i + 1][j] : 1 + dp[i + 1][j]);
                int option2 = (q[j] == r[l] ? dp[i][j + 1] : 1 + dp[i][j + 1]);
                dp[i][j] = min(option1, option2);
            }
        }
        cout << dp[0][0] << nline;
    }
    return 0;
}