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


Submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 using namespace __gnu_pbds;
using namespace std;

/*.........................................................................................*/
#define ll long long
#define int ll
#define ld long double
#define endl "\n"
// #define mod 1000000007
// #define mod  998244353
#define MAXN 2000001
#define relativeerror(x) (cout<<fixed<<setprecision(10)<<x<<endl)
#define getunique1(v) { v.erase(unique(v.begin(), v.end()), v.end());}
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define pi 3.141592653589793238462
#define tsb __builtin_popcountll
#define sz(x) ((int)(x).size())
#define all(c)              (c).begin(), (c).end()
#define allr(c)             (c).rbegin(), (c).rend()
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
/*..........................................................................................*/




/*..........................................................................................*/
template<class T, class V> // cin >> pair
istream &operator>>(istream &istream, pair<T, V> &p) { return (istream >> p.first >> p.second); }
template<class T, size_t SIZE> // cin >> array
istream &operator>>(istream &istream, array<T, SIZE> &a) { for (auto &it : a) { cin >> it; } return istream; }
template<class T> // cin >> vector
istream &operator>>(istream &istream, vector<T> &v) { for (auto &it : v) { cin >> it; } return istream; }
template <class T> void _print(T v[], ll n) {cerr << "[ "; for (ll i = 0; i < n; i++) {cerr << v[i] << " ";} cerr << "]";}
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << "{" << p.first << " " << p.second << "}"; }
template < typename T_container, typename T = typename enable_if < !is_same<T_container, string>::value, typename T_container::value_type >::type > ostream & operator<<(ostream &os, const T_container &v) { os << "[ "; string sep; for (const T &x : v) os << sep << x, sep = " "; return os << " ]"; }
void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << "" << H << " "; dbg_out(T...); }
#ifndef ONLINE_JUDGE
#define debug(...) cerr <<"[ "<<#__VA_ARGS__ <<" ]: ", dbg_out(__VA_ARGS__);
#define debug1(x,n) cerr <<"[ "<<#x <<" ]: "; _print(x,n); cerr<<"\n";
#else
#define debug(...)
#define debug1(x,n)
#endif
void init_code()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 }
void solve() {
   string a,b,c;
   cin>>a>>b>>c;
   int n = a.size() , m = b.size();
   int dp[n+1][m+1];
   memset(dp ,-1, sizeof(dp));

   function<int(int,int)> rec =[&](int i, int j)->int{

   		if(i==n && j==m){
   			return 0;
   		}

   		int ans =1e9;

   		if(i<n){
   			ans = min(ans , (c[i+j]== a[i]  ? 0:1) + rec(i+1 , j));
   		}

   		if(j<m){

   			ans = min(ans , (c[i+j] == b[j] ?0 :1)  + rec(i , j+1));
   		}

   		return ans;
   };
   cout<<rec(0,0)<<endl;
}




signed main() {
    init_code();
#ifndef ONLINE_JUDGE
    auto start = chrono::high_resolution_clock::now();
#endif
    int t = 1;
    // int i = 0;
    cin >> t; 
    // pre();
    // debug(t);

    while (t--)
    {   
    // cout << "Case #" <<  1 << ": ";
        solve();
        // i++;
    }
    cout << endl;
#ifndef ONLINE_JUDGE
    auto stop = chrono::high_resolution_clock::now();
    cerr << setprecision(10) << fixed;
    cerr << "Execution time: " << chrono::duration_cast<std::chrono::duration<double>>(stop - start).count() << " seconds" << "\n";
#endif
    return 0;
}