ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

using namespace std;



int main()

{

    int t;

    cin >> t;



    while(t --)

    {

        int n;

        string str;

        cin >> n >> str;

        int p = 0, s = 0;

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

        {

            if(str[i] == 'p') p ++;

            if(str[i] == 's') s ++; 

        }

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

            cout << "NO" << "\n";

        else cout << "YES" << "\n";

    }

}

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

using namespace std;



int main()

{

    int t;

    cin >> t;



    while(t --)

    {

        int n;

        string str;

        cin >> n >> str;

        int p = n, s = 0;

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

        {

            if(str[i] == 'p') p = min(p, i);

            if(str[i] == 's') s = max(s, i); 

        }

        if(p < s) cout << "NO" << "\n";

        else if(str[0] == '.' && str[n - 1] == '.' && p != n && s != 0) cout << "NO" << "\n";

        else cout << "YES" << "\n";



    }

}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
//fly!
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<numeric>
#define ll long  long
#define ull unsigned long long
#define itn int 
#define mian main
#define N 1000010
#define end <<"\n"
#define endd <<" "
#define yes true
#define no false
#define fi first
#define se second
#define be begin()
#define en end()
#define double long double
using namespace std;
//atuo lfy 琴弦断了，缘也尽了，你也走了
//ll x[500010] = { 0 };
ll sumy = 0;ll x[1000010]={0};ll x1[1000010]={0};

int Rank[1000010]={0};int pre[1000010]={0};
inline ll gcd(ll a, ll b) { return b > 0 ? gcd(b, a % b) : a; }// from kdb学长
inline ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
inline int jihefind(int root){if(pre[root]==root){return root;}pre[root]=jihefind(pre[root]);return pre[root];}
inline int jihejoin(int x,int y){ x=jihefind(x); y=jihefind(y);if(x==y){return 0;}if(Rank[x]>Rank[y]){pre[y]=x;}else{if(Rank[x]==Rank[y]){Rank[y]++;}pre[x]=y;}return 1;}
inline bool issame(itn x,int y){return jihefind(x)==jihefind(y);}
// priority_queue<int> q;//优先队列 大
//priority_queue<int,vector<int>,greater<int> > q;//优先队列 小
// struct q{

// }x;
//bool cmp(jian q, jian w) {
//    return q.b > w.b;
//}
int dx[8]={-1,1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};//上下左右，左上右上左下右上
void bfs(int i,int j){
  
}
void solve() {      
int n;
cin>>n;sumy=0;

for(int i=1;i<=n;i++){
  cin>>x[i];sumy+=x[i];
}
if(n==1){
  cout<<x[1] end;return ;
}
ll maxx=-1;
while(n>1){
  n--;ll sum=0;
  for(itn i=1;i<=n;i++){
    x[i]=x[i+1]-x[i];
    sum+=x[i];
  }
   maxx=max(sumy,max(sum,-sum));
}
cout<<maxx end;
}
int main() {
    std::ios::sync_with_stdio(false);
    int T = 1;
    // scanf("%d", &T);
      cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define LNF 1e18
#define INF 0x3f3f3f3f
//#define abs(x) llabs(x)
void solve(){
    int n;cin >> n;
    vector<int> arr(n);
    int sum=0;
    for (int i=0;i<n;i++) {
        cin >> arr[i];
        sum+=arr[i];
    }
    while (n!=1){
        sum=max(sum,abs(arr[0]-arr[n-1]));
        for (int i=0;i<n-1;i++) arr[i]=arr[i+1]-arr[i];
        n--;
    }
    cout << sum << endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    int T;cin >> T;
    while (T--) solve();
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define LNF 1e18
#define INF 0x3f3f3f3f
#define abs(x) llabs(x)
void solve(){
    int n;cin >> n;
    vector<int> arr(n);
    long long sum=0;
    for (int i=0;i<n;i++) {
        cin >> arr[i];
        sum+=arr[i];
    }
    while (n!=1){
        sum=max(sum,abs(arr[0]-arr[n-1]));
        for (int i=0;i<n-1;i++) arr[i]=arr[i+1]-arr[i];
        n--;
    }
    cout << sum << endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    int T;cin >> T;
    while (T--) solve();
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define LNF 1e18
#define INF 0x3f3f3f3f
//#define abs(x) llabs(x)
void solve(){
    int n;cin >> n;
    vector<int> arr(n);
    int sum=0;
    for (int i=0;i<n;i++) {
        cin >> arr[i];
        sum+=arr[i];
    }
    while (n!=1){
        sum=max(sum,abs(arr[0]-arr[n-1]));
        for (int i=0;i<n-1;i++) arr[i]=arr[i+1]-arr[i];
        n--;
    }
    cout << sum << endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    int T;cin >> T;
    while (T--) solve();
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define LNF 1e18
#define INF 0x3f3f3f3f
#define abs(x) llabs(x)
void solve(){
    int n;cin >> n;
    vector<int> arr(n);
    long long sum=0;
    for (int i=0;i<n;i++) {
        cin >> arr[i];
        sum+=arr[i];
    }
    while (n!=1){
        sum=max(sum,abs(arr[0]-arr[n-1]));
        for (int i=0;i<n-1;i++) arr[i]=arr[i+1]-arr[i];
        n--;
    }
    cout << sum << endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    int T;cin >> T;
    while (T--) solve();
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define LNF 1e18
#define INF 0x3f3f3f3f
#define abs(x) llabs(x)
void solve(){
    int n;cin >> n;
    vector<ll> arr(n);
    ll sum=0;
    for (int i=0;i<n;i++) {
        cin >> arr[i];
        sum+=arr[i];
    }
    while (n!=1){
        sum=max(sum,abs(arr[0]-arr[n-1]));
        for (int i=0;i<n-1;i++) arr[i]=arr[i+1]-arr[i];
        n--;
    }
    cout << sum << endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    int T;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>
using namespace std;
vector<int> num;
int cmp(int a,int b)
{
    if(num[a]>num[b]) return 1;
    else return 0;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        num.resize(n+1);
        for(int i=1;i<=n;i++)
        {
            num[i] = 0;
        }
        vector<int> big(n+1);
        for(int i=1;i<=n;i++)
        {
            big[i] = i;
        }
        map<pair<int,int>,int> mp;
        for(int i=1;i<n;i++)
        {
            int u,v;
            cin >> u >> v;
            mp[{v,u}]++;
            mp[{u,v}]++;            
            num[u]++;
            num[v]++;
        }
        int ans = 1;
        sort(big.begin()+1,big.end(),cmp);
        if(num[big[1]]!=num[big[2]])
        {
            // cout <<"num "<< num[big[1]] << ' ' << num[big[2]] <<'\n';
            ans += num[big[1]]+num[big[2]]-3;
            int i = 2;
            while(i<n&&num[big[i]]==num[big[2]])
            {
                if(!mp[{big[i],big[1]}])
                {
                    ans++;
                    break;
                }
                i++;
            }
            cout << ans <<'\n';
        }
        else
        {
            ans += 2*num[big[1]]-3;
            int k = 2;
            while(k<=n&&num[big[k]]==num[big[1]])
            {
                k++;
            }
            k--;
            for(int i=1;i<=k;i++)
            {
                for(int j=i+1;j<=k;j++)
                {
                    if(!mp[{big[i],big[j]}])
                    {
                        ans++;
                        break;
                    }
                }
            }
            cout << ans << '\n';
        }
    }
    return 0;
}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)


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

using namespace std;

int main()

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int t;

    cin >> t;

    while(t--)

    {

        int n;

        cin >> n;

        string s;

        cin >> s;

        map<char,int> mp;

        for(auto& x : s)

        {

            mp[x]++;

        }

        if(mp['.']==n) cout << "yes\n";

        else if(mp['s']==n) cout << "yes\n";

        else if(mp['p']==n) cout << "yes\n";

        else

        {

            int xp = -1,xs = -1;

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

            {

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

                {

                    xp = i;

                    break;

                }

            }

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

            {

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

                {

                    xs = i;

                    break;

                }

            }

            if(xp<xs) cout << "no\n";

            else

            {

                if(s[0]=='.') cout << "no\n";

                else cout << "yes\n";

            }

        }

    }

    return 0;

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

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

using namespace std;

int main()

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int t;

    cin >> t;

    while(t--)

    {

        int n;

        cin >> n;

        string s;

        cin >> s;

        map<char,int> mp;

        for(auto& x : s)

        {

            mp[x]++;

        }

        if(mp['.']==n) cout << "yes\n";

        else if(mp['s']==n) cout << "yes\n";

        else if(mp['p']==n) cout << "yes\n";

        else

        {

            int xp = -1,xs = -1;

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

            {

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

                {

                    xp = i;

                    break;

                }

            }

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

            {

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

                {

                    xs = i;

                    break;

                }

            }

            if(xp<xs) cout << "no\n";

            else

            {

                if(s[0]=='.') cout << "no\n";

                else cout << "yes\n";

            }

        }

    }

    return 0;

}

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

using namespace std;

int main()

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int t;

    cin >> t;

    while(t--)

    {

        int n;

        cin >> n;

        string s;

        cin >> s;

        map<char,int> mp;

        for(auto& x : s)

        {

            mp[x]++;

        }

        if(mp['.']==n) cout << "yes\n";

        else if(mp['s']==n) cout << "yes\n";

        else if(mp['p']==n) cout << "yes\n";

        else

        {

            int xp = -1,xs = -1;

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

            {

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

                {

                    xp = i;

                    break;

                }

            }

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

            {

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

                {

                    xs = i;

                    break;

                }

            }

            if(xp<xs) cout << "no\n";

            else

            {

                if(s[0]=='.') cout << "no\n";

                else if(mp['s']==1) cout << "yes\n";

                else

                {

                    if(mp['p']>1) cout << "no\n";

                    else if(s[n-1]=='.') cout << "no\n";

                    else cout  << "yes\n";

                }

            }

        }

    }

    return 0;

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

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

using namespace std;

int main()

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int t;

    cin >> t;

    while(t--)

    {

        int n;

        cin >> n;

        string s;

        cin >> s;

        map<char,int> mp;

        for(auto& x : s)

        {

            mp[x]++;

        }

        if(mp['.']==n) cout << "yes\n";

        else if(mp['s']==n) cout << "yes\n";

        else if(mp['p']==n) cout << "yes\n";

        else

        {

            int xp = -1,xs = -1;

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

            {

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

                {

                    xp = i;

                    break;

                }

            }

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

            {

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

                {

                    xs = i;

                    break;

                }

            }

            if(xp<xs) cout << "no\n";

            else

            {

                if(s[0]=='.') cout << "no\n";

                else if(mp['s']==1) cout << "yes\n";

                else

                {

                    if(mp['p']>1) cout << "no\n";

                    else if(s[n-1]=='.') cout << "no\n";

                    else cout  << "yes\n";

                }

            }

        }

    }

    return 0;

}

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

using namespace std;

int main()

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int t;

    cin >> t;

    while(t--)

    {

        int n;

        cin >> n;

        string s;

        cin >> s;

        map<char,int> mp;

        for(auto& x : s)

        {

            mp[x]++;

        }

        if(mp['.']==n) cout << "yes\n";

        else if(mp['s']==n) cout << "yes\n";

        else if(mp['p']==n) cout << "yes\n";

        else

        {

            int xp = -1,xs = -1;

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

            {

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

                {

                    xp = i;

                    break;

                }

            }

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

            {

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

                {

                    xs = i;

                    break;

                }

            }

            if(xp<xs) cout << "no\n";

            else

            {

                if(mp['s']==1&&mp['p']==1)

                {

                    if(s[0]=='.'&&s[n-1]=='.') cout << "no\n";

                    else cout << "yes\n";

                }

                if(mp['s']>1&&mp['p']>1) cout << "no\n";

                else

                {

                    if(mp['s']>1)

                    {

                        if(s[n-1]=='.') cout << "no\n";

                        else cout << "yes\n";

                    }

                    else

                    {

                        if(s[0]=='.') cout << "no\n";

                        else cout << "yes\n";

                    }

                }

            }

        }

    }

    return 0;

}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#define int long long

// macros
#define For(x) for (int i = 0; i < x; i++)
#define SORT(a) sort(a.begin(), a.end())
#define FOR(a, b, c) for(int i = a; i < b; i += c)
#define SUM(a) accumulate(a.begin(), a.end(), 0LL)
#define MAX(a) *max_element(a.begin(), a.end())
#define all(x) (x.begin(), x.end())

// syntax
#define mp make_pair

// other macros
#define MOD (int)1e8

// speed
#pragma GCC optimize("O3")

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int count;
    cin >> count;
    vector<int> arr(count);
    For (count){
        cin >> arr[i];
    }
    int counter = 0;
    for (int i = 0; i < count; i++){
        for (int j = i + 1; j < count; j++){
            if (arr[i] > arr[j]){
                counter++;
            } else {
                counter += 2;
            }
        }
    }
    cout << counter << "\n";
    for (int i = 0; i < count; i++){
        for (int j = i + 1; j < count; j++){
            cout << j + 1 << " " << i + 1 << "\n";
        }
    }
    for (int x = 0; x < count; x++){
        auto revIndex = count - x;
        if (arr[x] != revIndex){
            // cout << revIndex;
            if (arr[x] > revIndex){
                cout << revIndex << " " << arr[x] << "\n";
                auto v = arr[x];
                arr[x] = arr[x-1];
                arr[x-1] = v;
            } else {
                cout << arr[x] << " " << revIndex << "\n";
                
                auto v = arr[x];
                arr[x] = arr[x+1];
                arr[x+1] = v;
            }
        }
    }
}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

using namespace std;

void solve(void)

{

	int n;cin>>n;

	string s;cin>>s;

	int snum=0,pnum=0;

	bool pj=1;int posp,poss;

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

	{

		if(pj&&s[i]=='p')

		{

			posp=i;

			pj=0;

		}

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

		{

			snum++;

			poss=i;

		}

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

			pnum++;

	} 

	if(snum!=0&&pnum!=0&&posp<poss)

	{

		cout<<"NO\n";

		return ;

	}

	if(snum>1&&pnum>1)

	{

		cout<<"NO\n";

		return;

	}

	if(snum!=0&&pnum!=0&&s[0]!='s'&&s[n-1]!='p')

	{

		cout<<"NO\n";

		return;

	}

//	cout<<posp<<" "<<poss<<endl;

	cout<<"YES\n";

}

signed main(void)

{

	ios::sync_with_stdio(0);

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

	int t;cin>>t;

	while(t--)

	{

		solve();

	}

}

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

using namespace std;

void solve(void)

{

	int n;cin>>n;

	string s;cin>>s;

	int snum=0,pnum=0;

	bool pj=1;int posp,poss;

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

	{

		if(pj&&s[i]=='p')

		{

			posp=i;

			pj=0;

		}

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

		{

			snum++;

			poss=i;

		}

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

			pnum++;

	} 

	if(snum!=0&&pnum!=0&&posp<poss)

	{

		cout<<"NO\n";

		return ;

	}

	if(snum>1&&pnum>1)

	{

		cout<<"NO\n";

		return;

	}

	if(snum==1&&pnum==1&&s[0]!='s'&&s[n-1]!='p')

	{

		cout<<"NO\n";

		return;

	}

	if(snum==1&&pnum!=0&&s[0]!='s')

	{

		cout<<"NO\n";

		return;

	}

	if(pnum==1&&snum!=0&&s[n-1]!='p')

	{

		cout<<"NO\n";

		return;

	}

//	cout<<posp<<" "<<poss<<endl;

	cout<<"YES\n";

}

signed main(void)

{

	ios::sync_with_stdio(0);

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

	int t;cin>>t;

	while(t--)

	{

		solve();

	}

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

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

using namespace std;

void solve(void)

{

	int n;cin>>n;

	string s;cin>>s;

	int snum=0,pnum=0;

	bool pj=1;int posp,poss;

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

	{

		if(pj&&s[i]=='p')

		{

			posp=i;

			pj=0;

		}

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

		{

			snum++;

			poss=i;

		}

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

			pnum++;

	} 

	if(snum!=0&&pnum!=0&&posp<poss)

	{

		cout<<"NO\n";

		return ;

	}

	if(snum>1&&pnum>1)

	{

		cout<<"NO\n";

		return;

	}

	if(snum==1&&pnum==1&&(s[0]!='s'||s[n-1]!='p'))

	{

		cout<<"NO\n";

		return;

	}

	if(snum==1&&pnum!=0&&s[0]!='s')

	{

		cout<<"NO\n";

		return;

	}

	if(pnum==1&&snum!=0&&s[n-1]!='p')

	{

		cout<<"NO\n";

		return;

	}

//	cout<<posp<<" "<<poss<<endl;

	cout<<"YES\n";

}

signed main(void)

{

	ios::sync_with_stdio(0);

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

	int t;cin>>t;

	while(t--)

	{

		solve();

	}

}

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

using namespace std;

void solve(void)

{

	int n;cin>>n;

	string s;cin>>s;

	int snum=0,pnum=0;

	bool pj=1;int posp,poss;

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

	{

		if(pj&&s[i]=='p')

		{

			posp=i;

			pj=0;

		}

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

		{

			snum++;

			poss=i;

		}

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

			pnum++;

	} 

	if(snum!=0&&pnum!=0&&posp<poss)

	{

		cout<<"NO\n";

		return ;

	}

	if(snum>1&&pnum>1)

	{

		cout<<"NO\n";

		return;

	}

	if(snum==1&&pnum==1&&(s[0]=='s'||s[n-1]=='p'))

	{

		cout<<"YES\n";

		return;

	}

	if(snum==1&&pnum!=0&&s[0]!='s')

	{

		cout<<"NO\n";

		return;

	}

	if(pnum==1&&snum!=0&&s[n-1]!='p')

	{

		cout<<"NO\n";

		return;

	}

//	cout<<posp<<" "<<poss<<endl;

	cout<<"YES\n";

}

signed main(void)

{

	ios::sync_with_stdio(0);

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

	int t;cin>>t;

	while(t--)

	{

		solve();

	}

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

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

using namespace std;

void solve(void)

{

	int n;cin>>n;

	string s;cin>>s;

	int snum=0,pnum=0;

	bool pj=1;int posp,poss;

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

	{

		if(pj&&s[i]=='p')

		{

			posp=i;

			pj=0;

		}

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

		{

			snum++;

			poss=i;

		}

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

			pnum++;

	} 

	if(snum!=0&&pnum!=0&&posp<poss)

	{

		cout<<"NO\n";

		return ;

	}

	if(snum>1&&pnum>1)

	{

		cout<<"NO\n";

		return;

	}

	if(snum==1&&pnum==1&&s[0]!='s'&&s[n-1]!='p')

	{

		cout<<"NO\n";

		return;

	}

	if(snum==1&&pnum!=0&&s[0]!='s')

	{

		cout<<"NO\n";

		return;

	}

	if(pnum==1&&snum!=0&&s[n-1]!='p')

	{

		cout<<"NO\n";

		return;

	}

//	cout<<posp<<" "<<poss<<endl;

	cout<<"YES\n";

}

signed main(void)

{

	ios::sync_with_stdio(0);

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

	int t;cin>>t;

	while(t--)

	{

		solve();

	}

}

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

using namespace std;

void solve(void)

{

	int n;cin>>n;

	string s;cin>>s;

	int snum=0,pnum=0;

	bool pj=1;int posp,poss;

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

	{

		if(pj&&s[i]=='p')

		{

			posp=i;

			pj=0;

		}

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

		{

			snum++;

			poss=i;

		}

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

			pnum++;

	} 

	if(snum!=0&&pnum!=0&&posp<poss)

	{

		cout<<"NO\n";

		return ;

	}

	if(snum>1&&pnum>1)

	{

		cout<<"NO\n";

		return;

	}

	if(snum==1&&pnum==1&&(s[0]!='s'||s[n-1]!='p'))

	{

		cout<<"NO\n";

		return;

	}

	if(snum==1&&pnum!=0&&s[0]!='s')

	{

		cout<<"NO\n";

		return;

	}

	if(pnum==1&&snum!=0&&s[n-1]!='p')

	{

		cout<<"NO\n";

		return;

	}

//	cout<<posp<<" "<<poss<<endl;

	cout<<"YES\n";

}

signed main(void)

{

	ios::sync_with_stdio(0);

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

	int t;cin>>t;

	while(t--)

	{

		solve();

	}

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


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

using namespace std;

void solve(void)

{

	int n;cin>>n;

	string s;cin>>s;

	int snum=0,pnum=0;

	bool pj=1;int posp,poss;

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

	{

		if(pj&&s[i]=='p')

		{

			posp=i;

			pj=0;

		}

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

		{

			snum++;

			poss=i;

		}

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

			pnum++;

	} 

	if(snum!=0&&pnum!=0&&posp<poss)

	{

		cout<<"NO\n";

		return ;

	}

	if(snum>1&&pnum>1)

	{

		cout<<"NO\n";

		return;

	}

	if(snum!=0&&pnum!=0&&s[0]!='s'&&s[n-1]!='p')

	{

		cout<<"NO\n";

		return;

	}

//	cout<<posp<<" "<<poss<<endl;

	cout<<"YES\n";

}

signed main(void)

{

	ios::sync_with_stdio(0);

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

	int t;cin>>t;

	while(t--)

	{

		solve();

	}

}