ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
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
#define ull unsigned long long int
#define dl double long
#define all(x) x.begin(), x.end()
#define ss second
#define ff first
const int N = 2 * 1e5 + 10;
const int M = 1e9 + 7;
#define Priyanshu_Mishra

Priyanshu_Mishra

void solve()
{
    int l, r;
    cin >> l >> r;
    int x = log2(r);
    if ((1ll << (x - 1)) >= l + 1) {
        cout << (1ll << (x)) << " " << (1ll << (x - 1)) << " " << (1ll << (x - 1)) - 1 << endl;
        return;
    }
    int a=(1ll<<x);
    int y = log2(r);
    int temp=(1ll<<(y+1))-1;
    int b=0;
    for (; y >= 0; y--) {
           if(((1ll<<y)&a)){
            if ((temp - (1ll << y)) > l) {
                temp-=(1ll << y);
            }
            else b+=(1ll<<y);
        }
        else if(b+(1ll<<y)<r)b+=(1ll<<y);
    }
    // if(b==0)b=l+1;
    int  c = b- 1;
    
    cout << a << " " << b << " " << c << endl;




}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcases = 1;
    cin >> testcases;
    while (testcases--)
    {
        solve();
        #ifdef Priyanshu_Mishra
        cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
        #endif
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#define ll long long
#include "bits/stdc++.h"
using namespace std;
 
int main()
{
   ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int tt ; cin >> tt ;
   while(tt --)
   {
      int l, r ; cin >> l >> r ;
      int a = r, b = l , c = 0 ;
      l ++ , r -- ;
      for(int i = 30 ; i >= 0 ; i --)
      {
        int bita = (a >> i) & 1 , bitb = (b >> i) & 1;
        if(bita == bitb)
        {
          int p = bita ^ 1 ;
          if((c | (p << i)) >= l && (c | (p << i)) <= r)
            c |= (p << i) ;
          else c |= ((p ^ 1) << i) ;
        }
        else
        {
          if((c | (1 << i)) >= l && (c | (1 << i)) <= r)
            c |= (1 << i) ;
        }
      }
      cout << a << ' ' << b << ' ' << c << '\n' ;
   }
   return 0 ;
 }
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;
#define int long long
#define ull unsigned long long int
#define dl double long
#define all(x) x.begin(), x.end()
#define ss second
#define ff first
const int N = 2 * 1e5 + 10;
const int M = 1e9 + 7;
#define Priyanshu_Mishra

Priyanshu_Mishra

void solve()
{
    int l, r;
    cin >> l >> r;
    int x = log2(r);
    if ((1ll << (x - 1)) >= l + 1) {
        cout << (1ll << (x)) << " " << (1ll << (x - 1)) << " " << (1ll << (x - 1)) - 1 << endl;
        return;
    }
    int a=(1ll<<x);
    int y = log2(r);
    int temp=(1ll<<(y+1))-1;
    int b=0;
    for (; y >= 0; y--) {
           if(((1ll<<y)&r)){
            if ((temp - (1ll << y)) > l) {
                temp-=(1ll << y);
            }
            else b+=(1ll<<y);
        }
        else if(b+(1ll<<y)<r)b+=(1ll<<y);
    }
    // if(b==0)b=l+1;
    int  c = b- 1;
    
    cout << a << " " << b << " " << c << endl;




}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcases = 1;
    cin >> testcases;
    while (testcases--)
    {
        solve();
        #ifdef Priyanshu_Mishra
        cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
        #endif
    }
    return 0;
}

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

using namespace std;
#define int long long
#define ull unsigned long long int
#define dl double long
#define all(x) x.begin(), x.end()
#define ss second
#define ff first
const int N = 2 * 1e5 + 10;
const int M = 1e9 + 7;
#define Priyanshu_Mishra

Priyanshu_Mishra

void solve()
{
    int l, r;
    cin >> l >> r;
    int x = log2(r);
    if ((1ll << (x - 1)) >= l + 1) {
        cout << (1ll << (x)) << " " << (1ll << (x - 1)) << " " << (1ll << (x - 1)) - 1 << endl;
        return;
    }
    int a=(1ll<<x);
    int y = log2(r);
    int temp=(1ll<<(y+1))-1;
    int b=0;
    for (; y >= 0; y--) {
           if(((1ll<<y)&a)){
            if ((temp - (1ll << y)) > l) {
                temp-=(1ll << y);
            }
            else b+=(1ll<<y);
        }
        else if(b+(1ll<<y)<r)b+=(1ll<<y);
    }
    // if(b==0)b=l+1;
    int  c = b- 1;
    
    cout << a << " " << b << " " << c << endl;




}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcases = 1;
    cin >> testcases;
    while (testcases--)
    {
        solve();
        #ifdef Priyanshu_Mishra
        cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
        #endif
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;
#define int long long
#define ull unsigned long long int
#define dl double long
#define all(x) x.begin(), x.end()
#define ss second
#define ff first
const int N = 2 * 1e5 + 10;
const int M = 1e9 + 7;
#define Priyanshu_Mishra

Priyanshu_Mishra

void solve()
{
    int l, r;
    cin >> l >> r;
    int x = log2(r);
    if ((1ll << (x - 1)) >= l + 1) {
        cout << (1ll << (x)) << " " << (1ll << (x - 1)) << " " << (1ll << (x - 1)) - 1 << endl;
        return;
    }
    int a=(1ll<<x);
    int y = log2(r);
    int temp=(1ll<<(y+1))-1;
    int b=0;
    for (; y >= 0; y--) {
           if(((1ll<<y)&r)){
            if ((temp - (1ll << y)) > l) {
                temp-=(1ll << y);
            }
            else b+=(1ll<<y);
        }
        else if(b+(1ll<<y)<r)b+=(1ll<<y);
    }
    // if(b==0)b=l+1;
    int  c = b- 1;
    
    cout << a << " " << b << " " << c << endl;




}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcases = 1;
    cin >> testcases;
    while (testcases--)
    {
        solve();
        #ifdef Priyanshu_Mishra
        cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
        #endif
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;
#define int long long
#define ull unsigned long long int
#define dl double long
#define all(x) x.begin(), x.end()
#define ss second
#define ff first
const int N = 2 * 1e5 + 10;
const int M = 1e9 + 7;
#define Priyanshu_Mishra

Priyanshu_Mishra

void dfs(int node, int par, vector < int > graph[], vector < int > & vis) {
    vis[node] = true;
    for (auto it: graph[node]) {
        if (it != par) {
            dfs(it, node, graph, vis);
        }
    }
}

void solve()
{
    int n;
    cin >> n;
    int x = -1, y = -1;
    vector < set < int > > edge(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        edge[u].insert(v);
        edge[v].insert(u);
    }
    if (n == 2) {
        cout << 0 << endl;
        return;
    }
    vector < pair < int, set < int >>> vp(n);
    for (int i = 0; i < n; i++) {
        vp[i] = {
            i,
            edge[i]
        };
    }
    sort(all(vp), [](const pair < int, set < int >> & a,
        const pair < int, set < int >> & b) {
        return a.ss.size() > b.ss.size();
    });
    x = vp[0].ff;
    for (int it: vp[0].ss) {
        vp[it].ss.erase(vp[0].ff);
    }
    vp.erase(vp.begin());


    sort(all(vp), [](const pair < int, set < int >> & a,
        const pair < int, set < int >> & b) {
        return a.ss.size() > b.ss.size();
    });
    y = vp[0].ff;
    for (auto it: vp[0].ss) {
        vp[it].ss.erase(vp[0].ff);
    }
    vp.erase(vp.begin());


    vector < int > graph[n];
    for (int i = 0; i < n; i++) {
        int u = vp[i].ff;
        for (auto v: vp[i].ss) {
            graph[u].push_back(v);
            graph[v].push_back(u);
        }
    }
    int ans = 0;
    vector < int > vis(n, false);
    for (int i = 0; i < n; i++) {
        if (i != x && i != y) {
            if (!vis[i]) {
                ans++;
                dfs(i, -1, graph, vis);
            }
        }
    }
    cout << ans << endl;


}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcases = 1;
    cin >> testcases;
    while (testcases--)
    {
        solve();
        #ifdef Priyanshu_Mishra
        cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
        #endif
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int res=-2e9;
int a[60],bk[60];
int n;
void solve() {
    long long ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        ans+=a[i];
    }
    for(int j=n;j>=2;j--) {
        long long sum=0;
        for(int i=1;i<j;i++) {
            a[i]=a[i+1]-a[i];
            sum+=a[i];
        }
        ans=max(ans,sum);
        ans=max(ans,-sum);

    }
    cout<<ans<<endl;
}


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

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
int res=-2e9;
long long a[60];
int n;
void solve() {
    long long ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        ans+=a[i];
    }
    for(int j=n;j>=2;j--) {
        long long sum=0;
        for(int i=1;i<j;i++) {
            a[i]=a[i+1]-a[i];
            sum+=a[i];
        }
        ans=max(ans,sum);
        ans=max(ans,-sum);

    }
    cout<<ans<<endl;
}


int main() {
    int t;
    cin>>t;
    while(t--)solve();
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int res=-2e9;
int a[60],bk[60];
int n;
void solve() {
    int ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        ans+=a[i];
    }
    for(int j=n;j>=2;j--) {
        int sum=0;
        for(int i=1;i<j;i++) {
            a[i]=a[i+1]-a[i];
            sum+=a[i];
        }
        ans=max(ans,sum);
        ans=max(ans,-sum);

    }
    cout<<ans<<endl;
}


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

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int res=-2e9;
int a[60],bk[60];
int n;
void solve() {
    long long ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        ans+=a[i];
    }
    for(int j=n;j>=2;j--) {
        long long sum=0;
        for(int i=1;i<j;i++) {
            a[i]=a[i+1]-a[i];
            sum+=a[i];
        }
        ans=max(ans,sum);
        ans=max(ans,-sum);

    }
    cout<<ans<<endl;
}


int main() {
    int t;
    cin>>t;
    while(t--)solve();
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int res=-2e9;
int a[60],bk[60];
int n;
void solve() {
    int ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        ans+=a[i];
    }
    for(int j=n;j>=2;j--) {
        int sum=0;
        for(int i=1;i<j;i++) {
            a[i]=a[i+1]-a[i];
            sum+=a[i];
        }
        ans=max(ans,sum);
        ans=max(ans,-sum);

    }
    cout<<ans<<endl;
}


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

Previous submission (verdict: Wrong answer on test 2):
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>

using namespace std;
#define fore(i, l, r)                                      \
  for (auto i = (l) - ((l) > (r)); i != (r) - ((l) > (r)); \
       i += 1 - 2 * ((l) > (r)))
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif
using ld = long double;
using lli = long long;
using ii = pair<int, int>;

const int N = 1e3;

string a, b, c;
// int mem[N][N][2 * N];
// int done[N][N][2 * N];
// int timer = 0;

int dp(int ai, int bi, int ci){
    if(ci == sz(c)){
        return 0;
    }

    // auto & ans = mem[ai][bi][ci];
    // auto & vis = done[ai][bi][ci];

    // if(vis != timer){
    //     vis = timer;
    //     ans = 0;

        int conta = 0, contb = 0;
        if(a[ai] != c[ci]){
            conta++;
        }
        if(b[bi] != c[ci]){
            contb++;
        }

        return min(dp(ai + 1, bi, ci + 1) + conta, dp(ai, bi + 1, ci + 1) + contb);
    // }
    // return ans;
}

// int f(){
//     timer ++;
//     return dp(0, 0, 0);
// }

int main() {
    cin.tie(0)->sync_with_stdio(0), cout.tie(0);
    int t; cin >> t;

    fore(_, 0, t){
        cin >> a >> b >> c;
        cout << dp(0, 0, 0) << '\n';
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>

using namespace std;
#define fore(i, l, r)                                      \
  for (auto i = (l) - ((l) > (r)); i != (r) - ((l) > (r)); \
       i += 1 - 2 * ((l) > (r)))
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif
using ld = long double;
using lli = long long;
using ii = pair<int, int>;

const int N = 1e3;

string a, b, c;
// int mem[N][N][2 * N];
// int done[N][N][2 * N];
// int timer = 0;

int dp(int ai, int bi){
    int ci = ai + bi;
    debug(ai, bi, ci);
    if(ai > sz(a) || bi > sz(b)){
        return 2 * N + 20;
    }
    if(ci >= sz(c)){
        return 0;
    }

    int conta = 0, contb = 0;
    if(a[ai] != c[ci]){
        debug( ai, a[ai], c[ci]);
        conta++;
    }
    if(b[bi] != c[ci]){
        debug(bi, b[bi], c[ci]);
        contb++;
    }

    return min(dp(ai + 1, bi) + conta, dp(ai, bi + 1) + contb);
}

// int f(){
//     timer ++;
//     return dp(0, 0, 0);
// }

int main() {
    cin.tie(0)->sync_with_stdio(0), cout.tie(0);
    int t; cin >> t;

    fore(_, 0, t){
        cin >> a >> b >> c;

        int p = dp(0, 0);
        debug(p);
        cout << p << '\n';
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>

using namespace std;
#define fore(i, l, r)                                      \
  for (auto i = (l) - ((l) > (r)); i != (r) - ((l) > (r)); \
       i += 1 - 2 * ((l) > (r)))
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif
using ld = long double;
using lli = long long;
using ii = pair<int, int>;

const int N = 1e3;

string a, b, c;
// int mem[N][N][2 * N];
// int done[N][N][2 * N];
// int timer = 0;

int dp(int ai, int bi){
    int ci = ai + bi;
    debug(ai, bi, ci);
    if(ai > sz(a) || bi > sz(b)){
        return 2 * N + 20;
    }
    if(ci >= sz(c)){
        return 0;
    }

    int conta = 0, contb = 0;
    if(a[ai] != c[ci]){
        debug( ai, a[ai], c[ci]);
        conta++;
    }
    if(b[bi] != c[ci]){
        debug(bi, b[bi], c[ci]);
        contb++;
    }

    return min(dp(ai + 1, bi) + conta, dp(ai, bi + 1) + contb);
}

// int f(){
//     timer ++;
//     return dp(0, 0, 0);
// }

int main() {
    cin.tie(0)->sync_with_stdio(0), cout.tie(0);
    int t; cin >> t;

    fore(_, 0, t){
        cin >> a >> b >> c;

        int p = dp(0, 0);
        debug(p);
        cout << p << '\n';
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>

using namespace std;
#define fore(i, l, r)                                      \
  for (auto i = (l) - ((l) > (r)); i != (r) - ((l) > (r)); \
       i += 1 - 2 * ((l) > (r)))
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif
using ld = long double;
using lli = long long;
using ii = pair<int, int>;

const int N = 1e3;

string a, b, c;
int mem[N][N];
int done[N][N];
int timer = 0;

int dp(int ai, int bi){
    int ci = ai + bi;
    debug(ai, bi, ci);
    if(ai > sz(a) || bi > sz(b)){
        return 2 * N + 20;
    }
    if(ci >= sz(c)){
        return 0;
    }

    auto & ans = mem[ai][bi];
    auto vis = done[ai][bi];

    if(vis != timer){
        vis = timer;
        ans = 0;

        int conta = 0, contb = 0;
        if(a[ai] != c[ci]){
            debug( ai, a[ai], c[ci]);
            conta++;
        }
        if(b[bi] != c[ci]){
            debug(bi, b[bi], c[ci]);
            contb++;
        }

        ans = min(dp(ai + 1, bi) + conta, dp(ai, bi + 1) + contb);
    }

    return ans;
}

int main() {
    cin.tie(0)->sync_with_stdio(0), cout.tie(0);
    timer = 0;
    int t; cin >> t;

    fore(_, 0, t){
        timer ++;
        cin >> a >> b >> c;

        int p = dp(0, 0);
        debug(p);
        cout << p << '\n';
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>

using namespace std;
#define fore(i, l, r)                                      \
  for (auto i = (l) - ((l) > (r)); i != (r) - ((l) > (r)); \
       i += 1 - 2 * ((l) > (r)))
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif
using ld = long double;
using lli = long long;
using ii = pair<int, int>;

const int N = 1e3;

string a, b, c;
// int mem[N][N][2 * N];
// int done[N][N][2 * N];
// int timer = 0;

int dp(int ai, int bi, int ci){
    if(ci == sz(c)){
        return 0;
    }

    // auto & ans = mem[ai][bi][ci];
    // auto & vis = done[ai][bi][ci];

    // if(vis != timer){
    //     vis = timer;
    //     ans = 0;

        int conta = 0, contb = 0;
        if(a[ai] != c[ci]){
            conta++;
        }
        if(b[bi] != c[ci]){
            contb++;
        }

        return min(dp(ai + 1, bi, ci + 1) + conta, dp(ai, bi + 1, ci + 1) + contb);
    // }
    // return ans;
}

// int f(){
//     timer ++;
//     return dp(0, 0, 0);
// }

int main() {
    cin.tie(0)->sync_with_stdio(0), cout.tie(0);
    int t; cin >> t;

    fore(_, 0, t){
        cin >> a >> b >> c;
        cout << dp(0, 0, 0) << '\n';
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 16):
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>

using namespace std;
#define fore(i, l, r)                                      \
  for (auto i = (l) - ((l) > (r)); i != (r) - ((l) > (r)); \
       i += 1 - 2 * ((l) > (r)))
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif
using ld = long double;
using lli = long long;
using ii = pair<int, int>;

const int N = 1e3;

string a, b, c;
int mem[N][N];
int done[N][N];
int timer = 0;

int dp(int ai, int bi){
    int ci = ai + bi;
    debug(ai, bi, ci);
    if(ai > sz(a) || bi > sz(b)){
        return 2 * N + 20;
    }
    if(ci >= sz(c)){
        return 0;
    }

    auto & ans = mem[ai][bi];
    auto & vis = done[ai][bi];

    if(vis != timer){
        vis = timer;
        ans = 0;

        int conta = 0, contb = 0;
        if(a[ai] != c[ci]){
            debug( ai, a[ai], c[ci]);
            conta++;
        }
        if(b[bi] != c[ci]){
            debug(bi, b[bi], c[ci]);
            contb++;
        }

        ans = min(dp(ai + 1, bi) + conta, dp(ai, bi + 1) + contb);
    }

    return ans;
}

int main() {
    cin.tie(0)->sync_with_stdio(0), cout.tie(0);
    timer = 0;
    int t; cin >> t;

    fore(_, 0, t){
        timer ++;
        cin >> a >> b >> c;

        int p = dp(0, 0);
        debug(p);
        cout << p << '\n';
    }
    return 0;
}

Submission (verdict: Accepted):
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>

using namespace std;
#define fore(i, l, r)                                      \
  for (auto i = (l) - ((l) > (r)); i != (r) - ((l) > (r)); \
       i += 1 - 2 * ((l) > (r)))
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif
using ld = long double;
using lli = long long;
using ii = pair<int, int>;

const int N = 1e3 + 5;

string a, b, c;
int mem[N][N];
int done[N][N];
int timer = 0;

int dp(int ai, int bi){
    int ci = ai + bi;
    debug(ai, bi, ci);
    if(ai > sz(a) || bi > sz(b)){
        return 2 * N + 20;
    }
    if(ci >= sz(c)){
        return 0;
    }

    auto & ans = mem[ai][bi];
    auto & vis = done[ai][bi];

    if(vis != timer){
        vis = timer;
        ans = 0;

        int conta = 0, contb = 0;
        if(a[ai] != c[ci]){
            debug( ai, a[ai], c[ci]);
            conta++;
        }
        if(b[bi] != c[ci]){
            debug(bi, b[bi], c[ci]);
            contb++;
        }

        ans = min(dp(ai + 1, bi) + conta, dp(ai, bi + 1) + contb);
    }

    return ans;
}

int main() {
    cin.tie(0)->sync_with_stdio(0), cout.tie(0);
    timer = 0;
    int t; cin >> t;

    fore(_, 0, t){
        timer ++;
        cin >> a >> b >> c;

        int p = dp(0, 0);
        debug(p);
        cout << p << '\n';
    }
    return 0;
}