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


Submission (verdict: Wrong answer on test 3):
#include   "bits/stdc++.h"

//#include       <ext/pb_ds/assoc_container.hpp>
//#include       <ext/pb_ds/tree_policy.hpp>


/* -------------------------------------------------------------------------------------*/

/*             BEGIN               */


using namespace std;

//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
/* ordered_set : order_of_key(k) count_num_element < k
                 find_by_order(k) K-th element in set  */   

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")

  //Input Output
  #define        io(x)   if (fopen(x".inp", "r")){ freopen(x".inp","r",stdin),freopen(x".out","w",stdout);}
  #define fast cin.tie(NULL)->sync_with_stdio(false); cout.tie(NULL);
  #define inp freopen("caosang.inp","r",stdin);
  #define out freopen("caosang.out","w",stdout);
  #define el "\n"

  //Time
  #define unlock clock_t tStart = clock()
  #define TIME (1.0 * clock() / CLOCKS_PER_SEC)
  #define time cerr<<fixed<<setprecision(10)<<"\nTime Taken: "<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl

  // Pair Map
  #define fi first
  #define se second
  #define mp3 map<ll,ll>
  #define mib map<ll, bool>
  #define mc map<char,ll>

  //Vector or String
  #define all(v) v.begin(), v.end()
  #define pb push_back
  #define sz(s) (int)s.size()

  //Num
  #define gcd __gcd
  #define lb lower_bound
  #define ub upper_bound
  #define  bit(mask, i) ((mask >> i) & 1)

  // memset
  #define mem(v,so) memset(v,so,sizeof(v));

  //using
  using ll = long long;
  using ull= unsigned long long;
  using ss = string;
  using it = int;
  using dou = double;
  using pl = pair<ll,ll>;
  using pi = pair<it,it>;

  //Mod MaxN
  const it N = (int)1e6+5;
  const it MaxN = (int)1e3+5;
  const ll mod=1e9+7;
  const ll maxn=(int)1e7+5;
  const ll oo=0x3f3f;

  // template 

  template<class A,class B> inline bool _min(A &a,B b) { return (b < a) ? a = b, 1:0; };
  template<class A,class B> inline bool _max(A &a,B b) { return (b > a) ? a = b, 1:0; };

  inline void add(it &x, const it &y) { 

    x += y;

    if (x >= mod) x -= mod;

   }

   inline void mul(it &x, const it &y) { 

    x *= y;

    if (x >= mod) x %= mod;

   }

   inline void sub(it &x, const it &y) { 

    x -= y;

    if (x < 0) x += mod;

   }

  ll sqr(ll a) {  return (a)*(a);  }
  ll lcm(ll a, ll b) {  return (a) / (gcd(a,b)) * (b) ; }

//  8 : int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};  int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
//  4 : int dx[] = {-1 , 0 , 1 , 0}  ; int dy[] = {0 , 1 , 0 , -1} ;

  /*              -END-               */



   /*-----------------------------------------------------------------------------------*/

/* [~~ Nguyen Ngoc Cao Sang <VNG High School for Gifted Student> ~~] */




                                /*~~~~~~ Code: ~~~~~~*/





const bool Multi = false;



it dp[MaxN][MaxN] ;

void runcase() {

                  ss a, b, c;   cin >> a >> b >> c; 
                  it n = sz(a), m = sz(b); a = ' ' + a, b = ' ' + b, c = ' ' + c;

                  mem(dp, oo);
                  dp[0][0] = 0;
                  for (it i(0);i<=n;i++)
                    for (it j(0);j<=m;j++) {
                        if (i > 0) {
                            if (a[i] != c[i + j])
                                _min(dp[i][j], dp[i - 1][j] + 1);
                             else
                                dp[i][j] = dp[i - 1][j];
                        }
                        if (j > 0) {
                            if (b[j] != c[i + j])
                                _min(dp[i][j], dp[i][j - 1] + 1);
                             else
                                 dp[i][j] = dp[i][j - 1];
                         }
                    }

            cout << dp[n][m] << el;
} 

signed main()
{

     fast
    #ifndef ONLINE_JUDGE

       inp
       out
      
    #endif





         // io("") ;

    



     if (Multi){

           runcase();

     } else {

          it test;   cin >> test;

     while (test--){

           runcase();

       }
     }

     
    cerr << "Time elapsed: " << TIME << "s.\n";
    cerr << "Nguyen Ngoc Cao Sang" << "\n";
}