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

Solution 1 (runtime: 78 ms):
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define v(a) vector<(a)>
#define rep(a, i) for(int i = 0; i < (a); i++)
#define read(a, n) for(int i = 0; i < (n); i++){ cin >> a[i];}
#define pB pop_back
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define int long long
#define pi pair<int, int>
const int mod = 998244353;
#define bismillah ios::sync_with_stdio(0); cin.tie(0);
const int INF = 1e18;
 
 
void solve(){
    string aa, bb, c; cin >> aa >> bb >> c;
    
    int x = aa.size();
    int y = bb.size();
    vector<vector<int>> dp(x+1, vector<int>(y+1, 1e9));
    dp[0][0] = 0;
    for(int a = 0; a <= x; a++){
        for(int b = 0; b <= y; b++){  
            int z = a + b;
 
            if(z > c.size()) continue;
 
            if(a > 0 && aa[a-1] == c[z-1]){
                dp[a][b] = min(dp[a][b], dp[a-1][b]);
            }
 
            
 
            if(b > 0 && bb[b-1] == c[z-1]){
                dp[a][b] = min(dp[a][b], dp[a][b-1]);
            }
 
            if(a > 0) dp[a][b] = min(dp[a][b], dp[a-1][b] + 1);
            if(b > 0) dp[a][b] = min(dp[a][b], dp[a][b-1]+1);
            
        }
    }
 
    cout << dp[x][y];
    
}
 
signed main() {
    bismillah
    int t = 1;
    cin >> t;
    while(t--) {
        solve();
        cout << "\n";
    }
    return 0;
}

Solution 2 (runtime: 62 ms):
//Jai Shree Ram

//Author : Meet Upadhyay

#include<bits/stdc++.h>

#include<unordered_set>

#define lli long long int

const lli MOD=1e9+7 ;

const lli MOD2= 998244353; 

const lli inf=1e18; 

bool sortbysec(const std::pair<int,int> &a,const std::pair<int,int> &b) { return (a.second < b.second); } 

lli power(lli n,lli a){ lli res=1; while(a){ if(a%2) res*=n,a--; else   n*=n,a/=2;} return res;}

lli modpower(lli n,lli a,lli p){ lli res=1; while(a){ if(a%2) res= ((res*n)%p) ,a--; else n=((n*n)%p),a/=2;} return res;}

lli fastprime(lli a){ if (a != 2 && a % 2 == 0 || a < 2) return 0;  for(lli i = 3; i * i <= a; i += 2) if(a % i == 0) return 0; return 1;}  

lli mod_mul_inverse(lli a,lli b) {return modpower(a , b-2, b);}

using namespace std;



template <unsigned int MOD>

struct ModInt {

using uint = unsigned int;

using ull = unsigned long long;

using M = ModInt;

uint v;

ModInt(lli _v = 0) { set_norm(_v % MOD + MOD); }

M& set_norm(uint _v) {  //[0, MOD * 2)->[0, MOD)

v = (_v < MOD) ? _v : _v - MOD;

return *this;

}

explicit operator bool() const { return v != 0; }

M operator+(const M& a) const { return M().set_norm(v + a.v); }

M operator-(const M& a) const { return M().set_norm(v + MOD - a.v); }

M operator*(const M& a) const { return M().set_norm(ull(v) * a.v % MOD); }

M operator/(const M& a) const { return *this * a.inv(); }

M& operator+=(const M& a) { return *this = *this + a; }

M& operator-=(const M& a) { return *this = *this - a; }

M& operator*=(const M& a) { return *this = *this * a; }

M& operator/=(const M& a) { return *this = *this / a; }

M operator-() const { return M() - *this; }

M& operator++(int) { return *this = *this + 1; }

M& operator--(int) { return *this = *this - 1; }

M pow(lli n) const {

if (n < 0) return inv().pow(-n);

M x = *this, res = 1;

while (n) {

if (n & 1) res *= x;

x *= x;

n >>= 1;

}

return res;

}

M inv() const {

lli a = v, b = MOD, p = 1, q = 0, t;

while (b != 0) {

t = a / b;

swap(a -= t * b, b);

swap(p -= t * q, q);

}

return M(p);

}

bool operator==(const M& a) const { return v == a.v; }

bool operator!=(const M& a) const { return v != a.v; }

friend ostream& operator<<(ostream& os, const M& a) { return os << a.v; }

static uint get_mod() { return MOD; }

};

;

using Mint = ModInt<1000000007>;

void solve()

{

    string a;

    cin>>a;

    string b;

    cin>>b;

    string c;

    cin>>c;

    lli n = a.size();

    lli m = b.size();

    vector<vector<lli>>dp(n+5, vector<lli>(m+5,1e14));

    dp[0][0] = 0;

    for(lli i=0;i<n;i++)

    {

        dp[i+1][0] = dp[i][0] + (a[i]!=c[i]);

    }



    for(lli i=0;i<m;i++)

    {

        dp[0][i+1] = dp[0][i] + (b[i]!=c[i]);

    }



    for(lli i=1;i<=n;i++)

    {

        for(lli j=1;j<=m;j++)

        {

            dp[i][j] = min(dp[i-1][j] + (a[i-1]!=c[i+j-1]), dp[i][j-1] + (b[j-1]!=c[i+j-1]));

        }

    }



    cout<<dp[n][m]<<endl;



}

int main()

{

    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}