Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Memory limit exceeded on test 14):
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<set>
#include<iterator>
#include<sstream>
#include<fstream>
#include<queue>
#include<stack>
#include<unordered_set>
#include<numeric>
#include<utility>
#include<limits>
 
using namespace std;

int make_dp(vector< vector< vector<int> > >& dp, string a, string b, string c, int inda, int indb, int indc)
{
    if(dp[indc][indb][inda] != -1) return dp[indc][indb][inda];
    else if(inda >= a.length())
    {
        int temp = 0;
        int j = indb;
        int k = indc;
        while(j<b.length() && k<c.length())
        {
            if(b[j] != c[k]) temp++;

            j++;
            k++;
        }
        dp[indc][indb][inda] = temp;
        return dp[indc][indb][inda];
    }
    else if(indb >= b.length())
    {
        int temp = 0;
        int j = inda;
        int k = indc;
        while(j<a.length() && k<c.length())
        {
            if(a[j] != c[k]) temp++;

            j++;
            k++;
        }
        dp[indc][indb][inda] = temp;
        return dp[indc][indb][inda];
    }
    else
    {

        int temp1 = make_dp(dp, a, b, c, inda + 1, indb, indc + 1);
        int temp2 = make_dp(dp, a, b, c, inda, indb + 1, indc + 1);
        
        if(a[inda] != c[indc] && b[indb] != c[indc])
        {
            dp[indc][indb][inda] = min(1 + temp1, 1 + temp2);
        }
        else if(a[inda] == c[indc] && b[indb] != c[indc])
        {
            dp[indc][indb][inda] = min(temp1, 1 + temp2);
        }
        else if(a[inda] != c[indc] && b[indb] == c[indc])
        {
            dp[indc][indb][inda] = min(1 + temp1, temp2);
        }
        else 
        {
            dp[indc][indb][inda] = min(temp1, temp2);
        }

        return dp[indc][indb][inda];
    }
}


int main()
{
    int t;
    cin>>t;
    for(int i=0; i<t; i++)
    {
        string a, b, c;
        cin>>a>>b>>c;
        // question gives dynamic programming vibes
        int alen = a.length();
        int blen = b.length();
        int clen = c.length();

        vector< vector< vector<int> > > dp(clen + 1, vector<vector<int> >(blen + 1, vector<int>(alen + 1)));

        for(int j = 0; j <= clen; j++)
        {
            for(int k = 0; k <= blen; k++)
            {
                for(int l = 0; l <= alen; l++)
                {
                    dp[j][k][l] = -1;
                }
            }
        }

        cout<<make_dp(dp, a, b, c, 0, 0, 0)<<endl;
    }
}

Submission (verdict: Memory limit exceeded on test 14):
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<set>
#include<iterator>
#include<sstream>
#include<fstream>
#include<queue>
#include<stack>
#include<unordered_set>
#include<numeric>
#include<utility>
#include<limits>
 
using namespace std;

int make_dp(vector< vector< vector<int> > >& dp, string& a, string& b, string& c, int inda, int indb, int indc)
{
    if(dp[indc][indb][inda] != -1) return dp[indc][indb][inda];
    else if(inda >= a.length())
    {
        int temp = 0;
        int j = indb;
        int k = indc;
        while(j<b.length() && k<c.length())
        {
            if(b[j] != c[k]) temp++;

            j++;
            k++;
        }
        dp[indc][indb][inda] = temp;
        return dp[indc][indb][inda];
    }
    else if(indb >= b.length())
    {
        int temp = 0;
        int j = inda;
        int k = indc;
        while(j<a.length() && k<c.length())
        {
            if(a[j] != c[k]) temp++;

            j++;
            k++;
        }
        dp[indc][indb][inda] = temp;
        return dp[indc][indb][inda];
    }
    else
    {

        int temp1 = make_dp(dp, a, b, c, inda + 1, indb, indc + 1);
        int temp2 = make_dp(dp, a, b, c, inda, indb + 1, indc + 1);
        
        if(a[inda] != c[indc] && b[indb] != c[indc])
        {
            dp[indc][indb][inda] = min(1 + temp1, 1 + temp2);
        }
        else if(a[inda] == c[indc] && b[indb] != c[indc])
        {
            dp[indc][indb][inda] = min(temp1, 1 + temp2);
        }
        else if(a[inda] != c[indc] && b[indb] == c[indc])
        {
            dp[indc][indb][inda] = min(1 + temp1, temp2);
        }
        else 
        {
            dp[indc][indb][inda] = min(temp1, temp2);
        }

        return dp[indc][indb][inda];
    }
}


int main()
{
    int t;
    cin>>t;
    for(int i=0; i<t; i++)
    {
        string a, b, c;
        cin>>a>>b>>c;
        // question gives dynamic programming vibes
        int alen = a.length();
        int blen = b.length();
        int clen = c.length();

        vector< vector< vector<int> > > dp(clen + 1, vector<vector<int> >(blen + 1, vector<int>(alen + 1)));

        for(int j = 0; j <= clen; j++)
        {
            for(int k = 0; k <= blen; k++)
            {
                for(int l = 0; l <= alen; l++)
                {
                    dp[j][k][l] = -1;
                }
            }
        }

        cout<<make_dp(dp, a, b, c, 0, 0, 0)<<endl;
    }
}