Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#include <unordered_map>
#define pb push_back
#include<string>
#include<cmath>
#define ll long long
#define lli long long int
#define REP(i,n) for(ll i=1;i<=n;i++)
#include<cctype>
#include <sstream>
#define endl "\n"
#define pairs pair<int,int>
#define ld long double
#define mod 1000000009
#define Mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
# pragma GCC optimize ("Ofast")
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update>
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
ll ceil_div(ll a, ll b) {return a % b == 0 ? a / b : a / b + 1;}
ll pows(ll a,ll n,ll m)
{
	a=a%m;
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll gcd(ll a,ll b)
{
	
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1||n==0)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
		return false;
			}	
	}
	return true;
}
//D'N    G    UP
const int N = 1006;
string s,t,p;
ll n,m;
ll dp[N][N];
ll getans(ll i,ll j){
	if(i >= n && j >= m){
		return 0;
	}
	if(dp[i][j] != -1){
		return dp[i][j];
	}
	ll ans = 1e8;
	if(p[i+j] == s[i]){
		ans =  min(ans,getans(i+1,j));
	}
	if(p[i+j] == t[j]){
     	ans =  min(ans,getans(i,j+1));	
	}
	
	if(p[i+j] != s[i] && p[i+j] != t[j]){
		ans =  min(ans,getans(i+1,j)+1);
		ans =  min(ans,getans(i,j+1)+1);	
	}
	return dp[i][j]=ans;
}
int main()
{ 
  auto begin = std::chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tl;
  cin>>tl;
  while(tl--){
  cin>>s>>t>>p;
  n = s.size();
  m = t.size();
  for(ll i=0;i<=n;i++){
  	for(ll j=0;j<=m;j++){
  		dp[i][j] = -1;
	}
  }
  ll ans = getans(0,0);
  cout<<ans<<endl;
}
  auto end = std::chrono::high_resolution_clock::now();
  auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
  cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 

}


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#include <unordered_map>
#define pb push_back
#include<string>
#include<cmath>
#define ll long long
#define lli long long int
#define REP(i,n) for(ll i=1;i<=n;i++)
#include<cctype>
#include <sstream>
#define endl "\n"
#define pairs pair<int,int>
#define ld long double
#define mod 1000000009
#define Mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
# pragma GCC optimize ("Ofast")
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update>
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
ll ceil_div(ll a, ll b) {return a % b == 0 ? a / b : a / b + 1;}
ll pows(ll a,ll n,ll m)
{
	a=a%m;
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll gcd(ll a,ll b)
{
	
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1||n==0)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
		return false;
			}	
	}
	return true;
}
//D'N    G    UP
const int N = 1006;
string s,t,p;
ll n,m;
ll dp[N][N];
ll getans(ll i,ll j){
	if(i >= n && j >= m){
		return 0;
	}
	if(dp[i][j] != -1){
		return dp[i][j];
	}
	ll ans = 1e8;
	if(p[i+j] == s[i]){
		ans =  min(ans,getans(i+1,j));
	}
	if(p[i+j] == t[j]){
     	ans =  min(ans,getans(i,j+1));	
	}
	
	ans =  min(ans,getans(i+1,j)+1);
	ans =  min(ans,getans(i,j+1)+1);	
		
	return dp[i][j]=ans;
}
int main()
{ 
  auto begin = std::chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tl;
  cin>>tl;
  while(tl--){
  cin>>s>>t>>p;
  n = s.size();
  m = t.size();
  for(ll i=0;i<=n;i++){
  	for(ll j=0;j<=m;j++){
  		dp[i][j] = -1;
	}
  }
  ll ans = getans(0,0);
  cout<<ans<<endl;
}
  auto end = std::chrono::high_resolution_clock::now();
  auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
  cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 

}