ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
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 int 
void solve(){
    int n,m;
    cin>>n>>m;
    vector<int>a(n),b(m);
    for(auto & i : a) cin>>i;
    for(auto & i : b) cin>>i;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    multiset<int>sb(b.begin(),b.end());
    
    if(n<m){
        cout<<"NO"<<endl;
        return;
    }
    else if(n==m){
        if(a==b){
            cout<<"YES"<<endl;
            return;
        }
        cout<<"NO"<<endl;
        return;
    }
    vector<int>na;
    int i = 0,j = 0 ;
    int prev = 0 ;
    int sum = 0 ;
    while(i<n and j<m){
        if((abs(a[i]-sum)<=1) or (prev == 0) ){
            sum+=a[i];
            //cout<<"sum is : "<<sum<<" ";
        }
        if((sb.find(sum)!=sb.end()) or (b[j]==sum)){
            if((sb.find(sum)!=sb.end())){
                sb.erase(sb.find(sum));
            }
            
            //cout<<"yaha ayaa "<<endl;
            na.push_back(sum);
            sum=0;
            prev=0;
            j++;
        }
        else if(sum<b[j]){
            prev = sum;
        }
        
        i++;
    }
    if(i<n){
        cout<<"NO"<<endl;
        return;
        
    }
    //cout<<" kya hua "<<endl;
    if(na.empty()){
       // cout<<"khali h kya ?"<<endl;
    }
    //for(auto & it : na){
    //   cout<<it<<" ";
        
        
    //}
    //cout<<endl;
    sort(na.begin(),na.end());
    if(na==b){
        cout<<"YES"<<endl;
        return;
    }
    cout<<"NO"<<endl;
}
int32_t main(){
    int t; cin>>t;
    while(t--)  solve();
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
void solve(){
    int n,m;
    cin>>n>>m;
    vector<int>a(n),b(m);
    priority_queue<int>pq_a,pq_b;
    for(auto & i : a){
        cin>>i;
        pq_a.push(i);
    } 
    for(auto & i : b) {
        cin>>i;
        pq_b.push(i);
    }
    if(n<m){
        cout<<"NO"<<endl;
        return;
    }
    if(n==m){
        sort(a.begin(),a.end());
        sort(b.begin(),b.end());
        if(a==b){
            cout<<"YES"<<endl;
            return;
        }
        else{
            cout<<"NO"<<endl;
            return;
        }
    }
    while( (pq_b.size() < pq_a.size()) and (!pq_a.empty()) and (!pq_b.empty()) ){
        int mxa = pq_a.top();
        int mxb = pq_b.top();
        if(mxa>mxb){
            cout<<"NO"<<endl;
            return;
        }
        if(mxa==mxb){
            pq_a.pop();
            pq_b.pop();
            
        }
        if(mxa<mxb){
            pq_b.pop();
            pq_b.push((mxb/2));
            pq_b.push((mxb/2)+(mxb%2));
        }
    }
    vector<int>temp_a , temp_b;
    while(!pq_a.empty()){
        temp_a.push_back(pq_a.top());
        pq_a.pop();
    }
    while(!pq_b.empty()){
        temp_b.push_back(pq_b.top());
        pq_b.pop();
    }
    if(temp_a==temp_b){
        cout<<"YES"<<endl;
        return;
        
    }
    cout<<"NO"<<endl;
    return;
    
    
    
}
int32_t main(){
    int t; cin>>t;
    while(t--)  solve();
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
void solve(){
    int n,m;
    cin>>n>>m;
    vector<int>a(n),b(m);
    for(auto & i : a) cin>>i;
    for(auto & i : b) cin>>i;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    unordered_set<int>sb(b.begin(),b.end());
    
    if(n<m){
        cout<<"NO"<<endl;
        return;
    }
    else if(n==m){
        if(a==b){
            cout<<"YES"<<endl;
            return;
        }
        cout<<"NO"<<endl;
        return;
    }
    vector<int>na;
    int i = 0,j = 0 ;
    int prev = 0 ;
    int sum = 0 ;
    while(i<n and j<m){
        if((abs(a[i]-sum)<=1) or (prev == 0) ){
            sum+=a[i];
            //cout<<"sum is : "<<sum<<" ";
        }
        if(sb.find(sum)!=sb.end()){
            sb.erase(sb.find(sum));
            //cout<<"yaha ayaa "<<endl;
            na.push_back(sum);
            sum=0;
            prev=0;
            j++;
        }
        else if(sum<b[j]){
            prev = sum;
        }
        
        i++;
    }
    if(i<n){
        cout<<"NO"<<endl;
        return;
        
    }
    //cout<<" kya hua "<<endl;
    if(na.empty()){
        //cout<<"khali h kya ?"<<endl;
    }
    //for(auto & it : na){
     //   cout<<it<<" ";
        
        
    //}
    //cout<<endl;
    sort(na.begin(),na.end());
    if(na==b){
        cout<<"YES"<<endl;
        return;
    }
    cout<<"NO"<<endl;
}
int32_t main(){
    int t; cin>>t;
    while(t--)  solve();
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

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

using namespace std;

void solve();
#define ll long long
#define pii pair<int,int>
#define endl '\n'
#define ip(a,n) for(int i=0; i<n; ++i) cin>>a[i];
#define op(a,n) for(int i=0; i<n; ++i) cout<<a[i]<<" "; cout<<'\n';
#define p(x) cout<<(x)<<'\n';

const int mod = 1e9+7;


int main(){



    int t = 1;
    cin>>t;

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

    return 0;
}




/*



*/
bool fn(unordered_map<int,int>&m,int a,int b){
    if(a==0||b==0)
    return false;
    if(m.find(a)==m.end()||m[a]==0){
        int temp=a/2;
       if(! fn(m,temp,a-temp)) return false;
       
    }
    else
    --m[a];
     if(m.find(b)==m.end()||m[b]==0){
        int temp=b/2;
       if(! fn(m,temp,b-temp)) return false;
    }
    else
    --m[b];
    return true;
    

   
}






void solve(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n,0),b(k);
    ip(a,n);
    ip(b,k);
    unordered_map<int,int>m;
    for(auto i:a)
    m[i]++;

    for(int i=0;i<k;i++){
        if(m.find(b[i])!=m.end()&&m[b[i]]>0){
            --m[b[i]];
            
        }
        else {
        int temp1=b[i]/2;
        int temp2=b[i]-temp1;
      if(! fn(m,temp1,temp2)){
        cout<<"No"<<endl;
        return;
      }
        }


    }
    for(auto i:m){
        if(i.second>0){
          cout<<"No"<<endl;
        return;  
        }
    }
    cout<<"Yes"<<endl;





}


























































    

























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

using namespace std;

void solve();
#define ll long long
#define pii pair<int,int>
#define endl '\n'
#define ip(a,n) for(int i=0; i<n; ++i) cin>>a[i];
#define op(a,n) for(int i=0; i<n; ++i) cout<<a[i]<<" "; cout<<'\n';
#define p(x) cout<<(x)<<'\n';

const int mod = 1e9+7;


int main(){



    int t = 1;
    cin>>t;

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

    return 0;
}




/*



*/
bool fn(unordered_map<int,int>&m,int a,int b){
    if(a==0||b==0)
    return false;
    if(m.find(a)==m.end()||m[a]==0){
        int temp=a/2;
       if(! fn(m,temp,a-temp)) return false;
       
    }
    else
    --m[a];
     if(m.find(b)==m.end()||m[b]==0){
        int temp=b/2;
       if(! fn(m,temp,b-temp)) return false;
    }
    else
    --m[b];
    return true;
    

   
}






void solve(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n,0),b(k);
    ip(a,n);
    ip(b,k);
    unordered_map<int,int>m;
    for(auto i:a)
    m[i]++;
    sort(b.begin(),b.end());
    for(int i=0;i<k;i++){
        if(m.find(b[i])!=m.end()&&m[b[i]]>0){
            --m[b[i]];
            
        }
        else {
        int temp1=b[i]/2;
        int temp2=b[i]-temp1;
      if(! fn(m,temp1,temp2)){
        cout<<"No"<<endl;
        return;
      }
        }


    }
    for(auto i:m){
        if(i.second>0){
          cout<<"No"<<endl;
        return;  
        }
    }
    cout<<"Yes"<<endl;





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


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

using namespace std;

void solve();
#define ll long long
#define pii pair<int,int>
#define endl '\n'
#define ip(a,n) for(int i=0; i<n; ++i) cin>>a[i];
#define op(a,n) for(int i=0; i<n; ++i) cout<<a[i]<<" "; cout<<'\n';
#define p(x) cout<<(x)<<'\n';

const int mod = 1e9+7;


int main(){



    int t = 1;
    cin>>t;

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

    return 0;
}




/*



*/
bool fn(unordered_map<int,int>&m,int a,int b){
    if(a==0||b==0)
    return false;
    if(m.find(a)==m.end()||m[a]==0){
        int temp=a/2;
       if(! fn(m,temp,a-temp)) return false;
       
    }
    else
    --m[a];
     if(m.find(b)==m.end()||m[b]==0){
        int temp=b/2;
       if(! fn(m,temp,b-temp)) return false;
    }
    else
    --m[b];
    return true;
    

   
}






void solve(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n,0),b(k);
    ip(a,n);
    ip(b,k);
    unordered_map<int,int>m;
    for(auto i:a)
    m[i]++;

    for(int i=0;i<k;i++){
        if(m.find(b[i])!=m.end()&&m[b[i]]>0){
            --m[b[i]];
            
        }
        else {
        int temp1=b[i]/2;
        int temp2=b[i]-temp1;
      if(! fn(m,temp1,temp2)){
        cout<<"No"<<endl;
        return;
      }
        }


    }
    for(auto i:m){
        if(i.second>0){
          cout<<"No"<<endl;
        return;  
        }
    }
    cout<<"Yes"<<endl;





}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#ifdef _MSC_VER

#  include <intrin.h>

#  define __builtin_popcount __popcnt

#endif

#include <bits/stdc++.h>

#pragma GCC optimize("O3")

#pragma GCC optimize("Ofast")

#pragma GCC optimize("unroll-loops")

#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef long double ld;

#define MAX 3030

#define MAXS 20

#define BMAX 35

#define MOD 100'000'000

#define TC 1

#define ln '\n'

#define bb ' '

int A[MAX];

void solve() {

	int N;

	cin >> N;

	string s;

	cin >> s;

	int pc, sc;

	pc = sc = 0;

	for (auto c : s) {

		if (c == 'p') pc++;

		else if (c == 's') sc++;

	}

	if (pc > 1 && sc > 1) {

		cout << "NO" << ln;

		return;

	}

	if (!pc || !sc) {

		cout << "YES" << ln;

		return;

	}

	if (pc == 1) {

		if (s[N - 1] == 'p') cout << "YES" << ln;

		else cout << "NO" << ln;

	}

	else {

		if (s[0] == 's') cout << "YES" << ln;

		else cout << "NO" << ln;

	}

}

signed main() {

	ios::sync_with_stdio(false), cin.tie(0);

	int T = 1;

	if (TC) cin >> T;

	while (T--) solve();

}

Submission (verdict: Accepted):
#ifdef _MSC_VER

#  include <intrin.h>

#  define __builtin_popcount __popcnt

#endif

#include <bits/stdc++.h>

#pragma GCC optimize("O3")

#pragma GCC optimize("Ofast")

#pragma GCC optimize("unroll-loops")

#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef long double ld;

#define MAX 3030

#define MAXS 20

#define BMAX 35

#define MOD 100'000'000

#define TC 1

#define ln '\n'

#define bb ' '

int A[MAX];

void solve() {

	int N;

	cin >> N;

	string s;

	cin >> s;

	int pc, sc;

	pc = sc = 0;

	int i;

	for (i = 0; i < N; i++) {

		if (s[i] == 'p' && i < N - 1) pc++;

		if (s[i] == 's' && i) sc++;

	}

	if (!pc || !sc) {

		cout << "YES" << ln;

		return;

	}

	else cout << "NO" << ln;

}

signed main() {

	ios::sync_with_stdio(false), cin.tie(0);

	int T = 1;

	if (TC) cin >> T;

	while (T--) solve();

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#ifdef _MSC_VER

#  include <intrin.h>

#  define __builtin_popcount __popcnt

#endif

#include <bits/stdc++.h>

#pragma GCC optimize("O3")

#pragma GCC optimize("Ofast")

#pragma GCC optimize("unroll-loops")

#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef long double ld;

#define MAX 3030

#define MAXS 20

#define BMAX 35

#define MOD 100'000'000

#define TC 1

#define ln '\n'

#define bb ' '

int A[MAX];

void solve() {

	int N;

	cin >> N;

	string s;

	cin >> s;

	int pc, sc;

	pc = sc = 0;

	for (auto c : s) {

		if (c == 'p') pc++;

		else if (c == 's') sc++;

	}

	if (pc > 1 && sc > 1) {

		cout << "NO" << ln;

		return;

	}

	if (!pc || !sc) {

		cout << "YES" << ln;

		return;

	}

	if (pc == 1) {

		if (s[N - 1] == 'p') cout << "YES" << ln;

		else cout << "NO" << ln;

	}

	else {

		if (s[N - 1] == 's') cout << "YES" << ln;

		else cout << "NO" << ln;

	}

}

signed main() {

	ios::sync_with_stdio(false), cin.tie(0);

	int T = 1;

	if (TC) cin >> T;

	while (T--) solve();

}

Submission (verdict: Wrong answer on test 2):
#ifdef _MSC_VER

#  include <intrin.h>

#  define __builtin_popcount __popcnt

#endif

#include <bits/stdc++.h>

#pragma GCC optimize("O3")

#pragma GCC optimize("Ofast")

#pragma GCC optimize("unroll-loops")

#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef long double ld;

#define MAX 3030

#define MAXS 20

#define BMAX 35

#define MOD 100'000'000

#define TC 1

#define ln '\n'

#define bb ' '

int A[MAX];

void solve() {

	int N;

	cin >> N;

	string s;

	cin >> s;

	int pc, sc;

	pc = sc = 0;

	for (auto c : s) {

		if (c == 'p') pc++;

		else if (c == 's') sc++;

	}

	if (pc > 1 && sc > 1) {

		cout << "NO" << ln;

		return;

	}

	if (!pc || !sc) {

		cout << "YES" << ln;

		return;

	}

	if (pc == 1) {

		if (s[N - 1] == 'p') cout << "YES" << ln;

		else cout << "NO" << ln;

	}

	else {

		if (s[0] == 's') cout << "YES" << ln;

		else cout << "NO" << ln;

	}

}

signed main() {

	ios::sync_with_stdio(false), cin.tie(0);

	int T = 1;

	if (TC) cin >> T;

	while (T--) solve();

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#ifdef _MSC_VER

#  include <intrin.h>

#  define __builtin_popcount __popcnt

#endif

#include <bits/stdc++.h>

#pragma GCC optimize("O3")

#pragma GCC optimize("Ofast")

#pragma GCC optimize("unroll-loops")

#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef long double ld;

#define MAX 3030

#define MAXS 20

#define BMAX 35

#define MOD 100'000'000

#define TC 1

#define ln '\n'

#define bb ' '

int A[MAX];

void solve() {

	int N;

	cin >> N;

	string s;

	cin >> s;

	int pc, sc;

	pc = sc = 0;

	for (auto c : s) {

		if (c == 'p') pc++;

		else sc++;

	}

	if (pc > 1 && sc > 1) {

		cout << "NO" << ln;

		return;

	}

	if (!pc || !sc) {

		cout << "YES" << ln;

		return;

	}

	if (pc == 1) {

		if (s[N - 1] == 'p') cout << "YES" << ln;

		else cout << "NO" << ln;

	}

	else {

		if (s[N - 1] == 's') cout << "YES" << ln;

		else cout << "NO" << ln;

	}

}

signed main() {

	ios::sync_with_stdio(false), cin.tie(0);

	int T = 1;

	if (TC) cin >> T;

	while (T--) solve();

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#ifdef _MSC_VER

#  include <intrin.h>

#  define __builtin_popcount __popcnt

#endif

#include <bits/stdc++.h>

#pragma GCC optimize("O3")

#pragma GCC optimize("Ofast")

#pragma GCC optimize("unroll-loops")

#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef long double ld;

#define MAX 3030

#define MAXS 20

#define BMAX 35

#define MOD 100'000'000

#define TC 1

#define ln '\n'

#define bb ' '

int A[MAX];

void solve() {

	int N;

	cin >> N;

	string s;

	cin >> s;

	int pc, sc;

	pc = sc = 0;

	for (auto c : s) {

		if (c == 'p') pc++;

		else sc++;

	}

	if (pc > 1 && sc > 1) {

		cout << "NO" << ln;

		return;

	}

	if (!pc || !sc) {

		cout << "YES" << ln;

		return;

	}

	if (pc == 1) {

		if (s[N - 1] == 'p') cout << "YES" << ln;

		else cout << "NO" << ln;

	}

	else {

		if (s[N - 1] == 's') cout << "YES" << ln;

		else cout << "NO" << ln;

	}

}

signed main() {

	ios::sync_with_stdio(false), cin.tie(0);

	int T = 1;

	if (TC) cin >> T;

	while (T--) solve();

}

Submission (verdict: Wrong answer on test 2):
#ifdef _MSC_VER

#  include <intrin.h>

#  define __builtin_popcount __popcnt

#endif

#include <bits/stdc++.h>

#pragma GCC optimize("O3")

#pragma GCC optimize("Ofast")

#pragma GCC optimize("unroll-loops")

#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef long double ld;

#define MAX 3030

#define MAXS 20

#define BMAX 35

#define MOD 100'000'000

#define TC 1

#define ln '\n'

#define bb ' '

int A[MAX];

void solve() {

	int N;

	cin >> N;

	string s;

	cin >> s;

	int pc, sc;

	pc = sc = 0;

	for (auto c : s) {

		if (c == 'p') pc++;

		else if (c == 's') sc++;

	}

	if (pc > 1 && sc > 1) {

		cout << "NO" << ln;

		return;

	}

	if (!pc || !sc) {

		cout << "YES" << ln;

		return;

	}

	if (pc == 1) {

		if (s[N - 1] == 'p') cout << "YES" << ln;

		else cout << "NO" << ln;

	}

	else {

		if (s[N - 1] == 's') cout << "YES" << ln;

		else cout << "NO" << ln;

	}

}

signed main() {

	ios::sync_with_stdio(false), cin.tie(0);

	int T = 1;

	if (TC) cin >> T;

	while (T--) solve();

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<string>

using namespace std;

void solve()

{

	int n,jump=1;

	string s;

	cin>>n>>s;

	for(int i=1;i<n;i++)

	{

		if(s[i]=='.')

		{

			jump++;

			continue;

		}

		if(s[i]=='s'&&s[i-jump]=='p')

		{

			cout<<"NO"<<endl;

			return;

		}

		if(s[i]=='p'&&s[i-jump]=='s'&&i!=n-1)

		{

			cout<<"NO"<<endl;

			return;

		}

		jump=1;

	}

	cout<<"YES"<<endl;

}

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);cout.tie(0);

	int t;

	cin>>t;

	while(t--)

	{

		solve();

	}

	return 0; 

} 

Submission (verdict: Accepted):
#include<iostream>

#include<string>

using namespace std;

void solve()

{

	int n,jump=1;

	string s;

	cin>>n>>s;

	for(int i=1;i<n;i++)

	{

		if(s[i]=='.')

		{

			jump++;

			continue;

		}

		if(s[i]=='s'&&s[i-jump]=='p')

		{

			cout<<"NO"<<endl;

			return;

		}

		if(s[i]=='p'&&s[i-jump]=='s'&&i!=n-1&&i-jump!=0)

		{

			cout<<"NO"<<endl;

			return;

		}

		jump=1;

	}

	cout<<"YES"<<endl;

}

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);cout.tie(0);

	int t;

	cin>>t;

	while(t--)

	{

		solve();

	}

	return 0; 

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<string>

using namespace std;

void solve()

{

	int n;

	string s;

	cin>>n>>s;

	for(int i=1;i<n;i++)

	{

		if(s[i]=='s'&&s[i-1]=='p')

		{

			cout<<"NO"<<endl;

			return;

		}

		if(s[i]=='p'&&s[i-1]=='s'&&i!=n-1)

		{

			cout<<"NO"<<endl;

			return;

		}

	}

	cout<<"YES"<<endl;

}

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);cout.tie(0);

	int t;

	cin>>t;

	while(t--)

	{

		solve();

	}

	return 0; 

} 

Submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<string>

using namespace std;

void solve()

{

	int n,jump=1;

	string s;

	cin>>n>>s;

	for(int i=1;i<n;i++)

	{

		if(s[i]=='.')

		{

			jump++;

			continue;

		}

		if(s[i]=='s'&&s[i-jump]=='p')

		{

			cout<<"NO"<<endl;

			return;

		}

		if(s[i]=='p'&&s[i-jump]=='s'&&i!=n-1)

		{

			cout<<"NO"<<endl;

			return;

		}

		jump=1;

	}

	cout<<"YES"<<endl;

}

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);cout.tie(0);

	int t;

	cin>>t;

	while(t--)

	{

		solve();

	}

	return 0; 

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<string>

using namespace std;

void solve()

{

	int n;

	string s;

	cin>>n>>s;

	for(int i=1;i<n;i++)

	{

		if(s[i]=='s'&&s[i-1]=='p')

		{

			cout<<"NO"<<endl;

			return;

		}

		if(s[i]=='p'&&s[i-1]=='s'&&i!=n-1)

		{

			cout<<"NO"<<endl;

			return;

		}

	}

	cout<<"YES"<<endl;

}

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);cout.tie(0);

	int t;

	cin>>t;

	while(t--)

	{

		solve();

	}

	return 0; 

}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#define int long long
using namespace std;
int mod=998244353;
int INF=-1e10;
void dfs(int u,int p,auto &adj,auto &dp,auto &dgr){
    for(auto v:adj[u]){
        if(v==p) continue;
        dfs(v,u,adj,dp,dgr);
        dp[u][1][0]=max({dp[u][1][0],dp[v][1][1],dp[v][1][0]});
        dp[u][2][0]=max({dp[u][2][0],dp[v][2][0],dp[v][2][1]});
        dp[u][1][1]=dgr[u];
        dp[u][2][1]=max(dp[v][1][1]+dgr[u]-2,dp[v][1][0]+dgr[u]-1);
    }
    if(dgr[u]==1 && u!=0){
        dp[u][1][0] = 0;
        dp[u][2][0] = 0;
        dp[u][1][1] = 1;
        dp[u][2][1] = 0;
    }
}
void solve(){
    int n;
    cin>>n;
    vector<vector<int>> adj(n);
    vector<vector<vector<int>>> dp(n,vector<vector<int>>(3,vector<int>(2,0)));
    vector<int> dgr(n,0);
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        u--;v--;
        dgr[u]++;
        dgr[v]++;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(0,-1,adj,dp,dgr);
    //cout<<dp[4][1][1]<<endl;
    cout<<max(dp[0][2][0],dp[0][2][1])<<endl;
}
int32_t main(){
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#define int long long
using namespace std;
int mod=998244353;
int INF=-1e10;
void dfs(int u,int p,auto &adj,auto &dp,auto &dgr){
    for(auto v:adj[u]){
        if(v==p) continue;
        dfs(v,u,adj,dp,dgr);
        dp[u][1][0]=max({dp[u][1][0],dp[v][1][1],dp[v][1][0]});
        dp[u][2][0]=max({dp[u][2][0],dp[v][2][0],dp[v][2][1]});
        dp[u][1][1]=dgr[u];
        dp[u][2][1]=max({dp[u][2][1],dp[v][1][1]+dgr[u]-2,dp[v][1][0]+dgr[u]-1});
    }
    if(dgr[u]==1 && u!=0){
        dp[u][1][0] = 0;
        dp[u][2][0] = 0;
        dp[u][1][1] = 1;
        dp[u][2][1] = 0;
    }
}
void solve(){
    int n;
    cin>>n;
    vector<vector<int>> adj(n);
    vector<vector<vector<int>>> dp(n,vector<vector<int>>(3,vector<int>(2,0)));
    vector<int> dgr(n,0);
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        u--;v--;
        dgr[u]++;
        dgr[v]++;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(0,-1,adj,dp,dgr);
    //cout<<dp[4][1][1]<<endl;
    cout<<max(dp[0][2][0],dp[0][2][1])<<endl;
}
int32_t main(){
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#define int long long
using namespace std;
int mod=998244353;
int INF=-1e10;
void dfs(int u,int p,auto &adj,auto &dp,auto &dgr){
    for(auto v:adj[u]){
        if(v==p) continue;
        dfs(v,u,adj,dp,dgr);
        dp[u][1][0]=max({dp[u][1][0],dp[v][1][1],dp[v][1][0]});
        dp[u][2][0]=max({dp[u][2][0],dp[v][2][0],dp[v][2][1]});
        dp[u][1][1]=dgr[u];
        dp[u][2][1]=max(dp[v][1][1]+dgr[u]-2,dp[v][1][0]+dgr[u]-1);
    }
    if(dgr[u]==1 && u!=0){
        dp[u][1][0] = 0;
        dp[u][2][0] = 0;
        dp[u][1][1] = 1;
        dp[u][2][1] = 0;
    }
}
void solve(){
    int n;
    cin>>n;
    vector<vector<int>> adj(n);
    vector<vector<vector<int>>> dp(n,vector<vector<int>>(3,vector<int>(2,0)));
    vector<int> dgr(n,0);
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        u--;v--;
        dgr[u]++;
        dgr[v]++;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(0,-1,adj,dp,dgr);
    //cout<<dp[4][1][1]<<endl;
    cout<<max(dp[0][2][0],dp[0][2][1])<<endl;
}
int32_t main(){
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
}