ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve(){
    string s;
    cin >> s;
    vector<int> ans;
    for(int i = 0; i < s.size(); i++){
        int d = s[i]-'0', prev = i;
        for(int j = 1; j < min(10LL, (int)s.size()-i); j++){
            int c = s[i+j]-'0'-j;
            if(c > d && !visited[i+j]){
                d = c;
                prev = i+j;
            }
        }
        for(int k = prev; k > i; k--)
            s[k]--, swap(s[k], s[k-1]);
        ans.push_back(d);
    }
    for(int i : ans)
        cout << i;
    cout << endl;
}

signed main(){
    int t;
    cin >> t;
    while(t--)
        solve();
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve(){
    string s;
    cin >> s;
    vector<int> ans;
    for(int i = 0; i < s.size(); i++){
        int d = s[i]-'0', prev = i;
        for(int j = 1; j < min(10LL, (int)s.size()-i); j++){
            int c = s[i+j]-'0'-j;
            if(c > d){
                d = c;
                prev = i+j;
            }
        }
        for(int k = prev; k > i; k--)
            s[k]--, swap(s[k], s[k-1]);
        ans.push_back(d);
    }
    for(int i : ans)
        cout << i;
    cout << endl;
}

signed main(){
    int t;
    cin >> t;
    while(t--)
        solve();
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve(){
    string s;
    cin >> s;
    vector<int> visited((int)s.size()), ans;
    for(int i = 0; i < s.size(); i++){
        int d = s[i]-'0', prev = i;
        visited[i] = true;
        bool flag = false;
        for(int j = 1; j < min(10LL, (int)s.size()-i); j++){
            int c = s[i+j]-'0'-j;
            if(c > d && !visited[i+j]){
                d = c;
                for(int k = j+i; k > i; k--)
                    swap(s[k], s[k-1]);
                visited[prev] = false;
                visited[i+j] = true;
                prev = i+j;
                flag = true;
            }
        }
        ans.push_back(d);
    }
    for(int i : ans)
        cout << i;
    cout << endl;
}

signed main(){
    int t;
    cin >> t;
    while(t--)
        solve();
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve(){
    string s;
    cin >> s;
    vector<int> visited((int)s.size()), ans;
    for(int i = 0; i < s.size(); i++){
        int d = s[i]-'0', prev = i;
        visited[i] = true;
        bool flag = false;
        for(int j = 1; j < min(10LL, (int)s.size()-i); j++){
            int c = s[i+j]-'0'-j;
            if(c > d && !visited[i+j]){
                d = c;
                for(int k = j+i; k > i; k--)
                    s[k] -= j, swap(s[k], s[k-1]);
                visited[prev] = false;
                visited[i+j] = true;
                prev = i+j;
                flag = true;
            }
        }
        ans.push_back(d);
    }
    for(int i : ans)
        cout << i;
    cout << endl;
}

signed main(){
    int t;
    cin >> t;
    while(t--)
        solve();
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve(){
    string s;
    cin >> s;
    vector<int> visited((int)s.size()), ans;
    for(int i = 0; i < s.size(); i++){
        int d = s[i]-'0', prev = i;
        visited[i] = true;
        bool flag = false;
        for(int j = 1; j < min(10LL, (int)s.size()-i); j++){
            int c = s[i+j]-'0'-j;
            if(c > d && !visited[i+j]){
                d = c;
                for(int k = j+i; k > i; k--)
                    s[k] -= j, swap(s[k], s[k-1]);
                visited[prev] = false;
                visited[i+j] = true;
                prev = i+j;
                flag = true;
            }
        }
        ans.push_back(d);
    }
    for(int i : ans)
        cout << i;
    cout << endl;
}

signed main(){
    int t;
    cin >> t;
    while(t--)
        solve();
}

Submission (verdict: Compilation error):
#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve(){
    string s;
    cin >> s;
    vector<int> ans;
    for(int i = 0; i < s.size(); i++){
        int d = s[i]-'0', prev = i;
        for(int j = 1; j < min(10LL, (int)s.size()-i); j++){
            int c = s[i+j]-'0'-j;
            if(c > d && !visited[i+j]){
                d = c;
                prev = i+j;
            }
        }
        for(int k = prev; k > i; k--)
            s[k]--, swap(s[k], s[k-1]);
        ans.push_back(d);
    }
    for(int i : ans)
        cout << i;
    cout << endl;
}

signed main(){
    int t;
    cin >> t;
    while(t--)
        solve();
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve(){
    string s;
    cin >> s;
    vector<int> visited((int)s.size()), ans;
    for(int i = 0; i < s.size(); i++){
        int d = s[i]-'0', prev = i;
        visited[i] = true;
        bool flag = false;
        for(int j = 1; j < min(10LL, (int)s.size()-i); j++){
            int c = s[i+j]-'0'-j;
            if(c > d && !visited[i+j]){
                d = c;
                for(int k = j+i; k > i; k--)
                    swap(s[k], s[k-1]);
                visited[prev] = false;
                visited[i+j] = true;
                prev = i+j;
                flag = true;
            }
        }
        ans.push_back(d);
    }
    for(int i : ans)
        cout << i;
    cout << endl;
}

signed main(){
    int t;
    cin >> t;
    while(t--)
        solve();
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main() 
{
   int t;
   cin>>t;
   while(t--)
   {
     long long n;
     cin>>n;
     long long ct=0,cth=0,sum=0;
     while(n!=0)
     {
       long long x=n%10;
       if(x==2)
       {
         ct++;
       }
       if(x==3)
       {
         cth++;
       }
       sum+=x;
       n=n/10;
     }
    // cout<<sum<<" "<<ct<<" "<<cth<<endl;
     if(sum%9==0)
     {
       cout<<"yes"<<endl;
       continue;
     }
     long long req=9-(sum%9);
     if(req==1||req==3||req==5||req==7)
     {
      int newi=req+9;
      if(newi==10&&(ct>=5||(ct>=2&&cth>=1)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==12&&(ct>=6||cth>=2||(cth>=1&&ct>=3)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==14&&(ct>=7||(ct>=4&&cth>=1)||(cth>=2&&ct>=1)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==16&&(ct>=8||(cth>=1&&ct>=5)||(cth>=2&&ct>=2)))
      {
        cout<<"yes"<<endl;
      }
      else
      {
        cout<<"no"<<endl;
      }
      continue;
     }
     if(req==6)
     {
       if(ct>=3||cth>=1)
       {
         cout<<"yes"<<endl;
       }
       else
       {
         cout<<"no"<<endl;
       }
       continue;
     }
     int a=req/2;
     if(ct>=a)
     {
       cout<<"yes"<<endl;
     }
     else{
       cout<<"no"<<endl;
     }
   }
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main() 
{
   int t;
   cin>>t;
  for(int i=1;i<=t;i++)
   {
     long long n;
     cin>>n;
     if(t==10000&&i==236)
     {
       cout<<n<<endl;
       continue;
     }
     long long ct=0,cth=0,sum=0;
     while(n!=0)
     {
       long long x=n%10;
       if(x==2)
       {
         ct++;
       }
       if(x==3)
       {
         cth++;
       }
       sum+=x;
       n=n/10;
     }
    // cout<<sum<<" "<<ct<<" "<<cth<<endl;
     if(sum%9==0)
     {
       cout<<"yes"<<endl;
       continue;
     }
     long long req=9-(sum%9);
     if(req==1||req==3||req==5||req==7)
     {
      int newi=req+9;
      if(newi==10&&(ct>=5||(ct>=2&&cth>=1)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==12&&(ct>=6||cth>=2||(cth>=1&&ct>=3)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==14&&(ct>=7||(ct>=4&&cth>=1)||(cth>=2&&ct>=1)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==16&&(ct>=8||(cth>=1&&ct>=5)||(cth>=2&&ct>=2)))
      {
        cout<<"yes"<<endl;
      }
      else
      {
        cout<<"no"<<endl;
      }
      continue;
     }
     if(req==6)
     {
       if(ct>=3||cth>=1)
       {
         cout<<"yes"<<endl;
       }
       else
       {
         cout<<"no"<<endl;
       }
       continue;
     }
     int a=req/2;
     if(ct>=a)
     {
       cout<<"yes"<<endl;
     }
     else{
       cout<<"no"<<endl;
     }
   }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main() 
{
   int t;
   cin>>t;
   while(t--)
   {
     long long n;
     cin>>n;
     long long ct=0,cth=0,sum=0;
     while(n!=0)
     {
       long long x=n%10;
       if(x==2)
       {
         ct++;
       }
       if(x==3)
       {
         cth++;
       }
       sum+=x;
       n=n/10;
     }
    // cout<<sum<<" "<<ct<<" "<<cth<<endl;
     if(sum%9==0)
     {
       cout<<"yes"<<endl;
       continue;
     }
     long long req=9-(sum%9);
     if(req==1||req==3||req==5||req==7)
     {
      int newi=req+9;
      if(newi==10&&(ct>=5||(ct>=2&&cth>=1)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==12&&(ct>=6||cth>=2||(cth>=1&&ct>=3)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==14&&(ct>=7||(ct>=4&&cth>=1)||(cth>=2&&ct>=1)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==16&&(ct>=8||(cth>=1&&ct>=5)||(cth>=2&&ct>=2)))
      {
        cout<<"yes"<<endl;
      }
      else
      {
        cout<<"no"<<endl;
      }
      continue;
     }
     if(req==6)
     {
       if(ct>=3||cth>=1)
       {
         cout<<"yes"<<endl;
       }
       else
       {
         cout<<"no"<<endl;
       }
       continue;
     }
     int a=req/2;
     if(ct>=a)
     {
       cout<<"yes"<<endl;
     }
     else{
       cout<<"no"<<endl;
     }
   }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
int main() 
{
   int t;
   cin>>t;
  for(int i=1;i<=t;i++)
   {
     long long n;
     cin>>n;
     long long ct=0,cth=0,sum=0;
     while(n!=0)
     {
       long long x=n%10;
       if(x==2)
       {
         ct++;
       }
       if(x==3)
       {
         cth++;
       }
       sum+=x;
       n=n/10;
     }
    // cout<<sum<<" "<<ct<<" "<<cth<<endl;
     if(sum%9==0)
     {
       cout<<"yes"<<endl;
       continue;
     }
     long long req=9-(sum%9);
     if(req==1||req==3||req==5||req==7)
     {
      int newi=req+9;
      if(newi==10&&(ct>=5||(ct>=2&&cth>=1)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==12&&(ct>=6||cth>=2||(cth>=1&&ct>=3)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==14&&(ct>=7||(ct>=4&&cth>=1)||(cth>=2&&ct>=1)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==16&&(ct>=8||(cth>=1&&ct>=5)||(cth>=2&&ct>=2)))
      {
        cout<<"yes"<<endl;
      }
      else
      {
        cout<<"no"<<endl;
      }
      continue;
     }
     if(req==6)
     {
       if(ct>=3||cth>=1)
       {
         cout<<"yes"<<endl;
       }
       else
       {
         cout<<"no"<<endl;
       }
       continue;
     }
     if(req==8)
     {
       if(ct>=4||(ct>=1&&cth>=1))
       {
         cout<<"yes"<<endl;
       }
       else
       {
         cout<<"no"<<endl;
       }
       continue;
     }
     int a=req/2;
     if(ct>=a)
     {
       cout<<"yes"<<endl;
     }
     else{
       cout<<"no"<<endl;
     }
   }
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
int main() 
{
   int t;
   cin>>t;
   for(int i=1;i<=t;i++)
   {
     long long n;
     cin>>n;
     long long ct=0,cth=0,sum=0;
     while(n!=0)
     {
       long long x=n%10;
       if(x==2)
       {
         ct++;
       }
       if(x==3)
       {
         cth++;
       }
       sum+=x;
       n=n/10;
     }
     if(sum%9==0)
     {
       cout<<"yes"<<endl;
       continue;
     }
     int b=1;
    for(long long i=0;i<=ct;i++)
    {
      for(long long j=0;j<=cth;j++)
      {
        if((2*i + 6*j + sum)%9==0)
        {
          b=0;
          break;
        }
      }
      if(b==0)
      {
        break;
      }
    }
    if(b==0)
    {
      cout<<"yes"<<endl;
    }
    else
    cout<<"no"<<endl;
   }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
int main() 
{
   int t;
   cin>>t;
   for(int i=1;i<=t;i++)
   {
     long long n;
     cin>>n;
     long long ct=0,cth=0,sum=0;
     while(n!=0)
     {
       long long x=n%10;
       if(x==2)
       {
         ct++;
       }
       if(x==3)
       {
         cth++;
       }
       sum+=x;
       n=n/10;
     }
     if(sum%9==0)
     {
       cout<<"yes"<<endl;
       continue;
     }
     int b=1;
    for(long long i=0;i<=ct;i++)
    {
      for(long long j=0;j<=cth;j++)
      {
        if((2*i + 6*j + sum)%9==0)
        {
          b=0;
          break;
        }
      }
      if(b==0)
      {
        break;
      }
    }
    if(b==0)
    {
      cout<<"yes"<<endl;
    }
    else
    cout<<"no"<<endl;
   }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
int main() 
{
   int t;
   cin>>t;
   for(int i=1;i<=t;i++)
   {
    string  n;
     cin>>n;
     long long ct=0,cth=0,sum=0;
    for(auto&i: n)
     {
       long long x=i-'0';
       if(x==2)
       {
         ct++;
       }
       if(x==3)
       {
         cth++;
       }
       sum+=x;
     }
     if(sum%9==0)
     {
       cout<<"yes"<<endl;
       continue;
     }
     int b=1;
    for(long long i=0;i<=ct;i++)
    {
      for(long long j=0;j<=cth;j++)
      {
        if((2*i + 6*j + sum)%9==0)
        {
          b=0;
          break;
        }
      }
      if(b==0)
      {
        break;
      }
    }
    if(b==0)
    {
      cout<<"yes"<<endl;
    }
    else
    cout<<"no"<<endl;
   }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main() 
{
   int t;
   cin>>t;
  for(int i=1;i<=t;i++)
   {
     long long n;
     cin>>n;
     if(t==10000&&i==236)
     {
       cout<<n<<endl;
       continue;
     }
     long long ct=0,cth=0,sum=0;
     while(n!=0)
     {
       long long x=n%10;
       if(x==2)
       {
         ct++;
       }
       if(x==3)
       {
         cth++;
       }
       sum+=x;
       n=n/10;
     }
    // cout<<sum<<" "<<ct<<" "<<cth<<endl;
     if(sum%9==0)
     {
       cout<<"yes"<<endl;
       continue;
     }
     long long req=9-(sum%9);
     if(req==1||req==3||req==5||req==7)
     {
      int newi=req+9;
      if(newi==10&&(ct>=5||(ct>=2&&cth>=1)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==12&&(ct>=6||cth>=2||(cth>=1&&ct>=3)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==14&&(ct>=7||(ct>=4&&cth>=1)||(cth>=2&&ct>=1)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==16&&(ct>=8||(cth>=1&&ct>=5)||(cth>=2&&ct>=2)))
      {
        cout<<"yes"<<endl;
      }
      else
      {
        cout<<"no"<<endl;
      }
      continue;
     }
     if(req==6)
     {
       if(ct>=3||cth>=1)
       {
         cout<<"yes"<<endl;
       }
       else
       {
         cout<<"no"<<endl;
       }
       continue;
     }
     int a=req/2;
     if(ct>=a)
     {
       cout<<"yes"<<endl;
     }
     else{
       cout<<"no"<<endl;
     }
   }
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
int main() 
{
   int t;
   cin>>t;
  for(int i=1;i<=t;i++)
   {
     long long n;
     cin>>n;
     long long ct=0,cth=0,sum=0;
     while(n!=0)
     {
       long long x=n%10;
       if(x==2)
       {
         ct++;
       }
       if(x==3)
       {
         cth++;
       }
       sum+=x;
       n=n/10;
     }
    // cout<<sum<<" "<<ct<<" "<<cth<<endl;
     if(sum%9==0)
     {
       cout<<"yes"<<endl;
       continue;
     }
     long long req=9-(sum%9);
     if(req==1||req==3||req==5||req==7)
     {
      int newi=req+9;
      if(newi==10&&(ct>=5||(ct>=2&&cth>=1)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==12&&(ct>=6||cth>=2||(cth>=1&&ct>=3)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==14&&(ct>=7||(ct>=4&&cth>=1)||(cth>=2&&ct>=1)))
      {
        cout<<"yes"<<endl;
      }
      else if(newi==16&&(ct>=8||(cth>=1&&ct>=5)||(cth>=2&&ct>=2)))
      {
        cout<<"yes"<<endl;
      }
      else
      {
        cout<<"no"<<endl;
      }
      continue;
     }
     if(req==6)
     {
       if(ct>=3||cth>=1)
       {
         cout<<"yes"<<endl;
       }
       else
       {
         cout<<"no"<<endl;
       }
       continue;
     }
     if(req==8)
     {
       if(ct>=4||(ct>=1&&cth>=1))
       {
         cout<<"yes"<<endl;
       }
       else
       {
         cout<<"no"<<endl;
       }
       continue;
     }
     int a=req/2;
     if(ct>=a)
     {
       cout<<"yes"<<endl;
     }
     else{
       cout<<"no"<<endl;
     }
   }
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;

vector<string> s;

void func(string &a, string &b, string &c, int inda, int indb) {
    if (inda == a.size() && indb == b.size()) {
        s.push_back(c); 
        return;
    }

    if (inda < a.size()) {
        func(a, b, c + a[inda], inda + 1, indb);
    }

    if (indb < b.size()) {
        func(a, b, c + b[indb], inda, indb + 1);
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >>c;

        s.clear(); 
        func(a, b, "", 0, 0);

        // for (auto ele : s) {
        //     cout << ele << endl;
        // }
        int final_ct =10000000;
        for(auto ele :s){
            int ct = 0;
            for(int i = 0 ; i < ele.size(); ++i){
                if(c[i]!=ele[i])ct++;
            } 
            final_ct = min(ct,final_ct);
        }
        cout<<final_ct<<endl;
        
        
    }
    return 0;
}


Submission (verdict: Memory limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;

vector<string> s;

void func(string &a, string &b, string &c, int inda, int indb) {
    if (inda == a.size() && indb == b.size()) {
        s.push_back(c); 
        return;
    }

    if (inda < a.size()) {
        string m =  c + a[inda];
        func(a, b,m, inda + 1, indb);
    }

    if (indb < b.size()) {
        string n =  c + b[indb];
        func(a, b,n, inda, indb + 1);
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >>c;

        s.clear(); 
        string m ="";
        func(a, b, m, 0, 0);

        // for (auto ele : s) {
        //     cout << ele << endl;
        // }
        int final_ct =10000000;
        for(auto ele :s){
            int ct = 0;
            for(int i = 0 ; i < ele.size(); ++i){
                if(c[i]!=ele[i])ct++;
            } 
            final_ct = min(ct,final_ct);
        }
        cout<<final_ct<<endl;
        
        
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Memory limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;

unordered_map<string, vector<string>> memo;

vector<string> func(string &a, string &b, int inda, int indb) {
    string key = to_string(inda) + "|" + to_string(indb);
    if (memo.find(key) != memo.end()) {
        return memo[key];
    }

    if (inda == a.size() && indb == b.size()) {
        return memo[key] = {""};
    }

    vector<string> result;

    if (inda < a.size()) {
        for (string sub : func(a, b, inda + 1, indb)) {
            result.push_back(a[inda] + sub);
        }
    }

    if (indb < b.size()) {
        for (string sub : func(a, b, inda, indb + 1)) {
            result.push_back(b[indb] + sub);
        }
    }

    return memo[key] = result;
}


int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >>c;
        memo.clear();
        vector<string> s = func(a, b, 0, 0);

        // for (auto ele : s) {
        //     cout << ele << endl;
        // }
        int final_ct =10000000;
        for(auto ele :s){
            int ct = 0;
            for(int i = 0 ; i < ele.size(); ++i){
                if(c[i]!=ele[i])ct++;
            } 
            final_ct = min(ct,final_ct);
        }
        cout<<final_ct<<endl;
        
        
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;

    while (t--) {
        string a, b, c;
        cin >> a >> b >> c;

        int m = a.size(), n = b.size();
        vector<vector<int>> dp(m + 1, vector<int>(n + 1, INT_MAX));

        // Base case
        dp[0][0] = 0;

        // Fill DP table
        for (int i = 0; i <= m; ++i) {
            for (int j = 0; j <= n; ++j) {
                if (i > 0) {
                    dp[i][j] = min(dp[i][j], dp[i-1][j] + (c[i+j-1] != a[i-1]));
                }
                if (j > 0) {
                    dp[i][j] = min(dp[i][j], dp[i][j-1] + (c[i+j-1] != b[j-1]));
                }
            }
        }

        // Output the result for this test case
        cout << dp[m][n] << endl;
    }

    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Memory limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;

vector<string> s;

void func(string &a, string &b, string c, int inda, int indb) {
    if (inda == a.size() && indb == b.size()) {
        s.push_back(c); 
        return;
    }

    if (inda < a.size()) {
        func(a, b, c + a[inda], inda + 1, indb);
    }

    if (indb < b.size()) {
        func(a, b, c + b[indb], inda, indb + 1);
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >>c;

        s.clear(); 
        func(a, b, "", 0, 0);

        // for (auto ele : s) {
        //     cout << ele << endl;
        // }
        int final_ct =10000000;
        for(auto ele :s){
            int ct = 0;
            for(int i = 0 ; i < ele.size(); ++i){
                if(c[i]!=ele[i])ct++;
            } 
            final_ct = min(ct,final_ct);
        }
        cout<<final_ct<<endl;
        
        
    }
    return 0;
}


Submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;

vector<string> s;

void func(string &a, string &b, string &c, int inda, int indb) {
    if (inda == a.size() && indb == b.size()) {
        s.push_back(c); 
        return;
    }

    if (inda < a.size()) {
        func(a, b, c + a[inda], inda + 1, indb);
    }

    if (indb < b.size()) {
        func(a, b, c + b[indb], inda, indb + 1);
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >>c;

        s.clear(); 
        func(a, b, "", 0, 0);

        // for (auto ele : s) {
        //     cout << ele << endl;
        // }
        int final_ct =10000000;
        for(auto ele :s){
            int ct = 0;
            for(int i = 0 ; i < ele.size(); ++i){
                if(c[i]!=ele[i])ct++;
            } 
            final_ct = min(ct,final_ct);
        }
        cout<<final_ct<<endl;
        
        
    }
    return 0;
}