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

Code 1:
#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;

#define int long long
#define float double

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define inp(x) \
    int x;     \
    cin >> x;

#define pb push_back
#define fr(i, b) for (int i = 0; i < (int)(b); i++)
#define scanarr                 \
    int a[n];                   \
    for (int i = 0; i < n; i++) \
    cin >> a[i]
#define sz(a) (int)(a.size())
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define lower(a, b) lower_bound((a).begin(), (a).end(), (int)(b))
#define upper(a, b) upper_bound((a).begin(), (a).end(), (int)(b))
#define lower_ind(a, b) lower_bound((a).begin(), (a).end(), (int)(b)) - (a).begin()
#define upper_ind(a, b) upper_bound((a).begin(), (a).end(), (int)(b)) - (a).begin()

typedef vector<int> vi;
typedef set<int> si;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef map<char, int> mci;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key

void solve()
{
    string a;
    string b;
    string c;
    cin >> a >> b >> c;
    int n = a.size();
    int m = b.size();
    vector dp(n + 1, vector(m + 1, 0));
    for (int i = 1; i <= m; i++)
    {
        if (b[i - 1] != c[i - 1])
        {
            dp[0][i] = dp[0][i - 1] + 1;
        }
        else
        {
            dp[0][i] = dp[0][i - 1];
        }
    }
    for (int i = 1; i <= n; i++)
    {
        dp[i][0] = dp[i - 1][0];
        if (a[i - 1] != c[i - 1])
        {
            dp[i][0] += 1;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            int flag = 0;
            if (a[i - 1] == c[i + j - 1])
            {
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1] + 1);
                flag = 1;
            }
            if (b[j - 1] == c[i + j - 1])
            {
                if (flag == 1)
                {
                    dp[i][j] = min(dp[i][j], dp[i][j - 1]);
                }
                else
                {
                    dp[i][j] = dp[i][j - 1];
                }
            }
            if ((a[i - 1] != c[i + j - 1]) && (b[j - 1] != c[i + j - 1]))
            {
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1;
            }
        }
    }
    cout << dp[n][m] << endl;
}

signed main()
{
    fast;
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}

Code 2:
#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;

#define int long long
#define float double

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define inp(x) \
    int x;     \
    cin >> x;

#define pb push_back
#define fr(i, b) for (int i = 0; i < (int)(b); i++)
#define scanarr                 \
    int a[n];                   \
    for (int i = 0; i < n; i++) \
    cin >> a[i]
#define sz(a) (int)(a.size())
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define lower(a, b) lower_bound((a).begin(), (a).end(), (int)(b))
#define upper(a, b) upper_bound((a).begin(), (a).end(), (int)(b))
#define lower_ind(a, b) lower_bound((a).begin(), (a).end(), (int)(b)) - (a).begin()
#define upper_ind(a, b) upper_bound((a).begin(), (a).end(), (int)(b)) - (a).begin()

typedef vector<int> vi;
typedef set<int> si;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef map<char, int> mci;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key

void solve()
{
    string a;
    string b;
    string c;
    cin >> a >> b >> c;
    int n = a.size();
    int m = b.size();
    vector dp(n + 1, vector(m + 1, 1e9));
    dp[0][0] = 0;
    for (int i = 1; i <= m; i++)
    {
        if (b[i - 1] != c[i - 1])
        {
            dp[0][i] = dp[0][i - 1] + 1;
        }
        else
        {
            dp[0][i] = dp[0][i - 1];
        }
    }
    for (int i = 1; i <= n; i++)
    {
        dp[i][0] = dp[i - 1][0];
        if (a[i - 1] != c[i - 1])
        {
            dp[i][0] += 1;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (a[i - 1] == c[i + j - 1] && b[j - 1] == c[i + j - 1])
            {
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
            }
            else if (a[i - 1] == c[i + j - 1])
            {
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1] + 1);
            }
            else if (b[j - 1] == c[i + j - 1])
            {
                dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + 1);
            }
            else if (a[i - 1] != c[i + j - 1] && b[j - 1] != c[i + j - 1])
            {
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1;
            }
        }
    }
    cout << dp[n][m] << endl;
}

signed main()
{
    fast;
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}

Answer: 2