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

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <math.h>
// #include <numeric>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;
#define n_max 100000

#define rep(i, a, n) for (int i = a; i < n; i++)
#define rep2(i, a, n) for (int i = a; i <= n; i++)
#define rrep(i, a, n) for (int i = a; i > n; i--)
#define rrep2(i, a, n) for (int i = a; i >= n; i--)
#define lrep(i, a, n) for (long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

int main() {
  int ans = 0;
  int N;

  cin >> N;
  int H[N];

  rep(i, 0, N) { cin >> H[i]; }

  rep(i, 0, N - 1) {
    int tmp = 0;
    // cout << i << endl;
    rep(j, 0, N - i - 1) {
      if (H[i + j] < H[i + j + 1]) {
        break;
      } else {
        tmp++;
      }
    }
    ans = max(tmp, ans);
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <iostream>
#include <math.h>
// #include <numeric>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;
#define n_max 100000

#define rep(i, a, n) for (int i = a; i < n; i++)
#define rep2(i, a, n) for (int i = a; i <= n; i++)
#define rrep(i, a, n) for (int i = a; i > n; i--)
#define rrep2(i, a, n) for (int i = a; i >= n; i--)
#define lrep(i, a, n) for (long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

int main() {
  int ans = 0;
  int N;

  cin >> N;
  int H[N];

  rep(i, 0, N) { cin >> H[i]; }

  rep(i, 0, N - 1) {

    if (ans > (N - (i + 1) - 1))
      break;
    int tmp = 0;
    // cout << i << endl;
    rep(j, 0, N - i - 1) {
      if (H[i + j] < H[i + j + 1]) {
        break;
      } else {
        tmp++;
      }
    }
    ans = max(tmp, ans);
  }

  cout << ans << endl;

  return 0;
}
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);
  }
  int i = 0;
  int c = 0;
  int M = 0;
  while (i < N) {
    if (H.at(i - 1) >= H.at(i)) {
      c++;
      if (i == N - 1) {
        M = max(M, c);
      }
    } else {
      M = max(M, c);
      c = 0;
    }
    i++;
  }
  cout << M << 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 i = 1;
  int c = 0;
  int M = 0;
  while (i < N) {
    if (H.at(i - 1) >= H.at(i)) {
      c++;
      if (i == N - 1) {
        M = max(M, c);
      }
    } else {
      M = max(M, c);
      c = 0;
    }
    i++;
  }
  cout << M << endl;
}
Problem p02923 (C++)

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

using namespace std;
int main() {
  int n;
  cin >> n;

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

  int ans(0);
  for (int i(0); i < n - 1; i++) {
    int j(0);
    while (h[i + j] >= h[i + j + 1]) {
      // printf("%d, h[%d] >= h[%d]\n",j,i+j,i+j+1);
      j++;
      if (i + j + 1 > n - 1)
        break;
    }
    if (j > ans)
      ans = j;
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;
int main() {
  int n;
  cin >> n;

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

  int ans(0);
  for (int i(0); i < n - ans - 1; i++) {
    int j(0);
    while (h[i + j] >= h[i + j + 1]) {
      // printf("%d, h[%d] >= h[%d]\n",j,i+j,i+j+1);
      j++;
      if (i + j + 1 > n - 1)
        break;
    }
    if (j > ans)
      ans = j;
  }

  cout << ans << endl;

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main(void) {
  int n, h[1000], i, max = 0, cnt = 0;
  cin >> n;
  for (i = 0; i < n; i++)
    cin >> h[i];
  for (i = n - 2; i >= 0; i--) {
    if (h[i] >= h[i + 1])
      cnt++;
    else
      cnt = 0;
    if (max < cnt)
      max = cnt;
  }
  cout << max << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  int n, h[100000], i, max = 0, cnt = 0;
  cin >> n;
  for (i = 0; i < n; i++)
    cin >> h[i];
  for (i = n - 2; i >= 0; i--) {
    if (h[i] >= h[i + 1])
      cnt++;
    else
      cnt = 0;
    if (max < cnt)
      max = cnt;
  }
  cout << max << endl;
  return 0;
}
Problem p02923 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))

ans = []
count = 0
for i in range(N):
    for j in range(i + count, N):
        if j == N - 1:
            ans.append(count)
            count = 0
            break
        if H[j] < H[j + 1]:
            ans.append(count)
            count = 0
            break
        else:
            count += 1

print(max(ans))


Fixed submission:
N = int(input())
H = list(map(int, input().split()))

ans = []
count = 0
for j in range(N):
    if j == N - 1:
        ans.append(count)
        count = 0
        break
    if H[j] < H[j + 1]:
        ans.append(count)
        count = 0
        continue
    elif H[j] >= H[j + 1]:
        count += 1

print(max(ans))
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);
  }

  int ans = 0;
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (h.at(i) >= h.at(i + 1)) {
      count++;
    } else {
      ans = max(ans, count);
      count = 0;
    }
  }
  ans = max(ans, count);
  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);
  }

  int ans = 0;
  int count = 0;
  for (int i = 0; i < n - 1; i++) {
    if (h.at(i) >= h.at(i + 1)) {
      count++;
    } else {
      ans = max(ans, count);
      count = 0;
    }
  }
  ans = max(ans, count);
  cout << ans << endl;
}
Problem p02923 (C++)

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

using namespace std;

int a[10010];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int ans = 0;
  int record = a[0];
  int temp_ans = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] <= record) {
      temp_ans += 1;
      record = a[i];
    } else {
      ans = max(temp_ans, ans);
      temp_ans = 0;
      record = a[i];
    }
  }
  ans = max(temp_ans, ans);

  cout << ans << endl;
  return 0;
}


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

using namespace std;

int a[100010];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int ans = 0;
  int record = a[0];
  int temp_ans = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] <= record) {
      temp_ans += 1;
      record = a[i];
    } else {
      ans = max(temp_ans, ans);
      temp_ans = 0;
      record = a[i];
    }
  }
  ans = max(temp_ans, ans);

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

Buggy submission (status: Runtime Error):

#include <bits/stdc++.h>

using namespace std;

int main() {
  long long int i, k = 0;

  long long int n, a[5000], b[5000];

  cin >> n;

  for (i = 0; i < n; i++) {

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

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

    } else {
      b[k] = count1;
      k++;
      count1 = 0;
    }
  }
  b[k] = count1;
  k++;
  long long int max1 = -1;
  for (i = 0; i < k; i++) {
    if (b[i] > max1) {

      max1 = b[i];
    }
  }
  cout << max1;
}


Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  long long int i, k = 0;

  long long int n, a[500000], b[500000];

  cin >> n;

  for (i = 0; i < n; i++) {

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

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

    } else {
      b[k] = count1;
      k++;
      count1 = 0;
    }
  }
  b[k] = count1;
  k++;
  long long int max1 = -1;
  for (i = 0; i < k; i++) {
    if (b[i] > max1) {

      max1 = b[i];
    }
  }
  cout << max1;
}
Problem p02923 (Python)

Buggy submission (status: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力


def main():
    n = int(input())
    h = list(map(int, input().split()))

    result = []
    count = 0
    for i in range(n - 1):
        if h[i] < h[i + 1]:
            result.append(count)
            count = 0
            continue

        count += 1
        if i == n - 2:
            result.append(count)

    print(max(result))


if __name__ == "__main__":
    main()


Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力


def main():
    n = int(input())
    h = list(map(int, input().split()))

    if n == 1:
        print(0)
        return

    result = []
    count = 0
    for i in range(n - 1):
        if h[i] < h[i + 1]:
            result.append(count)
            count = 0
            continue

        count += 1
        if i == n - 2:
            result.append(count)

    print(max(result))


if __name__ == "__main__":
    main()
Problem p02923 (Python)

Buggy submission (status: Runtime Error):
# coding: utf-8
n = int(input())
lst = list(map(int, input().split()))
cnt = 0
data = []
for i in range(n - 1):
    if lst[i] >= lst[i + 1]:
        cnt += 1
    else:
        data.append(cnt)
        cnt = 0
print(max(cnt))


Fixed submission:
# coding: utf-8
n = int(input())
lst = list(map(int, input().split()))
cnt = 0
data = []
for i in range(n - 1):
    if lst[i] >= lst[i + 1]:
        cnt += 1
    else:
        data.append(cnt)
        cnt = 0
data.append(cnt)
print(max(data))
Problem p02923 (Python)

Buggy submission (status: Runtime Error):
n = input()
h_string = input()
h_list = h_string.split(" ")
for item in h_list:
    item = int(item)


longest = 0
now_value = -1
now_length = 0


for value in h_list:
    if value <= now_value:
        now_length += 1
        now_value = value
        if now_length > longest:
            longest = now_length
    else:
        if now_length > longest:
            longest = now_length
        now_value = value
        now_length = 0

print(longest)


Fixed submission:
n = input()
h_string = input()
h_list = h_string.split(" ")
for i in range(len(h_list)):
    h_list[i] = int(h_list[i])


longest = 0
now_value = -1
now_length = 0


for value in h_list:
    if value <= now_value:
        now_length += 1
        now_value = value
        if now_length > longest:
            longest = now_length
    else:
        if now_length > longest:
            longest = now_length
        now_value = value
        now_length = 0

print(longest)
Problem p02923 (Python)

Buggy submission (status: Runtime Error):
from sys import stdin

n = int(stdin.readline().rstrip())
h = [int(x) for x in stdin.readline().rstrip().split()]

m = 0
count = 0
for i in range(n):
    if (i == n - 1) and (m < count):
        m = count
    else:
        if h[i] >= h[i + 1]:
            count += 1
        else:
            if m < count:
                m = count
            count = 0

print(m)


Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
h = [int(x) for x in stdin.readline().rstrip().split()]

m = 0
count = 0
for i in range(n):
    if i == n - 1:
        if m < count:
            m = count
    else:
        if h[i] >= h[i + 1]:
            count += 1
        else:
            if m < count:
                m = count
            count = 0

print(m)
Problem p02923 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
H = [int, input().split(" ")]

counter = -1
last_h = float("inf")
_max = 0
for h in H:
    if h <= last_h:
        counter += 1
    else:
        if _max < counter:
            _max = counter
        counter = 0
    last_h = h
if _max < counter:
    _max = counter
print(_max)


Fixed submission:
N = int(input())
H = map(int, input().split())

counter = -1
last_h = float("inf")
_max = 0
for h in H:
    if h <= last_h:
        counter += 1
    else:
        if _max < counter:
            _max = counter
        counter = 0
    last_h = h
if _max < counter:
    _max = counter
print(_max)
Problem p02923 (C++)

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

using namespace std;

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

  int max = 0, ct = 0;
  for (size_t i = n - 1; i >= 0; i--) {
    if (i == n - 1 || h[i] < h[i + 1])
      ct = 0;
    ct++;
    if (max < ct)
      max = ct;
  }
  cout << max - 1 << endl;
}

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

using namespace std;

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

  int max = 0, ct = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1 || h[i] < h[i + 1])
      ct = 0;
    ct++;
    if (max < ct)
      max = ct;
  }
  cout << max - 1 << endl;
}
Problem p02923 (Python)

Buggy submission (status: Runtime Error):
import sys
from itertools import accumulate
from collections import Counter

input = sys.stdin.readline


def main():
    n = int(input())
    H = list(map(int, input().split()))
    print(
        Counter(accumulate([H[i] < H[i + 1] for i in range(n - 1)])).most_common(1)[0][
            1
        ]
        - 1
    )


if __name__ == "__main__":
    main()


Fixed submission:
import sys
from itertools import accumulate
from collections import Counter

input = sys.stdin.readline


def main():
    n = int(input())
    H = list(map(int, input().split()))
    if n == 1:
        print(0)
        return
    # 連続した場合、同値
    acc = list(accumulate([H[i] < H[i + 1] for i in range(n - 1)]))
    x, y = Counter(acc).most_common(1)[0]
    print(y if x == 0 else y - 1)


if __name__ == "__main__":
    main()
Problem p02923 (C++)

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

void solve(long long N, std::vector<float> H) {
  vector<float> dH(N - 1, 0);
  for (int i = 0; i < N - 1; ++i) {
    if (H[i + 1] - H[i] <= 0)
      dH[i] += 1;
  }
  // for(int i = 0; i < N; ++i) cout << dH[i] << endl;
  // cout << endl;
  vector<float> ans(N, 0);
  for (int i = 0; i < N; ++i) {
    if (dH[i] > 0)
      ans[i + 1] = ans[i] + dH[i];
    else
      ans[i + 1] = 0;
  }
  // for(int i = 0; i < N; ++i) cout << ans[i] << endl;
  sort(ans.begin(), ans.end(), greater<float>());
  cout << ans[0] << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<float> H(N);
  for (int i = 0; i < N; i++) {
    scanf("%fd", &H[i]);
  }
  solve(N, std::move(H));
  return 0;
}


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

void solve(long long N, std::vector<float> H) {
  vector<float> dH(N - 1, 0);
  for (int i = 0; i < N - 1; ++i) {
    if (H[i + 1] - H[i] <= 0)
      dH[i] += 1;
  }
  // for(int i = 0; i < N; ++i) cout << dH[i] << endl;
  // cout << endl;
  vector<float> ans(N, 0);
  for (int i = 0; i < N - 1; ++i) {
    if (dH[i] > 0)
      ans[i + 1] = ans[i] + dH[i];
    else
      ans[i + 1] = 0;
  }
  // for(int i = 0; i < N; ++i) cout << ans[i] << endl;
  sort(ans.begin(), ans.end(), greater<float>());
  cout << ans[0] << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<float> H(N);
  for (int i = 0; i < N; i++) {
    scanf("%fd", &H[i]);
  }
  solve(N, std::move(H));
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>

using namespace std;

const int maxn = 10005;

int n, ans, h[maxn], f[maxn];

int main(void) {
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i)
    scanf("%d", &h[i]);
  for (register int i = 2; i <= n; ++i) {
    if (h[i] <= h[i - 1])
      f[i] = f[i - 1] + 1;
    else
      f[i] = 0;
    ans = max(ans, f[i]);
  }
  printf("%d\n", ans);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>

using namespace std;

const int maxn = 100005;

int n, ans, h[maxn], f[maxn];

int main(void) {
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i)
    scanf("%d", &h[i]);
  for (register int i = 2; i <= n; ++i) {
    if (h[i] <= h[i - 1])
      f[i] = f[i - 1] + 1;
    else
      f[i] = 0;
    ans = max(ans, f[i]);
  }
  printf("%d\n", ans);
  return 0;
}
Problem p02923 (C++)

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

class Mass {
public:
  int N;
  long H[100];
};

int main() {

  Mass m;
  cin >> m.N;

  int i;
  int j = 0;
  int k = 0;
  for (i = 0; i < m.N; i++) {
    cin >> m.H[i];
    if (i != 0 && m.H[i] <= m.H[i - 1]) {
      j++;
    } else {
      k = max(k, j);
      j = 0;
    }
  }
  cout << max(k, j);

  return 0;
}

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

class Mass {
public:
  int N;
  long H[100000];
};

int main() {

  Mass m;
  cin >> m.N;

  int i;
  int j = 0;
  int k = 0;
  for (i = 0; i < m.N; i++) {
    cin >> m.H[i];
    if (i != 0 && m.H[i] <= m.H[i - 1]) {
      j++;
    } else {
      k = max(k, j);
      j = 0;
    }
  }
  cout << max(k, j);

  return 0;
}
Problem p02923 (C++)

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int cell[10000] = {0};
  int N, input;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> input;
    cell[i] = input;
  }

  int curr = 0, _max = 0;
  for (int i = 0; i < N - 1; i++) {
    // cout << "i, i+1 => " << cell[i] << " " << cell[i + 1] << endl;
    if (cell[i] >= cell[i + 1]) {
      curr++;
    } else {
      curr = 0;
    }

    // cout << "max, curr => " << _max << " " << curr << endl;

    if (curr > _max) {
      _max = curr;
    }
  }
  cout << _max << endl;
}

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int cell[100000] = {0};
  int N, input;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> input;
    cell[i] = input;
  }

  int curr = 0, _max = 0;
  for (int i = 0; i < N - 1; i++) {
    // cout << "i, i+1 => " << cell[i] << " " << cell[i + 1] << endl;
    if (cell[i] >= cell[i + 1]) {
      curr++;
    } else {
      curr = 0;
    }

    // cout << "max, curr => " << _max << " " << curr << endl;

    if (curr > _max) {
      _max = curr;
    }
  }
  cout << _max << endl;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define IFOR(i, a, b) for (int i = (b - 1); i >= (a); --i)
#define RPT(i, a, b) for (int i = (a); i < ((a) + (b)); ++i)
#define IRPT(i, a, b) for (int i = ((a) + (b)-1); i >= (a); --i)
#define ALL(x) x.begin(), x.end()

void solve() {
  int n;
  cin >> n;
  vector<ll> h(n);
  RPT(i, 0, n) cin >> h[i];
  vector<int> ds;
  int d = 0;
  for (; d < n - 1;) {
    int cnt = 0;
    while (d < n - 1) {
      ++d;
      if (h[d - 1] < h[d])
        break;
      cnt++;
    }
    ds.push_back(cnt);
    cnt = 0;
  }
  cout << *max_element(ALL(ds)) << endl;
}

int main() {
  solve();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define IFOR(i, a, b) for (int i = (b - 1); i >= (a); --i)
#define RPT(i, a, b) for (int i = (a); i < ((a) + (b)); ++i)
#define IRPT(i, a, b) for (int i = ((a) + (b)-1); i >= (a); --i)
#define ALL(x) x.begin(), x.end()

void solve() {
  int n;
  cin >> n;
  vector<ll> h(n);
  RPT(i, 0, n) cin >> h[i];
  vector<int> ds(1, 0);
  int d = 0;
  for (; d < n - 1;) {
    int cnt = 0;
    while (d < n - 1) {
      ++d;
      if (h[d - 1] < h[d])
        break;
      cnt++;
    }
    ds.push_back(cnt);
    cnt = 0;
  }
  cout << *max_element(ALL(ds)) << endl;
}

int main() {
  solve();
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

ll n, h[10000], ans, tmp;
int main(void) {
  ll i;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (i = 0; i < n - 1; i++) {
    if (h[i + 1] <= h[i])
      tmp++;
    else {
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  cout << ans << endl;
  return 0;
}


Fixed submission:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

ll n, h[100000], ans, tmp;
int main(void) {
  ll i;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (i = 0; i < n - 1; i++) {
    if (h[i + 1] <= h[i])
      tmp++;
    else {
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  cout << ans << endl;
  return 0;
}
Problem p02923 (C++)

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

int main(int argc, char *argv[]) {
  int N;
  int count = 0;
  int count_max = 0;
  cin >> N;
  vector<int> v;
  int m;
  for (int i = 0; i < N; i++) {
    cin >> m;
    v.push_back(m);
  }
  for (int i = 0; i < N - 1; i++) {
    count = 0;
    for (int j = i; j < N - 1; j++) {
      if (v[j] < v[j + 1])
        break;
      else {
        count++;
        //	continue;
      }
    }
    if (count > count_max)
      count_max = count;
  }
  cout << count_max << endl;
}


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

int main(int argc, char *argv[]) {
  int N;
  int count = 0;
  int count_max = 0;
  cin >> N;
  vector<int> v;
  int m;
  for (int i = 0; i < N; i++) {
    cin >> m;
    v.push_back(m);
  }
  for (int i = 0; i < N - 1; i++) {
    count = 0;
    if (N - i < count_max)
      break;
    for (int j = i; j < N - 1; j++) {
      if (v[j] < v[j + 1])
        break;
      else {
        count++;
        //	continue;
      }
    }
    if (count > count_max)
      count_max = count;
  }
  cout << count_max << endl;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <math.h>
#include <numeric>
#include <stdlib.h>
using namespace std;
int main() {
  int N, i, max = 0, j = 0;
  cin >> N;
  int H[N];
  for (i = 0; i < N; i++) {
    cin >> H[i];
  }
  for (i = 0; i < N - 1; i++) {
    for (j = 0; H[i + j] >= H[i + j + 1] && i + j + 1 < N;) {
      j++;
    }

    if (max < j) {
      max = j;
    }
  }
  cout << max << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#include <math.h>
#include <numeric>
#include <stdlib.h>
using namespace std;
int main() {
  int N, i, max = 0, j = 0;
  cin >> N;
  int H[N];
  for (i = 0; i < N; i++) {
    cin >> H[i];
  }
  for (i = 0; i < N - 1; i++) {
    for (j = 0; H[i + j] >= H[i + j + 1] && i + j + 1 < N;) {
      j++;
    }

    if (max < j) {
      max = j;
      i = i + max;
    }
  }
  cout << max << endl;
}
Problem p02923 (C++)

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

using namespace std;
int main() {
  int N, *H, max = 0, c = 0, co = 0, s = 0;

  cin >> N;

  H = (int *)malloc(sizeof(int) * N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  while (c < N) {
    co = c;
    s = 0;
    while (H[co] >= H[co + 1] && co < N - 1) {
      s++;
      co++;
    }
    if (max < s) {
      max = s;
    }
    c++;
  }
  cout << max;
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;
int main() {
  int N, *H, max = 0, c = 0, co = 0, s = 0;

  cin >> N;

  H = (int *)malloc(sizeof(int) * N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  while (c < N) {
    co = c;
    s = 0;
    while (H[co] >= H[co + 1] && co < N - 1) {
      s++;
      co++;
    }
    if (max < s) {
      max = s;
    }
    if (max >= N - c)
      break;
    c++;
  }
  cout << max;
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
/*
 * Project: AtCoder Beginners Contest 139 C - Lower
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/26
 * Copyright (c) 2020 toms74209200
 *
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdint>
#include <cstdio>
#include <vector>
using namespace std;

uint32_t n;
vector<uint64_t> h;

void solve() {

  uint32_t max_cnt = 0;
  for (auto i = h.begin(); i < h.end(); i++) {
    uint32_t cnt = 0;
    auto iter = i;
    while (*iter >= *next(iter) && iter < h.end() - 1) {
      cnt++;
      iter++;
    }
    max_cnt = max(max_cnt, cnt);
  }

  printf("%d\n", max_cnt);
}

int main() {

  scanf("%d", &n);
  h.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &h[i]);
  }

  solve();
}

Fixed submission:
/*
 * Project: AtCoder Beginners Contest 139 C - Lower
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/26
 * Copyright (c) 2020 toms74209200
 *
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdint>
#include <cstdio>
#include <vector>
using namespace std;

uint32_t n;
vector<uint64_t> h;

void solve() {

  uint32_t max_cnt = 0;
  for (auto i = h.begin(); i < h.end(); i++) {
    uint32_t cnt = 0;
    auto iter = i;
    while (*iter >= *next(iter) && iter < h.end() - 1) {
      cnt++;
      iter++;
    }
    max_cnt = max(max_cnt, cnt);
    if (iter == h.end() - 1) {
      break;
    }
  }

  printf("%d\n", max_cnt);
}

int main() {

  scanf("%d", &n);
  h.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &h[i]);
  }

  solve();
}
Problem p02923 (C++)

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

  int s;
  cin >> s;
  int array[s], score, max = 0, i, j;
  for (i = 0; i < s; i++) {
    cin >> array[i];
  }
  for (i = 0; i < s - 1; i++) {
    j = i;
    // cout<<j<<endl;
    while (array[j] >= array[j + 1] && j < s - 1) {
      score++;
      // cout<<j;
      j++;
    }
    // cout<<endl;
    // cout<<score<<endl;
    if (score > max)
      max = score;
    score = 0;
  }

  cout << max;
}

Fixed submission:
#include <iostream>
using namespace ::std;
int main() {

  int s;
  cin >> s;
  int array[s], score, max = 0, i, j;
  for (i = 0; i < s; i++) {
    cin >> array[i];
  }
  for (i = 0; i < s - 1; i++) {
    j = i;
    // cout<<j<<endl;
    while (array[j] >= array[j + 1] && j < s - 1) {
      score++;
      // cout<<j;
      j++;
    }
    // cout<<endl;
    // cout<<score<<endl;
    if (score > max)
      max = score;
    if (max >= s - j)
      break;
    score = 0;
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int N;
  int H[100000];
  int ans = 0, count = 0;

  scanf("%d", &N);

  for (int i = 0; i < N; i++)
    scanf("%d", &H[i]);

  for (int i = 0; i < N; i++) {
    count = 0;
    for (int j = i; j < N - 1; j++) {
      if (H[j] < H[j + 1])
        break;
      count++;
    }
    if (count > ans)
      ans = count;
  }

  printf("%d", ans);
}


Fixed submission:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int N;
  int H[100000];
  int ans = 0, count = 0;

  scanf("%d", &N);

  for (int i = 0; i < N; i++)
    scanf("%d", &H[i]);

  for (int i = 0; i < N; i++) {
    count = 0;
    for (int j = i; j < N - 1; j++) {
      if (H[j] < H[j + 1])
        break;
      count++;
    }
    if (count > 0)
      i += count - 1;
    if (count > ans)
      ans = count;
  }

  printf("%d", ans);
}
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[i];
  }

  // i番目のマスに降り立ったときに移動可能な回数を格納
  vector<int> can(N, 0);

  for (int i = 0; i < N - 1; i++) {

    if (i >= 1) {
      if (H[i] == H[i - 1])
        continue;
    }

    int j = 0;
    while (H[i + j] >= H[i + j + 1]) {
      can[i] += 1;
      j++;
      if (i + j == N - 1)
        break;
    }
  }

  sort(can.begin(), can.end(), greater<int>());

  cout << can[0] << 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[i];
  }

  // i番目のマスに降り立ったときに移動可能な回数を格納
  vector<int> can(N, 0);

  for (int i = 0; i < N - 1; i++) {

    if (i >= 1) {
      if (H[i] <= H[i - 1])
        continue;
    }

    int j = 0;
    while (H[i + j] >= H[i + j + 1]) {
      can[i] += 1;
      j++;
      if (i + j == N - 1)
        break;
    }
  }

  sort(can.begin(), can.end(), greater<int>());

  cout << can[0] << endl;
}
Problem p02923 (C++)

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

int main() {
  ll n;
  cin >> n;
  ll h[n], i, j, c = 0, d;
  for (i = 0; i < n; i++) {
    cin >> h[i];
  }
  vector<ll> a;

  for (i = 1; i < n; i++) {
    if (i == n - 1) {
      if (h[i] <= h[i - 1]) {
        a.push_back(c + 1);
      } else
        a.push_back(c);
    } else if (h[i] <= h[i - 1]) {
      c++;
    } else {
      a.push_back(c);
      c = 0;
    }
  }
  ll mx = 0;
  mx = a[0];
  for (i = 1; i < a.size(); i++) {
    if (a[i] > mx) {
      mx = a[i];
    }
  }
  cout << mx;
}


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

int main() {
  ll n;
  cin >> n;
  ll h[n], i, j, c = 0, d;
  for (i = 0; i < n; i++) {
    cin >> h[i];
  }
  vector<ll> a;
  if (n == 1) {
    cout << "0";
    return 0;
  }

  for (i = 1; i < n; i++) {
    if (i == n - 1) {
      if (h[i] <= h[i - 1]) {
        a.push_back(c + 1);
      } else
        a.push_back(c);
    } else if (h[i] <= h[i - 1]) {
      c++;
    } else {
      a.push_back(c);
      c = 0;
    }
  }
  ll mx = 0;
  mx = a[0];
  for (i = 1; i < a.size(); i++) {
    if (a[i] > mx) {
      mx = a[i];
    }
  }
  cout << mx;
}
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;
  vector<int> h(N);
  int ans = 0;
  rep(i, N) cin >> h[i];

  rep(i, N - 1) {
    int temp = 0;
    rep(j, N - i - 1) {
      if (h[i + j] >= h[i + j + 1])
        temp++;
      else
        break;
    }
    // cout << temp << endl;
    ans = max(ans, temp);
  }
  cout << ans;
  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;
  vector<int> h(N);
  int ans = 0;
  rep(i, N) cin >> h[i];

  rep(i, N - 1) {
    int temp = 0;
    rep(j, N - i - 1) {
      if (h[i + j] >= h[i + j + 1])
        temp++;
      else
        break;
    }
    // cout << temp << endl;
    ans = max(ans, temp);
    if (ans >= N - i - 1)
      break;
  }
  cout << ans;
  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 H[N];

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

  int biggest = 0;

  for (int i = 0; i < N - 1; i++) {
    int counter = 0;
    int t = i;

    while (t < N - 1) {
      if (H[t] >= H[t + 1]) {
        counter++;
        t++;
      } else {
        break;
      }
    }
    biggest = max(counter, biggest);
    // cout << i << ' ' << biggest << endl;
  }

  cout << biggest;
}


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

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

  int H[N];

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

  int biggest = 0;

  for (int i = 0; i < N - 1; i++) {
    int counter = 0;
    int t = i;
    if (biggest >= N - 1) {
      break;
    }

    while (t < N - 1) {
      if (H[t] >= H[t + 1]) {
        counter++;
        t++;
      } else {
        break;
      }
    }
    biggest = max(counter, biggest);
    // cout << i << ' ' << biggest << endl;
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;
#define mod 10007
#define rep(i, n) for (ll i = 0; i < n; i++)

int main(void) {
  ll n;
  cin >> n;
  vector<ll> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int max_cnt = 0;
  for (int i = 0; i < n - 1; i++) {
    int cnt = 0;
    for (int j = i; j < n - 1; j++) {
      if (h[j] >= h[j + 1]) {
        cnt++;
      } else {
        break;
      }
    }
    if (cnt > max_cnt) {
      max_cnt = cnt;
    }
  }
  cout << max_cnt << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;
#define mod 10007
#define rep(i, n) for (ll i = 0; i < n; i++)

int main(void) {
  ll n;
  cin >> n;
  vector<ll> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int max_cnt = 0;
  for (int i = 0; i < n - 1; i++) {
    int cnt = 0;
    for (int j = i; j < n - 1; j++) {
      if (h[j] >= h[j + 1]) {
        cnt++;
      } else {
        break;
      }
    }
    if (cnt > max_cnt) {
      max_cnt = cnt;
    }
    if (n - max_cnt < n / 2)
      break;
  }
  cout << max_cnt << endl;
  return 0;
}
Problem p02923 (C++)

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

int main() {
  int n, max_cnt = 0;
  cin >> n;
  int h[n];
  for (int i = 0; i < n; i++)
    cin >> h[i];
  for (int i = 0; i < n - 1; i++) {
    int cnt = 0;
    for (int j = i + 1; j < n; j++) {
      if (h[j - 1] >= h[j]) {
        cnt++;
        max_cnt = max(max_cnt, cnt);
      } else {
        break;
      }
    }
  }
  cout << max_cnt << endl;
  return 0;
}

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

int main() {
  int n, max_cnt = 0;
  cin >> n;
  int h[n];
  for (int i = 0; i < n; i++)
    cin >> h[i];
  for (int i = 0; i < n - 1; i++) {
    int cnt = 0;
    if (n - i - 1 <= max_cnt)
      break;
    for (int j = i + 1; j < n; j++) {
      if (h[j - 1] >= h[j]) {
        cnt++;
        max_cnt = max(max_cnt, cnt);
      } else {
        break;
      }
    }
  }
  cout << max_cnt << endl;
  return 0;
}
Problem p02923 (C++)

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

int main() {
  int num;
  cin >> num;
  vector<int> array(num, 0);
  for (int i = 0; i < num; i++) {
    int n;
    scanf("%d", &n);
    array[i] = n;
  }

  int ans = 0;

  for (int i = 0; i < num; i++) {
    int tmpCounter = 0;
    for (int j = i; j < num - 1; j++) {
      if (array[j] >= array[j + 1]) {
        tmpCounter++;
      } else {
        i = j;
        break;
      }
    }
    ans = max(ans, tmpCounter);
  }
  cout << ans << endl;
}

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

int main() {
  int num;
  cin >> num;
  vector<int> array(num, 0);
  for (int i = 0; i < num; i++) {
    int n;
    scanf("%d", &n);
    array[i] = n;
  }

  int ans = 0;

  for (int i = 0; i < num; i++) {
    int tmpCounter = 0;
    if (i + ans >= num) {
      break;
    }
    for (int j = i; j < num - 1; j++) {
      if (array[j] >= array[j + 1]) {
        tmpCounter++;
      } else {
        i = j;
        break;
      }
    }
    ans = max(ans, tmpCounter);
  }
  cout << ans << endl;
}
Problem p02923 (C++)

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

int main() {

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

  for (int i = 0; i < N; i++) {
    ans0 = 0;
    for (int j = i; j < N - 1; j++) {
      if (H[j] >= H[j + 1]) {
        ans0++;
      } else {
        break;
      }
    }
    if (ans0 > ans) {
      ans = ans0;
    }
  }

  cout << ans << endl;
}

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

int main() {

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

  for (int i = 0; i < N; i++) {
    ans0 = 0;
    if (ans >= N - i) {
      break;
    }
    for (int j = i; j < N - 1; j++) {
      if (H[j] >= H[j + 1]) {
        ans0++;
      } else {
        break;
      }
    }
    if (ans0 > ans) {
      ans = ans0;
    }
  }

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

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;
const int MAX_N = 10005;
int H[MAX_N];
bool check[MAX_N];

void init() {
  for (int i = 0; i < MAX_N; ++i) {
    check[i] = true;
  }
  check[0] = false;
}

int main() {
  int N;
  cin >> N;
  init();
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
    if (i != 0 && H[i - 1] < H[i]) {
      check[i] = false;
    }
  }
  check[N] = false;

  /*
  for (int i = 0; i <= N; ++i)
  {
          cout << check[i] << " ";
  }
  cout << endl;
  */

  int ans = 0;
  int cnt = 0;

  for (int i = 0; i <= N; ++i) {
    if (check[i]) {
      cnt++;
    } else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }

  cout << ans << endl;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
const int MAX_N = 100005;
int H[MAX_N];
bool check[MAX_N];

void init() {
  for (int i = 0; i < MAX_N; ++i) {
    check[i] = true;
  }
  check[0] = false;
}

int main() {
  int N;
  cin >> N;
  init();
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
    if (i != 0 && H[i - 1] < H[i]) {
      check[i] = false;
    }
  }
  check[N] = false;

  /*
  for (int i = 0; i <= N; ++i)
  {
          cout << check[i] << " ";
  }
  cout << endl;
  */

  int ans = 0;
  int cnt = 0;

  for (int i = 0; i <= N; ++i) {
    if (check[i]) {
      cnt++;
    } else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string.h>
#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 max = 0;
  for (int i = 0; i < n; i++) {
    // start point
    int count = 0;
    for (int k = i; k < n - 1; k++) {
      if (h[k] >= h[k + 1]) {
        count++;
        if (count > max)
          max = count;
      } else {
        break;
      }
    }
  }
  cout << max << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string.h>
#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 max = 0;
  int count = 0;
  for (int i = 0; i < n - 1; i++) {
    if (h[i] >= h[i + 1]) {
      count++;
      if (count > max)
        max = count;
    } else {
      count = 0;
    }
  }
  cout << max << endl;

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <cassert>
#include <numeric>
// #include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod = 1e9 + 7;
const int INF = 1001001001;
const int inf = 100000;
// const ll inf=1e9+7;
// const ll ful=1e18;
using namespace std;
// namespace mp = boost::multiprecision;
int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  int ans = 0;
  int now = 0;
  for (int i = 0; i < n - 1; ++i) {
    now = 0;
    for (int j = i; j < n - 1; ++j) {
      if (h[j] >= h[j + 1]) {
        now++;
        if (now > ans) {
          ans = now;
        }
        continue;
      }
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <cassert>
#include <numeric>
// #include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod = 1e9 + 7;
const int INF = 1001001001;
const int inf = 100000;
// const ll inf=1e9+7;
// const ll ful=1e18;
using namespace std;
// namespace mp = boost::multiprecision;
int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  int ans = 0;
  int now = 0;
  for (int i = 0; i < n - 1; ++i) {
    now = 0;
    for (int j = i; j < n - 1; ++j) {
      if (h[j] >= h[j + 1]) {
        now++;
        if (now > ans) {
          ans = now;
        }
        continue;
      }
      break;
    }
    if (ans >= n - i)
      break;
  }
  cout << ans << endl;
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_ll(i, n) for (ll i = 0; i < (ll)(n); i++)

using namespace std;

typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const long double PI = (acos(-1));

const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int gcd(int a, int b) {
  if (b == 0)
    return a;

  return gcd(b, a % b);
}

int main() {

  int n;
  cin >> n;

  vector<int> h(n);
  rep(i, n) cin >> h[i];

  int ans = 0;
  int cnt = 0;
  rep(i, n - 1) {
    if (h[i] >= h[i + i])
      cnt++;
    else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);

  cout << ans;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const long double PI = (acos(-1));

const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int gcd(int a, int b) {
  if (b == 0)
    return a;

  return gcd(b, a % b);
}

int main() {

  int n;
  cin >> n;

  vector<int> h(n);
  rep(i, n) cin >> h[i];

  int ans = 0;
  int cnt = 0;
  rep(i, n - 1) {
    if (h[i] >= h[i + 1])
      cnt++;
    else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);

  cout << ans;

  return 0;
}
Problem p02923 (C++)

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

using namespace std;

int main() {
  int m, n, c = 0;
  cin >> m >> n;
  int x = m - n;
  int y = x / (m - 1);
  cout << 1 + y;
}


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

using namespace std;

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

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

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

  vector<long long> h(n);
  rep(i, n) cin >> h[i];

  int ans = 0;
  rep(i, n) {
    int cnt = 0;
    int j = i;
    while ((j < n - 1) && (h[j] >= h[j + 1])) {
      cnt++;
      j++;
    }
    ans = max(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}


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

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

  vector<long long> h(n);
  rep(i, n) cin >> h[i];

  int ans = 0;
  rep(i, n) {
    int cnt = 0;
    int j = i;
    while ((j < n - 1) && (h[j] >= h[j + 1])) {
      cnt++;
      j++;
    }
    i = j;
    ans = max(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}
Problem p02923 (C++)

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

int main() {
  size_t N;
  cin >> N;
  vector<int> H(N, 0);
  for (auto &h : H) {
    cin >> h;
  }

  int move = 0;
  int moveMax = 0;
  size_t p = 0;
  while (p <= (N - 2)) {
    if (H[p] >= H[p + 1]) {
      ++move;
    } else {
      if (move > moveMax) {
        moveMax = move;
      }
      move = 0;
    }
    ++p;
  }
  moveMax = max(move, moveMax);
  cout << moveMax << endl;
}


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

int main() {
  size_t N;
  cin >> N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> H(N, 0);
  for (auto &h : H) {
    cin >> h;
  }

  int move = 0;
  int moveMax = 0;
  size_t p = 0;
  while (p <= (N - 2)) {
    if (H[p] >= H[p + 1]) {
      ++move;
    } else {
      if (move > moveMax) {
        moveMax = move;
      }
      move = 0;
    }
    ++p;
  }
  moveMax = max(move, moveMax);
  cout << moveMax << 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++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef long long ll;
typedef pair<ll, int> P;
typedef set<int> S;
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];
  ll ans = 0;
  ll now = 0;
  for (int i = 0; i < n - 1; i++) {
    int j = i;
    now = 0;
    while (j + 1 < n) {
      if (v[j + 1] <= v[j])
        now++;
      else
        break;
      j++;
    }
    ans = max(now, ans);
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef long long ll;
typedef pair<ll, int> P;
typedef set<int> S;
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];
  ll ans = 0;
  ll now = 0;
  for (int i = 0; i < n - 1; i++) {
    int j = i;
    now = 0;
    while (j + 1 < n) {
      if (v[j + 1] <= v[j])
        now++;
      else
        break;
      j++;
    }
    ans = max(now, ans);
    i = j;
  }
  cout << ans << endl;
  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string, int>;
const double PI = acos(-1);

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h.at(i);
  vector<int> a(n - 1);
  rep(i, n - 1) { a.at(i) = h.at(i) - h.at(i + 1); }
  vector<int> b;

  int x = 0;
  rep(i, n - 1) {
    if (a.at(i) >= 0) {
      x++;
      if (i == n - 2)
        b.push_back(x);
    } else {
      b.push_back(x);
      x = 0;
    }
  }

  sort(b.begin(), b.end());
  cout << b.back() << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string, int>;
const double PI = acos(-1);

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h.at(i);
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> a(n - 1);
  rep(i, n - 1) { a.at(i) = h.at(i) - h.at(i + 1); }
  vector<int> b;

  int x = 0;
  rep(i, n - 1) {
    if (a.at(i) >= 0) {
      x++;
      if (i == n - 2)
        b.push_back(x);
    } else {
      b.push_back(x);
      x = 0;
    }
  }

  sort(b.begin(), b.end());
  cout << b.back() << endl;
}