Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int p=1e9+7;
    bool valid(int k,int m){
        if(k>=1 && k<=m){
            return true;
        }
        return false;
    }
  long long  binpow(long long  a,  long long b) {
    long long ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = (ans) * (a);
        a = (a*a);
        b >>= 1;
    }
    return ans;
}
int modulo(int m){
    if(m<0){
       return (p-(abs(m))%p)%p;
    }
    else{
        return m%p;
    }
}
vector<int> printDivisors(int n) 
{ 
    vector<int>vec;

    for (int i = 1; i <= sqrt(n); i++) 
    { 
        if (n % i == 0) 
        { 
            // If divisors are equal,  
            // print only one 
            if (n / i == i) 
                vec.push_back(i);
  
            // Otherwise print both 
            else {
               vec.push_back(i);
               vec.push_back(n/i); }
        } 
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end()); 
    return vec;
}
bool check(vector<string>&vec,int i,int j){
int n=vec.size();
int m=vec[0].size();
if(i<n && i>=0 && j<m && j>=0){
    return true;
}
return false;
}
bool comp(const pair<int, int>& a, const pair<int, int>& b) {
        if(a.first==b.first){
            return a.second<b.second;
        }
        return a.first>b.first;
    }
void findsubsets(int i, int j, const string &a, const string &b, string &curr, vector<string> &result) {

    if (i == a.length()) {
        int originalSize = curr.length();
        curr.append(b.substr(j));
        result.push_back(curr);
        curr.resize(originalSize);
        return;
    }
    
    
    if (j == b.length()) {
        int originalSize = curr.length();
        curr.append(a.substr(i));
        result.push_back(curr);
        curr.resize(originalSize);
        return;
    }
    
  
    curr.push_back(a[i]);
    findsubsets(i + 1, j, a, b, curr, result);
    curr.pop_back();
    
    
    curr.push_back(b[j]);
    findsubsets(i, j + 1, a, b, curr, result);
    curr.pop_back();
}
 
 
 
int32_t main(){
int tests;
cin>>tests;
while(tests--){
   string a,b,c;
   cin>>a>>b>>c;
   vector<string>vec;
   int len=a.size()+b.size();
   int i=0;
   int j=0;
   int k=0;
   int cnt=0;
   while(i<a.size() && j<b.size() && k<len){
    if(c[k]==a[i]){
        i++;
        k++;
    }
    else if(c[k]==b[j]){
        j++;
        k++;
    }
    else{
        i++;
        j++;
        k++;
        cnt++;
    }
   }
   if(i==a.size()){
    while(j<b.size() && k<len){
        if(c[k]!=b[j]){
            cnt++;
        }
        k++;
        j++;
    }
    cout<<cnt<<endl;
   }
   else{
    while(i<a.size() && k<len){
        if(c[k]!=a[i]){
            cnt++;
        }
        k++;
        i++;
    }
    cout<<cnt<<endl;
   }
   
   
   


   
   
    
    
  
  }
 

    
    
    

   
   
}

    

    
   


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int p=1e9+7;
    bool valid(int k,int m){
        if(k>=1 && k<=m){
            return true;
        }
        return false;
    }
  long long  binpow(long long  a,  long long b) {
    long long ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = (ans) * (a);
        a = (a*a);
        b >>= 1;
    }
    return ans;
}
int modulo(int m){
    if(m<0){
       return (p-(abs(m))%p)%p;
    }
    else{
        return m%p;
    }
}
vector<int> printDivisors(int n) 
{ 
    vector<int>vec;

    for (int i = 1; i <= sqrt(n); i++) 
    { 
        if (n % i == 0) 
        { 
            // If divisors are equal,  
            // print only one 
            if (n / i == i) 
                vec.push_back(i);
  
            // Otherwise print both 
            else {
               vec.push_back(i);
               vec.push_back(n/i); }
        } 
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end()); 
    return vec;
}
bool check(vector<string>&vec,int i,int j){
int n=vec.size();
int m=vec[0].size();
if(i<n && i>=0 && j<m && j>=0){
    return true;
}
return false;
}
bool comp(const pair<int, int>& a, const pair<int, int>& b) {
        if(a.first==b.first){
            return a.second<b.second;
        }
        return a.first>b.first;
    }
void findsubsets(int i, int j, const string &a, const string &b, string &curr, vector<string> &result) {

    if (i == a.length()) {
        int originalSize = curr.length();
        curr.append(b.substr(j));
        result.push_back(curr);
        curr.resize(originalSize);
        return;
    }
    
    
    if (j == b.length()) {
        int originalSize = curr.length();
        curr.append(a.substr(i));
        result.push_back(curr);
        curr.resize(originalSize);
        return;
    }
    
  
    curr.push_back(a[i]);
    findsubsets(i + 1, j, a, b, curr, result);
    curr.pop_back();
    
    
    curr.push_back(b[j]);
    findsubsets(i, j + 1, a, b, curr, result);
    curr.pop_back();
}
 
 
 
int32_t main(){
int tests;
cin>>tests;
while(tests--){
   string a,b,c;
   cin>>a>>b>>c;
   vector<string>vec;
   int m=a.size();
   int n=b.size();
   int len=a.size()+b.size();
   vector<vector<int>>dp(m+1,vector<int>(n+1,INT_MAX));
  
   dp[0][0]=0;
   for(int i=0;i<=m;i++){
    for(int j=0;j<=n;j++){
        if(i==0 && j==0){
            continue;
        }
        int ans1=INT_MAX;
        int ans2=INT_MAX;
         if(i>=1){
         ans1=a[i-1]==c[i+j-1]?dp[i-1][j]:dp[i-1][j]+1;}
         if(j>=1){
         ans2=b[j-1]==c[i+j-1]?dp[i][j-1]:dp[i][j-1]+1;}
        dp[i][j]=min(ans1,ans2);
    }
   }
   cout<<dp[m][n]<<endl;
   
   
   


   
   
    
    
  
  }
 

    
    
    

   
   
}