ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ll t;
cin>>t;
while(t--){
    ll n,l,r;
    cin>>n>>l>>r;
     ll cnt=r-l+1;
    ll a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    ll sum=0;
    if(l==1 or r==n){
        for(int i=0;i<cnt;i++){
            sum+=b[i];
        }
        cout<<sum<<endl;
    }
    else{
            ll mn=b[cnt-1],cnt1=0,cnt2=0;
            ll lf[r];
        for(int i=0;i<r;i++){
            lf[i]=a[i];
        }
    ll rf[n-l+1];
    for(int i=l-1;i<n;i++){
        rf[i]=a[i];
    }
    sort(lf,lf+r);
    sort(rf,rf+n-l+1);
    for(int i=0;i<r;i++){
        if(lf[i]<=mn) cnt1++;
        else break;
    }
    for(int i=0;i<n-l+1;i++){
        if(rf[i]<=mn) cnt2++;
        else break;
    }
    if(cnt1>=cnt2){
        for(int i=0;i<cnt;i++){
            sum+=lf[i];
        }
        cout<<sum<<endl;
    }
    else{
        for(int i=0;i<cnt;i++){
            sum+=rf[i];
        }
        cout<<sum<<endl;
    }
    }
}
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ll t;
cin>>t;
while(t--){
    ll n,l,r;
    cin>>n>>l>>r;
     ll cnt=r-l+1;
    ll a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    ll sum=0;
    if(l==1 or r==n){
        for(int i=0;i<cnt;i++){
            sum+=b[i];
        }
        cout<<sum<<endl;
    }
    else{
            ll mn=b[cnt-1],cnt1=0,cnt2=0;
            ll lf[r];
        for(int i=0;i<r;i++){
            lf[i]=a[i];
        }
    ll rf[n-l+1];
    for(int i=l-1;i<n;i++){
        rf[i-l]=a[i];
    }
    sort(lf,lf+r);
    sort(rf,rf+n-l+1);
    for(int i=0;i<r;i++){
        if(lf[i]<=mn) cnt1++;
        else break;
    }
    for(int i=0;i<n-l+1;i++){
        if(rf[i]<=mn) cnt2++;
        else break;
    }
    if(cnt1>=cnt2){
        for(int i=0;i<cnt;i++){
            sum+=lf[i];
        }
        cout<<sum<<endl;
    }
    else{
        for(int i=0;i<cnt;i++){
            sum+=rf[i];
        }
        cout<<sum<<endl;
    }
    }
}
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ll t;
cin>>t;
while(t--){
    ll n,l,r;
    cin>>n>>l>>r;
     ll cnt=r-l+1;
    ll a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    ll sum=0;
    if(l==1 or r==n){
        for(int i=0;i<cnt;i++){
            sum+=b[i];
        }
        cout<<sum<<endl;
    }
    else{
            ll mn=b[cnt-1],cnt1=0,cnt2=0;
            ll lf[r];
        for(int i=0;i<r;i++){
            lf[i]=a[i];
        }
    ll rf[n-l+1];
    for(int i=l-1;i<n;i++){
        rf[i]=a[i];
    }
    sort(lf,lf+r);
    sort(rf,rf+n-l+1);
    for(int i=0;i<r;i++){
        if(lf[i]<=mn) cnt1++;
        else break;
    }
    for(int i=0;i<n-l+1;i++){
        if(rf[i]<=mn) cnt2++;
        else break;
    }
    if(cnt1>=cnt2){
        for(int i=0;i<cnt;i++){
            sum+=lf[i];
        }
        cout<<sum<<endl;
    }
    else{
        for(int i=0;i<cnt;i++){
            sum+=rf[i];
        }
        cout<<sum<<endl;
    }
    }
}
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

#define ll long long

using namespace std;

int main(){

ll t;

cin>>t;

while(t--){

    ll n,l,r;

    cin>>n>>l>>r;

     ll cnt=r-l+1;

    ll a[n],b[n];

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

        cin>>a[i];

        b[i]=a[i];

    }

    sort(b,b+n);

    ll sum=0;

    if(l==1 or r==n){

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

            sum+=b[i];

        }

        cout<<sum<<endl;

    }

    else{

            ll mn=b[cnt-1],cnt1=0,cnt2=0;

            ll lf[r];

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

            lf[i]=a[i];

        }

        ll p=n-l+1,o=0;

    ll rf[p];

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

        rf[o]=a[i];

        o++;

    }

    sort(lf,lf+r);

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

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

        if(lf[i]<=mn) cnt1++;

        else break;

    }

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

        if(rf[i]<=mn) cnt2++;

        else break;

    }

    if(cnt1>=cnt2){

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

            sum+=lf[i];

        }

        cout<<sum<<endl;

    }

    else{

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

            sum+=rf[i];

        }

        cout<<sum<<endl;

    }

    }

}

}



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

#define ll long long

using namespace std;

int main(){

ll t;

cin>>t;

while(t--){

    ll n,l,r;

    cin>>n>>l>>r;

     ll cnt=r-l+1;

    ll a[n],b[n];

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

        cin>>a[i];

        b[i]=a[i];

    }

    sort(b,b+n);

    ll sum=0;

    if(l==1 or r==n){

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

            sum+=b[i];

        }

        cout<<sum<<endl;

    }

    else{

            ll mn=b[cnt-1],cnt1=0,cnt2=0;

            ll lf[r];

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

            lf[i]=a[i];

        }

        ll p=n-l+1,o=0;

    ll rf[p];

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

        rf[o]=a[i];

        o++;

    }

    sort(lf,lf+r);

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

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

        if(lf[i]<=mn) cnt1++;

        else break;

    }

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

        if(rf[i]<=mn) cnt2++;

        else break;

    }

    ll sum1=0,sum2=0;



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

            sum1+=lf[i];

        }







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

            sum2+=rf[i];

        }



    cout<<min(sum1,sum2)<<endl;



    }

}

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
//! Bismillahi-Rahamanirahim.
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define str string
#define vll vector<ll>
// vector<vector<ll>> a(n,vector<ll>(n,v));
// priority_queue <int, vector<int>, greater<int>> pq;
#define pl pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define sz(n) (ll)(n).size()
#define sp ' '
#define sfor(i, s, n, m) for (ll i = s; i < n; i += m)
#define refor(i, n, s, m) for (ll i = n - 1; i >= s; i -= m)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define eps 1e-12
#define mod 1000000007
#define MAX 100007
#define inf 1000000000000000000
#define pi (2 * acos(0))
#define torad(x) ((x) * ((2 * acos(0)) / 180.0))
#define todeg(x) ((x) * (180.0 / (2 * acos(0))))
#define fixangle(x) ((x) > 1 ? 1 : (x) < -1 : (x))
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define endl "\n"
#define mem(x, y) memset(&x[0], y, sizeof(x))
#define bs(v, x) binary_search(v.begin(), v.end(), x)
#define ub(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define lb(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define fast() ios_base::sync_with_stdio(0);
#define fast1() cin.tie(0);cout.tie(0);
//-------------------------------------------------------------------------//

int main()
{
    fast();
//    fast1();
    ll test = 1, cas = 1;
    cin >> test;
    while (test--)
    {
        ll n,f=0;
        cin >> n;
        vll a(n,0);
        sfor(i,0,n,1)
        {
            cin >> a[i];
        }
        refor(i,n-1,0,1)
        {
            if(a[i]>a[i+1] && i>0)
            {
                ll p=a[i]-a[i-1];
                if(p>0 && p>a[i+1])
                {
                    f=1;
                    break;
                }
                else if(p<0)
                {
                    a[i-1]=p;
                }
            }
            else if(a[i]>a[i+1] && i==0)
            {
                f=1;
                break;
            }
        }
        if(f)
            no;
        else
            yes;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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


void kamehameha(){
     
     int n; cin>>n;
     vector<long long>v(n);
     for(auto &it:v)cin>>it;
     
     if(n==1){
        cout<<v[0]<<'\n';
        return;
     }

     long long ans=accumulate(v.begin(),v.end(),0ll);
     while(n>1){

        for(int i=1;i<n;i++){
             v[i-1]=v[i]-v[i-1];
        }
        n--;
        long long mx=accumulate(v.begin(),v.begin()+n,0ll);
        ans=max(ans,mx);

     }

     cout<<max(ans,abs(v[0]))<<'\n';





}


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

      int t; cin>>t;
      while(t--)
      {
          kamehameha();

      }


    return 0;
}

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


void kamehameha(){
     
     int n; cin>>n;
     vector<long long>v(n);
     for(auto &it:v)cin>>it;
     
     if(n==1){
        cout<<v[0]<<'\n';
        return;
     }

     long long ans=accumulate(v.begin(),v.end(),0ll);
     while(n>1){

        for(int i=1;i<n;i++){
             v[i-1]=v[i]-v[i-1];
        }
        n--;
        long long mx=accumulate(v.begin(),v.begin()+n,0ll);
        ans=max(ans,abs(mx));

     }

     cout<<max(ans,abs(v[0]))<<'\n';





}


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

      int t; cin>>t;
      while(t--)
      {
          kamehameha();

      }


    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


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


void kamehameha(){
     
     int n; cin>>n;
     vector<long long>v(n);
     for(auto &it:v)cin>>it;
     
     if(n==1){
        cout<<v[0]<<'\n';
        return;
     }

     long long ans=accumulate(v.begin(),v.end(),0ll);
     while(n>1){
        for(int i=1;i<n;i++){
             v[i-1]=v[i]-v[i-1];
        }
        n--;
     }

     cout<<max(ans,abs(v[0]))<<'\n';





}


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

      int t; cin>>t;
      while(t--)
      {
          kamehameha();

      }


    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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


void kamehameha(){
     
     int n; cin>>n;
     vector<long long>v(n);
     for(auto &it:v)cin>>it;
     
     if(n==1){
        cout<<v[0]<<'\n';
        return;
     }

     long long ans=accumulate(v.begin(),v.end(),0ll);
     while(n>1){
        for(int i=1;i<n;i++){
             v[i-1]=v[i]-v[i-1];
        }
        n--;
     }

     cout<<max(ans,abs(v[0]))<<'\n';





}


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

      int t; cin>>t;
      while(t--)
      {
          kamehameha();

      }


    return 0;
}

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


void kamehameha(){
     
     int n; cin>>n;
     vector<long long>v(n);
     for(auto &it:v)cin>>it;
     
     if(n==1){
        cout<<v[0]<<'\n';
        return;
     }

     long long ans=accumulate(v.begin(),v.end(),0ll);
     while(n>1){

        for(int i=1;i<n;i++){
             v[i-1]=v[i]-v[i-1];
        }
        n--;
        long long mx=accumulate(v.begin(),v.begin()+n,0ll);
        ans=max(ans,mx);

     }

     cout<<max(ans,abs(v[0]))<<'\n';





}


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

      int t; cin>>t;
      while(t--)
      {
          kamehameha();

      }


    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


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

signed main(){
    int t; cin >> t;
    while(t--){
        int n,m; cin >> n >> m;
        int A[n],B[m];

        for(int i = 0; i <n;i++){
            cin >> A[i];
        }
        for(int i = 0; i < m;i++){
            cin >> B[i];
        }

        multiset<int> s1,s2;
        for(auto i : A){
            s1.insert(i);
        }
        for(auto i : B){
            s2.insert(i);
        }

        bool flag = true;
        int tt = 0;
        while(true){
            tt +=1;
            if(tt == 40){break;}
            if(s1.size() == 0 || s2.size() == 0){
                break;
            }
            auto x = s1.end();
            x = prev(x);
            auto y = s2.end();
            y = prev(y);
           
            if(*x == *y){
                s1.erase(x);
                s2.erase(y);
            }

            else{

                if(*x > *y){
                    flag = false;
                    break;
                }
                if(s1.size() == s2.size()){break;}
                int pp = *y;

                s2.erase(y);

                int t1 = pp/2;
                int t2 = pp - t1;
                s2.insert(t1);
                s2.insert(t2);
                
            }

        }

        if(s1.size() == 0 && s2.size() == 0){
            cout << "Yes" << endl;
        }


        else{

            vector<int> v1,v2;
            for(auto i : s1){
                v1.push_back(i);
            }
            for(auto i : s2){
                v2.push_back(i);
            }

            if(v1.size() != v2.size()){
                cout << "No" << endl;
                continue;
            }

            bool flag = true;
            for(int i = 0; i < v1.size();i++){
                if(v1[i] != v2[i]){
                    flag = false;
                    break;
                }
            }

            if(flag){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }

            
        }


    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k,t;
    cin>>t;
    for(k=0;k<t;k++)
    {
        long long n,i,maxi,sum=0,p;
        cin>>n;
        p=n;
        int a[n];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            sum=sum+a[i];
        }
        maxi=sum;
        sum=0;
        while(n!=1)
        {
            for(i=0;i<n-1;i++)
            {
                a[i]=a[i+1]-a[i];
                sum=sum+a[i];
            }
            maxi=max(maxi,abs(sum*1LL));
            sum=0;
            n--;
        }
        cout<<maxi<<endl;
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k,t;
    cin>>t;
    for(k=0;k<t;k++)
    {
        long long n,i,maxi,sum=0,p;
        cin>>n;
        p=n;
        long long a[n];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            sum=sum+a[i];
        }
        maxi=sum;
        sum=0;
        while(n!=1)
        {
            for(i=0;i<n-1;i++)
            {
                a[i]=a[i+1]-a[i];
                sum=sum+a[i];
            }
            maxi=max(maxi,abs(sum*1LL));
            sum=0;
            n--;
        }
        cout<<maxi<<endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k,t;
    cin>>t;
    for(k=0;k<t;k++)
    {
        long long n,i,maxi,sum=0,p;
        cin>>n;
        p=n;
        int a[n];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            sum=sum+a[i];
        }
        maxi=sum;
        sum=0;
        while(n!=1)
        {
            for(i=0;i<n-1;i++)
            {
                a[i]=a[i+1]-a[i];
                sum=sum+a[i];
            }
            maxi=max(maxi,abs(sum));
            sum=0;
            n--;
        }
        cout<<maxi<<endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k,t;
    cin>>t;
    for(k=0;k<t;k++)
    {
        long long n,i,maxi,sum=0,p;
        cin>>n;
        p=n;
        int a[n];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            sum=sum+a[i];
        }
        maxi=sum;
        sum=0;
        while(n!=1)
        {
            for(i=0;i<n-1;i++)
            {
                a[i]=a[i+1]-a[i];
                sum=sum+a[i];
            }
            maxi=max(maxi,abs(sum));
            sum=0;
            n--;
        }
        cout<<maxi<<endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k,t;
    cin>>t;
    for(k=0;k<t;k++)
    {
        long long n,i,maxi,sum=0,p;
        cin>>n;
        p=n;
        int a[n];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            sum=sum+a[i];
        }
        maxi=sum;
        sum=0;
        while(n!=1)
        {
            for(i=0;i<n-1;i++)
            {
                a[i]=a[i+1]-a[i];
                sum=sum+a[i];
            }
            maxi=max(maxi,abs(sum*1LL));
            sum=0;
            n--;
        }
        cout<<maxi<<endl;
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


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

#define ll long long
#define EB emplace_back
#define V(x) vector<x>
#define pii pair<int,int>
#define F first
#define S second
#define MP(x,y) make_pair(x,y)

using namespace std;

long long solve(){
	int n;
	cin>>n;
	V(V(int)) a(n+1);
	for(int i = 0; i < n-1; i++){
		int u,v;
		cin>>u>>v;
		a[u].EB(v);
		a[v].EB(u);
	}
	int x = a[1].size(), ix = 1, y = a[2].size(), iy = 2;
	for(int i = 3; i <= n; i++) {
		if(a[i].size() > x){
			y = x;
			iy = ix;
			x = a[i].size();
			ix = i;
		}
		else if(a[i].size() > y){
			y = a[i].size();
			iy = i;
		}
	}
	int count = 0;
	V(int) vis(n+1);
	vis[ix] = 1;
	vis[iy] = 1;
	auto dfs = [&](int start){
		queue<int>q;
		q.push(start);
		vis[start] = 1;
		while(q.size()){
			int frnt = q.front();
			q.pop();
			for(int adj : a[frnt]){
				if(vis[adj]) continue;
				q.push(adj);
				vis[adj] = 1;
			}
		}
	};
	for(int i = 1; i <= n; i++){
		if(vis[i]) continue;
		count++;
		dfs(i);
	}
	return count;
}

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

	#ifndef ONLINE_JUDGE
    freopen("in", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
	
	int tt;
	tt = 1;
	
	cin>>tt;
	
	for(int i = 1; i <= tt; i++)
	{
		cout<<solve()<<"\n";
		// solve();
	}    
	
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 11):
//
// Created by bahab on 7/24/2024.
//
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#ifndef ONLINE_JUDGE
#endif

const long long mod=1e9+7;
const long long MOD=998244353;
#define ll long long
#define endl '\n'
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define INF 1e18+5
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define bahab(x) cout << x
#define lb cout << endl;
#define show(x) for (auto it : x) cout << it << " "

ll binpow(ll a,ll b){ll res=1;while(b>0){if(b&1)res=(res*a);a=((a)*(a));b/=2;}return res;}
ll gcd(ll a,ll b){return b==0 ? a:gcd(b,a%b);}
ll lcm(ll a,ll b){return (a/gcd(a,b))*b;}
ll comb(ll n, ll k) {
    if (k > n) return 0;
    if (k == 0 || k == n) return 1;
    if (k == 1) return n;
    ll result = 1;
    for (ll i = 1; i <= k; ++i) { result *= (n - i + 1) / i; }
    return result;
}
// -----------------------------------------------------------------------

void solve(){
    int n, k; cin >> n >> k;
    vector<ll> arr(n);
    vector<pair<int, ll>> p;
    unordered_map<ll,int> mp;
    for (int i = 0; i < n ; i++){
        cin >> arr[i];
        mp[arr[i]]++;
    }
    for(auto it : mp){
        p.emplace_back(it.S, it.F);
    }
    sort(all(p));
    int ind = 0;
    for (auto it : p){
        if (k >= it.F){
            ind++;
            k -= it.F;
        }
        else break;
    }
//    cout << " k : " << k << endl;
//    cout << "p.size() : " << p.size() << endl;
    int res = p.size() - ind;
    cout << max(1, res) << endl;
}
// -----------------------------------------------------------------------

int main (){
    FAST;
    int tc = 1;
    cin >> tc;
    while (tc --)
        solve();
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define v(a) vector<(a)>
#define rep(a, i) for(int i = 0; i < (a); i++)
#define read(a, n) for(int i = 0; i < (n); i++){ cin >> a[i];}
#define pB pop_back
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define int long long
#define pi pair<int, int>
const int mod = 998244353;
#define bismillah ios::sync_with_stdio(0); cin.tie(0);
const int INF = 1e18;


void solve(){
    string aa, bb, c; cin >> aa >> bb >> c;

    vector<vector<int>> dp(2005, vector<int>(2005, 1e9));
    dp[0][0] = 0;
    int x = aa.size();
    int y = bb.size();
    for(int a = 0; a <= x; a++){
        for(int b = 0; b <= y; b++){  
            int z = a + b;

            if(a > 0 && aa[a-1] == c[z-1]){
                dp[a][b] = min(dp[a][b], dp[a-1][b]);
            }

            

            if(b > 0 && bb[b-1] == c[z-1]){
                dp[a][b] = min(dp[a][b], dp[a][b-1]);
            }

            if(a > 0) dp[a][b] = min(dp[a][b], dp[a-1][b] + 1);
            if(b > 0) dp[a][b] = min(dp[a][b], dp[a][b-1]+1);
            
        }
    }

    cout << dp[x][y];
    
}

signed main() {
    bismillah
    int t = 1;
    cin >> t;
    while(t--) {
        solve();
        cout << "\n";
    }
    return 0;
}