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

Solution 1 (runtime: 140 ms):
// Jai shree ram
/**
 *  - B-A-B-U
 *  - Hard work always pays off
 **/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // find_by_order, order_of_key

#define int long long int
// #define INT_MAX LONG_LONG_MAX;
#define all(arr) arr.begin(), arr.end()
#define endll cout << '\n'
#define Y cout << "YES" << '\n';
#define N cout << "NO" << '\n';
#define scan(arr)       \
    for (auto &x : arr) \
        cin >> x;
#define print(arr)        \
    for (auto &x : arr)   \
        cout << x << " "; \
    cout << endl;
#define bpc(x) __builtin_popcountll(x)
int max_sub(string s, char a); // return max conse freq of a

// Conditional sorting in vector of pairs
bool sortcon(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;
}

int find(int i, int j, int k, string &a, string &b, string &c, vector<vector<int>>& dp)
{
    if (k == c.size())
    {
        return 0;
    }

    if (dp[i][j] != -1)
    {
        return dp[i][j];
    }

    int v1 = INT_MAX, v2 = INT_MAX;
    if (i < a.size())
    {
        v1 = (a[i] == c[k] ? 0 : 1) + find(i + 1, j, k + 1, a, b, c, dp);
    }
    if (j < b.size())
    {
        v2 = (b[j] == c[k] ? 0 : 1) + find(i, j + 1, k + 1, a, b, c, dp);
    }

    return dp[i][j] = min(v1, v2);
}

void Haribol()
{
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.size(), m = b.size(), k = c.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, -1));
    cout << find(0, 0, 0, a, b, c, dp) << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--)
    {
        Haribol();
    }
}

int max_sub(string s, char a)
{
    int temp = 0, flag = 0, ans = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == a)
        {
            temp++;
            flag = 1;
        }
        else
        {
            temp = 0;
            flag = 0;
        }
        if (flag == 1 && temp > ans)
            ans = temp;
    }
    return ans;
}

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

// int dp[1001][1001];
// int valid[1001][1001];
// int t;

// int minChangedChars(string a, string b, string c)
// {
//   int i = a.size(), j = b.size();
//   if (valid[i][j] == t)
//     return dp[i][j];
//   valid[i][j] = t;
//   int acnt = 0, bcnt = 0;
//   if (a.size() == 0)
//   {
//     for (int i = 0; i < c.size(); i++)
//     {
//       if (c[i] != b[i])
//         bcnt++;
//     }
//     return dp[i][j] = bcnt;
//   }

//   if (b.size() == 0)
//   {
//     for (int i = 0; i < c.size(); i++)
//     {
//       if (c[i] != a[i])
//         acnt++;
//     }
//     return dp[i][j] = acnt;
//   }
//   acnt = minChangedChars(a.substr(1), b, c.substr(1));
//   if (a[0] != c[0])
//     acnt++;
//   bcnt = minChangedChars(a, b.substr(1), c.substr(1));
//   if (b[0] != c[0])
//     bcnt++;
//   return dp[i][j] = min(acnt, bcnt);
// }

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

int main()
{
  int t;
  cin >> t;
  while (t--)
  {
    string a, b, c;
    cin >> a >> b >> c;
    vector<vector<int>> dp(a.size() + 1, vector<int>(b.size() + 1, INT_MAX));
    dp[0][0] = 0;
    for (int i = 0; i <= a.size(); i++)
    {
      for (int j = 0; j <= b.size(); j++)
      {
        if (i > 0)
          dp[i][j] = min(dp[i][j], dp[i - 1][j] + (a[i - 1] != c[i + j - 1]));
        if (j > 0)
          dp[i][j] = min(dp[i][j], dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));
      }
    }
    cout << dp[a.size()][b.size()] << endl;
    // cout << minChangedChars(a, b, c) << endl;
  }
  return 0;
}