ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int tests;
    cin >> tests;

    for (int _ = 1; _ <= tests; _++)
    {
        int n, m, ok = 1;
        cin >> n >> m;

        vector<int> a(n), b(m);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        for (int j = 0; j < m; j++)
            cin >> b[j];

        sort(b.rbegin(), b.rend());
        multiset<int> ms(a.begin(), a.end());
        priority_queue<int> pq(b.begin(), b.end());

        int cnt = n - m;

        while (cnt)
        {
            int x = pq.top();
            pq.pop();

            if (ms.count(x))
            {
                auto it = ms.lower_bound(x);
                ms.erase(it);
            }
            else if (x != 1)
            {
                int y = x / 2;
                pq.emplace(y);
                if (x % 2 == 1)
                    y++;
                pq.emplace(y);
                cnt--;
            }
            else
            {
                ok = 0;
                break;
            }
        }

        // cout << ok << "\n";

        while (ok && pq.size())
        {
            int x = pq.top();
            pq.pop();

            if (ms.count(x))
                ms.erase(ms.lower_bound(x));
            else
                ok = 0;
        }

        cout << (ok ? "Yes\n" : "No\n");
    }

    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int tests;
    cin >> tests;

    for (int _ = 1; _ <= tests; _++)
    {
        int n, m, ok = 1;
        cin >> n >> m;

        vector<int> a(n), b(m);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        for (int j = 0; j < m; j++)
            cin >> b[j];

        sort(b.rbegin(), b.rend());
        multiset<int> ms(a.begin(), a.end());
        priority_queue<int> pq(b.begin(), b.end());

        int cnt = n - m;

        while (cnt)
        {
            int x = pq.top();
            pq.pop();

            if (ms.count(x))
            {
                auto it = ms.lower_bound(x);
                ms.erase(it);
            }
            else if (x != 1)
            {
                int y = x / 2;
                pq.emplace(y);
                if (x % 2 == 1)
                    y++;
                pq.emplace(y);
                cnt--;
            }
            else
            {
                ok = 0;
                break;
            }
        }

        // cout << ok << "\n";

        while (ok && pq.size())
        {
            int x = pq.top();
            pq.pop();

            if (ms.count(x))
                ms.erase(ms.lower_bound(x));
            else
                ok = 0;
        }

        cout << (ok ? "Yes\n" : "No\n");
    }

    return 0;
}

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

using namespace std;

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int tests;
    cin >> tests;

    for (int _ = 1; _ <= tests; _++)
    {
        int n, m, ok = 1;
        cin >> n >> m;

        vector<int> a(n), b(m);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        for (int j = 0; j < m; j++)
            cin >> b[j];

        sort(b.rbegin(), b.rend());
        multiset<int> ms(a.begin(), a.end());
        priority_queue<int> pq(b.begin(), b.end());

        int cnt = n - m;

        while (cnt && pq.size())
        {
            int x = pq.top();
            pq.pop();

            if (ms.count(x))
            {
                auto it = ms.lower_bound(x);
                ms.erase(it);
            }
            else if (x != 1)
            {
                int y = x / 2;
                pq.emplace(y);
                if (x % 2 == 1)
                    y++;
                pq.emplace(y);
                cnt--;
            }
            else
            {
                ok = 0;
                break;
            }
        }

        // cout << ok << "\n";

        while (ok && pq.size())
        {
            int x = pq.top();
            pq.pop();

            if (ms.count(x))
                ms.erase(ms.lower_bound(x));
            else
                ok = 0;
        }

        cout << (ok ? "Yes\n" : "No\n");
    }

    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int tests;
    cin >> tests;

    for (int _ = 1; _ <= tests; _++)
    {
        int n, m, ok = 1;
        cin >> n >> m;

        vector<int> a(n), b(m);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        for (int j = 0; j < m; j++)
            cin >> b[j];

        sort(b.rbegin(), b.rend());
        multiset<int> ms(a.begin(), a.end());
        priority_queue<int> pq(b.begin(), b.end());

        int cnt = n - m;

        while (cnt && pq.size())
        {
            int x = pq.top();
            pq.pop();

            if (ms.count(x))
            {
                auto it = ms.lower_bound(x);
                ms.erase(it);
            }
            else if (x != 1)
            {
                int y = x / 2;
                pq.emplace(y);
                if (x % 2 == 1)
                    y++;
                pq.emplace(y);
                cnt--;
            }
            else
            {
                ok = 0;
                break;
            }
        }

        // cout << ok << "\n";

        while (ok && pq.size())
        {
            int x = pq.top();
            pq.pop();

            if (ms.count(x))
                ms.erase(ms.lower_bound(x));
            else
                ok = 0;
        }

        cout << (ok ? "Yes\n" : "No\n");
    }

    return 0;
}

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

using namespace std;

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int tests;
    cin >> tests;

    for (int _ = 1; _ <= tests; _++)
    {
        int n, m, ok = 1;
        cin >> n >> m;

        vector<int> a(n), b(m);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        for (int j = 0; j < m; j++)
            cin >> b[j];

        sort(b.rbegin(), b.rend());
        multiset<int> ms(a.begin(), a.end());
        priority_queue<int> pq(b.begin(), b.end());

        int cnt = n - m;

        while (cnt && pq.size())
        {
            int x = pq.top();
            pq.pop();

            if (ms.count(x))
            {
                auto it = ms.lower_bound(x);
                ms.erase(it);
            }
            else if (x != 1)
            {
                int y = x / 2;
                pq.emplace(y);
                if (x % 2 == 1)
                    y++;
                pq.emplace(y);
                cnt--;
            }
            else
            {
                ok = 0;
                break;
            }
        }

        // cout << ok << "\n";

        while (ok && pq.size())
        {
            int x = pq.top();
            pq.pop();

            if (ms.count(x))
                ms.erase(ms.lower_bound(x));
            else
                ok = 0;
        }

        cout << (ok && ms.size() == 0 ? "Yes\n" : "No\n");
    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

void solve()
{
    string s;
    cin >> s;

    int n = s.length();
    int que = 0;
    int cnt[2] = {0};
    for (int i = 0; i < n; ++i)
    {
        if (s[i] > '1' && s[i] < '4')
            ++cnt[s[i] - '2'];
        que += s[i] - '0';
    }

    if (que % 9 == 0)
    {
        cout << "YES" << endl;
        return;
    }

    if (que % 2 == 0 && (cnt[0] != 0 || cnt[1] != 0))
    {
        vector<vector<int>> dp(cnt[0] + 1, vector<int>(cnt[1] + 1, que));
        for (int i = 0; i <= cnt[0]; ++i)
        {
            for (int j = 0; j <= cnt[1]; ++j)
            {
                dp[i][j] += i * 2 + j * 6;
                if (dp[i][j] % 9 == 0)
                {
                    cout << "YES" << endl;
                    return;
                }
            }
        }
    }

    cout << "NO" << endl;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Submission (verdict: Memory limit exceeded on test 4):
#include <bits/stdc++.h>
using namespace std;

void solve()
{
    string s;
    cin >> s;

    int n = s.length();
    int que = 0;
    int cnt[2] = {0};
    for (int i = 0; i < n; ++i)
    {
        if (s[i] > '1' && s[i] < '4')
            ++cnt[s[i] - '2'];
        que += s[i] - '0';
    }

    if (que % 9 == 0)
    {
        cout << "YES" << endl;
        return;
    }

    if (cnt[0] != 0 || cnt[1] != 0)
    {
        vector<vector<int>> dp(cnt[0] + 1, vector<int>(cnt[1] + 1, que));
        for (int i = 0; i <= cnt[0]; ++i)
        {
            for (int j = 0; j <= cnt[1]; ++j)
            {
                dp[i][j] += i * 2 + j * 6;
                if (dp[i][j] % 9 == 0)
                {
                    cout << "YES" << endl;
                    return;
                }
            }
        }
    }

    cout << "NO" << endl;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

void solve()
{
    string s;
    cin >> s;

    int n = s.length();
    int que = 0;
    int cnt[2] = {0};
    for (int i = 0; i < n; ++i)
    {
        if (s[i] > '1' && s[i] < '4')
            ++cnt[s[i] - '2'];
        que += s[i] - '0';
    }

    if (que % 9 == 0)
    {
        cout << "YES" << endl;
        return;
    }

    if (que % 2 == 0 && (cnt[0] != 0 || cnt[1] != 0))
    {
        vector<vector<int>> dp(cnt[0] + 1, vector<int>(cnt[1] + 1, que));
        for (int i = 0; i <= cnt[0]; ++i)
        {
            for (int j = 0; j <= cnt[1]; ++j)
            {
                dp[i][j] += i * 2 + j * 6;
                if (dp[i][j] % 9 == 0)
                {
                    cout << "YES" << endl;
                    return;
                }
            }
        }
    }

    cout << "NO" << endl;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Memory limit exceeded on test 4):
#include <bits/stdc++.h>
using namespace std;

void solve()
{
    string s;
    cin >> s;

    int n = s.length();
    int que = 0;
    int cnt[2] = {0};
    for (int i = 0; i < n; ++i)
    {
        if (s[i] > '1' && s[i] < '4')
            ++cnt[s[i] - '2'];
        que += s[i] - '0';
    }

    if (que % 9 == 0)
    {
        cout << "YES" << endl;
        return;
    }

    if (cnt[0] != 0 || cnt[1] != 0)
    {
        vector<vector<int>> dp(cnt[0] + 1, vector<int>(cnt[1] + 1, que));
        for (int i = 0; i <= cnt[0]; ++i)
        {
            for (int j = 0; j <= cnt[1]; ++j)
            {
                dp[i][j] += i * 2 + j * 6;
                if (dp[i][j] % 9 == 0)
                {
                    cout << "YES" << endl;
                    return;
                }
            }
        }
    }

    cout << "NO" << endl;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

void solve()
{
    string s;
    cin >> s;

    int n = s.length();
    int que = 0;
    int cnt[2] = {0};
    for (int i = 0; i < n; ++i)
    {
        if (s[i] > '1' && s[i] < '4')
            ++cnt[s[i] - '2'];
        que += s[i] - '0';
    }

    if (que % 9 == 0)
    {
        cout << "YES" << endl;
        return;
    }

    if (cnt[0] != 0 || cnt[1] != 0)
    {
        if (cnt[0] < 2)
        {
            while (cnt[1] >= 0)
            {
                int tmp = que + cnt[1]-- * 6;
                if (tmp % 9 == 0 || (tmp + cnt[0] * 2) % 9 == 0)
                {
                    cout << "YES" << endl;
                    return;
                }
            }
        }
        else
        {
            for (int i = 0; i <= cnt[1]; ++i)
            {
                int tmp = que + i * 6;
                if (tmp % 9 == 0 || (tmp + 2) % 9 == 0 || (tmp + 4) % 9 == 0)
                {
                    cout << "YES" << endl;
                    return;
                }
            }
            que += cnt[1] * 6;
            for (int i = 3; i <= cnt[0]; ++i)
            {
                if ((que + i * 2) % 9 == 0)
                {
                    cout << "YES" << endl;
                    return;
                }
            }
        }
    }

    cout << "NO" << endl;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
/*

This code template was updated by Yukii_P on 2024/11/12.

*/
#include <bits/stdc++.h>
#define FIO cin.tie(0); ios::sync_with_stdio(false)
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define inf 0x3f3f3f3f

#ifndef ONLINE_JUDGE
#define debug(...) std::cerr << #__VA_ARGS__ << " = "; dbg1(__VA_ARGS__)
void dbg2() { std::cerr << "\n"; }
template<typename T, typename... T2>
void dbg2(T x, T2... args) {
    std::cerr << ", " << x;
    dbg2(args...);
}
template<typename T, typename... T2>
void dbg1(T x, T2... args) {
    std::cerr << x;
    dbg2(args...);
}
#else
#define debug(...) 
#endif

using namespace std;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using pii = std::pair<int, int>;

inline char nc() {
    static char buf[1 << 20], *p1, *p2;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<20, stdin), p1 == p2) ? EOF : *p1++;
}
#ifndef ONLINE_JUDGE
#define nc getchar
#endif
void read() {}
template<typename T, typename... T2> 
inline void read(T &x, T2 &... oth) {
    x = 0; char c = nc(), up = c;
    while(!isdigit(c)) up = c, c = nc();
    while(isdigit(c)) x = x * 10 + c - '0', c = nc();
    up == '-' ? x = -x : 0;
    read(oth...);
}

constexpr int N = 1e3 + 10;
constexpr int MOD = 998244353;

int a[N], pv[N], sv[N];
set<int> st[N];
pii ans[N];
int top;

void solve() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (a[i] > i) {
            //cnt += a[i] - i;
            for (int j = a[i] - 1; j >= i; --j) {
                ans[top++] = {a[i], j};
                st[a[i]].insert(j);
                st[j].insert(a[i]);
            }
            
        }
    }
    for (int i = 1; i <= n - 1; ++i) {
        if (st[a[i]].contains(a[i+1])) continue;
        ans[top++] = {a[i+1], a[i]};
        ans[top++] = {a[i], a[i+1]};
    }
    cout << top << '\n';
    for (int i = 0; i < top; ++i) {
        cout << ans[i].fi << ' ' << ans[i].se << '\n';
    }

}

signed main() {
    
    FIO;
    int t = 1;
    //cin >> t;
    while (t--) solve();

    return 0;
}

/*

 __  __     ___    ___      _      __ _            ___      _             _      
 \ \/ /    | _ \  /   \    | |    / _` |   ___    / __|    | |    _  _   | |__   
  >  <     |  _/  | - |    | |    \__, |  / _ \  | (__     | |   | +| |  | '_ \  
 /_/\_\   _|_|_   |_|_|   _|_|_   |___/   \___/   \___|   _|_|_   \_,_|  |_.__/  
_|"""""|_| """ |_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| 
"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-' 

(Font: ASCII - Train)

"El Psy Kongroo." -- Hououin Kyoma

*/
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<cmath>
using namespace std;
int t,n,a[52];
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		int aa=0;
		scanf("%d",&n);
		for(int q=1;q<=n;q++)
			scanf("%d",&a[q]),aa+=a[q];
		a[n+1]=0;
		while(n--)
		{
			for(int q=1;q<=n;q++)
				a[q]=a[q+1]-a[q];
			int sum=0;
			for(int q=1;q<=n;q++)
				sum+=a[q];
			aa=max(aa,abs(sum));
		}
		printf("%d\n",aa);
	}
	
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<cmath>
using namespace std;
int t,n,a[52];
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		int aa=0;
		scanf("%d",&n);
		for(int q=1;q<=n;q++)
			scanf("%d",&a[q]),aa+=a[q];
		a[n+1]=0;
		while(n--)
		{
			for(int q=1;q<=n;q++)
				a[q]=a[q+1]-a[q];
			int sum=0;
			for(int q=1;q<=n;q++)
				sum+=a[q];
			aa=max(aa,abs(sum));
		}
		printf("%d\n",aa);
	}
	
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<cmath>
using namespace std;
int t,n,a[52];
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		int aa=0;
		scanf("%d",&n);
		for(int q=1;q<=n;q++)
			scanf("%d",&a[q]),aa+=a[q];
		a[n+1]=0;
		if(aa!=1)
		{
			while(n--)
			{
				for(int q=1;q<=n;q++)
					a[q]=a[q+1]-a[q];
				int sum=0;
				for(int q=1;q<=n;q++)
					sum+=a[q];
				aa=max(aa,abs(sum));
			}
		}
		printf("%d\n",aa);
	}
	
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<cmath>
using namespace std;
long long int t,n,a[52];
int main()
{
	scanf("%lld",&t);
	while(t--)
	{
		long long int aa=0;
		scanf("%lld",&n);
		for(long long int q=1;q<=n;q++)
			scanf("%lld",&a[q]),aa+=a[q];
		a[n+1]=0;
		if(aa!=1)
		{
			while(n--)
			{
				for(long long int q=1;q<=n;q++)
					a[q]=a[q+1]-a[q];
				long long int sum=0;
				for(long long int q=1;q<=n;q++)
					sum+=a[q];
				aa=max(aa,max(sum,-sum));
			}
		}
		printf("%lld\n",aa);
	}
	
	return 0;
}

Submission (verdict: Accepted):
#include<iostream>
#include<cmath>
using namespace std;
long long int t,n,a[52];
int main()
{
	scanf("%lld",&t);
	while(t--)
	{
		long long int aa=0;
		scanf("%lld",&n);
		for(long long int q=1;q<=n;q++)
			scanf("%lld",&a[q]),aa+=a[q];
		a[n+1]=0;
		if(n!=1)
		{
			while(n--)
			{
				for(long long int q=1;q<=n;q++)
					a[q]=a[q+1]-a[q];
				long long int sum=0;
				for(long long int q=1;q<=n;q++)
					sum+=a[q];
				aa=max(aa,max(sum,-sum));
			}
		}
		printf("%lld\n",aa);
	}
	
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<cmath>
using namespace std;
int t,n,a[52];
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		int aa=0;
		scanf("%d",&n);
		for(int q=1;q<=n;q++)
			scanf("%d",&a[q]),aa+=a[q];
		a[n+1]=0;
		if(aa!=1)
		{
			while(n--)
			{
				for(int q=1;q<=n;q++)
					a[q]=a[q+1]-a[q];
				int sum=0;
				for(int q=1;q<=n;q++)
					sum+=a[q];
				aa=max(aa,abs(sum));
			}
		}
		printf("%d\n",aa);
	}
	
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<cmath>
using namespace std;
long long int t,n,a[52];
int main()
{
	scanf("%lld",&t);
	while(t--)
	{
		long long int aa=0;
		scanf("%lld",&n);
		for(long long int q=1;q<=n;q++)
			scanf("%lld",&a[q]),aa+=a[q];
		a[n+1]=0;
		if(aa!=1)
		{
			while(n--)
			{
				for(long long int q=1;q<=n;q++)
					a[q]=a[q+1]-a[q];
				long long int sum=0;
				for(long long int q=1;q<=n;q++)
					sum+=a[q];
				aa=max(aa,max(sum,-sum));
			}
		}
		printf("%lld\n",aa);
	}
	
	return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

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

int dp[1001][1001];

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

void accept_it() {
    string a, b, c;
    cin >> a >> b >> c;
    
    memset(dp, -1, sizeof(dp));
    int res = dfs(0, 0, a, b, c);
    
    cout << res << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;

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

    return 0;
}

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

int dp[1001][1001];

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

void accept_it() {
    string a, b, c;
    cin >> a >> b >> c;
    
    memset(dp, -1, sizeof(dp));
    int res = dfs(0, 0, a, b, c);
    
    cout << res << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;

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

    return 0;
}