prithivMLmods/Coder-Stat huggingface dataset:
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  vector<int> cnt(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  for (int i = 0; i < N; i++) {
    for (int j = i; j < N - 1; j++) {
      if (H[j] >= H[j + 1]) {
        cnt[i]++;
      } else {
        break;
      }
    }
  }
  sort(cnt.begin(), cnt.end());

  cout << cnt[N - 1] << endl;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  vector<int> cnt(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  for (int i = 0; i < N; i++) {
    for (int j = i; j < N - 1; j++) {
      if (H[j] >= H[j + 1]) {
        cnt[i]++;
      } else {
        break;
      }
    }
    if (cnt[i] * 2 >= N) {
      break;
    }
  }
  sort(cnt.begin(), cnt.end());

  cout << cnt[N - 1] << endl;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

int main() {
  int n, a[100000], c = 0;

  cin >> n;

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

  for (int i = 0; i < n - 1; i++) {
    int x = 0;
    for (int j = i; j < n - 1; j++) {
      if (a[j + 1] > a[j]) {
        break;
      } else {
        x++;
      }
    }
    if (x > c)
      c = x;
  }
  cout << c;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int n, a[100000], c = 0;

  cin >> n;

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

  for (int i = 0; i < n - 1; i++) {
    int x = 0;
    for (; i < n - 1; i++) {
      if (a[i + 1] > a[i]) {
        break;
      } else {
        x++;
      }
    }
    if (x > c)
      c = x;
  }
  cout << c;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++)
    cin >> H.at(i);
  priority_queue<int> A;
  int count = 0;
  for (int i = 0; i < N - 1; i++) {
    if (H.at(i) >= H.at(i + 1))
      count++;
    else {
      A.push(count);
      count = 0;
    }
  }
  int ans = A.top();
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++)
    cin >> H.at(i);
  priority_queue<int> A;
  int count = 0;
  for (int i = 0; i < N - 1; i++) {
    if (H.at(i) >= H.at(i + 1))
      count++;
    else {
      A.push(count);
      count = 0;
    }
  }
  A.push(count);
  int ans = A.top();
  cout << ans << endl;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;

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

  int max_count = 0;
  for (int i = 1; i < n; i++) {
    int j = i;
    int count = 0;
    while (j < n) {
      if (h[j] >= h[j + 1]) {
        j++;
        count++;
        max_count = max(max_count, count);
      } else {
        break;
      }
    }
  }
  cout << max_count;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;

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

  int max_count = 0;
  int count = 0;
  for (int i = n; i > 1; i--) {
    if (h[i] <= h[i - 1]) {
      count++;
      max_count = max(max_count, count);
    } else {
      count = 0;
    }
  }
  cout << max_count;

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <time.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
void solve() {
  ll n;
  cin >> n;
  vector<ll> h(n);
  ll i, j, k;
  for (i = 0; i < n; i++)
    cin >> h[i];
  ll dp[n];
  dp[n - 1] = 1;
  for (i = n - 2; i >= 0; i--) {
    if (h[i] >= h[i + 1])
      dp[i] = dp[i + 1] + 1;
    else
      dp[i] = 1;
  }
  ll ans = INT_MIN;
  for (i = 0; i < n; i++)
    ans = max(ans, dp[i]);
  cout << ans - 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  clock_t tStart = clock();
  ll t;
  // cin>>t;
  // while(t--)
  solve();
  // printf("\nTime taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <time.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
void solve() {
  ll n;
  cin >> n;
  vector<ll> h(n);
  ll i, j, k;
  for (i = 0; i < n; i++)
    cin >> h[i];
  ll dp[n];
  dp[n - 1] = 1;
  for (i = n - 2; i >= 0; i--) {
    if (h[i] >= h[i + 1])
      dp[i] = dp[i + 1] + 1;
    else
      dp[i] = 1;
  }
  ll ans = INT_MIN;
  for (i = 0; i < n; i++)
    ans = max(ans, dp[i]);
  cout << ans - 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  // #endif
  clock_t tStart = clock();
  ll t;
  // cin>>t;
  // while(t--)
  solve();
  // printf("\nTime taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, sum, saidai;
  cin >> N;
  sum = 0;
  saidai = 0;
  vector<int> vec(N);
  vector<int> wow(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < N; i++) {
    wow.at(i) = 0;
  }
  for (int i = 0; i < N - 1; i++) {
    for (int j = 0; j < N - 1; j++) {
      if (vec.at(j) >= vec.at(j + 1)) {
        wow.at(i)++;
      } else {
        break;
      }
    }
  }
  if (vec.at(N - 2) > vec.at(N - 1)) {
    wow.at(N - 1) = 1;
  } else {
    wow.at(N - 1) = 0;
  }
  for (int i = 0; i < N; i++) {
    if (saidai < wow.at(i)) {
      saidai = wow.at(i);
    }
  }
  cout << saidai << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, sum, saidai;
  cin >> N;
  sum = 0;
  saidai = 0;
  vector<int> vec(N);
  vector<int> wow(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  reverse(vec.begin(), vec.end());
  for (int i = 1; i < N; i++) {
    if (vec.at(i - 1) <= vec.at(i))
      sum++;
    else
      sum = 0;
    saidai = max(saidai, sum);
  }
  cout << saidai << endl;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  int nowmax = 0;
  cin >> N;
  vector<int> data(N + 1);
  data.at(N) = 1000000001;
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }

  for (int i = 0; i < N; i++) // 落下地点
  {
    int Now = i;
    int count = 0;
    while (data.at(Now) >= data.at(Now + 1)) {
      Now++;
      count++;
    }
    if (count > nowmax) {
      nowmax = count;
    }
  }
  cout << nowmax << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  int nowmax = 0;
  cin >> N;
  vector<int> data(N + 1);
  data.at(N) = 1000000001;
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }

  for (int i = 0; i < N; i++) // 落下地点
  {
    int Now = i;
    int count = 0;
    while (data.at(Now) >= data.at(Now + 1)) {
      Now++;
      count++;
    }
    if (count > nowmax) {
      nowmax = count;
    }
    if (nowmax >= N - i)
      break;
  }
  cout << nowmax << endl;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

int main() {
  int n;
  std::cin >> n;
  std::vector<long long> h(n);
  std::priority_queue<long long> q;
  for (int i = 0; i < n; i++) {
    std::cin >> h[i];
  }

  int c = 0;
  for (int i = n - 1; i >= 1; i--) {
    if (h[i] <= h[i - 1]) {
      c++;
      continue;
    }
    q.push(c);
    c = 0;
  }

  std::cout << q.top() << std::endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

int main() {
  int n;
  std::cin >> n;
  std::vector<long long> h(n);
  std::priority_queue<long long> q;
  for (int i = 0; i < n; i++) {
    std::cin >> h[i];
  }

  int c = 0;
  for (int i = n - 1; i >= 1; i--) {
    if (h[i] <= h[i - 1]) {
      c++;
      continue;
    }
    q.push(c);
    c = 0;
  }
  q.push(c);

  std::cout << q.top() << std::endl;
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int N;

int main() {
  cin >> N;
  int C[N];
  for (int i = 0; i < N; i++)
    cin >> C[i];
  int ans = 0, keep;

  for (int i = 0; i < N; i++) {
    keep = 0;
    for (int j = i; j < N - 1; j++) {
      if (C[j] < C[j + 1])
        break;
      keep++;
    }
    ans = max(ans, keep);
  }

  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int N;

int main() {
  cin >> N;
  int C[N];
  for (int i = 0; i < N; i++)
    cin >> C[i];
  int ans = 0, keep;

  for (int i = 0; i < N; i++) {
    if ((C[i - 1] >= C[i]) && i)
      continue;
    keep = 0;
    for (int j = i; j < N - 1; j++) {
      if (C[j] < C[j + 1])
        break;
      keep++;
    }
    ans = max(ans, keep);
  }

  cout << ans << endl;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  // Your code here!
  int n;
  int h[100000];
  int i, j, k;
  int cnt = 0;
  int max = cnt;
  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (i = 0; i < n; i++) {
    if (i == n - 1) {
      break;
    }
    k = i;
    j = i;
    while (h[k] >= h[++j]) {
      k = j;
      if (j == n) {
        break;
      }
    }
    cnt = j - i - 1;
    if (max < cnt) {
      max = cnt;
    }
  }
  cout << max;
}


Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  // Your code here!
  int n;
  int h[100000];
  int i, j, k;
  int cnt = 0;
  int max = cnt;
  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (i = 0; i < n; i++) {
    if (i == n - 1 || max > n / 2) {
      break;
    }
    k = i;
    j = i;
    while (h[k] >= h[++j]) {
      k = j;
      if (j == n) {
        break;
      }
    }
    cnt = j - i - 1;
    if (max < cnt) {
      max = cnt;
    }
  }
  cout << max;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>
using namespace std;

int main(int argc, char **argv) {
  int N;
  vector<int> H;
  int i, max = 0, count;

  cin >> N;
  H.resize(N);
  for (int c = 0; c < N; c++) {
    cin >> H.at(c);
  }

  for (i = 0; i < (H.size() - 2); i++) {
    count = 0;
    while ((i + count + 1) <= (H.size() - 1)) {
      if (H.at(i + count) < H.at(i + count + 1)) {
        break;
      }
      count++;
    }
    if (max < count) {
      max = count;
    }
  }

  cout << max << endl;

  return 0;
}


Fixed submission:
#include <iostream>
#include <vector>
using namespace std;

int main(int argc, char **argv) {
  int N;
  vector<int> H;
  int i, max = 0, count;

  cin >> N;
  H.resize(N);
  for (int c = 0; c < N; c++) {
    cin >> H.at(c);
  }

  for (i = 0; i < (H.size() - 1 - max); i++) {
    count = 0;
    while ((i + count + 1) <= (H.size() - 1)) {
      if (H.at(i + count) < H.at(i + count + 1)) {
        break;
      }
      count++;
    }
    if (max < count) {
      max = count;
    }
  }

  cout << max << endl;

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <cmath>
#include <iostream>
using namespace std;

int main() {
  int n;
  int h[10100];
  int count = 0;
  int max = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  for (int i = 0; i < (n - 1); i++) {
    if (h[i] < h[i + 1]) {
      max = ((max < count) ? count : max);
      count = 0;
    } else {
      count++;
    }
  }

  max = ((max < count) ? count : max);
  cout << max << endl;

  return 0;
}

Fixed submission:
#include <cmath>
#include <iostream>
using namespace std;

int main() {
  int n;
  int h[101000];
  int count = 0;
  int max = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  for (int i = 0; i < (n - 1); i++) {
    if (h[i] < h[i + 1]) {
      max = ((max < count) ? count : max);
      count = 0;
    } else {
      count++;
    }
  }

  max = ((max < count) ? count : max);
  cout << max << endl;

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define lli long long int
#define loop(i, x, n) for (lli i = x; i <= n; i++)
#define rloop(i, n, x) for (lli i = n; i >= x; i--)

typedef vector<ll> v64;
typedef vector<pair<ll, ll>> vp64;
typedef vector<bool> vbo;
typedef set<ll> s64;
typedef set<bool> sbo;
typedef unordered_set<ll> us64;
typedef map<ll, ll> m64;
typedef unordered_map<ll, ll> um64;

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x = 0;
    for (int j = i + 1; j < n; j++) {
      if (a[j] > a[j - 1])
        break;
      x++;
    }
    ans = max(ans, x);
  }
  cout << ans;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define lli long long int
#define loop(i, x, n) for (lli i = x; i <= n; i++)
#define rloop(i, n, x) for (lli i = n; i >= x; i--)

typedef vector<ll> v64;
typedef vector<pair<ll, ll>> vp64;
typedef vector<bool> vbo;
typedef set<ll> s64;
typedef set<bool> sbo;
typedef unordered_set<ll> us64;
typedef map<ll, ll> m64;
typedef unordered_map<ll, ll> um64;

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int ans = 0;
  int check[n];
  check[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    if (a[i] >= a[i + 1])
      check[i] = check[i + 1] + 1;
    else
      check[i] = 0;
    ans = max(ans, check[i]);
  }
  cout << ans;
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
using namespace std;

int main() {
  int long long n, cou = 0;
  cin >> n;
  vector<int> A(n);
  std::priority_queue<int> ans;
  for (int i = 0; i < n; i++) {
    cin >> A.at(i);
  }
  for (int a = 0; a < n; a++) {
    cou = 0;
    for (int b = a; b < n; b++) {
      if (b + 1 == n || A.at(b) < A.at(b + 1)) {
        ans.push(cou);
        if (ans.top() == n - 1) {
          cout << n - 1;
          exit(0);
        }
        break;
      }
      cou++;
    }
  }
  cout << ans.top();
}


Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
using namespace std;

int main() {
  int long long n, cou = 0;
  cin >> n;
  vector<int> A(n);
  std::priority_queue<int> ans;
  for (int i = 0; i < n; i++) {
    cin >> A.at(i);
  }
  for (int a = 0; a < n; a++) {
    cou = 0;
    for (int b = a; b < n; b++) {
      if (b + 1 == n || A.at(b) < A.at(b + 1)) {
        ans.push(cou);
        if (ans.top() == n - 1 || ans.top() >= n - a) {
          cout << ans.top();
          exit(0);
        }
        break;
      }
      cou++;
    }
  }
  cout << ans.top();
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

typedef long long ll;

#define fi first
#define se second

#define all(x) (x).begin(), (x).end()

using namespace std;
// using namespace __gnu_pbds;

typedef vector<int> vi;

// template<typename T> using ordered_set = tree<T, null_type, less<T>,
// rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;

int n, a[55];

void solve() {
  cin >> n;
  int mx = 0, cnt = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  for (int i = 1; i < n; i++) {
    if (a[i] >= a[i + 1]) {
      cnt++;
    } else {
      mx = max(mx, cnt);
      cnt = 0;
    }
  }
  cout << max(mx, cnt);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int tt = 1;

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

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

typedef long long ll;

#define fi first
#define se second

#define all(x) (x).begin(), (x).end()

using namespace std;
// using namespace __gnu_pbds;

typedef vector<int> vi;

// template<typename T> using ordered_set = tree<T, null_type, less<T>,
// rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;

ll n, a[100500];

void solve() {
  cin >> n;
  int mx = 0, cnt = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  for (int i = 1; i < n; i++) {
    if (a[i] >= a[i + 1]) {
      cnt++;
    } else {
      mx = max(mx, cnt);
      cnt = 0;
    }
  }
  cout << max(mx, cnt);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int tt = 1;

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

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rep2(i, m, n) for (int(i) = (m); (i) < (n); (i)++)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<int> r(n);
  r[n - 1] = 0;
  for (int i = n - 2; i != 0; i--) {
    if (h[i] >= h[i + 1])
      r[i] = r[i + 1] + 1;
    else
      r[i] = 0;
  }
  int M = 0;
  rep(i, n) M = max(M, r[i]);
  cout << M << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rep2(i, m, n) for (int(i) = (m); (i) < (n); (i)++)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<int> r(n);
  r[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    if (h[i] >= h[i + 1])
      r[i] = r[i + 1] + 1;
    else
      r[i] = 0;
  }
  int M = 0;
  rep(i, n) M = max(M, r[i]);
  cout << M << endl;
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

int main() {
  int n;
  cin >> n;

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

  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < n; i++) {
    int c = 0;
    for (int j = 1; j < n - i; j++) {
      if (a.at(i + j - 1) >= a.at(i + j)) {
        c++;
      } else {
        break;
      }
    }

    b.at(i) = c;
  }

  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());

  cout << b.at(0) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

int main() {
  int n;
  cin >> n;

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

  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < n; i++) {
    int c = 0;
    for (int j = 1; j < n - i; j++) {
      if (a.at(i + j - 1) >= a.at(i + j)) {
        c++;
      } else {
        break;
      }
    }

    b.at(i) = c;
    if (c > n / 2) {
      break;
    }
  }

  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());

  cout << b.at(0) << endl;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int N;
  int H[10000];
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }

  int max_step = 0;
  int step = 0;
  for (int i = 0; i < N - 1; ++i) {
    if (H[i] >= H[i + 1]) {
      step += 1;
    } else {
      max_step = max(step, max_step);
      step = 0;
    }
  }
  cout << max(max_step, step) << endl;

  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int N;
  int H[100000];
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }

  int max_step = 0;
  int step = 0;
  for (int i = 0; i < N - 1; ++i) {
    if (H[i] >= H[i + 1]) {
      step += 1;
    } else {
      max_step = max(step, max_step);
      step = 0;
    }
  }
  cout << max(max_step, step) << endl;

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  vector<int> nvec(N);

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  for (int i = 0; i < N; i++) {
    for (int j = i; j < N - 1; j++) {
      if (vec.at(j) >= vec.at(j + 1)) {
        nvec.at(i)++;
      }
      //   cout << nvec.at(i) << i << endl;}
      else {
        break;
      }
    }
  }

  sort(nvec.begin(), nvec.end());

  cout << nvec.at(N - 1) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  vector<int> nvec(N);

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  for (int i = 0; i < N; i++) {
    for (int j = i; j < N - 1; j++) {
      if (vec.at(j) >= vec.at(j + 1)) {
        nvec.at(i)++;
      }
      //   cout << nvec.at(i) << i << endl;}
      else {
        break;
      }
    }
    if (nvec.at(i) + 1 >= N - nvec.at(i) - 1) {
      break;
    }
  }

  sort(nvec.begin(), nvec.end());

  cout << nvec.at(N - 1) << endl;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;

  vector<int> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];

  int left, right;
  left = right = 0;
  priority_queue<int> que;

  while (right < n - 1) {
    if (h[right] >= h[right + 1]) {
      right++;
      if (right == n - 1)
        que.push(right - left);
    } else {
      que.push(right - left);
      right++;
      left = right;
    }
  }

  cout << que.top() << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;

  vector<int> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];

  int left, right;
  left = right = 0;
  priority_queue<int> que;
  que.push(0);

  while (right < n - 1) {
    if (h[right] >= h[right + 1]) {
      right++;
      if (right == n - 1)
        que.push(right - left);
    } else {
      que.push(right - left);
      right++;
      left = right;
    }
  }

  cout << que.top() << endl;

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {

  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int cur = arr[i];
    int tmp = 0;
    for (int j = i + 1; j < n; j++) {
      if (arr[j] > cur) {
        break;
      }
      tmp++;
      cur = arr[j];
    }

    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {

  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int rem = n - (i + 1);
    if (rem < ans) {
      break;
    }
    int cur = arr[i];
    int tmp = 0;
    for (int j = i + 1; j < n; j++) {
      if (arr[j] > cur) {
        break;
      }
      tmp++;
      cur = arr[j];
    }

    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n, max = 0;
  cin >> n;
  vector<int> h;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    h.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    int count = 0;
    for (int j = i; j < n - 1; j++) {
      if (h.at(j) >= h.at(j + 1)) {
        count++;
      } else {
        break;
      }
    }
    if (count > max) {
      max = count;
    }
  }
  cout << max;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n, max = 0;
  cin >> n;
  vector<int> h;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    h.push_back(x);
  }
  int count = 0;
  for (int i = 0; i < n - 1; i++) {
    if (h.at(i) >= h.at(i + 1)) {
      count++;
    } else {
      count = 0;
    }
    if (count > max) {
      max = count;
    }
  }
  cout << max;

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  vector<ll> H(N);
  vector<ll> can_move(N - 1);
  cin >> H[0];
  for (int i = 1; i < N; i++) {
    cin >> H[i];
    if (H[i - 1] >= H[i]) {
      can_move[i - 1] = 1;
    } else {
      can_move[i - 1] = 0;
    }
  }

  int cnt = 0;
  int i = 0;
  int ans = 0;
  while (true) {

    if (can_move[i] == 1) {
      cnt += 1;
      ans = max(ans, cnt);
    } else {
      cnt = 0;
    }

    i += 1;
    if (i == N - 1)
      break;
  }

  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;

  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }

  vector<ll> H(N);
  vector<ll> can_move(N - 1);
  cin >> H[0];
  for (int i = 1; i < N; i++) {
    cin >> H[i];
    if (H[i - 1] >= H[i]) {
      can_move[i - 1] = 1;
    } else {
      can_move[i - 1] = 0;
    }
  }

  int cnt = 0;
  int i = 0;
  int ans = 0;
  while (true) {

    if (can_move[i] == 1) {
      cnt += 1;
      ans = max(ans, cnt);
    } else {
      cnt = 0;
    }

    i += 1;
    if (i == N - 1)
      break;
  }

  cout << ans << endl;

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

// const int dy[] = { 0, 0, 1, -1 };
// const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> h;
map<ll, ll> m;

int main() {
  ll n;
  ll ans = 0;
  ll tmp = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    h.push_back(tmp);
  }

  for (int i = 0; i < n; i++) {
    tmp = 0;
    for (int j = i; j < n - 1; j++) {
      if (h[j] >= h[j + 1]) {
        tmp++;
      } else {
        break;
      }
    }
    if (tmp > ans) {
      ans = tmp;
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

// const int dy[] = { 0, 0, 1, -1 };
// const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> h;
map<ll, ll> m;

int main() {
  ll n;
  ll ans = 0;
  ll tmp = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    h.push_back(tmp);
  }

  for (int i = 0; i < n; i++) {
    tmp = 0;
    if ((n - i) <= ans) {
      break;
    }
    for (int j = i; j < n - 1; j++) {
      if (h[j] >= h[j + 1]) {
        tmp++;
      } else {
        break;
      }
    }
    if (tmp > ans) {
      ans = tmp;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  // your code goes here
  int n, i, max = 0, memo = 0;
  long long h[10005];
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> h[i];
    if (i > 1) {
      if (h[i - 1] >= h[i])
        memo++;
      else
        memo = 0;
      if (memo > max)
        max = memo;
    }
  }
  cout << max << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  // your code goes here
  int n, i, max = 0, memo = 0;
  long long h[100005];
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> h[i];
    if (i > 1) {
      if (h[i - 1] >= h[i])
        memo++;
      else
        memo = 0;
      if (memo > max)
        max = memo;
    }
  }
  cout << max << endl;
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int count;
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    count = 0;
    for (int h = i; h < n - 1; h++) {
      if (a.at(h + 1) <= a.at(h))
        count += 1;
      else
        break;
    }

    ans = max(count, ans);
  }

  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  long int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int count;
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    count = 0;
    for (int h = i; h < n - 1; h++) {
      if (a.at(h + 1) <= a.at(h))
        count += 1;
      else
        break;
    }

    ans = max(count, ans);
    if (ans > n - i)
      break;
  }

  cout << ans << endl;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int N;

int max_move(vector<int> &H, int i) {
  int a = 0;
  int j = i;
  while (j <= N - 1) {
    if (H[j] >= H[j + 1]) {
      j++;
      a++;
    } else {
      break;
    }
  }
  return a;
}

int main() {
  cin >> N;
  vector<int> H(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> H[i];
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans = max(ans, max_move(H, i));
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int N;

int max_move(vector<int> &H, int i) {
  int a = 0;
  int j = i;
  while (j <= N - 1) {
    if (H[j] >= H[j + 1]) {
      j++;
      a++;
    } else {
      break;
    }
  }
  return a;
}

int main() {
  cin >> N;
  vector<int> H(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> H[i];
  }

  int ans = 0;
  int i = 1;
  while (i <= N) {
    int mov = max_move(H, i);
    ans = max(ans, mov);
    i = i + mov + 1;
  }
  cout << ans << endl;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  int t;
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    t = 0;
    for (int j = i; j < n - 1; j++) {
      if (a.at(j) >= a.at(j + 1))
        t++;
      else
        break;
    }
    b.at(i) = t;
  }
  int M = *max_element(b.begin(), b.end());
  cout << M << endl;
}

Fixed submission:
#include <algorithm>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  int t;
  vector<int> b(n);
  for (int i = 0; i < n; i += t + 1) {
    t = 0;
    for (int j = i; j < n - 1; j++) {
      if (a.at(j) >= a.at(j + 1))
        t++;
      else
        break;
    }
    b.at(i) = t;
  }
  int M = *max_element(b.begin(), b.end());
  cout << M << endl;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
#define ll long long
#define rep(i, end) for (ll i = 0; i < (ll)(end); i++)

int main() {
  ll n, count = 0, maxi = 0, last;
  cin >> n;
  ll h[10001];
  rep(i, n) { cin >> h[i]; }
  rep(i, n) {
    if (i != 0) {
      if (h[i] <= last)
        count++;
      else {
        maxi = max(maxi, count);
        count = 0;
      }
    }
    last = h[i];
  }
  maxi = max(maxi, count);
  cout << maxi << endl;

  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
#define ll long long
#define rep(i, end) for (ll i = 0; i < (ll)(end); i++)

int main() {
  ll n, count = 0, maxi = 0, last;
  cin >> n;
  ll h[100001] = {};
  rep(i, n) { cin >> h[i]; }
  rep(i, n) {
    if (i != 0) {
      if (h[i] <= last)
        count++;
      else {
        maxi = max(maxi, count);
        count = 0;
      }
    }
    last = h[i];
  }
  maxi = max(maxi, count);
  cout << maxi << endl;

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n); i >= 0; i--)

using namespace std;

int main() {

  int N;
  veci H;
  int cnt = 0;

  cin >> N;
  rep(i, N) {
    int x;
    cin >> x;
    H.push_back(x);
  }

  rep(i, N) {
    int amax = 0;
    for (int j = i; j < N - 1; j++) {
      if (H[j] >= H[j + 1]) {
        amax++;
        continue;
      } else
        break;
    }
    cnt = max(cnt, amax);
  }

  cout << cnt << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n); i >= 0; i--)

using namespace std;

int main() {

  int N;
  veci H;
  int cnt = 0;

  cin >> N;
  rep(i, N) {
    int x;
    cin >> x;
    H.push_back(x);
  }

  rep(i, N) {
    int amax = 0;
    if (cnt > N - i)
      break;
    for (int j = i; j < N - 1; j++) {
      if (H[j] >= H[j + 1]) {
        amax++;
        continue;
      } else
        break;
    }
    cnt = max(cnt, amax);
  }

  cout << cnt << endl;
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  int maxi = 0;
  for (int i = 0; i < N - 1; i++) {
    int count = 0;
    int checking = i;
    bool canLoop = true;
    while (canLoop) {
      if (H.at(checking) >= H.at((checking) + 1)) {
        count++;
        checking++;
        if (checking == N - 1) {
          canLoop = false;
        }
      } else {
        canLoop = false;
      }
      maxi = max(maxi, count);
    }
  }
  cout << maxi << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  int maxi = 0;
  for (int i = 0; i < N - 1; i++) {
    int count = 0;
    int checking = i;
    bool canLoop = true;
    while (canLoop) {
      if (H.at(checking) >= H.at((checking) + 1)) {
        count++;
        checking++;
        if (checking == N - 1) {
          canLoop = false;
        }
      } else {
        canLoop = false;
      }
      maxi = max(maxi, count);
    }
    if (maxi >= (N - i)) {
      break;
    }
  }
  cout << maxi << endl;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h[100010];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int now = INT_MAX, maxx = 0, thisone = 0;
  for (int j = 0; j < n - 1; j++) {
    thisone = 0;
    int under = j;
    while (h[under] >= h[under + 1] && under < n - 1) {
      thisone++;
      under++;
    }
    maxx = max(thisone, maxx);
  }
  cout << maxx;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h[100010];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int now = INT_MAX, maxx = 0, thisone = 0;
  for (int j = 0; j < n - 1; j++) {
    thisone = 0;
    int under = j;
    while (h[under] >= h[under + 1] && under < n - 1) {
      thisone++;
      under++;
    }
    j = under;
    maxx = max(thisone, maxx);
  }
  cout << maxx;
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int n, h[100005], x, o;

int main() {

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  for (int i = 0; i < n; i++) {
    x = 0;
    if ((i + 1) != n) {
      for (int j = i + 1; j < n; j++) {
        int b = j - 1;
        if (h[b] >= h[j]) {
          x++;
        } else {
          break;
        }
      }
    }
    if (x > o) {
      o = x;
    }
  }

  cout << o;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int n, h[100005], x, o;

int main() {

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  for (int i = 0; i < n; i++) {
    x = 0;
    if ((i + 1) != n && (n - (i + 1) > o)) {
      for (int j = i + 1; j < n; j++) {
        int b = j - 1;
        if (h[b] >= h[j]) {
          x++;
        } else {
          break;
        }
      }
    }
    if (x > o) {
      o = x;
    }
  }

  cout << o;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i)
    cin >> a[i];
  int res = 0;
  for (int i = 0; i < N;) {
    int j = i + 1;
    while (j < N && a[j] <= a[j - 1])
      ++j;
    res = max(res, j - i - 1);
  }
  cout << res << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i)
    cin >> a[i];
  int res = 0;
  for (int i = 0; i < N;) {
    int j = i + 1;
    while (j < N && a[j] <= a[j - 1])
      ++j;
    res = max(res, j - i - 1);
    i = j;
  }
  cout << res << endl;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long;
#define _CRT_SECURE_NO_WARNINGS
const double pai = acos(-1.0);
const int max1 = 5e5 + 5;
int a[max1], maxlen[max1];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int i, k, sum = 1, n, j, sum1 = 1;
  cin >> n;
  for (i = 1; i <= n; i++)
    cin >> a[i];
  for (i = 1; i <= n; i++) {
    sum = 1;
    for (j = i; j < n; j++)
      if (a[j] >= a[j + 1])
        sum++;
      else
        break;
    sum1 = max(sum, sum1);
  }
  cout << sum1 - 1 << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long;
#define _CRT_SECURE_NO_WARNINGS
const double pai = acos(-1.0);
const int max1 = 5e5 + 5;
int a[max1], maxlen[max1];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int i, k, sum = 1, n, j, sum1 = 1;
  cin >> n;
  for (i = 1; i <= n; i++)
    cin >> a[i];
  sum = 1;
  for (i = 1; i < n; i++) {
    if (a[i] >= a[i + 1])
      sum++;
    else
      sum = 1;
    sum1 = max(sum, sum1);
  }
  cout << sum1 - 1 << endl;
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <functional>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {

  int N;
  cin >> N;
  vector<int> H(N);
  rep(i, N) cin >> H.at(i);
  vector<int> score;
  int cnt = 0;

  while (1) {
    int num = 0;
    for (int j = cnt; j < N - 1; j++) {
      if (H.at(j) >= H.at(j + 1)) {
        cnt++;
        num++;
        if ((j + 1) >= (N - 1)) {
          score.push_back(num);
        }
      } else if (H.at(j) < H.at(j + 1)) {
        cnt++;
        score.push_back(num);
        break;
      }
    }
    if (cnt == (N - 1))
      break;
  }
  sort(score.begin(), score.end());
  reverse(score.begin(), score.end());

  cout << score.front() << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <functional>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {

  int N;
  cin >> N;
  vector<int> H(N);
  rep(i, N) cin >> H.at(i);
  vector<int> score(1, 0);
  int cnt = 0;

  while (1) {
    int num = 0;
    for (int j = cnt; j < N - 1; j++) {
      if (H.at(j) >= H.at(j + 1)) {
        cnt++;
        num++;
        if ((j + 1) >= (N - 1)) {
          score.push_back(num);
        }
      } else if (H.at(j) < H.at(j + 1)) {
        cnt++;
        score.push_back(num);
        break;
      }
    }
    if (cnt == (N - 1))
      break;
  }
  sort(score.begin(), score.end());
  reverse(score.begin(), score.end());

  cout << score.front() << endl;

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  int count = 0;
  int c = 0;
  for (int i = 0; i < N; i++) {
    if (data.at(i) >= data.at(i + 1)) {
      count++;
      c = max(count, c);
    } else if (data.at(i) < data.at(i + 1)) {
      count = 0;
    }
  }
  cout << c << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  vector<int> data(N + 10, 1e10);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  int count = 0;
  int c = 0;
  for (int i = 0; i < N; i++) {
    if (data.at(i) >= data.at(i + 1)) {
      count++;
      c = max(count, c);
    } else if (data.at(i) < data.at(i + 1)) {
      count = 0;
    }
  }
  cout << c << endl;
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
using namespace std;
int n;
int h[100010];
vector<int> result(100010, 0);

int move(int x) {
  if (h[x + 1] > h[x] || x == n - 1) {
    return 0;
  }

  return move(x + 1) + 1;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < n; i++) {
    // cout << move(i) << endl;
    result.at(i) = move(i);
  }
  sort(result.begin(), result.end());
  cout << result.at(100009) << endl;
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;
int n;
int h[100010];
vector<int> result(100010, 0);

int move(int x) {
  if (h[x + 1] > h[x] || x == n - 1) {
    return 0;
  }

  return move(x + 1) + 1;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < n; i++) {
    // cout << move(i) << endl;
    if (i != 0) {
      if (h[i - 1] < h[i]) {
        result.at(i) = move(i);
      }
    } else {
      result.at(i) = move(i);
    }
  }
  sort(result.begin(), result.end());
  cout << result.at(100009) << endl;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;

  vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }

  vector<int> A(N - 1, 0);
  vector<int> B(N - 1, 0);

  for (int i = 0; i < N - 1; i++) {
    if (H.at(i) >= H.at(i + 1)) {
      A.at(i) = 1;
    }
  }

  int count = 0;
  for (int i = 0; i < N - 1; i++) {
    if (A.at(i) == 1 && i != N - 2) {
      count++;
    } else if (A.at(i) == 1 && i == N - 2) {
      count++;
      B.at(i) = count;
    } else {
      B.at(i) = count;
      count = 0;
    }
  }

  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  cout << B.at(0) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;

  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }

  vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }

  vector<int> A(N - 1, 0);
  vector<int> B(N - 1, 0);

  for (int i = 0; i < N - 1; i++) {
    if (H.at(i) >= H.at(i + 1)) {
      A.at(i) = 1;
    }
  }

  int count = 0;
  for (int i = 0; i < N - 1; i++) {
    if (A.at(i) == 1 && i != N - 2) {
      count++;
    } else if (A.at(i) == 1 && i == N - 2) {
      count++;
      B.at(i) = count;
    } else {
      B.at(i) = count;
      count = 0;
    }
  }

  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  cout << B.at(0) << endl;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main(void) {
  long long int n, i = 0, j, cnt = 0, max = 0;
  cin >> n;
  vector<int> h(n);
  for (i = 0; i < n; i++) {
    cin >> h[i];
  }

  for (i = 0; i < n - 1; i++) {
    cnt = 0;
    for (j = i; j < n - 1; j++) {
      if (h[j] >= h[j + 1]) {
        cnt++;
      } else {
        break;
      }
    }
    if (max < cnt)
      max = cnt;
  }
  cout << max;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main(void) {
  long long int n, i = 0, j, cnt = 0, max = 0;
  cin >> n;
  vector<int> h(n);
  for (i = 0; i < n; i++) {
    cin >> h[i];
  }

  for (i = 0; i < n - 1; i++) {
    cnt = 0;
    for (j = i; j < n - 1; j++) {
      if (h[j] >= h[j + 1]) {
        cnt++;
      } else {
        break;
      }
    }
    if (max < cnt)
      max = cnt;
    if (max > n - i)
      break;
  }
  cout << max;
}