ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
typedef int32_t i32;
typedef int64_t i64;
const i32 N = 2e3+1;

i64 dp[N][N];
void solve()
{
	std::string a, b, c;
	std::cin >> a >> b >> c;
	a = " " + a;
	b = " " + b;
	c = " " + c;
	for(i32 i = 0; i < c.size(); i++)
	{
		for(i32 j = 0; j < b.size(); j++)
		{
			dp[i][j] = 1e18;
		}
	}
	dp[0][0] = 0;
	for(i32 i = 1; i < c.size(); i++)
	{
		for(i32 j = 1; j < a.size(); j++)
		{
			if(i < j)
			{
				continue;
			}
			dp[i][j] = std::min(dp[i-1][j] + bool(b[i-j] != c[i]), dp[i-1][j-1] + bool(c[i] != a[j]));
		}
	}
	std::cout << dp[(i32)c.size() - 1][(i32)a.size() - 1] << "\n";
}
int main()
{
	std::cin.tie(0)->sync_with_stdio(0);
	int t = 1;
	std::cin >> t;
	while(t--)
	{
		solve();
	}
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
typedef int32_t i32;
typedef int64_t i64;
const i32 N = 33;

i64 dp[N][N];
void solve()
{
	std::string a, b, c;
	std::cin >> a >> b >> c;
	a = " " + a;
	b = " " + b;
	c = " " + c;
	for(i32 i = 0; i < c.size(); i++)
	{
		for(i32 j = 0; j < b.size(); j++)
		{
			dp[i][j] = 1e18;
		}
	}
	for(i32 i = 1; i < a.size(); i++)
	{
		dp[0][i] = 0;
	}
	for(i32 i = 1; i < c.size(); i++)
	{
		for(i32 j = 1; j < a.size(); j++)
		{
			if(i < j)
			{
				continue;
			}
			dp[i][j] = std::min(dp[i-1][j] + bool(i-j != 0 and b[i-j] != c[i]), dp[i-1][j-1] + bool(c[i] != a[j]));
		}
	}
	std::cout << dp[(i32)c.size() - 1][(i32)a.size() - 1] << "\n";
}
int main()
{
	std::cin.tie(0)->sync_with_stdio(0);
	int t = 1;
	std::cin >> t;
	while(t--)
	{
		solve();
	}
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
typedef int32_t i32;
typedef int64_t i64;
const i32 N = 2e3+10;

i64 dp[N][N];
void solve()
{
	std::string a, b, c;
	std::cin >> a >> b >> c;
	a = " " + a;
	b = " " + b;
	c = " " + c;
	for(i32 i = 0; i < c.size(); i++)
	{
		for(i32 j = 0; j < a.size(); j++)
		{
			dp[i][j] = 1e18;
		}
	}
	dp[0][0] = 0;
	for(i32 i = 1; i < c.size(); i++)
	{
		for(i32 j = 1; j < a.size(); j++)
		{
			if(i < j or i-j >= b.size())
			{
			}
			else
			{
				dp[i][j] = std::min(dp[i-1][j] + bool(i-j != 0 and b[i-j] != c[i]), dp[i-1][j-1] + bool(c[i] != a[j]));
			}
		}
	}
	std::cout << dp[(i32)c.size() - 1][(i32)a.size() - 1] << "\n";
}
int main()
{
	std::cin.tie(0)->sync_with_stdio(0);
	int t = 1;
	std::cin >> t;
	while(t--)
	{
		solve();
	}
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
typedef int32_t i32;
typedef int64_t i64;
const i32 N = 2e3+1;

i64 dp[N][N];
void solve()
{
	std::string a, b, c;
	std::cin >> a >> b >> c;
	a = " " + a;
	b = " " + b;
	c = " " + c;
	for(i32 i = 0; i < c.size(); i++)
	{
		for(i32 j = 0; j < a.size(); j++)
		{
			dp[i][j] = 1e18;
		}
	}
	dp[0][0] = 0;
	for(i32 i = 1; i < c.size(); i++)
	{
		dp[i][0] = dp[i-1][0] + bool(b[i] != c[i]);
		for(i32 j = 1; j < a.size(); j++)
		{
			if(i < j or i-j >= b.size())
			{
			}
			else
			{
				dp[i][j] = std::min(dp[i-1][j] + bool(i-j != 0 and b[i-j] != c[i]), dp[i-1][j-1] + bool(c[i] != a[j]));
			}
		}
	}
	std::cout << dp[(i32)c.size() - 1][(i32)a.size() - 1] << "\n";
}
int main()
{
	std::cin.tie(0)->sync_with_stdio(0);
	int t = 1;
	std::cin >> t;
	while(t--)
	{
		solve();
	}
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

void solve()
{
    int n, l, r; cin >> n >> l >> r;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    cout << accumulate(a.begin(), a.begin()+r-l+1, 0ll) << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc=1; cin >> tc;
    while(tc--) solve();
}

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

using namespace std;



void solve()

{

    int n, l, r; cin >> n >> l >> r;

    vector<int> a(n), b(n);

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

    sort(a.begin(), a.begin()+r-1);

    sort(b.begin()+l-1, b.end());

    cout << min(accumulate(a.begin(), a.begin()+r-l+1, 0ll), accumulate(b.begin(), b.begin()+r-l+1, 0ll)) << '\n';

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int tc=1; cin >> tc;

    while(tc--) solve();

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

using namespace std;



void solve()

{

    int n, l, r; cin >> n >> l >> r;

    vector<int> a(n), b(n);

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

    sort(a.begin(), a.begin()+r-1);

    sort(b.begin()+l-1, b.end());

    cout << min(accumulate(a.begin(), a.begin()+r-l+1, 0ll), accumulate(b.begin(), b.begin()+r-l+1, 0ll)) << '\n';

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int tc=1; cin >> tc;

    while(tc--) solve();

}

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

using namespace std;



void solve()

{

    int n, l, r; cin >> n >> l >> r;

    vector<int> a(n), b(n);

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

    sort(a.begin(), a.begin()+r-1);

    sort(b.begin()+l-1, b.end());

    cout << min(accumulate(a.begin(), a.begin()+r-l+1, 0ll), accumulate(b.begin()+l-1, b.begin()+r, 0ll)) << '\n';

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int tc=1; cin >> tc;

    while(tc--) solve();

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


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

void solve()
{
    int n, l, r; cin >> n >> l >> r;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    cout << accumulate(a.begin(), a.begin()+r-l+1, 0ll) << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc=1; cin >> tc;
    while(tc--) solve();
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

using namespace std;



void solve()

{

    int n, l, r; cin >> n >> l >> r;

    vector<int> a(n), b(n);

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

    sort(a.begin(), a.begin()+r-1);

    sort(b.begin()+l-1, b.end());

    cout << min(accumulate(a.begin(), a.begin()+r-l+1, 0ll), accumulate(b.begin()+l-1, b.begin()+r, 0ll)) << '\n';

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int tc=1; cin >> tc;

    while(tc--) solve();

}

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

void solve()
{
    int n, l, r; cin >> n >> l >> r;
    vector<int> a(n), b(n);
    for(int i=0; i<n; i++) cin >> a[i], b[i]=a[i];
    sort(a.begin(), a.begin()+r);
    sort(b.begin()+l-1, b.end());
    cout << min(accumulate(a.begin(), a.begin()+r-l+1, 0ll), accumulate(b.begin()+l-1, b.begin()+r, 0ll)) << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc=1; cin >> tc;
    while(tc--) solve();
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
#define sz(st) int(st.size())
#define all(st) st.begin(), st.end()


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

	bool flag = true;
	for (int i = 1;i < n;i += 2)
	{
		flag &= (a[i] >= a[i - 1]);
	}
	flag |= is_sorted(a, a + n);
	cout << (flag ? "YES" : "NO");
}

signed main()
{
#if LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int t = 1;
	cin >> t;
	for (int tc = 1; tc <= t; tc++) {
		solve(), cout << "\n";
	}
	return 0;
}

Submission (verdict: Time limit exceeded on test 8):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
#define sz(st) int(st.size())
#define all(st) st.begin(), st.end()


void solve()
{
	int n; cin >> n;
	int a[n];
	for (int i = 0;i < n;i++)
		cin >> a[i];
	vector<int>v;

	function<void()> apply = [&]()
		{
			for (int i = 0;i + 1 < sz(v);i++)
			{
				int mn = min(v[i], v[i + 1]);
				v[i] -= mn, v[i + 1] -= mn;
			}
		};

	for (int i = 0;i < n;i++)
	{
		if (v.empty())
		{
			v.push_back(a[i]);
		}
		else
		{
			if (a[i] >= v.back())
			{
				v.push_back(a[i]);
			}
			else
			{
				apply();
				if (a[i] >= v.back())
				{
					v.push_back(a[i]);
					continue;;
				}
				else
				{
					cout << "NO";
					return;
				}
			}
		}
	}
	cout << "YES";

}

signed main()
{
#if LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int t = 1;
	cin >> t;
	for (int tc = 1; tc <= t; tc++) {
		solve(), cout << "\n";
	}
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
#define sz(st) int(st.size())
#define all(st) st.begin(), st.end()


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

	bool flag = true;
	for (int i = 1;i < n;i += 2)
	{
		flag &= (a[i] >= a[i - 1]);
	}
	flag |= is_sorted(a, a + n);
	cout << (flag ? "YES" : "NO");
}

signed main()
{
#if LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int t = 1;
	cin >> t;
	for (int tc = 1; tc <= t; tc++) {
		solve(), cout << "\n";
	}
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 8):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
#define sz(st) int(st.size())
#define all(st) st.begin(), st.end()


void solve()
{
	int n; cin >> n;
	int a[n];
	for (int i = 0;i < n;i++)
		cin >> a[i];
	vector<int>v;

	function<void()> apply = [&]()
		{
			for (int i = 0;i + 1 < sz(v);i++)
			{
				int mn = min(v[i], v[i + 1]);
				v[i] -= mn, v[i + 1] -= mn;
			}
		};

	for (int i = 0;i < n;i++)
	{
		if (v.empty())
		{
			v.push_back(a[i]);
		}
		else
		{
			if (a[i] >= v.back())
			{
				v.push_back(a[i]);
			}
			else
			{
				apply();
				if (a[i] >= v.back())
				{
					v.push_back(a[i]);
					continue;;
				}
				else
				{
					cout << "NO";
					return;
				}
			}
		}
	}
	cout << "YES";

}

signed main()
{
#if LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int t = 1;
	cin >> t;
	for (int tc = 1; tc <= t; tc++) {
		solve(), cout << "\n";
	}
	return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
#define sz(st) int(st.size())
#define all(st) st.begin(), st.end()


void solve()
{
	int n; cin >> n;
	int a[n];
	for (int i = 0;i < n;i++)
		cin >> a[i];
	vector<int>v;
	int lst = 0;
	function<void()> apply = [&]()
		{
			for (int i = lst;i + 1 < sz(v);i++)
			{
				int mn = min(v[i], v[i + 1]);
				v[i] -= mn, v[i + 1] -= mn;
				if (v[i] == 0)
					lst = max(lst, i);
			}
		};

	for (int i = 0;i < n;i++)
	{
		if (v.empty())
		{
			v.push_back(a[i]);
		}
		else
		{
			if (a[i] >= v.back())
			{
				v.push_back(a[i]);
			}
			else
			{
				apply();
				if (a[i] >= v.back())
				{
					v.push_back(a[i]);
					continue;;
				}
				else
				{
					cout << "NO";
					return;
				}
			}
		}
	}
	cout << "YES";

}

signed main()
{
#if LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int t = 1;
	cin >> t;
	for (int tc = 1; tc <= t; tc++) {
		solve(), cout << "\n";
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: Python 3


Submission (verdict: Wrong answer on test 2):
test = int(input())
for _ in range(test):
    n, l, r = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    for i in range(r-l+1):
        ans += a[i]
    print(ans)
Problem: 2063B - Subsequence Update
Language: Python 3

Previous submission (verdict: Wrong answer on test 2):
test = int(input())
for _ in range(test):
    n, l, r = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    left_sorted = sorted(a[:r])
    right_sorted = sorted(a[l-1:])
    sum_1 = sum(left_sorted[:r-l+1])
    sum_2 = sum(right_sorted[:r-l+1])
    print(min(sum_1, sum_2))
    # ans = 0
    # for i in range(r-l+1):
    #     ans += a[i]
    # print(ans)
        
    
    

Submission (verdict: Accepted):
test = int(input())
for _ in range(test):
    n, l, r = map(int, input().split())
    a = list(map(int, input().split()))
   
    left_sorted = sorted(a[:r])
    right_sorted = sorted(a[l-1:])
    sum_1 = sum(left_sorted[:r-l+1])
    sum_2 = sum(right_sorted[:r-l+1])
    print(min(sum_1, sum_2))
    # ans = 0
    # for i in range(r-l+1):
    #     ans += a[i]
    # print(ans)
Problem: 2063B - Subsequence Update
Language: Python 3

Previous submission (verdict: Wrong answer on test 2):
test = int(input())
for _ in range(test):
    n, l, r = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    for i in range(r-l+1):
        ans += a[i]
    print(ans)
        
    
    

Submission (verdict: Wrong answer on test 2):
test = int(input())
for _ in range(test):
    n, l, r = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    left_sorted = sorted(a[:r])
    right_sorted = sorted(a[l-1:])
    sum_1 = sum(left_sorted[:r-l+1])
    sum_2 = sum(right_sorted[:r-l+1])
    print(min(sum_1, sum_2))
    # ans = 0
    # for i in range(r-l+1):
    #     ans += a[i]
    # print(ans)
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define all(x) x.begin(), x.end()



void solve() {
    int n; cin >> n;
    vector <ll> v(n);
    for(auto &it : v) cin >> it;
    ll mx_sum = accumulate(all(v), 0);
    vector <ll> vv;
    while(v.size() > 1){
        for(int i = 0; i < v.size()-1; i++)
            vv.push_back(v[i+1]-v[i]);
        ll sum = abs(accumulate(all(vv), 0));
        mx_sum = max(mx_sum, sum);
        v = vv;
        vv.clear();
    }
    cout << mx_sum << endl;
}

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


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define all(x) x.begin(), x.end()



void solve() {
    int n; cin >> n;
    vector <ll> v(n);
    for(auto &it : v) cin >> it;
    ll mx_sum = accumulate(all(v), 0LL);
    vector <ll> vv;
    while(v.size() > 1){
        for(int i = 0; i < v.size()-1; i++)
            vv.push_back(v[i+1]-v[i]);
        ll sum = abs(accumulate(all(vv), 0LL));
        mx_sum = max(mx_sum, sum);
        v = vv;
        vv.clear();
    }
    cout << mx_sum << endl;
}

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


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define all(x) x.begin(), x.end()



void solve() {
    int n; cin >> n;
    vector <int> v(n);
    for(auto &it : v) cin >> it;
    int mx_sum = accumulate(all(v), 0);
    vector <int> vv;
    while(v.size() > 1){
        for(int i = 0; i < v.size()-1; i++)
            vv.push_back(v[i+1]-v[i]);
        int sum = abs(accumulate(all(vv), 0));
        mx_sum = max(mx_sum, sum);
        v = vv;
        vv.clear();
    }
    cout << mx_sum << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    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):
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define all(x) x.begin(), x.end()



void solve() {
    int n; cin >> n;
    vector <int> v(n);
    for(auto &it : v) cin >> it;
    int mx_sum = accumulate(all(v), 0);
    vector <int> vv;
    while(v.size() > 1){
        for(int i = 0; i < v.size()-1; i++)
            vv.push_back(v[i+1]-v[i]);
        int sum = abs(accumulate(all(vv), 0));
        mx_sum = max(mx_sum, sum);
        v = vv;
        vv.clear();
    }
    cout << mx_sum << endl;
}

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


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define all(x) x.begin(), x.end()



void solve() {
    int n; cin >> n;
    vector <ll> v(n);
    for(auto &it : v) cin >> it;
    ll mx_sum = accumulate(all(v), 0);
    vector <ll> vv;
    while(v.size() > 1){
        for(int i = 0; i < v.size()-1; i++)
            vv.push_back(v[i+1]-v[i]);
        ll sum = abs(accumulate(all(vv), 0));
        mx_sum = max(mx_sum, sum);
        v = vv;
        vv.clear();
    }
    cout << mx_sum << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    cin >> t;
    while (t--) {
        solve();
    }
    
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
					    		/*Jai Maa Bhawani*/
  #include <bits/stdc++.h>
  using namespace std;
  #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
  #define int long long
  #define TEST int t;cin>>t;while(t--)
  #define inf 5e18
  #define ll long long
  #define pb push_back
  const int N=2e5+10;
  void solve()
  {
  		int n;cin>>n;
  		vector<int>a(n);
  		for(int i=0;i<n;++i)cin>>a[i];
  		if(a[0]>a[1])
  		{
  			cout<<"NO"<<endl;
  			return;
  		}
  		bool f=0;
  		for(int i=2;i<n;++i)
  		{
  			if(a[i]<a[i-1])
  			{
  				f=1;
  				break;
  			}
  		}
  		if(!f)
  		{
  			cout<<"YES"<<endl;
  		}
  		else if(n%2==0)
  		{
  			cout<<"YES"<<endl;
  		}
  		else
  		{
  			cout<<"NO"<<endl;
  		}
  		
  		
  	
  		
  		
  		
  	
	
		
	}
  		
  		
  		
  		
  		
  		
  		
  		
  		
  		
   
    signed main(){FAST TEST{solve();}}

Submission (verdict: Accepted):
					    		/*Jai Maa Bhawani*/
  #include <bits/stdc++.h>
  using namespace std;
  #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
  #define int long long
  #define TEST int t;cin>>t;while(t--)
  #define inf 5e18
  #define ll long long
  #define pb push_back
  const int N=2e5+10;
  void solve()
  {
  		int n;cin>>n;
  		vector<int>a(n);
  		for(int i=0;i<n;++i)cin>>a[i];
  		if(a[0]>a[1])
  		{
  			cout<<"NO"<<endl;
  			return;
  		}
  		for(int i=1;i<n;++i)
  		{
  			int mn=min(a[i],a[i-1]);
  			a[i]-=mn;
  			a[i-1]-=mn;
  		}
  		for(int i=1;i<n;++i)
  		{
  			if(a[i]<a[i-1])
  			{
  				cout<<"NO"<<endl;
  				return;
  			}
  		}
  		cout<<"YES"<<endl;
  		
  		
  		
  		
  	
  		
  		
  		
  	
	
		
	}
  		
  		
  		
  		
  		
  		
  		
  		
  		
  		
   
    signed main(){FAST TEST{solve();}}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
					    		/*Jai Maa Bhawani*/
  #include <bits/stdc++.h>
  using namespace std;
  #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
  #define int long long
  #define TEST int t;cin>>t;while(t--)
  #define inf 5e18
  #define ll long long
  #define pb push_back
  const int N=2e5+10;
  void solve()
  {
  		int n;cin>>n;
  		vector<int>a(n);
  		for(int i=0;i<n;++i)cin>>a[i];
  		if(a[0]>a[1])
  		{
  			cout<<"NO"<<endl;
  			return;
  		}
  		for(int i=1;i<n;++i)
  		{
  			if(a[i]!=a[i-1])
  			{
  				if(a[i]>=a[i-1])
  				{
  					cout<<"YES"<<endl;
  				}
  				else
  				{
  					cout<<"NO"<<endl;
  				}
  				return;
  			}
  		}
  		cout<<"YES"<<endl;
  		
  	
  		
  		
  		
  	
	
		
	}
  		
  		
  		
  		
  		
  		
  		
  		
  		
  		
   
    signed main(){FAST TEST{solve();}}

Submission (verdict: Wrong answer on test 2):
					    		/*Jai Maa Bhawani*/
  #include <bits/stdc++.h>
  using namespace std;
  #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
  #define int long long
  #define TEST int t;cin>>t;while(t--)
  #define inf 5e18
  #define ll long long
  #define pb push_back
  const int N=2e5+10;
  void solve()
  {
  		int n;cin>>n;
  		vector<int>a(n);
  		for(int i=0;i<n;++i)cin>>a[i];
  		if(a[0]>a[1])
  		{
  			cout<<"NO"<<endl;
  			return;
  		}
  		for(int i=2;i<n;++i)
  		{
  			if(a[i]<a[i-1])
  			{
  				if(a[i-1]-a[i-2]>a[i])
  				{
  					cout<<"NO"<<endl;
  					return;
  				}
  				a[i-1]-=a[i-2];
  			}
  		}
  		cout<<"YES"<<endl;
  		
  	
  		
  		
  		
  	
	
		
	}
  		
  		
  		
  		
  		
  		
  		
  		
  		
  		
   
    signed main(){FAST TEST{solve();}}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
					    		/*Jai Maa Bhawani*/
  #include <bits/stdc++.h>
  using namespace std;
  #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
  #define int long long
  #define TEST int t;cin>>t;while(t--)
  #define inf 5e18
  #define ll long long
  #define pb push_back
  const int N=2e5+10;
  void solve()
  {
  		int n;cin>>n;
  		vector<int>a(n);
  		for(int i=0;i<n;++i)cin>>a[i];
  		if(a[0]>a[1])
  		{
  			cout<<"NO"<<endl;
  			return;
  		}
  		for(int i=2;i<n;++i)
  		{
  			if(a[i]<a[i-1])
  			{
  				if(a[i-1]-a[i-2]>a[i])
  				{
  					cout<<"NO"<<endl;
  					return;
  				}
  				a[i-1]-=a[i-2];
  			}
  		}
  		cout<<"YES"<<endl;
  		
  	
  		
  		
  		
  	
	
		
	}
  		
  		
  		
  		
  		
  		
  		
  		
  		
  		
   
    signed main(){FAST TEST{solve();}}

Submission (verdict: Wrong answer on test 2):
					    		/*Jai Maa Bhawani*/
  #include <bits/stdc++.h>
  using namespace std;
  #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
  #define int long long
  #define TEST int t;cin>>t;while(t--)
  #define inf 5e18
  #define ll long long
  #define pb push_back
  const int N=2e5+10;
  void solve()
  {
  		int n;cin>>n;
  		vector<int>a(n);
  		for(int i=0;i<n;++i)cin>>a[i];
  		if(a[0]>a[1])
  		{
  			cout<<"NO"<<endl;
  			return;
  		}
  		bool f=0;
  		for(int i=2;i<n;++i)
  		{
  			if(a[i]<a[i-1])
  			{
  				f=1;
  				break;
  			}
  		}
  		if(!f)
  		{
  			cout<<"YES"<<endl;
  		}
  		else if(n%2==0)
  		{
  			cout<<"YES"<<endl;
  		}
  		else
  		{
  			cout<<"NO"<<endl;
  		}
  		
  		
  	
  		
  		
  		
  	
	
		
	}
  		
  		
  		
  		
  		
  		
  		
  		
  		
  		
   
    signed main(){FAST TEST{solve();}}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
					    		/*Jai Maa Bhawani*/
  #include <bits/stdc++.h>
  using namespace std;
  #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
  #define int long long
  #define TEST int t;cin>>t;while(t--)
  #define inf 5e18
  #define ll long long
  #define pb push_back
  const int N=2e5+10;
  void solve()
  {
  		int n;cin>>n;
  		vector<int>a(n);
  		for(int i=0;i<n;++i)cin>>a[i];
  		if(a[0]>a[1])
  		{
  			cout<<"NO"<<endl;
  			return;
  		}
  		for(int i=1;i<n;++i)
  		{
  			if(a[i]!=a[i-1])
  			{
  				if(a[i]>=a[i-1])
  				{
  					cout<<"YES"<<endl;
  				}
  				else
  				{
  					cout<<"NO"<<endl;
  				}
  				return;
  			}
  		}
  		cout<<"YES"<<endl;
  		
  	
  		
  		
  		
  	
	
		
	}
  		
  		
  		
  		
  		
  		
  		
  		
  		
  		
   
    signed main(){FAST TEST{solve();}}