ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

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

#define x first

#define y second

using namespace std;

#define int long long

typedef pair<int, int> PII;

typedef long long LL;

const int N = 2e5+10;

const int mod = 998244353;

const int p = 1e9 + 7;

int a[N];

void solve(){

   int n, x, y;

	cin >> n >> x >> y;

	a[x] = 1, a[y] = 0;

	int t1 = abs(x-y)-1, t2 = n - 2 - t1;

	if(x > y)swap(x, y);

	int st = x+1;

	

		for(int i = 1; i <= t1/2; i ++) {

			a[st] = 0;

			a[st+1] = 1;

			st+=2;

		}

	if(t1%2)a[st] = 2;

		st = y+1;

		if(st > n)st-=n;

	for(int i = 1; i <= t2/ 2; i ++){

		a[st] = 1;

			a[st+1] = 0;

			st+=2;

			if(st > n)st-=n;

	}

	if(t2%2)a[st] = 2;

	for(int i = 1; i <= n; i++)cout << a[i] <<' ';

	cout <<endl;

}

signed main() {

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}

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

#define x first

#define y second

using namespace std;

#define int long long

typedef pair<int, int> PII;

typedef long long LL;

const int N = 2e5+10;

const int mod = 998244353;

const int p = 1e9 + 7;

int a[N];

void solve(){

   int n, x, y;

	cin >> n >> x >> y;

	a[x] = 1, a[y] = 0;

	int t1 = abs(x-y)-1, t2 = n - 2 - t1;

	if(x > y)swap(x, y);

	int st = x+1;

	

		for(int i = 1; i <= t1/2; i ++) {

			a[st] = 0;

			a[st+1] = 1;

			st+=2;

		}

	if(t1%2)a[st] = 2;

		st = y+1;

		if(st > n)st-=n;

	for(int i = 1; i <= t2/ 2; i ++){

		if(st > n)st-=n;

		a[st] = 1;

		if(st+1 > n)st-=n;

			a[st+1] = 0;

			st+=2;

		

	}

	if(t2%2)a[st] = 2;

	for(int i = 1; i <= n; i++)cout << a[i] <<' ';

	cout <<endl;

}

signed main() {

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)


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

#define x first

#define y second

using namespace std;

#define int long long

typedef pair<int, int> PII;

typedef long long LL;

const int N = 2e5+10;

const int mod = 998244353;

const int p = 1e9 + 7;

int a[N];

void solve(){

   int n, x, y;

	cin >> n >> x >> y;

	a[x] = 1, a[y] = 0;

	int t1 = abs(x-y)-1, t2 = n - 2 - t1;

	if(x > y)swap(x, y);

	int st = x+1;

	

		for(int i = 1; i <= t1/2; i ++) {

			a[st] = 0;

			a[st+1] = 1;

			st+=2;

		}

	if(t1%2)a[st] = 2;

		st = y+1;

		if(st > n)st-=n;

	for(int i = 1; i <= t2/ 2; i ++){

		a[st] = 1;

			a[st+1] = 0;

			st+=2;

			if(st > n)st-=n;

	}

	if(t2%2)a[st] = 2;

	for(int i = 1; i <= n; i++)cout << a[i] <<' ';

	cout <<endl;

}

signed main() {

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

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

#define x first

#define y second

using namespace std;

#define int long long

typedef pair<int, int> PII;

typedef long long LL;

const int N = 2e5+10;

const int mod = 998244353;

const int p = 1e9 + 7;

int a[N];

void solve(){

   int n, x, y;

	cin >> n >> x >> y;

	a[x] = 1, a[y] = 0;

	int t1 = abs(x-y)-1, t2 = n - 2 - t1;

	if(x > y)swap(x, y);

	int st = x+1;

	

		for(int i = 1; i <= t1/2; i ++) {

			a[st] = 0;

			a[st+1] = 1;

			st+=2;

		}

	if(t1%2)a[st] = 2;

		st = y+1;

		if(st > n)st-=n;

	for(int i = 1; i <= t2/ 2; i ++){

		if(st > n)st-=n;

		a[st] = 1;

		if(st+1 > n)st-=n;

			a[st+1] = 0;

			st+=2;

		

	}

	if(t2%2)a[st] = 2;

	for(int i = 1; i <= n; i++)cout << a[i] <<' ';

	cout <<endl;

}

signed main() {

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}

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

#define x first

#define y second

using namespace std;

#define int long long

typedef pair<int, int> PII;

typedef long long LL;

const int N = 2e5+10;

const int mod = 998244353;

const int p = 1e9 + 7;

int a[N];

void solve(){

   int n, x, y;

	cin >> n >> x >> y;

	a[x] = 1, a[y] = 0;

	int t1 = abs(x-y)-1, t2 = n - 2 - t1;

	if(x > y)swap(x, y);

	int st = x+1;

	

		for(int i = 1; i <= t1/2; i ++) {

			a[st] = 0;

			a[st+1] = 1;

			st+=2;

		}

	if(t1%2)a[st] = 2;

		st = y+1;

		if(st > n)st-=n;

	for(int i = 1; i <= t2/ 2; i ++){

		if(st > n)st-=n;

		a[st] = 1;

		if(st+1 > n)st-=n;

			a[st+1] = 0;

			st+=2;	

	}

	if(st > n)st-=n;

	if(t2%2)a[st] = 2;

	for(int i = 1; i <= n; i++)cout << a[i] <<' ';

	cout <<endl;

}

signed main() {

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64


Submission (verdict: Memory limit exceeded on test 3):
import io, os
from typing import List, Tuple
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline 
def dynamicProgramming(digits: List[int], i: int, memo: dict) -> bool:
    key = (i, tuple(digits))
    if key in memo:
        return memo[key]
    if i >= len(digits):
        memo[key] = sum(digits) % 9 == 0
        return memo[key]
    if digits[i] <= 1 or digits[i] > 3:
        memo[key] = dynamicProgramming(digits, i + 1, memo)
        return memo[key]
    original = digits[i]
    digits[i] = digits[i] ** 2
    choose = dynamicProgramming(digits, i, memo)
    digits[i] = original  
    skip = dynamicProgramming(digits, i + 1, memo)
    memo[key] = choose or skip
    return memo[key]
def main():
    for _ in [0]*int(input().decode()):
        digits = list(map(int, input().decode().strip()))
        memo = {}
        result = "Yes" if dynamicProgramming(digits, 0, memo) else "No"
        print(result)
if __name__ == "__main__":
    main()
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64

Previous submission (verdict: Memory limit exceeded on test 3):
import io, os
from typing import List, Tuple
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline 
def dynamicProgramming(digits: List[int], i: int, memo: dict) -> bool:
    key = (i, tuple(digits))
    if key in memo:
        return memo[key]
    if i >= len(digits):
        memo[key] = sum(digits) % 9 == 0
        return memo[key]
    if digits[i] <= 1 or digits[i] > 3:
        memo[key] = dynamicProgramming(digits, i + 1, memo)
        return memo[key]
    original = digits[i]
    digits[i] = digits[i] ** 2
    choose = dynamicProgramming(digits, i, memo)
    digits[i] = original  
    skip = dynamicProgramming(digits, i + 1, memo)
    memo[key] = choose or skip
    return memo[key]
def main():
    for _ in [0]*int(input().decode()):
        digits = list(map(int, input().decode().strip()))
        memo = {}
        result = "Yes" if dynamicProgramming(digits, 0, memo) else "No"
        print(result)
if __name__ == "__main__":
    main()

Submission (verdict: Time limit exceeded on test 3):
from typing import List
from functools import lru_cache

def dynamicProgramming(digits: List[int], i: int) -> bool:
    digits_tuple = tuple(digits)
    
    if i >= len(digits):
        return int("".join(map(str, digits))) % 9 == 0
    
    if digits[i] <= 1 or digits[i] > 3:
        return dynamicProgramming(digits, i + 1)
    
    original = digits[i]
    digits[i] = digits[i] ** 2
    choose = dynamicProgramming(digits, i)
    digits[i] = original  

    skip = dynamicProgramming(digits, i + 1)
    
    return choose or skip

@lru_cache(None)
def memoizedDynamicProgramming(digits_tuple: tuple, i: int) -> bool:
    digits = list(digits_tuple)
    return dynamicProgramming(digits, i)

def main():
    t = int(input())
    for _ in range(t):
        digits = list(map(int, input().strip()))
        result = "Yes" if memoizedDynamicProgramming(tuple(digits), 0) else "No"
        print(result)

if __name__ == "__main__":
    main()
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64

Previous submission (verdict: Runtime error on test 4):
from functools import lru_cache
from typing import List, Tuple

def isDivisibleBy9(digit_sum: int) -> bool:
    """
    Checks if the given sum of digits is divisible by 9.
    """
    return digit_sum % 9 == 0

@lru_cache(None)
def dynamicProgramming(digits_tuple: Tuple[int], i: int, digit_sum: int) -> bool:
    """
    Recursive DP function with memoization to determine if a valid number divisible
    by 9 can be formed by modifying the digits.
    
    Args:
    - digits_tuple: Tuple of digits (immutable version of the list for caching).
    - i: Current index in the digits array.
    - digit_sum: Current sum of the digits modulo 9.
    
    Returns:
    - True if divisible by 9; False otherwise.
    """
    if i >= len(digits_tuple):
        return isDivisibleBy9(digit_sum)
    
    # Current digit
    current_digit = digits_tuple[i]
    
    # Skip the current digit
    skip = dynamicProgramming(digits_tuple, i + 1, digit_sum)
    
    # Try modifying the current digit if it's in the valid range
    modify = False
    if 1 <= current_digit <= 3:
        squared_digit = current_digit ** 2
        new_sum = (digit_sum - current_digit + squared_digit) % 9
        modify = dynamicProgramming(digits_tuple, i + 1, new_sum)
    
    return skip or modify

def main():
    t = int(input())
    for _ in range(t):
        digits = list(map(int, input().strip()))
        digit_sum = sum(digits) % 9  # Precompute the sum of digits modulo 9
        # Convert digits to tuple for memoization compatibility
        result = "Yes" if dynamicProgramming(tuple(digits), 0, digit_sum) else "No"
        print(result)

if __name__ == "__main__":
    main()


Submission (verdict: Accepted):
def main():
    import sys
    input = sys.stdin.read
    data = input().split()

    tc = int(data[0])  # Read the number of test cases
    results = []

    for t in range(1, tc + 1):
        str_num = data[t]
        sum_digits = 0
        two_cnt = 0
        three_cnt = 0

        # Count sum of digits, number of 2's, and number of 3's
        for char in str_num:
            digit = int(char)
            sum_digits += digit
            if digit == 2:
                two_cnt += 1
            elif digit == 3:
                three_cnt += 1

        valid = False

        # Try combinations of 2's and 3's
        for i in range(min(8, two_cnt) + 1):
            for j in range(min(8, three_cnt) + 1):
                if (sum_digits + 2 * i + 6 * j) % 9 == 0:
                    results.append("yes".capitalize())
                    valid = True
                    break
            if valid:
                break
        if not valid:
            results.append("no".capitalize())
    
    # Print all results at once
    sys.stdout.write("\n".join(results) + "\n")

if __name__ == "__main__":
    main()
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64

Previous submission (verdict: Time limit exceeded on test 3):
from typing import List
from functools import lru_cache

def dynamicProgramming(digits: List[int], i: int) -> bool:
    digits_tuple = tuple(digits)
    
    if i >= len(digits):
        return int("".join(map(str, digits))) % 9 == 0
    
    if digits[i] <= 1 or digits[i] > 3:
        return dynamicProgramming(digits, i + 1)
    
    original = digits[i]
    digits[i] = digits[i] ** 2
    choose = dynamicProgramming(digits, i)
    digits[i] = original  

    skip = dynamicProgramming(digits, i + 1)
    
    return choose or skip

@lru_cache(None)
def memoizedDynamicProgramming(digits_tuple: tuple, i: int) -> bool:
    digits = list(digits_tuple)
    return dynamicProgramming(digits, i)

def main():
    t = int(input())
    for _ in range(t):
        digits = list(map(int, input().strip()))
        result = "Yes" if memoizedDynamicProgramming(tuple(digits), 0) else "No"
        print(result)

if __name__ == "__main__":
    main()

Submission (verdict: Runtime error on test 4):
from functools import lru_cache
from typing import List, Tuple

def isDivisibleBy9(digit_sum: int) -> bool:
    """
    Checks if the given sum of digits is divisible by 9.
    """
    return digit_sum % 9 == 0

@lru_cache(None)
def dynamicProgramming(digits_tuple: Tuple[int], i: int, digit_sum: int) -> bool:
    """
    Recursive DP function with memoization to determine if a valid number divisible
    by 9 can be formed by modifying the digits.
    
    Args:
    - digits_tuple: Tuple of digits (immutable version of the list for caching).
    - i: Current index in the digits array.
    - digit_sum: Current sum of the digits modulo 9.
    
    Returns:
    - True if divisible by 9; False otherwise.
    """
    if i >= len(digits_tuple):
        return isDivisibleBy9(digit_sum)
    
    # Current digit
    current_digit = digits_tuple[i]
    
    # Skip the current digit
    skip = dynamicProgramming(digits_tuple, i + 1, digit_sum)
    
    # Try modifying the current digit if it's in the valid range
    modify = False
    if 1 <= current_digit <= 3:
        squared_digit = current_digit ** 2
        new_sum = (digit_sum - current_digit + squared_digit) % 9
        modify = dynamicProgramming(digits_tuple, i + 1, new_sum)
    
    return skip or modify

def main():
    t = int(input())
    for _ in range(t):
        digits = list(map(int, input().strip()))
        digit_sum = sum(digits) % 9  # Precompute the sum of digits modulo 9
        # Convert digits to tuple for memoization compatibility
        result = "Yes" if dynamicProgramming(tuple(digits), 0, digit_sum) else "No"
        print(result)

if __name__ == "__main__":
    main()
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

void solve()
{
    ll n ; cin>>n;
    vector<ll>v(n);
    for(auto &i : v)cin>>i;
    int j =0;
    for(ll i=1; i<n-1 ; i++)
       if(v[i+1] < v[i])  j = i   ; 
               

    if(j == 0){
        cout<<"YES"<<endl;
        return ;
    }

    auto fun = [&](ll i){
        ll mini = min(v[i], v[i+1]);
            v[i] -= mini;
            v[i+1] -=mini;
       };

       for(ll i =0; i<j ; i++){
           fun(i);
       }

       cout<<(is_sorted(v.begin(), v.end())?"YES":"NO")<<endl;
}

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


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

void solve()
{
    ll n ; cin>>n;
    vector<ll>v(n);
    for(auto &i : v)cin>>i;
    int j =0;
    for(ll i=1; i<n ; i++)
       if(v[i-1] > v[i])  j = i   ; 
               

    if(j == 0){
        cout<<"YES"<<endl;
        return ;
    }

    auto fun = [&](ll i){
        ll mini = min(v[i], v[i+1]);
            v[i] -= mini;
            v[i+1] -=mini;
       };

       for(ll i =0; i<j ; i++){
           fun(i);
       }

       cout<<(is_sorted(v.begin(), v.end())?"YES":"NO")<<endl;
}

signed main()
{
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

void solve()
{
    int n ; cin>>n;
    vector<int>v(n);
    for(auto &i : v)cin>>i;

    if(v[0] < v[1]){
        cout<<"YES"<<endl;
    }else{ 
     for(int i=0; i<n ; i++){
        if(v[i+1] < v[i]){
            cout<<"NO"<<endl;
            return;
        }        
    }}    
}

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


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

void solve()
{
    ll n ; cin>>n;
    vector<ll>v(n);
    for(auto &i : v)cin>>i;
    int j =0;
    for(ll i=0; i<n-1 ; i++)
       if(v[i+1] < v[i])  j = i   ; 
               

    if(j == 0){
        cout<<"YES"<<endl;
        return ;
    }

    auto fun = [&](ll i){
        ll mini = min(v[i], v[i+1]);
            v[i] -= mini;
            v[i+1] -=mini;
       };

       for(ll i =0; i<n-1 ; i++){
           fun(i);
       }

       cout<<(is_sorted(v.begin(), v.end())?"YES":"NO")<<endl;
}

signed main()
{
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

void solve()
{
    ll n ; cin>>n;
    vector<ll>v(n);
    for(auto &i : v)cin>>i;
    int j =0;
    for(ll i=0; i<n-1 ; i++)
       if(v[i+1] < v[i])  j = i   ; 
               

    if(j == 0){
        cout<<"YES"<<endl;
        return ;
    }

    auto fun = [&](ll i){
        ll mini = min(v[i], v[i+1]);
            v[i] -= mini;
            v[i+1] -=mini;
       };

       for(ll i =0; i<n-1 ; i++){
           fun(i);
       }

       cout<<(is_sorted(v.begin(), v.end())?"YES":"NO")<<endl;
}

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


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

void solve()
{
    ll n ; cin>>n;
    vector<ll>v(n);
    for(auto &i : v)cin>>i;
    int j =0;
    for(ll i=1; i<n-1 ; i++)
       if(v[i+1] < v[i])  j = i   ; 
               

    if(j == 0){
        cout<<"YES"<<endl;
        return ;
    }

    auto fun = [&](ll i){
        ll mini = min(v[i], v[i+1]);
            v[i] -= mini;
            v[i+1] -=mini;
       };

       for(ll i =0; i<j ; i++){
           fun(i);
       }

       cout<<(is_sorted(v.begin(), v.end())?"YES":"NO")<<endl;
}

signed main()
{
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

void solve()
{
    int n ; cin>>n;
    vector<int>v(n);
    for(auto &i : v)cin>>i;

    if(v[0] < v[1]){
        cout<<"YES"<<endl;
    }else{ 
     for(int i=0; i<n ; i++){
        if(v[i+1] < v[i]){
            cout<<"NO"<<endl;
            return;
        }        
    }}    
}

signed main()
{
    int t;
    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;

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

        while (v.size() > 1)
        {
            vector<int> w = v;
            reverse(w.begin(), w.end());
            int firstsum = 0, secondsum = 0;

            for (int i = 1; i < v.size(); i++)
            {
                firstsum += (v[i] - v[i - 1]);
            }

            for (int i = 1; i < w.size(); i++)
            {
                secondsum += (w[i] - w[i - 1]);
            }

            vector<int> newarray;
            if (firstsum > secondsum)
            {

                for (int i = 1; i < v.size(); i++)
                {
                    newarray.push_back(v[i] - v[i - 1]);
                }
            }
            else
            {

                for (int i = 1; i < w.size(); i++)
                {
                    newarray.push_back(w[i] - w[i - 1]);
                }
            }

            v = newarray;
        }

        cout << max(v[0], initialsum) << endl;
    }
    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;

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

        while (v.size() > 1)
        {
            vector<int> w = v;
            reverse(w.begin(), w.end());
            int firstsum = 0, secondsum = 0;

            for (int i = 1; i < v.size(); i++)
            {
                firstsum += (v[i] - v[i - 1]);
            }

            for (int i = 1; i < w.size(); i++)
            {
                secondsum += (w[i] - w[i - 1]);
            }

            vector<int> newarray;
            if (firstsum > secondsum)
            {

                for (int i = 1; i < v.size(); i++)
                {
                    newarray.push_back(v[i] - v[i - 1]);
                }
            }
            else
            {

                for (int i = 1; i < w.size(); i++)
                {
                    newarray.push_back(w[i] - w[i - 1]);
                }
            }

            v = newarray;
        }

        cout << max(v[0], initialsum) << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int t;
    cin >> t;
    while (t--)
    {
        long long int n;
        cin >> n;
        vector<long long int> v(n);
        long long int initialsum = 0;
        for (long long int i = 0; i < n; i++)
        {
            cin >> v[i];
            initialsum += v[i];
        }

        while (v.size() > 1)
        {
            vector<long long int> w = v;
            reverse(w.begin(), w.end());
            long long int firstsum = 0, secondsum = 0;

            for (long long int i = 1; i < v.size(); i++)
            {
                firstsum += (v[i] - v[i - 1]);
            }

            for (long long int i = 1; i < w.size(); i++)
            {
                secondsum += (w[i] - w[i - 1]);
            }

            vector<long long int> newarray;
            if (firstsum > secondsum)
            {

                for (long long int i = 1; i < v.size(); i++)
                {
                    newarray.push_back(v[i] - v[i - 1]);
                }
            }
            else
            {

                for (long long int i = 1; i < w.size(); i++)
                {
                    newarray.push_back(w[i] - w[i - 1]);
                }
            }

            v = newarray;
        }

        cout << max(v[0], initialsum) << endl;
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<deque>
using namespace std;
void work(){
    int n;
    cin>>n;
    int check=0;
    vector<int>a(n);
    cin>>a[0];
    cin>>a[1];
    if(a[0]>a[1]){
        check=1;
    }
    for(int i=2;i<n;i++){
        cin>>a[i];
        if(a[i]<a[i-1]-a[i-2]){
        check=1;}
        
    }
    if(check!=1){
        cout<<"YES"<<"\n";
    }
    else{
        cout<<"NO"<<"\n";
    }

    
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        work();
    }
    return 0;
}