ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050B - Transfusion
Language: Python 3

Previous submission (verdict: Wrong answer on test 1):
def process_array():
    _size = int(input())
    a =list(map(int, input().split()))
    sum1 = 0 
    odd= (_size+1)/2
    sum2 = 0 
    even = _size-odd
    for i in range(_size):
        if i%2==0 :
           sum1+=a[i]
        else :
           sum2+=a[i] 
    if (sum1+sum2)%_size==0 :
       if sum1 == odd*((sum1+sum2)/_size) and sum2== even*((sum1+sum2)/_size):
          print("YES")
          return
    else:
      print("NO")

t = int(input())    
for _ in range(t): 
       process_array()


Submission (verdict: Wrong answer on test 1):
def process_array():
    _size = int(input())
    a =list(map(int, input().split()))
    sum1 = 0 
    odd= (_size+1)/2
    sum2 = 0 
    even = _size-odd
    for i in range(_size):
        if i%2==0 :
           sum1+=a[i]
        else :
           sum2+=a[i] 
    if (sum1+sum2)%_size==0 :
       if sum1 == odd*((sum1+sum2)/_size) and sum2== even*((sum1+sum2)/_size):
          print("YES")
          return
       else:
         print("NO")
         return   
    else:
      print("NO")

t = int(input())    
for _ in range(t): 
       process_array()
Problem: 2050B - Transfusion
Language: Python 3


Submission (verdict: Wrong answer on test 1):
def process_array():
    _size = int(input())
    a =list(map(int, input().split()))
    sum1 = 0 
    odd= (_size+1)/2
    sum2 = 0 
    even = _size-odd
    for i in range(_size):
        if i%2==0 :
           sum1+=a[i]
        else :
           sum2+=a[i] 
    if (sum1+sum2)%_size==0 :
       if sum1 == odd*((sum1+sum2)/_size) and sum2== even*((sum1+sum2)/_size):
          print("YES")
          return
    else:
      print("NO")

t = int(input())    
for _ in range(t): 
       process_array()
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define  int long long int
#define endl "\n"
int findans(vector<int>&v){
        int ans=0;
        int n=v.size();
        for(int i=0;i<n;i++)ans+=v[i];
        while(v.size()!=1){
            vector<int>temp;
            int curr=0;
            for(int i=1;i<v.size();i++){
                temp.push_back(v[i]-v[i-1]);
                curr+=(v[i]-v[i-1]);
            }
            if(v.size()==2)curr=max(curr,abs(v[1]-v[0]));
            ans=max(curr,ans);
            v=temp;
        }
        return ans;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int tt;
    cin>>tt;
    while(tt--){
        int n;
        cin>>n;
        vector<int>v(n),rv;
        for(int i=0;i<n;i++)cin>>v[i];
        int ans=findans(v);
        reverse(v.begin(),v.end());
        ans=max(ans,findans(v));
        cout<<ans<<endl;
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define  int long long int
#define endl "\n"
int findans(vector<int>&v){
        int ans=0;
        int n=v.size();
        for(int i=0;i<n;i++)ans+=v[i];
        while(v.size()!=1){
            vector<int>temp;
            int curr=0;
            for(int i=1;i<v.size();i++){
                temp.push_back(v[i]-v[i-1]);
                curr+=(v[i]-v[i-1]);
            }
            if(v.size()==2)curr=max(curr,abs(v[1]-v[0]));
            ans=max(abs(curr),ans);
            v=temp;
        }
        return ans;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int tt;
    cin>>tt;
    while(tt--){
        int n;
        cin>>n;
        vector<int>v(n),rv;
        for(int i=0;i<n;i++)cin>>v[i];
        int ans=findans(v);
        cout<<ans<<endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define  int long long int
#define endl "\n"
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int tt;
    cin>>tt;
    while(tt--){
        int n;
        cin>>n;
        vector<int>v(n);
        int ans=0;
        for(int i=0;i<n;i++)cin>>v[i],ans+=v[i];
        while(v.size()!=1){
            vector<int>temp;
            int curr=0;
            for(int i=1;i<v.size();i++){
                temp.push_back(v[i]-v[i-1]);
                curr+=(v[i]-v[i-1]);
            }
            if(v.size()==2)curr=max(curr,abs(v[1]-v[0]));
            ans=max(curr,ans);
            v=temp;
        }
        cout<<ans<<endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define  int long long int
#define endl "\n"
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int tt;
    cin>>tt;
    while(tt--){
        int n;
        cin>>n;
        vector<int>v(n);
        int ans=0;
        for(int i=0;i<n;i++)cin>>v[i],ans+=v[i];
        while(v.size()!=1){
            vector<int>temp;
            int curr=0;
            for(int i=1;i<v.size();i++){
                temp.push_back(v[i]-v[i-1]);
                curr+=(v[i]-v[i-1]);
            }
            if(v.size()==2)curr=max(curr,abs(v[1]-v[0]));
            ans=max(curr,ans);
            v=temp;
        }
        cout<<ans<<endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define  int long long int
#define endl "\n"
int findans(vector<int>&v){
        int ans=0;
        int n=v.size();
        for(int i=0;i<n;i++)ans+=v[i];
        while(v.size()!=1){
            vector<int>temp;
            int curr=0;
            for(int i=1;i<v.size();i++){
                temp.push_back(v[i]-v[i-1]);
                curr+=(v[i]-v[i-1]);
            }
            if(v.size()==2)curr=max(curr,abs(v[1]-v[0]));
            ans=max(curr,ans);
            v=temp;
        }
        return ans;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int tt;
    cin>>tt;
    while(tt--){
        int n;
        cin>>n;
        vector<int>v(n),rv;
        for(int i=0;i<n;i++)cin>>v[i];
        int ans=findans(v);
        reverse(v.begin(),v.end());
        ans=max(ans,findans(v));
        cout<<ans<<endl;
    }
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

 
int main(){

    int t;
    cin >> t;

    while(t--){
        int n,l,r;
        cin >> n >> l >>r;
        vector<int> v(n, 0);
        for (int i = 0; i < n;i++){ 
        cin >> v[i];
        }

        sort(v.begin(), v.end());
        int sum = 0;
        for (int i = 0; i < (r - l + 1);i++){
            sum += v[i];
        }
        cout << sum << endl;
    }
}
Problem: 2063B - Subsequence Update
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,l,r;
        cin >> n >> l >>r;
        vector<int> v(n, 0);
        for (int i = 0; i < n;i++){ 
        cin >> v[i];
        }
        vector<int> v2 = v;
        vector<int> v3 = v;
        sort(v2.begin(), v2.begin() + (r+1) );
        sort(v3.begin() +l-1, v3.end()  );
        int sum1 = 0;
        for (int i = 0; i < (r - l + 1);i++){
            sum1 += v2[i];
        }
        int sum2 = 0;
        for (int i = l-1; i < r;i++){
            sum2 += v3[i];
        }

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

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

 
int main(){

    int t;
    cin >> t;

    while(t--){
        int n,l,r;
        cin >> n >> l >>r;
        vector<int> v(n, 0);
        for (int i = 0; i < n;i++){ 
        cin >> v[i];
        }
        vector<int> v2 = v;
        vector<int> v3 = v;
        sort(v2.begin(), v2.begin() + r );
        sort(v3.begin() +l-1, v3.end()  );
        int sum1 = 0;
        for (int i = 0; i < (r - l + 1);i++){
            sum1 += v2[i];
        }
        int sum2 = 0;
        for (int i = l-1; i < r;i++){
            sum2 += v3[i];
        }

        cout << min(sum1,sum2) << endl;
    }
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

 
int main(){

    int t;
    cin >> t;

    while(t--){
        int n,l,r;
        cin >> n >> l >>r;
        vector<int> v(n, 0);
        for (int i = 0; i < n;i++){ 
        cin >> v[i];
        }
        vector<int> v2 = v;
        vector<int> v3 = v;
        sort(v2.begin(), v2.begin() + r );
        sort(v3.begin() +l-1, v3.end()  );
        int sum1 = 0;
        for (int i = 0; i < (r - l + 1);i++){
            sum1 += v2[i];
        }
        int sum2 = 0;
        for (int i = l-1; i < r;i++){
            sum2 += v3[i];
        }

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

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

 
int main(){

    int t;
    cin >> t;

    while(t--){
        int n,l,r;
        cin >> n >> l >>r;
        vector<int> v(n, 0);
        for (int i = 0; i < n;i++){ 
        cin >> v[i];
        }
        vector<int> v2 = v;
        vector<int> v3 = v;
        sort(v2.begin(), v2.begin() + r );
        sort(v3.begin() +l-1, v3.end()  );
        long long sum1 = 0;
        for (int i = 0; i < (r - l + 1);i++){
            sum1 += v2[i];
        }
        long long sum2 = 0;
        for (int i = l-1; i < r;i++){
            sum2 += v3[i];
        }

        cout << min(sum1,sum2) << endl;
    }
}
Problem: 2063B - Subsequence Update
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,l,r;
        cin >> n >> l >>r;
        vector<int> v(n, 0);
        for (int i = 0; i < n;i++){ 
        cin >> v[i];
        }

        sort(v.begin(), v.end());
        int sum = 0;
        for (int i = 0; i < (r - l + 1);i++){
            sum += v[i];
        }
        cout << sum << endl;
    }
}

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

 
int main(){

    int t;
    cin >> t;

    while(t--){
        int n,l,r;
        cin >> n >> l >>r;
        vector<int> v(n, 0);
        for (int i = 0; i < n;i++){ 
        cin >> v[i];
        }
        vector<int> v2 = v;
        vector<int> v3 = v;
        sort(v2.begin(), v2.begin() + (r+1) );
        sort(v3.begin() +l-1, v3.end()  );
        int sum1 = 0;
        for (int i = 0; i < (r - l + 1);i++){
            sum1 += v2[i];
        }
        int sum2 = 0;
        for (int i = l-1; i < r;i++){
            sum2 += v3[i];
        }

        cout << min(sum1,sum2) << endl;
    }
}
Problem: 2057B - Gorilla and the Exam
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,k;
        cin>>n>>k;
        vector<int> v(n);
        map<int,int> ct;
        set<int> s;
        for(int i=0;i<n;++i){
            cin>>v[i];
            ct[v[i]]++;
            s.insert(v[i]);
        }

        int m=s.size();
        int dt=m;

        vector<int> a(m);
        int idx=0;
        for( auto it:ct){
            
            a[idx]= it.second;
            idx++;

        }
        sort(a.begin(),a.end());
        for(int i=0;i<m-1;++i){
            if(k>=a[i]){
                k-=ct[a[i]];
                dt--;

            }
            else{
                break;
            }
        }

        cout<< dt <<endl;



    }
}

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

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<ll> v(n);
        map<ll,ll> ct;
        set<ll> s;
        for(int i=0;i<n;++i){
            cin>>v[i];
            ct[v[i]]++;
            s.insert(v[i]);
        }

        ll m=s.size();
        ll dt=m;

        vector<ll> a(m);
        ll idx=0;
        for( auto it:ct){
            
            a[idx]= it.second;
            idx++;

        }
        sort(a.begin(),a.end());
        for(int i=0;i<m-1;++i){
            if(k>=a[i]){
                k-=ct[a[i]];
                dt--;

            }
            else{
                break;
            }
        }

        cout<< dt <<endl;



    }
}
Problem: 2057B - Gorilla and the Exam
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

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<ll> v(n);
        map<ll,ll> ct;
        set<ll> s;
        for(int i=0;i<n;++i){
            cin>>v[i];
            ct[v[i]]++;
            s.insert(v[i]);
        }

        ll m=s.size();
        ll dt=m;

        vector<ll> a(m);
        ll idx=0;
        for( auto it:ct){
            
            a[idx]= it.second;
            idx++;

        }
        sort(a.begin(),a.end());
        for(int i=0;i<m-1;++i){
            if(k>=a[i]){
                k-=ct[a[i]];
                dt--;

            }
            else{
                break;
            }
        }

        cout<< dt <<endl;



    }
}

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

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<ll> v(n);
        map<ll,ll> ct;
        set<ll> s;
        for(int i=0;i<n;++i){
            cin>>v[i];
            ct[v[i]]++;
            s.insert(v[i]);
        }

        ll m=s.size();
        int dt=m;

        vector<ll> a(m);
        ll idx=0;
        for( auto it:ct){
            
            a[idx]= it.second;
            idx++;

        }
        sort(a.begin(),a.end());
        for(int i=0;i<m-1;++i){
            if(k>=a[i]){
                k-=a[i];
                dt--;

            }
            else{
                break;
            }
        }

        // int ans=max(1,dt);

        cout<< dt <<endl;



    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


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

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int> v(n);
        map<int,int> ct;
        set<int> s;
        for(int i=0;i<n;++i){
            cin>>v[i];
            ct[v[i]]++;
            s.insert(v[i]);
        }

        int m=s.size();
        int dt=m;

        vector<int> a(m);
        int idx=0;
        for( auto it:ct){
            
            a[idx]= it.second;
            idx++;

        }
        sort(a.begin(),a.end());
        for(int i=0;i<m-1;++i){
            if(k>=a[i]){
                k-=ct[a[i]];
                dt--;

            }
            else{
                break;
            }
        }

        cout<< dt <<endl;



    }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long
#define Endl endl


signed main() {
    fastio;
	int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int n=s.size();
        vector<short> v(n);
        int c2=0,c3=0,sum=0;
        for(int i=0;i<n;i++)
        {
            v[i]=s[i]-48;
            if(v[i]==2)c2++;
            else if(v[i]==3)c3++;
            sum+=v[i];
        } 
        int r= 9-sum%9;
        if(r==1 && c2>=2 && c3>=1)
        {
            cout<<"YES\n";
            continue;
        }
        if(r==2 && (  (c2>=1)  ))
        {
            cout<<"YES\n";
            continue;
        }
        if(r==3 && ((c3>=2) || (c3>=4 && c2>=3)))
        {
            cout<<"YES\n";
            continue;
        }
        if(r==2 || r==4 || r==6 || r==8)
        {
            if(2*c2 >= r){
                cout<<"YES\n";
            continue;}
        }
        if(r==5 && (c2>=7) ||(c2>=4 && c3>=1) || (c3>=2 && c2>=1))
        {
            cout<<"YES\n";
            continue;
        }
        if(r==6 && c3>=1){
            cout<<"YES\n";
            continue;
        }
        if(r==7 && (  (c2>=8) || (c3>=1 && c2>=5) || (c3>=2 && c2>=2 )   ))
        {
            cout<<"YES\n";
            continue;
        }
        if(r==8 && (  (c2>=4) || (c3>=1 && c2>=1)  ))
        {
            cout<<"YES\n";
            continue;
        }
        if(r==0 || r==9){
            cout<<"YES\n";
            continue;
        }
        cout<<"NO\n";

        
    }
    
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Compilation error):
#include <algorithm>
#include <bits/floatn-common.h>
#include <climits>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> PI;
typedef vector<PI> vii;
#define F first
#define S second
#define int ll
#define MP make_pair
#define PB push_back
#define tv takeVector
#define PV printVector
#define all(x) x.begin(), x.end()
#define FOR(i, a, b) for (ll i = a; i < (b); i++)
#define F0Rd(i, n) for (int i = n - 1; i >= 0; i--)
#define FORd(i, a, n) for (int i = n - 1; i >= a; i--)
#define F0R(i, b) for (ll i = 0; i < (b); i++)
#define iter(item, list) for (auto item : list)
#define SQ(a) (a) * (a)
const char nl = '\n';
const int MOD = 1e9 + 7;
const int mod = MOD;
void takeVector(vector<ll> &a) {
  for (auto &i : a) {
    cin >> i;
  }
}
void printVector(vector<int> arr) {
  FOR(i, 0, arr.size()) { cout << arr[i] << " "; }
  cout << endl;
}
void printVector(vector<PI> a) {
  for (auto i : a) {
    cout << i.F << " " << i.S << nl;
  }
}
const int MAX_N = 200005;
int MODpow(int x, int n, ll m) {
  if (n == 0) {
    return 1 % m;
  }
  if (n & 1) {
    ll u = MODpow(x, n - 1, m);
    return (x % m) * (u % m) % m;
  } else {
    ll u = MODpow(x, n / 2, m) % m;
    return (u * u) % m;
  }
}
string s, t;
bool multi = true;
int n, b, m, q, l, k, r, x, y, z, w;
int ans;
void solve() {
    cin>>l>>r;
    int num = 1;
    while(num < r){
        num<<=1LL;
    }
    FOR(i,l,r+1){
        if(i != num && i != num-1){
            cout<<num<<" "<<num-1<<" "<<i<<nl;
            break;
        }
    }
}
signed main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  if (multi)
    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 <bits/stdc++.h>

using namespace std;





   void solve(){

      int n;

      cin>>n;

      string s;

      cin>>s;

      int pp=0;

      int ss=0;

      int dot=0;

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

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

            pp++;

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

            ss++;



         }else{

            dot++;

         }

        

      }

      // cout<<pp<<endl;

      if(ss+dot==n||pp+dot==n||dot==n){

         cout<<"YES"<<endl;

         return ;

      }

        bool flag=false;

        int cnt=0;

        int cnt2=0;

        bool s1=false;

        bool s2=false;

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

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

            cnt++;

            flag=true;

            s1=true;

         }

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

            cnt++;

            s2=true;

         }

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

            cnt++;

         }





      }

      bool found=true;

           bool p1=false;

           bool p2=false;

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

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

            cnt2++;

            p1=true;

         }

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

            cnt2++;

            found=false;

            p2=true;

         }

         if(p1==true&&p2==false&&s[i]=='.'){

            cnt2++;

         }

      }

      if(cnt==n||cnt2==n){

         cout<<"YES"<<endl;

         return ;

      }

      cout<<"NO"<<endl;

   }



   int main(){

   int t;

   cin>>t;



   while(t--){

      solve();



   }



return 0;

}

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

using namespace std;





   void solve(){

      int n;

      cin>>n;

      string s;

      cin>>s;

      int pp=0;

      int ss=0;

      

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

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

            pp++;

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

            ss++;



        

        

      }

   }

     

      if(ss==0||pp==0){

         cout<<"YES"<<endl;

         return ;

      }

      int s1=0;

      int p1=-1;

      int idx=0;

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

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

            s1=idx;

         }

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

            if(p1==-1){

               p1=idx;

            }

         }

         idx++;

      }

      if(s1==0||p1==n-1){

         cout<<"YES"<<endl;

         return;

      }





        

      cout<<"NO"<<endl;

   }





   int main(){

   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 <bits/stdc++.h>

using namespace std;





   void solve(){

      int n;

      cin>>n;

      string s;

      cin>>s;

      int pp=0;

      int ss=0;

      int dot=0;

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

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

            pp++;

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

            ss++;



         }else{

            dot++;

         }

        

      }

      // cout<<pp<<endl;

      if(ss==n||pp==n||dot==n){

         cout<<"YES"<<endl;

         return ;

      }

        bool flag=false;

        int cnt=0;

        int cnt2=0;

        bool s1=false;

        bool s2=false;

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

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

            cnt++;

            flag=true;

            s1=true;

         }

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

            cnt++;

            s2=true;

         }

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

            cnt++;

         }





      }

      bool found=true;

           bool p1=false;

           bool p2=false;

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

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

            cnt2++;

            p1=true;

         }

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

            cnt2++;

            found=false;

            p2=true;

         }

         if(p1==true&&p2==false&&s[i]=='.'){

            cnt2++;

         }

      }

      if(cnt==n||cnt2==n){

         cout<<"YES"<<endl;

         return ;

      }

      cout<<"NO"<<endl;

   }



   int main(){

   int t;

   cin>>t;



   while(t--){

      solve();



   }



return 0;

}