ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 93 ms):
#include <iostream>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);init_code();
#include<bits/stdc++.h>
#define ll long long 
#define read(x) int x;cin>>x;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vb vector<bool>
#define ld long double 
using namespace std;

void init_code(){
	#ifndef ONLINE_JUDGE
	freopen("inputf.txt","r",stdin);
	freopen("outputf.txt","w",stdout);
	#endif
}

void solve(){
	ll n,l,r;
	cin >>n>>l>>r;
	l--; r--;
	vl a1,a2;
	for (int i=0;i<n;i++){
		read(temp);
		if (i<=r)a1.push_back(temp);
		if (i>=l)a2.push_back(temp);
	}
	sort (a2.begin(),a2.end());
	sort (a1.begin(),a1.end());
	ll s1=0,s2 = 0;
	for (int i=0;i<(r-l+1);i++){
		s1 += a1[i];
		s2 += a2[i];
	}
	cout << min(s1,s2)<<endl; 
}

int main(){
	fast ;
	read(t);
	while (t--)solve();
	return 0;
}



Solution 2 (runtime: 93 ms):
#include <bits/stdc++.h>



using namespace std;

using ll = long long;



// https://codeforces.com/blog/entry/62393

struct custom_hash {

	static uint64_t splitmix64(uint64_t x) {

		// http://xorshift.di.unimi.it/splitmix64.c

		x += 0x9e3779b97f4a7c15;

		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;

		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;

		return x ^ (x >> 31);

	}



	size_t operator()(uint64_t x) const {

		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();

		return splitmix64(x + FIXED_RANDOM);

	}

};



void solve() {

	int n, l, r;

	cin >> n >> l >> r;

	vector<int> a, b, c;

	ll ref = 0;

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

		int x;

		cin >> x;

		if (i + 1 < l) {

			a.push_back(x);

		} else if (i + 1 <= r) {

			b.push_back(x);

			ref += x;

		} else {

			c.push_back(x);

		}

	}

	sort(a.begin(), a.end());

	sort(b.begin(), b.end());

	sort(c.begin(), c.end());



	ll ans = ref;

	ll test1 = ref;

	for (int i = 0, j = b.size() - 1; i < a.size() && j >= 0; i++, j--) {

		if (b[j] < a[i]) {

			break;

		}

		test1 += a[i];

		test1 -= b[j];

		ans = min(ans, test1);

	}

	ll test2 = ref;

	for (int i = 0, j = b.size() - 1; i < c.size() && j >= 0; i++, j--) {

		if (b[j] < c[i]) {

			break;

		}

		test2 += c[i];

		test2 -= b[j];

		ans = min(ans, test2);

	}

	cout << ans << endl;

}



int main() {

	ios::sync_with_stdio(false);

  cin.tie(nullptr);

  int tt;

	cin >> tt;

	while (tt--) {

		solve();

	}

}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 46 ms):
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define pb push_back
#define inf 1e9
using namespace std;

const int dim = 2e5+1, mod = 1e9+7;
int n, st, i;
ll a[dim];

//void op1(int a[], int& st)
//{
//    reverse(a+st, a+n+1);
//}

void op2(ll a[], int& st)
{
    int i;
    if (n-st+1 <= 1)
        return;
    st++;
    for (i = n; i >= st; i--)
        a[i] = a[i]-a[i-1];
//    cout << "a: ";
//    for (i = st; i <= n; i++)
//        cout << a[i] << ' ';
//    cout << endl;
}

ll sum(ll a[], int& st)
{
    ll rez = 0;
    for (int i = st; i <= n; i++)
        rez += a[i];
    if (n > 1)
        return abs(rez);
    return rez;
}

void solve()
{
    cin >> n;
    st = 1;
    ll rez = 0;
    for (i = 1; i <= n; i++)
        cin >> a[i], rez += a[i];
    while (n-st+1 > 1)
    {
        op2(a, st);
        rez = max(rez, sum(a, st));
    }
    cout << rez << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}


Solution 2 (runtime: 62 ms):
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define ENDL '\n'
#define MAXN 100001
#define mod 998244353
#define ft first
#define sd second
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef long double ld;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;

ll n, m, k;

ll binpow(ll a, ll b){
	if(b==0)return 1;
	if(b==1)return a;
	ll num=binpow(a,b>>1)%mod, p=1;
	if(b%2)p=a;
	ll part=(num*num)%mod;
	return (part*p)%mod;
}

const int mov_f[]={-1,0,1, 0};
const int mov_c[]={0,-1,0, 1};

void solve(){
    cin>>n;
    vll v(n);

    ll ans=0;
    for(int i=0; i<n; i++){
        cin>>v[i];
        ans+=v[i];
    }

    while(v.size()>1){
        ll sum1=0, sum2=0;
        vll a1, a2;
        for(int i=1; i<v.size(); i++){
            a1.push_back(v[i]-v[i-1]);
            sum1+=a1.back();
        }

        for(int i=v.size()-1; i>0; i--){
            a2.push_back(v[i-1]-v[i]);
            sum2+=a2.back();
        }

        if(sum1>sum2)v=a1;
        else v=a2;

        ans=max(ans, max(sum1, sum2));
        if(v.size()==1)break;
    }

    cout<<ans<<ENDL;
}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cout.precision(0);
    cout<<fixed;
	//freopen("fencedin.in", "r", stdin);
	//freopen("fencedin.out", "w", stdout);

	int t=1;
    cin>>t;
	while(t--)solve();

	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 62 ms):
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
#define int long long
typedef pair<int,int> pii;

const int N=100010;


void solve()
{
    int l,r;
    cin>>l>>r;
    int idx=0;
    for(int i=30;i>=0;i--)
    {
        if((l>>i&1)!=(r>>i&1))
        {
            idx=i;break;
        }
    }
    int a=l|(1<<idx)-1;
    int b=a+1;
    int c;
    if(a==l)c=r;
    else c=l;
    cout<<a<<" "<<b<<" "<<c<<endl;
}
signed main()
{ 
    int good_luck_to_you;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>good_luck_to_you;
    while(good_luck_to_you--)
    {
       solve();
    }
}

Solution 2 (runtime: 108 ms):
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair <int, int> P;
 
const int N = 2e5 + 5;
const int inf = 0x3f3f3f3f;



void solve()
{
	int l, r;
	int a = 0, b = 0, c = 0;
	cin >> l >> r;
	for (int i = 29; i >= 0; -- i) {
		if ((l ^ r) >> i & 1) {
			a |= 1 << i;
			b |= (1 << i) - 1;
			break;
		} else {
			a |= l & (1 << i);
			b |= r & (1 << i);
		}
	}
	c = l;
	while (c == a || c == b) {
		c ++;
	}
	cout << a << " " << b << " " << c << endl;
}

signed main()
{
    int T;
    cin >> T;
    
    while (T--) {
    	solve();	
	}
	
    return 0;
}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 171 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lb long double
#define ull unsigned long long
#define pb push_back
#define qq endl
#define fori(i,k,n) for(int i=int(k);i<int(n);i++)
#define revfor(i,n,k) for(int i=int(n);i>=int(k);i--)
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define srt(arr) sort(arr.begin(),arr.end())
#define rsrt(arr) sort(arr.rbegin(),arr.rend())
#define print(arr) for(int i=0;i<arr.size();i++){cout<<arr[i]<<" ";}
#define pri(x) cout<<(int)x<<endl
#define all(x) x.begin(),x.end()
ll mod = 1000000007;
int N = 1000000;

int dp[1001][1001];

int recur(string &a,string &b,string &c,int i,int j){
    if(i>=a.size() && j>=b.size())return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    int ans=1e9;
    if(i<a.size()){
        if(c[i+j]==a[i]){
            ans = min(ans,recur(a,b,c,i+1,j));
        }else{
            ans = min(ans,1+recur(a,b,c,i+1,j));
        }
    }
    if(j<b.size()){
        if(c[i+j]==b[j]){
            ans = min(ans,recur(a,b,c,i,j+1));
        }else{
            ans = min(ans,1+recur(a,b,c,i,j+1));
        }
    }
    return dp[i][j]=ans;
}

void solve() {
    string a,b,c;cin>>a>>b>>c;
    memset(dp,-1,sizeof(dp));
    cout<<recur(a,b,c,0,0)<<endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    solve();
    return 0;
}



Solution 2 (runtime: 77 ms):
#include<bits/stdc++.h>
using namespace std;

int minChange(int aIndex, int bIndex, string &a, string &b, string &c, vector<vector<int>> &dp) {
  if(aIndex + bIndex >= c.size())
    return 0;

  if(dp[aIndex][bIndex] != -1)
    return dp[aIndex][bIndex];

  int cIndex = aIndex + bIndex;
  int mn = c.size() - cIndex + 1;
  if(aIndex < a.size()) {
    if(a[aIndex] == c[cIndex])
      mn = min(mn, minChange(aIndex + 1, bIndex, a, b, c, dp));
    mn = min(mn, minChange(aIndex + 1, bIndex, a, b, c, dp) + 1);
  }
  if(bIndex < b.size()) {
    if(b[bIndex] == c[cIndex])
      mn = min(mn, minChange(aIndex, bIndex + 1, a, b, c, dp));
    mn = min(mn, minChange(aIndex, bIndex + 1, a, b, c, dp) + 1);
  }
  return dp[aIndex][bIndex] = mn;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  int t;
  cin >> t;
  while(t--) {
    string a, b, c;
    cin >> a >> b >> c;

    vector<vector<int>> dp(a.size() + 1, vector<int> (b.size() + 1, -1));
    cout << minChange(0, 0, a, b, c, dp) << endl;
  }
}
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Solution 1 (runtime: 234 ms):
#include<bits/stdc++.h>

using namespace std;

#define ll long long int

bool comp (pair<ll, int> a, pair<ll, int> b) {
    return a.second < b.second;
}

int main(){
    int t;
    cin>>t;
    for (int ii = 0;ii<t;ii++) {
        int n,k;
        cin>>n>>k;
        if (k >= n-1){
            for (int j = 0 ; j < n; j++) {
                ll e;
                cin>>e;
            }
            cout <<"1"<<endl;
            continue;
        }
        vector<ll>values;
        //unordered_map<ll, int>values;
        for (int j = 0 ; j < n; j++) {
            ll e;
            cin>>e;
            values.push_back(e);
            //if (values.find(e) == values.end()) values[e] = 0;
            //values[e]+=1;
        }
        sort(values.begin(), values.end());
        vector<pair<ll, int> > vals;
        int c = 1;
        ll p = values[0];
        for (int i = 1;i < values.size();i++) {
            if (p == values[i]){
                c+=1;
            }
            else{
                pair<ll,int> pp;
                pp.first = p;
                pp.second = c;
                vals.push_back(pp);
                c = 1;
                p = values[i];
            }
        }
        pair<ll,int> pp;
        pp.first = p;
        pp.second = c;
        vals.push_back(pp);
        sort(vals.begin(), vals.end(), comp);
        int i = 0;
        while (i < vals.size()-1) {
            k-=vals[i].second;
            if (k < 0) break;
            i+=1;
        }
        cout<<vals.size()-i<<endl;

    }
    return 0;
}


Solution 2 (runtime: 109 ms):
#include<bits/stdc++.h>

using namespace std;

#define ll long long int
#define pb push_back
#define f first
#define s second
#define ld long double

// code for disjoint set union (by size)
ll findpar(ll node,vector<ll>&par){
    if(node==par[node]) return node;
    return par[node]=findpar(par[node],par);
}
void ubs(ll u, ll v,vector<ll>&par,vector<ll>&size){
    ll ulp_u=findpar(u,par);
    ll ulp_v=findpar(v,par);
    if(ulp_v==ulp_u) return;
    if(size[ulp_u]<size[ulp_v]){
        par[ulp_u]=ulp_v;
        size[ulp_v]+=size[ulp_u];
    }
    else{
        par[ulp_v]=ulp_u;
        size[ulp_u]+=size[ulp_v];
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    while(t--){
        ll n,k;
        cin >> n>>k;
        vector <ll> a(n);
        for(int i=0;i<n;i++) cin>>a[i];
        sort(a.begin(),a.end());
        map<ll,ll>m;
        for(int i=0;i<n;i++) m[a[i]]++;
        vector<pair<ll,ll>>temp;
        for(auto it:m){
            temp.pb({it.s,it.f});
        }
        sort(temp.begin(),temp.end());
        ll ans=0;
        for(int i=0;i<temp.size();i++){
            ll count=temp[i].f,num=temp[i].s;
            if(k>=count){
                temp[i].f=0;k-=count;
            }
            else break;
        }
        // for(auto it:m) cout<<it.f<<" "<<it.s<<endl;
    
        ans=1;
        ll c=0;
        for(auto it:temp) if(it.first>0) c++;
        // cout<<c<<endl;
        if(c==0 || c==1) cout<<1<<endl;
        else cout<<c<<endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 46 ms):
#include<iostream>
#include<vector>
#include<queue>
#include <cstdio>
#include<set>
#include<algorithm>
using namespace std;



int main(){

	// freopen("input.txt", "r", stdin);

	int test;
	cin >> test;
	while(test--){
		int n;
		long long sum = 0;
		cin >> n;
		vector<long long>vec(n);
		for(int i=0;i<n;i++){
			cin >> vec[i];
			sum += vec[i];
		}
		long long tmp;
		for(int i=1;i<n;i++){
			tmp = 0;
			for(int j=0;j<n-i;j++){
				vec[j] = vec[j+1] - vec[j];
				tmp += vec[j];
			}
			sum = max(sum,abs(tmp));
		}
		cout << sum << endl;

	}
	return 0;
}

Solution 2 (runtime: 46 ms):
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 998244353;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;cin>>n;
        vector<int>v(n);
        int sum = 0;
        for(int i=0;i<n;i++){
            cin>>v[i];
            sum += v[i];
        }
        int ans = sum;
        while(v.size()>1){
            //two options 
            vector<int>temp1;
            for(int i=1;i<v.size();i++){
                temp1.push_back(v[i]-v[i-1]);
            }
            ans = max(ans,abs(v.front()-v.back()));
            v.clear();
            for(auto it:temp1){
                v.push_back(it);
            }
        }
        cout<<ans<<"\n";

    }

    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 108 ms):
#include <bits/stdc++.h>

#define endl '\n'

typedef long long ll;

using namespace std;



void sol() {

    ll n;

    cin >> n;

    ll a[n];

    for (ll i = 0; i < n; i++) cin >> a[i];

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

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

            cout << "NO" << endl;

            return;

        }

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

    }

    cout << "YES" << endl;

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);



    #ifdef NGUYEN_PHUC_LOC

    freopen(".INP", "r", stdin);

    freopen(".OUT", "w", stdout);

    #endif



    ll t = 1;

    cin >> t;

    while (t--) {

        sol();

    }



    return 0;

}

Solution 2 (runtime: 312 ms):
#include<iostream>

#include<string.h>

#include<math.h>

#include<stack>

#include<queue>

#include<vector>

#include<algorithm>

#include<cmath>

#include<climits>

#include<cctype>

using namespace std;

#define int long long

const int N = 2e5 + 1;

int t, n;

int a[N];

int temp;

signed main() {

cin >> t;

while (t--) {

cin >> n;

temp = 0;

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

cin >> a[i];

}

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

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

a[i] -= x;

a[i + 1] -= x;

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

temp = 1;

break;

}

}

if (temp) {

cout << "NO" << endl;

}

else {

cout << "YES" << endl;

}



}

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 327 ms):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int tests;
    cin>>tests;
    for (int z=0;z<tests;z++){
        int size;
        cin>>size;
        vector<int> inputArray;
        for (int i=0;i<size;i++){
            int temp;
            cin>>temp;
            inputArray.push_back(temp);
        }
        bool endCheck = false;
        int i=0;
        while(i<inputArray.size()-1 && !endCheck){
            if (inputArray[i]<inputArray[i+1]){
                inputArray[i+1]=inputArray[i+1]-inputArray[i];
                inputArray[i]=0;
            }else{
                endCheck =true;
            }
            i++;
        }
        if (endCheck){
            cout<<"NO"<<endl;
        }else{
            cout<<"YES"<<endl;
        }
    }
}

Solution 2 (runtime: 343 ms):
#include<bits/stdc++.h>

using namespace std;

int main(){

    int t;

    cin >> t;

    while(t--){

        int n;

        bool dec = true;

        cin >> n;

        vector<int> a(n);

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

            cin >> a[i];

        }

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

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

            a[i+1] -= m;

            a[i] -= m; 

        }

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

            if(a[i+1] < a[i]) dec = false;

        }

        if(dec) cout << "Yes\n";

        else cout << "No\n";

    }

}
Problem: 2049C - MEX Cycle
Language: c++17 

Solution 1 (runtime: 77 ms):
#include<iostream>

#include<vector>

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n,x,y;

        cin>>n>>x>>y;

        vector<int>s;

         if(n%2==1){

            int op=0;

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

            if(i==y){s.push_back(2);}

            else{

                s.push_back(op);

                if(op)op=0;

                else op=1;

            }





            }

    

        }

        else{int op=0;

            if(x==1&&y==n||(y-x==1)){

                

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

              

                    s.push_back(op);

                    if(op)op=0;

                    else op=1;

                

            }}

           else if((y-x)%2==0){

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

                if(i==y){s.push_back(2);}

                else{

                    s.push_back(op);

                   

                }

                    if(op)op=0;

                    else op=1;



            }}

            else{if(x%2)op=1;

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

                    if(i==x){

                        s.push_back(op);

                        if(op)op=0;

                        else op=1;

                        i++;i++;

                        s.push_back(2);

                        s.push_back(op);

                        if(op)op=0;

                        else op=1;

                        continue;

                    }

                    if(i==y){s.push_back(2);}

                    else{

                        s.push_back(op);

                       if(op)op=0;

                        else op=1;

                    }

                        

    

                }

            }

    

        }

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

            cout<<s[i]<<" ";

        }

        cout<<endl;

    }

}

Solution 2 (runtime: 93 ms):
#include <bits/stdc++.h>

using namespace std;

#define int long long

#define ios ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

const int mod = 23;

const int N = 1e6 + 3;

const int inf = 0x7f7f7f7f;

int dir[8][2] = {

    {-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}};

void solve()

{

    int n, x, y;

    cin >> n >> x >> y;

    vector<int> a(n + 1);

    if (n % 2 == 0)

    {

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

        {

            a[i] = i % 2;

        }

        if (a[x] == a[y])

        {

            a[y] = 2;

        }

    }

    else

    {

        a[x] = 2;

        int cnt = x + 1;

        int p = 1;

        while (cnt != x)

        {

            a[cnt] = p^1;

            p ^=1;

            cnt++;

            if (cnt == n + 1)

            {

                cnt = 1;

            }

        }

    }

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

    {

        cout << a[i] << " ";

    }

    cout << endl;

}

signed main()

{

    // ios;

    int t;

    // t = 1;

    cin >> t;

    while (t--)

        solve();

    system("pause");

}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 140 ms):
#include<bits/stdc++.h>
using namespace std;
#define int long long
int solve(int i,int j,int n,int m,vector<vector<int>>&dp,string&a,string& b,string &c){
  if(i==n){
    int cnt=0;
    for(int k=i+j;k<c.length();k++){
        if(c[k]!=b[k-i]) cnt++;
    }
    return cnt;
  }
  if(j==m){
    int cnt=0;
    for(int k=i+j;k<c.length();k++){
        if(c[k]!=a[k-j]) cnt++;
    }
    return cnt;
  }
  if(dp[i][j]!=-1) return dp[i][j];
  int t=INT_MAX;
  if(a[i]==c[i+j]) t=min(t,solve(i+1,j,n,m,dp,a,b,c));
   if(b[j]==c[i+j]) t=min(t,solve(i,j+1,n,m,dp,a,b,c));
  t=min(t,1+min(solve(i+1,j,n,m,dp,a,b,c),solve(i,j+1,n,m,dp,a,b,c)));
  return dp[i][j]=t;
}
int32_t main(){
    int t;cin>>t;
    // if(t==675){
    //       for(int i=0;i<675;i++){
    //          string a,b,c;
    //          cin>>a>>b>>c;
    //          if(i==45) {
    //             cout<<a<<" "<<b<<" "<<c<<endl;
    //          }
    //       }
    // }
   while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        int n=a.length(),m=b.length();
        vector<vector<int>>dp(n,vector<int>(m,-1));
     cout<<solve(0,0,n,m,dp,a,b,c)<<endl;
    }
    return 0;
}

Solution 2 (runtime: 62 ms):
#include <bits/stdc++.h>
using namespace std;

void f() {
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.size();
    int m = b.size();
    vector<vector<int>> f(n + 1, vector<int>(m + 1, INT_MAX));
    f[0][0] = 0;

    for (int i = 1; i <= n; i ++) {
        f[i][0] = f[i - 1][0] + (a[i - 1] != c[i - 1]);
    }

    for (int j = 1; j <= m; j ++) {
        f[0][j] = f[0][j - 1] + (b[j - 1] != c[j - 1]);
    }

    for (int i = 1; i <= n; i ++) {
        for (int j = 1; j <= m; j ++) {
            f[i][j] = min(f[i - 1][j] + (a[i - 1] != c[i + j - 1]), f[i][j - 1] + (b[j - 1] != c[i + j - 1]));
        }
    }
    cout << f[n][m] << "\n";
}

int main() {
    int t;
    cin >> t;
    while (t --) f();
    return 0;
}