ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[100];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		long long ans=0;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i],ans+=a[i];
		}
		if(n==1)
		{
			cout<<ans<<endl;
			continue;
		}
		while(n>1)
		{
			n--;
			for(int i=1;i<=n;i++)
			{
				a[i]=a[i+1]-a[i];
			}
			long long sum=0;
			for(int i=1;i<=n;i++) sum+=a[i];
			ans=max(ans,max(sum,-sum));
		}
		cout<<ans<<endl;
	}
	
return 0;
} 

Submission (verdict: Accepted):
#include<iostream>
#include<algorithm>
#include<cstring>
#define int long long
using namespace std;
int a[100];
signed main()
{
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int ans=0;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			ans+=a[i];
		}
		if(n==1){
			cout<<ans<<"\n";//不能进行1，2操作
			continue;
		}
		while(n){
			n--;
			for(int i=1;i<=n;i++){
				a[i]=a[i+1]-a[i];//2操作
			}
			int sum=0;
			for(int i=1;i<=n;i++) sum+=a[i];
			ans=max(ans,max(sum,-sum));//是否进行1操作
		}
		cout<<ans<<"\n";
			}
return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[100];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int sum=0;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i],sum+=a[i];
		}
		if(n==1)
		{
			cout<<sum<<endl;
			continue;
		}
		while(n>1)
		{
			n--;
			int ans=0;
			for(int i=1;i<=n;i++)
			{
				a[i]=a[i+1]-a[i];
				ans+=a[i]; 
			}
			sum=max(sum,max(ans,-ans));
		}
		cout<<sum<<endl;
	}
	
return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[100];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int sum=0;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i],sum+=a[i];
		}
		if(n==1)
		{
			cout<<sum<<endl;
			continue;
		}
		while(n>1)
		{
			n--;
			int ans=0;
			for(int i=1;i<=n;i++)
			{
				a[i]=a[i+1]-a[i];
				ans+=a[i]; 
			}
			sum=max(sum,max(ans,-ans));
		}
		cout<<sum<<endl;
	}
	
return 0;
} 

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[100];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		long long sum=0;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i],sum+=a[i];
		}
		if(n==1)
		{
			cout<<sum<<endl;
			continue;
		}
		while(n>1)
		{
			n--;
			long long ans=0;
			for(int i=1;i<=n;i++)
			{
				a[i]=a[i+1]-a[i];
				ans+=a[i]; 
			}
			sum=max(sum,max(ans,-ans));
		}
		cout<<sum<<endl;
	}
	
return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[100];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		long long sum=0;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i],sum+=a[i];
		}
		if(n==1)
		{
			cout<<sum<<endl;
			continue;
		}
		while(n>1)
		{
			n--;
			long long ans=0;
			for(int i=1;i<=n;i++)
			{
				a[i]=a[i+1]-a[i];
				ans+=a[i]; 
			}
			sum=max(sum,max(ans,-ans));
		}
		cout<<sum<<endl;
	}
	
return 0;
} 

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[100];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		long long ans=0;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i],ans+=a[i];
		}
		if(n==1)
		{
			cout<<ans<<endl;
			continue;
		}
		while(n>1)
		{
			n--;
			for(int i=1;i<=n;i++)
			{
				a[i]=a[i+1]-a[i];
			}
			long long sum=0;
			for(int i=1;i<=n;i++) sum+=a[i];
			ans=max(ans,max(sum,-sum));
		}
		cout<<ans<<endl;
	}
	
return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 4):
#include<iostream>
using namespace std;

void swap(int& x,int& y){
    int temp = x;
    x = y;
    y = temp;
    cout << x << " " << y << endl;
}

int main(){
    
    int n;
    cin >> n;
    int arr[n];
    int arr1[n];

    for(int i = 0 ; i < n ; i++){
        cin >> arr1[i];
        arr[i] = i + 1;
    }

    int count = (n*(n-1))/2;
    for(int i = 0 ; i < n ; i++){
        if((n - arr1[i] - i )>0)
        count += n - arr1[i] - i ;
    }
    cout << count << endl;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n - i - 1 ; j++){
            swap(arr[j],arr[j+1]);
        }
    }
    for(int i = 0 ; i < n ; i++){
        for(int j = n - arr1[i] ; j > i  ; j--){
            swap(arr[j-1],arr[j]);
        }
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#include<iostream>
using namespace std;

void swap(int& x,int& y){
    int temp = x;
    x = y;
    y = temp;
    cout << x << " " << y << endl;
}

int main(){
    
    int n;
    cin >> n;
    int arr[n];
    int arr1[n];

    for(int i = 0 ; i < n ; i++){
        cin >> arr1[i];
        arr[i] = i + 1;
    }

    int count = (n*(n-1))/2;
    for(int i = 0 ; i < n ; i++){
        if((n - arr1[i] - i )>0)
        count += n - arr1[i] - i ;
    }
    cout << count << endl;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n - i - 1 ; j++){
            swap(arr[j],arr[j+1]);
        }
    }
    for(int i = 0 ; i < n ; i++){
        for(int j = n - arr1[i] ; j > i  ; j--){
            swap(arr[j-1],arr[j]);
        }
    }
}

Submission (verdict: Wrong answer on test 4):
#include<iostream>
using namespace std;

void swap(int& x,int& y){
    int temp = x;
    x = y;
    y = temp;
    cout << x << " " << y << endl;
}

int main(){
    
    int n;
    cin >> n;
    int* arr = new int[n];
    int* arr1 = new int[n];

    for(int i = 0 ; i < n ; i++){
        cin >> arr1[i];
        arr[i] = i + 1;
    }

    int count = (n*(n-1))/2;
    for(int i = 0 ; i < n ; i++){
        if((n - arr1[i] - i )>0)
        count += n - arr1[i] - i ;
    }
    cout << count << endl;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n - i - 1 ; j++){
            swap(arr[j],arr[j+1]);
        }
    }
    for(int i = 0 ; i < n ; i++){
        for(int j = n - arr1[i] ; j > i  ; j--){
            swap(arr[j-1],arr[j]);
        }
    }
    delete [] arr;
    delete [] arr1;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

void swap(vector<vector<int>> & v,int& x,int& y){
	int temp = x;
	x = y;
	y = temp;

	vector<int> v1;
	v1.push_back(x);
	v1.push_back(y);
	v.push_back(v1);

	return;
}

int main(){
	int n;
	cin >> n;
	vector<int> v1(n);
	vector<int> v2(n);
	vector<vector<int>> print;

	int count = 0;

	for(int i = 0 ; i < n ; i++){
		v1[i] = i + 1;
		cin >> v2[i];
	}
	
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n - i - 1 ; j++){
			swap(print,v1[j],v1[j+1]);
			count++;
		}
	}
	
	for(int i = 0 ; i < n ; i++){
		
		auto k = find(v2.begin()+i,v2.end(),v2[i]);
		int x = distance(begin(v2),k);
		for(int j = x ;j > i;j--){
			swap(print,v1[j-1],v1[j]);
			count++;
		}

	}
	cout << count << endl;
	for(int i = 0 ; i < print.size() ; i++){
		cout << print[i][0] << " " << print[i][1] << endl;
	}
	return 0;

}


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

void swap(vector<vector<int>> & v,int& x,int& y){
	int temp = x;
	x = y;
	y = temp;

	vector<int> v1;
	v1.push_back(x);
	v1.push_back(y);
	v.push_back(v1);

	return;
}

int main(){
	int n;
	cin >> n;
	vector<int> v1(n);
	vector<int> v2(n);
	vector<vector<int>> print;

	int count = 0;

	for(int i = 0 ; i < n ; i++){
		v1[i] = i + 1;
		cin >> v2[i];
	}
	
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n - i - 1 ; j++){
			swap(print,v1[j],v1[j+1]);
			count++;
		}
	}


	
	for(int i = 0 ; i < n ; i++){
		
		auto k = find(v1.begin()+i,v1.end(),v2[i]);
		int x = distance(begin(v1),k);
		for(int j = x ;j > i;j--){
			swap(print,v1[j-1],v1[j]);
			count++;
		}

	}
	cout << count << endl;
	for(int i = 0 ; i < print.size() ; i++){
		cout << print[i][0] << " " << print[i][1] << endl;
		
	}
	return 0;

}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#include<iostream>
using namespace std;

void swap(int& x,int& y){
    int temp = x;
    x = y;
    y = temp;
    cout << x << " " << y << endl;
}

int main(){
    
    int n;
    cin >> n;
    int* arr = new int[n];
    int* arr1 = new int[n];

    for(int i = 0 ; i < n ; i++){
        cin >> arr1[i];
        arr[i] = i + 1;
    }

    int count = (n*(n-1))/2;
    for(int i = 0 ; i < n ; i++){
        if((n - arr1[i] - i )>0)
        count += n - arr1[i] - i ;
    }
    cout << count << endl;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n - i - 1 ; j++){
            swap(arr[j],arr[j+1]);
        }
    }
    for(int i = 0 ; i < n ; i++){
        for(int j = n - arr1[i] ; j > i  ; j--){
            swap(arr[j-1],arr[j]);
        }
    }
    delete [] arr;
    delete [] arr1;
}

Submission (verdict: Wrong answer on test 4):
#include<iostream>
using namespace std;

void swap(int& x,int& y){
    int temp = x;
    x = y;
    y = temp;
    cout << x << " " << y << endl;
}

int main(){
    
    int n;
    cin >> n;
    int* arr = new int[n];
    int* arr1 = new int[n];

    for(int i = 0 ; i < n ; i++){
        cin >> arr1[i];
        arr[i] = i + 1;
    }

    int count = (n*(n-1))/2;
    for(int i = 0 ; i < n ; i++){
        if((n - arr1[i] - i )>0)
        count += n - arr1[i] - i ;
    }
    cout << count << endl;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n - i - 1 ; j++){
            swap(arr[j],arr[j+1]);
        }
    }
    for(int i = 0 ; i < n ; i++){
        for(int j = n - arr1[i] ; j > i  ; j--){
            swap(arr[j-1],arr[j]);
        }
    }
    
    delete [] arr;
    delete [] arr1;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#include<iostream>
using namespace std;

void swap(int& x,int& y){
    int temp = x;
    x = y;
    y = temp;
    cout << x << " " << y << endl;
}

int main(){
    
    int n;
    cin >> n;
    int* arr = new int[n];
    int* arr1 = new int[n];

    for(int i = 0 ; i < n ; i++){
        cin >> arr1[i];
        arr[i] = i + 1;
    }

    int count = (n*(n-1))/2;
    for(int i = 0 ; i < n ; i++){
        if((n - arr1[i] - i )>0)
        count += n - arr1[i] - i ;
    }
    cout << count << endl;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n - i - 1 ; j++){
            swap(arr[j],arr[j+1]);
        }
    }
    for(int i = 0 ; i < n ; i++){
        for(int j = n - arr1[i] ; j > i  ; j--){
            swap(arr[j-1],arr[j]);
        }
    }
    
    delete [] arr;
    delete [] arr1;
}

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

void swap(vector<vector<int>> & v,int& x,int& y){
	int temp = x;
	x = y;
	y = temp;

	vector<int> v1;
	v1.push_back(x);
	v1.push_back(y);
	v.push_back(v1);

	return;
}

int main(){
	int n;
	cin >> n;
	vector<int> v1(n);
	vector<int> v2(n);
	vector<vector<int>> print;

	int count = 0;

	for(int i = 0 ; i < n ; i++){
		v1[i] = i + 1;
		cin >> v2[i];
	}
	
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n - i - 1 ; j++){
			swap(print,v1[j],v1[j+1]);
			count++;
		}
	}
	
	for(int i = 0 ; i < n ; i++){
		
		auto k = find(v2.begin()+i,v2.end(),v2[i]);
		int x = distance(begin(v2),k);
		for(int j = x ;j > i;j--){
			swap(print,v1[j-1],v1[j]);
			count++;
		}

	}
	cout << count << endl;
	for(int i = 0 ; i < print.size() ; i++){
		cout << print[i][0] << " " << print[i][1] << endl;
	}
	return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;

    while(t--)
    {
        string s;
        cin >> s;

        int n = s.size();
        s = ' ' + s;
        
        ll sum = 0;
        int ctr = 0;
        ll cnt2 = 0 , cnt6 = 0;
        for(int i = 1; i <= n ; ++i){
            sum += (s[i] - '0');

            if(s[i] == '2') cnt2++;
            else if(s[i] == '3') cnt6++;
        }

        if(sum%9 == 0)
        {
            ctr = 1;
        }        
        else if(cnt6 == 0)
        {
            int mini = (9 - sum%9)/2;
            if(n%2 == 0) mini += 5;

            if(cnt2 >= mini) ctr = 1;
        }
        else if(cnt2 == 0)
        {
            if((sum%9)%3 == 0 && cnt6 >= (sum%9)/3) ctr = 1;
        }
        else
        {
            // cout << sum%9 << " " << cnt2 << " " << cnt6 << '\n';
            if(cnt2 > 8) cnt2 = 8;
            if(cnt6 > 3) cnt6 = 3;

            for(int i = 0 ; i <= cnt2 ; ++i){
                for(int j = 0 ; j <= cnt6 ; ++j){
                    if((sum%9 + 2*i + 6*j)%9 == 0){
                        ctr = 1;
                        break;
                    }
                }
            }
        }

        if(ctr) cout << "YES\n";
        else cout << "NO\n";
    }

    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;

    while(t--)
    {
        string s;
        cin >> s;

        int n = s.size();
        s = ' ' + s;
        
        ll sum = 0;
        int ctr = 0;
        ll cnt2 = 0 , cnt6 = 0;
        for(int i = 1; i <= n ; ++i){
            sum += (s[i] - '0');

            if(s[i] == '2') cnt2++;
            else if(s[i] == '3') cnt6++;
        }

        if(sum%9 == 0)
        {
            ctr = 1;
        }        
        else if(cnt6 == 0 && cnt2 != 0)
        {
            int mini = (9 - sum%9)/2;
            if(n%2 == 0) mini += 5;

            if(cnt2 >= mini) ctr = 1;
        }
        else if(cnt2 == 0 && cnt6 != 0)
        {
            if((sum%9)%3 == 0 && cnt6 >= (sum%9)/3) ctr = 1;
        }
        else
        {
            // cout << sum%9 << " " << cnt2 << " " << cnt6 << '\n';
            if(cnt2 > 8) cnt2 = 8;
            if(cnt6 > 3) cnt6 = 3;

            for(int i = 0 ; i <= cnt2 ; ++i){
                for(int j = 0 ; j <= cnt6 ; ++j){
                    if((sum%9 + 2*i + 6*j)%9 == 0){
                        ctr = 1;
                        break;
                    }
                }
            }
        }

        if(ctr) cout << "YES\n";
        else cout << "NO\n";
    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;

    while(t--)
    {
        string s;
        cin >> s;

        int n = s.size();
        s = ' ' + s;
        
        ll sum = 0;
        int ctr = 0;
        ll cnt2 = 0 , cnt6 = 0;
        for(int i = 1; i <= n ; ++i){
            sum += (s[i] - '0');

            if(s[i] == '2') cnt2++;
            else if(s[i] == '3') cnt6++;
        }

        if(sum%9 == 0)
        {
            ctr = 1;
        }        
        else if(cnt6 == 0)
        {
            int mini = (9 - sum%9)/2;
            if(n%2 == 0) mini += 5;

            if(cnt2 >= mini) ctr = 1;
        }
        else if(cnt2 == 0)
        {
            if((sum%9)%3 == 0 && cnt6 >= (sum%9)/3) ctr = 1;
        }
        else
        {
            // cout << sum%9 << " " << cnt2 << " " << cnt6 << '\n';
            if(cnt2 > 8) cnt2 = 8;
            if(cnt6 > 3) cnt6 = 3;

            for(int i = 0 ; i <= cnt2 ; ++i){
                for(int j = 0 ; j <= cnt6 ; ++j){
                    if((sum%9 + 2*i + 6*j)%9 == 0){
                        ctr = 1;
                        break;
                    }
                }
            }
        }

        if(ctr) cout << "YES\n";
        else cout << "NO\n";
    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;

    while(t--)
    {
        string s;
        cin >> s;

        int n = s.size();
        s = ' ' + s;
        
        ll sum = 0;
        int ctr = 0;
        ll cnt2 = 0 , cnt6 = 0;
        for(int i = 1; i <= n ; ++i){
            sum += (s[i] - '0');

            if(s[i] == '2') cnt2++;
            else if(s[i] == '3') cnt6++;
        }

        if(sum%9 == 0)
        {
            ctr = 1;
        }        
        else if(cnt6 == 0 && cnt2 != 0)
        {
            int mini = (9 - sum%9)/2;
            if(n%2 == 0) mini += 5;

            if(cnt2 >= mini) ctr = 1;
        }
        else if(cnt2 == 0 && cnt6 != 0)
        {
            if((sum%9)%3 == 0 && cnt6 >= (sum%9)/3) ctr = 1;
        }
        else
        {
            // cout << sum%9 << " " << cnt2 << " " << cnt6 << '\n';
            if(cnt2 > 8) cnt2 = 8;
            if(cnt6 > 3) cnt6 = 3;

            for(int i = 0 ; i <= cnt2 ; ++i){
                for(int j = 0 ; j <= cnt6 ; ++j){
                    if((sum%9 + 2*i + 6*j)%9 == 0){
                        ctr = 1;
                        break;
                    }
                }
            }
        }

        if(ctr) cout << "YES\n";
        else cout << "NO\n";
    }

    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;

    while(t--)
    {
        string s;
        cin >> s;

        int n = s.size();
        s = ' ' + s;
        
        ll sum = 0;
        int ctr = 0;
        ll cnt2 = 0 , cnt6 = 0;
        for(int i = 1; i <= n ; ++i){
            sum += (s[i] - '0');

            if(s[i] == '2') cnt2++;
            else if(s[i] == '3') cnt6++;
        }

        if(sum%9 == 0)
        {
            ctr = 1;
        }        
        else
        {
            if(cnt2 > 8) cnt2 = 8;
            if(cnt6 > 3) cnt6 = 3;

            for(int i = 0 ; i <= cnt2 ; ++i){
                for(int j = 0 ; j <= cnt6 ; ++j){
                    if((sum%9 + 2*i + 6*j)%9 == 0){
                        ctr = 1;
                        break;
                    }
                }
            }
        }

        if(ctr) cout << "YES\n";
        else cout << "NO\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;

#define rep(b) for (ll i = 0; i < b; ++i)

#define f(i, a, b) for (ll i = a; i <= b; ++i)

#define vl vector<ll>

#define vp vector<pair<ll, ll>>

#define ALL(x) (x).begin(), (x).end()

#define eb emplace_back

#define ia(a, n)     \

    vector<ll> a(n); \

    f(i, 0, n - 1) cin >> a[i]



const ll mod = 1e9 + 7;



long long power(long long base, long long exp) {

    long long result = 1;

    

    while (exp > 0) {

        // If exp is odd, multiply the result by base

        if (exp % 2 == 1) {

            result *= base;

        }

        

        // Square the base and halve the exponent

        base *= base;

        exp /= 2;

    }

    

    return result;

}

void solve(){

    int n ;

    cin >> n ;

    string s ;

    cin >> s ;

    int posP = 0;

    int posS = 0;

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

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

            posP = i ;

            break ;

        }



    }



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

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

            posS = i ;

            break ;

        }

    }

    //cout << "s " << posS << " " << "p " << posP << endl;

    if(posS > posP){

        //cout << "1" << endl;

        cout << "NO" << endl;

        return  ;

    }



    vector <int> a ;

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

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

            a.push_back(i+1);

        }

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

            a.push_back(n - i) ;

        }

    }

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

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

        cout <<  "YES" << endl;

        return ;

    }

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

        if(a[i] == a[i-1] && a[i] != n){

           // cout << "2" << endl;

            cout << "NO" << endl;

            return ;

        }

    }

    cout << "YES" << endl;

    



}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.flush();

    ll t;

    cin >> t;



    while (t--)

    {

        solve();

    }



    return 0;

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


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long int ll;
typedef unsigned long long ull;
const ll INF = (1ll << 61);
const ll inf = 1e9;
const ll MOD=1e9 + 7;
const ll M=998244353;
 
 
 
ll gcd(ll a, ll b) {
    return b ? gcd (b, a % b) : a;
}
 
ll lcm(ll a,ll b){
  return ((a*b)/gcd(a,b));
}

ll fact[2000001];

void factfun(){
  fact[0] = fact[1] = 1;
  for(ll i=2;i<=2000000;i++){
    fact[i] = (fact[i-1]%MOD * i%MOD)%MOD;
  }
}

ll expo(ll a,ll n){
   ll ans = 1;
   while(n > 0){
    if(n & 1ll){
      ans = ans * a % MOD;
    }
    a = a * a % MOD;
    n >>= 1;
   }
   return ans;
}

ll fermatNCr(ll a,ll b){
   return ((fact[a]%MOD * expo(fact[b],MOD - 2)%MOD * expo(fact[a - b],MOD - 2)%MOD)%MOD);
}



void solve(){
   ll l,r;
   cin>>l>>r;
   if(l == 1 && r == 3){
    cout<<1<<" "<<2<<" "<<3<<endl;
    return;
   }
   ll a = 0,b = 0,c = 0;
   ll flg = 0,fset = 0;
   for(ll i=30;i>=0;i--){
     if(flg == 0){
      ll b1 = ((l >> i) & 1ll);
      ll b2 = ((r >> i) & 1ll);
       if(b1 == b2){
        a += (b1 << i);
        b += (b1 << i);
        c += (b1 << i);
       }
       else{
        flg = 1;
        a += (b1 << i);
        b += (b1 << i);
        c += (b2 << i);
       }
     }
     else{
       ll b1 = ((l >> i) & 1ll);
       ll b2 = ((r >> i) & 1ll);
       if(b1 == 1 && fset == 0){
          fset = 1;
          a += (1 << i);
          b += (1 << i);
          c += (0 << i);
       }
       else{
         a += (b1 << i);
         b += (1 << i);
         c += (0 << i);
       }
     }
   }

   cout<<a<<" "<<b<<" "<<c<<endl;
}
 
 
 
 
 
int main(){
 
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif*/
    

      ll testcase;
      //testcase = 1;
      cin>>testcase;
     
      while(testcase--){       
        solve();
      }
 
}