ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define e endl
#define int long long
#define all(a) a.begin(), a.end()
#define ip(s) int s; cin >> s;
#define ipp(arr,n) vector<int> arr(n); for (auto &it : arr) cin >> it;
#define f(n) for(int i = 0; i < n; i++)

int32_t main() {
    int t; cin >> t;
    while (t--) {
        ip(n);
        string s = to_string(n);
        int sum=0;
        int two=0;
        int three=0;
        for(int i=0;i<s.length();i++) {
            sum+=s[i]-'0';
            if(s[i]=='2') two++;
            else if(s[i]=='3') three++;
        }
        bool found=false;
        for(int i=0;i<=min(two,8LL);i++){
            for(int j=0;j<=min(three,8LL);j++){
                if((sum+2*i+6*j)%9==0){
                    found=true;
                    break;
                }
            }
            if(found) break;
 
        }
        if(found) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;


    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int sum=0,two=0,three=0;
        for(auto ch:s){
            sum+=ch-'0';
            if(ch=='2') two++;
            else if(ch=='3') three++;
        }
        bool found=false;
        for(int i=0;i<=min(two,9);i++){
            for(int j=0;j<=min(three,9);j++){
                if((sum+2*i+6*j)%9==0){
                    found=true;
                    break;
                }
            }
            if(found) break;

        }
        if(found) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
//              find_by_order(k) -> iterator to the kth largest element - zero indexed
//              order_of_key(k)  -> no. of items in that are strictly smaller than k
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll,ll>> vpll;
typedef vector<vpll> vvpll;
typedef vector<pair<ld , ld>> vplld;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,pair<ll,ll>>> vppll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
#define fi first
#define se second
#define pb push_back
#define yes  cout << "YES" << endl
#define no  cout << "NO" << endl
#define mod1 998244353
#define mod 1000000007
#define print(a) for(auto x:a) cout<<x<<" ";cout<<endl;
#define printarr(nums,n) for(int i = 0 ; i < n  ;i ++) cout << nums[i] << " "; cout << endl;
#define inputarr(nums,n) for(int i=0;i<n;i++) cin>>nums[i];
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()


long long power(long long a,long long b){
    long long res=1;
    while(b){
        if(b%2==1){
            b--;
            res*=a;
        }
        else{
            a*=a;
            b/=2;
        }
    }
    return res;
}

long long mpower(long long a,long long b,long long p){
    long long res=1;
    while(b){
        if(b%2==1){
            b--;
            res=(res*a)%p;
        }
        else{
            a=(a*a)%p;
            b/=2;
        }
    }
    return res;
}

ll modinv(ll a,ll m){
    ll x=mpower(a,m-2,m);
    return x;
}
/*-----------------------------------------------------------------------------------------*/
void solve(){
    ll l,r;
    cin>>l>>r;

    vll a(32),b(32);
    ll start=0;

    for(int i=0;i<=31;i++){
        if(1&(r>>i)){
            b[i]=1;
            start=i;
        }
    }

    ll x=(1<<start);

    ll ans=0;

    if(r==x||r==x-1){
        ans=l;
    }
    else ans=r;

    cout<<x<<" "<<(x-1)<<" "<<ans<<endl;

}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while (t--) 
    solve();
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Runtime error on test 2):
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
//              find_by_order(k) -> iterator to the kth largest element - zero indexed
//              order_of_key(k)  -> no. of items in that are strictly smaller than k
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll,ll>> vpll;
typedef vector<vpll> vvpll;
typedef vector<pair<ld , ld>> vplld;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,pair<ll,ll>>> vppll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
#define fi first
#define se second
#define pb push_back
#define yes  cout << "YES" << endl
#define no  cout << "NO" << endl
#define mod1 998244353
#define mod 1000000007
#define print(a) for(auto x:a) cout<<x<<" ";cout<<endl;
#define printarr(nums,n) for(int i = 0 ; i < n  ;i ++) cout << nums[i] << " "; cout << endl;
#define inputarr(nums,n) for(int i=0;i<n;i++) cin>>nums[i];
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()


long long power(long long a,long long b){
    long long res=1;
    while(b){
        if(b%2==1){
            b--;
            res*=a;
        }
        else{
            a*=a;
            b/=2;
        }
    }
    return res;
}

long long mpower(long long a,long long b,long long p){
    long long res=1;
    while(b){
        if(b%2==1){
            b--;
            res=(res*a)%p;
        }
        else{
            a=(a*a)%p;
            b/=2;
        }
    }
    return res;
}

ll modinv(ll a,ll m){
    ll x=mpower(a,m-2,m);
    return x;
}
/*-----------------------------------------------------------------------------------------*/
void solve(){
    ll m,n;
    cin>>m>>n;
    vll s(m),t(n);
    inputarr(s,m);
    inputarr(t,n);

    if(n>m){
        no;
        return;
    }

    priority_queue<ll> a;
    priority_queue<ll> b;

    for(ll i : s) a.push(i);
    for(ll i : t) b.push(i);


    while(b.size()<a.size()){
        if(b.top()==a.top()){
            b.pop();
            a.pop();
        }
        else if(a.top()>b.top()){
            no;
            return;
        }
        else{
            ll node=b.top();
            b.pop();
            b.push(node/2);
            b.push(node/2+node%2);
        }
    }

    if(b.size()>a.size()){
        no;
        return;
    }

    while(!a.empty()){
        if(a.top()!=b.top()){
            no;
            return;
        }
        a.pop();
        b.pop();
    }

    yes;

}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while (t--) 
    solve();
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
int a[100005];
void solve(){
	memset(a,0,sizeof(a));
	int n,l,r;
	cin>>n>>l>>r;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	ll ans=0;
	for(int i=1;i<=r-l+1;i++){
		ans+=a[i];
	}
	cout<<ans<<endl;
}
int main(int argc, char** argv) {
	int t;
	cin>>t;
	while(t--){
		solve();
	} 
	return 0;
}



Submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
int a[100005],b[100005];
void solve(){
	memset(b,0,sizeof(b));
	memset(a,0,sizeof(a));
	int n,l,r;
	cin>>n>>l>>r;
	int ans=0,cnt=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=r;i++){
		b[i]=a[i];
	}
	sort(b+1,b+r+1);
	for(int i=1;i<=r-l+1;i++){
		ans+=b[i];
	}
	sort(a+l,a+n+1);
	for(int i=l;i<=r;i++){
		cnt+=a[i];
	}
	cout<<min(ans,cnt)<<endl;
}
int main(int argc, char** argv) {
	int t;
	cin>>t;
	while(t--){
		solve();
	} 
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
int a[100005],b[100005];
void solve(){
	memset(b,0,sizeof(b));
	memset(a,0,sizeof(a));
	int n,l,r;
	cin>>n>>l>>r;
	int ans=0,cnt=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=r;i++){
		b[i]=a[i];
	}
	sort(b+1,b+r+1);
	for(int i=1;i<=r-l+1;i++){
		ans+=b[i];
	}
	sort(a+l,a+n+1);
	for(int i=l;i<=r;i++){
		cnt+=a[i];
	}
	cout<<min(ans,cnt)<<endl;
}
int main(int argc, char** argv) {
	int t;
	cin>>t;
	while(t--){
		solve();
	} 
	return 0;
}



Submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
int a[100005],b[100005],c[100005];
void solve(){
	memset(b,0,sizeof(b));
	memset(a,0,sizeof(a));
	memset(c,0,sizeof(c));
	int n,l,r;
	cin>>n>>l>>r;
	int sum1=0,sum2=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=r;i++){
		b[i]=a[i];
	}
	sort(b+1,b+r+1);
	for(int i=1;i<=r-l+1;i++){
		sum1+=b[i];
	}
	for(int i=l;i<=n;i++){
		c[i-l+1]=a[i];
	}
	sort(c+1,c+n-l+2);
	for(int i=1;i<=r-l+1;i++){
		sum2+=c[i];
	}
	cout<<min(sum1,sum2)<<endl;
}
int main(int argc, char** argv) {
	int t;
	cin>>t;
	while(t--){
		solve();
	} 
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
int a[100005];
void solve(){
	memset(a,0,sizeof(a));
	int n,l,r;
	cin>>n>>l>>r;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	ll ans=0;
	for(int i=1;i<=r-l+1;i++){
		ans+=a[i];
	}
	cout<<ans<<endl;
}
int main(int argc, char** argv) {
	int t;
	cin>>t;
	while(t--){
		solve();
	} 
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
int a[100005],b[100005],c[100005];
void solve(){
	memset(b,0,sizeof(b));
	memset(a,0,sizeof(a));
	memset(c,0,sizeof(c));
	int n,l,r;
	cin>>n>>l>>r;
	int sum1=0,sum2=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=r;i++){
		b[i]=a[i];
	}
	sort(b+1,b+r+1);
	for(int i=1;i<=r-l+1;i++){
		sum1+=b[i];
	}
	for(int i=l;i<=n;i++){
		c[i-l+1]=a[i];
	}
	sort(c+1,c+n-l+2);
	for(int i=1;i<=r-l+1;i++){
		sum2+=c[i];
	}
	cout<<min(sum1,sum2)<<endl;
}
int main(int argc, char** argv) {
	int t;
	cin>>t;
	while(t--){
		solve();
	} 
	return 0;
}



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

using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

#define ll long long

const int maxx=1e5+5;

ll a[maxx],b[maxx],c[maxx];

void solve(){

	int n,l,r;

	cin>>n>>l>>r;

	for(int i=1;i<=n;i++){

		cin>>a[i];

	}

	for(int i=1;i<=r;i++){

		b[i]=a[i];

	}

	sort(b+1,b+r+1);

	ll ans=0;

	for(int i=1;i<=r-l+1;i++){

		ans+=b[i];

	}

	for(int i=l;i<=n;i++){

		c[i-l+1]=a[i];

	}

	sort(c+1,c+n-l+1+1);

	ll cnt=0;

	for(int i=1;i<=r-l+1;i++){

		cnt+=c[i];

	}

	ll x=min(ans,cnt);

	cout<<x<<endl;

}

int main(int argc, char** argv) {

	int t;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

#define int long long

bitset<9> b;

void solve() {
    b.reset();
    string s;
    cin >> s;
    int sum = 0;
    b[0] = 1;
    for(auto c:s) {
        int x = c-'0';
        sum += x;
        if(x!=1 && x*x<10) {
            int y = x*x;
            b|=(b>>(y-x));
            b|=(b<<(9-(y-x)));
        }
        // for(int i=0;i<10;i++) {
        //     cout << b[i];
        // }
        // cout << "\n";
    }
    // cout << sum << "\n";
    if(b[sum%9]) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    cin >> t;
    while(t--) solve();
}
Problem: 2050C - Uninteresting Number
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

bitset<9> b;

void solve() {
    b.reset();
    string s;
    cin >> s;
    int sum = 0;
    b[0] = 1;
    for(auto c:s) {
        int x = c-'0';
        sum += x;
        if(x!=1 && x*x<10) {
            int y = x*x;
            b|=(b>>(y-x));
            b|=(b<<(9-(y-x)));
        }
        // for(int i=0;i<10;i++) {
        //     cout << b[i];
        // }
        // cout << "\n";
    }
    // cout << sum << "\n";
    if(b[sum%9]) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    cin >> t;
    while(t--) solve();
}

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

#define int long long

bitset<9> b;

void solve() {
    b.reset();
    string s;
    cin >> s;
    int sum = 0;
    b[0] = 1;
    for(auto c:s) {
        int x = c-'0';
        sum = (sum+x)%9;
        if(x>1 && x<4) {
            int y = x*x;
            b|=(b>>(y-x));
            b|=(b<<(9-(y-x)));
        }
        // for(int i=0;i<10;i++) {
        //     cout << b[i];
        // }
        // cout << "\n";
    }
    // cout << sum << "\n";
    if(b[sum]) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    cin >> t;
    while(t--) solve();
}
Problem: 2050C - Uninteresting Number
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

bitset<9> b;

void solve() {
    b.reset();
    string s;
    cin >> s;
    int sum = 0;
    b[0] = 1;
    for(auto c:s) {
        int x = c-'0';
        sum = (sum+x)%9;
        if(x>1 && x<4) {
            int y = x*x;
            b|=(b>>(y-x));
            b|=(b<<(9-(y-x)));
        }
        // for(int i=0;i<10;i++) {
        //     cout << b[i];
        // }
        // cout << "\n";
    }
    // cout << sum << "\n";
    if(b[sum]) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    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;
    int sum = 0;
    map<int, int> cnt;
    for(auto c:s) {
        int x = c-'0';
        sum += x;
        if(x>1 && x<4) {
            cnt[x]++;
        }
        // for(int i=0;i<10;i++) {
        //     cout << b[i];
        // }
        // cout << "\n";
    }
    for(int i=0;i<=min(9LL, cnt[2]);i++) {
        for(int j=0;j<=min(9LL, cnt[3]);j++) {
            int sum2 = sum + i*(4-2) + j*(9-3);
            if(sum2 % 9 == 0) {
                cout << "YES\n";
                return;
            }
        }
    }
    cout << "NO\n";
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    cin >> t;
    while(t--) solve();
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

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

#define int long long

const int MAX_N = 1e3+5, INF = 1e9+5;
int dp[MAX_N][MAX_N];

void solve() {
    string a,b,c;
    cin >> a >> b >> c;
    a = " "+a;
    b = " "+b;
    c = " "+c;
    for(int i=0;i<=a.size();i++) {
        for(int j=0;j<=b.size();j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 1;
    dp[1][0] = a[1] != c[1];
    dp[0][1] = b[1] != c[1];
    for(int i=0;i<=a.size();i++) {
        for(int j=0;j<=b.size();j++) {
            if(i) dp[i][j] = min(dp[i][j], dp[i-1][j] + (a[i] != c[i+j]));
            if(j) dp[i][j] = min(dp[i][j], dp[i][j-1] + (b[j] != c[i+j]));
        }
    }
    // for(int i=0;i<=a.size();i++) {
    //     for(int j=0;j<=b.size();j++) {
    //         cout << i << " " << j << " " << dp[i][j] << "\n";
    //     }
    // }
    cout << dp[a.size()][b.size()] << "\n";
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    cin >> t;
    while(t--) solve();
}

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

#define int long long

const int MAX_N = 2e3+5, INF = 1e9+5;
int dp[MAX_N][MAX_N];

void solve() {
    string a,b,c;
    cin >> a >> b >> c;
    a = " "+a;
    b = " "+b;
    c = " "+c;
    for(int i=0;i<=a.size();i++) {
        for(int j=0;j<=b.size();j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i=0;i<=a.size();i++) {
        for(int j=0;j<=b.size();j++) {
            if(i) dp[i][j] = min(dp[i][j], dp[i-1][j] + (a[i] != c[i+j]));
            if(j) dp[i][j] = min(dp[i][j], dp[i][j-1] + (b[j] != c[i+j]));
        }
    }
    // for(int i=0;i<a.size();i++) {
    //     for(int j=0;j<b.size();j++) {
    //         cout << i << " " << j << " " << dp[i][j] << "\n";
    //     }
    // }
    cout << dp[a.size()][b.size()] << "\n";
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    cin >> t;
    while(t--) solve();
}
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 MAX_N = 2e3+5, INF = 1e9+5;
int dp[MAX_N][MAX_N];

void solve() {
    string a,b,c;
    cin >> a >> b >> c;
    a = " "+a;
    b = " "+b;
    c = " "+c;
    for(int i=0;i<=a.size();i++) {
        for(int j=0;j<=b.size();j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i=0;i<=a.size();i++) {
        for(int j=0;j<=b.size();j++) {
            if(i) dp[i][j] = min(dp[i][j], dp[i-1][j] + (a[i] != c[i+j]));
            if(j) dp[i][j] = min(dp[i][j], dp[i][j-1] + (b[j] != c[i+j]));
        }
    }
    // for(int i=0;i<a.size();i++) {
    //     for(int j=0;j<b.size();j++) {
    //         cout << i << " " << j << " " << dp[i][j] << "\n";
    //     }
    // }
    cout << dp[a.size()][b.size()]-1 << "\n";
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    cin >> t;
    while(t--) solve();
}

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

#define int long long

const int MAX_N = 2e3+5, INF = 1e9+5;
int dp[MAX_N][MAX_N];

void solve() {
    string a,b,c;
    cin >> a >> b >> c;
    a = " "+a;
    b = " "+b;
    c = " "+c;
    for(int i=0;i<=a.size();i++) {
        for(int j=0;j<=b.size();j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i=0;i<a.size();i++) {
        for(int j=0;j<b.size();j++) {
            if(i) dp[i][j] = min(dp[i][j], dp[i-1][j] + (a[i] != c[i+j]));
            if(j) dp[i][j] = min(dp[i][j], dp[i][j-1] + (b[j] != c[i+j]));
        }
    }
    cout << dp[a.size()-1][b.size()-1] << "\n";
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    cin >> t;
    while(t--) solve();
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

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

#define int long long

const int MAX_N = 2e3+5, INF = 1e9+5;
int dp[MAX_N][MAX_N];

void solve() {
    string a,b,c;
    cin >> a >> b >> c;
    a = " "+a;
    b = " "+b;
    c = " "+c;
    for(int i=0;i<=a.size();i++) {
        for(int j=0;j<=b.size();j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i=0;i<=a.size();i++) {
        for(int j=0;j<=b.size();j++) {
            if(i) dp[i][j] = min(dp[i][j], dp[i-1][j] + (a[i] != c[i+j]));
            if(j) dp[i][j] = min(dp[i][j], dp[i][j-1] + (b[j] != c[i+j]));
        }
    }
    // for(int i=0;i<a.size();i++) {
    //     for(int j=0;j<b.size();j++) {
    //         cout << i << " " << j << " " << dp[i][j] << "\n";
    //     }
    // }
    cout << dp[a.size()][b.size()] << "\n";
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    cin >> t;
    while(t--) solve();
}

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

#define int long long

const int MAX_N = 2e3+5, INF = 1e9+5;
int dp[MAX_N][MAX_N];

void solve() {
    string a,b,c;
    cin >> a >> b >> c;
    a = " "+a;
    b = " "+b;
    c = " "+c;
    for(int i=0;i<=a.size();i++) {
        for(int j=0;j<=b.size();j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i=0;i<=a.size();i++) {
        for(int j=0;j<=b.size();j++) {
            if(i) dp[i][j] = min(dp[i][j], dp[i-1][j] + (a[i] != c[i+j]));
            if(j) dp[i][j] = min(dp[i][j], dp[i][j-1] + (b[j] != c[i+j]));
        }
    }
    // for(int i=0;i<a.size();i++) {
    //     for(int j=0;j<b.size();j++) {
    //         cout << i << " " << j << " " << dp[i][j] << "\n";
    //     }
    // }
    cout << dp[a.size()][b.size()]-1 << "\n";
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    cin >> t;
    while(t--) solve();
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


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

#define int long long

const int MAX_N = 1e3+5, INF = 1e9+5;
int dp[MAX_N][MAX_N];

void solve() {
    string a,b,c;
    cin >> a >> b >> c;
    a = " "+a;
    b = " "+b;
    c = " "+c;
    for(int i=0;i<=a.size();i++) {
        for(int j=0;j<=b.size();j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 1;
    dp[1][0] = a[1] != c[1];
    dp[0][1] = b[1] != c[1];
    for(int i=0;i<=a.size();i++) {
        for(int j=0;j<=b.size();j++) {
            if(i) dp[i][j] = min(dp[i][j], dp[i-1][j] + (a[i] != c[i+j]));
            if(j) dp[i][j] = min(dp[i][j], dp[i][j-1] + (b[j] != c[i+j]));
        }
    }
    // for(int i=0;i<=a.size();i++) {
    //     for(int j=0;j<=b.size();j++) {
    //         cout << i << " " << j << " " << dp[i][j] << "\n";
    //     }
    // }
    cout << dp[a.size()][b.size()] << "\n";
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    cin >> t;
    while(t--) solve();
}