ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(x) x.begin(), x.end()
#define pll pair<ll, ll>
#define vec vector
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const ll mod = 998244353;
ll fpow(ll a, ll b, ll m = -1)
{
	if (m != -1)
		a %= m;
	ll res = 1;
	while (b > 0)
	{
		if (b % 2 == 1)
		{
			if (m != -1)
				res = res * a % m;
			else
			{
				res *= a;
			}
		}
		a = a * a;
		if (m != -1)
		{
			a %= m;
		}
		b /= 2;
	}
	return res;
}
int main()
{
	fast;
	// freopen("pails.in", "r", stdin);
	// freopen("pails.out", "w", stdout);
	ll t = 1;
	// cin >> t;
end:;
	while (t--)
	{
		ll n, k;
		cin >> n;
		vec<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		set<ll> st;
		ll mx = 0;
		vec<pll> ans;
		for (int i = 0; i < n; i++)
		{
			for (int j = 1; j < v[i]; j++)
			{
				ans.push_back({v[i], j});
				if(st.count(j))
				{
					ans.push_back({j, v[i]});
				}
			}
			st.insert(v[i]);
		}
		cout << ans.size() << '\n';
		for (int i = 0; i < ans.size(); i++)
		{
			cout << ans[i].first << ' ' << ans[i].second << '\n';
		}
		
	}
	return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(x) x.begin(), x.end()
#define pll pair<ll, ll>
#define vec vector
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const ll mod = 998244353;
ll fpow(ll a, ll b, ll m = -1)
{
	if (m != -1)
		a %= m;
	ll res = 1;
	while (b > 0)
	{
		if (b % 2 == 1)
		{
			if (m != -1)
				res = res * a % m;
			else
			{
				res *= a;
			}
		}
		a = a * a;
		if (m != -1)
		{
			a %= m;
		}
		b /= 2;
	}
	return res;
}
int main()
{
	fast;
	// freopen("pails.in", "r", stdin);
	// freopen("pails.out", "w", stdout);
	ll t = 1;
	// cin >> t;
end:;
	while (t--)
	{
		ll n, k;
		cin >> n;
		vec<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		set<ll> st;
		ll mx = 0;
		vec<pll> ans;
		for (int i = 0; i < n; i++)
		{
			for(int j = i - 1; j >= 0; j--)
			{
				swap(v[j+1], v[j]);
				ans.push_back({v[j+1], v[j]});
			}
			ll in = 0;
			while(in < i && v[in]> v[in+1])
			{
				swap(v[in], v[in+1]);
				ans.push_back({v[in+1], v[in]});
			}
		}
		reverse(all(ans));
		cout << ans.size() << '\n';
		for (int i = 0; i < ans.size(); i++)
		{
			cout << ans[i].first << ' ' << ans[i].second << '\n';
		}
		
	}
	return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(x) x.begin(), x.end()
#define pll pair<ll, ll>
#define vec vector
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const ll mod = 998244353;
ll fpow(ll a, ll b, ll m = -1)
{
	if (m != -1)
		a %= m;
	ll res = 1;
	while (b > 0)
	{
		if (b % 2 == 1)
		{
			if (m != -1)
				res = res * a % m;
			else
			{
				res *= a;
			}
		}
		a = a * a;
		if (m != -1)
		{
			a %= m;
		}
		b /= 2;
	}
	return res;
}
int main()
{
	fast;
	// freopen("pails.in", "r", stdin);
	// freopen("pails.out", "w", stdout);
	ll t = 1;
	// cin >> t;
end:;
	while (t--)
	{
		ll n, k;
		cin >> n;
		vec<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		set<ll> st;
		ll mx = 0;
		vec<pll> ans;
		for (int i = 0; i < n; i++)
		{
			for(int j = i - 1; j >= 0; j--)
			{
				swap(v[j+1], v[j]);
				ans.push_back({v[j+1], v[j]});
			}
			ll in = 0;
			while(in < i && v[in]> v[in+1])
			{
				swap(v[in], v[in+1]);
				ans.push_back({v[in+1], v[in]});
				in++;
			}
		}
		reverse(all(ans));
		cout << ans.size() << '\n';
		for (int i = 0; i < ans.size(); i++)
		{
			cout << ans[i].first << ' ' << ans[i].second << '\n';
		}
		
	}
	return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(x) x.begin(), x.end()
#define pll pair<ll, ll>
#define vec vector
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const ll mod = 998244353;
ll fpow(ll a, ll b, ll m = -1)
{
	if (m != -1)
		a %= m;
	ll res = 1;
	while (b > 0)
	{
		if (b % 2 == 1)
		{
			if (m != -1)
				res = res * a % m;
			else
			{
				res *= a;
			}
		}
		a = a * a;
		if (m != -1)
		{
			a %= m;
		}
		b /= 2;
	}
	return res;
}
int main()
{
	fast;
	// freopen("pails.in", "r", stdin);
	// freopen("pails.out", "w", stdout);
	ll t = 1;
	// cin >> t;
end:;
	while (t--)
	{
		ll n, k;
		cin >> n;
		vec<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		set<ll> st;
		ll mx = 0;
		vec<pll> ans;
		for (int i = 0; i < n; i++)
		{
			for (int j = 1; j < v[i]; j++)
			{
				ans.push_back({v[i], j});
				if(st.count(j))
				{
					ans.push_back({j, v[i]});
				}
			}
			st.insert(v[i]);
		}
		cout << ans.size() << '\n';
		for (int i = 0; i < ans.size(); i++)
		{
			cout << ans[i].first << ' ' << ans[i].second << '\n';
		}
		
	}
	return 0;
}

Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(x) x.begin(), x.end()
#define pll pair<ll, ll>
#define vec vector
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const ll mod = 998244353;
ll fpow(ll a, ll b, ll m = -1)
{
	if (m != -1)
		a %= m;
	ll res = 1;
	while (b > 0)
	{
		if (b % 2 == 1)
		{
			if (m != -1)
				res = res * a % m;
			else
			{
				res *= a;
			}
		}
		a = a * a;
		if (m != -1)
		{
			a %= m;
		}
		b /= 2;
	}
	return res;
}
int main()
{
	fast;
	// freopen("pails.in", "r", stdin);
	// freopen("pails.out", "w", stdout);
	ll t = 1;
	// cin >> t;
end:;
	while (t--)
	{
		ll n, k;
		cin >> n;
		vec<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		set<ll> st;
		ll mx = 0;
		vec<pll> ans;
		for (int i = 0; i < n; i++)
		{
			for(int j = i - 1; j >= 0; j--)
			{
				swap(v[j+1], v[j]);
				ans.push_back({v[j+1], v[j]});
			}
			ll in = 0;
			while(in < i && v[in]> v[in+1])
			{
				swap(v[in], v[in+1]);
				ans.push_back({v[in+1], v[in]});
			}
		}
		reverse(all(ans));
		cout << ans.size() << '\n';
		for (int i = 0; i < ans.size(); i++)
		{
			cout << ans[i].first << ' ' << ans[i].second << '\n';
		}
		
	}
	return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

void solve() {
    string s; cin >> s;
    vector<int> a(s.size()), res;
    for(int i = 0; i < a.size(); i++){
        a[i] = s[i] - '0';
    }

    while(a.size() != 0){
        int v_max = a[0], bef = a[0], ind_max = 0;
        for(int j = 0; j <= min(8, int(a.size()) - 1); j++){
            bef = v_max;
            v_max = max(v_max, a[j] - j);
            if(v_max != bef){
                ind_max = j;
            }
        }
        res.push_back(v_max);
        if(ind_max != 0){
            a.erase(a.begin() + ind_max);
        }
        else{
            a.erase(a.begin());
        }
    }
    for(auto x: res) cout << x;
    cout << '\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #if LOCAL
        freopen("output.txt", "w", stdout);
        freopen("input.txt", "r", stdin);
    #endif
    int t; cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

void solve() {
    string s; cin >> s;
    for(int i = 0; i < s.size(); i++){
        int best = s[i] - '0', pos = i;
        for(int j = i; j < min(9, (int)s.size()); j++){
            if(s[j] - '0' - (j - i) > best){
                best = s[j] - '0' - (j - i);
                pos = j;
            }
        }
        while (pos > i) {
            swap(s[pos], s[pos - 1]);
            pos--;
        }
        s[i] = char(best + '0');
    }
    cout << s << '\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #if LOCAL
        freopen("output.txt", "w", stdout);
        freopen("input.txt", "r", stdin);
    #endif
    int t; cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


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

void solve() {
    string s; cin >> s;
    vector<int> a(s.size()), res;
    for(int i = 0; i < a.size(); i++){
        a[i] = s[i] - '0';
    }

    while(a.size() != 0){
        int v_max = a[0], bef = a[0], ind_max = 0;
        for(int j = 1; j <= min(7, int(a.size()) - 1); j++){
            bef = v_max;
            v_max = max(v_max, a[j] - j);
            if(v_max != bef){
                ind_max = j;
            }
        }
        res.push_back(v_max);
        if(ind_max != 0){
            a.erase(a.begin() + ind_max);
        }
        else{
            a.erase(a.begin());
        }
    }
    for(auto x: res) cout << x;
    cout << '\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #if LOCAL
        freopen("output.txt", "w", stdout);
        freopen("input.txt", "r", stdin);
    #endif
    int t; cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

void solve() {
    string s; cin >> s;
    vector<int> a(s.size()), res;
    for(int i = 0; i < a.size(); i++){
        a[i] = s[i] - '0';
    }

    while(a.size() != 0){
        int v_max = a[0], bef = a[0], ind_max = 0;
        for(int j = 0; j <= min(8, int(a.size()) - 1); j++){
            bef = v_max;
            v_max = max(v_max, a[j] - j);
            if(v_max != bef){
                ind_max = j;
            }
        }
        res.push_back(v_max);
        if(ind_max != 0){
            a.erase(a.begin() + ind_max);
        }
        else{
            a.erase(a.begin());
        }
        for(auto x: a) cout << x;
        cout << '\n';
    }
    for(auto x: res) cout << x;
    cout << '\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #if LOCAL
        freopen("output.txt", "w", stdout);
        freopen("input.txt", "r", stdin);
    #endif
    int t; cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

void solve() {
    string s; cin >> s;
    vector<int> a(s.size()), res;
    for(int i = 0; i < a.size(); i++){
        a[i] = s[i] - '0';
    }

    while(a.size() != 0){
        int v_max = a[0], bef = a[0], ind_max = 0;
        for(int j = 0; j <= min(8, int(a.size()) - 1); j++){
            bef = v_max;
            v_max = max(v_max, a[j] - j);
            if(v_max != bef){
                ind_max = j;
            }
        }
        res.push_back(v_max);
        if(ind_max != 0){
            a.erase(a.begin() + ind_max);
        }
        else{
            a.erase(a.begin());
        }
    }
    for(auto x: res) cout << x;
    cout << '\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #if LOCAL
        freopen("output.txt", "w", stdout);
        freopen("input.txt", "r", stdin);
    #endif
    int t; cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

void solve() {
    string s; cin >> s;
    vector<int> a(s.size()), res;
    for(int i = 0; i < a.size(); i++){
        a[i] = s[i] - '0';
    }

    while(a.size() != 0){
        int v_max = a[0], bef = a[0], ind_max = 0;
        for(int j = 1; j <= min(7, int(a.size()) - 1); j++){
            bef = v_max;
            v_max = max(v_max, a[j] - j);
            if(v_max != bef){
                ind_max = j;
            }
        }
        res.push_back(v_max);
        if(ind_max != 0){
            a.erase(a.begin() + ind_max);
        }
        else{
            a.erase(a.begin());
        }
    }
    for(auto x: res) cout << x;
    cout << '\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #if LOCAL
        freopen("output.txt", "w", stdout);
        freopen("input.txt", "r", stdin);
    #endif
    int t; cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

void solve() {
    string s; cin >> s;
    vector<int> a(s.size()), res;
    for(int i = 0; i < a.size(); i++){
        a[i] = s[i] - '0';
    }

    while(a.size() != 0){
        int v_max = a[0], bef = a[0], ind_max = 0;
        for(int j = 0; j <= min(8, int(a.size()) - 1); j++){
            bef = v_max;
            v_max = max(v_max, a[j] - j);
            if(v_max != bef){
                ind_max = j;
            }
        }
        res.push_back(v_max);
        if(ind_max != 0){
            a.erase(a.begin() + ind_max);
        }
        else{
            a.erase(a.begin());
        }
        for(auto x: a) cout << x;
        cout << '\n';
    }
    for(auto x: res) cout << x;
    cout << '\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #if LOCAL
        freopen("output.txt", "w", stdout);
        freopen("input.txt", "r", stdin);
    #endif
    int t; cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

void solve() {
    string s; cin >> s;
    for(int i = 0; i < s.size(); i++){
        int best = s[i] - '0', pos = i;
        for(int j = i; j < min(9, (int)s.size()); j++){
            if(s[j] - '0' - (j - i) > best){
                best = s[j] - '0' - (j - i);
                pos = j;
            }
        }
        while (pos > i) {
            swap(s[pos], s[pos - 1]);
            pos--;
        }
        s[i] = char(best + '0');
    }
    cout << s << '\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #if LOCAL
        freopen("output.txt", "w", stdout);
        freopen("input.txt", "r", stdin);
    #endif
    int t; cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

void solve() {
    string s; cin >> s;
    for(int i = 0; i < s.size(); i++){
        int best = s[i] - '0', pos = i;
        for(int j = i; j < min(10 + i, (int)s.size()); j++){
            if(s[j] - '0' - (j - i) > best){
                best = s[j] - '0' - (j - i);
                pos = j;
            }
        }
        while (pos > i) {
            swap(s[pos], s[pos - 1]);
            pos--;
        }
        s[i] = char(best + '0');
    }
    cout << s << '\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #if LOCAL
        freopen("output.txt", "w", stdout);
        freopen("input.txt", "r", stdin);
    #endif
    int t; cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


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

void solve() {
	string a, b, c;
	cin >> a >> b >> c;
	int n = a.size(), m = b.size();
	int N = n + m;
	vector dp(N + 1, vector<int> (n + 1, 1005));
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= min(n, i); j++) {
			if (j + 1 <= n) dp[i][j + 1] = min(dp[i][j + 1], dp[i - 1][j] + (c[i - 1] != a[j]));
			dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] != b[i - j - 1]));
		}
	}
	int ans = 1005;
	for (int i = 0; i <= n; i++) {
		ans = min(ans, dp[N][i]);
	}
	cout << ans << "\n";
}

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

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

	return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

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

void solve() {
	string a, b, c;
	cin >> a >> b >> c;
	int n = a.size(), m = b.size();
	int N = n + m;
	vector dp(N + 1, vector<int> (n + 1, 2005));
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= min(n, i); j++) {
			if (j + 1 <= n) dp[i][j + 1] = min(dp[i][j + 1], 
				dp[i - 1][j] + (c[i - 1] != a[j]));
			dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] != b[i - j - 1]));
		}
	}
	int ans = 2005;
	for (int i = 0; i <= n; i++) {
		// cerr << dp[N][i] << "\n";
		ans = min(ans, dp[N][i]);
	}
	cout << ans << "\n";
}

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

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

	return 0;
}

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

void solve() {
	string a, b, c;
	cin >> a >> b >> c;
	int n = a.size(), m = b.size();
	int N = n + m;
	vector dp(N + 1, vector<int> (n + 1, 2005));
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= min(n, i); j++) {
			if (j + 1 <= n) dp[i][j + 1] = min(dp[i][j + 1], 
				dp[i - 1][j] + (c[i - 1] != a[j]));
			dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] != b[i - j - 1]));
		}
	}
	int ans = dp[N][n];
	cout << ans << "\n";
}

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

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

	return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

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

void solve() {
	string a, b, c;
	cin >> a >> b >> c;
	int n = a.size(), m = b.size();
	int N = n + m;
	vector dp(N + 1, vector<int> (n + 1, 2005));
	for (int i = 0; i <= n; i++) {
		dp[0][i] = 0;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= min(n, i); j++) {
			if (j + 1 <= n) dp[i][j + 1] = min(dp[i][j + 1], dp[i - 1][j] + (c[i - 1] != a[j]));
			dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] != b[i - j - 1]));
		}
	}
	int ans = 2005;
	for (int i = 0; i <= n; i++) {
		ans = min(ans, dp[N][i]);
	}
	cout << ans << "\n";
}

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

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

	return 0;
}

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

void solve() {
	string a, b, c;
	cin >> a >> b >> c;
	int n = a.size(), m = b.size();
	int N = n + m;
	vector dp(N + 1, vector<int> (n + 1, 2005));
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= min(n, i); j++) {
			if (j + 1 <= n) dp[i][j + 1] = min(dp[i][j + 1], 
				dp[i - 1][j] + (c[i - 1] != a[j]));
			dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] != b[i - j - 1]));
		}
	}
	int ans = 2005;
	for (int i = 0; i <= n; i++) {
		// cerr << dp[N][i] << "\n";
		ans = min(ans, dp[N][i]);
	}
	cout << ans << "\n";
}

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

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

	return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

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

void solve() {
	string a, b, c;
	cin >> a >> b >> c;
	int n = a.size(), m = b.size();
	int N = n + m;
	vector dp(N + 1, vector<int> (n + 1, 1005));
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= min(n, i); j++) {
			if (j + 1 <= n) dp[i][j + 1] = min(dp[i][j + 1], dp[i - 1][j] + (c[i - 1] != a[j]));
			dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] != b[i - j - 1]));
		}
	}
	int ans = 1005;
	for (int i = 0; i <= n; i++) {
		ans = min(ans, dp[N][i]);
	}
	cout << ans << "\n";
}

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

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

	return 0;
}

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

void solve() {
	string a, b, c;
	cin >> a >> b >> c;
	int n = a.size(), m = b.size();
	int N = n + m;
	vector dp(N + 1, vector<int> (n + 1, 2005));
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= min(n, i); j++) {
			if (j + 1 <= n) dp[i][j + 1] = min(dp[i][j + 1], dp[i - 1][j] + (c[i - 1] != a[j]));
			dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] != b[i - j - 1]));
		}
	}
	int ans = 2005;
	for (int i = 0; i <= n; i++) {
		ans = min(ans, dp[N][i]);
	}
	cout << ans << "\n";
}

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

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

	return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

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

void solve() {
	string a, b, c;
	cin >> a >> b >> c;
	int n = a.size(), m = b.size();
	int N = n + m;
	vector dp(N + 1, vector<int> (n + 1, 2005));
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= min(n, i); j++) {
			if (j + 1 <= n) dp[i][j + 1] = min(dp[i][j + 1], dp[i - 1][j] + (c[i - 1] != a[j]));
			dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] != b[i - j - 1]));
		}
	}
	int ans = 2005;
	for (int i = 0; i <= n; i++) {
		ans = min(ans, dp[N][i]);
	}
	cout << ans << "\n";
}

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

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

	return 0;
}

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

void solve() {
	string a, b, c;
	cin >> a >> b >> c;
	int n = a.size(), m = b.size();
	int N = n + m;
	vector dp(N + 1, vector<int> (n + 1, 2005));
	for (int i = 0; i <= n; i++) {
		dp[0][i] = 0;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= min(n, i); j++) {
			if (j + 1 <= n) dp[i][j + 1] = min(dp[i][j + 1], dp[i - 1][j] + (c[i - 1] != a[j]));
			dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] != b[i - j - 1]));
		}
	}
	int ans = 2005;
	for (int i = 0; i <= n; i++) {
		ans = min(ans, dp[N][i]);
	}
	cout << ans << "\n";
}

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

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

	return 0;
}