ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Code 1:
#include <bits/stdc++.h>
using namespace std;
int mod=1e9+7;
long long power(long long x,int y)
{
    long long res=1;
    while(y>0)
    {
        int r=y%2;
        if(r==1)
        {
            res=res*x;
        }
        y=y/2;
        x=x*x;
    }
    return res;
}
int main() {
    int t;
    cin>>t;
    while(t--)
    {
       long long low,l,high,h;
       cin>>low>>high;
       l=low;
       h=high;
       vector<int>v1(35,0),v2(35,0);
       int j=32;
      // long long p=1;
       while(high>0)
       {
           int r1=high%2;
           int r2=low%2;
           v1[j]=r1;
           v2[j]=r2;
           j--;
          
           high=high/2;
           low=low/2;    
         
        }
       // cout<<j<<endl;
        long long z=0;
        int idx;
        for(int i=0;i<=32;i++)
        {
            if(v1[i]==v2[i])
            {
                continue;
            }
            idx=33-i;
           
           z=power(2,idx);
            z--;
            break;
        }
       // cout<<z<<endl;
      //  cout<<z;
        long long num1=l^z;
        long long num2=h^z;
        if(num1<h&&num1>l)
        {
            cout<<l<<" "<<num1<<" "<<h<<endl;
        }
        else if(num2>l&&num2<h){
             cout<<l<<" "<<num2<<" "<<h<<endl;
        }
        else{
            cout<<l<<" "<<l+1<<" "<<h<<endl;
        }
    }
    
    return 0;
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int,int>
#define iii pair<int, ii>
#define fi first
#define se second
#define inf 1e16
int tc, l, r;
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen("main.inp","r")) {
        freopen("main.inp", "r", stdin);
        freopen("main.out", "w", stdout);
    }
    cin >> tc;
    while(tc--) {
        cin >> l >> r;
        int a = 0, b = 0, c =  0;
        for(int j = 30; j >= 0; j--) {
            if((r&(1<<j)) && (l&(1<<j))) {
                a += (1<<j);
                b += (1<<j);
                c += (1<<j);
            }
            else if(!(r&(1<<j)) && !(l&(1<<j))) continue;
            else {
                a += (1<<j);
                b += (1<<j)-1;
                c += (1<<j)-2;
                break;
            }
        }
        if(min({a,b,c}) < l) {
            a++;
            b++;
            c++;
        }
        cout << a << ' ' << b << ' ' << c << '\n';
    }
    return 0;
}


Answer: 2
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Code 1:
//जय सिया राम
// Author : **Aditya Raj**

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
#define ll  long long int
#define ld long double
#define endl '\n'
#define loopi(n) for(int i=0;i<n;i++)


void solve(){
    int l,r;
    cin>>l>>r;
    int a,b,c;
    int ans = 0;
    a = 0;
    b = 0;
    c = 1;
    for(int i=30;i>=0;i--){
        int b1 = 0;
        int b2 = 0;

        if(l&(1ll << i)){
            b1 = 1;
        }
        if(r&(1ll << i)){
            b2 = 1;
        }
        if(b1==b2){
            ans += b1*(1ll << i);
        }
        else{
            a = ans + (1ll<<i);
            b = a - 1;
            break;
        }
    }

    for(int i = l;i<r;i++){
        if(i != a && i != b){
            c = i;
            break;
        }
    }

    cout<<a<<" "<<b<<" "<<c<<" "<<endl;


}



signed main() {    
    //fast input output
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int t = 1;
    cin>>t;

    while(t--){

        solve();

    }
    return 0;
}




Code 2:
//जय सिया राम
// Author : **Aditya Raj**

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
#define ll  long long int
#define ld long double
#define endl '\n'
#define loopi(n) for(int i=0;i<n;i++)


void solve(){
    int l,r;
    cin>>l>>r;
    int a,b,c;
    int ans = 0;
    a = 0;
    b = 0;
    c = 0;
    for(int i=30;i>=0;i--){
        int b1 = 0;
        int b2 = 0;

        if(l&(1ll << i)){
            b1 = 1;
        }
        if(r&(1ll << i)){
            b2 = 1;
        }
        if(b1==b2){
            ans += b1*(1ll << i);
        }
        else{
            a = ans + (1ll<<i);
            b = a - 1;
            break;
        }
    }

    for(int i = l;i<=r;i++){
        if(i != a && i != b){
            c = i;
            break;
        }
    }

    cout<<a<<" "<<b<<" "<<c<<" "<<endl;


}



signed main() {    
    //fast input output
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int t = 1;
    cin>>t;

    while(t--){

        solve();

    }
    return 0;
}




Answer: 2
Problem: 2057C - Trip to the Olympiad
Language: c++20 

Code 1:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
void solve(){
    ll l,r;
    cin>>l>>r;
    ll ans=0;
    ll a=0,b=0,c=0;
    for(ll i=30;i>=0;i--){
        ll curr=(1ll<<i);
        ll b1=0,b2=0;
        if(l & curr){
            b1=1;
        }
        if(r & curr){
            b2=1;
        }
        if(b1==b2){
            ans+=b1*curr;
        }else{
            a=ans+curr;
            b=a-1;
            break;
        }
    }
    for(ll i=l;i<=r;i++){
        if(i!=a and i!=b){
            c=i;
            break;
        }
    }
    cout<<a<<" "<<b<<" "<<c<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t;
    cin>> t;
    while(t--)
    solve();
    return 0;
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
void solve(){
    ll l,r;
    cin>>l>>r;
    ll ans=0;
    ll a=0,b=0,c=0;
    for(ll i=30;i>=0;i--){
        ll curr=(1ll<<i);
        ll b1=0,b2=0;
        if(l & curr){
            b1=1;
        }
        if(r & curr){
            b2=1;
        }
        if(b1==b2){
            ans+=b1*curr;
        }else{
            a=ans+curr;
            b=a-1;
            c=a;
            break;
        }
    }
    cout<<a<<" "<<b<<" "<<c<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t;
    cin>> t;
    while(t--)
    solve();
    return 0;
}

Answer: 1
Problem: 2057C - Trip to the Olympiad
Language: python

Code 1:
t=int(input())
for ii in range (0,t):
    l,r=list(map(int, input().split()))
    c=0
    sr=bin(r)[2:]
    t =len(sr) - 1
    sl=bin(l)[2:]
    k=len(sl)-1
    sl="0"*(t-k)+sl
    n=t
    while t>=0:
        d=n-t
        e=int(sr[d]) + int(sl[d])
        if e==1 or e==2:
            if c+2**t<=l+1 or l*2==2**t:
                c+=2**t
        else:
            if c+2**t<r:
                c+=2**t
        t-=1
    print(l,r,c)



Code 2:
t=int(input())
for ii in range (0,t):
    l, r = map(int, input().split())
    k = 0
    for i in range(30, -1, -1):
        if ((l >> i) & 1) ^ ((r >> i) & 1):
            k = i
            break
    a = (1 << k) - 1 | l
    b = a + 1
    c = r if a == l else l
    print(a, b, c)




Answer: 2
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Code 1:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define close ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

void solved()
{
    int l,r;
    cin>>l>>r;
    int k = (l^r);
    bitset<31>b(k);
    int ans = 0;
    for(int i = 0;i<=30;i++)
    {
        if(b[i] == 1)
        {
            ans = i;
        }
    }
    int result = l | ((1 << ans) - 1 );
    cout<<result<<" ";
    cout<<result + 1<<" ";
    cout<<(result == l ? r : l )<<endl;
}



signed main()
{
    close;
    int T;
    cin>>T;
    while(T--)
    {
        solved();
    }
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define close ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

void solved()
{
    int l, r;
    cin >> l >> r;
    bitset<30> right(r);
    bitset<30> left(l);
    bitset<30> ans;
    set<int>st;
    for (int i = 0; i < 30; i++) {
        if (right[i] == 1 && left[i] == 1) {
            ans[i] = 0;
        } 
        else if (right[i] == 0 && left[i] == 0) {
            ans[i] = 1;
        }
        else
        {
            st.insert(i);
        }
    }

    int k = ans.to_ulong();

    while(!(k != l && k != r && k >= l && k <= r)) 
    {
        if(st.empty())
        {
            break;
        }
        ans[*(st.begin())] = 1;
        st.erase(st.begin());
        k = ans.to_ulong();
    }
    cout<<l<<" "<<r<<" "<<k<<endl;
}

signed main()
{
    close;
    int T = 1;
    cin >> T;
    while (T--) {
        solved();
    }
    return 0;
}


Answer: 1
Problem: 2057C - Trip to the Olympiad
Language: c++20 

Code 1:
#include <iostream>

using namespace std;
using ll = long long;

void solve(){
    ll a=0,b=0,c=0;
    ll l,r;
    ll ans = 0;
    cin >> l >> r;
    for(int i=31;i>=0;i--){
        int b1 = 0, b2 = 0;
        if(l&(1ll<<i)) b1 = 1;
        if(r&(1ll<<i)) b2 = 1;
        if(b1==b2) ans += b1*(1ll<<i);
        else{
            a = ans+(1ll<<i);
            b = a-1;
            break;
        }
    }
    for(ll i=l;i<=r;i++){
        if(i!=a&&i!=b){
            c = i;
            break;
        }
    }
    cout << a << " " << b << " " << c << endl;
}

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

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

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

    int t;
    cin >> t;
    while (t--) {
        long long l, r;
        cin >> l >> r;

        long long m = 0;
        if (r > 0) {
            m = 63 - __builtin_clzll(r);
        }
        long long a = (1LL << m);
        if (a > r || a < l) {
            a = r;
        }
        long long b = (a - 1);
        if (b < l) {
            b = r - 1;
        }
        if (b == a) {
            b = a - 1;
        }
        long long c = l;
        if (c == a || c == b) {
            c = l + 1;
            if (c == a || c == b) c++;
        }

        cout << a << " " << b << " " << c << "\n";
    }
    return 0;
}

Answer: 1
Problem: 2057C - Trip to the Olympiad
Language: c++20 

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

using namespace std;

#define int int64_t
#define ar array

void solve() {
    int l,r; cin >> l >> r;
    int k = 0;
    for (int i = 0; i <= 30; i++) {
        if (((l^r)>>i) & 1) k = i;
    }
    int x = r & ((1 << 31) - (1 << k));
    if (r == x) cout << l << ' ' << x << ' ' << x-1 << '\n';
    else cout << r << ' ' << x << ' ' << x-1 << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1; cin >> t;
    while (t--) {
        solve();
    }
}

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

using namespace std;

#define int int64_t
#define ar array

void solve() {
    int l,r; cin >> l >> r;
    int k = 0;
    for (int i = 1; i <= 30; i++) {
        if (((l^r)>>i) & 1) k = i-1;
    }
    int x = r & ((1 << 31) - (1 << k));
    if (r == x) cout << l << ' ' << x << ' ' << x-1 << '\n';
    else cout << r << ' ' << x << ' ' << x-1 << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1; cin >> t;
    while (t--) {
        solve();
    }
}

Answer: 1
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9+7;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int total, l, r;
    cin>>total;
    for (int cap = 0; cap < total; ++cap) {
        cin>>l>>r;
        int diff = 0, inv = 0;
        for (int i = 30; i >= 0; --i) {
            //cout<<'-'<<i<<' '<<(r & (1<<i))<<' '<<(l & (1<<i))<<'\n';
            if ((r & (1<<i)) != (l & (1<<i))) {
                diff = i;
                break;
            }
        }  
        for (int j = diff - 1; j >= 0; --j) {
            //cout<<j<<' '<<(r & (1<<j))<<(l & (1<<j))<<'\n';
            if ((r & (1<<j)) >= (l & (1<<j))) {
                inv = j;
                break;
            }
        }
        // inv += 1;
        int bind = r & (1<<inv), ret;
        if (bind) {
            ret = r;
        } else {
            ret = l;
        }
        //cout<<diff<<'\n';
        int oink = ret % (1<<inv+1);
        //cout<<oink<<'\n';
        ret -= oink;
        ret += (1<<(inv+1)) - 1 - oink;
        if (ret < l) {
            ret += (1<<diff);
        }
        cout<<l<<' '<<ret<<' '<<r<<'\n';
    }
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9+7;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int total, l, r;
    cin>>total;
    for (int cap = 0; cap < total; ++cap) {
        cin>>l>>r;
        int diff = 0, inv = 0;
        for (int i = 30; i >= 0; --i) {
            //cout<<'-'<<i<<' '<<(r & (1<<i))<<' '<<(l & (1<<i))<<'\n';
            if ((r & (1<<i)) != (l & (1<<i))) {
                diff = i;
                break;
            }
        }  
        for (int j = diff - 1; j >= 0; --j) {
            if ((r & (1<<j)) >= (l & (1<<j))) {
                inv = j;
                break;
            }
        }
        // inv += 1;
        int bind = r & (1<<inv), ret;
        if (bind == 1) {
            ret = r;
        } else {
            ret = l;
        }
        //cout<<diff<<'\n';
        int oink = ret % (1<<inv+1);
        ret -= oink;
        ret += (1<<(inv+1)) - 1 - oink;
        if (ret < l) {
            ret += (1<<diff);
        }
        cout<<l<<' '<<ret<<' '<<r<<'\n';
    }
}

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

Code 1:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<ll>a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int sheng=0;
        int jiang=0;
        for(int i=0;i<n-1;i++){
            if(a[i]>a[i+1]){
                jiang++;
            }
            if(a[i]<a[i+1]){
                sheng++;
            }
        }
        if(jiang>=sheng){
            cout<<"NO"<<endl;
        }
        else{
            cout<<"YES"<<endl;
        }
    }
    return 0;
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int a[n+1];
		int y=1;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			if(i>1)
            a[i]-=a[i-1];
			if(a[i]<0)
            y=0;
		}
		if(y==1)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

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

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

using namespace std;



typedef long long ll;

typedef unsigned long long ull;



#define entf          cout << endl

#define ent           cout << "\n"

#define REP(i, a, b)  for (int i = a; i < b; ++i)

#define REPV(i, a, b) for (int i = a; i >= b; --i)

#define MOD           1000000007

#define PRINT(x) cout << x << endl

#define d(x) cerr << #x << " = " << x << endl  // Pass a variable name and it will print it with the value



#define TESTCASES true



void solve(int tt) {

int n;

cin >> n;



int val;

vector<int> a;

a.reserve(n);

REP(i, 0, n){

cin >> val;

a.push_back(val);

}

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

cout << "NO" << endl;

return;

}



bool ans = true;

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

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

ans = false;

break;

}

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

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

a[i] -= a[i];

}



cout << (ans ? "YES": "NO") << endl;

}



int main() {

ios::sync_with_stdio(0);

cin.tie(0);



if (TESTCASES) {

int tt; cin >> tt;

REP(i, 1, tt+1) {

solve(i);

}

} else solve(1);



return 0;

}

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

using namespace std;



typedef long long ll;

typedef unsigned long long ull;



#define entf          cout << endl

#define ent           cout << "\n"

#define REP(i, a, b)  for (int i = a; i < b; ++i)

#define REPV(i, a, b) for (int i = a; i >= b; --i)

#define MOD           1000000007

#define PRINT(x) cout << x << endl

#define d(x) cerr << #x << " = " << x << endl  // Pass a variable name and it will print it with the value



#define TESTCASES true



void solve(int tt) {

int n;

cin >> n;



int val;

vector<int> a;

a.reserve(n);

REP(i, 0, n){

cin >> val;

a.push_back(val);

}

// if(a[0] > a[1]) {

//     cout << "NO" << endl;

//     return;

// }



bool ans = true;

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

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

ans = false;

break;

}

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

a[i] -= a[i];

}



cout << (ans ? "YES": "NO") << endl;





}



int main() {

ios::sync_with_stdio(0);

cin.tie(0);



if (TESTCASES) {

int tt; cin >> tt;

REP(i, 1, tt+1) {

solve(i);

}

} else solve(1);



return 0;

}

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

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

int numFib(vector<int>& v, int i) {

    int totalFib = 0;
    totalFib = (i == v[0] + v[1]) ? totalFib + 1 : totalFib;
    totalFib = (v[2] == i + v[1]) ? totalFib + 1 : totalFib;
    totalFib = (v[3] == i + v[2]) ? totalFib + 1 : totalFib;

    return totalFib;

}
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin>>t;

    while (t--) {
        
        int n;
        cin>>n;
        vector<int> v(n);

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

        bool valid = true;
        int minNum = INT_MAX;

        for (int i = 0; i < n - 1; i++) {
            if (i > 0 && v[i-1] > v[i]) {
                valid = false;
                break;
            } 

            minNum = min(v[i], v[i-1]);
            v[i] -= minNum;
            v[i-1] -= minNum;
        }

        if (valid && v[v.size() - 1] >= v[v.size() - 2]) {
            cout << "YES\n";
        } else {
            cout << "NO\n";
        }

    }

    return 0;
}


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

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin>>t;

    while (t--) {
        
        int n;
        cin>>n;
        vector<int> v(n);

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

        bool valid = true;
        int minNum = INT_MAX;

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

            if (v[i-1] > v[i]) {
                valid = false;
                break;
            }
            minNum = min(v[i], v[i-1]);
            v[i] -= minNum;
            v[i-1] -= minNum;
        }

        if (valid && v[v.size() - 1] >= v[v.size() - 2]) {
            cout << "YES\n";
        } else {
            cout << "NO\n";
        }

    }

    return 0;
}


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

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

using namespace std;

#define ll long long

#define ull unsigned long long

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

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



void Mostafa() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

#ifndef ONLINE_JUDGE

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

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

#endif

}

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-1; ++i) {

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

        a[i] -= mn;

        a[i+1] -= mn;

    }

    if(is_sorted(a.begin(), a.end())) cout<<"YES\n";

    else cout<<"NO\n";

}

int main() {

    Mostafa();

    int t; cin>>t;

    while(t--) {

        solve();

    }

    return 0;

}



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

using namespace std;

#define ll long long

#define ull unsigned long long

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

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



void Mostafa() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

#ifndef ONLINE_JUDGE

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

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

#endif

}

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+=2) {

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

            cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

int main() {

    Mostafa();

    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;

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

        for(long long i =0 ; i<n-1 ;i++){
            int temp = min(v[i] , v[i+1]);
            v[i] =v[i] - temp;
            v[i+1] = v[i+1]- temp;
        }

        int cnt =0;
        for(long long i=0 ;i< n ;i++){
            if(v[i]!=0){
                ++cnt;
            }
        }

        if(cnt == 1){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}

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

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

        for(long long i =0 ; i<n-1 ;i++){
            long long temp = min(v[i] , v[i+1]);
            v[i] =v[i] - temp;
            v[i+1] = v[i+1]- temp;
        }
        v[n-1]=0;

        long long cnt =0;
        for(long long i=0 ;i< n ;i++){
            if(v[i]!=0){
                ++cnt;
            }
        }

        if(cnt == 0){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

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

using namespace std;

typedef long long ll;





void solve(){

    ll n; cin>>n;

    vector<ll> v(n);

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

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

        cout<<"YES"<<endl;

        return;

    }

    vector<ll> diff(n-1);

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

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

    }

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

        if(diff[i]<0 and diff[i+1]<0){

            cout<<"NO"<<endl;

            return;

        }

    }

    if(is_sorted(v.rbegin(), v.rend())){

        cout<<"NO"<<endl;

        return;

    }

    cout<<"YES"<<endl;

    

}







int main(){

    int t; 

    cin>>t;

    while(t--){

        solve();

    }

    // solve();

}





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

using namespace std;

typedef long long ll;





void solve(){

    ll n; cin>>n;

    vector<ll> v(n);

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

    // if(is_sorted(v.begin(),v.end())){

    //     cout<<"YES"<<endl;

    //     return;

    // }

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

        ll diff = min(v[i], v[i+1]);

        v[i]-=diff;

        v[i+1]-=diff;

    }

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

        cout<<"YES"<<endl;

    }

    else cout<<"NO"<<endl;

    

}







int main(){

    int t; 

    cin>>t;

    while(t--){

        solve();

    }

    // solve();

}





Answer: 2