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

Previous submission (verdict: Wrong answer on test 2):
/// Bismillah
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define double long double
#define pii pair<int , int>
#define endl '\n'
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> indexed_set;
typedef tree<int , null_type , less_equal<int> , rb_tree_tag , tree_order_statistics_node_update> indexed_multiset;
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0)
#define vi vector<int>
#define vpii vector<pii>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)((x).size())
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define F first
#define S second
const int mod = 1e9 + 7;
const int N = 3e3 + 5;
const int INF = (int)2e18 + 123;

int dp[N][N];

void solve()
{
    string a , b , c;
    cin >> a >> b >> c;
    int n = sz(a) , m = sz(b);

    for(int i = 0; i < n + m; i++){
        for(int j = 0; j <= min(i + 1 , n); j++){ /// j chars of a
            dp[i + 1][j] = INT_MAX;
            if(i - j < m)
                dp[i + 1][j] = dp[i][j] + (b[i - j] != c[i]);
            if(j)
                dp[i + 1][j] = min(dp[i + 1][j] , dp[i][j - 1] + (a[j - 1] != c[i]));
            //cout << dp[i + 1][j] << " ";
        }
        //cout << '\n';
    }
    cout << dp[n + m][n] << '\n';
}


signed main(){
    _FastIO;
    int T = 1;
    cin >> T;
    while(T--){
        solve();
    }
    //system("pause");
}























Submission (verdict: Time limit exceeded on test 2):
/// Bismillah
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define double long double
#define pii pair<int , int>
#define endl '\n'
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> indexed_set;
typedef tree<int , null_type , less_equal<int> , rb_tree_tag , tree_order_statistics_node_update> indexed_multiset;
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0)
#define vi vector<int>
#define vpii vector<pii>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)((x).size())
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define F first
#define S second
const int mod = 1e9 + 7;
const int N = 3e3 + 5;
const int INF = (int)2e18 + 123;

int dp[N][N];

void solve()
{
    string a , b , c;
    cin >> a >> b >> c;
    int n = sz(a) , m = sz(b);
    for(int i = 0; i <= 2005; i++){
        for(int j = 0; j <= 2005; j++){
            dp[i][j] = INT_MAX;
        }
    }
    dp[0][0] = 0;
    for(int i = 0; i < n + m; i++){
        for(int j = 0; j <= min(i + 1 , n); j++){ /// j chars of a
            if(i - j < m && j <= i)
                dp[i + 1][j] = min(dp[i + 1][j] , dp[i][j] + (b[i - j] != c[i]));
            if(j)
                dp[i + 1][j] = min(dp[i + 1][j] , dp[i][j - 1] + (a[j - 1] != c[i]));
            //cout << dp[i + 1][j] << " ";
        }
        //cout << '\n';
    }
    cout << dp[n + m][n] << '\n';
}


signed main(){
    _FastIO;
    int T = 1;
    cin >> T;
    while(T--){
        solve();
    }
    //system("pause");
}