ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: c++17 

Solution 1 (runtime: 61 ms):
#include <algorithm>

#include <array>

#include <bitset>

#include <cassert>

#include <chrono>

#include <climits>

#include <cmath>

#include <complex>

#include <cstring>

#include <functional>

#include <iomanip>

#include <iostream>

#include <map>

#include <numeric>

#include <queue>

#include <random>

#include <set>

#include <vector>

using namespace std;



#define ll long long

#define forn(i, s, n) for (int i = s; i < n; i++)

#define bforn(i, s) for (int i = s; i >= 0; i--)

// for pairs

#define s second

#define f first 

const int M = 2e5 + 1;

const char nl = '\n';



void solve(){

    string s; cin >> s;

    int n = s.size(); 



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

        int ind = -1;

        for (int j = i + 1; j < min(n, i + 10); j++) {

            int sj = s[j] - '0';

            int si = s[i] - '0';

            if (sj - (j - i) > si) {

                if (ind == -1) ind = j;

                else if (s[j] - (j - i) > s[ind] - (ind - i)) ind = j;

            }

        }

        //cout << "ind: " << ind << nl;

        if (ind == -1) continue;

        while (ind > i) {

            char temp = s[ind - 1];

            s[ind - 1] = s[ind] - 1;

            s[ind] = temp;

            ind--;

        }

        //cout << s << nl;

    }

    cout << s << nl;

}

// if you are unsure of how to do a problem by hand

// the solution is most likely somewhat brute force (i.e binsearch)

// if input is limited to 0-9 or a-z, usually you will loop through all combinations

// of letters or numbers

// constructive problems : start with 1 when constructing

// :%y+ to copy all lines

// rearrange math expressions

// difference array? (a[i] - b[i])

// debugging : reread the problem statement-every word is important!

// debugging : print important variables!

// think brute force sol first

int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    int t; cin >> t;

    for (int tt = 0; tt < t; tt++) solve();

}







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

using namespace std;



int32_t main() {

ios::sync_with_stdio(false);

cin.tie(nullptr);

int tc;

cin>>tc;

string s;

while(tc--){

cin>>s;

int a;

for (int i = 1; i < int(s.size()); i++) {

for (int j = i; j >0 ; j--) {

if (s[j]-1>s[j-1]) {

a = s[j]-1;

s[j] = s[j-1];

s[j-1] = a;

}else break;

}

}

cout<<s<<'\n';

}

return 0;

}
Problem: 2063B - Subsequence Update
Language: c++17 

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

using namespace std;

using ll = long long;

const int N = 1e5+3; 

const ll MOD = 1e9+7;

const int INF = -1e4;

void solve(){

    ll n,l,r; cin >> n >> l >> r;

    //l--; r--;

    vector<int> a(n);

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

    vector<ll> b,c;

    for(ll i = 0; i < r; i++)  b.push_back(a[i]);

    for(ll i = l-1; i < n; i++)  c.push_back(a[i]);

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

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

    ll s1 = accumulate(b.begin(),b.begin()+(int)r-l+1,0LL);

    ll s2 = accumulate(c.begin(),c.begin()+(int)r-l+1,0LL);

    cout << min(s1,s2) << '\n';

}

int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    int t;  cin >> t;

    while(t--){

        solve();

    }

    return 0;

}



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

#define ll long long
#define pb push_back
#define all(v) v.begin(), v.end()
#define nn '\n'

// Fast Input-Output
void fastIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int main()
{
    fastIO();

    int t;
    cin >> t;
    while (t--)
    {
        int n, l, r;
        cin >> n >> l >> r;
        l--; // Adjust for 0-based index

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

        vector<ll> brr = arr;
        sort(brr.begin() + l, brr.end());

        vector<ll> crr = arr;
        sort(crr.begin(), crr.begin() + r, greater<ll>());

        ll sum_brr = accumulate(brr.begin() + l, brr.begin() + r, 0LL);
        ll sum_crr = accumulate(crr.begin() + l, crr.begin() + r, 0LL);

        cout << min(sum_brr, sum_crr) << nn;
    }

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: c++17 

Solution 1 (runtime: 1125 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define F first
#define S second

void solve (ll t) {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    vector<ll> curr(n);
    for(ll i = 0; i < n; i++) curr[i] = i + 1;
    vector<pair<ll ,ll>> ans;
    for(ll i = 0; i < n; i++) {
        ll p = 0;
        for(; p < n; p++) {
            if(a[i] == curr[p]) {
                
                break;
            }
        
        }
        for(ll j = p + 1; j < n; j++) {
            ans.push_back({curr[j], curr[p]});
        }
        for(ll j = n - 1; j > p; j--) ans.push_back({curr[p], curr[j]});
        for (int j = p - 1; j >= i; j--) {
			ans.push_back(make_pair(curr[j + 1], curr[j]));
			swap(curr[j + 1], curr[j]);
		}
    
    }
    cout << ans.size() << endl;
	for (auto i : ans) cout << i.first << " " << i.second << endl;
	return;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // ll t;
    
    // cin >> t;
    ll t = 1;
    while(t)
    solve(t--);
}

Solution 2 (runtime: 1250 ms):
#include<bits/stdc++.h> 
using namespace std; 
# define ll long long 
void print(vector<pair<int,int>> & v){
    cout << v.size() << endl; 
    for(auto p : v){
        cout << p.first <<" "<<p.second << endl; 
    }
}

int main(){
    int n; 
    cin >> n; 
    vector<int> v(n); 
    for(int i=0; i<n; i++){
        cin >> v[i]; 
    }
    
    if(n==1){
        cout << 0 << endl; 
        return 0; 
    }
    
    // let all overtake, so that pura reverse ho jaye, 
    // then do un overtakes, so that you reach req config. 
    
    vector<pair<int,int>> pr; 
    for(int i=n; i>0; i--){
        for(int j=i-1; j>0; j--){
            pr.push_back({i, j}); 
        }
    }// abhi its ulta. 
    
    vector<int> a(n); 
    for(int i=0; i<n; i++){
        a[i] = n-i; 
    }
    
    for(int i=0; i<n; i++){
        int curr = v[i]; 
        int idx; 
        for(int t=0; t<n; t++){
            if(a[t]==curr){
                idx = t; 
                break; 
            }
        }
        
        for(int j=idx; j>i; j--){
            pr.push_back({a[j], a[j-1]}); 
            swap(a[j], a[j-1]); 
        }
    }
    print(pr);
    
    return 0; 
}
Problem: 2050D - Digital string maximization
Language: c++17 

Solution 1 (runtime: 124 ms):
//                   Dont read ugly code  :(

#include <bits/stdc++.h>
#define int long long
using namespace std;

void solve(vector<int>& nya) {
    for (int i = 0; i < nya.size(); i++) {
        int maxi = -1, ind = -1;
        for (int j = 0; j < nya.size(); j++) {
            if (maxi < nya[j] - j) {
                ind = j;
                maxi = nya[j] - j;
            }
        }
        for (int k = ind; k > 0; k--) swap(nya[k], nya[k - 1]);
        nya[0] = maxi;
    }
}

string solve1(vector<int>& nya) {
    string ans;
    for (int i = 0; i < nya.size(); i++) {
        int maxi = -1, ind = -1;
        for (int j = 0; j < nya.size(); j++) {
            if (nya[j] >= 0 && maxi < nya[j] - j) {
                ind = j;
                maxi = nya[j] - j;
            }
        }
        if (ind != -1) {
            for (int k = ind + 1; k < nya.size(); k++) nya[k]++;
            ans.push_back('0' + max(0LL, maxi));
            nya[ind] = -10;
        }
    }
    return ans;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--) {
        string arr;
        cin >> arr;
        int n = arr.length();

        if (n < 9) {
            vector<int> nya(arr.begin(), arr.end());
            for (auto& x : nya) x -= '0';
            cout << solve1(nya) << endl;
        } else {
            for (int i = 0; i <= n - 9; i++) {
                vector<int> nya(arr.begin() + i, arr.begin() + i + 9);
                for (auto& x : nya) x -= '0';
                solve(nya);
                for (int j = 0; j < 9; j++) arr[i + j] = nya[j] + '0';
            }

            vector<int> nya(arr.end() - 8, arr.end());
            for (auto& x : nya) x -= '0';
            string temp = solve1(nya);
            for (int i = 0; i < 8; i++) arr[n - 8 + i] = temp[i];
            cout << arr << endl;
        }
    }
    return 0;
}


Solution 2 (runtime: 140 ms):
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>

using namespace std;


int main() {

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

    int t;
    cin>>t;
    while (t--) {
        string s;
        cin>>s;

        priority_queue<pair<int,int> > q;
        for (int i=1; i<s.length(); i++) {
            if (s[i] > s[i-1] + 1) {
                q.push(make_pair(s[i] - s[i-1], i));
            }
        }

        while (q.size() > 0) {
            int i = q.top().second;
            q.pop();
            if (s[i] > s[i-1] + 1) {
                swap(s[i], s[i-1]);
                s[i-1]--;
            }
            if (i + 1 < s.length() && s[i+1] > s[i] + 1) {
                q.push(make_pair(s[i+1] - s[i], i+1));
            }
            if (i - 2 >= 0 && s[i-1] > s[i-2] + 1) {
                q.push(make_pair(s[i-1] - s[i-2], i-1));
            }
        }

        cout<<s<<endl;
    }

    return 0;

}
Problem: 2050D - Digital string maximization
Language: c++17 

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

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    string s;
	    cin>>s;
	    for (int i=1;i<s.size();i++)
		{
			if(s[i]=='0')continue;
			int ind=i;
			while(ind>=1&&s[ind]-s[ind-1]>=2)
			{
				s[ind]--;
				swap(s[ind],s[ind-1]);
				ind--; 
			}
		}
		cout<<s<<endl;
	}
   
}


Solution 2 (runtime: 61 ms):
	#define _CRT_SECURE_NO_WARNINGS
	#define _USE_MATH_DEFINES
	#include <bits/stdc++.h>

	#include <vector>

	#include <ext/pb_ds/assoc_container.hpp>

	#include <ext/pb_ds/tree_policy.hpp>
	
	#define int long long
	#define ll long long
	#define ld long double
	#define mp make_pair
	#define GCD(m, n) __gcd(m, n)
	#define MAX 1000000009
	using namespace std;
	using namespace __gnu_pbds;
	signed main()
	{
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    cout.tie(NULL);
	    int T;
	    cin>>T;
	    while(T--)
	    {
	        string s;
	        cin>>s;
	        int n = s.length();
	        int i = 1;
	        while(i<n)
	        {
	            int a = s[i]-'0';
	            for(int j=1;j<=8 && i-j>=0;j++)
	            {
	                int b = s[i-j]-'0';
	                a = a - 1;
	                if(a>b){
	                    
	                    s[i-j+1] = char(48+b);
	                    s[i-j] = char(48+a);
	                }
	                else{
	                    break;
	                }
	            }
	            i++;
	        }
	        cout<<s<<endl;
	    }
	}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 109 ms):
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <limits>
#include <unordered_set>
#include <set>
#include <cassert>

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

    while (t-- > 0)
    {
        unsigned l, r;
        std::cin >> l >> r;

        auto b = [](unsigned x)
        {
            std::vector<int> v;
            while (x)
            {
                v.push_back(x % 2);
                x /= 2;
            }
            v.push_back(0);
            return v;
        };

        auto lb = b(l), rb = b(r);
        auto n = rb.size();

        while (lb.size() < n)
        {
            lb.push_back(0);
        }

        std::vector<int> v;
        int i = n - 1;
        while (i >= 0 && rb[i] == lb[i])
        {
            v.push_back(rb[i]);
            --i;
        }

        int j = v.size();
        v.push_back(1);
        --i;
        for (; i >= 0; --i)
        {
            if (lb[i] != rb[i])
            {
                v.push_back(0);
            }
            else if (lb[i] == 0)
            {
                if (j != -1)
                {
                    for (; j < v.size(); ++j)
                    {
                        v[j] = v[j] ^ 1;
                    }
                    j = -1;
                }
                v.push_back(1);
            }
            else
            {
                j = -1;
                v.push_back(0);
            }
        }

        unsigned x = 1;
        unsigned m = 0;
        while (!v.empty())
        {
            if (v.back())
            {
                m += x;
            }
            v.pop_back();
            x *= 2;
        }

        std::cout << l << ' ' << m << ' ' << r << '\n';
    }
}


Solution 2 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int x,j,y;
        cin>>x>>y;
        if((y-x)==2)
        {
            cout<<y<<" "<<y-1<<" "<<y-2<<endl;
            continue;
        }
        int k=0;
        for(int i=30;i>=0;i--)
        {
            if(((1<<i)&y)!=0)
            {
                j=i;
                break;
            }
        }
        for(int i=j;i>=0;i--)
        {
            if(((1<<i)&x)==((1<<i)&y) )
            {
                if(((1<<i)&x)!=0)
                {
                    k+=(1<<i);
                }
            }
            else
            {
                break;
            }
        }
        x=x-k;
        y=y-k;
        int a,b,c;
        for(int i=30;i>=0;i--)
        {
            if((1<<i)>=x && (1<<i)<=y)
            {
                a=1<<i;
                b=a-1;
                c=a-2;
                if(c<x)
                {
                    c=y;
                }
                break;
            }
        }
        cout<<k+a<<" "<<k+b<<" "<<k+c<<endl;
        // " "<<((a^b)+(b^c)+(c^a))<<
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 61 ms):
#include<bits/stdc++.h>
#include<unordered_map>
#include<vector>
#define gcd(x,y) __gcd(x,y)
#define ll long long
#define mod 1e9+7
#define fr(s,n) for(int i=s;i<n;i++)
#define fr2(s,n) for(int i=n-1;i>=s;i--)
using namespace std;

struct tree{
    int val;
    tree* left;
    tree* right;
    tree() : val(0), left(nullptr), right(nullptr) {}
    tree(int x) : val(x), left(nullptr), right(nullptr) {}
};

bool cmp(pair<ll,ll> p1,pair<ll,ll>p2){
    if(p1.first>p2.first)return true;
    else if(p1.first==p2.first){
        if(p1.second>p2.second)return true;
        else return false;
    }
    else return false;
}

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

        string a,b,c;cin>>a>>b>>c;
        ll n=a.length(),m=b.length();
        vector<vector<ll>>dp(n+1,vector<ll>(m+1,0));
        dp[0][0]=0;
        fr(0,n){
            if(a[i]==c[i]) dp[i+1][0]=dp[i][0]+1;
            else dp[i+1][0]=dp[i][0];

        }

            fr(0,m){
            if(b[i]==c[i]) dp[0][i+1]=dp[0][i]+1;
            else dp[0][i+1]=dp[0][i];
            }

        for(ll i=0;i<n;i++){
            for(ll j=0;j<m;j++){
                if(a[i]==c[i+j+1]) dp[i+1][j+1]=1+dp[i][j+1];
                else dp[i+1][j+1]=dp[i][j+1];

                if(b[j]==c[i+j+1]) dp[i+1][j+1]=max(dp[i+1][j+1],1+dp[i+1][j]);
                else dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
            }
        }
		
// for(ll i=0;i<=n;i++){
//             for(ll j=0;j<=m;j++){
//                cout<<dp[i][j]<<" ";
//             }
//             cout<<endl;
//         }
// cout<<endl;
        cout<<n+m-dp[n][m]<<endl;
	}
	return 0;
	}

Solution 2 (runtime: 61 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define GPQ priority_queue<ll>
#define all(v) v.begin(), v.end()
const int mod=998244353; //1e9 + 7;

void solve(){
    string s,t,c;
    cin>>s>>t>>c;
    int n=s.size(),m=t.size();
    vector<vector<int>> dp(n+1,vector<int> (m+1,-1));

    dp[0][0]=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            int x=INT_MAX,y=INT_MAX;
            if(i>0){
                if(s[i-1]==c[i+j-1]) x=dp[i-1][j];
                else x=1+dp[i-1][j];
            }

            if(j>0){
                if(t[j-1]==c[i+j-1]) y=dp[i][j-1];
                else y=1+dp[i][j-1];
            }

            if(i!=0 || j!=0) dp[i][j]=min(x,y);
        }
    }

    cout<<dp[n][m]<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        freopen("Error.txt", "w", stderr);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1; cin>>t;

    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 62 ms):
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int _;cin>>_;
	while(_--){
		int n;cin>>n;
		long long a[n];
		long long sum1=0,sum2=0,ans;
		for(int i=0;i<n;i++){
			cin>>a[i];
			sum1+=a[i];
		}
		if(n==1){
			cout<<a[0];
		}else{
			ans=sum1;
			while(n>1){
				sum2=0;
				for(int i=0;i<n-1;i++){
					a[i]=a[i+1]-a[i];
					sum2+=a[i];
				}
				n--;
				ans=max(ans,abs(sum2));
			}
			cout<<ans;
		}
		cout<<endl;
	}
	return 0;
}

Solution 2 (runtime: 46 ms):
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,sse4a,avx,avx2,popcnt,tune=native")
#include<bits/stdc++.h>
using namespace std;



#define ll long long




int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
    
    
    
    ll n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    int m=n;
    long long ans=-1e18;
    
    for(int i=0;i<n;i++){
        
        long long sm=0;
        
        for(int i=0;i<m;i++) sm+=arr[i];
            
        if(i==0) ans=max(ans,sm);
    else ans=max(ans,max(sm,(-sm)));
    for(int i=0;i<m-1;i++) arr[i]=(arr[i+1]-arr[i]);
        m--;
    }
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
}    
    
return 0;
}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 61 ms):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 4e18;
const int N = 2e5 + 5;
int n;
ll a[N], b[N];
void solve(){
	cin >> n;
	for(int i = 1;i <= n; ++ i)cin >> a[i];

	ll ans = 0;
	for(int i = 1;i <= n; ++ i)ans += a[i];

	ll pf = a[1], pb = a[n];

	for(int len = n - 1;len >= 1; -- len){
		for(int i = 1;i <= len; ++ i){
			b[i] = a[i + 1] - a[i];
		}
		ans = max(ans, pf - pb);
		ans = max(ans, pb - pf);

		for(int i = 1;i <= len; ++ i)a[i] = b[i];
		pf = a[1], pb = a[len];
	}

	cout << ans << '\n';
}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int _ = 1;cin >> _;
	while(_ --){
		solve();
	}
	return 0;
}
/*


*/

Solution 2 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
  ll n, k;
  cin >> n;
  vector<ll> v(n);
  vector<ll> a;
  map<ll, ll> m;
  for (ll i = 0; i < n; i++)
  {
    cin >> v[i];
  }
  if (v.size() == 1)
  {
    cout << v[0];
    return;
  }
  ll ans = accumulate(v.begin(), v.end(), 0ll);
  for (ll i = 0; i < 50; i++)
  {
    for (ll i = 0; i < n - 1; i++)
    {
      a.push_back(v[i + 1] - v[i]);
    }
    ans = max(ans, abs(accumulate(a.begin(), a.end(), 0ll)));
    for (ll i = 0; i < n - 1; i++)
    {
      v[i] = a[i];
    }
    a.clear();
    n = n - 1;
  }
  cout << ans;
}

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

  int t;
  cin >> t;
  while (t--)
  {
    solve();
    cout << endl;
  }

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

Solution 1 (runtime: 124 ms):
#include<bits/stdc++.h>
using namespace std;
#define ll              long long 
#define pb              push_back
#define all(v)          v.begin(),v.end()
#define sz(a)           (ll)a.size()
#define F               first
#define S               second
#define INF             2000000000000000000
#define popcount(x)     __builtin_popcountll(x)
#define pll             pair<ll,ll>
#define pii             pair<int,int>
#define ld              long double
#define fr(i, y, z)     for (ll i = y; i < z; i++)
#define yes             cout<<"YES"<<endl
#define no              cout<<"NO"<<endl



ll solve(string &a,string &b,string &c,ll i,ll j,vector<vector<ll>>&dp){
  if(i==a.size() && j==b.size()) return 0;

  if(dp[i][j]!=-1)return dp[i][j];
  
  ll k=i+j;
  ll x=2010,y=2010;
  
  if(i<a.size()){
    x=(a[i]!=c[k])+solve(a,b,c,i+1,j,dp);
  }
  if(j<b.size()){
    y=(b[j]!=c[k])+solve(a,b,c,i,j+1,dp);
  }
  return dp[i][j]=min(x,y);
}

int main()
{
    long long t;
    cin>>t;
   
    for(long long i=0;i<t;i++)
    {
      
   string a,b,c;
   cin>>a>>b>>c;
   vector<vector<ll>>dp(a.size()+1,vector<ll>(b.size()+1,-1));
   cout<<solve(a,b,c,0,0,dp)<<endl;
    }
    return 0;
}


Solution 2 (runtime: 61 ms):
#include<bits/stdc++.h>
using namespace std;
const int MAXN=200005;
int n,q,t,p;
int dp[1010][1010];

int gcd(int a,int b){
    return b? gcd(b,a%b):a;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
    string a,b,c;
    cin>>t;
    while(t--){
        cin>>a>>b>>c;
        for(int l=1;l<=c.length();l++){
            for(int i=(l>b.length()?l-b.length():0);i<=a.length();i++){
                int j=l-i;
                if(i>0&&j>0) dp[i][j]=min(dp[i-1][j]+(a[i-1]!=c[l-1]),dp[i][j-1]+(b[j-1]!=c[l-1]));
                if(i==0&&j>0) dp[i][j]=dp[i][j-1]+(b[j-1]!=c[l-1]);
                if(i>0&&j==0) dp[i][j]=dp[i-1][j]+(a[i-1]!=c[l-1]);
            }
        }
        cout<<dp[a.length()][b.length()]<<endl;
    }
    return 0;
}