ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049B - pspspsps
Language: python

Code 1:
def solve():

    n=int(input())

    s=input()



    cnt_s=0

    cnt_p=0

    cnt=0

    bol=False

    b=False

    for i in range(n):

        if s[i]=='s':

            cnt_s+=1

            if bol:

                b=True

        elif s[i]=='p':

            bol=True

            cnt_p+=1

        else:

            cnt+=1



    if b:

        print("NO")

        return



    if cnt_s==n or cnt_p==n or cnt==n or cnt+cnt_p==n or cnt+cnt_p==n:

        print("YES")

        return



    if s[n-1]=='.' and s[0]=='.':

        print("NO")

        return



    if cnt_p==1 and cnt_s==1:

        print("YES")

        return

    elif cnt_p==1:

        if s[n-1]=='p':

            print("YES")

        else:

            print("NO")

    elif cnt_s==1:

        if s[0]=='s':

            print("YES")

        else:

            print("NO")

    else:

        print("NO")



t=int(input())



for _ in range(t):

    solve()

Code 2:
def solve():

    n=int(input())

    s=input()



    cnt_s=0

    cnt_p=0

    cnt=0

    bol=False

    b=False

    for i in range(n):

        if s[i]=='s':

            cnt_s+=1

            if bol:

                b=True

        elif s[i]=='p':

            bol=True

            cnt_p+=1

        else:

            cnt+=1



    if b:

        print("NO")

        return



    if cnt_s==n or cnt_p==n or cnt==n or cnt+cnt_p==n or cnt+cnt_s==n:

        print("YES")

        return



    if s[n-1]=='.' and s[0]=='.':

        print("NO")

        return



    if cnt_p==1 and cnt_s==1:

        print("YES")

        return

    elif cnt_p==1:

        if s[n-1]=='p':

            print("YES")

        else:

            print("NO")

    elif cnt_s==1:

        if s[0]=='s':

            print("YES")

        else:

            print("NO")

    else:

        print("NO")



t=int(input())



for _ in range(t):

    solve()

Answer: 2
Problem: 2049B - pspspsps
Language: c++17 

Code 1:
#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=505;

char s[N];int n;

void work(){

    cin>>n;

    cin>>(s+1);

    int fl=0;int cs=0,cp=0;

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

        if(s[i]=='p'){if(fl==0);cp++;}

        if(s[i]=='s'){if(fl==1)fl++;cs++;}

    }

    if(fl==2){

        cout<<"NO"<<endl;

        return;

    }

    if(cs==0||cp==0||(cp==1&&s[n]=='p')||(cs==1&&s[1]=='s'))

        cout<<"YES"<<endl;

    else cout<<"NO"<<endl;

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}

Code 2:
#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=505;

char s[N];int n;

void work(){

    cin>>n;

    cin>>(s+1);

    int fl=0;int cs=0,cp=0;

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

        if(s[i]=='p')fl++,cp++;

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

            if(fl==1)fl++;

            cs++;

        }

    }

    if(fl==2){

        cout<<"NO"<<endl;

        return;

    }

    if(cs==0||cp==0||(cp==1&&s[n]=='p')||(cs==1&&s[1]=='s')){

        cout<<"YES"<<endl;

    }else cout<<"NO"<<endl;

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}

Answer: 1
Problem: 2049B - pspspsps
Language: c++20 

Code 1:
#include <bits/stdc++.h>



using namespace std;



void solve(){

    int n;

    cin>>n;

    string s;

    cin>>s;

    if(s[0]=='s'){

        s[0]='.';

    }

    if(s[n-1]=='p'){

        s[n-1]='.';

    }

    int cd1=0,cd2=0;

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

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

            cd1=1;

        }

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

            cd2=1;

        }

    }

    if(cd1 && cd2){

        cout<<"NO\n";

        return;

    }

    cout<<"YES\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}

Code 2:
#include <bits/stdc++.h>



using namespace std;



void solve(){

    int n;

    cin>>n;

    string s;

    cin>>s;

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

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

            continue;

        }

        if(s.substr(i,2)=="ps"){

            cout<<"NO\n";

            return;

        }

        if(s.substr(i,2)=="sp" && i+2>=3 &&n-i>=3 ){

            cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}

Answer: 1
Problem: 2049B - pspspsps
Language: c++23 

Code 1:
#include<bits/stdc++.h>

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n,i,j,ok=1;

        cin>>n;

        string s;

        cin>>s;

        for(i=0;i<n-1;i++){

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

                for(j=i+1;j<n;j++){

                    if(s[j]=='s'){

                        ok=0;

                        break;

                    }

                }

                if(ok==0)   break;

            }

            if(i>0 && i<n-2 && s[i]=='s'){

                for(j=i+1;j<n;j++){

                    if(s[j]=='p'){

                        ok=0;

                        break;

                    }

                }

                if(ok==0)   break;

            }

        }

        if(ok==1)   cout<<"YES\n";

        else cout<<"NO\n";

    }

    return 0;

}

Code 2:
#include<bits/stdc++.h>

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n,i,j,ok=1;

        cin>>n;

        string s;

        cin>>s;

        if(s[0]=='s')   s[0]='.';

        if(s[n-1]=='p')   s[n-1]='.';

        for(i=0;i<n-1;i++){

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

                for(j=i+1;j<n;j++){

                    if(s[j]=='s'){

                        ok=0;

                        break;

                    }

                }

                if(ok==0)   break;

            }

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

                for(j=i+1;j<n;j++){

                    if(s[j]=='p'){

                        ok=0;

                        break;

                    }

                }

                if(ok==0)   break;

            }

        }

        if(ok==1)   cout<<"YES\n";

        else cout<<"NO\n";

    }

    return 0;

}

Answer: 2
Problem: 2049B - pspspsps
Language: c++23 

Code 1:
#include<bits/stdc++.h>

#define ll long long

#define PII pair<int,int>

using namespace std;



void solve()

{

    int n;

    cin>>n;

    string s;

    cin>>s;

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

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

            cout<<"NO\n";

            return;

        }

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

            cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    int t;

    cin>>t;

    while(t--){

        solve();

    }

    return 0;

}

Code 2:
#include<bits/stdc++.h>

#define ll long long

#define PII pair<int,int>

using namespace std;



void solve()

{

    int n;

    cin>>n;

    string s;

    cin>>s;

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

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

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

                if(s[j]=='s'){

                    cout<<"NO\n";

                    return;

                }

            }

        }

        if(s[i]=='s' && i!=0){

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

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

                    cout<<"NO\n";

                    return;

                }

            }

        }

    }

    cout<<"YES\n";

}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    int t;

    cin>>t;

    while(t--){

        solve();

    }

    return 0;

}

Answer: 2
Problem: 2049B - pspspsps
Language: c++20 

Code 1:
#include"bits/stdc++.h"
using namespace std;
 
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
 
typedef long long ll;
const int MOD = 1000000007;
const int Nmax = 2e5+5;

void akibify(){ 

      int n ;cin>>n ;
      string s ;
      cin>>s;bool f = 1;
      map<char,int>m ;
      int slast = 0;
      int pfirst = -1 ;
       for(int i = 0 ; i < n ; i++){
            m[s[i]]++;
            if(s[i] == 's'){
                slast = i ;
            }
            if(s[i] == 'p' && pfirst == -1){
                pfirst = i ;  
            }
       }
       if(m['p'] == 0 || m['s'] == 0){
        YES;
        return;
       }
       if(slast == 0 || pfirst == n-1){
        YES;
        return;
       }
       NO;
      

      }

    



int main(){
   fast_io;
    int t ;
    cin>>t ;
    while(t--){
      akibify();
        
    }
 
 
    return 0;
}

Code 2:
#include"bits/stdc++.h"
using namespace std;
 
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
 
typedef long long ll;
const int MOD = 1000000007;
const int Nmax = 2e5+5;

void akibify(){ 

      int n ;cin>>n ;
      string s ;
      cin>>s;bool f = 1;
      map<char,int>m ;
      int plast = -1;
      int sfirst = -1 ;
       for(int i = 0 ; i < n ; i++){
            m[s[i]]++;
            if(s[i] == 's' && sfirst == -1){
                sfirst = i ;
            }
            if(s[i] == 'p'){
                plast = i ;  
            }
       }
       if(m['.'] == n || m['p'] == n || m['s'] == n){
        YES;
        return;
       }
       if(sfirst == 0 || plast == n-1){
        YES;
        return;
       }
       NO;
      

      }

    



int main(){
   fast_io;
    int t ;
    cin>>t ;
    while(t--){
      akibify();
        
    }
 
 
    return 0;
}

Answer: 1
Problem: 2049B - pspspsps
Language: c++17 

Code 1:
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define pair pair<ll,ll>

ll n,m,say1,say2,cem=0;

int main()

{

    cin>>n;

    string s;

    while(n--)

    {

      cin>>m;

      cin>>s;

      say1=0;

      say2=0;

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

      {

        cout<<"yes"<<endl;

        continue;

      }

      for(int i=0;i<s.size();i++)

      {

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

        say1++;

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

        say2++;

      }

      if(say2==0)

      {

        cout<<"yes"<<endl;

        continue;

      }

      if(s[0]=='.' and say1==0)

      {

        cout<<"yes"<<endl;

        continue;

      }

     else

      cout<<"no"<<endl;

    }

}

Code 2:
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define pair pair<ll,ll>

ll n,m,say1,say2,cem=0;

int main()

{

    cin>>n;

    string s;

    while(n--)

    {

      cin>>m;

      cin>>s;

      say1=0;

      say2=0;

      bool b=0,b1=0;

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

      {

        s[0]='.';

      }

      if(s[m-1]=='p')

      s[m-1]='.';

      for(int i=0;i<s.size();i++)

      {

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

        b=1;

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

        b1=1;

      }

      if(b1 and b)

      cout<<"no"<<endl;

      else cout<<"yes"<<endl;

    }

}

Answer: 2
Problem: 2049B - pspspsps
Language: c++17 

Code 1:
#include <bits/stdc++.h>
#define pb push_back
#define endl ("\n")
#define all(aa) aa.begin(), aa.end()
typedef long long ll;
using namespace std;

void solve(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	array<int, 2> cnt = {0, 0};
	for(int i = 0; i < n; i++){
		if(s[i] == 's') cnt[0]++;
		if(s[i] == 'p') cnt[1]++;
	}
	if(cnt[0] >= 2 && cnt[1] >= 2){
		cout << "No" << endl;
		return;
	}
	if(cnt[0] == 0 || cnt[1] == 0){
		cout << "Yes" << endl;
		return;
	}
	if(cnt[0] == 1 && s[0] == 's'){
		cout << "Yes" << endl;
		return;
	}
	if(cnt[1] == 1 && s[n - 1] == 'p'){
		cout << "Yes" << endl;
		return;
	}
	cout << "No" << endl;
}

int main(){
	int tt;
	cin >> tt;
	while(tt--){
		solve();
	}
}



Code 2:
#include <bits/stdc++.h>
#define pb push_back
#define endl ("\n")
#define all(aa) aa.begin(), aa.end()
typedef long long ll;
using namespace std;

void solve(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> a(n), b(n, n - 1);
	for(int i = 0; i < n; i++){
		if(i) a[i] = a[i - 1];
		if(s[i] == 's') a[i] = i;
	}
	for(int i = n - 1; i >= 0; i--){
		if(i + 1 < n) b[i] = b[i + 1];
		if(s[i] == 'p') b[i] = i;
	}
	bool ok = 1;
	for(int i = 0; i < n; i++){
		ok &= a[i] <= b[i];
	}
	cout << (ok ? "Yes" : "No") << endl;
}

int main(){
	int tt;
	cin >> tt;
	while(tt--){
		solve();
	}
}



Answer: 1
Problem: 2049B - pspspsps
Language: c++20 

Code 1:
#include <bits/stdc++.h>

using namespace std;



int main() {

	// your code goes here

	

	int T;

	cin>>T;

	

	while(T--){

	    int n;

	    cin>>n;

	    

	    string s;

	    cin>>s;

	    int cntp=0;

	    int cnts=0;

	    

	    for(int i=0; i<s.size(); i++){

	        if(s[i]=='p') cntp++;

	        else if(s[i]=='s') cnts++;

	    }

	    

	    if(cnts==0 || cntp==0){

	        cout<<"Yes"<<endl;

	        continue;

	    }

	    

	    if(cntp>0 && cnts>0){

	        if(cntp==1 && s[s.size()-1]=='p'){

	            cout<<"Yes"<<endl;

	        }

	        else{

	            cout<<"No"<<endl;

	        }

	        continue;

	    }

	    

	}



}



Code 2:
#include <bits/stdc++.h>

using namespace std;



int main() {

	// your code goes here

	

	int T;

	cin>>T;

	

	while(T--){

	    int n;

	    cin>>n;

	    

	    string s;

	    cin>>s;

	    int cntp=0;

	    int cnts=0;

	    

	    for(int i=0; i<s.size(); i++){

	        if(s[i]=='p') cntp++;

	        else if(s[i]=='s') cnts++;

	    }

	    

	    if(cnts==0 || cntp==0){

	        cout<<"Yes"<<endl;

	        continue;

	    }

	    

	    if(cntp>0 && cnts>0){

	        if(cntp==1 && s[s.size()-1]=='p'|| cnts==1 && s[0]=='s'){

	            cout<<"Yes"<<endl;

	        }

	        else{

	            cout<<"No"<<endl;

	        }

	        continue;

	    }

	    

	}



}



Answer: 2
Problem: 2049B - pspspsps
Language: python

Code 1:
a = int(input())

for y in range(a):

  b = int(input())

  c = input()

  k = 0

  for z in range(b):

    if c[z] == "p" and k == 0:

      k = 1

      

    elif k == 1 and c[z] == "s":

      k = -1

      break

    

  if k != -1:

    n = c[0]

    for y in range(1,b):

      if c[y-1] != c[y]:

        n += c[y]

        

        

    if ".sp." in n:

      print("No")

      

    else:

      print("Yes")

        

  elif k == -1:

    print("No")

    

      

Code 2:
a = int(input())

for y in range(a):

  b = int(input())

  c = input()

  j = list(c)

  

  if j[0] == "s":

    j[0] = "."

    

  if j[-1] == "p":

    j[-1] = "."

    

  l = 0

  if "s" in j and "p" in j:

    l = -1

    

    

  print("Yes") if l == 0 else print("No")

    

Answer: 2
Problem: 2049B - pspspsps
Language: c++17 

Code 1:
#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; 

} 

Code 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; 

} 

Answer: 1
Problem: 2049B - pspspsps
Language: c++20 

Code 1:
#include <bits/stdc++.h>



using namespace std;



#define ll long long

#define ld long double

#define mp make_pair

#define F first 

#define S second

#define pb push_back

#define upb upper_bound

#define lwb lower_bound



const int maxn = 512;

int n;

char s[maxn];



void clear_array() {

    fill(s, s + 3 + n, 0);

    n = 0;

}



void solve() {

    cin >> n;

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

        cin >> s[i];

    }

    int l = -1;

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

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

            l = i;

            break;

        }

    }

    int r = -1;

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

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

            r = i;

            break;

        }

    }

    if (l == -1 || r == -1) {

        cout << "YES\n";

        return;

    }

    if (l < r) {

        cout << "NO\n";

        return;

    }

    int pos1 = (n / 2);

    int pos2 = (n + 3) / 2;

    while (pos1 > 1 && pos2 < n) {

        if (s[pos1] == 's' && s[pos2] == 'p') {

            cout << "NO\n";

            return;

        }

        pos1--;

        pos2++;

    }

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

        for (int j = 2; j < i; j++) {

            if (s[i] == 'p' && s[j] == 's') {

                cout << "NO\n";

                return;

            }

        }

    }

    cout << "YES\n";

}



void boost() {

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

    ios_base :: sync_with_stdio(false);

}



int main() {

    boost();

    int TT;

    cin >> TT;

    while (TT--) {

        solve();

    }

    return 0;

}

Code 2:
#include <bits/stdc++.h>



using namespace std;



#define ll long long

#define ld long double

#define mp make_pair

#define F first 

#define S second

#define pb push_back

#define upb upper_bound

#define lwb lower_bound



const int maxn = 512;

int n;

char s[maxn];



void clear_array() {

    fill(s, s + 3 + n, 0);

    n = 0;

}



void solve() {

    cin >> n;

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

        cin >> s[i];

    }

    int l = -1;

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

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

            l = i;

            break;

        }

    }

    int r = -1;

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

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

            r = i;

            break;

        }

    }

    if (l == -1 || r == -1) {

        cout << "YES\n";

        return;

    }

    if (l < r) {

        cout << "NO\n";

        return;

    }

    int pos1 = (n / 2);

    int pos2 = (n + 3) / 2;

    while (pos1 > 1 && pos2 < n) {

        if (s[pos1] == 's' && s[pos2] == 'p') {

            cout << "NO\n";

            return;

        }

        pos1--;

        pos2++;

    }

    cout << "YES\n";

}



void boost() {

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

    ios_base :: sync_with_stdio(false);

}



int main() {

    boost();

    int TT;

    cin >> TT;

    while (TT--) {

        solve();

    }

    return 0;

}

Answer: 1
Problem: 2049B - pspspsps
Language: python

Code 1:
from collections import defaultdict, deque
from bisect import bisect_right, bisect_left
from math import inf, isqrt, sqrt, gcd, factorial, ceil
from itertools import permutations

mod = 10**9 + 7

def main():
    for _ in range(int(input())):
        solve()

#     solve()
def solve():

    n = int(input())
    s = input()
    p_found = False
    for i in range(n):
        if s[i] == "p":
            p_found = True
        if p_found and s[i] == "s":
            print("NO")
            return
    a = 0
    while True:
        try:
            a = s.index("sp",a)
            if a-1>=0 and a+2<n:
                print("NO")
                return
            a+=1
        except:
            break
    print("YES")




main()



Code 2:
from collections import defaultdict, deque
from bisect import bisect_right, bisect_left
from math import inf, isqrt, sqrt, gcd, factorial, ceil
from itertools import permutations

mod = 10**9 + 7

def main():
    for _ in range(int(input())):
        solve()

#     solve()
def solve():

    n = int(input())
    s = list(input())

    s[0] = "." if s[0] == "s" else s[0]
    s[-1] = "." if s[-1] == "p" else s[-1]

    c1 = s.count("s")
    c2 = s.count("p")
    if c1 > 0 and c2 > 0:
        print("NO")
    else:
        print("YES")




main()



Answer: 2
Problem: 2049B - pspspsps
Language: python

Code 1:
a = int(input())

for y in range(a):

  b = int(input())

  c = input()

  j = list(c)

  

  if j[0] == "s":

    j[0] = "."

    

  if j[-1] == "p":

    j[-1] = "."

    

  l = 0

  if "s" in j and "p" in j:

    l = -1

    

    

  print("Yes") if l == 0 else print("No")

    

Code 2:
a = int(input())

for y in range(a):

  b = int(input())

  c = input()

  k = 0

  for z in range(b):

    if c[z] == "p" and k == 0:

      k = 1

      

    elif k == 1 and c[z] == "s":

      k = -1

      break

    

  if k != -1:

    n = c[0]

    for y in range(1,b):

      if c[y-1] != c[y]:

        n += c[y]

        

        

    if ".sp." in n:

      print("No")

      

    else:

      s = 0

      p = 0

      l = 0

      for y in range(b):

        if c[y] == ".":

          if (s > 1 and p > 0):

            l = -1

            break

          

          s = 0

          p = 0

        else:

          if c[y] == "s":

            s += 1

              

          else:

            p += 1

          

        

      s = 0

      p = 0

      for y in range(b-1,-1,-1):

        if c[y] == ".":

          if (p > 1 and s > 0):

            l = -1

            break 

          

          s = 0

          p = 0

          

        else:

          if c[y] == "s":

            s += 1

              

          else:

            p += 1

              

              

           

      if l == -1:

        print("No")

        

      else:

        print("Yes")

          

      

  

  elif k == -1:

    print("No")

    



Answer: 1
Problem: 2049B - pspspsps
Language: c++23 

Code 1:
#include <bits/stdc++.h>



#define endl "\n"



// #define int long long



using namespace std;



using i64 = long long;

using u64 = unsigned long long;



constexpr int N = 2e5 + 1;

constexpr int P = 131;

constexpr int INF = 1e9;



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    s = " " + s;

    int r = INF;

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

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

            r = i;

        }

    }

    bool ok = true;

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

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

            if (n > r) {

                ok = false;

                break;

            }

        }

    }

    if (ok) {

        cout << "YES\n";

    } else {

        cout << "NO\n";

    }

}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    int T;

    cin >> T;

    while (T--) {

        solve();

    }

}





Code 2:
#include <bits/stdc++.h>



#define endl "\n"



// #define int long long



using namespace std;



using i64 = long long;

using u64 = unsigned long long;



constexpr int N = 2e5 + 1;

constexpr int P = 131;

constexpr int INF = 1e9;



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    s = " " + s;

    int r = INF;

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

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

            r = i;

            break;

        }

    }

    bool ok = true;

    for (int i = 2; i <= n; i++) {

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

            if (n > r) {

                ok = false;

                break;

            }

        }

    }

    if (ok) {

        cout << "YES\n";

    } else {

        cout << "NO\n";

    }

}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    int T;

    cin >> T;

    while (T--) {

        solve();

    }

}





Answer: 2