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

Solution 1 (runtime: 62 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD18 = 1e18;
const ll MOD9  = 1e9+7;
const ll MOD = 998244353;
#define _endl "\n"
#define p2(num) (1LL << (num))
#define _ceil(a, b) (ceil((double)(a) / (b)))
#define _floor(a, b) (floor((double)(a) / (b)))
#define all(a) a.begin(),a.end()
#define LL_MAX LLONG_MAX
#define LL_MIN LLONG_MIN
#define printVec(vec) for (auto &x : (vec)) cout << x << " "; cout << '\n';
#define printRev(vec) for (auto it = (vec).rbegin(); it != (vec).rend(); ++it) cout << *it << " "; cout << '\n';
#define f(i,start,end) for(int i=(start);i<(end);++i)
#define fe(i,start,end) for(int i=(start);i>=(end);--i)
#define CTB(num) ([](long long n) { vector<int> bin; while(n > 0) { bin.push_back(n % 2); n /= 2; } reverse(bin.begin(), bin.end()); return bin; }(num))
#define CTB32(num) ([](long long n) { vector<int> bin; while(n > 0) { bin.push_back(n % 2); n /= 2; } while(bin.size() < 33) bin.push_back(0); reverse(bin.begin(), bin.end()); return bin; }(num))
#define CTB64(num) ([](long long n) { vector<int> bin; while(n > 0) { bin.push_back(n % 2); n /= 2; } while(bin.size() < 64) bin.push_back(0); reverse(bin.begin(), bin.end()); return bin; }(num))
#define getUnique(arr) ([](auto& a) { sort(begin(a), end(a)); a.erase(unique(begin(a), end(a)), end(a)); return vector<long long>(begin(a), end(a)); })(arr)
#define checkPrime(num) ((num)<=1 ? false : (num)==2 || (num)==3 ? true : (num)%2==0 || (num)%3==0 ? false : ([](int n){for(int i=5;i*i<=n;i+=6){if(n%i==0||n%(i+2)==0)return false;}return true;}(num)))
#define intn(p1, p2) ((p2.first < p1.first ? swap(p1, p2), 0 : 0), (p2.first > p1.second ? make_pair(LL_MAX, LL_MIN) : make_pair(max(p1.first, p2.first), min(p1.second, p2.second))))
#define pof(b, exp, MOD) ({ long long ans = 1, base = (b) % (MOD), exp_copy = (exp); while (exp_copy) { if (exp_copy % 2) ans = (ans * base) % (MOD); base = (base * base) % (MOD); exp_copy /= 2; } ans; })
#define IS_POWER(n) ([](long long n)->bool{if(n<=1)return false;for(long long b=2;b<=sqrt(n);++b)for(long long k=2;pow(b,k)<=n;++k)if(pow(b,k)==n)return true;return false;}(n))
#define LARGEST_BASE(n) ([](long long n)->long long{if(n<=1)return -1;for(long long b=sqrt(n);b>=2;--b)for(long long k=2;pow(b,k)<=n;++k)if(pow(b,k)==n)return b;return -1;}(n))
#define SMALLEST_BASE(n) ([](long long n)->long long{if(n<=1)return -1;for(long long b=2;b<=sqrt(n);++b)for(long long k=2;pow(b,k)<=n;++k)if(pow(b,k)==n)return b;return -1;}(n))



// using a>=b is more favourable as compared to a-b>=0, one problem gave TLE
// vector's size is returned in unsigned int and hence in minimum and maximum functions subtracting int from size can give error
// xor donot follow distributive property over +  and - , but do follow over and and or operators
// in a multiset erasing a number directly using the ms.erase(num), will remove all the occurences, while  doing that ms.erase(it.find(num)) will remove just one of the occurences
// also dont remove and erase while iterating using the auto it : method in a set or multiset

void solve() {
    string a,b,c;cin>>a>>b>>c;

    vector<vector<int>>m(a.size()+1,vector<int>(b.size()+1,-1));
    
    m[0][0]=0;

    for(int i=0;i<=a.size();i++){
       for(int j=0;j<=b.size();j++){
          if(i==0&&j==0) continue;
          else if(i==0){
            m[i][j]=(!(c[i+j-1]==b[j-1])+m[i][j-1]);
          }
          else if(j==0){
            m[i][j]=(!(c[i+j-1]==a[i-1])+m[i-1][j]);
          }
          else m[i][j]=min((!(c[i+j-1]==b[j-1])+m[i][j-1]),(!(c[i+j-1]==a[i-1])+m[i-1][j]));
       }
    }

    cout<<m[a.size()][b.size()]<<_endl;
}



signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#ifndef ONLINE_JUDGE
    freopen("lmaoinp.txt", "r", stdin); freopen("lmaooutput_.txt", "w", stdout);
#endif
    int test=1; cin >> test; 
    while (test--) solve();
}

Solution 2 (runtime: 124 ms):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int , int> pii;
typedef pair<long , long> pll;
typedef vector<pair<int ,int>> vpii;
typedef vector<pair<long, long>> vpll;
typedef vector<long double> vld;
ll MOD = 1e9 +7;

int f(string &a, string &b,string&c, vector<vector<int>>&dp, int c_in,int a_used, int &tl, int &al)
{
     if(c_in>=(tl))
     {
          return 0;
     }
     if(dp[c_in][a_used]!=-1)
     {
          return dp[c_in][a_used];
     }
     int ans=1e8;
     if(a_used< al)
     {
     if(a[a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used+1,tl,al));
     }
     else
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used+1,tl,al));
     }
     }
    // int bused=c_in-a_used;
     if((c_in - a_used)<(tl-al))
     {
     if(b[c_in - a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used,tl,al));
     }
     else
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used,tl,al));
     }
     }
     return dp[c_in][a_used]=ans;

}

int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
     string a;
     cin>>a;
     string b;
     cin>>b;
     string c;
     cin>>c;
     int al=a.size();
     int bl=b.size();
     int tl=c.size();
     vector<vector<int>> dp((al+bl),vector<int>(al+1,-1)); 
     cout<<f(a,b,c,dp,0,0,tl,al)<<"\n";



    }
       
    
    return 0;
}