ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

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

using namespace std;
const int NMAX = 2e5 + 5;

int a[NMAX], b[NMAX];

map <int, int> fr;

priority_queue <int> pq;

int main()
{

    cin.tie(0);
    ios_base :: sync_with_stdio(false);

    int tt;
    cin >> tt;

    while(tt --)
    {
        int n, m;

        cin >> n >> m;

        fr.clear();
        while(!pq.empty()) pq.pop();

        int s1 = 0, s2 = 0;

        for(int i = 1; i <= n; i ++) {cin >> a[i]; s1 += a[i];}
        for(int i = 1; i <= m; i ++) {cin >> b[i]; s2 += b[i];}

        for(int i = 1; i <= n; i ++) fr[a[i]] ++;

        for(int i = 1; i <= m; i ++) pq.push(b[i]);

        if(s1 != s2)
        {
            cout << "NO" << '\n';
            continue;
        }


        while(!pq.empty())
        {
            int val = pq.top();
            pq.pop();

            if(fr.find(val) == fr.end() || fr[val] == 0)
            {
                if(val == 1) break;
                int val1 = ceil(val / 2.00);
                int val2 = floor(val / 2.00);

                pq.push(val1), pq.push(val2);
            }
            else
            {
                fr[val] --;
            }
        }

        bool ok = true;
        if(pq.size()) ok = false;

        for(auto it : fr)
        {
            if(it.second)
            {
                ok = false;
            }
        }

        cout << (ok ? "YES" : "NO") << '\n';
    }

    return 0;
}


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

using namespace std;
const int NMAX = 2e5 + 5;

int a[NMAX], b[NMAX];

map <int, int> fr;

priority_queue <int> pq;

int main()
{

    cin.tie(0);
    ios_base :: sync_with_stdio(false);

    int tt;
    cin >> tt;

    while(tt --)
    {
        int n, m;

        cin >> n >> m;

        fr.clear();
        while(!pq.empty()) pq.pop();

        int s1 = 0, s2 = 0;

        for(int i = 1; i <= n; i ++) {cin >> a[i]; s1 += a[i];}
        for(int i = 1; i <= m; i ++) {cin >> b[i]; s2 += b[i];}

        for(int i = 1; i <= n; i ++) fr[a[i]] ++;

        for(int i = 1; i <= m; i ++) pq.push(b[i]);

        if(s1 != s2)
        {
            cout << "NO" << '\n';
            continue;
        }

        sort(a + 1, a + n + 1);

        int ind = n;


        while(!pq.empty())
        {
            int val = pq.top();
            pq.pop();

            if(fr.find(val) == fr.end() || fr[val] == 0)
            {
                if(val == 1 || a[ind] > val) break;
                int val1 = ceil(val / 2.00);
                int val2 = floor(val / 2.00);

                pq.push(val1), pq.push(val2);
            }
            else
            {
                fr[val] --;
                ind --;
            }
        }

        bool ok = true;
        if(pq.size()) ok = false;

        for(auto it : fr)
        {
            if(it.second)
            {
                ok = false;
            }
        }

        cout << (ok ? "YES" : "NO") << '\n';
    }

    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef pair<int,int> pi;
const int mod=998244353;
#define int long long
const int M = 4e5 + 10;
int  power(int a, int b){
    if (b==0) return 1;
    int t =power(a,b/2);
    return (b%2?t*t%mod*a%mod:t*t%mod);
 }
 bool f(int x,map<int,int>&mp){
    if(mp[x]>0){
        mp[x]--;
        return true;
    }
    if(x==0){return false;}
    int flag=f(x/2,mp)&&f((x+1)/2,mp);
    return flag;
 }
 void solve(){ 
   int n,m;
   cin>>n>>m;
   vector<int>a(n),b(m);
   map<int,int>mp;
   for(int i=0;i<n;i++){cin>>a[i];mp[a[i]]++;}
   for(int i=0;i<m;i++){
    cin>>b[i];
   }
   sort(a.begin(),a.end());
   sort(b.begin(),b.end());
   for(int i=0;i<m;i++){
     if(!f(b[i],mp)){cout<<"NO"<<endl;return;}
   }
   for(int i=0;i<n;i++){
     if(mp[a[i]]){cout<<"NO"<<endl;return;}
   }
   cout<<"YES"<<endl;
 }
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T=1;
    cin >> T;
    while (T--) {
        solve();
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
bool cmp(pii a, pii b) {
	return a.second <b.second;
}
void maho(){
	int n, k,ans=0;
	cin >> n >> k;
	vector<pair<int,int>>a;
	map<int, int>mp;
	for (int i = 0; i < n; i++) {
		int ai; cin >> ai;
		mp[ai]++;
		if (mp[ai]==1) {
			a.push_back({ ai,0 });
		}
	}
	for (int i = 0; i < a.size(); i++) a[i].second = mp[a[i].first];
	sort(a.begin(), a.end(), cmp);
	ans = a.size();
	for (auto& x : a) {
		if (k <=x.second)break;
		k -= x.second;
		ans -= 1;
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int _; cin >> _;
	while (_--) {
		maho();
	}
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
bool cmp(pii a, pii b) {
	return a.second <b.second;
}
void maho(){
	int n, k,ans=0;
	cin >> n >> k;
	vector<pair<int,int>>a;
	map<int, int>mp;
	for (int i = 0; i < n; i++) {
		int ai; cin >> ai;
		mp[ai]++;
		if (mp[ai]==1) {
			a.push_back({ ai,0 });
		}
	}
	for (int i = 0; i < a.size(); i++) a[i].second = mp[a[i].first];
	sort(a.begin(), a.end(), cmp);
	ans = a.size();
	for (auto& x : a) {
		if (k <=x.second)break;
		k -= x.second;
		ans -= 1;
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int _; cin >> _;
	while (_--) {
		maho();
	}
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
bool cmp(pii a, pii b) {
	return a.second <b.second;
}
void maho(){
	int n, k,ans=0;
	cin >> n >> k;
	vector<pair<int,int>>a;
	map<int, int>mp;
	for (int i = 0; i < n; i++) {
		int ai; cin >> ai;
		mp[ai]++;
		if (mp[ai]==1) {
			a.push_back({ ai,0 });
		}
	}
	for (int i = 0; i < a.size(); i++) a[i].second = mp[a[i].first];
	sort(a.begin(), a.end(), cmp);
	ans = a.size();
	for (auto& x : a) {
		if (k <= 0)break;
		if (k >= x.second) ans--;
		k -= x.second;
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int _; cin >> _;
	while (_--) {
		maho();
	}
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
bool cmp(pii a, pii b) {
	return a.second <b.second;
}
void maho(){
	int n, k,ans=0;
	cin >> n >> k;
	vector<pair<int,int>>a;
	map<int, int>mp;
	for (int i = 0; i < n; i++) {
		int ai; cin >> ai;
		mp[ai]++;
		if (mp[ai]==1) {
			a.push_back({ ai,0 });
		}
	}
	for (int i = 0; i < a.size(); i++) a[i].second = mp[a[i].first];
	sort(a.begin(), a.end(), cmp);
	ans = a.size();
	for (auto& x : a) {
		if (k <= 0)break;
		if (k >= x.second) ans--;
		k -= x.second;
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int _; cin >> _;
	while (_--) {
		maho();
	}
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
bool cmp(pii a, pii b) {
	return a.second <b.second;
}
void maho(){
	int n, k,ans=0;
	cin >> n >> k;
	vector<pair<int,int>>a;
	map<int, int>mp;
	for (int i = 0; i < n; i++) {
		int ai; cin >> ai;
		mp[ai]++;
		if (mp[ai]==1) {
			a.push_back({ ai,0 });
		}
	}
	for (int i = 0; i < a.size(); i++) a[i].second = mp[a[i].first];
	sort(a.begin(), a.end(), cmp);
	ans = a.size();
	for (auto& x : a) {
		if (k <= 0)break;
		if (k >= x.second) ans--;
		k -= x.second;
	}
	cout << (ans<=0?1:ans) << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int _; cin >> _;
	while (_--) {
		maho();
	}
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 2):
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// #define ordered_multiset tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update>
#define lcm(a,b) (a*b)/__gcd(a,b)
#define nl "\n"
#define spc " "

typedef long long ll;

const int N = 2e5+5;
const int mod = 1000000007;

// code starts here

int find_max(vector<int>&V,int length)
{
    int ans=0,index=1;
    for(int i=1;i<=length;i++)
    {
        if(V[i]>ans)
        {
            ans=V[i];
            index=i;
        }
    }
    return index;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    //t=1;
    while(t--)
    {
       int n;
       cin>>n;
       vector<int>g[n+1];
       vector<int>degree(n+1,0);
       int ans=1;
       for(int i=1;i<n;i++)
       {
           int u,v;
           cin>>u>>v;
           g[u].push_back(v);
           g[v].push_back(u);
           degree[u]++;
           degree[v]++;
       }
       int node=find_max(degree,n+1);
       ans=ans+degree[node]-1;
       degree[node]=0;
       for(auto it : g[node])
       {
           degree[it]--;
       }
       node=find_max(degree,n+1);
       ans=ans+degree[node]-1;
       if(ans<0)
       ans=0;
       cout<<ans<<nl;


    }

}


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// #define ordered_multiset tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update>
#define lcm(a,b) (a*b)/__gcd(a,b)
#define nl "\n"
#define spc " "

typedef long long ll;

const int N = 2e5+5;
const int mod = 1000000007;

// code starts here

int find_max(vector<int>&V,int length)
{
    int ans=0,index=1;
    for(int i=1;i<length;i++)
    {
        if(V[i]>ans)
        {
            ans=V[i];
            index=i;
        }
    }
    return index;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    //t=1;
    while(t--)
    {
       int n;
       cin>>n;
       vector<int>g[n+1];
       vector<int>degree(n+1,0);
       int ans=1;
       for(int i=1;i<n;i++)
       {
           int u,v;
           cin>>u>>v;
           g[u].push_back(v);
           g[v].push_back(u);
           degree[u]++;
           degree[v]++;
       }
       int node=find_max(degree,n+1);
       ans=ans+degree[node]-1;
       degree[node]=0;
       for(auto it : g[node])
       {
           degree[it]--;
       }
       node=find_max(degree,n+1);
       ans=ans+degree[node]-1;
       if(ans<0)
       ans=0;
       cout<<ans<<nl;


    }

}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Runtime error on test 2):
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// #define ordered_multiset tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update>
#define lcm(a,b) (a*b)/__gcd(a,b)
#define nl "\n"
#define spc " "

typedef long long ll;

const int N = 2e5+5;
const int mod = 1000000007;

// code starts here

int find_max(vector<int>&V,int length)
{
    int ans=0,index=1;
    for(int i=1;i<=length;i++)
    {
        if(V[i]>ans)
        {
            ans=V[i];
            index=i;
        }
    }
    return index;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    //t=1;
    while(t--)
    {
       int n;
       cin>>n;
       vector<int>g[n+1];
       vector<int>degree(n+1,0);
       int ans=1;
       for(int i=1;i<n;i++)
       {
           int u,v;
           cin>>u>>v;
           g[u].push_back(v);
           g[v].push_back(u);
           degree[u]++;
           degree[v]++;
       }
       int node=find_max(degree,n+1);
       ans=ans+degree[node]-1;
       degree[node]=0;
       for(auto it : g[node])
       {
           degree[it]--;
       }
       node=find_max(degree,n+1);
       ans=ans+degree[node]-1;
       if(ans<0)
       ans=0;
       cout<<ans<<nl;


    }

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)


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

using namespace std;



#pragma GCC optimize ("unroll-loops")

#pragma GCC optimize ("O2")

using ll = long long;

const ll MAXN =2e3 + 5;

const ll INF = 2e18;

const ll MOD = 1e9 + 7;

const ll LOG = 30;

#define fi first

#define se second

#define pll pair <ll, ll>

#define vll vector <ll>

#define endl '\n'

#define debug(x) cout << #x << ": " << (x) << endl;



ll n, m, k;

ll a [MAXN];



void solve(){

    cin >> n >> m >> k;

    if(m > k) swap(m, k);

    a[m] = 0;

    a[k] = 1;

    for(ll i = m+1; i < k; i++) a[i] = !a[i-1];

    for(ll i = m-1; i >= 1; i--) a[i] = !a[i+1];

    if(n > k){

        a[n] = !a[1];

        for(ll i = n-1; i > k; i--) a[i] = !a[i+1];

    }

    for(ll i = 1; i <= n; i++) cout << a[i] << " ";

    cout << endl;

}



int main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll t; cin >> t;

    while(t--){

        solve();

    }

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

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

using namespace std;



#pragma GCC optimize ("unroll-loops")

#pragma GCC optimize ("O2")

using ll = long long;

const ll MAXN =2e5 + 5;

const ll INF = 2e18;

const ll MOD = 1e9 + 7;

const ll LOG = 30;

#define fi first

#define se second

#define pll pair <ll, ll>

#define vll vector <ll>

#define endl '\n'

#define debug(x) cout << #x << ": " << (x) << endl;



ll n, m, k;

ll a [MAXN];



void solve(){

    cin >> n >> m >> k;

    if(m > k) swap(m, k);

    a[m] = 0;

    a[k] = 1;

    for(ll i = m+1; i < k; i++) a[i] = !a[i-1];

    if(a[k-1] == 1) a[k-1] = 2;

    for(ll i = m-1; i >= 1; i--) a[i] = !a[i+1];

    if(n > k){

        a[n] = !a[1];

        for(ll i = n-1; i > k; i--) a[i] = !a[i+1];

        if(a[k+1] == 1) a[k+1] = 2;

    }

    for(ll i = 1; i <= n; i++) cout << a[i] << " ";

    cout << endl;

}



int main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll t; cin >> t;

    while(t--){

        solve();

    }

}

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

using namespace std;



#pragma GCC optimize ("unroll-loops")

#pragma GCC optimize ("O2")

using ll = long long;

const ll MAXN =2e5 + 5;

const ll INF = 2e18;

const ll MOD = 1e9 + 7;

const ll LOG = 30;

#define fi first

#define se second

#define pll pair <ll, ll>

#define vll vector <ll>

#define endl '\n'

#define debug(x) cout << #x << ": " << (x) << endl;



ll n, m, k;

ll a [MAXN];



void solve(){

    cin >> n >> m >> k;

    if(m > k) swap(m, k);

    a[m] = 0;

    a[k] = 1;

    for(ll i = m+1; i < k; i++) a[i] = !a[i-1];

    if(a[k-1] == 1) a[k-1] = 2;

    for(ll i = m-1; i >= 1; i--) a[i] = !a[i+1];

    for(ll i = n; i > k; i--){

        ll pre = i+1;

        if(pre == n+1) pre = 1;

        a[i] = !a[pre];

    }

    ll pre = k+1;

    if(pre == n+1) pre = 1;

    if(a[pre] == 1) a[pre] = 2;

    for(ll i = 1; i <= n; i++) cout << a[i] << " ";

    cout << endl;

}



int main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll t; cin >> t;

    while(t--){

        solve();

    }

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

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

using namespace std;



#pragma GCC optimize ("unroll-loops")

#pragma GCC optimize ("O2")

using ll = long long;

const ll MAXN =2e3 + 5;

const ll INF = 2e18;

const ll MOD = 1e9 + 7;

const ll LOG = 30;

#define fi first

#define se second

#define pll pair <ll, ll>

#define vll vector <ll>

#define endl '\n'

#define debug(x) cout << #x << ": " << (x) << endl;



ll n, m, k;

ll a [MAXN];



void solve(){

    cin >> n >> m >> k;

    if(m > k) swap(m, k);

    a[m] = 0;

    a[k] = 1;

    for(ll i = m+1; i < k; i++) a[i] = !a[i-1];

    for(ll i = m-1; i >= 1; i--) a[i] = !a[i+1];

    if(n > k){

        a[n] = !a[1];

        for(ll i = n-1; i > k; i--) a[i] = !a[i+1];

    }

    for(ll i = 1; i <= n; i++) cout << a[i] << " ";

    cout << endl;

}



int main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll t; cin >> t;

    while(t--){

        solve();

    }

}

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

using namespace std;



#pragma GCC optimize ("unroll-loops")

#pragma GCC optimize ("O2")

using ll = long long;

const ll MAXN =2e5 + 5;

const ll INF = 2e18;

const ll MOD = 1e9 + 7;

const ll LOG = 30;

#define fi first

#define se second

#define pll pair <ll, ll>

#define vll vector <ll>

#define endl '\n'

#define debug(x) cout << #x << ": " << (x) << endl;



ll n, m, k;

ll a [MAXN];



void solve(){

    cin >> n >> m >> k;

    if(m > k) swap(m, k);

    a[m] = 0;

    a[k] = 1;

    for(ll i = m+1; i < k; i++) a[i] = !a[i-1];

    if(a[k-1] == 1) a[k-1] = 2;

    for(ll i = m-1; i >= 1; i--) a[i] = !a[i+1];

    if(n > k){

        a[n] = !a[1];

        for(ll i = n-1; i > k; i--) a[i] = !a[i+1];

        if(a[k+1] == 1) a[k+1] = 2;

    }

    for(ll i = 1; i <= n; i++) cout << a[i] << " ";

    cout << endl;

}



int main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll t; cin >> t;

    while(t--){

        solve();

    }

}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#include <unordered_map>
#define pb push_back
#include<string>
#include<cmath>
#define ll long long
#define lli long long int
#define REP(i,n) for(ll i=1;i<=n;i++)
#include<cctype>
#include <sstream>
#define endl "\n"
#define pairs pair<int,int>
#define ld long double
#define mod 1000000009
#define Mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
# pragma GCC optimize ("Ofast")
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update>
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
ll ceil_div(ll a, ll b) {return a % b == 0 ? a / b : a / b + 1;}
ll pows(ll a,ll n,ll m)
{
	a=a%m;
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll gcd(ll a,ll b)
{
	
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1||n==0)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
		return false;
			}	
	}
	return true;
}
//D'N    G    UP
const int N = 1006;
string s,t,p;
ll n,m;
ll dp[N][N];
ll getans(ll i,ll j){
	if(i >= n && j >= m){
		return 0;
	}
	if(dp[i][j] != -1){
		return dp[i][j];
	}
	ll ans = 1e8;
	if(p[i+j] == s[i]){
		ans =  min(ans,getans(i+1,j));
	}
	if(p[i+j] == t[j]){
     	ans =  min(ans,getans(i,j+1));	
	}
	
	if(p[i+j] != s[i] && p[i+j] != t[j]){
		ans =  min(ans,getans(i+1,j)+1);
		ans =  min(ans,getans(i,j+1)+1);	
	}
	return dp[i][j]=ans;
}
int main()
{ 
  auto begin = std::chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tl;
  cin>>tl;
  while(tl--){
  cin>>s>>t>>p;
  n = s.size();
  m = t.size();
  for(ll i=0;i<=n;i++){
  	for(ll j=0;j<=m;j++){
  		dp[i][j] = -1;
	}
  }
  ll ans = getans(0,0);
  cout<<ans<<endl;
}
  auto end = std::chrono::high_resolution_clock::now();
  auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
  cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 

}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#include <unordered_map>
#define pb push_back
#include<string>
#include<cmath>
#define ll long long
#define lli long long int
#define REP(i,n) for(ll i=1;i<=n;i++)
#include<cctype>
#include <sstream>
#define endl "\n"
#define pairs pair<int,int>
#define ld long double
#define mod 1000000009
#define Mod 998244353
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
# pragma GCC optimize ("Ofast")
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update>
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
ll ceil_div(ll a, ll b) {return a % b == 0 ? a / b : a / b + 1;}
ll pows(ll a,ll n,ll m)
{
	a=a%m;
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll gcd(ll a,ll b)
{
	
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1||n==0)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
		return false;
			}	
	}
	return true;
}
//D'N    G    UP
const int N = 300006;
ll n,m;
ll a[N];
ll b[N];
int main()
{ 
  auto begin = std::chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin>>t;
//  t = 1;
  while(t--){
  	cin>>n>>m;
  	map<ll,ll>mp;
  	for(ll i=0;i<n;i++){
  		cin>>a[i];
  		mp[a[i]]++;
	  }
  	for(ll i=0;i<m;i++){
  		cin>>b[i];
	  }
	  
	  sort(b,b+m);
	  reverse(b,b+m);
	  ll flag = 1;
	  ll w = 0;
	  for(ll i=0;i<m;i++){
	  	if(flag == 0){
	  		break;
		  }
	  	  multiset<ll>val;
	  	  val.insert(b[i]);
	  	  	if(w >= n+5){
	  	  		flag = 0;
	  	  		break;
			}
	  	  while(!val.empty()){
	  	  	if(w >= n+5){
	  	  		flag = 0;
	  	  		break;
				}
	  	  	ll v = *val.rbegin();
	  	  	if(mp.find(v) != mp.end() && mp[v] > 0 ){
	  	  		mp[v]--;
				val.erase(val.find(v));
				continue;
			}
			if(v == 1){
			   flag = 0;
			   break;
			}
			val.erase(val.find(v));
			if(v %2 != 0){
				val.insert(v/2);
				val.insert((v/2)+1);
			} else{
				val.insert(v/2);
				val.insert(v/2);				
			}	
			w = w+2;
	  }
  }
  for(pair<ll,ll>x:mp){
  	if(x.second > 0){
  		flag = 0;
	  }
  }
  if(flag == 0){
  	cout<<"No"<<endl;
  }else{
  	cout<<"Yes"<<endl;
  }
}
  auto end = std::chrono::high_resolution_clock::now();
  auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
  cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 

}