ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 6):
tc = int(input())

for _ in range(tc):
    n = int(input())
    a = list(map(int, input().split()))
    res = sum(a)
    if n == 1:
        print(a[0])
    else:
        res = 0
        while len(a) > 2:
            b = []
            for i in range(len(a) - 1):
                b.append(a[i] - a[i + 1])
            res = max(res, sum(b))
            a = a[::-1]
            b = []
            for i in range(len(a) - 1):
                b.append(a[i] - a[i + 1])
            res = max(res, sum(b))
            a = b
            # print(_, a, len(a))
        res = max(a[1] - a[0], a[0] - a[1], a[0] + a[1], res)
        print(res)


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

for _ in range(tc):
    n = int(input())
    a = list(map(int, input().split()))
    res = sum(a)
    if n == 1:
        print(a[0])
    else:
        while len(a) > 2:
            b = []
            for i in range(len(a) - 1):
                b.append(a[i] - a[i + 1])
            res = max(res, sum(b))
            a = a[::-1]
            b = []
            for i in range(len(a) - 1):
                b.append(a[i] - a[i + 1])
            res = max(res, sum(b))
            a = b
            # print(_, a, len(a))
        res = max(a[1] - a[0], a[0] - a[1], a[0] + a[1], res)
        print(res)
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 13):
#include <bits/stdc++.h>

using namespace std;

const int maxn = (int)2e5 + 7;

int tt, dp[210][210];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> tt;
    while (tt--) {
        string a, b, c;
        cin >> a >> b >> c;
        for (int i = 1; i <= (int)a.size(); i++) {
            dp[i][0] = dp[i - 1][0] + (a[i - 1] != c[i - 1]);
//            cout << dp[i][0] << ' ';
        }
//        cout << '\n';
        for (int i = 1; i <= (int)b.size(); i++) {
            dp[0][i] = dp[0][i - 1] + (b[i - 1] != c[i - 1]);
//            cout << dp[0][i] << ' ';
        }
        for (int i = 1; i <= (int)a.size(); i++) {
            for (int j = 1; j <= (int)b.size(); j++) {
                dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1]), dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));
            }
        }
//        for (int i = 0; i <= (int)a.size(); i++) {
//            for (int j = 0; j <= (int)b.size(); j++) {
//                cout << dp[i][j] << ' ';
//            }
//            cout << '\n';
//        }
        cout << dp[(int)a.size()][(int)b.size()] << '\n';
    }
}
/*
1
ab
ba
aabb
*/


Submission (verdict: Time limit exceeded on test 13):
#include <bits/stdc++.h>

using namespace std;

const int maxn = (int)2e5 + 7;

int tt, dp[210][210];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> tt;
    while (tt--) {
        string a, b, c;
        cin >> a >> b >> c;
        for (int i = 1; i <= (int)a.size(); i++) {
            dp[i][0] = dp[i - 1][0] + (a[i - 1] != c[i - 1]);
//            cout << dp[i][0] << ' ';
        }
//        cout << '\n';
        for (int i = 1; i <= (int)b.size(); i++) {
            dp[0][i] = dp[0][i - 1] + (b[i - 1] != c[i - 1]);
//            cout << dp[0][i] << ' ';
        }
        for (int i = 1; i <= (int)a.size(); i++) {
            for (int j = 1; j <= (int)b.size(); j++) {
                dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1]), dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));
            }
        }
//        for (int i = 0; i <= (int)a.size(); i++) {
//            for (int j = 0; j <= (int)b.size(); j++) {
//                cout << dp[i][j] << ' ';
//            }
//            cout << '\n';
//        }
        cout << dp[(int)a.size()][(int)b.size()] << '\n';
        for (int i = 0; i <= (int)a.size(); i++) {
            for (int j = 0; j <= (int)b.size(); j++) {
                dp[i][j] = 0;
            }
        }
    }
}
/*
1
ab
ba
aabb
*/
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Runtime error on test 13):
#include <bits/stdc++.h>

using namespace std;

const int maxn = (int)2e5 + 7;

int tt;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> tt;
    while (tt--) {
        string a, b, c;
        int dp[210][210];
        cin >> a >> b >> c;
        dp[0][0] = 0;
        for (int i = 1; i <= (int)a.size(); i++) {
            dp[i][0] = dp[i - 1][0] + (a[i - 1] != c[i - 1]);
        }
        for (int i = 1; i <= (int)b.size(); i++) {
            dp[0][i] = dp[0][i - 1] + (b[i - 1] != c[i - 1]);
        }
        for (int i = 1; i <= (int)a.size(); i++) {
            for (int j = 1; j <= (int)b.size(); j++) {
                dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1]), dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));
            }
        }
        cout << dp[(int)a.size()][(int)b.size()] << '\n';
    }
}
/*
1
ab
ba
aabb
*/


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

using namespace std;

const int maxn = (int)2e5 + 7;

int tt;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> tt;
    while (tt--) {
        string a, b, c;
        int dp[2010][2010];
        cin >> a >> b >> c;
        dp[0][0] = 0;
        for (int i = 1; i <= (int)a.size(); i++) {
            dp[i][0] = dp[i - 1][0] + (a[i - 1] != c[i - 1]);
        }
        for (int i = 1; i <= (int)b.size(); i++) {
            dp[0][i] = dp[0][i - 1] + (b[i - 1] != c[i - 1]);
        }
        for (int i = 1; i <= (int)a.size(); i++) {
            for (int j = 1; j <= (int)b.size(); j++) {
                dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1]), dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));
            }
        }
        cout << dp[(int)a.size()][(int)b.size()] << '\n';
    }
}
/*
1
ab
ba
aabb
*/
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 13):
#include <bits/stdc++.h>

using namespace std;

const int maxn = (int)2e5 + 7;

int tt, dp[210][210];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> tt;
    while (tt--) {
        string a, b, c;
        cin >> a >> b >> c;
        for (int i = 1; i <= (int)a.size(); i++) {
            dp[i][0] = dp[i - 1][0] + (a[i - 1] != c[i - 1]);
//            cout << dp[i][0] << ' ';
        }
//        cout << '\n';
        for (int i = 1; i <= (int)b.size(); i++) {
            dp[0][i] = dp[0][i - 1] + (b[i - 1] != c[i - 1]);
//            cout << dp[0][i] << ' ';
        }
        for (int i = 1; i <= (int)a.size(); i++) {
            for (int j = 1; j <= (int)b.size(); j++) {
                dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1]), dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));
            }
        }
//        for (int i = 0; i <= (int)a.size(); i++) {
//            for (int j = 0; j <= (int)b.size(); j++) {
//                cout << dp[i][j] << ' ';
//            }
//            cout << '\n';
//        }
        cout << dp[(int)a.size()][(int)b.size()] << '\n';
    }
}
/*
1
ab
ba
aabb
*/
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 13):
#include <bits/stdc++.h>

using namespace std;

const int maxn = (int)2e5 + 7;

int tt, dp[210][210];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> tt;
    while (tt--) {
        string a, b, c;
        cin >> a >> b >> c;
        for (int i = 1; i <= (int)a.size(); i++) {
            dp[i][0] = dp[i - 1][0] + (a[i - 1] != c[i - 1]);
//            cout << dp[i][0] << ' ';
        }
//        cout << '\n';
        for (int i = 1; i <= (int)b.size(); i++) {
            dp[0][i] = dp[0][i - 1] + (b[i - 1] != c[i - 1]);
//            cout << dp[0][i] << ' ';
        }
        for (int i = 1; i <= (int)a.size(); i++) {
            for (int j = 1; j <= (int)b.size(); j++) {
                dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1]), dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));
            }
        }
//        for (int i = 0; i <= (int)a.size(); i++) {
//            for (int j = 0; j <= (int)b.size(); j++) {
//                cout << dp[i][j] << ' ';
//            }
//            cout << '\n';
//        }
        cout << dp[(int)a.size()][(int)b.size()] << '\n';
        for (int i = 0; i <= (int)a.size(); i++) {
            for (int j = 0; j <= (int)b.size(); j++) {
                dp[i][j] = 0;
            }
        }
    }
}
/*
1
ab
ba
aabb
*/


Submission (verdict: Runtime error on test 13):
#include <bits/stdc++.h>

using namespace std;

const int maxn = (int)2e5 + 7;

int tt;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> tt;
    while (tt--) {
        string a, b, c;
        int dp[210][210];
        cin >> a >> b >> c;
        dp[0][0] = 0;
        for (int i = 1; i <= (int)a.size(); i++) {
            dp[i][0] = dp[i - 1][0] + (a[i - 1] != c[i - 1]);
        }
        for (int i = 1; i <= (int)b.size(); i++) {
            dp[0][i] = dp[0][i - 1] + (b[i - 1] != c[i - 1]);
        }
        for (int i = 1; i <= (int)a.size(); i++) {
            for (int j = 1; j <= (int)b.size(); j++) {
                dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1]), dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));
            }
        }
        cout << dp[(int)a.size()][(int)b.size()] << '\n';
    }
}
/*
1
ab
ba
aabb
*/
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


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

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define rsort(v) sort(all(v),greater<pr>());
#define minheap priority_queue<ll, vector<ll>, greater<ll>>
#define vb vector<bool>
#define vs vector<string>
#define vpll vector<pair<ll, ll>>
#define pr pair<ll,ll>
#define stkll stack<ll>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define maxi(v) *max_element(all(v))
#define mini(v) *min_element(all(v))
#define f1(i, j, n  ) for (ll i = j; i < n; i++)
#define f2(i, j, n  ) for (ll i = j; i >= n; i--)
#define print1(a) cout << a << endl;
#define print2(a, b) cout << a << " " << b << endl;
#define print3(a, b, c) cout << a << " " << b << " " << c << endl;
#define optimize()                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod(n) n % 1000000007
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define umpll unordered_map<ll, ll>
#define umplb unordered_map<ll, bool>
#define umpcl unordered_map<char, ll>
#define umplc unordered_map<ll, char>
#define line cout << endl;
#define pvpl(v) f1(i,0,v.size()){cout<<v[i].first<<" "<<v[i].second<<endl;}
#define pvl(v) f1(i,0,v.size()){cout<<v[i]<<" ";}

int main(){
    optimize();
    ll size;
    cin>>size;
    while(size--){
        ll n,m;
        cin>>n>>m; 

        ll x;
        priority_queue<ll> a,b;

        f1(i,0,n){
            cin>>x;
            a.push(x);
        }

        f1(i,0,m){
            cin>>x;
            b.push(x);
        }
        ll i=n+m;
        while(!a.empty() && !b.empty() && i){
            ll t1=a.top(),t2=b.top();
            if(t1==t2){
                a.pop();
                b.pop();
            } else{
                b.pop();
                b.push(ceil(float(t2)/2));
                b.push(floor(float(t2)/2));
            }
            i--;
        }

        if(a.empty() && b.empty()) yes
        else no

    }
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define len(a) (int) a.size()


signed main() {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n == 1) {
        return cout << 0, 0;
    }

    vector<pll> ans1, ans2;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                ans1.push_back({a[i], a[j]});
            } else {
                ans2.push_back({a[j], a[i]});
                ans2.push_back({a[i], a[j]});
            }
        }
    }
   
    cout << (len(ans1) + len(ans2)) << '\n';
    for (auto [l, r]: ans2) {
        cout << l << ' ' << r << '\n';
    }
    sort(ans1.begin(), ans1.end());
    for (auto [l, r]: ans1) {
        cout << l << ' ' << r << '\n';
    }

    return 0;


}



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

typedef long long ll;
typedef pair<ll, ll> pll;

#define len(a) (int) a.size()


signed main() {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n == 1) {
        return cout << 0, 0;
    }


    vector<pll> ans1, ans2, ans3;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] < a[j]) {
                ans1.push_back({a[i], a[j]});
            }
        }
    }
   
    cout << (len(ans1) + (n * (n - 1)) / 2) << '\n';

    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            cout << j << ' ' << i << '\n';
        }
    }

    sort(ans1.begin(), ans1.end());
    for (auto [l, r]: ans1) {
        cout << l << ' ' << r << '\n';
    }

    return 0;


}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define len(a) (int) a.size()


signed main() {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n == 1) {
        return cout << 0, 0;
    }

    vector<pll> ans1, ans2;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                ans1.push_back({a[i], a[j]});
            } else {
                ans2.push_back({a[j], a[i]});
                ans2.push_back({a[i], a[j]});
            }
        }
    }
   
    cout << (len(ans1) + len(ans2)) << '\n';
    for (auto [l, r]: ans2) {
        cout << l << ' ' << r << '\n';
    }
    for (auto [l, r]: ans1) {
        cout << l << ' ' << r << '\n';
    }

    return 0;


}



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

typedef long long ll;
typedef pair<ll, ll> pll;

#define len(a) (int) a.size()


signed main() {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n == 1) {
        return cout << 0, 0;
    }

    vector<pll> ans1, ans2;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                ans1.push_back({a[i], a[j]});
            } else {
                ans2.push_back({a[j], a[i]});
                ans2.push_back({a[i], a[j]});
            }
        }
    }
   
    cout << (len(ans1) + len(ans2)) << '\n';
    for (auto [l, r]: ans2) {
        cout << l << ' ' << r << '\n';
    }
    sort(ans1.begin(), ans1.end());
    for (auto [l, r]: ans1) {
        cout << l << ' ' << r << '\n';
    }

    return 0;


}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define len(a) (int) a.size()


signed main() {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n == 1) {
        return cout << 0, 0;
    }


    vector<pll> ans1, ans2, ans3;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] < a[j]) {
                ans1.push_back({a[i], a[j]});
            }
        }
    }
   
    cout << (len(ans1) + (n * (n - 1)) / 2) << '\n';

    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            cout << j << ' ' << i << '\n';
        }
    }

    sort(ans1.begin(), ans1.end());
    for (auto [l, r]: ans1) {
        cout << l << ' ' << r << '\n';
    }

    return 0;


}



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

typedef long long ll;
typedef pair<ll, ll> pll;

#define len(a) (int) a.size()


signed main() {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n), b(n+1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[a[i]] = i;
    }
    if (n == 1) {
        return cout << 0, 0;
    }


    vector<pll> ans1, ans2, ans3;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] < a[j]) {
                ans1.push_back({a[i], a[j]});
            }
        }
    }
   
    cout << (len(ans1) + (n * (n - 1)) / 2) << '\n';

    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            cout << j << ' ' << i << '\n';
        }
    }

    // vector<ll> b(n);
    // iota(b.begin(), b.end(), 1);
    // reverse(b.begin(), b.end());

    // for (int i = 0; i < n; i++) {
    //     for (int j = i - 1; j >= 0; j--) {
    //         ans1.push_back({a[i], a[j]});
    //         swap
    //     }
    // }

    sort(ans1.begin(), ans1.end(), [&](pll i, pll j) {
        if (b[i.first] == b[j.first])
            return i.second < j.second;
        return b[i.first] < b[j.first];

    });
    for (auto [l, r]: ans1) {
        cout << l << ' ' << r << '\n';
    }

    return 0;


}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define len(a) (int) a.size()


signed main() {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n == 1) {
        return cout << 0, 0;
    }

    vector<pll> ans;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                ans.push_back({a[i], a[j]});
            } else {
                ans.push_back({a[j], a[i]});
                ans.push_back({a[i], a[j]});
            }
        }
    }
   
    cout << len(ans) << '\n';
    for (auto [l, r]: ans) {
        cout << l << ' ' << r << '\n';
    }

    return 0;

}



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

typedef long long ll;
typedef pair<ll, ll> pll;

#define len(a) (int) a.size()


signed main() {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n == 1) {
        return cout << 0, 0;
    }

    vector<pll> ans1, ans2;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                ans1.push_back({a[i], a[j]});
            } else {
                ans2.push_back({a[j], a[i]});
                ans2.push_back({a[i], a[j]});
            }
        }
    }
   
    cout << (len(ans1) + len(ans2)) << '\n';
    for (auto [l, r]: ans2) {
        cout << l << ' ' << r << '\n';
    }
    for (auto [l, r]: ans1) {
        cout << l << ' ' << r << '\n';
    }

    return 0;


}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


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

typedef long long ll;
typedef pair<ll, ll> pll;

#define len(a) (int) a.size()


signed main() {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n == 1) {
        return cout << 0, 0;
    }

    vector<pll> ans;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                ans.push_back({a[i], a[j]});
            } else {
                ans.push_back({a[j], a[i]});
                ans.push_back({a[i], a[j]});
            }
        }
    }
   
    cout << len(ans) << '\n';
    for (auto [l, r]: ans) {
        cout << l << ' ' << r << '\n';
    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
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>
using namespace std;
using namespace __gnu_pbds;
template <class type1>
#define ll long long int
#define endl "\n"
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using ordered_multiset = tree <type1, null_type, less_equal <type1>, rb_tree_tag, tree_order_statistics_node_update>;
#define yes cout << "YES\n"
#define no cout << "NO\n"
ll lcm(ll x,ll y)
{
    return (x*y)/__gcd(x,y);
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt;
    cin >> tt;
    while (tt--)
    {
        int n;
        cin >> n;

        vector<ll> a(n);
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
         int mn;
         vector<int>v,vv;
        for(int i=0;i<n-1;i++)
        {
            mn=min(a[i],a[i+1]);
            v.push_back(a[i]-mn);
            a[i+1]=a[i+1]-mn;
        }
        v.push_back(a[n-1]-mn);
        int bb=0;
        for(int i=0;i<n-1;i++)
        {
            if(v[i]<=v[i+1])continue;
            else
            {
                bb=1;
                no;
                break;
            }
        }
        if(bb==0)yes;



    }
    return 0;
}