ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define all(s) s.begin(),s.end()
typedef long long ll;
const double pi = acos(-1),ef=1e-9;
const ll N=5e5+5,M=1e9+7,H=131,inf=1e9;

string a,b,c;
ll mm[1002][1002];
ll rec(ll i,ll j)
{
	if(i+j>=c.size()){
		return 0;
	}

	ll &ans=mm[i][j];
	if(ans!=-1)return ans;

	if(i<a.size() && c[i+j]==a[i]){
		ans=rec(i+1,j);
	}
	else ans=1+rec(i+1,j);


	if(j<b.size() && c[i+j]==b[j]){
		ans=min(ans,rec(i,j+1));
	}
	else ans=min(ans,1+rec(i,j+1));

	return ans;

}

void solve()
{
	cin>>a>>b>>c;
	for(ll i=0;i<=a.size();i++){
		for(ll j=0;j<=b.size();j++){
			mm[i][j]=-1;
		}
	}
	cout<<rec(0,0)<<"\n";

}




int main()
{
    fast;
    ll t=1,tc=1;
    cin>>tc;
    while(tc--)
    {
       // cout<<"Case "<<t++<<":\n";
        solve();//cout<<"\n";
        // cout.flush();
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define all(s) s.begin(),s.end()
typedef long long ll;
const double pi = acos(-1),ef=1e-9;
const ll N=5e5+5,M=1e9+7,H=131,inf=1e9;

string a,b,c;
ll mm[1002][1002];
ll rec(ll i,ll j)
{
	if(i>=a.size() && j>=b.size())return 0;
	ll &ans=mm[i][j];
	if(ans!=-1)return ans;
	ans=inf;

	if(i<a.size()){
		if(c[i+j]==a[i])ans=min(ans,rec(i+1,j));
		else ans=min(ans,1+rec(i+1,j));
	}

	if(j<b.size()){
		if(c[i+j]==b[j])ans=min(ans,rec(i,j+1));
		else ans=min(ans,1+rec(i,j+1));
	}

	return ans;

}

void solve()
{
	cin>>a>>b>>c;
	for(ll i=0;i<=a.size();i++){
		for(ll j=0;j<=b.size();j++){
			mm[i][j]=-1;
		}
	}
	cout<<rec(0,0)<<"\n";

}




int main()
{
    fast;
    ll t=1,tc=1;
    cin>>tc;
    while(tc--)
    {
       // cout<<"Case "<<t++<<":\n";
        solve();//cout<<"\n";
        // cout.flush();
    }
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define all(s) s.begin(),s.end()
typedef long long ll;
const double pi = acos(-1),ef=1e-9;
const ll N=5e5+5,M=1e9+7,H=131,inf=1e9;

string a,b,c;
ll mm[2002][2002];
ll rec(ll i,ll sa)
{
	if(i>=a.size()+b.size())return 0;

	auto ans=mm[i][sa];
	if(ans!=-1)return ans;

	ll sb=(i-sa);

	ans=1+min(rec(i+1,sa),rec(i+1,sa+1));

	if(sa<a.size()){
		if(c[i]==a[sa]){
			ans=min(ans,rec(i+1,sa+1));
		}
	}
	if(sb<b.size()){
		if(b[sb]==c[i]){
			ans=min(ans,rec(i+1,sa));
		}
	}
	return ans;



}

void solve()
{
	cin>>a>>b>>c;
	for(ll i=0;i<=c.size();i++){
		for(ll j=0;j<=a.size();j++){
			mm[i][j]=-1;
		}
	}
	cout<<rec(0,0)<<"\n";

}




int main()
{
    fast;
    ll t=1,tc=1;
    cin>>tc;
    while(tc--)
    {
       // cout<<"Case "<<t++<<":\n";
        solve();//cout<<"\n";
        // cout.flush();
    }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define all(s) s.begin(),s.end()
typedef long long ll;
const double pi = acos(-1),ef=1e-9;
const ll N=5e5+5,M=1e9+7,H=131,inf=1e9;

string a,b,c;
ll mm[2002][2002];
ll rec(ll i,ll sa)
{
	ll sb=(i-sa);
	if(i>=a.size()+b.size()){
		if(sa>=a.size() && sb>=b.size())return 0;
		return inf;
	}
	auto ans=mm[i][sa];
	if(ans!=-1)return ans;
	ans=1+min(rec(i+1,sa),rec(i+1,sa+1));
	if(sa<a.size()){
		if(c[i]==a[sa]){
			ans=min(ans,rec(i+1,sa+1));
		}
	}
	
	if(sb<b.size()){
		if(b[sb]==c[i]){
			ans=min(ans,rec(i+1,sa));
		}
	}
	return ans;



}

void solve()
{
	cin>>a>>b>>c;
	for(ll i=0;i<=c.size();i++){
		for(ll j=0;j<=a.size();j++){
			mm[i][j]=-1;
		}
	}
	cout<<rec(0,0)<<"\n";

}




int main()
{
    fast;
    ll t=1,tc=1;
    cin>>tc;
    while(tc--)
    {
       // cout<<"Case "<<t++<<":\n";
        solve();//cout<<"\n";
        // cout.flush();
    }
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define all(s) s.begin(),s.end()
typedef long long ll;
const double pi = acos(-1),ef=1e-9;
const ll N=5e5+5,M=1e9+7,H=131,inf=1e9;

string a,b,c;
ll mm[2002][2002];
ll rec(ll i,ll sa)
{
	if(i>=a.size()+b.size())return 0;

	auto ans=mm[i][sa];
	if(ans!=-1)return ans;

	ll sb=(i-sa);

	ans=1+min(rec(i+1,sa),rec(i+1,sa+1));

	if(sa<a.size()){
		if(c[i]==a[sa]){
			ans=min(ans,rec(i+1,sa+1));
		}
	}
	if(sb<b.size()){
		if(b[sb]==c[i]){
			ans=min(ans,rec(i+1,sa));
		}
	}
	return ans;



}

void solve()
{
	cin>>a>>b>>c;
	for(ll i=0;i<=c.size();i++){
		for(ll j=0;j<=a.size();j++){
			mm[i][j]=-1;
		}
	}
	cout<<rec(0,0)<<"\n";

}




int main()
{
    fast;
    ll t=1,tc=1;
    cin>>tc;
    while(tc--)
    {
       // cout<<"Case "<<t++<<":\n";
        solve();//cout<<"\n";
        // cout.flush();
    }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n;
        cin >> n;
        int two = 0;
        int three = 0;
        long long sum = 0;
        long long a = n;
        while (n > 0)
        {
            if ((n % 10) == 2)
                two++;
            if ((n % 10) == 3)
                three++;
            sum += (n % 10);
            n /= 10;
        }
        n = a;
        if (sum % 9 == 0)
        {
            cout << "YES" << endl;
        }
        else
        {
            bool f = false;
            long long val = sum;
            for (int i = 1; i <= three; i++)
            {   
                sum += a;
                if (sum % 9 == 0)
                {
                    f = true;
                    break;
                }
            }
            sum = val;
            if (!f)
            {
                for (int i = 1; i <= two; i++)
                {
                    sum += 2; 
                    if (sum % 9 == 0)
                    {
                        f = true;
                        break;
                    }
                }
            }
            sum = val;
            if (!f)
            {
                for (int i = 1; i <= two; i++)
                {   
                    sum+=2;
                    long long temp=sum;
                    for (int j = 1; j <= three; j++)
                    {
                        sum+=6;
                        if(sum%9==0){
                            f=true;
                            break;
                        }
                    }
                    sum=temp;
                }
            }
            if(f)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        string n;
        cin >> n;
        int two = 0;
        int three = 0;
        long long sum = 0;
        for(int i=0;i<n.length();i++){
            if(n[i]=='2')two++;
            if(n[i]=='3')three++;
            sum+=(n[i]-'0');
            // for optimation 
            sum=sum%9;
        }
        if (sum % 9 == 0)
        {
            cout << "YES" << endl;
        }
        else
        {  
            bool f=false;
            long long val = sum;
            sum = val;
                for (int i = 0; i <= two; i++)
                {   
                    for (int j = 0; j <= three; j++)
                    {
                        long long temp=sum;
                        temp+=(2*i)+(6*j);
                        if(temp%9==0){
                            f=true;
                            break;
                        }
                    }
                }
            if(f)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        string n;
        cin >> n;
        int two = 0;
        int three = 0;
        long long sum = 0;
        for (int i = 0; i < n.length(); i++)
        {
            if (n[i] == '2')
                two++;
            else if (n[i] == '3')
                three++;

            sum += (n[i] - '0');
            // for optimation
            sum = sum % 9;
        }
        if (sum % 9 == 0)
        {
            cout << "YES" << endl;
        }
        else
        {
            bool f = false;
            for (int i = 0; i <= three; i++)
            {
                for (int j = 0; j <= two; j++)
                {
                    long long temp = sum;
                    temp += (6 * i) + (2 * j);
                    if (temp % 9 == 0)
                    {
                        f = true;
                        break;
                    }
                }
            }
            if (f)
                cout << "YES" << endl;
            else
                cout << "NO" << endl;
        }
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n;
        cin >> n;
        int two = 0;
        int three = 0;
        long long sum = 0;
        long long a = n;
        while (n > 0)
        {
            if ((n % 10) == 2)
                two++;
            if ((n % 10) == 3)
                three++;
            sum += (n % 10);
            n /= 10;
        }
        n = a;
        if (sum % 9 == 0)
        {
            cout << "YES" << endl;
        }
        else
        {
            bool f = false;
            long long val = sum;
            for (int i = 1; i <= three; i++)
            {   
                sum += 6;
                if (sum % 9 == 0)
                {
                    f = true;
                    break;
                }
            }
            sum = val;
            if (!f)
            {
                for (int i = 1; i <= two; i++)
                {
                    sum += 2; 
                    if (sum % 9 == 0)
                    {
                        f = true;
                        break;
                    }
                }
            }
            sum = val;
            if (!f)
            {
                for (int i = 1; i <= two; i++)
                {   
                    sum+=2;
                    long long temp=sum;
                    for (int j = 1; j <= three; j++)
                    {
                        sum+=6;
                        if(sum%9==0){
                            f=true;
                            break;
                        }
                    }
                    sum=temp;
                }
            }
            if(f)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n;
        cin >> n;
        int two = 0;
        int three = 0;
        long long sum = 0;
        while (n > 0)
        {
            if ((n % 10) == 2)
                two++;
            if ((n % 10) == 3)
                three++;
            sum += (n % 10);
            n /= 10;
        }
        if (sum % 9 == 0)
        {
            cout << "YES" << endl;
        }
        else
        {  
            bool f=false;
            long long val = sum;
            sum = val;
                for (int i = 0; i <= two; i++)
                {   
                    for (int j = 0; j <= three; j++)
                    {
                        long long temp=sum;
                        temp+=(2*i)+(6*j);
                        if(temp%9==0){
                            f=true;
                            break;
                        }
                    }
                }
            if(f)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n;
        cin >> n;
        int two = 0;
        int three = 0;
        long long sum = 0;
        while (n > 0)
        {
            if ((n % 10) == 2)
                two++;
            if ((n % 10) == 3)
                three++;
            sum += (n % 10);
            n /= 10;
        }
        if (sum % 9 == 0)
        {
            cout << "YES" << endl;
        }
        else
        {  
            bool f=false;
            long long val = sum;
            sum = val;
                for (int i = 0; i <= two; i++)
                {   
                    for (int j = 0; j <= three; j++)
                    {
                        long long temp=sum;
                        temp+=(2*i)+(6*j);
                        if(temp%9==0){
                            f=true;
                            break;
                        }
                    }
                }
            if(f)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        string n;
        cin >> n;
        int two = 0;
        int three = 0;
        long long sum = 0;
        for(int i=0;i<n.length();i++){
            if(n[i]=='2')two++;
            if(n[i]=='3')three++;
            sum+=(n[i]-'0');
            // for optimation 
            sum=sum%9;
        }
        if (sum % 9 == 0)
        {
            cout << "YES" << endl;
        }
        else
        {  
            bool f=false;
            long long val = sum;
            sum = val;
                for (int i = 0; i <= two; i++)
                {   
                    for (int j = 0; j <= three; j++)
                    {
                        long long temp=sum;
                        temp+=(2*i)+(6*j);
                        if(temp%9==0){
                            f=true;
                            break;
                        }
                    }
                }
            if(f)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

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

const ll MOD = 1e9 + 7;
const ll MAX_N = 5e5;


int main(){
    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll temp = n-1;
        map<ll, multiset<ll>> m;
        while(temp--){
            ll l,r;
            cin>>l>>r;
            m[l].insert(r);
            m[r].insert(l);
        }
        ll v = 0;
        ll maxx = INT_MIN;
        ll ans = 0;
        for(auto i : m){
            if(i.second.size() > maxx){
                maxx = i.second.size();
                v = i.first;
            }
        }
        for(auto i : m[v]){
            m[i].erase(v);
        }
        m.erase(v);
        ans += maxx;
        maxx = INT_MIN;
        v = 0;
        for(auto i : m){
            if(i.second.size() > maxx){
                maxx = i.second.size();
                v = i.first;
            }
        }
        for(auto i : m[v]){
            m[i].erase(v);
        }
        m.erase(v);
        ans += maxx;
        cout<<ans-1<<endl;
    }

return 0;
}

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

const ll MOD = 1e9 + 7;
const ll MAX_N = 5e5;

int main() {
    ll t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;
        ll temp = n - 1;
        map<ll, multiset<ll>> m;
        
        // Read input and construct adjacency list
        while (temp--) {
            ll l, r;
            cin >> l >> r;
            m[l].insert(r);
            m[r].insert(l);
        }

        ll v = -1;
        ll maxx = 0;
        ll ans = 0;

        for (auto& i : m) {
            if (i.second.size() > maxx) {
                maxx = i.second.size();
                v = i.first;
            }
        }

        if (v != -1) { 
            for (auto i : m[v]) {
                if (m.find(i) != m.end()) {
                    m[i].erase(v);
                }
            }
            m.erase(v);
            ans += maxx;
        }

        maxx = 0;
        v = -1;

     
        for (auto& i : m) {
            if (i.second.size() > maxx) {
                maxx = i.second.size();
                v = i.first;
            }
        }

        if (v != -1) { 
            for (auto i : m[v]) {
                if (m.find(i) != m.end()) {
                    m[i].erase(v);
                }
            }
            m.erase(v);
            ans += maxx;
        }

        cout << ans - 1 << endl;
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


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

const ll MOD = 1e9 + 7;
const ll MAX_N = 5e5;


int main(){
    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll temp = n-1;
        map<ll, multiset<ll>> m;
        while(temp--){
            ll l,r;
            cin>>l>>r;
            m[l].insert(r);
            m[r].insert(l);
        }
        ll v = 0;
        ll maxx = INT_MIN;
        ll ans = 0;
        for(auto i : m){
            if(i.second.size() > maxx){
                maxx = i.second.size();
                v = i.first;
            }
        }
        for(auto i : m[v]){
            m[i].erase(v);
        }
        m.erase(v);
        ans += maxx;
        maxx = INT_MIN;
        v = 0;
        for(auto i : m){
            if(i.second.size() > maxx){
                maxx = i.second.size();
                v = i.first;
            }
        }
        for(auto i : m[v]){
            m[i].erase(v);
        }
        m.erase(v);
        ans += maxx;
        cout<<ans-1<<endl;
    }

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

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pii pair<int,int>
const int maxn = 100005, MOD = 1e9 + 7;

void fast_io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
}

// bool prime[1001];

// void SieveOfEratosthenes(int n)
// {
//     memset(prime, true, sizeof(prime));
//     for (int p = 2; p * p <= n; p++) {
//         if (prime[p] == true) {
//             for (int i = p * p; i <= n; i += p)prime[i] = false;
//         }
//     }
// }


void solve(){
    string n; cin >> n; 
    int twos = 0, threes = 0, md = 0;
    int x = n.size();
    bool ans = 0;
    for(int i = 0; i<x ; ++i){
        int temp = (int)(n[i]) - 48;
        md += temp; 
        md = (md % 9);
        // cout << temp << " ";
        if(temp == 2) twos++;
        if(temp == 3) threes++;

    }
    twos = (twos%9);
    threes = (threes%9);
    for(int i = 0; i<=twos; ++i){
        for(int j = 0; j<=threes; ++j){
            int temp = (2*i) + (6*j);
            if((md+temp) % 9 == 0) {
                ans = 1;
                break;
            }
        }
        if(ans) break;
    }
    if(ans) cout << "YES";
    else cout << "NO";
    
}

signed main() {
    fast_io();
    int t = 1;
    cin >> t;
    while(t--){
        solve();
        cout << endl;
    }
}



Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pii pair<int,int>
const int maxn = 100005, MOD = 1e9 + 7;

void fast_io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
}

// bool prime[1001];

// void SieveOfEratosthenes(int n)
// {
//     memset(prime, true, sizeof(prime));
//     for (int p = 2; p * p <= n; p++) {
//         if (prime[p] == true) {
//             for (int i = p * p; i <= n; i += p)prime[i] = false;
//         }
//     }
// }


void solve(){
    string n; cin >> n; 
    int twos = 0, threes = 0, md = 0;
    int x = n.size();
    bool ans = 0;
    for(int i = 0; i<x ; ++i){
        int temp = (int)(n[i]) - 48;
        md += temp; 
        md = (md % 9);
        // cout << temp << " ";
        if(temp == 2) twos++;
        if(temp == 3) threes++;

    }
    twos = min((int)8, twos);
    threes = min((int)2, threes);
    for(int i = 0; i<=twos; ++i){
        for(int j = 0; j<=threes; ++j){
            int temp = (2*i) + (6*j);
            if((md+temp) % 9 == 0) {
                ans = 1;
                break;
            }
        }
        if(ans) break;
    }
    if(ans) cout << "YES";
    else cout << "NO";
    
}

signed main() {
    fast_io();
    int t = 1;
    cin >> t;
    while(t--){
        solve();
        cout << endl;
    }
}