ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define MULTI 1
#define int long long
#define inf (LLONG_MAX >> 2)
#define ninf (LLONG_MIN >> 2)
#define binrep(x) (bitset<32>(x))


void solve() {
    // tip of the iceberg
    int l,r; cin >> l >> r;

    // cout << "inputs are " << endl << binrep(l) << endl;
    // cout << binrep(r) << endl;

    int temp = log2(l^r);
    int MASK = ( 1ll << (1 + temp)) - 1;
    int res = l - (l & MASK);

    l &= MASK;
    r &= MASK;

    int rval = log2(r);
    int lval = log2(l);

    int x = ( 1ll << rval );
    int third = l;
    
    if ( x - 1 == l ){
        third = x + 1;
    }

    // cout << "res is " << endl << binrep(res) << endl;

    cout << res + x << " " << res + x - 1 << " " << res + l << endl;
    
}

signed main() {
    ios::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    int t {1};
    if (MULTI)
        cin >> t;

    for (int i = 1; i <= t ; i++ ) {
        solve();
    }

    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define MULTI 1
#define int long long
#define inf (LLONG_MAX >> 2)
#define ninf (LLONG_MIN >> 2)
#define binrep(x) (bitset<32>(x))


void solve() {
    // tip of the iceberg
    int l,r; cin >> l >> r;

    // cout << "inputs are " << endl << binrep(l) << endl;
    // cout << binrep(r) << endl;

    int temp = log2(l^r);
    int MASK = ( 1ll << (1 + temp)) - 1;
    int res = l - (l & MASK);

    l &= MASK;
    r &= MASK;

    int rval = log2(r);

    int x = ( 1ll << rval );
    int third = l;
    
    if ( x - 1 == l ){
        third = x + 1;
    }

    // cout << "res is " << endl << binrep(res) << endl;

    cout << res + x << " " << res + x - 1 << " " << res + l << endl;
    
}

signed main() {
    ios::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    int t {1};
    if (MULTI)
        cin >> t;

    for (int i = 1; i <= t ; i++ ) {
        solve();
    }

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


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

#define int long long

void push()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];

    vector<int> p(n);
    for (int i = 0; i < n; i++)
        p[i] = i + 1;

    vector<pair<int, int>> ans;

    for (int i = n - 1; i >= 0; i--)
    {
        int idx = -1;
        for (int j = 0; j < n; j++)
        {
            if (v[i] == p[j])
            {
                idx = j;
                break;
            }
        }
        while (idx != i)
        {
            ans.push_back({p[idx + 1], p[idx]});
            swap(p[idx], p[idx + 1]);
            idx++;
        }
    }

    vector<int> tmp = {v[0]};
    for (int i = 1; i < n; i++)
    {
        if (v[i] < v[i - 1])
        {
            int sz = tmp.size();
            for (int j = sz - 1; j >= 0; j--)
            {
                for (int idx = 0; idx < j; idx++)
                {
                    ans.push_back({tmp[idx + 1], tmp[idx]});
                    swap(tmp[idx], tmp[idx + 1]);
                }
            }
            for (int j = sz - 1; j >= 0; j--)
            {
                for (int idx = 0; idx < j; idx++)
                {
                    ans.push_back({tmp[idx + 1], tmp[idx]});
                    swap(tmp[idx], tmp[idx + 1]);
                }
            }
            tmp.clear();
        }
        tmp.push_back(v[i]);
    }

    int sz = tmp.size();
    for (int j = sz - 1; j >= 0; j--)
    {
        for (int idx = 0; idx < j; idx++)
        {
            ans.push_back({tmp[idx], tmp[idx + 1]});
            swap(tmp[idx], tmp[idx + 1]);
        }
    }
    for (int j = sz - 1; j >= 0; j--)
    {
        for (int idx = 0; idx < j; idx++)
        {
            ans.push_back({tmp[idx], tmp[idx + 1]});
            swap(tmp[idx], tmp[idx + 1]);
        }
    }

    cout << ans.size() << endl;
    for (auto &pr : ans)
    {
        cout << pr.first << " " << pr.second << endl;
    }
}

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

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

void push()
{
    int n;
    cin >> n;
    vector<int> v(n), p(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];
    for (int i = 0; i < n; i++)
        p[i] = i + 1;

    vector<pair<int, int>> ans;

    for (int i = n - 1; i >= 0; i--)
    {
        int idx = find(p.begin(), p.end(), v[i]) - p.begin();
        while (idx != i)
        {
            ans.push_back({p[idx + 1], p[idx]});
            swap(p[idx], p[idx + 1]);
            idx++;
        }
    }

    vector<int> tmp = {v[0]};
    for (int i = 1; i < n; i++)
    {
        if (v[i] < v[i - 1])
        {
            int size = tmp.size();
            for (int j = size - 1; j >= 0; j--)
            {
                for (int k = 0; k < j; k++)
                {
                    ans.push_back({tmp[k + 1], tmp[k]});
                    swap(tmp[k], tmp[k + 1]);
                }
            }
            for (int j = size - 1; j >= 0; j--)
            {
                for (int k = 0; k < j; k++)
                {
                    ans.push_back({tmp[k + 1], tmp[k]});
                    swap(tmp[k], tmp[k + 1]);
                }
            }
            tmp.clear();
        }
        tmp.push_back(v[i]);
    }

    int size = tmp.size();
    for (int j = size - 1; j >= 0; j--)
    {
        for (int k = 0; k < j; k++)
        {
            ans.push_back({tmp[k + 1], tmp[k]});
            swap(tmp[k], tmp[k + 1]);
        }
    }
    for (int j = size - 1; j >= 0; j--)
    {
        for (int k = 0; k < j; k++)
        {
            ans.push_back({tmp[k + 1], tmp[k]});
            swap(tmp[k], tmp[k + 1]);
        }
    }

    cout << ans.size() << endl;
    for (auto &[a, b] : ans)
        cout << a << " " << b << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    while (t--)
        push();
    return 0;
}


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

void push()
{
    int n;
    cin >> n;
    vector<int> v(n), p(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];
    for (int i = 0; i < n; i++)
        p[i] = i + 1;

    vector<pair<int, int>> ans;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n - i - 1; j++)
        {
            ans.push_back({p[j + 1], p[j]});
            swap(p[j], p[j + 1]);
        }
    }

    for (int i = n - 1; i >= 0; i--)
    {
        int x = v[i], j = 0;
        while (p[j] != x)
            j++;
        while (j < i)
        {
            ans.push_back({p[j + 1], p[j]});
            swap(p[j], p[j + 1]);
            j++;
        }
    }

    cout << ans.size() << endl;
    for (auto &i : ans)
        cout << i.first << ' ' << i.second << endl;
}

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

    int t = 1;
    while (t--)
        push();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> //ÓÃtree
using namespace std;
namespace pbds = __gnu_pbds;
template<typename T>
using pbdstree = pbds::tree<T,pbds::null_type,less<T>,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
#define int long long
using ll = long long;
template <typename T>
using Qmin = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using Qmax = priority_queue<T>;
#define rep(i, a, b) for(int i = a; i <= (b); ++i)
#define frep(i, a, b) for(int i = a; i < (b); ++i)
#define drep(i, a, b) for(int i = a; i >= (b); --i)
// #define ls (p << 1)
// #define rs (p << 1 | 1)
// #define mid ((l + r) >> 1)
const int MAXN = 200010;
const int MOD = 998244353;
// const int INF = 0x3f3f3f3f;
const int INF = 1e15;
int get(int x, int k){
    return (x >> k) & 1;
}
void solve(){
    int l, r;
    cin >> l >> r;
    int ans = 0;
    int i = 30;
    while(i >= 0){
        if(get(l, i) != get(r, i)) break;
        --i;
    }
    int x = (r >> i) << i;
    int y = l + (1 << i) - 1;
    int z = x == r ? y - 1 : x + 1;
    cout << x << " " << y << " " << z << endl;
    return;
}
signed main(){
    // cout << (965321865 ^ 375544086) + (965321865 ^ 12551794) + (375544086 ^ 12551794) << endl;
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int _t = 1;
    cin >> _t;
    while(_t--){
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> //ÓÃtree
using namespace std;
namespace pbds = __gnu_pbds;
template<typename T>
using pbdstree = pbds::tree<T,pbds::null_type,less<T>,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
#define int long long
using ll = long long;
template <typename T>
using Qmin = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using Qmax = priority_queue<T>;
#define rep(i, a, b) for(int i = a; i <= (b); ++i)
#define frep(i, a, b) for(int i = a; i < (b); ++i)
#define drep(i, a, b) for(int i = a; i >= (b); --i)
// #define ls (p << 1)
// #define rs (p << 1 | 1)
// #define mid ((l + r) >> 1)
const int MAXN = 200010;
const int MOD = 998244353;
// const int INF = 0x3f3f3f3f;
const int INF = 1e15;
int get(int x, int k){
    return (x >> k) & 1;
}
void solve(){
    int l, r;
    cin >> l >> r;
    int ans = 0;
    int i = 30;
    while(i >= 0){
        if(get(l, i) != get(r, i)) break;
        --i;
    }
    int x = (r >> i) << i;
    int y = x - 1;
    int z = x == r ? y - 1 : x + 1;
    cout << x << " " << y << " " << z << endl;
    return;
}
signed main(){
    // cout << (965321865 ^ 375544086) + (965321865 ^ 12551794) + (375544086 ^ 12551794) << endl;
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int _t = 1;
    cin >> _t;
    while(_t--){
        solve();
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> //ÓÃtree
using namespace std;
namespace pbds = __gnu_pbds;
template<typename T>
using pbdstree = pbds::tree<T,pbds::null_type,less<T>,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
#define int long long
using ll = long long;
template <typename T>
using Qmin = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using Qmax = priority_queue<T>;
#define rep(i, a, b) for(int i = a; i <= (b); ++i)
#define frep(i, a, b) for(int i = a; i < (b); ++i)
#define drep(i, a, b) for(int i = a; i >= (b); --i)
// #define ls (p << 1)
// #define rs (p << 1 | 1)
// #define mid ((l + r) >> 1)
const int MAXN = 200010;
const int MOD = 998244353;
// const int INF = 0x3f3f3f3f;
const int INF = 1e15;
int get(int x, int k){
    return (x >> k) & 1;
}
void solve(){
    int l, r;
    cin >> l >> r;
    int ans = 0;
    int i = 30;
    while(i >= 0){
        if(get(l, i) != get(r, i)) break;
        --i;
    }
    r = (r >> i) << i;
    l = l + (1 << i) - 1;
    cout << r << " " << r << " " << l << endl;
    return;
}
signed main(){
    cout << (965321865 ^ 375544086) + (965321865 ^ 12551794) + (375544086 ^ 12551794) << endl;
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int _t = 1;
    cin >> _t;
    while(_t--){
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> //ÓÃtree
using namespace std;
namespace pbds = __gnu_pbds;
template<typename T>
using pbdstree = pbds::tree<T,pbds::null_type,less<T>,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
#define int long long
using ll = long long;
template <typename T>
using Qmin = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using Qmax = priority_queue<T>;
#define rep(i, a, b) for(int i = a; i <= (b); ++i)
#define frep(i, a, b) for(int i = a; i < (b); ++i)
#define drep(i, a, b) for(int i = a; i >= (b); --i)
// #define ls (p << 1)
// #define rs (p << 1 | 1)
// #define mid ((l + r) >> 1)
const int MAXN = 200010;
const int MOD = 998244353;
// const int INF = 0x3f3f3f3f;
const int INF = 1e15;
int get(int x, int k){
    return (x >> k) & 1;
}
void solve(){
    int l, r;
    cin >> l >> r;
    int ans = 0;
    int i = 30;
    while(i >= 0){
        if(get(l, i) != get(r, i)) break;
        --i;
    }
    r = (r >> i) << i;
    l = l + (1 << i) - 1;
    cout << r << " " << r << " " << l << endl;
    return;
}
signed main(){
    // cout << (965321865 ^ 375544086) + (965321865 ^ 12551794) + (375544086 ^ 12551794) << endl;
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int _t = 1;
    cin >> _t;
    while(_t--){
        solve();
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> //ÓÃtree
using namespace std;
namespace pbds = __gnu_pbds;
template<typename T>
using pbdstree = pbds::tree<T,pbds::null_type,less<T>,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
#define int long long
using ll = long long;
template <typename T>
using Qmin = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using Qmax = priority_queue<T>;
#define rep(i, a, b) for(int i = a; i <= (b); ++i)
#define frep(i, a, b) for(int i = a; i < (b); ++i)
#define drep(i, a, b) for(int i = a; i >= (b); --i)
// #define ls (p << 1)
// #define rs (p << 1 | 1)
// #define mid ((l + r) >> 1)
const int MAXN = 200010;
const int MOD = 998244353;
// const int INF = 0x3f3f3f3f;
const int INF = 1e15;
int get(int x, int k){
    return (x >> k) & 1;
}
void solve(){
    int l, r;
    cin >> l >> r;
    int ans = 0;
    int i = 30;
    while(i >= 0){
        if(get(l, i) != get(r, i)) break;
        --i;
    }
    r = (r >> i) << i;
    l = l + (1 << i) - 1;
    cout << r << " " << r << " " << l << endl;
    return;
}
signed main(){
    // cout << (965321865 ^ 375544086) + (965321865 ^ 12551794) + (375544086 ^ 12551794) << endl;
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int _t = 1;
    cin >> _t;
    while(_t--){
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> //ÓÃtree
using namespace std;
namespace pbds = __gnu_pbds;
template<typename T>
using pbdstree = pbds::tree<T,pbds::null_type,less<T>,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
#define int long long
using ll = long long;
template <typename T>
using Qmin = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using Qmax = priority_queue<T>;
#define rep(i, a, b) for(int i = a; i <= (b); ++i)
#define frep(i, a, b) for(int i = a; i < (b); ++i)
#define drep(i, a, b) for(int i = a; i >= (b); --i)
// #define ls (p << 1)
// #define rs (p << 1 | 1)
// #define mid ((l + r) >> 1)
const int MAXN = 200010;
const int MOD = 998244353;
// const int INF = 0x3f3f3f3f;
const int INF = 1e15;
int get(int x, int k){
    return (x >> k) & 1;
}
void solve(){
    int l, r;
    cin >> l >> r;
    int ans = 0;
    int i = 30;
    while(i >= 0){
        if(get(l, i) != get(r, i)) break;
        --i;
    }
    int x = (r >> i) << i;
    int y = l + (1 << i) - 1;
    int z = x == r ? y - 1 : x + 1;
    cout << x << " " << y << " " << z << endl;
    return;
}
signed main(){
    // cout << (965321865 ^ 375544086) + (965321865 ^ 12551794) + (375544086 ^ 12551794) << endl;
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int _t = 1;
    cin >> _t;
    while(_t--){
        solve();
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> //ÓÃtree
using namespace std;
namespace pbds = __gnu_pbds;
template<typename T>
using pbdstree = pbds::tree<T,pbds::null_type,less<T>,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
#define int long long
using ll = long long;
template <typename T>
using Qmin = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using Qmax = priority_queue<T>;
#define rep(i, a, b) for(int i = a; i <= (b); ++i)
#define frep(i, a, b) for(int i = a; i < (b); ++i)
#define drep(i, a, b) for(int i = a; i >= (b); --i)
// #define ls (p << 1)
// #define rs (p << 1 | 1)
// #define mid ((l + r) >> 1)
const int MAXN = 200010;
const int MOD = 998244353;
// const int INF = 0x3f3f3f3f;
const int INF = 1e15;
int get(int x, int k){
    return (x >> k) & 1;
}
void solve(){
    int l, r;
    cin >> l >> r;
    int ans = 0;
    int i = 30;
    while(i >= 0){
        if(get(l, i) != get(r, i)) break;
        --i;
    }
    r = (r >> i) << i;
    l = l + (1 << i) - 1;
    cout << r << " " << r << " " << l << endl;
    return;
}
signed main(){
    cout << (965321865 ^ 375544086) + (965321865 ^ 12551794) + (375544086 ^ 12551794) << endl;
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int _t = 1;
    cin >> _t;
    while(_t--){
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
//                              بسم الله الرحمان الرحيم

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define openFiles freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define openFiles2 freopen("teamwork.in", "r", stdin); freopen("teamwork.out", "w", stdout);
#define ll long long
#define endl "\n"
#define uint unsigned int
#define bigint  unsigned long long int
ll maxll=9223372036854775807;
ll mod=1e9+7.;
#define pb push_back
#define rep(i, st, endex) for (ll i = st; i < (ll)endex; ++i)
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define vb vector<bool>
#define vii vector<pair<int, int>>
#define vvii vector<vector<pair<int, int>>>
#define viii vector<tuple<int, int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define tiii tuple<int, int, int>
#define tll tuple<ll, ll, ll>
#define LSOne(S) ((S) & -(S))
#define fi first

///////////////////////////////code/////////////////////////////////////////////////////
const long long MOD = 1e9 + 7; // chose any MOD
long long binpow(long long a, long long b) {
    a %= MOD;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}

int main() {
    IOS
    int t;
    cin >> t;
    while (t--) {
       int n;
        cin >> n;
        vector<int> v(n);
        for (int i = 0; i < n; i++)
            cin >> v[i];
        int x=v[1]-v[0];
        int i=2;
        while (v[i]>=x and i<n and x>0) {
            x=v[i]-x;
            i++;
        }
        if (i==n) cout << "YES" << endl;
        else cout << "NO" << endl;


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

Previous submission (verdict: Time limit exceeded on test 16):
#include <bits/stdc++.h>

using namespace std;

 

typedef long long ll;

#define vi vector <int> 

#define vll vector <ll> 

#define vp vector<pair<ll,ll>>

#define all(a) (a).begin(),(a).end()

#define rep(i,a) for(int i=0;i<a;i++)

#define fa(v) for (auto &it : (v))

#define ff first

#define ss second

#define pb push_back

#define pl pair<ll ,ll> 

 

    int rec(  vector<vector<int>> &dp,  string a,string b , string c, int i, int j){

        if(i+j>=c.size())return 0 ;



        // dp[i][j] == minimun changes req after index i , j ...

        

        if( dp[i][j]!=-1)return dp[i][j] ;



            

            int x = 1e7, y = 1e7, z= 1e7, w = 1e7 ;

                

            if(i<a.size()){

               

                if(c[i+j]==a[i]) z= rec(dp,a,b,c,i+1,j) ;

                else{ x=rec(dp,a,b,c,i+1,j)+1;}

                z=min(x,z);

            }



            if(j<b.size()){

                if(c[i+j]==b[j])w = rec( dp, a,b,c ,i, j+1) ;

                else{y=rec(dp,a,b,c,i,j+1)+1;}

                w= min(y,w);

            }

//cout<<x<<z<<y<<x<<endl;

            return dp[i][j]= min(z,w) ;

    



        return 0 ;

    }



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

int t; cin>>t;

while (t--){ 



    string a,b,c; cin>>a>>b>>c;

    int n =a.size(), m = b.size() ;

    vector<vector<int>> dp(n+1, vector<int>(m+1,-1)) ;



    cout<<rec(dp, a,b,c,0,0)<<endl ;





} 

}

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

using namespace std;

 

typedef long long ll;

#define vi vector <int> 

#define vll vector <ll> 

#define vp vector<pair<ll,ll>>

#define all(a) (a).begin(),(a).end()

#define rep(i,a) for(int i=0;i<a;i++)

#define fa(v) for (auto &it : (v))

#define ff first

#define ss second

#define pb push_back

#define pl pair<ll ,ll> 

 



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

int t; cin>>t;

while (t--){ 



    string a,b,c; cin>>a>>b>>c;

    int n =a.size(), m = b.size() ;

    vector<vector<int>> dp(n+1, vector<int>(m+1,0)) ;



    dp[n][m]=0;



    for(int i=n-1;i>=0;i--){

        if(a[i]==c[m+i])dp[i][m]=dp[i+1][m];

        else {

            dp[i][m]=dp[i+1][m]+1;

        }

    }



    for(int i=m-1;i>=0;i--){

        if(b[i]==c[n+i])dp[n][i]=dp[n][i+1];

        else{

            dp[n][i]= dp[n][i+1]+1;

        }

    }



    for(int i=n-1;i>=0;i--){

        for(int j=m-1;j>=0;j--){



            int x= 1e5,y = 1e5;

            

            if(a[i]==c[i+j])x=dp[i+1][j];

            else{x= dp[i+1][j]+1 ;}



            if(b[j]==c[i+j])y=dp[i][j+1];

            else {y= dp[i][j+1]+1;}



            dp[i][j] = min(x,y) ;



        }

    }



    cout<< dp[0][0] <<endl ;



} 

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


Submission (verdict: Time limit exceeded on test 16):
#include <bits/stdc++.h>

using namespace std;

 

typedef long long ll;

#define vi vector <int> 

#define vll vector <ll> 

#define vp vector<pair<ll,ll>>

#define all(a) (a).begin(),(a).end()

#define rep(i,a) for(int i=0;i<a;i++)

#define fa(v) for (auto &it : (v))

#define ff first

#define ss second

#define pb push_back

#define pl pair<ll ,ll> 

 

    int rec(  vector<vector<int>> &dp,  string a,string b , string c, int i, int j){

        if(i+j>=c.size())return 0 ;



        // dp[i][j] == minimun changes req after index i , j ...

        

        if( dp[i][j]!=-1)return dp[i][j] ;



            

            int x = 1e7, y = 1e7, z= 1e7, w = 1e7 ;

                

            if(i<a.size()){

                x=rec(dp,a,b,c,i+1,j)+1;

                if(c[i+j]==a[i]) z= rec(dp,a,b,c,i+1,j) ;

                z=min(x,z);

            }



            if(j<b.size()){y=rec(dp,a,b,c,i,j+1)+1;

                if(c[i+j]==b[j])w = rec( dp, a,b,c ,i, j+1) ;

                w= min(y,w);

            }

//cout<<x<<z<<y<<x<<endl;

            return dp[i][j]= min(z,w) ;

    



        return 0 ;

    }



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

int t; cin>>t;

while (t--){ 



    string a,b,c; cin>>a>>b>>c;

    int n =a.size(), m = b.size() ;

    vector<vector<int>> dp(n+1, vector<int>(m+1,-1)) ;



    cout<<rec(dp, a,b,c,0,0)<<endl ;





} 

}