ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: c++20 

Code 1:
#include <bits/stdc++.h>



using namespace std;



void noTimeLimit()

{

cin.tie(0);

cin.sync_with_stdio(0);

cout.tie(0);

cout.sync_with_stdio(0);

}

#define ll long long

#define ss string

#define dd double

#define yes "YES"

#define v vector<ll>



#define no "NO"

#define el "\n"

#define fr(x, i, n) for (ll i = x; i < n; i++)

#define frr(i, n) for (ll i = n - 1; i >= 0; i--)

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

#define allr(a) a.rbegin(), a.rend()

#define pi 3.141592653589793238462643383279502884197

#define ee 2.718281828459045

const ll mod = 1e9 + 7;

int inf = 1e9;



void solve()

{

int n;

cin >> n;

vector<int> a(n);

fr(0, i, n) cin >> a[i];

bool f = 1;

if (a[0] == *max_element(all(a)))

return void(cout << no);

fr(1, i, n - 1)

{

if ((a[i] > a[i + 1] and a[i] < a[i - 1]) or (a[i] > a[i + 1] and a[i] - a[i + 1] > a[i - 1]) or (a[i] > a[i - 1] and a[i] - a[i - 1] > a[i + 1]))

f = 0;

}

if (f)

cout << yes;

else

cout << no;

}



int main()

{

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

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

noTimeLimit();

int testCase = 1;

cin >> testCase;

while (testCase--)

{

solve();

cout << el;

}

return 0;

}

Code 2:
#include <bits/stdc++.h>



using namespace std;



void noTimeLimit()

{

cin.tie(0);

cin.sync_with_stdio(0);

cout.tie(0);

cout.sync_with_stdio(0);

}

#define ll long long

#define ss string

#define dd double

#define yes "YES"

#define v vector<ll>



#define no "NO"

#define el "\n"

#define fr(x, i, n) for (ll i = x; i < n; i++)

#define frr(i, n) for (ll i = n - 1; i >= 0; i--)

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

#define allr(a) a.rbegin(), a.rend()

#define pi 3.141592653589793238462643383279502884197

#define ee 2.718281828459045

const ll mod = 1e9 + 7;

int inf = 1e9;



void solve()

{

int n;

cin >> n;

vector<int> a(n);

fr(0, i, n) cin >> a[i];

fr(1, i, n)

{

int minn = min(a[i], a[i - 1]);

a[i] -= minn, a[i - 1] -= minn;

}

bool f = 1;

fr(0, i, n - 1)

{

if (a[i] > a[i + 1])

f = 0;

}

if (f)

cout << yes;

else

cout << no;

}



int main()

{

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

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

noTimeLimit();

int testCase = 1;

cin >> testCase;

while (testCase--)

{

solve();

cout << el;

}

return 0;

}

Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++17 

Code 1:
#include <bits/stdc++.h>

#define ll long long

#define mod 1000000007

using namespace std;



int main() {

#ifndef ONLINE_JUDGE

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

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

#endif

// your code goes here

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int>v(n);

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

cin>>v[i];

}

if(v[0]>=v[1]){

cout<<"YES"<<endl;

}else{

cout<<"NO"<<endl;

}

}

return 0;

}

Code 2:
#include <bits/stdc++.h>

#define ll long long

#define mod 1000000007

using namespace std;



int main() {

#ifndef ONLINE_JUDGE

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

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

#endif

// your code goes here

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int>v(n);

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

cin>>v[i];

}

if(v[0]>v[1]){

cout<<"NO"<<endl;

continue;

}

bool flag=true;

int a=v[1]-v[0];

v[1]=a;

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

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

flag=false;

break;

}else{

v[i+1]-=v[i];

}

}

if(flag){

cout<<"YES"<<endl;

}else{

cout<<"NO"<<endl;

}

}

return 0;

}

Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++17 

Code 1:
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include "algorithm"

using namespace std;

#define int long long


void solve() {
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i < n; ++i) {
        if (a[i - 1] > a[i]) {
            cout << "nO\n";
            return;
        }
        int t = min(a[i], a[i - 1]);
        a[i - 1] -= t;
        a[i] -= t;
    }
    cout << "YeS\n";
}




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

Code 2:
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include "algorithm"

using namespace std;

#define int long long


void solve() {
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    if (a[n - 2] > a[n - 1] && a[1] > a[2]) {
        cout << "nO\n";
    } else {
        cout << "yEs\n";
    }
}




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

Answer: 1
Problem: 2060D - Subtract Min Sort
Language: c++23 

Code 1:
#include <numeric>

#include <bits/stdc++.h>

#include <algorithm>

typedef long long ll;

const ll INF = 1e18;

const int P = 1e9 + 7;

const ll N = 1e12;

std::unordered_set<ll> cubes;

template<typename T>T min(const std::vector<T>&v) {

	return *min_element(v.begin(),v.end());

}

template<typename T>T max(const std::vector<T>&v) {

	return *max_element(v.begin(),v.end());

}

template<typename T>T sum(const std::vector<T>&v) {

	return accumulate(v.begin(),v.end(),T(0));

}

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

#define frev(i,a,b) for(ll i = a;i >= b;i--)

#define input(a) for(auto &x:a) std::cin>>x

typedef std::vector<ll> ve;

void run_case() {

	ll n;

	std::cin >> n;

	ll list[n];

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

	    std::cin >> list[i];

	}

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

	    if(list[i] <= list[i+1]){

	        list[i+1]-=list[i];

	        list[i]=0;

	    }

	}

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

	    std::cout << list[i] << " ";

	}

	std::cout << "\n";*/

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

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

	        std::cout << "NO\n";

	        return;

	    }

	}

	std::cout << "YES\n";

}

int main() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(nullptr);

	std::cout.tie(nullptr);

	ll t;

	//t = 1;

	std::cin >> t;

	while(t--) {

		run_case();

	}

}

Code 2:
#include <numeric>

#include <bits/stdc++.h>

#include <algorithm>

typedef long long ll;

const ll INF = 1e18;

const int P = 1e9 + 7;

const ll N = 1e12;

std::unordered_set<ll> cubes;

template<typename T>T min(const std::vector<T>&v) {

	return *min_element(v.begin(),v.end());

}

template<typename T>T max(const std::vector<T>&v) {

	return *max_element(v.begin(),v.end());

}

template<typename T>T sum(const std::vector<T>&v) {

	return accumulate(v.begin(),v.end(),T(0));

}

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

#define frev(i,a,b) for(ll i = a;i >= b;i--)

#define input(a) for(auto &x:a) std::cin>>x

typedef std::vector<ll> ve;

void run_case() {

	ll n;

	std::cin >> n;

	ll list[n];

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

	    std::cin >> list[i];

	}

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

	    if(list[i] < list[i+1]){

	        list[i+1]-=list[i];

	        list[i]=0;

	        

	        //std::cout << list[i] << " " << list[i+1] << "\n";

	    }

	}

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

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

	        std::cout << "NO\n";

	        return;

	    }

	}

	std::cout << "YES\n";

}

int main() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(nullptr);

	std::cout.tie(nullptr);

	ll t;

	//t = 1;

	std::cin >> t;

	while(t--) {

		run_case();

	}

}

Answer: 1
Problem: 2060D - Subtract Min Sort
Language: c++20 

Code 1:
#include <bits/stdc++.h>

#define int long long

#define xyz



using namespace std;

typedef long double ld;

typedef pair<int,int> PII;

const int N = 1e5+10,mod = 1e9+7;

const int INF = (1ll<<60)-1;

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

int n,m;



int encode(int x,int y)

{

    return (x-1)*m+y;

}

PII decode(int x)

{

    return make_pair((x-1)/m+1,(x-1)%m+1);

}



int qmi(int a,int b)

{

    int res=1;

    while(b)

    {

        if(b&1)res=res*a%mod;

        a=a*a%mod;

        b>>=1;

    }

    return res;

}



void solve()

{

    int n;

    cin>>n;

    vector<int>a(n+2);

    for(int i=1;i<=n;i++)cin>>a[i];

    int flag=1;

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

    {

        int t=min(a[i],a[i+1]);

        a[i]-=t;

        a[i+1]-=t;

        if(a[i]>a[i+1])

        {

            flag=0;

            break;

        }

    }

    if(flag)cout<<"YES"<<"\n";

    else cout<<"NO"<<"\n";

}



signed main()

{

    cin.tie(nullptr);

    ios::sync_with_stdio(false);

    int T=1;

    cin>>T;

    while(T--)solve();

    return 0;

}

/*



1

1 2



*/



Code 2:
#include <bits/stdc++.h>

#define int long long

#define xyz



using namespace std;

typedef long double ld;

typedef pair<int,int> PII;

const int N = 1e5+10,mod = 1e9+7;

const int INF = (1ll<<60)-1;

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

int n,m;



int encode(int x,int y)

{

    return (x-1)*m+y;

}

PII decode(int x)

{

    return make_pair((x-1)/m+1,(x-1)%m+1);

}



int qmi(int a,int b)

{

    int res=1;

    while(b)

    {

        if(b&1)res=res*a%mod;

        a=a*a%mod;

        b>>=1;

    }

    return res;

}



void solve()

{

    int n;

    cin>>n;

    vector<int>a(n+2);

    for(int i=1;i<=n;i++)cin>>a[i];

    int flag=1;

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

    {

        if(a[i]>a[i+1])

        {

            if(i-1>0)

            {

                a[i]-=a[i-1];

                a[i-1]=0;

                if(a[i]>a[i+1])

                {

                    flag=0;

                    break;

                }

            }

        }

    }

    if(flag)cout<<"YES"<<"\n";

    else cout<<"NO"<<"\n";

}



signed main()

{

    cin.tie(nullptr);

    ios::sync_with_stdio(false);

    int T=1;

    cin>>T;

    while(T--)solve();

    return 0;

}

/*



1

1 2



*/



Answer: 1
Problem: 2060D - Subtract Min Sort
Language: c++20 

Code 1:
#include<bits/stdc++.h>

using namespace std;

#ifndef ONLINE_JUDGE

#define debug(x) cerr << #x << " = " << (x) << endl;

#else

#define debug(x)

#endif

using ll = long long ;

void solve(){

ll n  ;

cin>>n;

vector<ll>v(n) ;

bool is_sorted = false ;



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

cin>>v[i] ;

}

if(n==2){

if(v[0]>v[1]){

cout<<"NO"<<endl;

return ;

}

}

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

if(v[i]<=v[i+1]){

if((v[i+1]-v[i])<=v[i+2]){

v[i+1]-=v[i] ;

}

else{

cout<<"NO"<<endl;

return ;

}

}

else{

cout<<"NO"<<endl;

return ;

}

}

cout<<"YES"<<endl;



}

int main(){

ios::sync_with_stdio(false);

cin.tie(0);

cout.tie(0) ;

int t;

cin>>t;

while(t--){

solve() ;

}

}

Code 2:
#include<bits/stdc++.h>

using namespace std;

#ifndef ONLINE_JUDGE

#define debug(x) cerr << #x << " = " << (x) << endl;

#else

#define debug(x)

#endif

using ll = long long ;

void solve(){

ll n ; cin>>n;

vector<ll>v(n) ;

ll largest = INT_MIN ;

bool formed = true;

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

cin>>v[i] ;

largest = max(largest,v[i]) ;

}

debug(largest)

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

if(largest == v[i] && i==0){

formed = false ;

break ;



}

}

for(int i=0;i<v.size()-2;i++){

if(v[i+2]<v[i+1]-v[i]){

formed = false ;

break  ;

}

}

if(formed==false){

cout<<"NO"<<endl;

}

else{

cout<<"YES"<<endl;

}





}

int main(){

ios::sync_with_stdio(false);

cin.tie(0);

cout.tie(0) ;

int t;

cin>>t;

while(t--){

solve() ;

}

}

Answer: 1
Problem: 2060D - Subtract Min Sort
Language: c++20 

Code 1:
#include <bits/stdc++.h>
using namespace std;
int main() {
	int t,n;
	cin>>t;
	while(t--){
	    cin>>n;
	    vector<int> nums(n);
	    for(int i=0; i<n; i++){
	        cin>>nums[i];
	    }
	    for(int i=0; i<n-1; i++){
	        int sub = min(nums[i], nums[i+1]);
	        nums[i] = nums[i]-sub;
	         nums[i+1] = nums[i+1]-sub;
	         if(is_sorted(nums.begin(), nums.end())){
	             cout<<"YES"<<endl;
	             break;
	         }
	         else if(i==n-2){
	             cout<<"NO"<<endl;
	         }
	    }
	    
	    
	    
	    
	}
	return 0;
    
}
	    

Code 2:
#include <bits/stdc++.h>
using namespace std;

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

        for (int i = 0; i < n - 1; i++) {
            int sub = min(nums[i], nums[i + 1]);
            nums[i] -= sub;
            nums[i + 1] -= sub;
        }

        // Check if the array is sorted
        if (is_sorted(nums.begin(), nums.end())) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}


Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++23 

Code 1:
// Bluntforces ;)

#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
typedef long long int ll;

void solve() {
    int n; cin >>n;
    vector <int>a(n);
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    for(int i=0;i<n/2;i+=2){
        if(a[i] >a[i+1]){
            cout <<"NO"<<endl;

            return;
        }
    }
    cout <<"YES"<<endl;
}

int main() {
    fast;
    ll t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
typedef long long int ll;

void solve() {
    int n;
    cin >> n;
    deque<int> a(n);
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    
  while(a.size()>1){
    if(a[0]>a[1]){
        cout <<"NO"<<endl;
        return;
    }else if(a[0]<a[1]){
        a[1]-=a[0];
        a.pop_front();
    }else{
        a.pop_front();
        a.pop_front();
    }
  }
  cout <<"YES"<<endl;
}

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


Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++20 

Code 1:
#include <iostream>

#include <vector>

using namespace std;



void solve() {

    int n;

    cin >> n;

    vector<int> a(n);

    for (int &x : a) cin >> x;

    

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

        if (a[i] < a[i - 1]) { 

            cout << "NO\n";

            return;

        }

        a[i] -= min(a[i], a[i - 1]); 

    }

    cout << "YES\n";

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}

Code 2:
#include <bits/stdc++.h>

using namespace std;



void solve() {

    int n;

    cin >> n;

    vector<long long> a(n);

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

        cin >> a[i];

    }

    

    // ????????? ??????? ??????? ?????

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

        if (a[i] > a[i - 1] && a[i] > a[i + 1]) {

            cout << "NO\n";

            return;

        }

    }

    cout << "YES\n";

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}

Answer: 1
Problem: 2060D - Subtract Min Sort
Language: c++17 

Code 1:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define nl "\n"

#ifndef ONLINE_JUDGE
#include "debug_template.h"
#else
#define debug(...)
#define debugArr(...)
#endif

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

  int t; cin >> t; while (t--)
  {
    ll n; cin>>n; ll  a[n];
    for(int i=0; i<n; i++) cin>>a[i];

    if(a[0]>a[1]) cout<<"NO"<<nl;
    else {
      for(int i=1; i<n-1; i++) {
        if(a[i]-a[i-1]<a[i+1]) {
          a[i-1]=0;
          a[i]-=a[i-1];
        }
      }
      cout<<(is_sorted(a,a+n)? "YES\n":"No\n");
    }
    

  }
  return 0;
}

Code 2:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define nl "\n"

#ifndef ONLINE_JUDGE
#include "debug_template.h"
#else
#define debug(...)
#define debugArr(...)
#endif

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

  int t; cin >> t; while (t--)
  {
    ll n; cin>>n; ll  a[n];
    for(int i=0; i<n; i++) cin>>a[i];

    ll cnt= 0;
    for(int i=2; i<n; i++) {
      if(a[i-1]>=a[i-2] && a[i-1]-a[i-2]<=a[i]) {
        cnt++;
        a[i-1]-=a[i-2];
        a[i-2]=0;
      }
    }
    cout<<(is_sorted(a,a+n)? "YES\n":"No\n");

    debugArr(a,n);

  }
  return 0;
}

Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++17 

Code 1:
#include <bits/stdc++.h>
using namespace std;

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0)
#define ll long long
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define vinput for(auto& x: v) cin >> x;
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define range(i,x,y) for(int i=x;i<y;i++)
#define back_range(i,x,y) for(int i=y-1;i>=x;i--)
#define mem(a,b) memset(a, b, sizeof(a) )

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef vector<pii> vii;

// Debug..
#ifdef LOCAL
#include "debug2.h"
#else
#define dg(x...)
#endif

void Solve() {
    int n;
    cin >> n;
    vi v(n);
    vinput;
    
    for(int i=1; i<n; i+=2){
        if(v[i] == v[i-1]){
            v[i] = 0; 
            v[i-1] = 0;
        }
        if(v[i-1] > v[i] or (i == n-2 and v[i] > v[i+1])){
            cout << "NO\n";
            return;
        }
    }
    cout << "YES\n";
}

int main() {
    optimize();
    
    int t = 1;
    cin >> t;
    for(int i=1; i<=t; i++){
        //cout << "Case " << i << ": ";
        Solve();
    }
    
    return 0;
}

Code 2:
#include <bits/stdc++.h>
using namespace std;

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0)
#define ll long long
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define vinput for(auto& x: v) cin >> x;
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define range(i,x,y) for(int i=x;i<y;i++)
#define back_range(i,x,y) for(int i=y-1;i>=x;i--)
#define mem(a,b) memset(a, b, sizeof(a) )

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef vector<pii> vii;

// Debug..
#ifdef LOCAL
#include "debug2.h"
#else
#define dg(x...)
#endif

void Solve() {
    int n;
    cin >> n;
    vi v(n);
    vinput;
    
    for(int i=1; i<n; i++){
        if(v[i-1] > v[i]){
            cout << "NO\n";
            return;
        }
        else{
            v[i] -= v[i-1];
            v[i-1] = 0;
        }
    }
    if(is_sorted(all(v))){
        cout << "YES\n";
    }
    else cout << "NO\n";
}

int main() {
    optimize();
    
    int t = 1;
    cin >> t;
    for(int i=1; i<=t; i++){
        //cout << "Case " << i << ": ";
        Solve();
    }
    
    return 0;
}

Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++23 

Code 1:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define  nn                     cout<<"NO"<<endl
#define  hh                     cout<<"YES"<<endl
#define all(x)                   x.begin(),x.end()
#define rall(x)                 x.rbegin(),x.rend()
#define ct(x)                   cout<<x<<endl
#define TT                      TALHA TASEEN
using namespace std;
using ll = long long;
bool isPrime(ll n)
{
    for(int i=2;i*i<=n;i++)   if(n%i==0) return false;
    return true;
}
ll gcd(ll a,ll b)                   {return (__gcd(a,b));}
ll lcm(ll a,ll b)                   {return (a/(gcd(a,b))*b);}
void talha();
int  main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    cin>>t;
    while(t--)talha();
    return 0;
}
void talha()
{
    int n;
    cin>>n;
    vector<ll>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    int ans=0;
    for(int i=0;i<n-1;i++)
    {
        if(v[i]<=v[i+1])
        {
            i++;
            ans=i;
        }
    }
    if(n%2==1)
    {
        if(v[n-1]>=v[n-2])hh;
        else nn;
    }
    else
    {
        if(ans==n-1)hh;
        else nn;
    }
}


Code 2:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define  nn                     cout<<"NO"<<endl
#define  hh                     cout<<"YES"<<endl
#define all(x)                   x.begin(),x.end()
#define rall(x)                 x.rbegin(),x.rend()
#define ct(x)                   cout<<x<<endl
#define TT                      TALHA TASEEN
using namespace std;
using ll = long long;
bool isPrime(ll n)
{
    for(int i=2;i*i<=n;i++)   if(n%i==0) return false;
    return true;
}
ll gcd(ll a,ll b)                   {return (__gcd(a,b));}
ll lcm(ll a,ll b)                   {return (a/(gcd(a,b))*b);}
void talha();
int  main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    cin>>t;
    while(t--)talha();
    return 0;
}
void talha()
{
    int n;
    cin>>n;
    vector<ll>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    int ans=0;
    for(int i=0;i<n-1;i++)
    {
        ll bal=min(v[i],v[i+1]);
        v[i]-=bal;
        v[i+1]-=bal;
    }
    if(is_sorted(all(v))) hh;
    else nn;
}


Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++23 

Code 1:

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main()

{
    int t;
    cin >> t;
    while (t--)
    {
        

        bool b = true;
        int n,k=0;
        cin >> n;
        vector<int> a(n);

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

        while (k<n-1)
        {
            if (a[k]<a[k+1])
            {
                k++;
            }
            else{
                if(k>1 && (a[k]-a[k+1] != a[k-1]-a[k-2])){
                b=false;
                break;
                }
            }

            k++;
            
        }
        if (b)
        {
            cout<<"YES"<<endl;
        }
        else
        cout<<"NO"<<endl;
        
    }
}


Code 2:

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main()

{
    int t;
    cin >> t;
    while (t--)
    {

        bool b = true;
        int n, k = 0;
        cin >> n;
        vector<int> a(n);

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

        while (k < n - 1 && k >= 0)
        {
            if (a[k] <= a[k + 1])
            {
                k++;
            }
            else
            {
                b = false;
                break;
            }
        }
        if (b)
        {
            cout << "YES" << endl;
            continue;
        }
        else
        {

            for (int i = 0; i < n - 1; i++)
            {
                int mi = min(a[i], a[i + 1]);
                a[i] = a[i] - mi;
                a[i + 1] = a[i + 1] - mi;
            }

            b = true;
            while (k < n - 1 && k >= 0)
            {
                if (a[k] <= a[k + 1])
                {
                    k++;
                }
                else
                {
                    b = false;
                    break;
                }
            }

            if (b)
            {
                cout << "YES" << endl;
            }
            else
                cout << "NO" << endl;
        }
    }
}


Answer: 2
Problem: 2060D - Subtract Min Sort
Language: python

Code 1:
for _ in range(int(input())):
     n = int(input())
     a=list(map(int,input().split()))
     bol = True
     for i in range(n-1):
          if a[i] >a[i+1]:
               bol =False
               break
          else:
               a[i+1] = a[i+1]- a[i]
     print("YES" if bol else"NO")          
                                  

Code 2:
for _ in range(int(input())):
     n = int(input())
     a=list(map(int,input().split()))
     bol = True
     for i in range(n-1):
          if i % 2 == 0:
               if a[i] > a[i+1]:
                    bol=False
     print("YES" if bol else"NO")                         

Answer: 1