ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'

using namespace std;


int n;
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int t; cin >> t;

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

        vector<int> pre(n+1, 0), cnt(n+1, 0);

        for (int i = 0; i < n-1; i++) {
            int u, v; cin >> u >> v;

            pre[v] = u; cnt[u]++;
        }

        int m1 = -1, m2 = -1, j1 = -1, j2 = -1;
        for (int i = 1; i <= n; i++) if (cnt[i] > m1) m1 = cnt[i], j1 = i;
        for (int i = 1; i <= n; i++) {
            if (i == j1 || pre[j1] == i || pre[i] == j1) continue;

            if (cnt[i] > m2) m2 = cnt[i], j2 = i;
        }

        int ans = max(m1 + m2, m1 + cnt[pre[j1]] - 1);

        for (int i = 1; i <= n; i++) {
            if (pre[i] == j1) ans = max(ans, m1 + cnt[i] - 1);
        }

        cout << ans << endl;
    }

    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'

using namespace std;


int n;
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int t; cin >> t;

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

        vector<int> edge[n+1], cnt(n+1, 0);
        for (int i = 0; i < n-1; i++) {
            int u, v; cin >> u >> v;
            edge[u].push_back(v); cnt[u]++;
            edge[v].push_back(u); cnt[v]++;
        }

        multiset<int> ms;
        for (int i = 1; i <= n; i++) ms.insert(cnt[i]);

        int ans = 0;
        for (int i = 1; i <= n; i++) {
            ms.erase(ms.find(cnt[i]));
            for (auto e: edge[i]) ms.erase(ms.find(cnt[e])), ms.insert(cnt[e] - 1);
            ans = max(ans, *ms.rbegin() + cnt[i] - 1);
            ms.insert(cnt[i]);
            for (auto e: edge[i]) ms.erase(ms.find(cnt[e] - 1)), ms.insert(cnt[e]);
        }

        cout << ans << endl;
    }

    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'

using namespace std;


int n;
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int t; cin >> t;

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

        vector<int> edge[n + 1];
        vector<int> cnt(n+1, 0);

        for (int i = 0; i < n-1; i++) {
            int u, v; cin >> u >> v;

            edge[u].push_back(v); cnt[u]++;
        }

        int m1 = -1, m2 = -1, j1 = -1, j2 = -1;
        for (int i = 1; i <= n; i++) if (cnt[i] > m1) m1 = cnt[i], j1 = i;
        for (int i = 1; i <= n; i++) if (cnt[i] > m2 && i != j1) m2 = cnt[i], j2 = i;

        int ans = m1 + m2;

        for (auto e: edge[min(j1, j2)]) {
            if (e == max(j1, j2)) {
                ans--;
                break;
            }
        }

        cout << ans << endl;
    }

    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'

using namespace std;


int n;
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int t; cin >> t;

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

        vector<int> edge[n + 1];
        vector<int> cnt(n+1, 0);

        for (int i = 0; i < n-1; i++) {
            int u, v; cin >> u >> v;

            edge[u].push_back(v); cnt[u]++;
        }

        int m1 = -1, m2 = -1, j1 = -1, j2 = -1;
        for (int i = 1; i <= n; i++) if (cnt[i] > m1) m1 = cnt[i], j1 = i;
        for (int i = 1; i <= n; i++) if (cnt[i] > m2 && i != j1) m2 = cnt[i], j2 = i;

        int ans = m1 + m2;

        for (auto e: edge[min(j1, j2)]) {
            if (e == max(j1, j2)) {
                ans--;
                break;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'

using namespace std;


int n;
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int t; cin >> t;

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

        vector<int> pre(n+1, 0), cnt(n+1, 0);

        for (int i = 0; i < n-1; i++) {
            int u, v; cin >> u >> v;

            pre[v] = u; cnt[u]++;
        }

        int m1 = -1, m2 = -1, j1 = -1, j2 = -1;
        for (int i = 1; i <= n; i++) if (cnt[i] > m1) m1 = cnt[i], j1 = i;
        for (int i = 1; i <= n; i++) {
            if (i == j1 || pre[j1] == i || pre[i] == j1) continue;

            if (cnt[i] > m2) m2 = cnt[i], j2 = i;
        }

        int ans = max(m1 + m2, m1 + cnt[pre[j1]] - 1);

        for (int i = 1; i <= n; i++) {
            if (pre[i] == j1) ans = max(ans, m1 + cnt[i] - 1);
        }

        cout << ans << endl;
    }

    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)

#define debug0(x) std::cout << #x << " = " << x << '\n'
#define debug1(f, a, b) std::cout << #f << ": "; for (int i = (a); i <= (b); i++) std::cout << (f)[i] << " \n"[i == (b)]
#define debug2(f, a, b, c, d) std::cout << #f << ":\n"; for (int i = (a); i <= (b); i++) for (int j = (c); j <= (d); j++) std::cout << (f)[i][j] << " \n"[j == (d)]
#define debug3(q) std::cout << #q << ": "; for (auto it : (q)) std::cout << it << ' '; std::cout << '\n'

#include <bits/stdc++.h>

#define INF 0x3f3f3f3f
const int N = 1e5 + 10;

typedef long long ll;

void solve () {
    int n, m;
    std::cin >> n >> m;

    std::deque<int> a;
    std::deque<int> b;

    std::multiset<int> A;
    std::multiset<int> B;
    
    for (int i = 1; i <= n; i++) {
        int x;
        std::cin >> x;

        a.push_back(x);
        A.insert(x);
    }
    for (int i = 1; i <= m; i++) {
        int x;
        std::cin >> x;

        b.push_back(x);
        B.insert(x);
    }

    if (n == m) {
        if (A == B) std::cout << "Yes\n";
        else std::cout << "No\n";
        return;
    }

    int cnt = 0;
    while (a.size() > b.size()) {
        if (cnt >= 10000) break;

        if (a.front() == b.front()) {
            a.push_back(a.front());
            b.push_back(b.front());

            a.pop_front();
            b.pop_front();
        }
        else {
            if (std::abs(a[0] - a[1]) <= 1) {
                a.push_back(a[0] + a[1]);
                a.pop_front(); a.pop_front();
            }
        }

        cnt++;
    }
    // debug3(a), debug3(b);

    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());
    
    if (a == b) std::cout << "Yes\n";
    else std::cout << "No\n";
}

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

    int t;
    std::cin >> t;

    while (t--) {
        solve();
    }

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


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

using namespace std;

void solve(){
    int64_t n;
    cin >> n;
    vector<int64_t>c(n);
    for (int i = 0; i < n; i++){
        cin >> c[i];
    }
    if (n == 1){
        cout << 0;
    }
    else{
        int ans = 0;
        vector<vector<int64_t>>matrix(n + 1, vector<int64_t>(n + 1, 0));
        vector<int64_t>start(n, n);
        for (int i = 0; i < n; i++){
            start[i] = i + 1;
        }
        vector<pair<int64_t, int64_t>>ans_;
        for (int i = 0; i < n; i++){
            while(c[i] != start[i]){
                int j = i;
                while(c[j] != start[j]){
                    matrix[min(start[j], start[j + 1])][max(start[j], start[j + 1])] = 1;
                    pair<int64_t, int64_t>temp;
                    temp.first = start[j + 1];
                    temp.second = start[j];
                    ans_.push_back(temp);
                    ans += 1;
                    swap(start[j], start[j + 1]);
                    j += 1;
                }
            }
        }
        for (int i = 0; i < n - 1; i++){
            if (matrix[min(c[i], c[i + 1])][max(c[i + 1], c[i])] == 0){
                pair<int64_t, int64_t>temp;
                temp.first = start[i + 1];
                temp.second = start[i];
                ans_.push_back(temp);
                temp.first = start[i];
                temp.second = start[i + 1];
                ans_.push_back(temp);
                ans += 2;
            }
        }
        cout << ans << endl;
        for (int i = 0; i < ans; i++){
            cout << ans_[i].first << ' ' << ans_[i].second << endl;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(16);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
        cout << endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


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>
#ifndef ONLINE_JUDGE
#include "dbg/dbg.h"
#else
#define debug(...) 1
#endif
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int dr[] = { -1, 0, +1, 0};
const int dc[] = {0, +1, 0, -1};
template <class T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &it : a) {
        cin >> it;
    }

    if (n == 1) {
        cout << a[0] << '\n';
        return;
    }

    int ans = accumulate(all(a), 0);
    while (a.size() > 1) {
        vector<int> diffa, revDiffa;

        for(int i = 0; i < (int)a.size() - 1; i++) 
            diffa.push_back(a[i + 1] - a[i]);

        reverse(all(a));

        for(int i = 0; i < (int)a.size() - 1; i++)
            revDiffa.push_back(a[i + 1] - a[i]);

        int sum = accumulate(all(diffa), 0);
        int revSum = accumulate(all(revDiffa), 0);

        ans = max({ans, sum, revSum});

        if(sum >= revSum) a = diffa;
        else a = revDiffa;
    }

    cout << ans << '\n';
}

int main() {
// #ifndef ONLINE_JUDGE
//     freopen("error.txt", "w", stderr);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int tt = 1;
    cin >> tt;

    while (tt--) {
        solve();
    }

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
//Code from Whalica
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"

void solve() {
	int n;
	cin>>n;
	vector<ll>a(n),b;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	ll ans=-1001;
	while(a.size()!=1){
		ans=max(ans,abs(accumulate(a.begin(),a.end(),0ll)));
		for(int i=0;i<a.size()-1;i++){
			b.push_back(a[i+1]-a[i]);
		}
		a=b;
		b.clear();
	}
	ans=max(ans,abs(a[0]));
	cout<<ans<<endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	int T = 1;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
//Code from Whalica
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"

void solve() {
	int n;
	cin>>n;
	vector<ll>a(n),b;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	ll ans=-1001;
	while(a.size()!=1){
		ans=max(ans,abs(accumulate(a.begin(),a.end(),0ll)));
		for(int i=0;i<a.size()-1;i++){
			b.push_back(a[i+1]-a[i]);
		}
		a=b;
		b.clear();
	}
	ans=max(ans,abs(a[0]));
	cout<<ans<<endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	int T = 1;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}


Submission (verdict: Wrong answer on test 2):
//Code from Whalica
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"

void solve() {
	int n;
	cin>>n;
	vector<ll>a(n),b;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	if(n==1){
		cout<<a[0]<<endl;
		return;
	}
	ll ans=-1001;
	while(a.size()!=1){
		ans=max(ans,abs(accumulate(a.begin(),a.end(),0ll)));
		for(int i=0;i<a.size()-1;i++){
			b.push_back(a[i+1]-a[i]);
		}
		a=b;
		b.clear();
	}
	ans=max(ans,abs(a[0]));
	cout<<ans<<endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	int T = 1;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
//Code from Whalica
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"

void solve() {
	int n;
	cin>>n;
	vector<ll>a(n),b;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	if(n==1){
		cout<<a[0]<<endl;
		return;
	}
	ll ans=-1001;
	while(a.size()!=1){
		ans=max(ans,abs(accumulate(a.begin(),a.end(),0ll)));
		for(int i=0;i<a.size()-1;i++){
			b.push_back(a[i+1]-a[i]);
		}
		a=b;
		b.clear();
	}
	ans=max(ans,abs(a[0]));
	cout<<ans<<endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	int T = 1;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}


Submission (verdict: Accepted):
//Code from Whalica
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"

void solve() {
	int n;
	cin>>n;
	vector<ll>a(n),b;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	n--;
	ll ans=-1001;
	ans=max(ans,accumulate(a.begin(),a.end(),0ll));
	for(int i=0;i<a.size()-1;i++){
		b.push_back(a[i+1]-a[i]);
	}
	a=b;
	b.clear();
	while(n--){
		ans=max(ans,abs(accumulate(a.begin(),a.end(),0ll)));
		for(int i=0;i<a.size()-1;i++){
			b.push_back(a[i+1]-a[i]);
		}
		a=b;
		b.clear();
	}
	cout<<ans<<endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	int T = 1;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Compilation error):
#pragma GCC optimize("O3")
 
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define lpr pair<ll,ll>
#define ld long double
#define all(x) x.begin(),x.end()
#define f0(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
const ll INF = LLONG_MAX;
const ll NEF = LLONG_MIN;
const ld pi = acos(-1.0);
const ll one=1;
void solve(){   
    ll n;cin>>n;
    vector<ll> arr(n,0);
    for(auto &i:arr) cin>>i;
    ll ans=NEF;
    if(n==1){
        cout<<arr[i]<<endl;
        return;
    }
    for(int i=0;i<n;i++){
        ll cur=0;    
        for( int j=0;j<n-i;j++){
            cur+=arr[j];
        }
        for( int j=0;j<n-i-1;j++){
            arr[j]=arr[j+1]-arr[j];
            // cout<<arr[j]<<" ";
        }
     
        ans=max(ans,max(cur,(-cur)));
        // cout<<" the ans is:"<<ans<<endl;
    }
    cout<<ans<<endl;
    
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<setprecision(9)<<fixed;
    ll t=1;
    cin>>t;
    while(t--){
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#pragma GCC optimize("O3")
 
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define lpr pair<ll,ll>
#define ld long double
#define all(x) x.begin(),x.end()
#define f0(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
const ll INF = LLONG_MAX;
const ll NEF = LLONG_MIN;
const ld pi = acos(-1.0);
const ll one=1;
void solve(){   
    ll n;cin>>n;
    vector<ll> arr(n,0);
    for(auto &i:arr) cin>>i;
    ll ans=NEF;
    if(n==1){
        cout<<arr[0]<<endl;
        return;
    }
    for(int i=0;i<n;i++){
        ll cur=0;    
        for( int j=0;j<n-i;j++){
            cur+=arr[j];
        }
        for( int j=0;j<n-i-1;j++){
            arr[j]=arr[j+1]-arr[j];
            // cout<<arr[j]<<" ";
        }
     
        ans=max(ans,max(cur,(-cur)));
        // cout<<" the ans is:"<<ans<<endl;
    }
    cout<<ans<<endl;
    
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<setprecision(9)<<fixed;
    ll t=1;
    cin>>t;
    while(t--){
        solve();
    }
}

Submission (verdict: Accepted):
#pragma GCC optimize("O3")
 
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define lpr pair<ll,ll>
#define ld long double
#define all(x) x.begin(),x.end()
#define f0(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
const ll INF = LLONG_MAX;
const ll NEF = LLONG_MIN;
const ld pi = acos(-1.0);
const ll one=1;

void solve(){   
    ll n;cin>>n;
    vector<ll> arr(n,0);
    for(auto &i:arr) cin>>i;
    ll ans=NEF;
    if(n==1){
        cout<<arr[0]<<endl;
        return;
    }
    
    ll cur=0;
    for( int j=0;j<n;j++){
        cur+=arr[j];
    }
    ans=max(cur,ans);
    for(int i=0;i<n-1;i++){ 
        ll cur=0;    
        for( int j=0;j<n-i-1;j++){
            arr[j]=arr[j+1]-arr[j];
        }
        for( int j=0;j<n-i-1;j++){
            cur+=arr[j];
        }
        ans=max(ans,max(cur,(-cur)));
        
    }
    cout<<ans<<endl;
    
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<setprecision(9)<<fixed;
    ll t=1;
    cin>>t;
    while(t--){
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#pragma GCC optimize("O3")
 
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define lpr pair<ll,ll>
#define ld long double
#define all(x) x.begin(),x.end()
#define f0(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
const ll INF = LLONG_MAX;
const ll NEF = LLONG_MIN;
const ld pi = acos(-1.0);
const ll one=1;
void solve(){   
    ll n;cin>>n;
    vector<ll> arr(n,0);
    for(auto &i:arr) cin>>i;
    ll ans=NEF;
    if(n==1){
        cout<<arr[i]<<endl;
        return;
    }
    for(int i=0;i<n;i++){
        ll cur=0;    
        for( int j=0;j<n-i;j++){
            cur+=arr[j];
        }
        for( int j=0;j<n-i-1;j++){
            arr[j]=arr[j+1]-arr[j];
            // cout<<arr[j]<<" ";
        }
     
        ans=max(ans,max(cur,(-cur)));
        // cout<<" the ans is:"<<ans<<endl;
    }
    cout<<ans<<endl;
    
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<setprecision(9)<<fixed;
    ll t=1;
    cin>>t;
    while(t--){
        solve();
    }
}

Submission (verdict: Wrong answer on test 2):
#pragma GCC optimize("O3")
 
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define lpr pair<ll,ll>
#define ld long double
#define all(x) x.begin(),x.end()
#define f0(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
const ll INF = LLONG_MAX;
const ll NEF = LLONG_MIN;
const ld pi = acos(-1.0);
const ll one=1;
void solve(){   
    ll n;cin>>n;
    vector<ll> arr(n,0);
    for(auto &i:arr) cin>>i;
    ll ans=NEF;
    if(n==1){
        cout<<arr[0]<<endl;
        return;
    }
    for(int i=0;i<n;i++){
        ll cur=0;    
        for( int j=0;j<n-i;j++){
            cur+=arr[j];
        }
        for( int j=0;j<n-i-1;j++){
            arr[j]=arr[j+1]-arr[j];
            // cout<<arr[j]<<" ";
        }
     
        ans=max(ans,max(cur,(-cur)));
        // cout<<" the ans is:"<<ans<<endl;
    }
    cout<<ans<<endl;
    
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<setprecision(9)<<fixed;
    ll t=1;
    cin>>t;
    while(t--){
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64

Previous submission (verdict: Runtime error on test 2):
t = int(input())



while t > 0:

n = int(input())

solved = False

arr = list(map(int, input().split()))

if n >= 3:

for i in range(n-2):

q = arr[i:i+3]

c = q.copy()

q.sort(reverse=True)

if q == c:

print("NO")

solved = True

break

if not solved:

print("YES")

else:

if n[0]>n[1]:

print("NO")

else:

print("YES")



t -= 1

Submission (verdict: Wrong answer on test 2):
t = int(input())



while t > 0:

n = int(input())

solved = False

arr = list(map(int, input().split()))

if n >= 3:

for i in range(n-2):

q = arr[i:i+3]

c = q.copy()

q.sort(reverse=True)

if q == c:

print("NO")

solved = True

break

if not solved:

print("YES")

else:

if arr[0]>arr[1]:

print("NO")

else:

print("YES")



t -= 1
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 2):
t = int(input())



while t > 0:

n = int(input())

solved = False

arr = list(map(int, input().split()))

for i in range(n-2):

q = arr[i:i+3]

c = q.copy()

q.sort(reverse=True)

if q == c:

print("NO")

solved = True

break

if not solved:

print("YES")

t -= 1
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
t = int(input())



while t > 0:

n = int(input())

solved = False

arr = list(map(int, input().split()))

for i in range(n-2):

q = arr[i:i+3]

c = q.copy()

q.sort(reverse=True)

if q == c:

print("NO")

solved = True

break

if not solved:

print("YES")

t -= 1

Submission (verdict: Runtime error on test 2):
t = int(input())



while t > 0:

n = int(input())

solved = False

arr = list(map(int, input().split()))

if n >= 3:

for i in range(n-2):

q = arr[i:i+3]

c = q.copy()

q.sort(reverse=True)

if q == c:

print("NO")

solved = True

break

if not solved:

print("YES")

else:

if n[0]>n[1]:

print("NO")

else:

print("YES")



t -= 1
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
t = int(input())



while t > 0:

n = int(input())

solved = False

arr = list(map(int, input().split()))

if n >= 3:

for i in range(n-2):

q = arr[i:i+3]

c = q.copy()

q.sort(reverse=True)

if q == c:

print("NO")

solved = True

break

if not solved:

print("YES")

else:

if arr[0]>arr[1]:

print("NO")

else:

print("YES")



t -= 1

Submission (verdict: Accepted):
t = int(input())



while t > 0:

n = int(input())

solved = False

arr = list(map(int, input().split()))

for i in range(n-1):

q = min(arr[i], arr[i+1])

arr[i] = arr[i]- q

arr[i+1] = arr[i+1]- q

for i in range(n-1):

if arr[i+1]<arr[i]:

solved = True

print("NO")

break

if not solved:

print("YES")





t -= 1