ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int t;cin>>t;
	while(t--){
		int n,l,r;cin>>n>>l>>r;
		int a[n+1],b[n+1];
		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);//从1排到r位置
		int ans=1e15,sum=0;
		for(int i=1;i<=r-l+1;i++) sum+=b[i];
		ans=sum;
		for(int i=l;i<=n;i++) b[i]=a[i];
		sort(b+l,b+n+1);/从l排到n位置
		sum=0;
		for(int i=l;i<=r;i++) sum+=b[i];
		ans=min(ans,sum);
		cout<<ans<<endl;
	}
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int t;cin>>t;
	while(t--){
		int n,l,r;cin>>n>>l>>r;
		int a[n+1],b[n+1];
		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);//从1排到r位置
		int ans=1e15,sum=0;
		for(int i=1;i<=r-l+1;i++) sum+=b[i];
		ans=sum;
		for(int i=l;i<=n;i++) b[i]=a[i];
		sort(b+l,b+n+1);//从l排到n位置
		sum=0;
		for(int i=l;i<=r;i++) sum+=b[i];
		ans=min(ans,sum);
		cout<<ans<<endl;
	}
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int t;cin>>t;
	while(t--){
		int n,l,r;cin>>n>>l>>r;
		int a[n+1];
		for(int i=1;i<=n;i++){
			cin>>a[i];
		}
		sort(a+1,a+1+n);
		vector<int> pre(n+1,0);
		for(int i=1;i<=n;i++) pre[i]=a[i]+pre[i-1];
		cout<<pre[r-l+1]<<endl;
	}
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

void asoiaf(){
    int n,k;
    cin>>n>>k;

    map<int,int> m;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        m[a]++;
    }
    vector<int> v;
    for(auto &p: m){
        v.push_back(p.second);
    }
    sort(v.begin(),v.end());
    int j=0;
    int res=v.size();
    while(k>0 && j<v.size()){
        k-=v[j];
        res--;
    }
    cout<<max(1,res)<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    int t;
    cin>>t;
    while(t--){
        asoiaf();
    }
}

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

void asoiaf(){
    int n,k;
    cin>>n>>k;

    map<int,int> m;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        m[a]++;
    }
    vector<int> v;
    for(auto &p: m){
        v.push_back(p.second);
    }
    sort(v.begin(),v.end());
    int j=0;
    int res=v.size();
    while(k>0 && j<v.size()){
        k-=v[j];
        res--;
        j++;
    }
    cout<<max(1,res)<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    int t;
    cin>>t;
    while(t--){
        asoiaf();
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


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

void asoiaf(){
    int n,k;
    cin>>n>>k;

    map<int,int> m;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        m[a]++;
    }
    vector<int> v;
    for(auto &p: m){
        v.push_back(p.second);
    }
    sort(v.begin(),v.end());
    int j=0;
    int res=v.size();
    while(k>0 && j<v.size()){
        k-=v[j];
        res--;
    }
    cout<<max(1,res)<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    int t;
    cin>>t;
    while(t--){
        asoiaf();
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

void asoiaf(){
    int n,k;
    cin>>n>>k;

    map<int,int> m;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        m[a]++;
    }
    vector<int> v;
    for(auto &p: m){
        v.push_back(p.second);
    }
    sort(v.begin(),v.end());
    int j=0;
    int res=v.size();
    while(k>0 && j<v.size()){
        if(k>=v[j]){

            res--;
        }
        else{
            cout<<max(1,res)<<'\n';
            return;
        }
        j++;
    }
    cout<<max(1,res)<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    int t;
    cin>>t;
    while(t--){
        asoiaf();
    }
}

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

void asoiaf(){
    int n,k;
    cin>>n>>k;

    map<int,int> m;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        m[a]++;
    }
    vector<int> v;
    for(auto &p: m){
        v.push_back(p.second);
    }
    sort(v.begin(),v.end());
    int j=0;
    int res=v.size();
    while(k>0 && j<v.size()){
        if(k>=v[j]){
            k-=v[j];
            res--;
        }
        else{
            cout<<max(1,res)<<'\n';
            return;
        }
        j++;
    }
    cout<<max(1,res)<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    int t;
    cin>>t;
    while(t--){
        asoiaf();
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

void asoiaf(){
    int n,k;
    cin>>n>>k;

    map<int,int> m;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        m[a]++;
    }
    vector<int> v;
    for(auto &p: m){
        v.push_back(p.second);
    }
    sort(v.begin(),v.end());
    int j=0;
    int res=v.size();
    while(k>0 && j<v.size()){
        k-=v[j];
        res--;
        j++;
    }
    cout<<max(1,res)<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    int t;
    cin>>t;
    while(t--){
        asoiaf();
    }
}

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

void asoiaf(){
    int n,k;
    cin>>n>>k;

    map<int,int> m;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        m[a]++;
    }
    vector<int> v;
    for(auto &p: m){
        v.push_back(p.second);
    }
    sort(v.begin(),v.end());
    int j=0;
    int res=v.size();
    while(k>0 && j<v.size()){
        if(k>=v[j]){

            res--;
        }
        else{
            cout<<max(1,res)<<'\n';
            return;
        }
        j++;
    }
    cout<<max(1,res)<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    int t;
    cin>>t;
    while(t--){
        asoiaf();
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 17):
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <ios>
#include <map>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
const int MOD = 1e9+7;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll tt = 1;
    cin >> tt;
    while (tt--) {
        auto solve = [&]()
        {
            ll n, m, k, x, y;
            
            cin>>n>>m;
            multiset<ll> a;
            vector<ll> b;

            for (int i = 0; i < n; i++) {
                cin>>x;
                a.insert(x);
            }

            for (int i = 0; i < m; i++) {
                cin>>x;
                b.push_back(x);
            }

            auto f = [&] (ll  x, auto &&f) -> bool {
                if(a.count(x)) {
                    a.erase(a.find(x));
                    return true;
                }
                else if(!a.size()) return false;
                else if(*a.begin()>x) return false;
                else return f(x/2, f)&& f(x-x/2, f);
            };

            bool ok = true;
            for (int i = 0; i < m; i++) {
                if(!f(b[i], f)) {
                    ok = false;
                    break;
                }
            }
            
            if(a.size()) ok = false;
            cout<<(ok ? "YES" : "NO");


            cout<<endl;
        };
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


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

using namespace std;

#define fastio()                      \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define nline "\n"
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcountll
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

#ifndef ONLINE_JUDGE
#define debug(x)       \
	cerr << #x << " "; \
	_print(x);         \
	cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(lld t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(ull t) { cerr << t; }

template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p)
{
	cerr << "{";
	_print(p.ff);
	cerr << ",";
	_print(p.ss);
	cerr << "}";
}
template <class T>
void _print(vector<T> v)
{
	cerr << "[ ";
	for (T i : v)
	{
		_print(i);
		cerr << " ";
	}
	cerr << "]";
}
template <class T>
void _print(set<T> v)
{
	cerr << "[ ";
	for (T i : v)
	{
		_print(i);
		cerr << " ";
	}
	cerr << "]";
}
template <class T>
void _print(multiset<T> v)
{
	cerr << "[ ";
	for (T i : v)
	{
		_print(i);
		cerr << " ";
	}
	cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v)
{
	cerr << "[ ";
	for (auto i : v)
	{
		_print(i);
		cerr << " ";
	}
	cerr << "]";
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("Error.txt", "w", stderr);
#endif
	int t;
	cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		bool ans = false;
		map<int, int> mp;
		ll sum = 0;
		while (n > 0)
		{
			sum += n % 10;
			if (n % 10 == 2 || n % 10 == 3)
			{
				mp[n % 10]++;
			}
			n /= 10;
		}
		if (sum % 9 == 0)
		{
			ans = true;
		}
		else
		{
			ll k = mp[2];
			ll m = mp[3];
			for (int i = 0; i <= k; i++)
			{
				for (int j = 0; j <= m; j++)
				{
					if ((sum += (2 * i + 6 * j)) % 9 == 0)
					{
						ans = true;
						break;
					}
				}
				if (ans)
				{
					break;
				}
			}
		}
		cout << (ans ? "YES" : "NO") << '\n';
	}
}
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;
    while(t--)
    {
         
        long long int n;
        cin >> n;
        long long int sum =0,digit,tcount=0,threecount=0;
        while(n!=0){
            sum += n%10;
            if(n%10 == 2)
            {
                tcount++;
            }
            else if(n%10==3)
            {
                threecount++;
            }
            n = n/10;
        }
        int flag=0;
        for(int i=0;i<=8&&i<=tcount;i++){
            for(int j=0;j<=8&&j<=threecount;j++)
            {
                if((sum+ 2*i + 6*j)%9==0)
                {
                    flag =1;
                }
            }
        }
        if(flag){
            cout << "YES\n";
        }
        else cout << "NO\n";
    }

    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
         
        long long int n;
        cin >> n;
        long long int sum =0,tcount=0,threecount=0;
        while(n!=0){
            sum += n%10;
            if(n%10 == 2)
            {
                tcount++;
            }
            else if(n%10==3)
            {
                threecount++;
            }
            n = n/10;
        }
        int flag=0;
        for(int i=0;(i<=10)&&(i<=tcount);i++){
            for(int j=0;(j<=10)&&(j<=threecount);j++)
            {
                if((sum+ 2*i + 6*j)%9==0)
                {
                    flag =1;
                }
            }
        }
        if(flag){
            cout << "YES\n";
        }
        else cout << "NO\n";
    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
         
        long long int n;
        cin >> n;
        long long int sum =0,digit,tcount=0,threecount=0;
        while(n!=0){
            sum += n%10;
            if(n%10 == 2)
            {
                tcount++;
            }
            else if(n%10==3)
            {
                threecount++;
            }
            n = n/10;
        }
        int flag=0;
        for(int i=0;i<=8&&i<=tcount;i++){
            for(int j=0;j<=8&&j<=threecount;j++)
            {
                if((sum+ 2*i + 6*j)%9==0)
                {
                    flag =1;
                }
            }
        }
        if(flag){
            cout << "YES\n";
        }
        else cout << "NO\n";
    }

    return 0;
}
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;
    while(t--)
    {
         
        long long int n;
        cin >> n;
        long long int sum =0,tcount=0,threecount=0;
        while(n!=0){
            sum += n%10;
            if(n%10 == 2)
            {
                tcount++;
            }
            else if(n%10==3)
            {
                threecount++;
            }
            n = n/10;
        }
        int flag=0;
        for(int i=0;(i<=10)&&(i<=tcount);i++){
            for(int j=0;(j<=10)&&(j<=threecount);j++)
            {
                if((sum+ 2*i + 6*j)%9==0)
                {
                    flag =1;
                }
            }
        }
        if(flag){
            cout << "YES\n";
        }
        else cout << "NO\n";
    }

    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
         
        string n;
        cin >> n;
        long long int sum =0,tcount=0,threecount=0;
        for(char c : n)
        {
            int digit = c -'0';
            sum += digit;
            if(digit ==2)
            {
                tcount++;
            }
            else if(digit==3)
            {
                threecount++;
            }
        }
        int flag=0;
        for(int i=0;(i<=10)&&(i<=tcount);i++){
            for(int j=0;(j<=10)&&(j<=threecount);j++)
            {
                if((sum+ (2*i) + (6*j))%9==0)
                {
                    flag =1;
                    break;
                }
            }
        }
        if(flag){
            cout << "YES\n";
        }
        else cout << "NO\n";
    }

    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

using namespace std;

void solve(){

int n;

cin >> n;

vector<long long> a(n);

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

cin >> a[i];

}

if(n==2){

if(a[0]<=a[1]){

cout <<"YES\n";

}

else cout <<"NO\n";

return;

}

if(n==3){

if(max(a[0],a[1])-min(a[0],a[1])<=a[2]){

cout <<"YES\n";

}

else cout << "NO\n";

return;

}

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

if(max(a[i],a[i-1])-min(a[i],a[i-1])>=a[i+1]){

cout << "NO\n";

return;

}

else{

long long temp = min(a[i],a[i-1]);

a[i]-= temp;

a[i-1] -= temp;

}

}

if(a[n-1]>=a[n-2]){

cout <<"YES\n";

}

else cout <<"NO\n";

}

int main()

{

int t;

cin >> t;

while(t--){

solve();

}

return 0;

}

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

using namespace std;

void solve(){

int n;

cin >> n;

vector<long long> a(n);

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

cin >> a[i];

}

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

int temp = min(a[i],a[i+1]);

a[i]-=temp;

a[i+1]-=temp;

}

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

if(a[i]>a[i+1]){

cout << "NO\n";

return;

}

}

cout << "YES\n";



}

int main()

{

int t;

cin >> t;

while(t--){

solve();

}

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

using namespace std;

void solve(){

int n;

cin >> n;

vector<long long> a(n);

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

cin >> a[i];

}

if(n==2){

if(a[0]<=a[1]){

cout <<"YES\n";

}

else cout <<"NO\n";

return;

}

if(n==3){

if(max(a[0],a[1])-min(a[0],a[1])>=a[2]){

cout <<"YES\n";

}

else cout << "NO\n";

return;

}

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

if(max(a[i],a[i-1])-min(a[i],a[i-1])>=a[i+1]){

cout << "NO\n";

return;

}

else{

long long temp = min(a[i],a[i-1]);

a[i]-= temp;

a[i-1] -= temp;

}

}

if(a[n-1]>=a[n-2]){

cout <<"YES\n";

}

else cout <<"NO\n";

}

int main()

{

int t;

cin >> t;

while(t--){

solve();

}

return 0;

}

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

using namespace std;

void solve(){

int n;

cin >> n;

vector<long long> a(n);

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

cin >> a[i];

}

if(n==2){

if(a[0]<=a[1]){

cout <<"YES\n";

}

else cout <<"NO\n";

return;

}

if(n==3){

if(max(a[0],a[1])-min(a[0],a[1])<=a[2]){

cout <<"YES\n";

}

else cout << "NO\n";

return;

}

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

if(max(a[i],a[i-1])-min(a[i],a[i-1])>=a[i+1]){

cout << "NO\n";

return;

}

else{

long long temp = min(a[i],a[i-1]);

a[i]-= temp;

a[i-1] -= temp;

}

}

if(a[n-1]>=a[n-2]){

cout <<"YES\n";

}

else cout <<"NO\n";

}

int main()

{

int t;

cin >> t;

while(t--){

solve();

}

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

using namespace std;

void solve(){

int n;

cin >> n;

vector<long long> a(n);

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

cin >> a[i];

}

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

if(max(a[i],a[i-1])-min(a[i],a[i-1])>a[i+1]){

cout << "NO\n";

return;

}

else{

long long temp = min(a[i],a[i-1]);

a[i]-= temp;

a[i-1] -= temp;

}

}

if(a[n-1]>a[n-2]){

cout <<"YES\n";

}

else cout <<"NO\n";

}

int main()

{

int t;

cin >> t;

while(t--){

solve();

}

return 0;

}

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

using namespace std;

void solve(){

int n;

cin >> n;

vector<long long> a(n);

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

cin >> a[i];

}

if(n==2){

if(a[0]<=a[1]){

cout <<"YES\n";

}

else cout <<"NO\n";

return;

}

if(n==3){

if(max(a[0],a[1])-min(a[0],a[1])>=a[2]){

cout <<"YES\n";

}

else cout << "NO\n";

return;

}

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

if(max(a[i],a[i-1])-min(a[i],a[i-1])>=a[i+1]){

cout << "NO\n";

return;

}

else{

long long temp = min(a[i],a[i-1]);

a[i]-= temp;

a[i-1] -= temp;

}

}

if(a[n-1]>=a[n-2]){

cout <<"YES\n";

}

else cout <<"NO\n";

}

int main()

{

int t;

cin >> t;

while(t--){

solve();

}

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

using namespace std;

void solve(){

int n;

cin >> n;

vector<long long> a(n);

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

cin >> a[i];

}

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

if(max(a[i],a[i-1])-min(a[i],a[i-1])>a[i+1]){

cout << "NO\n";

return;

}

else{

long long temp = min(a[i],a[i-1]);

a[i]-= temp;

a[i-1] -= temp;

}

}

if(a[n-1]>a[n-2]){

cout <<"YES\n";

}

else cout <<"NO\n";

}

int main()

{

int t;

cin >> t;

while(t--){

solve();

}

return 0;

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

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define all(s) s.begin(),s.end()
typedef long long ll;
const double pi = acos(-1),ef=1e-9;
const ll N=5e5+5,M=1e9+7,H=131,inf=1e9;

string a,b,c;
ll mm[2002][2002];
ll rec(ll i,ll sa)
{
	ll sb=(i-sa);
	if(i>=a.size()+b.size()){
		if(sa>=a.size() && sb>=b.size())return 0;
		return inf;
	}
	auto ans=mm[i][sa];
	if(ans!=-1)return ans;
	ans=1+min(rec(i+1,sa),rec(i+1,sa+1));
	if(sa<a.size()){
		if(c[i]==a[sa]){
			ans=min(ans,rec(i+1,sa+1));
		}
	}
	
	if(sb<b.size()){
		if(b[sb]==c[i]){
			ans=min(ans,rec(i+1,sa));
		}
	}
	return ans;



}

void solve()
{
	cin>>a>>b>>c;
	for(ll i=0;i<=c.size();i++){
		for(ll j=0;j<=a.size();j++){
			mm[i][j]=-1;
		}
	}
	cout<<rec(0,0)<<"\n";

}




int main()
{
    fast;
    ll t=1,tc=1;
    cin>>tc;
    while(tc--)
    {
       // cout<<"Case "<<t++<<":\n";
        solve();//cout<<"\n";
        // cout.flush();
    }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define all(s) s.begin(),s.end()
typedef long long ll;
const double pi = acos(-1),ef=1e-9;
const ll N=5e5+5,M=1e9+7,H=131,inf=1e9;

string a,b,c;
ll mm[1002][1002];
ll rec(ll i,ll j)
{
	if(i+j>=c.size()){
		return 0;
	}

	ll &ans=mm[i][j];
	if(ans!=-1)return ans;

	if(i<a.size() && c[i+j]==a[i]){
		ans=rec(i+1,j);
	}
	else ans=1+rec(i+1,j);


	if(j<b.size() && c[i+j]==b[j]){
		ans=min(ans,rec(i,j+1));
	}
	else ans=min(ans,1+rec(i,j+1));

	return ans;

}

void solve()
{
	cin>>a>>b>>c;
	for(ll i=0;i<=a.size();i++){
		for(ll j=0;j<=b.size();j++){
			mm[i][j]=-1;
		}
	}
	cout<<rec(0,0)<<"\n";

}




int main()
{
    fast;
    ll t=1,tc=1;
    cin>>tc;
    while(tc--)
    {
       // cout<<"Case "<<t++<<":\n";
        solve();//cout<<"\n";
        // cout.flush();
    }
}