ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: Java 21

Previous submission (verdict: Time limit exceeded on test 7):
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc=new Scanner(System.in);

        int t=sc.nextInt();

        while(t-- >0){

          String str=sc.next();

          int n=str.length(); 

          int arr[]=new int[n];

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

              arr[i]=str.charAt(i)-'0';

          }

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

              int idx=i;

              while(idx>=1&&arr[idx]>0&&arr[idx]>arr[idx-1]+1){

                  int temp=arr[idx];

                  arr[idx]=arr[idx-1];

                  arr[idx-1]=temp-1;

                  if(idx>1){

                      idx--;

                  }else{

                      break;

                  }

              }

          }

          String s="";

          for(int a: arr){

              s+=a;

          }

          System.out.println(s);

        }

    }

}

Submission (verdict: Accepted):
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();

        while (t-- > 0) {

            String str = sc.next();

            int n = str.length();

            int arr[] = new int[n];



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

                arr[i] = str.charAt(i) - '0';

            }

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

                int idx = i;

                while (idx >= 1 && arr[idx] > 0 && arr[idx] > arr[idx - 1] + 1) {

                    int temp = arr[idx];

                    arr[idx] = arr[idx - 1];

                    arr[idx - 1] = temp - 1;

                    idx--; 

                }

            }

            StringBuilder sb = new StringBuilder(n);

            for (int a : arr) {

                sb.append(a);

            }

            System.out.println(sb);

        }

    }

}
Problem: 2050D - Digital string maximization
Language: Java 21


Submission (verdict: Time limit exceeded on test 7):
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc=new Scanner(System.in);

        int t=sc.nextInt();

        while(t-- >0){

          String str=sc.next();

          int n=str.length(); 

          int arr[]=new int[n];

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

              arr[i]=str.charAt(i)-'0';

          }

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

              int idx=i;

              while(arr[idx]>0 && arr[idx]>arr[idx-1]+1){

                  int temp=arr[idx];

                  arr[idx]=arr[idx-1];

                  arr[idx-1]=temp-1;

                  if(idx>1){

                      idx--;

                  }else{

                      break;

                  }

              }

          }

          String s="";

          for(int a: arr){

              s+=a;

          }

          System.out.println(s);

        }

    }

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


int main() {
	long long q, x , y, z;
	cin >> q;
	while(q--){
		cin >> x;
		int a[x], ans[x] = {0}, k = 0;
		for(int i = 0; i < x; i++){
			cin >> a[i];
			ans[k] += a[i];
		}
		k++;
		vector <int> j;
		for(int i = 1; i < x; i++)
			j.push_back(a[i] - a[i - 1]);
		for(int i = 0; i < x - 2; i++){
			ans[k] = j[j.size() - 1] - j[0];
			k++;
			vector <int> w;
			for(int i = 0; i < j.size(); i++)
				w.push_back(j[i]);
			j.clear();
			for(int i = 1; i < w.size(); i++)
				j.push_back(w[i] - w[i - 1]);
		}
		if(j.size())
			ans[k] = j[0];
		int m = INT_MIN;
		for(int i = 1; i < x; i++)
			if(abs(ans[i]) > m)
				m = abs(ans[i]);
		if(ans[0] > m)
			m = ans[0];
		cout << m << "\n";
	}
}

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


int main() {
	long long q, x , y, z;
	cin >> q;
	while(q--){
		cin >> x;
		long long a[x], ans[x] = {0}, k = 0;
		for(int i = 0; i < x; i++){
			cin >> a[i];
			ans[k] += a[i];
		}
		k++;
		vector <long long> j;
		for(int i = 1; i < x; i++)
			j.push_back(a[i] - a[i - 1]);
		for(int i = 0; i < x - 2; i++){
			ans[k] = j[j.size() - 1] - j[0];
			k++;
			vector <long long> w;
			for(int i = 0; i < j.size(); i++)
				w.push_back(j[i]);
			j.clear();
			for(int i = 1; i < w.size(); i++)
				j.push_back(w[i] - w[i - 1]);
		}
		if(j.size())
			ans[k] = j[0];
		long long m = LONG_LONG_MIN;
		for(int i = 1; i < x; i++)
			if(abs(ans[i]) > m)
				m = abs(ans[i]);
		if(ans[0] > m)
			m = ans[0];
		cout << m << "\n";
	}
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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


int main() {
	long long q, x , y, z;
	cin >> q;
	while(q--){
		cin >> x;
		long long a[x], ans[x] = {0}, k = 0;
		for(int i = 0; i < x; i++){
			cin >> a[i];
			ans[k] += a[i];
		}
		k++;
		vector <long long> j;
		for(int i = 1; i < x; i++)
			j.push_back(a[i] - a[i - 1]);
		for(int i = 0; i < x - 2; i++){
			ans[k] = j[j.size() - 1] - j[0];
			k++;
			vector <long long> w;
			for(int i = 0; i < j.size(); i++)
				w.push_back(j[i]);
			j.clear();
			for(int i = 1; i < w.size(); i++)
				j.push_back(w[i] - w[i - 1]);
		}
		if(j.size())
			ans[k] = j[0];
		long long m = LONG_LONG_MIN;
		for(int i = 1; i < x; i++)
			if(abs(ans[i]) > m)
				m = abs(ans[i]);
		if(ans[0] > m)
			m = ans[0];
		cout << m << "\n";
	}
}

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


int main() {
	long long q, x , y, z;
	cin >> q;
	while(q--){
		cin >> x;
		long long a[x], ans[x] = {0}, k = 0;
		for(int i = 0; i < x; i++){
			cin >> a[i];
			ans[k] += a[i];
		}
		k++;
		vector <long long> j;
		for(int i = 0; i < x; i++)
			j.push_back(a[i]);
		for(int i = 0; i < x - 1; i++){
			ans[k] = j[j.size() - 1] - j[0];
			k++;
			vector <long long> w;
			for(int u = 0; u < j.size(); u++)
				w.push_back(j[u]);
			j.clear();
			for(int u = 1; u < w.size(); u++)
				j.push_back(w[u] - w[u - 1]);
		}
		if(j.size())
			ans[k] = j[0];
		long long m = LONG_LONG_MIN;
		for(int i = 1; i < x; i++){
			if(abs(ans[i]) > m)
				m = abs(ans[i]);
			//cout << ans[i] << ' ';
		}
		if(ans[0] > m)
			m = ans[0];
		cout << m << "\n";
	}
}
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;


int main() {
	long long q, x , y, z;
	cin >> q;
	while(q--){
		cin >> x;
		int a[x], ans[x] = {0}, k = 0;
		for(int i = 0; i < x; i++){
			cin >> a[i];
			ans[k] += a[i];
		}
		k++;
		vector <int> j;
		for(int i = 1; i < x; i++)
			j.push_back(a[i] - a[i - 1]);
		for(int i = 0; i < x - 2; i++){
			ans[k] = j[j.size() - 1] - j[0];
			k++;
			vector <int> w;
			for(int i = 0; i < j.size(); i++)
				w.push_back(j[i]);
			j.clear();
			for(int i = 1; i < w.size(); i++)
				j.push_back(w[i] - w[i - 1]);
		}
		if(j.size())
			ans[k] = j[0];
		int m = INT_MIN;
		for(int i = 1; i < x; i++)
			if(abs(ans[i]) > m)
				m = abs(ans[i]);
		if(ans[0] > m)
			m = ans[0];
		cout << m << "\n";
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

int main() {

  int t;

  cin >> t;

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

    int n, x;

    cin >> n;

    vector<int> a;

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

      cin >> x;

      a.push_back(x);

    }



    while (a.size() != 2) {

      if (a[0] > a[1]) {

        cout << "NO" << endl;

        break;

      } else if (a[0] < a[1]) {

        a[1] = a[1] - a[0];

        a.erase(a.begin());

      } else {

        a.erase(a.begin());

        a.erase(a.begin());

      }

    }

    if (a.size() == 1) cout << "YES" << endl;

    if (a.size() == 2) {

      if (a[0] > a[1])

        cout << "NO" << endl;

      else

        cout << "YES" << endl;

    }

  }

}

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

using namespace std;

int main() {

  int t;

  cin >> t;

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

    int n;

    cin >> n;

    vector<int> a(n);

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

      cin >> a[j];

    }



    while (a.size() != 2) {

      if (a[0] > a[1]) {

        cout << "NO" << endl;

        break;

      } else if (a[0] < a[1]) {

        a[1] = a[1] - a[0];

        a.erase(a.begin());

      } else {

        a.erase(a.begin());

        a.erase(a.begin());

      }

    }

    if (a.size() == 1) cout << "YES" << endl;

    if (a.size() == 2) {

      if (a[0] > a[1])

        cout << "NO" << endl;

      else

        cout << "YES" << endl;

    }

  }

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

int main() {

  int t;

  cin >> t;

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

    int n, x;

    cin >> n;

    vector<int> a;

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

      cin >> x;

      a.push_back(x);

    }



    while (a.size() != 2) {

      if (a[0] > a[1]) {

        cout << "NO" << endl;

        break;

      } else if (a[0] < a[1]) {

        a[1] = a[1] - a[0];

        a.erase(a.begin());

      } else {

        a.erase(a.begin());

        a.erase(a.begin());

      }

    }

    if (a.size() == 1) cout << "YES" << endl;

    if (a.size() == 2) {

      if (a[0] > a[1])

        cout << "NO" << endl;

      else

        cout << "YES" << endl;

    }

  }

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

int main() {

  int t;

  cin >> t;

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

    int n, done, v = 0;

    cin >> n;

    vector<int> a(n);

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

      cin >> a[j];

    }

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

      if (a[j] <= a[j + 1]) {

        a[j + 1] -= a[j];

        a[j] = 0;

      }

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

        if (a[k] < a[k + 1]) {

          done = 0;

          break;

        }

        if (a[k] > a[k + 1]) {

          done = 1;

          break;

        }

      }

      if (done == 1) {

        v = 1;

        cout << "NO" << endl;

        break;

      }

    }

    if (v == 0) cout << "YES" << endl;

  }

}



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

using namespace std;

int main() {

  int t;

  cin >> t;

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

    int n, done, v = 0;

    cin >> n;

    vector<int> a(n);

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

      cin >> a[j];

    }

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

      if (a[j] <= a[j + 1] && a[j] != 0) {

        a[j + 1] -= a[j];

        a[j] = 0;

      } else if (a[j] != 0) {

        v = 1;

        cout << "NO" << endl;

        break;

      }

    }

    if (v == 0) cout << "YES" << endl;

  }

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

int main() {

  int t;

  cin >> t;

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

    int n;

    cin >> n;

    vector<int> a(n);

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

      cin >> a[j];

    }



    while (a.size() != 2) {

      if (a[0] > a[1]) {

        cout << "NO" << endl;

        break;

      } else if (a[0] < a[1]) {

        a[1] = a[1] - a[0];

        a.erase(a.begin());

      } else {

        a.erase(a.begin());

        a.erase(a.begin());

      }

    }

    if (a.size() == 1) cout << "YES" << endl;

    if (a.size() == 2) {

      if (a[0] > a[1])

        cout << "NO" << endl;

      else

        cout << "YES" << endl;

    }

  }

}

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

using namespace std;

int main() {

  int t;

  cin >> t;

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

    int n, done, v = 0;

    cin >> n;

    vector<int> a(n);

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

      cin >> a[j];

    }

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

      if (a[j] <= a[j + 1]) {

        a[j + 1] -= a[j];

        a[j] = 0;

      }

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

        if (a[k] < a[k + 1]) {

          done = 0;

          break;

        }

        if (a[k] > a[k + 1]) {

          done = 1;

          break;

        }

      }

      if (done == 1) {

        v = 1;

        cout << "NO" << endl;

        break;

      }

    }

    if (v == 0) cout << "YES" << endl;

  }

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


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

using namespace std;

int main(){

	int t;

	cin>>t;

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

		int n,l,r;

		int ar1[n];

		cin>>n>>l>>r;

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

	    	cin>>ar1[i];

	    }

	    vector<int>v,b;

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

	    	v.push_back(ar1[i]);

	    }

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

	    	b.push_back(ar1[i]);

	    }

	    sort(v.begin(),v.end());

	    sort(b.begin(),b.end());

	    int sum1=0,sum2=0;

	    for(int i=0;i<=r-l;i++){

	    	sum1=sum1+v[i];

	    	sum2=sum2+b[i];

	    }

	    cout<<min(sum1,sum2)<<endl;

	}

	return 0;

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

using namespace std;

int main(){

	int t;

	cin>>t;

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

		long long int n,l,r;

		long long int ar1[n];

		cin>>n>>l>>r;

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

	    	cin>>ar1[i];

	    }

	    vector<long long int>v,b;

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

	    	v.push_back(ar1[i]);

	    }

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

	    	b.push_back(ar1[i]);

	    }

	    sort(v.begin(),v.end());

	    sort(b.begin(),b.end());

	    long long int sum1=0,sum2=0;

	    for(int i=0;i<=r-l;i++){

	    	sum1=sum1+v[i];

	    	sum2=sum2+b[i];

	    }

	    cout<<min(sum1,sum2)<<endl;

	}

	return 0;

}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	cin>>t;
	for(int i=0;i<t;i++){
		long long int n,l,r;
		cin>>n>>l>>r;
		long long int ar1[n];
	    for(int i=0;i<n;i++){
	    	cin>>ar1[i];
	    }
	    vector<long long int>v,b;
	    for(int i=0;i<r;i++){
	    	v.push_back(ar1[i]);
	    }
	    for(int i=l-1;i<n;i++){
	    	b.push_back(ar1[i]);
	    }
	    sort(v.begin(),v.end());
	    sort(b.begin(),b.end());
	    long long int sum1=0,sum2=0;
	    for(int i=0;i<r-l+1;i++){
	    	sum1=sum1+v[i];
	    	sum2=sum2+b[i];
	    }
	    cout<<min(sum1,sum2)<<endl;
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

using namespace std;

int main(){

	int t;

	cin>>t;

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

		int n,l,r;

		int ar1[n];

		cin>>n>>l>>r;

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

	    	cin>>ar1[i];

	    }

	    vector<int>v,b;

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

	    	v.push_back(ar1[i]);

	    }

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

	    	b.push_back(ar1[i]);

	    }

	    sort(v.begin(),v.end());

	    sort(b.begin(),b.end());

	    int sum1=0,sum2=0;

	    for(int i=0;i<=r-l;i++){

	    	sum1=sum1+v[i];

	    	sum2=sum2+b[i];

	    }

	    cout<<min(sum1,sum2)<<endl;

	}

	return 0;

}

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

using namespace std;

int main(){

	int t;

	cin>>t;

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

		long long int n,l,r;

		long long int ar1[n];

		cin>>n>>l>>r;

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

	    	cin>>ar1[i];

	    }

	    vector<long long int>v,b;

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

	    	v.push_back(ar1[i]);

	    }

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

	    	b.push_back(ar1[i]);

	    }

	    sort(v.begin(),v.end());

	    sort(b.begin(),b.end());

	    long long int sum1=0,sum2=0;

	    for(int i=0;i<=r-l;i++){

	    	sum1=sum1+v[i];

	    	sum2=sum2+b[i];

	    }

	    cout<<min(sum1,sum2)<<endl;

	}

	return 0;

}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 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;

      for(int i = 1 ; i < n ; i++){
           char c1 = s[i-1];
           int l1,r1 ;
           if(c1 == 'p') {
            l1 = 0 ;
            r1 = i-1;
           }
           else if(c1 == 's') {
            l1 = i-1;
            r1 = n-1;
           }
           else {
            l1 = 0 ;
            r1 = n-1;
           }
           char c2 = s[i];
            int l2,r2 ;
             if(c2 == 'p') {
            l2 = 0 ;
            r2 = i;
           }
           else if(c2 == 's') {
            l2 = i;
            r2 = n-1;
           }
           else {
            l2= 0 ;
            r2 = n-1;
           }
           if(r1 < l2 || (l2 < l1 && r2 < r1)){
              f = 0 ;
              NO;
              return ;
           }

      }
    //   int l = 0 , r = n-1;
    //   while(l < r){
    //     if(s[l] )
    //   }
      YES;

}

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

Submission (verdict: Wrong answer on test 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;

      for(int i = 1 ; i < n ; i++){
           char c1 = s[i-1];
           int l1,r1 ;
           if(c1 == 'p') {
            l1 = 0 ;
            r1 = i-1;
           }
           else if(c1 == 's') {
            l1 = i-1;
            r1 = n-1;
           }
           else {
            l1 = 0 ;
            r1 = n-1;
           }
           char c2 = s[i];
            int l2,r2 ;
             if(c2 == 'p') {
            l2 = 0 ;
            r2 = i;
           }
           else if(c2 == 's') {
            l2 = i;
            r2 = n-1;
           }
           else {
            l2= 0 ;
            r2 = n-1;
           }
           if(c1 == 'p' && c2 == 's' && r1 < l2 ){
              f = 0 ;
              NO;
              return ;
           }
           if(c1 == 's' && c2 == 'p' && l2 < l1 && r2 <r1){
               f = 0;
               NO;
               return;
           }

      }
    //   int l = 0 , r = n-1;
    //   while(l < r){
    //     if(s[l] )
    //   }
      YES;

}

int main(){
   fast_io;
    int t ;
    cin>>t ;
    while(t--){
      akibify();
        
    }
 
 
    return 0;
}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 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;

      for(int i = 1 ; i < n ; i++){
           char c1 = s[i-1];
           int l1,r1 ;
           if(c1 == 'p') {
            l1 = 0 ;
            r1 = i-1;
           }
           else if(c1 == 's') {
            l1 = i-1;
            r1 = n-1;
           }
           else {
            l1 = 0 ;
            r1 = n-1;
           }
           char c2 = s[i];
            int l2,r2 ;
             if(c2 == 'p') {
            l2 = 0 ;
            r2 = i;
           }
           else if(c2 == 's') {
            l2 = i;
            r2 = n-1;
           }
           else {
            l2= 0 ;
            r2 = n-1;
           }
           if(c1 == 'p' && c2 == 's' && r1 < l2 ){
              f = 0 ;
              NO;
              return ;
           }
           if(c1 == 's' && c2 == 'p' && l2 < l1 && r2 <r1){
               f = 0;
               NO;
               return;
           }

      }
    //   int l = 0 , r = n-1;
    //   while(l < r){
    //     if(s[l] )
    //   }
      YES;

}

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

Submission (verdict: Wrong answer on test 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;
}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 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;
}

Submission (verdict: Wrong answer on test 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 slast = -1;
      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['.'] == n || m['p'] == n ){
        YES;
        return;
       }
       if(slast == 0 || pfirst == n-1){
        YES;
        return;
       }
       NO;
      

      }

    



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