ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

using namespace std;



void solve() {

int t;

cin >> t;

while (t--) {

string s;

cin >> s;

int n = s.size();

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

if (s[i] > '0' && s[i] - 1 >= s[i - 1]) {

swap(s[i], s[i - 1]);

s[i]--;

i = min(i + 2, n);

}

}

cout << s << "\n";

}

}



int main() {

ios::sync_with_stdio(0);

cin.tie(0);

solve();

return 0;

}



Submission (verdict: Wrong answer on test 1):
#include <iostream>

#include <string>

#include <vector>



int main() {

std::ios_base::sync_with_stdio(false);

std::cin.tie(nullptr);



int t;

std::cin >> t;



while (t--) {

std::string s;

std::cin >> s;



int n = s.length();

bool changed = true;



while (changed) {

changed = false;



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

if (s[i] == '0') continue;



for (int j = i - 1; j >= 0; j--) {

std::string temp = s;

temp[i]--;

std::swap(temp[j], temp[i]);



if (temp > s) {

s = temp;

changed = true;

break;

}

}



if (changed) break;

}

}



std::cout << s << '\n';

}



return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>

#include <string>



int main() {

std::ios_base::sync_with_stdio(false);

std::cin.tie(nullptr);



int t;

std::cin >> t;



while (t--) {

std::string s;

std::cin >> s;



bool found;

do {

found = false;

std::string best_result = s;

int best_i = -1, best_j = -1;



for (int i = 1; i < s.size(); ++i) {

if (s[i] == '0') continue;





for (int j = 0; j < i; ++j) {



std::string temp = s;

char decreased = temp[i] - 1;

temp[i] = temp[j];

temp[j] = decreased;



if (temp > best_result) {

best_result = temp;

best_i = i;

best_j = j;

found = true;

}

}

}



if (found) {

s = best_result;

}

} while (found);



std::cout << s << '\n';

}



return 0;

}

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

using namespace std;



#define fastio ios::sync_with_stdio(0);cin.tie(0)



int main()

{

fastio;

long long t,n,i,j;

string s;

char cur;

cin>>t;

while(t--)

{

cin>>s;

n=s.size();

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

{

cur=s[i];

for(j=i-1;j>=0;j--)

{

if(cur<=s[j]+1)

break;

s[j+1]=s[j];

s[j]=(char)(cur-1);

cur--;

if(cur=='0')

break;

}

}

cout<<s<<"\n";

}

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>

#include <string>



int main() {

std::ios_base::sync_with_stdio(false);

std::cin.tie(nullptr);



int t;

std::cin >> t;



while (t--) {

std::string s;

std::cin >> s;



bool improved = true;

while (improved) {

improved = false;



for (int i = 1; i < s.size(); i++) {

if (s[i] == '0') continue;



for (int j = i-1; j >= 0; j--) {

std::string temp = s;

temp[i]--;

std::swap(temp[i], temp[j]);



if (temp > s) {

s = temp;

improved = true;

goto found_improvement;

}

}

}

found_improvement:;

}



std::cout << s << "\n";

}



return 0;

}

Submission (verdict: Wrong answer on test 1):
#include <iostream>

#include <string>



int main() {

std::ios_base::sync_with_stdio(false);

std::cin.tie(nullptr);



int t;

std::cin >> t;



while (t--) {

std::string s;

std::cin >> s;



bool found;

do {

found = false;

std::string best_result = s;

int best_i = -1, best_j = -1;



for (int i = 1; i < s.size(); ++i) {

if (s[i] == '0') continue;





for (int j = 0; j < i; ++j) {



std::string temp = s;

char decreased = temp[i] - 1;

temp[i] = temp[j];

temp[j] = decreased;



if (temp > best_result) {

best_result = temp;

best_i = i;

best_j = j;

found = true;

}

}

}



if (found) {

s = best_result;

}

} while (found);



std::cout << s << '\n';

}



return 0;

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


Submission (verdict: Memory limit exceeded on test 1):
#include <cstdio>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
const int maxn = 2e5 + 50;
inline int rd() {
    int sum = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        sum = sum * 10 + ch - '0';
        ch = getchar();
    }
    return f * sum;
}
int n, t, ans;
struct F {
    int a, u;
} f[maxn];
vector<int> g[maxn];
void dfs(int u, int fa) {
    priority_queue<int> q;
    for (auto v : g[u]) {
        if (v == fa)
            continue;
        dfs(v, u);
        if (f[v].a > f[u].a)
            f[u].a = f[v].a, f[u].u = f[v].u;
        q.push(f[v].a);
        if (f[v].u == v)
            ans = max(ans, f[v].a + (int)g[u].size() - 1);
        else
            ans = max(ans, f[v].a + (int)g[u].size());
    }
    if ((int)g[u].size() - 1 > f[u].a)
        f[u].a = (int)g[u].size() - 1, f[u].u = u;
    if ((int)g[u].size() == 1)
        f[u].u = u;
    if (q.size() >= 2) {
        int x = q.top();
        q.pop();
        ans = max(ans, x + q.top());
    }
    while (!q.empty())
        q.pop();
}
void work() {
    n = rd();
    for (int i = 1; i < n; i++) {
        int u = rd(), v = rd();
        g[u].push_back(v), g[v].push_back(u);
    }
    ans = 0;
    dfs(1, 1);
    // for (int i = 1; i <= n; i++)
    //     printf("%d %d\n", f[i].u, f[i].a);
    for (int i = 1; i <= n; i++)
        f[i].u = f[i].a = 0;
    printf("%d\n", ans);
}
int main() {
    // freopen("a.in","r",stdin);
    t = rd();
    while (t--)
        work();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

using namespace std;
using LL = long long;

void work(){
  int n;
  cin >> n;
  vector<int> a(n + 3);
  int ans = -1e9, sss = 0;
  for(int i = 1; i <= n; i++){
    cin >> a[i], sss += a[i];
  }
  ans = max(ans, sss);
  while(n > 1){
    int sum = 0;
    sum = a[n] - a[1];
    ans = max(ans, sum);
    int _sum = 0;
    _sum = a[1] - a[n];
    ans = max(ans, _sum);
    for(int i = 1; i <= n - 1; i++) a[i] = a[i + 1] - a[i];
    n--;
  }
  cout << ans << "\n";
}

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  int T;
  cin >> T;
  while(T--){
    work();
  }
  return 0;
}


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

using namespace std;
using LL = long long;

void work(){
  int n;
  cin >> n;
  vector<LL> a(n + 3);
  LL ans = -1e18, sss = 0;
  for(int i = 1; i <= n; i++){
    cin >> a[i], sss += a[i];
  }
  ans = max(ans, sss);
  while(n > 1){
    int sum = 0;
    sum = a[n] - a[1];
    ans = max(ans, sum);
    int _sum = 0;
    _sum = a[1] - a[n];
    ans = max(ans, _sum);
    for(int i = 1; i <= n - 1; i++) a[i] = a[i + 1] - a[i];
    n--;
  }
  cout << ans << "\n";
}

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  int T;
  cin >> T;
  while(T--){
    work();
  }
  return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


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

using namespace std;
using LL = long long;

void work(){
  int n;
  cin >> n;
  vector<int> a(n + 3);
  int ans = -1e9, sss = 0;
  for(int i = 1; i <= n; i++){
    cin >> a[i], sss += a[i];
  }
  ans = max(ans, sss);
  while(n > 1){
    int sum = 0;
    sum = a[n] - a[1];
    ans = max(ans, sum);
    int _sum = 0;
    _sum = a[1] - a[n];
    ans = max(ans, _sum);
    for(int i = 1; i <= n - 1; i++) a[i] = a[i + 1] - a[i];
    n--;
  }
  cout << ans << "\n";
}

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  int T;
  cin >> T;
  while(T--){
    work();
  }
  return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>

using namespace std;
using LL = long long;

void work(){
  int n;
  cin >> n;
  vector<LL> a(n + 3);
  LL ans = -1e18, sss = 0;
  for(int i = 1; i <= n; i++){
    cin >> a[i], sss += a[i];
  }
  ans = max(ans, sss);
  while(n > 1){
    int sum = 0;
    sum = a[n] - a[1];
    ans = max(ans, sum);
    int _sum = 0;
    _sum = a[1] - a[n];
    ans = max(ans, _sum);
    for(int i = 1; i <= n - 1; i++) a[i] = a[i + 1] - a[i];
    n--;
  }
  cout << ans << "\n";
}

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  int T;
  cin >> T;
  while(T--){
    work();
  }
  return 0;
}


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

using namespace std;
using LL = long long;

void work(){
  int n;
  cin >> n;
  vector<LL> a(n + 3);
  LL ans = -1e18, sss = 0;
  for(int i = 1; i <= n; i++){
    cin >> a[i], sss += a[i];
  }
  ans = max(ans, sss);
  while(n > 1){
    LL sum = 0;
    sum = a[n] - a[1];
    ans = max(ans, sum);
    LL _sum = 0;
    _sum = a[1] - a[n];
    ans = max(ans, _sum);
    for(int i = 1; i <= n - 1; i++) a[i] = a[i + 1] - a[i];
    n--;
  }
  cout << ans << "\n";
}

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  int T;
  cin >> T;
  while(T--){
    work();
  }
  return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define psi pair<string,int>
#define mp make_pair
#define pii pair<int,int>
#define yes cout << "Yes\n"
#define no cout << "No\n"
using namespace std;
const int N = 1e6;
const ll M = 998244353;
const int inf = -1e9;
using namespace std;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int _;cin >> _;
    while(_ --)
    {
        int l,r;cin >> l >> r;
        int a = 0,b = 0,c = 0;
        int ans = 0;
        for(int i = 29;i >= 0;i --)
        {
            if((1 << i) <= l)
            {
                l -= (1 << i);
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
            }
            else if((1 << i) <= r)
            {
                a += (1 << i);
                b += (1 << i) - 1;
                c += (1 << i) - 1;
                break;
            }
        }
        cout << a << " " << b << " " << c << '\n';
    }
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define psi pair<string,int>
#define mp make_pair
#define pii pair<int,int>
#define yes cout << "Yes\n"
#define no cout << "No\n"
using namespace std;
const int N = 1e6;
const ll M = 998244353;
const int inf = -1e9;
using namespace std;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int _;cin >> _;
    while(_ --)
    {
        int l,r;cin >> l >> r;
        int a = 0,b = 0,c = 0;
        int ans = 0;
        for(int i = 29;i >= 0;i --)
        {
            if((1 << i) <= l)
            {
                l -= (1 << i);
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
            }
            else if((1 << i) <= r)
            {
                a += (1 << i);
                b += (1 << i) - 1;
                c += (1 << i) - 2;
                break;
            }
        }
        cout << a << " " << b << " " << c << '\n';
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define psi pair<string,int>
#define mp make_pair
#define pii pair<int,int>
#define yes cout << "Yes\n"
#define no cout << "No\n"
using namespace std;
const int N = 1e6;
const ll M = 998244353;
const int inf = -1e9;
using namespace std;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int _;cin >> _;
    while(_ --)
    {
        int l,r;cin >> l >> r;
        int a = 0,b = 0,c = 0;
        int ans = 0;
        for(int i = 29;i >= 0;i --)
        {
            if((1 << i) <= l)
            {
                l -= (1 << i);
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
            }
            else if((1 << i) <= r)
            {
                a += (1 << i);
                b += (1 << i) - 1;
                c += (1 << i) - 1;
                break;
            }
        }
        cout << a << " " << b << " " << c << '\n';
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define psi pair<string,int>
#define mp make_pair
#define pii pair<int,int>
#define yes cout << "Yes\n"
#define no cout << "No\n"
using namespace std;
const int N = 1e6;
const ll M = 998244353;
const int inf = -1e9;
using namespace std;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int _;cin >> _;
    while(_ --)
    {
        int l,r;cin >> l >> r;
        int a = 0,b = 0,c = 0;
        int ans = 0;
        for(int i = 29;i >= 0;i --)
        {
            if((1 << i) <= l)
            {
                l -= (1 << i);
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
            }
            else if((1 << i) <= r)
            {
                a += (1 << i);
                b += (1 << i) - 1;
                c += (1 << i) - 2;
                if(c < l)c = a + 1;
                break;
            }
        }
        cout << a << " " << b << " " << c << '\n';
    }
}


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define psi pair<string,int>
#define mp make_pair
#define pii pair<int,int>
#define yes cout << "Yes\n"
#define no cout << "No\n"
using namespace std;
const int N = 1e6;
const ll M = 998244353;
const int inf = -1e9;
using namespace std;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int _;cin >> _;
    while(_ --)
    {
        int l,r;cin >> l >> r;
        int a = 0,b = 0,c = 0;
        int ans = 0;
        for(int i = 29;i >= 0;i --)
        {
            if((1 << i) <= l)
            {
                l -= (1 << i);
                r -= (1 << i);
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
            }
            else if((1 << i) <= r)
            {
                a += (1 << i);
                b += (1 << i) - 1;
                c += (1 << i) - 2;
                if(c < l)c = a + 1;
                break;
            }
        }
        cout << a << " " << b << " " << c << '\n';
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define psi pair<string,int>
#define mp make_pair
#define pii pair<int,int>
#define yes cout << "Yes\n"
#define no cout << "No\n"
using namespace std;
const int N = 1e6;
const ll M = 998244353;
const int inf = -1e9;
using namespace std;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int _;cin >> _;
    while(_ --)
    {
        int l,r;cin >> l >> r;
        int a = 0,b = 0,c = 0;
        int ans = 0;
        for(int i = 29;i >= 0;i --)
        {
            if((1 << i) <= l)
            {
                l -= (1 << i);
                r -= (1 << i);
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
            }
            else if((1 << i) <= r)
            {
                a += (1 << i);
                b += (1 << i) - 1;
                c += (1 << i) - 2;
                if(c < l)c = a + 1;
                break;
            }
        }
        cout << a << " " << b << " " << c << '\n';
    }
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define psi pair<string,int>
#define mp make_pair
#define pii pair<int,int>
#define yes cout << "Yes\n"
#define no cout << "No\n"
using namespace std;
const int N = 1e6;
const ll M = 998244353;
const int inf = -1e9;
using namespace std;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int _;cin >> _;
    while(_ --)
    {
        int l,r;cin >> l >> r;
        int tl = l,tr = r;
        int a = 0,b = 0,c = 0;
        int ans = 0;
        for(int i = 29;i >= 0;i --)
        {
            if((1 << i) <= tl)
            {
                tl -= (1 << i);
                tr -= (1 << i);
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
            }
            else if((1 << i) <= tr)
            {
                a += (1 << i);
                b += (1 << i) - 1;
                c += (1 << i) - 2;
                if(c < l)c = a + 1;
                break;
            }
        }
        cout << a << " " << b << " " << c << '\n';
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define psi pair<string,int>
#define mp make_pair
#define pii pair<int,int>
#define yes cout << "Yes\n"
#define no cout << "No\n"
using namespace std;
const int N = 1e6;
const ll M = 998244353;
const int inf = -1e9;
using namespace std;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int _;cin >> _;
    while(_ --)
    {
        int l,r;cin >> l >> r;
        int a = 0,b = 0,c = 0;
        int ans = 0;
        for(int i = 29;i >= 0;i --)
        {
            if((1 << i) <= l)
            {
                l -= (1 << i);
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
            }
            else if((1 << i) <= r)
            {
                a += (1 << i);
                b += (1 << i) - 1;
                c += (1 << i) - 2;
                break;
            }
        }
        cout << a << " " << b << " " << c << '\n';
    }
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define psi pair<string,int>
#define mp make_pair
#define pii pair<int,int>
#define yes cout << "Yes\n"
#define no cout << "No\n"
using namespace std;
const int N = 1e6;
const ll M = 998244353;
const int inf = -1e9;
using namespace std;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int _;cin >> _;
    while(_ --)
    {
        int l,r;cin >> l >> r;
        int a = 0,b = 0,c = 0;
        int ans = 0;
        for(int i = 29;i >= 0;i --)
        {
            if((1 << i) <= l)
            {
                l -= (1 << i);
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
            }
            else if((1 << i) <= r)
            {
                a += (1 << i);
                b += (1 << i) - 1;
                c += (1 << i) - 2;
                if(c < l)c = a + 1;
                break;
            }
        }
        cout << a << " " << b << " " << c << '\n';
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

using namespace std;



void solve(){

int n;

cin >> n;

vector<int>a(n+1);

for(int i = 1;i<=n;i++)cin >> a[i];

int cnt = 1;

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

if(a[i]<=a[i+1]){

cnt++;

}else{

if(cnt!=2){

cout << "NO" << endl;

return ;

}

cnt = 1;

}

}

cout << "YES" << endl;

}



int main(){

int t;

cin >> t;

while (t--){

solve();

}

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

using namespace std;



void solve(){

int n;

cin >> n;

vector<int>a(n+1);

for(int i = 1;i<=n;i++)cin >> a[i];

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

if(a[i]<=a[i+1]){



}else{

if(i == 1){

cout << "NO" << endl;

return ;

}

a[i] -= min(a[i],a[i-1]);

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

cout << "NO" << endl;

return ;

}

}

}

cout << "YES" << endl;

}



int main(){

int t;

cin >> t;

while (t--){

solve();

}

}

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

using namespace std;



void solve(){

int n;

cin >> n;

vector<int>a(n+1);

for(int i = 1;i<=n;i++)cin >> a[i];

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

if(a[i]<=a[i+1]){

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

a[i] -= t;

a[i+1] -= t;

}else{

cout << "NO" << endl;

return ;

}

}

cout << "YES" << endl;

}



int main(){

int t;

cin >> t;

while (t--){

solve();

}

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

using namespace std;



void solve(){

int n;

cin >> n;

vector<int>a(n+1);

for(int i = 1;i<=n;i++)cin >> a[i];

int cnt = 1;

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

if(a[i]<=a[i+1]){

cnt++;

}else{

if(cnt<2){

cout << "NO" << endl;

return ;

}

cnt = 1;

}

}

cout << "YES" << endl;

}



int main(){

int t;

cin >> t;

while (t--){

solve();

}

}

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

using namespace std;



void solve(){

int n;

cin >> n;

vector<int>a(n+1);

for(int i = 1;i<=n;i++)cin >> a[i];

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

if(a[i]<=a[i+1]){



}else{

if(i == 1){

cout << "NO" << endl;

return ;

}

a[i] -= min(a[i],a[i-1]);

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

cout << "NO" << endl;

return ;

}

}

}

cout << "YES" << endl;

}



int main(){

int t;

cin >> t;

while (t--){

solve();

}

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

using namespace std;



void solve(){

int n;

cin >> n;

vector<int>a(n+1);

for(int i = 1;i<=n;i++)cin >> a[i];

int cnt = 1;

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

if(a[i]<=a[i+1]){

cnt++;

}else{

if(cnt!=2){

cout << "NO" << endl;

return ;

}

cnt = 1;

}

}

cout << "YES" << endl;

}



int main(){

int t;

cin >> t;

while (t--){

solve();

}

}

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

using namespace std;



void solve(){

int n;

cin >> n;

vector<int>a(n+1);

for(int i = 1;i<=n;i++)cin >> a[i];

int cnt = 1;

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

if(a[i]<=a[i+1]){

cnt++;

}else{

if(cnt<2){

cout << "NO" << endl;

return ;

}

cnt = 1;

}

}

cout << "YES" << endl;

}



int main(){

int t;

cin >> t;

while (t--){

solve();

}

}