ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long int
void print(vector<int> &a){
    for(auto _ : a)cerr<<_<<" ";
    cerr<<endl;
}
void incheck(){
    cerr<<"inloop"<<endl;
}
void solve() {
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans = 0;
    vector<pair<int,int>> res;
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] < a[j+1]){
                //incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
           
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] > a[j+1]){
                //incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
            //print(a);
        }
    }
    cout<<res.size()<<endl;
    for(auto it : res){
        cout<<it.first<<" "<<it.second<<endl;
    }
    
}

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

    int t;
    cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long int
void print(vector<int> &a){
    for(auto _ : a)cerr<<_<<" ";
    cerr<<endl;
}
void incheck(){
    cerr<<"inloop"<<endl;
}
void solve() {
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans = 0;
    vector<pair<int,int>> res;
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] < a[j+1]){
                incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
           print(a);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] > a[j+1]){
                incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
            print(a);
        }
    }
    cout<<res.size()<<endl;
    for(auto it : res){
        cout<<it.first<<" "<<it.second<<endl;
    }
    
}

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

    int t;
    t = 1;

    while (t--) {
        solve();
    }

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long int
void print(vector<int> &a){
    for(auto _ : a)cerr<<_<<" ";
    cerr<<endl;
}
void incheck(){
    cerr<<"inloop"<<endl;
}
void solve() {
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans = 0;
    vector<pair<int,int>> res;
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] < a[j+1]){
                incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
           print(a);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] > a[j+1]){
                incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
            print(a);
        }
    }
    cout<<res.size()<<endl;
    for(auto it : res){
        cout<<it.first<<" "<<it.second<<endl;
    }
    
}

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

    int t;
    t = 1;

    while (t--) {
        solve();
    }

    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long int
void print(vector<int> &a){
    for(auto _ : a)cerr<<_<<" ";
    cerr<<endl;
}
void incheck(){
    cerr<<"inloop"<<endl;
}
void solve() {
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans = 0;
    vector<pair<int,int>> res;
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] < a[j+1]){
                incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
           print(a);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] > a[j+1]){
                incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
            print(a);
        }
    }
    reverse(a.begin(),a.end());
    cout<<res.size()<<endl;
    for(auto it : res){
        cout<<it.first<<" "<<it.second<<endl;
    }
    
}

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

    int t;
    t = 1;

    while (t--) {
        solve();
    }

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long int
void print(vector<int> &a){
    for(auto _ : a)cerr<<_<<" ";
    cerr<<endl;
}
void incheck(){
    cerr<<"inloop"<<endl;
}
void solve() {
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans = 0;
    vector<pair<int,int>> res;
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] < a[j+1]){
                incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
           print(a);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] > a[j+1]){
                incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
            print(a);
        }
    }
    reverse(a.begin(),a.end());
    cout<<res.size()<<endl;
    for(auto it : res){
        cout<<it.first<<" "<<it.second<<endl;
    }
    
}

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

    int t;
    t = 1;

    while (t--) {
        solve();
    }

    return 0;
}

Submission (verdict: Time limit exceeded on test 34):
#include <bits/stdc++.h>
using namespace std;
#define int long long int
void print(vector<int> &a){
    for(auto _ : a)cerr<<_<<" ";
    cerr<<endl;
}
void incheck(){
    cerr<<"inloop"<<endl;
}
void solve() {
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans = 0;
    vector<pair<int,int>> res;
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] < a[j+1]){
                incheck();
                res.push_back({a[j],a[j+1]});
                swap(a[j],a[j+1]);
            }
           print(a);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] > a[j+1]){
                incheck();
                res.push_back({a[j],a[j+1]});
                swap(a[j],a[j+1]);
            }
            print(a);
        }
    }
    reverse(res.begin(),res.end());
    cout<<res.size()<<endl;
    for(auto it : res){
        cout<<it.first<<" "<<it.second<<endl;
    }
    
}

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

    int t;
    t = 1;

    while (t--) {
        solve();
    }

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 34):
#include <bits/stdc++.h>
using namespace std;
#define int long long int
void print(vector<int> &a){
    for(auto _ : a)cerr<<_<<" ";
    cerr<<endl;
}
void incheck(){
    cerr<<"inloop"<<endl;
}
void solve() {
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans = 0;
    vector<pair<int,int>> res;
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] < a[j+1]){
                incheck();
                res.push_back({a[j],a[j+1]});
                swap(a[j],a[j+1]);
            }
           print(a);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] > a[j+1]){
                incheck();
                res.push_back({a[j],a[j+1]});
                swap(a[j],a[j+1]);
            }
            print(a);
        }
    }
    reverse(res.begin(),res.end());
    cout<<res.size()<<endl;
    for(auto it : res){
        cout<<it.first<<" "<<it.second<<endl;
    }
    
}

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

    int t;
    t = 1;

    while (t--) {
        solve();
    }

    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long int
void print(vector<int> &a){
   // for(auto _ : a)cerr<<_<<" ";
    cerr<<endl;
}
void incheck(){
    cerr<<"inloop"<<endl;
}
void solve() {
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans = 0;
    vector<pair<int,int>> res;
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] < a[j+1]){
               // incheck();
                res.push_back({a[j],a[j+1]});
                swap(a[j],a[j+1]);
            }
          // print(a);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] > a[j+1]){
                //incheck();
                res.push_back({a[j],a[j+1]});
                swap(a[j],a[j+1]);
            }
            //print(a);
        }
    }
    reverse(res.begin(),res.end());
    cout<<res.size()<<endl;
    for(auto it : res){
        cout<<it.first<<" "<<it.second<<endl;
    }
    
}

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

    int t;
    t = 1;

    while (t--) {
        solve();
    }

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long int
void print(vector<int> &a){
    for(auto _ : a)cerr<<_<<" ";
    cerr<<endl;
}
void incheck(){
    cerr<<"inloop"<<endl;
}
void solve() {
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans = 0;
    vector<pair<int,int>> res;
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] < a[j+1]){
                //incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
           
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] > a[j+1]){
                //incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
            //print(a);
        }
    }
    cout<<res.size()<<endl;
    for(auto it : res){
        cout<<it.first<<" "<<it.second<<endl;
    }
    
}

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

    int t;
    cin >> t;

    while (t--) {
        solve();
    }

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

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

int main() {
   
   int t;
   cin>>t;
   while(t--){
       int n;
       cin>>n;
       vector<int>nums(n);
       for(int i=0;i<n;i++){
           cin>>nums[i];
       }
       int ans=nums[0];
       for(int i=1;i<n;i++){
           if(nums[i]-ans<0){
               cout<<"NO"<<endl;
               return 0;
           }
           else{
               ans=nums[i]-ans;
           }
       }
       cout<<"YES"<<endl;
   }
   return 0;
}

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

int main() {
   
   int t;
   cin>>t;
   while(t--){
       int n;
       cin>>n;
       vector<int>nums(n);
       for(int i=0;i<n;i++){
           cin>>nums[i];
       }
       int ans=nums[0],flag=1;
       for(int i=1;i<n;i++){
           if(nums[i]-ans<0){
               flag=0;
               break;
           }
           else{
               ans=nums[i]-ans;
           }
       }
       if(flag==1){
       cout<<"YES"<<endl;
       }
       else{
           cout<<"NO"<<endl;
       }
   }
   return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

int main() {
   
   int t;
   cin>>t;
   while(t--){
       int n;
       cin>>n;
       vector<int>nums(n,0);
       for(int i=0;i<n;i++){
           cin>>nums[i];
       }
       int ans=nums[0];
       for(int i=1;i<n;i++){
           if(nums[i]-ans<0){
               cout<<"NO"<<endl;
               return 0;
           }
           else{
               ans=nums[i]-ans;
           }
       }
       cout<<"YES"<<endl;
   }
   return 0;
}

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

int main() {
   
   int t;
   cin>>t;
   while(t--){
       int n;
       cin>>n;
       vector<int>nums(n);
       for(int i=0;i<n;i++){
           cin>>nums[i];
       }
       int ans=nums[0];
       for(int i=1;i<n;i++){
           if(nums[i]-ans<0){
               cout<<"NO"<<endl;
               return 0;
           }
           else{
               ans=nums[i]-ans;
           }
       }
       cout<<"YES"<<endl;
   }
   return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

int main() {
   
   int t;
   cin>>t;
   while(t--){
       int n;
       cin>>n;
       vector<int>nums(n,0);
       for(int i=0;i<n;i++){
           cin>>nums[i];
       }
       int ans=nums[0];
       for(int i=1;i<n;i++){
           if(nums[i]-ans<0){
               cout<<"NO"<<endl;
           }
           else{
               ans=nums[i]-ans;
           }
       }
       cout<<"YES"<<endl;
   }
   return 0;
}

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

int main() {
   
   int t;
   cin>>t;
   while(t--){
       int n;
       cin>>n;
       vector<int>nums(n,0);
       for(int i=0;i<n;i++){
           cin>>nums[i];
       }
       int ans=nums[0];
       for(int i=1;i<n;i++){
           if(nums[i]-ans<0){
               cout<<"NO"<<endl;
               return 0;
           }
           else{
               ans=nums[i]-ans;
           }
       }
       cout<<"YES"<<endl;
   }
   return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

int main() {
   
   int t;
   cin>>t;
   while(t--){
       int n;
       cin>>n;
       vector<int>nums(n,0);
       for(int i=0;i<n;i++){
           cin>>nums[i];
       }
       int ans=nums[0];
       for(int i=1;i<n;i++){
           if(nums[i]-ans<0){
               cout<<"NO"<<endl;
           }
           else{
               ans=nums[i]-ans;
           }
       }
       cout<<"YES"<<endl;
   }
   return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int f(int i, int j ,int ind, int m ,int n,int p, string a, string b, string c, vector<vector<int>>&dp){
    if(i>=m){
        int count =0;
        while(j<n&&ind<p){
            if(c[ind]!=b[j]){
                count++;
            }
            ind++;
            j++;
        }
        return count;
    }
    if(j>=n){
        int count =0;
        while(i<m&&ind<p){
            if(c[ind]!=a[i]){
                count++;
            }
            ind++;
            i++;
        }
        return count;

    }
    
    int val=INT_MAX;

    if(a[i]==c[ind]){
        val=min(val,f(i+1,j,ind+1,m,n,p,a,b,c,dp));
    }
     if(b[j]==c[ind]){
        val=min(val,f(i,j+1,ind+1,m,n,p,a,b,c,dp));
    }
    if(a[i]!=c[ind]){
        val=min(val,1+f(i+1,j,ind+1,m,n,p,a,b,c,dp));

        
    }
    if(b[j]!=c[ind]){
        val=min(val,1+f(i,j+1,ind+1,m,n,p,a,b,c,dp));
    }
    return dp[i][j]=val;
}

int main() {
    ll t;
    cin >> t;
    while (t--) {
       string a;
       string b;
       string c;

       cin>>a;
       cin>>b;
       cin>>c;

       int m=a.size();
       int n=b.size();
       int p=c.size();
       
       vector<vector<int>>dp(m,vector<int>(n,-1));
       int ans=f(0,0,0,m,n,p,a,b,c,dp);
       cout<<ans<<endl;


       
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int f(int i, int j ,int ind, int m ,int n,int p, string &a, string &b, string & c, vector<vector<int>>&dp){
    if(i>=m){
        int count =0;
        while(j<n&&ind<p){
            if(c[ind]!=b[j]){
                count++;
            }
            ind++;
            j++;
        }
        return count;
    }
    if(j>=n){
        int count =0;
        while(i<m&&ind<p){
            if(c[ind]!=a[i]){
                count++;
            }
            ind++;
            i++;
        }
        return count;

    }
    
    int val=INT_MAX;

    if(a[i]==c[ind]){
        val=min(val,f(i+1,j,ind+1,m,n,p,a,b,c,dp));
    }
     if(b[j]==c[ind]){
        val=min(val,f(i,j+1,ind+1,m,n,p,a,b,c,dp));
    }
    if(a[i]!=c[ind]){
        val=min(val,1+f(i+1,j,ind+1,m,n,p,a,b,c,dp));

        
    }
    if(b[j]!=c[ind]){
        val=min(val,1+f(i,j+1,ind+1,m,n,p,a,b,c,dp));
    }
    return dp[i][j]=val;
}

int main() {
    ll t;
    cin >> t;
    while (t--) {
       string a;
       string b;
       string c;

       cin>>a;
       cin>>b;
       cin>>c;

       int m=a.size();
       int n=b.size();
       int p=c.size();
       
       vector<vector<int>>dp(m,vector<int>(n,-1));
       int ans=f(0,0,0,m,n,p,a,b,c,dp);
       cout<<ans<<endl;


       
    }
    return 0;
}


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int f(int i, int j ,int ind, int m ,int n,int p, string &a, string &b, string & c, vector<vector<int>>&dp){
    // if(i>=m){
    //     int count =0;
    //     while(j<n&&ind<p){
    //         if(c[ind]!=b[j]){
    //             count++;
    //         }
    //         ind++;
    //         j++;
    //     }
    //     return count;
    // }
    // if(j>=n){
    //     int count =0;
    //     while(i<m&&ind<p){
    //         if(c[ind]!=a[i]){
    //             count++;
    //         }
    //         ind++;
    //         i++;
    //     }
    //     return count;

    // }
    if(ind>=p){
        return 0;
    }

    
    int val=INT_MAX;

    if(i<m&&a[i]==c[ind]){
        val=min(val,f(i+1,j,ind+1,m,n,p,a,b,c,dp));
    }
     if(j<n&&b[j]==c[ind]){
        val=min(val,f(i,j+1,ind+1,m,n,p,a,b,c,dp));
    }
    if(i<m&&a[i]!=c[ind]){
        val=min(val,1+f(i+1,j,ind+1,m,n,p,a,b,c,dp));

        
    }
    if(j<n&&b[j]!=c[ind]){
        val=min(val,1+f(i,j+1,ind+1,m,n,p,a,b,c,dp));
    }
    return dp[i][j]=val;
}

int main() {
    ll t;
    cin >> t;
    while (t--) {
       string a;
       string b;
       string c;

       cin>>a;
       cin>>b;
       cin>>c;

       int m=a.size();
       int n=b.size();
       int p=c.size();
       
       vector<vector<int>>dp(m+1,vector<int>(n+1,-1));
       int ans=f(0,0,0,m,n,p,a,b,c,dp);
       cout<<ans<<endl;


       
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int f(int i, int j ,int ind, int m ,int n,int p, string a, string b, string c, vector<vector<int>>&dp){
    if(i>=m){
        int count =0;
        while(j<n&&ind<p){
            if(c[ind]!=b[j]){
                count++;
            }
            ind++;
            j++;
        }
        return count;
    }
    if(j>=n){
        int count =0;
        while(i<m&&ind<p){
            if(c[ind]!=a[i]){
                count++;
            }
            ind++;
            i++;
        }
        return count;

    }
    
    int val=INT_MAX;

    if(a[i]==c[ind]){
        val=min(val,f(i+1,j,ind+1,m,n,p,a,b,c,dp));
    }
     if(b[j]==c[ind]){
        val=min(val,f(i,j+1,ind+1,m,n,p,a,b,c,dp));
    }
    if(a[i]!=c[ind]){
        val=min(val,1+f(i+1,j,ind+1,m,n,p,a,b,c,dp));

        
    }
    if(b[j]!=c[ind]){
        val=min(val,1+f(i,j+1,ind+1,m,n,p,a,b,c,dp));
    }
    return dp[i][j]=val;
}

int main() {
    ll t;
    cin >> t;
    while (t--) {
       string a;
       string b;
       string c;

       cin>>a;
       cin>>b;
       cin>>c;

       int m=a.size();
       int n=b.size();
       int p=c.size();
       
       vector<vector<int>>dp(m,vector<int>(n,-1));
       int ans=f(0,0,0,m,n,p,a,b,c,dp);
       cout<<ans<<endl;


       
    }
    return 0;
}


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int f(int i, int j ,int ind, int m ,int n,int p, string &a, string &b, string & c, vector<vector<int>>&dp){
    if(i>=m){
        int count =0;
        while(j<n&&ind<p){
            if(c[ind]!=b[j]){
                count++;
            }
            ind++;
            j++;
        }
        return count;
    }
    if(j>=n){
        int count =0;
        while(i<m&&ind<p){
            if(c[ind]!=a[i]){
                count++;
            }
            ind++;
            i++;
        }
        return count;

    }
    
    int val=INT_MAX;

    if(a[i]==c[ind]){
        val=min(val,f(i+1,j,ind+1,m,n,p,a,b,c,dp));
    }
     if(b[j]==c[ind]){
        val=min(val,f(i,j+1,ind+1,m,n,p,a,b,c,dp));
    }
    if(a[i]!=c[ind]){
        val=min(val,1+f(i+1,j,ind+1,m,n,p,a,b,c,dp));

        
    }
    if(b[j]!=c[ind]){
        val=min(val,1+f(i,j+1,ind+1,m,n,p,a,b,c,dp));
    }
    return dp[i][j]=val;
}

int main() {
    ll t;
    cin >> t;
    while (t--) {
       string a;
       string b;
       string c;

       cin>>a;
       cin>>b;
       cin>>c;

       int m=a.size();
       int n=b.size();
       int p=c.size();
       
       vector<vector<int>>dp(m,vector<int>(n,-1));
       int ans=f(0,0,0,m,n,p,a,b,c,dp);
       cout<<ans<<endl;


       
    }
    return 0;
}