ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;



template <class T>

using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define int long long int

#define pb push_back

#define pi pair<int, int>

#define pii pair<int, pi>

#define fir first

#define sec second

#define MAXN 200005

#define mod 998244353



signed main()

{

  ios_base::sync_with_stdio(false);

  cin.tie(NULL);

  int q;

  cin >> q;

  while (q--)

  {

    int n, l, r;

    cin >> n >> l >> r;

    l--, r--;

    vector<int> v(n);

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

      cin >> v[i];

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

    int ans = 1e18;

    {

      vector<int> v2;

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

        v2.pb(v[i]);

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

      int curr = 0;

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

        curr += v2[i];

      ans = min(ans, curr);

    }

    {

      vector<int> v2;

      for (int i = n - 1; i >= l; i--)

        v2.pb(v[i]);

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

      int curr = 0;

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

        curr += v2[i];

      ans = min(ans, curr);

    }

    cout << ans << endl;

  }

}

// eu nao tinha lido o exactly once :)

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;



template <class T>

using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define int long long int

#define pb push_back

#define pi pair<int, int>

#define pii pair<int, pi>

#define fir first

#define sec second

#define MAXN 200005

#define mod 998244353



signed main()

{

  ios_base::sync_with_stdio(false);

  cin.tie(NULL);

  int q;

  cin >> q;

  while (q--)

  {

    int n, l, r;

    cin >> n >> l >> r;

    l--, r--;

    vector<int> v(n);

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

      cin >> v[i];

    int ans = 1e18;

    {

      vector<int> v2;

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

        v2.pb(v[i]);

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

      int curr = 0;

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

        curr += v2[i];

      ans = min(ans, curr);

    }

    {

      vector<int> v2;

      for (int i = n - 1; i >= l; i--)

        v2.pb(v[i]);

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

      int curr = 0;

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

        curr += v2[i];

      ans = min(ans, curr);

    }

    cout << ans << endl;

  }

}

// eu nao tinha lido o exactly once :)
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;



template <class T>

using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define int long long int

#define pb push_back

#define pi pair<int, int>

#define pii pair<int, pi>

#define fir first

#define sec second

#define MAXN 200005

#define mod 998244353



signed main()

{

  ios_base::sync_with_stdio(false);

  cin.tie(NULL);

  int q;

  cin >> q;

  while (q--)

  {

    int n, l, r;

    cin >> n >> l >> r;

    vector<int> v(n);

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

    {

      cin >> v[i];

    }

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

    int ans = 0;

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

      ans += v[i];

    cout << ans << endl;

  }

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;



template <class T>

using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define int long long int

#define pb push_back

#define pi pair<int, int>

#define pii pair<int, pi>

#define fir first

#define sec second

#define MAXN 200005

#define mod 998244353



signed main()

{

  ios_base::sync_with_stdio(false);

  cin.tie(NULL);

  int q;

  cin >> q;

  while (q--)

  {

    int n, l, r;

    cin >> n >> l >> r;

    vector<int> v(n);

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

    {

      cin >> v[i];

    }

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

    int ans = 0;

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

      ans += v[i];

    cout << ans << endl;

  }

}

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;



template <class T>

using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define int long long int

#define pb push_back

#define pi pair<int, int>

#define pii pair<int, pi>

#define fir first

#define sec second

#define MAXN 200005

#define mod 998244353



signed main()

{

  ios_base::sync_with_stdio(false);

  cin.tie(NULL);

  int q;

  cin >> q;

  while (q--)

  {

    int n, l, r;

    cin >> n >> l >> r;

    l--, r--;

    vector<int> v(n);

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

      cin >> v[i];

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

    int ans = 1e18;

    {

      vector<int> v2;

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

        v2.pb(v[i]);

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

      int curr = 0;

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

        curr += v2[i];

      ans = min(ans, curr);

    }

    {

      vector<int> v2;

      for (int i = n - 1; i >= l; i--)

        v2.pb(v[i]);

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

      int curr = 0;

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

        curr += v2[i];

      ans = min(ans, curr);

    }

    cout << ans << endl;

  }

}

// eu nao tinha lido o exactly once :)
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<string>
#include<set>
#include<deque>
#include<stack>
#include<sstream>
#include<queue>
typedef long long ll;
using namespace std;

void solve() {
	int n; cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int t; cin >> t;
		a.push_back(t);
	}
	bool f = 1;
	bool k = 0; bool l = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] < a[i - 1]) {
			if (i > 2&&k!=1&&(a[0]!=0||a[1]!=0||a[2]!=0)) {
				l = 1;
			}
			if (i != 1) {
				if (a[i - 1] - a[i - 2] > a[i]) {
					f = 0;
					break;
				}
				else {
					if (l) {
						f = 0;
						break;
					}
					a[i - 1] -= a[i - 2];
					a[i - 2] = 0;
				
				}
			}
			else f = 0; 
			k = 1;
		}
	}
	if (f)cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

Submission (verdict: Accepted):
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<string>
#include<set>
#include<deque>
#include<stack>
#include<sstream>
#include<queue>
typedef long long ll;
using namespace std;

void solve() {
	int n; cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int t; cin >> t;
		a.push_back(t);
	}
	bool f = 1;
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			if (a[i] <= a[i + 1]) {
				int x = a[i];
				a[i] -= x;
				a[i + 1] -= x;
			}
			else {
				f = 0;
				break;
			}
		}
		else if(i==n-1){
			if (a[i] < a[i - 1]) f = 0;
		}
		else {
			if (a[i] <= a[i + 1] + a[i - 1]) {
				int x = a[i];
				a[i] -= x;
				a[i + 1] -= x;
			}
			else {
				f = 0;
				break;
			}
		}
	}
	if (f)cout << "YES" << endl;
	else cout << "NO" << endl;
}

int main()
{
	int t; cin >> t;
	while (t--)
		solve();
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<string>
#include<set>
#include<deque>
#include<stack>
#include<sstream>
#include<queue>
typedef long long ll;
using namespace std;

void solve() {
	int n; cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int t; cin >> t;
		a.push_back(t);
	}
	bool f = 1;
	for (int i = 1; i < n; i++) {
		if (a[i] < a[i - 1]) {
			if (i != 1) {
				if (a[i - 1] - a[i - 2] > a[i]) {
					f = 0;
					break;
				}
				else {
					a[i - 1] -= a[i - 2];
					a[i - 2] = 0;
				}
			}
			else f = 0;
		}
	}
	if (f)cout << "YES" << endl;
	else cout << "NO" << endl;
}

int main()
{
	int t; cin >> t;
	while (t--)
		solve();
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<string>
#include<set>
#include<deque>
#include<stack>
#include<sstream>
#include<queue>
typedef long long ll;
using namespace std;

void solve() {
	int n; cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int t; cin >> t;
		a.push_back(t);
	}
	bool f = 1;
	for (int i = 1; i < n; i++) {
		if (a[i] < a[i - 1]) {
			if (i != 1) {
				if (a[i - 1] - a[i - 2] > a[i]) {
					f = 0;
					break;
				}
				else {
					a[i - 1] -= a[i - 2];
					a[i - 2] = 0;
				}
			}
			else f = 0;
		}
	}
	if (f)cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<string>
#include<set>
#include<deque>
#include<stack>
#include<sstream>
#include<queue>
typedef long long ll;
using namespace std;

void solve() {
	int n; cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int t; cin >> t;
		a.push_back(t);
	}
	bool f = 1;
	bool k = 0; bool l = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] < a[i - 1]) {
			if (i > 2&&k!=1&&(a[0]!=0||a[1]!=0||a[2]!=0)) {
				l = 1;
			}
			if (i != 1) {
				if (a[i - 1] - a[i - 2] > a[i]) {
					f = 0;
					break;
				}
				else {
					if (l) {
						f = 0;
						break;
					}
					a[i - 1] -= a[i - 2];
					a[i - 2] = 0;
				
				}
			}
			else f = 0; 
			k = 1;
		}
	}
	if (f)cout << "YES" << endl;
	else cout << "NO" << endl;
}

int main()
{
	int t; cin >> t;
	while (t--)
		solve();
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int sum(vector<int>&v){
    int tot = 0;
    for(int i = 0;i < v.size() - 1;i++)
        tot += v[i] - v[i + 1] ;
    return tot;
}
int sumall(vector<int>&v){
    int sum = 0;
    for(int i = 0;i < v.size();i++){
        sum +=v[i];
    }
    return sum;
}
void _()
{
    int n; cin >> n;
    vector<int>v(n);
    for(int i = 0;i < n;i++)
        cin >> v[i];
    int res = -1e10;
    while(!v.empty()){
        res = max(res,sumall(v));
        vector<int>a = v,b = v;
        reverse(a.begin(),a.end());
        if(sum(a) > sum(b)){
            reverse(v.begin(),v.end());
        }
        for(int i = 0;i < a.size() - 1;i++){
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
    }
    cout << res << endl;
}
signed main()
{
    int t = 1;cin >> t;
    while(t--)
    {
        _();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int sum(vector<int>&v){
    int tot = 0;
    for(int i = 1;i < v.size() - 1;i++)
        tot += v[i] - v[i - 1] ;
    return tot;
}
int sumall(vector<int>&v){
    int sum = 0;
    for(int i = 0;i < v.size();i++){
        sum +=v[i];
    }
    return sum;
}
void _()
{
    int n; cin >> n;
    vector<int>v(n);
    for(int i = 0;i < n;i++)
        cin >> v[i];
    int res = -1e10;
    while(!v.empty()){
        res = max(res,sumall(v));
        vector<int>a = v,b = v;
        reverse(a.begin(),a.end());
        if(sum(a) > sum(b)){
            reverse(v.begin(),v.end());
        }
        for(int i = 0;i < v.size() - 1;i++){
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
    }
    cout << res << endl;
}
signed main()
{
    int t = 1;cin >> t;
    while(t--)
    {
        _();
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int sum(vector<int>&v){
    int tot = 0;
    for(int i = 1;i < v.size();i++)
        tot += v[i] - v[i - 1] ;
    return tot;
}
int sumall(vector<int>&v){
    int sum = 0;
    for(int i = 0;i < v.size();i++){
        sum +=v[i];
    }
    return sum;
}
void _()
{
    int n; cin >> n;
    vector<int>v(n);
    for(int i = 0;i < n;i++)
        cin >> v[i];
    int res = -1e10;
    while(!v.empty()){
        res = max(res,sumall(v));
        vector<int>a = v,b = v;
        reverse(a.begin(),a.end());
        if(sum(a) > sum(b)){
            reverse(v.begin(),v.end());
        }
        for(int i = 0;i < v.size() - 1;i++){
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
    }
    cout << res << endl;
}
signed main()
{
    int t = 1;cin >> t;
    while(t--)
    {
        _();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int sum(vector<int>&v){
    int tot = 0;
    for(int i = 0;i < v.size() - 1;i++)
        tot += v[i] - v[i + 1] ;
    return tot;
}
int sumall(vector<int>&v){
    int sum = 0;
    for(int i = 0;i < v.size();i++){
        sum +=v[i];
    }
    return sum;
}
void _()
{
    int n; cin >> n;
    vector<int>v(n);
    for(int i = 0;i < n;i++)
        cin >> v[i];
    int res = -1e10;
    while(!v.empty()){
        res = max(res,sumall(v));
        vector<int>a = v,b = v;
        reverse(a.begin(),a.end());
        if(sum(a) > sum(b)){
            reverse(v.begin(),v.end());
        }
        for(int i = 0;i < v.size() - 1;i++){
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
    }
    cout << res << endl;
}
signed main()
{
    int t = 1;cin >> t;
    while(t--)
    {
        _();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int sum(vector<int>&v){
    int tot = 0;
    for(int i = 1;i < v.size() - 1;i++)
        tot += v[i] - v[i - 1] ;
    return tot;
}
int sumall(vector<int>&v){
    int sum = 0;
    for(int i = 0;i < v.size();i++){
        sum +=v[i];
    }
    return sum;
}
void _()
{
    int n; cin >> n;
    vector<int>v(n);
    for(int i = 0;i < n;i++)
        cin >> v[i];
    int res = -1e10;
    while(!v.empty()){
        res = max(res,sumall(v));
        vector<int>a = v,b = v;
        reverse(a.begin(),a.end());
        if(sum(a) > sum(b)){
            reverse(v.begin(),v.end());
        }
        for(int i = 0;i < v.size() - 1;i++){
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
    }
    cout << res << endl;
}
signed main()
{
    int t = 1;cin >> t;
    while(t--)
    {
        _();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int sum(vector<int>&v){
    int tot = 0;
    for(int i = 0;i < v.size() - 1;i++)
        tot += v[i] - v[i + 1] ;
    return tot;
}
int sumall(vector<int>&v){
    int sum = 0;
    for(int i = 0;i < v.size();i++){
        sum +=v[i];
    }
    return sum;
}
void _()
{
    int n; cin >> n;
    vector<int>v(n);
    for(int i = 0;i < n;i++)
        cin >> v[i];
    int res = -1e10;
    while(!v.empty()){
        res = max(res,sumall(v));
        vector<int>a = v,b = v;
        reverse(a.begin(),a.end());
        if(sum(a) > sum(b)){
            reverse(v.begin(),v.end());
        }
        for(int i = 0;i < a.size() - 1;i++){
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
    }
    cout << res << endl;
}
signed main()
{
    int t = 1;cin >> t;
    while(t--)
    {
        _();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int sum(vector<int>&v){
    int tot = 0;
    for(int i = 0;i < v.size() - 1;i++)
        tot += v[i] - v[i + 1] ;
    return tot;
}
int sumall(vector<int>&v){
    int sum = 0;
    for(int i = 0;i < v.size();i++){
        sum +=v[i];
    }
    return sum;
}
void _()
{
    int n; cin >> n;
    vector<int>v(n);
    for(int i = 0;i < n;i++)
        cin >> v[i];
    int res = -1e10;
    while(!v.empty()){
        res = max(res,sumall(v));
        vector<int>a = v,b = v;
        reverse(a.begin(),a.end());
        if(sum(a) > sum(b)){
            reverse(v.begin(),v.end());
        }
        for(int i = 0;i < v.size() - 1;i++){
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
    }
    cout << res << endl;
}
signed main()
{
    int t = 1;cin >> t;
    while(t--)
    {
        _();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

#define int long long

#define endl '\n';

#define cin(c) for(auto&xyz:c)cin>>xyz

#define cout(c) for(auto&xyz:c)cout<<xyz<<' ';

const int N = 1e5 + 5, MOD = 1e9 + 7, LOG = 30;

const int dx[4] = {0, 1, 0, -1};

const int dy[4] = {1, 0, -1, 0};



using namespace std;



void fast() {

ios::sync_with_stdio(false);

cin.tie(nullptr);

cout.tie(nullptr);

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

}



vector<int> LPS(string str) {

vector<int> lps(str.size());

for (int i = 0, j = 1; j < str.size();) {

while (j < str.size() and str[i] == str[j]) {

lps[j] = i + 1;

++i, ++j;

}

if (i == 0)++j;

else i = lps[i - 1];

}

return lps;

}



void solve() {

int n;

cin >> n;

vector<int> arr(n);

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

cin >> arr[i];

}

if (arr[n-2] > arr[n-1]) {

cout<<"NO\n";

return;

}

cout<<"YES\n";

}



int32_t main() {

fast();

int q = 1;

cin >> q;

while (q--)solve();

}



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

#define int long long

#define endl '\n';

#define cin(c) for(auto&xyz:c)cin>>xyz

#define cout(c) for(auto&xyz:c)cout<<xyz<<' ';

const int N = 1e5 + 5, MOD = 1e9 + 7, LOG = 30;

const int dx[4] = {0, 1, 0, -1};

const int dy[4] = {1, 0, -1, 0};



using namespace std;



void fast() {

ios::sync_with_stdio(false);

cin.tie(nullptr);

cout.tie(nullptr);

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

}



vector<int> LPS(string str) {

vector<int> lps(str.size());

for (int i = 0, j = 1; j < str.size();) {

while (j < str.size() and str[i] == str[j]) {

lps[j] = i + 1;

++i, ++j;

}

if (i == 0)++j;

else i = lps[i - 1];

}

return lps;

}



void solve() {

int n;

cin >> n;

int arr[n];

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

cin >> arr[i];

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

if (arr[i] >= arr[i - 1])

{

arr[i] -= arr[i - 1];

arr[i - 1] = 0;

}

int temp = arr[0];

bool flag = true;

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

{

if (arr[i] < temp)

{

flag = false;

}

temp = arr[i];

}

cout << (flag ? "YES\n" : "NO\n");

}



int32_t main() {

fast();

int q = 1;

cin >> q;

while (q--)solve();

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

#define int long long

#define endl '\n';

#define cin(c) for(auto&xyz:c)cin>>xyz

#define cout(c) for(auto&xyz:c)cout<<xyz<<' ';

const int N = 1e5 + 5, MOD = 1e9 + 7, LOG = 30;

const int dx[4] = {0, 1, 0, -1};

const int dy[4] = {1, 0, -1, 0};



using namespace std;



void fast() {

ios::sync_with_stdio(false);

cin.tie(nullptr);

cout.tie(nullptr);

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

}



vector<int> LPS(string str) {

vector<int> lps(str.size());

for (int i = 0, j = 1; j < str.size();) {

while (j < str.size() and str[i] == str[j]) {

lps[j] = i + 1;

++i, ++j;

}

if (i == 0)++j;

else i = lps[i - 1];

}

return lps;

}



void solve() {

int n;

cin >> n;

vector<int> arr(n);

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

cin >> arr[i];

}

if (arr[n-2] > arr[n-1]) {

cout<<"NO\n";

return;

}

arr[0] = arr[1] = 0;

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

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

if (arr[i] != arr[i - 1])

arr[i] = arr[i - 1];

else

arr[i] = arr[i - 1] = 0;

--i;

}

}

if(is_sorted(arr.begin(),arr.end())) {

cout<<"YES\n";

}

else {

cout<<"NO\n";

}

}



int32_t main() {

fast();

int q = 1;

cin >> q;

while (q--)solve();

}



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

#define int long long

#define endl '\n';

#define cin(c) for(auto&xyz:c)cin>>xyz

#define cout(c) for(auto&xyz:c)cout<<xyz<<' ';

const int N = 1e5 + 5, MOD = 1e9 + 7, LOG = 30;

const int dx[4] = {0, 1, 0, -1};

const int dy[4] = {1, 0, -1, 0};



using namespace std;



void fast() {

ios::sync_with_stdio(false);

cin.tie(nullptr);

cout.tie(nullptr);

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

}



vector<int> LPS(string str) {

vector<int> lps(str.size());

for (int i = 0, j = 1; j < str.size();) {

while (j < str.size() and str[i] == str[j]) {

lps[j] = i + 1;

++i, ++j;

}

if (i == 0)++j;

else i = lps[i - 1];

}

return lps;

}



void solve() {

int n;

cin >> n;

vector<int> arr(n);

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

cin >> arr[i];

}

if (arr[n-2] > arr[n-1]) {

cout<<"NO\n";

return;

}

cout<<"YES\n";

}



int32_t main() {

fast();

int q = 1;

cin >> q;

while (q--)solve();

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

#define int long long

#define endl '\n';

#define cin(c) for(auto&xyz:c)cin>>xyz

#define cout(c) for(auto&xyz:c)cout<<xyz<<' ';

const int N = 1e5 + 5, MOD = 1e9 + 7, LOG = 30;

const int dx[4] = {0, 1, 0, -1};

const int dy[4] = {1, 0, -1, 0};



using namespace std;



void fast() {

ios::sync_with_stdio(false);

cin.tie(nullptr);

cout.tie(nullptr);

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

}



vector<int> LPS(string str) {

vector<int> lps(str.size());

for (int i = 0, j = 1; j < str.size();) {

while (j < str.size() and str[i] == str[j]) {

lps[j] = i + 1;

++i, ++j;

}

if (i == 0)++j;

else i = lps[i - 1];

}

return lps;

}



void solve() {

int n;

cin >> n;

vector<int> arr(n);

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

cin >> arr[i];

}

if (arr[n-2] > arr[n-1]) {

cout<<"NO\n";

return;

}

arr[0] = arr[1] = 0;

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

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

if (arr[i] != arr[i - 1])

arr[i] = arr[i - 1];

else

arr[i] = arr[i - 1] = 0;

--i;

}

}

if(is_sorted(arr.begin(),arr.end())) {

cout<<"YES\n";

}

else {

cout<<"NO\n";

}

}



int32_t main() {

fast();

int q = 1;

cin >> q;

while (q--)solve();

}
Problem: 2050E - Three Strings
Language: PyPy 3-64


Submission (verdict: Runtime error on test 14):
from sys import stdin
input = lambda: stdin.buffer.readline().decode().strip()
from functools import cache


for _ in range(int(input())):
    a = input(); n = len(a)
    b = input(); m = len(b)
    c = input()

    @cache
    def solve(i, j):
        if i + j == n + m: return 0
        ans1 = (solve(i + 1, j) + (a[i] != c[i + j])) if i < n else float('inf')
        ans2 = (solve(i, j + 1) + (b[j] != c[i + j])) if j < m else float('inf')
        return min(ans1, ans2)

    print(solve(0, 0))
    solve.cache_clear()