Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

#define Fast_IO                       \

    ios_base::sync_with_stdio(false); \

    cin.tie(NULL);                    \

    cout.tie(NULL);

#define int long long int

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)



/* ***********  My code start here *********** */



int32_t main()

{

    Fast_IO



#ifndef ONLINE_JUDGE

        freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);

#endif

    clock_t danger_close = clock();



    int t;

    cin >> t;

    while (t--)

    {

        string a = "", b = "", c = "";

        cin >> a >> b >> c;

        c = " " + c;

        a = " " + a;

        b = " " + b;

        int x = a.size(), y = b.size();

        int dp[x+2][y+2];

        for(int i = 0; i <= x+1; i++)

            for(int j = 0; j <= y+1; j++)

                dp[i][j] = 0;

        for(int i = 1; i <= x; i++)

        {

            if(a[i] == c[i])

                dp[i][0] = dp[i-1][0];

            else

                dp[i][0] = dp[i-1][0] + 1;

        }

        for(int i = 1; i <= y; i++)

        {

            if(b[i] == c[i])

                dp[0][i] = dp[0][i-1];

            else

                dp[0][i] = dp[0][i-1] + 1;

        }

        for(int i = 1; i <= x; i++)

        {

            for(int j = 1; j <= y; j++)

            {

                int m1, m2;

                if(a[i] == c[i+j])

                    m1 = dp[i-1][j];

                else

                    m1 = dp[i-1][j] + 1;

                if(b[j] == c[i+j])

                    m2 = dp[i][j-1];

                else

                    m2 = dp[i][j-1] + 1;

                dp[i][j] = min(m1, m2);

            }

        }

        if(dp[x][y] > 0)

            dp[x][y]--;

        cout << dp[x][y] << endl;

    }

    debug("Total Time: %.3f\n", (double)(clock() - danger_close) / CLOCKS_PER_SEC);

    return 0;

}

Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;

#define Fast_IO                       \

    ios_base::sync_with_stdio(false); \

    cin.tie(NULL);                    \

    cout.tie(NULL);

#define int long long int

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)



/* ***********  My code start here *********** */



int32_t main()

{

    Fast_IO



#ifndef ONLINE_JUDGE

        freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);

#endif

    clock_t danger_close = clock();



    int t;

    cin >> t;

    while (t--)

    {

        string a = "", b = "", c = "";

        cin >> a >> b >> c;

        int x = a.size(), y = b.size();

        int dp[x+2][y+2];

        for(int i = 0; i <= x+1; i++)

            for(int j = 0; j <= y+1; j++)

                dp[i][j] = 0;

        for(int i = 1; i <= x; i++)

        {

            if(a[i-1] == c[i-1])

                dp[i][0] = dp[i-1][0];

            else

                dp[i][0] = dp[i-1][0] + 1;

        }

        for(int i = 1; i <= y; i++)

        {

            if(b[i-1] == c[i-1])

                dp[0][i] = dp[0][i-1];

            else

                dp[0][i] = dp[0][i-1] + 1;

        }

        for(int i = 1; i <= x; i++)

        {

            for(int j = 1; j <= y; j++)

            {

                int m1, m2;

                if(a[i-1] == c[i+j-1])

                    m1 = dp[i-1][j];

                else

                    m1 = dp[i-1][j] + 1;

                if(b[j-1] == c[i+j-1])

                    m2 = dp[i][j-1];

                else

                    m2 = dp[i][j-1] + 1;

                dp[i][j] = min(m1, m2);

            }

        }

        cout << dp[x][y] << endl;

    }

    debug("Total Time: %.3f\n", (double)(clock() - danger_close) / CLOCKS_PER_SEC);

    return 0;

}