ShaysXIA/CodeInsightBench huggingface dataset:
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;



void solve(){

    int n; cin >> n;

    vector<int> ar(n);

    for (int i=0; i<n; i++) cin >> ar[i];

    int prev = -1;



    bool invalid = false;

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

        if (prev > ar[i] and ar[i] > ar[i+1]){

            invalid = true;

            break;

        }

        prev = ar[i];

    }



    prev = 0;

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

        if (ar[i] >= ar[i+1]){

            ar[i] -= min(ar[i], prev);

            if (ar[i] > ar[i+1]){

                invalid = true;

                break;

            }

        }

        prev = ar[i];

    }

    cout << (invalid ? "NO" : "YES") << 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;

    vector<int> ar(n);

    for (int i=0; i<n; i++) cin >> ar[i];

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

        int ts = min(ar[i], ar[i-1]);

        ar[i] -= ts;

        ar[i-1] -= ts;

    }

    cout << (is_sorted(ar.begin(), ar.end()) ? "YES" : "NO") << endl;

}



int main(){

    int t; cin >> t;

    while (t--){

        solve();

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
void work() {
	memset(a, 0, sizeof a);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = n; i > 1; i--) {
		if (i == n && a[i] > a[i - 1]) {
			cout << "Yes" << endl;
			return;
		}
		if (i + 1 <= n) {
			int itemp = min(a[i], a[i + 1]);
			if (a[i] > a[i - 1]) {
				a[i] -= itemp;
				a[i + 1] -= itemp;
			}
			if (a[i] > a[i - 1]) {
				cout << "Yes" << endl;
				return;
			}
		}
	} 
	cout << "No" << endl;
	return;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int testcase;
	cin >> testcase;
	while (testcase--) {
		work();
	}
	
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
void work() {
	memset(a, 0, sizeof a);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = n; i > 1; i--) {
		if (i == n && a[i] > a[i - 1]) {
			cout << "Yes" << endl;
			return;
		}
		if (i + 1 <= n) {
			int itemp = min(a[i], a[i + 1]);
			if (a[i] > a[i - 1]) {
				a[i] -= itemp;
				a[i + 1] -= itemp;
			}
			if (a[i] > a[i - 1]) {
				cout << "Yes" << endl;
				return;
			}
		}
	} 
	cout << "No" << endl;
	return;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int testcase;
	cin >> testcase;
	while (testcase--) {
		work();
	}
	
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
void work() {
	memset(a, 0, sizeof a);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = n; i > 1; i--) {
		if (i == n && a[i] >= a[i - 1]) {
			cout << "Yes" << endl;
			return;
		}
		if (i>1&&a[i] < a[i - 1])continue;
		if (i + 1 <= n) {
			int itemp = min(a[i], a[i + 1]);
			if (a[i] > a[i - 1]) {
				a[i] -= itemp;
				a[i + 1] -= itemp;
			}
			if (a[i] > a[i - 1]) {
				cout << "Yes" << endl;
				return;
			}
		}
	} 
	cout << "No" << endl;
	return;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int testcase;
	cin >> testcase;
	while (testcase--) {
		work();
	}
	
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
void work() {
	memset(a, 0, sizeof a);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = n; i > 1; i--) {
		if (i == n && a[i] >= a[i - 1]) {
			cout << "Yes" << endl;
			return;
		}
		if (i>1&&a[i] < a[i - 1])continue;
		if (i + 1 <= n) {
			int itemp = min(a[i], a[i + 1]);
			if (a[i] > a[i - 1]) {
				a[i] -= itemp;
				a[i + 1] -= itemp;
			}
			if (a[i] > a[i - 1]) {
				cout << "Yes" << endl;
				return;
			}
		}
	} 
	cout << "No" << endl;
	return;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int testcase;
	cin >> testcase;
	while (testcase--) {
		work();
	}
	
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
void work() {
	memset(a, 0, sizeof a);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = n; i > 1; i--) {
		if (i == n && a[i] >= a[i - 1]) {
			cout << "Yes" << endl;
			return;
		}
		if (i>1&&a[i] < a[i - 1])continue;
		else {
			int itemp = min(a[i], a[i + 1]);
				a[i] -= itemp;
				a[i + 1] -= itemp;
			if (a[i] > a[i - 1]) {
				cout << "Yes" << endl;
				return;
			}
		}
	} 
	cout << "No" << endl;
	return;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int testcase;
	cin >> testcase;
	while (testcase--) {
		work();
	}
	
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
void work() {
	memset(a, 0, sizeof a);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = n; i > 1; i--) {
		if (i == n && a[i] > a[i - 1]) {
			cout << "Yes" << endl;
			return;
		}
		if (i>1&&a[i] <= a[i - 1])continue;
		else {
			int itemp = min(a[i], a[i + 1]);
				a[i] -= itemp;
				a[i + 1] -= itemp;
			if (a[i] > a[i - 1]) {
				cout << "Yes" << endl;
				return;
			}
		}
	} 
	cout << "No" << endl;
	return;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int testcase;
	cin >> testcase;
	while (testcase--) {
		work();
	}
	
	return 0;
}

Submission (verdict: Accepted):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
void work() {
	memset(a, 0, sizeof a);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i<n; i++) {
		if (a[i] >a[i+1]) {
			cout << "No" << endl;
			return;
		}
		else {
			int itemp = min(a[i], a[i + 1]);
			if (a[i] - itemp >= a[i - 1]) {
				a[i] -= itemp;
				a[i + 1] -= itemp;
			}
		}
	} 
	cout << "Yes" << endl;
	return;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int testcase;
	cin >> testcase;
	while (testcase--) {
		work();
	}
	
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
void work() {
	memset(a, 0, sizeof a);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = n; i > 1; i--) {
		if (i == n && a[i] >= a[i - 1]) {
			cout << "Yes" << endl;
			return;
		}
		if (i>1&&a[i] < a[i - 1])continue;
		else {
			int itemp = min(a[i], a[i + 1]);
				a[i] -= itemp;
				a[i + 1] -= itemp;
			if (a[i] > a[i - 1]) {
				cout << "Yes" << endl;
				return;
			}
		}
	} 
	cout << "No" << endl;
	return;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int testcase;
	cin >> testcase;
	while (testcase--) {
		work();
	}
	
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
void work() {
	memset(a, 0, sizeof a);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = n; i > 1; i--) {
		if (i == n && a[i] > a[i - 1]) {
			cout << "Yes" << endl;
			return;
		}
		if (i>1&&a[i] <= a[i - 1])continue;
		else {
			int itemp = min(a[i], a[i + 1]);
				a[i] -= itemp;
				a[i + 1] -= itemp;
			if (a[i] > a[i - 1]) {
				cout << "Yes" << endl;
				return;
			}
		}
	} 
	cout << "No" << endl;
	return;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int testcase;
	cin >> testcase;
	while (testcase--) {
		work();
	}
	
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include <iostream>
#include <vector>
#include <string>
#include<bits/stdc++.h>


using namespace std;
using ll = long long;

template<class T>
void cl(vector<T> &vec,ll a,ll b){
    ll min_ = min(vec[a],vec[b]);
    vec[a]-=min_;
    vec[b]-=min_;
};
template<class T>
void ret(vector<T> &vec1){
    // checker for sorted
    int is_sorted_ = 0;
    for(ll j = 0; j < vec1.size(); ++j){

        if(vec1[j]<=vec1[j + 1]){
            cl(vec1,j,j+1);
        }
    }

    cout << (is_sorted(ve.begin(), ve.end()) ? "YES" : "NO") << '\n';
}




int main(){
    cin.tie(nullptr) -> sync_with_stdio(false);
    ll n;
    cin >> n;
    
    for(ll s = 0; s < n; s++){
        ll sn;
        cin >> sn;
        vector<ll> vec(sn);
        for (ll &t : vec){
            cin >> t;
        }
        ret(vec);

        
    }
    return 0;


}

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


using namespace std;
using ll = long long;

template<class T>
void cl(vector<T> &vec,ll a,ll b){
    ll min_ = min(vec[a],vec[b]);
    vec[a]-=min_;
    vec[b]-=min_;
}
template<class T>
void ret(vector<T> &vec1){
    // checker for sorted

    for(ll j = 0; j < vec1.size(); ++j){

        if(vec1[j]<=vec1[j + 1]){
            cl(vec1,j,j+1);
        }
    }

    cout << (is_sorted(vec1.begin(), vec1.end()) ? "YES" : "NO") << '\n';
}




int main(){
    cin.tie(nullptr) -> sync_with_stdio(false);
    ll n;
    cin >> n;
    
    for(ll s = 0; s < n; s++){
        ll sn;
        cin >> sn;
        vector<ll> vec(sn);
        for (ll &t : vec){
            cin >> t;
        }
        ret(vec);

        
    }
    return 0;


}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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


using namespace std;
using ll = long long;

template<class T>
void cl(vector<T> &vec,ll a,ll b){
    ll min_ = min(vec[a],vec[b]);
    vec[a]-=min_;
    vec[b]-=min_;
};
template<class T>
void ret(vector<T> &vec1){
    // checker for sorted
    int is_sorted_ = 0;
    for(ll j = 0; j < vec1.size(); ++j){
        if(is_sorted(vec1.begin(),vec1.end())){
            is_sorted_ = 1;
            break;
        }
        if(vec1[j]<vec1[j + 1]){
            cl(vec1,j,j+1);
        }
    }
    if(is_sorted_){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}




int main(){

    ll n;
    cin >> n;
    
    for(ll s = 0; s < n; s++){
        ll sn;
        cin >> sn;
        vector<ll> vec(sn);
        for (ll &t : vec){
            cin >> t;
        }
        ret(vec);

        
    }
    return 0;


}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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


using namespace std;
using ll = long long;

template<class T>
void cl(vector<T> &vec,ll a,ll b){
    ll min_ = min(vec[a],vec[b]);
    vec[a]-=min_;
    vec[b]-=min_;
};
template<class T>
void ret(vector<T> &vec1){
    // checker for sorted
    int is_sorted_ = 0;
    for(ll j = 0; j < vec1.size(); ++j){
        if(is_sorted(vec1.begin(),vec1.end())){
            is_sorted_ = 1;
            break;
        }
        if(vec1[j]<vec1[j + 1]){
            cl(vec1,j,j+1);
        }
    }
    if(is_sorted_){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}




int main(){

    ll n;
    cin >> n;
    
    for(ll s = 0; s < n; s++){
        ll sn;
        cin >> sn;
        vector<ll> vec(sn);
        for (ll &t : vec){
            cin >> t;
        }
        ret(vec);

        
    }
    return 0;


}

Submission (verdict: Compilation error):
#include <iostream>
#include <vector>
#include <string>
#include<bits/stdc++.h>


using namespace std;
using ll = long long;

template<class T>
void cl(vector<T> &vec,ll a,ll b){
    ll min_ = min(vec[a],vec[b]);
    vec[a]-=min_;
    vec[b]-=min_;
};
template<class T>
void ret(vector<T> &vec1){
    // checker for sorted
    int is_sorted_ = 0;
    for(ll j = 0; j < vec1.size(); ++j){

        if(vec1[j]<=vec1[j + 1]){
            cl(vec1,j,j+1);
        }
    }

    cout << (is_sorted(ve.begin(), ve.end()) ? "YES" : "NO") << '\n';
}




int main(){
    cin.tie(nullptr) -> sync_with_stdio(false);
    ll n;
    cin >> n;
    
    for(ll s = 0; s < n; s++){
        ll sn;
        cin >> sn;
        vector<ll> vec(sn);
        for (ll &t : vec){
            cin >> t;
        }
        ret(vec);

        
    }
    return 0;


}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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


using namespace std;
using ll = long long;

template<class T>
void cl(vector<T> &vec,ll a,ll b){
    ll min_ = min(vec[a],vec[b]);
    vec[a]-=min_;
    vec[b]-=min_;
}
template<class T>
void ret(vector<T> &vec1){
    // checker for sorted

    for(ll j = 0; j < vec1.size(); ++j){

        if(vec1[j]<=vec1[j + 1]){
            cl(vec1,j,j+1);
        }
    }

    cout << (is_sorted(vec1.begin(), vec1.end()) ? "YES" : "NO") << '\n';
}




int main(){
    cin.tie(nullptr) -> sync_with_stdio(false);
    ll n;
    cin >> n;
    
    for(ll s = 0; s < n; s++){
        ll sn;
        cin >> sn;
        vector<ll> vec(sn);
        for (ll &t : vec){
            cin >> t;
        }
        ret(vec);

        
    }
    return 0;


}

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


using namespace std;
using ll = long long;

template<class T>
void cl(vector<T> &vec,ll a,ll b){
    ll min_ = min(vec[a],vec[b]);
    vec[a]-=min_;
    vec[b]-=min_;
}
template<class T>
void ret(vector<T> &vec1){
    // checker for sorted

    for(ll j = 0; j < vec1.size()-1; ++j){

        if(vec1[j]<=vec1[j + 1]){
            cl(vec1,j,j+1);
        }
    }

    cout << (is_sorted(vec1.begin(), vec1.end()) ? "YES" : "NO") << '\n';
}




int main(){
    cin.tie(nullptr) -> sync_with_stdio(false);
    ll n;
    cin >> n;
    
    for(ll s = 0; s < n; s++){
        ll sn;
        cin >> sn;
        vector<ll> vec(sn);
        for (ll &t : vec){
            cin >> t;
        }
        ret(vec);

        
    }
    return 0;


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

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    int t;
    cin >> t;
    while(t--) {
        LL l, r;
        cin >> l >> r;
        LL a = 1 << (int)log2(r);
        LL b = a - 1;
        LL c = l;
        cout << a << " " << b << " " << c << endl; 
    } 
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    int t;
    cin >> t;
    while(t--) {
        LL l, r;
        cin >> l >> r;
        LL a = 1 << (int)log2(r);
        LL b = a - 1;
        LL c = l;
        if(b == c) c++;
        if(c == a) a++; 
        cout << a << " " << b << " " << c << endl;
    } 
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    int t;
    cin >> t;
    while(t--) {
        LL l, r;
        cin >> l >> r;
        LL a = 1 << (int)log2(r);
        LL b = a - 1;
        LL c = l + 1;
        cout << a << " " << b << ' ' << c << endl; 
    } 
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    int t;
    cin >> t;
    while(t--) {
        LL l, r;
        cin >> l >> r;
        LL a = 1 << (int)log2(r);
        LL b = a - 1;
        LL c = l;
        cout << a << " " << b << " " << c << endl; 
    } 
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    int t;
    cin >> t;
    while(t--) {
        LL l, r;
        cin >> l >> r;
        int k = (int)log2(r);
        int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
        std::cout << a << " " << b << " " << c << "\n";
    } 
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    int t;
    cin >> t;
    while(t--) {
        LL l, r;
        cin >> l >> r;
        int k = (int)log2(l ^ r);
        int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
        std::cout << a << " " << b << " " << c << "\n";
    } 
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    int t;
    cin >> t;
    while(t--) {
        LL l, r;
        cin >> l >> r;
        LL a = 1 << (int)log2(r);
        LL b = a - 1;
        LL c = l + 1;
        cout << a << " " << b << ' ' << c << endl; 
    } 
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    int t;
    cin >> t;
    while(t--) {
        LL l, r;
        cin >> l >> r;
        LL a = 1 << (int)log2(r);
        LL b = a - 1;
        LL c = l;
        if(b == c) c++;
        if(c == a) a++; 
        cout << a << " " << b << " " << c << endl;
    } 
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    int t;
    cin >> t;
    while(t--) {
        LL l, r;
        cin >> l >> r;
        int k = (int)log2(r);
        int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
        std::cout << a << " " << b << " " << c << "\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;

typedef long long ll;

bool compareByFirst(const pair<int, int>& a, const pair<int, int>& b) {

    return a.first < b.first;

}



void solve(){

	int n;

	cin>>n;

	string s;

	cin>>s;

	int l1=s.length();

	char last=s[0];

	bool can=true;

	if(last=='.'){

		bool pf=false;

		bool sf=false;

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

			if(s[i]=='p')pf=true;

			if(s[i]=='s')sf=true;

			}

		if(sf && pf)can=false;

		}

	else{

		bool pf=false;

		bool sf=false;

		int countp=0;

		int counts=0;

		for(auto x:s){

			if(x=='p'){pf=true;countp++;}

			if(x=='s'){

				sf=true;

				counts++;

				if(pf){can=false;break;}

				}		

			}

		if(countp>1 && counts>1){

			can=false;

			}

		}

	if(can){

		cout<<"yes"<<endl;

		}

	else{

		cout<<"no"<<endl;

		}

	}



int main(){

	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;

typedef long long ll;



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    int l1 = s.length();

    char last = s[0];

    bool can = true;



    if (last == '.') {

        bool pf = false, sf = false;

        for (int i = 0; i < l1; i++) {  // Start from i = 0 to consider all characters

            if (s[i] == 'p') pf = true;

            if (s[i] == 's') sf = true;

        }

        if (sf && pf) can = false;

    } else {

        bool pf = false, sf = false;

        int countp = 0, counts = 0;



        for (auto x : s) {

            if (x == 'p') {

                pf = true;

                countp++;

            }

            if (x == 's') {

                sf = true;

                counts++;

                if (pf) { 

                    can = false; 

                    break; 

                }

            }

        }

        if (countp > 1 && counts > 1) {

            can = false;

        }

    }



    if (can) {

        cout << "yes" << endl;

    } else {

        cout << "no" << endl;

    }

}



int main() {

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

}



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

using namespace std;

typedef long long ll;



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    int l1 = s.length();

    char last = s[0];

    bool can = true;



    if (last == '.') {

        bool pf = false, sf = false;

        int countp = 0, counts = 0;



        for (auto x : s) {

            if (x == 'p') {

                pf = true;

                countp++;

            }

            if (x == 's') {

                sf = true;

                counts++;

                if (pf) { 

                    can = false; 

                    break; 

                }

            }

        }

        if (countp > 1 && counts > 1) {

            can = false;

        }

        if(s[l1-1]=='.' && pf && sf){can=false;}

    }

     else {

        bool pf = false, sf = false;

        int countp = 0, counts = 0;



        for (auto x : s) {

            if (x == 'p') {

                pf = true;

                countp++;

            }

            if (x == 's') {

                sf = true;

                counts++;

                if (pf) { 

                    can = false; 

                    break; 

                }

            }

        }

        if (countp > 1 && counts > 1) {

            can = false;

        }

    }



    if (can) {

        cout << "yes" << endl;

    } else {

        cout << "no" << endl;

    }

}



int main() {

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

}