ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
#include<stdio.h> 
#include<chrono>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds ; 
using ll = long long ;  
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> pbds ; 
ll inf = (4e18L) + 100 ;
ll ninf = (-4e18L) - 100 ;
const ll mod = 1e9 + 7 ; // 998244353; 
const int MAXN = 2e5 + 100 ; 

void solve_test_case() 
{     
    int n ; 
    cin >> n ; 
    
    vector<int> arr(n+1) ; 
    
    for(int i = 1 ; i <= n ; i++) cin >> arr[i] ; 
    vector<pair<int,int>> ans ;
    vector<bool> visited(n,false) ; 
    for(int j = n  ; j > 0 ; j--) 
    {
        int x = arr[j] ; 
        visited[x] = true ; 
        for(int i = 1 ; i <= n ; i++) 
        {
            if(i == x) continue ; 
            if(visited[i] == true) continue ; 
            
            if(i < x) 
            {
                ans.push_back({x,i}) ; 
                ans.push_back({i,x}) ; 
            }
            else 
            {
                ans.push_back({i,x}) ; 
            }
        }
    }
    
    cout << (int)ans.size() << endl; 
    
    for(auto v : ans) 
    {
        cout << v.first << " " << v.second << endl ;
    }
}


int32_t main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cout.tie(NULL) ;
    // init_code() ;
    ll t = 1 ; 
    // cin >> t;  
    while(t--) solve_test_case() ; 
    return 0 ; 
}


Submission (verdict: Wrong answer on test 39):
#include<bits/stdc++.h>
#include<stdio.h> 
#include<chrono>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds ; 
using ll = long long ;  
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> pbds ; 
ll inf = (4e18L) + 100 ;
ll ninf = (-4e18L) - 100 ;
const ll mod = 1e9 + 7 ; // 998244353; 
const int MAXN = 2e5 + 100 ; 

void solve_test_case() 
{     
    int n ; 
    cin >> n ; 
    
    vector<int> arr(n+1) ; 
    
    for(int i = 1 ; i <= n ; i++) cin >> arr[i] ; 
    vector<pair<int,int>> ans ;
    vector<bool> visited(n,false) ; 
    for(int j = n  ; j > 0 ; j--) 
    {
        int x = arr[j] ; 
        visited[x] = true ; 
        
        for(int i = x-1 ; i > 0 ; i--) 
        {
            if(visited[i] == true) continue ; 
            ans.push_back({x,i}) ;  
        }
        for(int i = 1 ; i <= x-1 ; i++) 
        {
            if(visited[i] == true) continue ; 
            ans.push_back({i,x}) ; 
        }
        
        for(int i = x+1 ; i <= n ; i++) 
        {
            if(visited[i] == true) continue ;
            ans.push_back({i,x}) ; 
        }
    }
    
    cout << (int)ans.size() << endl; 
    
    for(auto v : ans) 
    {
        cout << v.first << " " << v.second << endl ;
    }
}


int32_t main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cout.tie(NULL) ;
    // init_code() ;
    ll t = 1 ; 
    // cin >> t;  
    while(t--) solve_test_case() ; 
    return 0 ; 
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
#include<stdio.h> 
#include<chrono>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds ; 
using ll = long long ;  
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> pbds ; 
ll inf = (4e18L) + 100 ;
ll ninf = (-4e18L) - 100 ;
const ll mod = 1e9 + 7 ; // 998244353; 
const int MAXN = 2e5 + 100 ; 

void solve_test_case() 
{     
    int n ; 
    cin >> n ; 
    
    vector<int> arr(n+1) ; 
    
    for(int i = 1 ; i <= n ; i++) cin >> arr[i] ; 
    vector<pair<int,int>> ans ;
    vector<bool> visited(n,false) ; 
    for(int j = n  ; j > 0 ; j--) 
    {
        int x = arr[j] ; 
        visited[x] = true ; 
        for(int i = 1 ; i <= n ; i++) 
        {
            if(i == x) continue ; 
            if(visited[i] == true) continue ; 
            
            if(i < x) 
            {
                ans.push_back({x,i}) ; 
                ans.push_back({i,x}) ; 
            }
            else 
            {
                ans.push_back({i,x}) ; 
            }
        }
    }
    
    cout << (int)ans.size() << endl; 
    
    for(auto v : ans) 
    {
        cout << v.first << " " << v.second << endl ;
    }
}


int32_t main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cout.tie(NULL) ;
    // init_code() ;
    ll t = 1 ; 
    // cin >> t;  
    while(t--) solve_test_case() ; 
    return 0 ; 
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
// I AM NOT HERE TO PARTICIPATE, I AM HERE TO DOMINATE

#define JAI ios::sync_with_stdio(false);

#define SHREE cin.tie(NULL);

#define RAM cout.tie(NULL);

#include <bits/stdc++.h>



#define f(i, n, k) for (int i; i < n; i += k)

#define pb push_back

#define ppb pop_back

#define int long long

#define mp make_pair

using namespace std;

using vpi = vector < pair < int, int >> ;

using pi = pair < int, int > ;

using vi = vector < int > ;

using mapi = map < int, int > ;

using vvi = vector < vector < int >> ;

#define ff first

#define ss second

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

#define sz(x)(int)(x).size()

const int inf = 9e17;

const int mod = 1e9 + 7;

#define DEBUG(x) cerr << #x << ": " << x << '\n'

template < typename T, typename Y >

istream & operator >> (istream & is, pair < T, Y > & p)

{

is >> p.first >> p.second;

return is;

}

template < typename T, typename Y >

ostream & operator << (ostream & os, pair < T, Y > p)

{

os << p.first << ' ' << p.second << ' ';

return os;

}

template < typename T >

istream & operator >> (istream & is, vector < T > & v)

{

for (auto & i: v)

is >> i;

return is;

}

template < typename T >

ostream & operator << (ostream & os, vector < T > v)

{

for (auto & i: v)

os << i << ' ';

return os;

}



int power(int base, int ex, int mod) {

int res = 1;

while (ex > 0) {

if (ex % 2 == 1) {

res = (res * base) % mod;

}

base = (base * base) % mod;

ex /= 2;

}

return res;

}



void sol() {

int n ;

cin>>n;



string str = to_string(n);

for(int j = 0;j<str.length();j++){

for(int i = 1;i<str.length();i++){



if(str[i] - '0' -1 > str[i-1] - '0'){





str[i] = (str[i] - '0' - 1) + '0' ;



swap(str[i],str[i-1]);

}

}

}

cout<<str;

}



signed main() {



JAI SHREE RAM



int t;

cin >> t;





while (t--) {





sol();

cout<<endl;

}







}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    
    for (int T = 1; T <= t; T++){
        string s;
        cin >> s;

        string ans;
        while (s.length() > 0) {
            priority_queue<pair<int,int>> pq;
            for (int i = 0; i < (int)min(9, (int)s.length()); i++) {
                if (s[i] == '0') continue;
                if (!pq.empty() && pq.top().first == s[i]-'0'-i) continue;
                pq.push({s[i]-'0'-i, i});
            }
            if (pq.empty()) break;
            ans += '0' + pq.top().first;
            s.erase(s.begin()+pq.top().second);
        }

        for (int i = 0; i < s.length(); i++) {
            ans += s[i];
        }

        cout << ans << endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    
    for (int T = 1; T <= t; T++){
        string s;
        cin >> s;

        string ans;
        while (s.length() > 0) {
            priority_queue<pair<int,int>> pq;
            for (int i = 0; i < (int)min(9, (int)s.length()); i++) {
                if (s[i] == '0') continue;
                if (!pq.empty() && pq.top().first == s[i]-'0'-i) continue;
                pq.push({s[i]-'0'-i, i});
            }
            if (pq.empty()) break;
            ans += '0' + pq.top().first;
            if (pq.top().first == 0) s.erase(s.begin());
            else s.erase(s.begin()+pq.top().second);
        }

        for (int i = 0; i < s.length(); i++) {
            ans += s[i];
        }

        cout << ans << endl;
    }
}



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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    
    for (int T = 1; T <= t; T++){
        string s;
        cin >> s;

        string ans;
        while (s.length() > 0) {
            priority_queue<pair<int,int>> pq;
            for (int i = 0; i < (int)min(9, (int)s.length()); i++) {
                if (s[i] == '0' || s[i]-'0'-i < 0) continue;
                if (!pq.empty() && pq.top().first == s[i]-'0'-i) continue;
                pq.push({s[i]-'0'-i, i});
            }
            if (pq.empty()) break;
            ans += '0' + pq.top().first;
            if (pq.top().first == 0) s.erase(s.begin());
            else s.erase(s.begin()+pq.top().second);
        }

        for (int i = 0; i < s.length(); i++) {
            ans += s[i];
        }

        cout << ans << endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    
    for (int T = 1; T <= t; T++){
        string s;
        cin >> s;

        string ans;
        while (s.length() > 0) {
            priority_queue<pair<int,int>> pq;
            for (int i = 0; i < (int)min(9, (int)s.length()); i++) {
                if (s[i] == '0' || s[i]-'0'-i < 0) continue;
                if (!pq.empty() && pq.top().first == s[i]-'0'-i) continue;
                pq.push({s[i]-'0'-i, i});
            }
            if (pq.empty()) break;
            ans += '0' + pq.top().first;
            if (pq.top().first == 0) s.erase(s.begin());
            else s.erase(s.begin()+pq.top().second);
        }

        for (int i = 0; i < s.length(); i++) {
            ans += s[i];
        }

        cout << ans << endl;
    }
}



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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    
    for (int T = 1; T <= t; T++){
        string s;
        cin >> s;

        string ans;
        while (s.length() > 0) {
            priority_queue<pair<int,int>> pq;
            for (int i = 0; i < (int)min(9, (int)s.length()); i++) {
                if (s[i]-'0'-i < 0) continue;
                if (!pq.empty() && pq.top().first == s[i]-'0'-i) continue;
                pq.push({s[i]-'0'-i, i});
            }
            if (pq.empty()) break;
            ans += '0' + pq.top().first;
            if (pq.top().first == 0) s.erase(s.begin());
            else s.erase(s.begin()+pq.top().second);
        }

        for (int i = 0; i < s.length(); i++) {
            ans += s[i];
        }

        cout << ans << endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    
    for (int T = 1; T <= t; T++){
        string s;
        cin >> s;

        string ans;
        while (s.length() > 0) {
            priority_queue<pair<int,int>> pq;
            for (int i = 0; i < (int)min(9, (int)s.length()); i++) {
                if (s[i] == '0') continue;
                if (!pq.empty() && pq.top().first == s[i]-'0'-i) continue;
                pq.push({s[i]-'0'-i, i});
            }
            if (pq.empty()) break;
            ans += '0' + pq.top().first;
            s.erase(s.begin()+pq.top().second);
        }

        for (int i = 0; i < s.length(); i++) {
            ans += s[i];
        }

        cout << ans << endl;
    }
}



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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    
    for (int T = 1; T <= t; T++){
        string s;
        cin >> s;

        string ans;
        while (s.length() > 0) {
            priority_queue<pair<int,int>> pq;
            for (int i = 0; i < (int)min(9, (int)s.length()); i++) {
                if (s[i] == '0') continue;
                if (!pq.empty() && pq.top().first == s[i]-'0'-i) continue;
                pq.push({s[i]-'0'-i, i});
            }
            if (pq.empty()) break;
            ans += '0' + pq.top().first;
            if (pq.top().first == 0) s.erase(s.begin());
            else s.erase(s.begin()+pq.top().second);
        }

        for (int i = 0; i < s.length(); i++) {
            ans += s[i];
        }

        cout << ans << 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;
bool b[201010];
int n, a[201010], t;
int main(){
	scanf("%d", &t);
	for(int l = 1; l <= t; l++){
		scanf("%d", &n);
		for(int i = 1; i <= n; i++){
			scanf("%d", &a[i]);
		}
		b[n] = true;
		for(int i = n - 1; i > 0; i--){
			if(b[i + 1] == false){
				b[i] = false;
			}
			else{
				if(a[i] <= a[i + 1]){
					b[i] = true;
				}
				else{
					b[i] = false;
					b[i + 1] = false;
				}
			}
		}
		bool z = true;
		for(int i = 2; !b[i]; i++){
			int k = min(a[i], a[i - 1]);
			a[i] -= k;
			a[i - 1] -= k;
			if(a[i - 1] > 0){
				z = false;
				break;
			}
			if(a[i] <= a[i + 1] && b[i + 1])
				break;
		}
		if(a[2] < a[1])
			z = false;
		if(a[n - 1] > a[n])
			z = false;
		if(z)
			printf("YES\n");
		else
			printf("NO\n");
	}
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
bool b[201010];
int n, a[201010], t;
int main(){
	scanf("%d", &t);
	for(int l = 1; l <= t; l++){
		scanf("%d", &n);
		for(int i = 1; i <= n; i++){
			scanf("%d", &a[i]);
		}
		b[n] = true;
		for(int i = n - 1; i > 0; i--){
			if(b[i + 1] == false){
				b[i] = false;
			}
			else{
				if(a[i] <= a[i + 1]){
					b[i] = true;
				}
				else{
					b[i] = false;
					b[i + 1] = false;
				}
			}
		}
		bool z = true;
		for(int i = 2; !b[i] && i <= n; i++){
			int k = min(a[i], a[i - 1]);
			a[i] -= k;
			a[i - 1] -= k;
			if(a[i - 1] > 0){
				z = false;
				break;
			}
			if(a[i] <= a[i + 1] && b[i + 1])
				break;
		}
		if(a[2] < a[1])
			z = false;
		if(a[n - 1] > a[n])
			z = false;
		if(z)
			printf("YES\n");
		else
			printf("NO\n");
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
bool b[201010];
int n, a[201010], t;
int main(){
	scanf("%d", &t);
	for(int l = 1; l <= t; l++){
		scanf("%d", &n);
		for(int i = 1; i <= n; i++){
			scanf("%d", &a[i]);
		}
		b[n] = true;
		for(int i = n - 1; i > 0; i--){
			if(b[i + 1] == false){
				b[i] = false;
			}
			else{
				if(a[i] <= a[i + 1]){
					b[i] = true;
				}
				else{
					b[i] = false;
				}
			}
		}
		bool z = true;
		for(int i = 2; !b[i]; i++){
			int k = min(a[i], a[i - 1]);
			a[i] -= k;
			a[i - 1] -= k;
			if(a[i - 1] > 0){
				z = false;
				break;
			}
			if(a[i] <= a[i + 1] && b[i + 1])
				break;
		}
		if(a[2] < a[1])
			z = false;
		if(a[n - 1] > a[n])
			z = false;
		if(z)
			printf("YES\n");
		else
			printf("NO\n");
	}
}
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;
bool b[201010];
int n, a[201010], t;
int main(){
	scanf("%d", &t);
	for(int l = 1; l <= t; l++){
		scanf("%d", &n);
		for(int i = 1; i <= n; i++){
			scanf("%d", &a[i]);
		}
		b[n] = true;
		for(int i = n - 1; i > 0; i--){
			if(b[i + 1] == false){
				b[i] = false;
			}
			else{
				if(a[i] <= a[i + 1]){
					b[i] = true;
				}
				else{
					b[i] = false;
				}
			}
		}
		bool z = true;
		for(int i = 2; !b[i]; i++){
			int k = min(a[i], a[i - 1]);
			a[i] -= k;
			a[i - 1] -= k;
			if(a[i - 1] > 0){
				z = false;
				break;
			}
			if(a[i] <= a[i + 1] && b[i + 1])
				break;
		}
		if(a[2] < a[1])
			z = false;
		if(a[n - 1] > a[n])
			z = false;
		if(z)
			printf("YES\n");
		else
			printf("NO\n");
	}
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
bool b[201010];
int n, a[201010], t;
int main(){
	scanf("%d", &t);
	for(int l = 1; l <= t; l++){
		scanf("%d", &n);
		for(int i = 1; i <= n; i++){
			scanf("%d", &a[i]);
		}
		b[n] = true;
		for(int i = n - 1; i > 0; i--){
			if(b[i + 1] == false){
				b[i] = false;
			}
			else{
				if(a[i] <= a[i + 1]){
					b[i] = true;
				}
				else{
					b[i] = false;
					b[i + 1] = false;
				}
			}
		}
		bool z = true;
		for(int i = 2; !b[i]; i++){
			int k = min(a[i], a[i - 1]);
			a[i] -= k;
			a[i - 1] -= k;
			if(a[i - 1] > 0){
				z = false;
				break;
			}
			if(a[i] <= a[i + 1] && b[i + 1])
				break;
		}
		if(a[2] < a[1])
			z = false;
		if(a[n - 1] > a[n])
			z = false;
		if(z)
			printf("YES\n");
		else
			printf("NO\n");
	}
}
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() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int n,l,r;
	    cin>>n>>l>>r;
	    
	    vector<int> vec(n);
	    for(int i = 0;i<n;i++){
	        cin>>vec[i];
	    }
	    int k = r- l +1;
	    sort(vec.begin(),vec.end());
	    int ans = 0;
	    
	    for(int i= 0;i<k;i++){
	        ans += vec[i];
	    }
	   // cout<<"Her"<<endl;
	    cout<<ans<<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() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int n,l,r;
	    cin>>n>>l>>r;
	    
	    vector<int> vec(n);
	    for(int i = 0;i<n;i++){
	        cin>>vec[i];
	    }
	    int k = r- l +1;
	    sort(vec.begin(),vec.end());
	    int ans = 0;
	    
	    for(int i= 0;i<k;i++){
	        ans += vec[i];
	    }
	   // cout<<"Her"<<endl;
	    cout<<ans<<endl;
	}


}


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

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int n,l,r;
	    cin>>n>>l>>r;
	    
	    vector<int> vec(n);
	    for(int i = 0;i<n;i++){
	        cin>>vec[i];
	    }
	    int k = r- l +1;
	    vector<int> v1,v2;
	    for(int i = 0;i<r;i++){
	        v1.push_back(vec[i]);
	    }
	    for(int i = l-1;i<n;i++){
	        v2.push_back(vec[i]);
	    }
	    int a1= 0,a2=0;
	    sort(v1.begin(),v1.end());
	    sort(v2.begin(),v2.end());
	    for(int i = 0;i<k;i++){
	        a1 += v1[i];
	        a2 += v2[i];
	        
	    }
	   // cout<<"Her"<<endl;
	    cout<<min(a1,a2)<<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() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int n,l,r;
	    cin>>n>>l>>r;
	    
	    vector<int> vec(n);
	    for(int i = 0;i<n;i++){
	        cin>>vec[i];
	    }
	    int k = r- l +1;
	    vector<int> v1,v2;
	    for(int i = 0;i<r;i++){
	        v1.push_back(vec[i]);
	    }
	    for(int i = l-1;i<n;i++){
	        v2.push_back(vec[i]);
	    }
	    int a1= 0,a2=0;
	    sort(v1.begin(),v1.end());
	    sort(v2.begin(),v2.end());
	    for(int i = 0;i<k;i++){
	        a1 += v1[i];
	        a2 += v2[i];
	        
	    }
	   // cout<<"Her"<<endl;
	    cout<<min(a1,a2)<<endl;
	}


}


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

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int n,l,r;
	    cin>>n>>l>>r;
	    
	    vector<int> vec(n);
	    for(int i = 0;i<n;i++){
	        cin>>vec[i];
	    }
	    int k = r- l +1;
	    vector<int> v1,v2;
	    for(int i = 0;i<r;i++){
	        v1.push_back(vec[i]);
	    }
	    for(int i = l-1;i<n;i++){
	        v2.push_back(vec[i]);
	    }
	    long long a1= 0,a2=0;
	    sort(v1.begin(),v1.end());
	    sort(v2.begin(),v2.end());
	    for(int i = 0;i<k;i++){
	        a1 += v1[i];
	        a2 += v2[i];
	        
	    }
	   // cout<<"Her"<<endl;
	    cout<<min(a1,a2)<<endl;
	}


}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

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

 

using namespace std;

 #define int long long

 

 

 

 bool solve(){

  int n;

  cin>>n;

  string s;cin>>s;

  

  int flag=0;

  int flag2=0;

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

    if(s[i]!='.')flag2=1;

  if(s[i]=='p')flag=1;

  if(flag&&s[i]=='s'){return 0;}

  }

  if(flag2 && s[0]=='.' && s[n-1]=='.')return 0;

  return 1;

 }

 

 

int32_t main() {

   

int t;cin>>t;

while(t--){

  bool a=solve();

  if(a)cout<<"YES"<<endl;

   else cout<<"NO"<<endl;

}

return 0;

}

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

 

using namespace std;

 #define int long long

 

 

 

 bool solve(){

  int n;

  cin>>n;

  string s;cin>>s;

  

  int flag=0;

  int flag2=0;

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

    if(s[i]=='s')flag2=1;

  if(s[i]=='p')flag=1;

  if(flag&&s[i]=='s'){return 0;}

  }

  if(flag &&flag2 && s[0]=='.' && s[n-1]=='.')return 0;

  return 1;

 }

 

 

int32_t main() {

   

int t;cin>>t;

while(t--){

  bool a=solve();

  if(a)cout<<"YES"<<endl;

   else cout<<"NO"<<endl;

}

return 0;

}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)


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

 

using namespace std;

 #define int long long

 

 

 

 bool solve(){

  int n;

  cin>>n;

  string s;cin>>s;

  

  int flag=0;

  int flag2=0;

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

    if(s[i]!='.')flag2=1;

  if(s[i]=='p')flag=1;

  if(flag&&s[i]=='s'){return 0;}

  }

  if(flag2 && s[0]=='.' && s[n-1]=='.')return 0;

  return 1;

 }

 

 

int32_t main() {

   

int t;cin>>t;

while(t--){

  bool a=solve();

  if(a)cout<<"YES"<<endl;

   else cout<<"NO"<<endl;

}

return 0;

}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

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

 

using namespace std;

 #define int long long

 

 

 

 bool solve(){

  int n;

  cin>>n;

  string s;cin>>s;

  

  int flag=0;

  int flag2=0;

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

    if(s[i]=='s')flag2=1;

  if(s[i]=='p')flag=1;

  if(flag&&s[i]=='s'){return 0;}

  }

  if(flag &&flag2 && s[0]=='.' && s[n-1]=='.')return 0;

  return 1;

 }

 

 

int32_t main() {

   

int t;cin>>t;

while(t--){

  bool a=solve();

  if(a)cout<<"YES"<<endl;

   else cout<<"NO"<<endl;

}

return 0;

}

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

 

using namespace std;

 #define int long long

 

 

 

 bool solve(){

  int n;

  cin>>n;

  string s;cin>>s;

  

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

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

  int flag1=0;int flag2=0;

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

    if(s[i]=='s')flag1=1;

    if(s[i]=='p')flag2=1;

  }

  if(flag1 &&flag2)return 0;

  return 1;

 }

 

 

int32_t main() {

   

int t;cin>>t;

while(t--){

  bool a=solve();

  if(a)cout<<"YES"<<endl;

   else cout<<"NO"<<endl;

}

return 0;

}