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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int sz = pow(2, n);
  vector<int> s(sz);
  rep(i, sz) cin >> s[i];
  sort(s.rbegin(), s.rend());

  if (sz == 1)
    cout << "Yes" << endl;
  else {
    if (s[0] == s[1])
      cout << "No" << endl;
    else {
      ll cap = n;
      ll ncap = n;
      priority_queue<ll> pq;

      pq.push(n);
      rep1(i, sz - 1) {
        vector<ll> tmp;
        ll same = 1;
        ll cn;
        cn = pq.top();
        pq.pop();
        if (cn > 0) {
          pq.push(cn - 1);
          tmp.pb(cn - 1);
          ncap += (cn - 1) * 2 - cn;
        }
        while (i < sz - 1 && s[i] == s[i + 1]) {
          i++;
          same++;
          if (!pq.empty()) {
            cn = pq.top();
            pq.pop();
          } else
            continue;
          if (cn > 0) {
            pq.push(cn - 1);
            tmp.pb(cn - 1);
            ncap += (cn - 1) * 2 - cn;
          }
        }

        //	cout << "cap same " << cap << " " << same << endl;
        //	cout << "ncap" << ncap <<endl;
        if (same > cap) {
          cout << "No" << endl;
          return 0;
        }
        cap = ncap;
        rep(j, tmp.size()) pq.push(tmp[i]);
        if (pq.empty())
          break;
      }
      cout << "Yes" << endl;
    }
  }
  return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int sz = pow(2, n);
  vector<int> s(sz);
  rep(i, sz) cin >> s[i];
  sort(s.rbegin(), s.rend());

  if (sz == 1)
    cout << "Yes" << endl;
  else {
    if (s[0] == s[1])
      cout << "No" << endl;
    else {
      ll cap = n;
      ll ncap = n;
      priority_queue<ll> pq;

      pq.push(n);
      rep1(i, sz - 1) {
        vector<ll> tmp;
        ll same = 1;
        ll cn;
        cn = pq.top();
        pq.pop();
        if (cn > 0) {
          pq.push(cn - 1);
          tmp.pb(cn - 1);
          ncap += (cn - 1) * 2 - cn;
        }
        while (i < sz - 1 && s[i] == s[i + 1]) {
          i++;
          same++;
          if (!pq.empty()) {
            cn = pq.top();
            pq.pop();
          } else
            continue;
          if (cn > 0) {
            pq.push(cn - 1);
            tmp.pb(cn - 1);
            ncap += (cn - 1) * 2 - cn;
          }
        }

        //	cout << "cap same " << cap << " " << same << endl;
        //	cout << "ncap" << ncap <<endl;
        if (same > cap) {
          cout << "No" << endl;
          return 0;
        }
        cap = ncap;
        rep(j, tmp.size()) pq.push(tmp[j]);
        if (pq.empty())
          break;
      }
      cout << "Yes" << endl;
    }
  }
  return 0;
}
Problem p02920 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
using namespace std;
#define N 1000010
multiset<int> s;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, a[N], tot;
int b[N], bn;
int main() {
  n = read();
  tot = 1 << n;
  for (int i = 1; i <= tot; i++) {
    a[i] = read();
    s.insert(a[i]);
  }
  b[++bn] = (*--s.end());
  s.erase(s.find(b[bn]));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= (1 << (i - 1)); j++) {
      if (*s.begin() > b[j]) {
        cout << "No" << endl;
        return 0;
      }
      b[++bn] = (*--s.lower_bound(b[j]));
      s.erase(s.find(b[bn]));
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
using namespace std;
#define N 1000010
multiset<int> s;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, a[N], tot;
int b[N], bn;
int main() {
  n = read();
  tot = 1 << n;
  for (int i = 1; i <= tot; i++) {
    a[i] = read();
    s.insert(a[i]);
  }
  b[++bn] = (*--s.end());
  s.erase(s.find(b[bn]));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= (1 << (i - 1)); j++) {
      if (*s.begin() >= b[j]) {
        cout << "No" << endl;
        return 0;
      }
      b[++bn] = (*--s.lower_bound(b[j]));
      s.erase(s.find(b[bn]));
    }
  }
  cout << "Yes" << endl;
  return 0;
}
Problem p02921 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx,tune=naive")
// #pragma GCC diagnostic ignored "-W"
// #include<bits/extc++.h>
// using namespace __gnu_pbds;
using namespace std;
#define F(i, L, R) for (int i = L; i < R; i++)
#define FE(i, L, R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a, b) scanf("%d%d", &a, &b)
#define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n)                                                               \
  int(n);                                                                      \
  scanf("%d", &(n))
#define VgetII(n, m)                                                           \
  int(n), (m);                                                                 \
  scanf("%d %d", &(n), &(m))
#define VgetIII(n, m, k)                                                       \
  int(n), (m), (k);                                                            \
  scanf("%d %d %d", &(n), &(m), &(k))
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD = 1e9 + 7;
char in[1005], in2[5];
int main() {
  while (scanf("%s%s", in, in2)) {
    int ans = 0;
    F(i, 0, 3) if (in[i] == in2[i]) ans++;
    printf("%d\n", ans);
  }
}

Fixed submission:
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx,tune=naive")
// #pragma GCC diagnostic ignored "-W"
// #include<bits/extc++.h>
// using namespace __gnu_pbds;
using namespace std;
#define F(i, L, R) for (int i = L; i < R; i++)
#define FE(i, L, R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a, b) scanf("%d%d", &a, &b)
#define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n)                                                               \
  int(n);                                                                      \
  scanf("%d", &(n))
#define VgetII(n, m)                                                           \
  int(n), (m);                                                                 \
  scanf("%d %d", &(n), &(m))
#define VgetIII(n, m, k)                                                       \
  int(n), (m), (k);                                                            \
  scanf("%d %d %d", &(n), &(m), &(k))
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD = 1e9 + 7;
char in[1005], in2[5];
int main() {
  scanf("%s%s", in, in2);
  int ans = 0;
  F(i, 0, 3) if (in[i] == in2[i]) ans++;
  printf("%d\n", ans);
}
Problem p02921 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main() {

  string S;
  string T;

  cin >> S;
  cin >> T;

  int ans = 0;

  for (int i = 0; S.size(); i++) {
    if (S[i] == T[i]) {
      ans += 1;
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main() {

  string S;
  string T;

  cin >> S;
  cin >> T;

  int ans = 0;

  for (int i = 0; i < S.size(); i++) {
    if (S[i] == T[i]) {
      ans += 1;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p02921 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
int main() {
  string s, t;
  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i)) {
      count++;
    }
  }
  cout << count;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
int main() {
  string s, t;
  cin >> s >> t;
  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i)) {
      count++;
    }
  }
  cout << count;
}
Problem p02921 (C++)

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

int main() {
  string S, T;
  int count = 0;
  cin >> S >> T;
  for (int i = 1; i <= 3; i++) {
    if (S.at(i) == T.at(i)) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

int main() {
  string S, T;
  int count = 0;
  cin >> S >> T;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == T.at(i)) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
Problem p02921 (C++)

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

int main() {
  string s;
  string t;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main() {
  string s;
  string t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02921 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  string s, t;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02921 (C++)

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

int main() {

  string s, t;
  cin >> s >> t;
  int ans = 0;

  for (int i = 0; i, 3; i++) {
    if (s[i] == t[i])
      ans++;
  }

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


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

int main() {

  string s, t;
  cin >> s >> t;
  int ans = 0;

  for (int i = 0; i < 3; i++) {
    if (s[i] == t[i])
      ans++;
  }

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define gc getchar_unlocked
#define cases                                                                  \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
ll mod = 1e9 + 7;
// template<typename T>
inline ll pwr(ll base, ll n) {
  ll ans = 1;
  while (n > 0) {
    if (n % 2 == 1)
      ans = ans * base;
    base = base * base;
    n /= 2;
  }
  return ans;
}
struct range {
  int l, h;
};
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  string s, t;
  cin >> s >> t;

  int ct = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == t[i])
      ct++;
  }
  cout << ct;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define gc getchar_unlocked
#define cases                                                                  \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
ll mod = 1e9 + 7;
// template<typename T>
inline ll pwr(ll base, ll n) {
  ll ans = 1;
  while (n > 0) {
    if (n % 2 == 1)
      ans = ans * base;
    base = base * base;
    n /= 2;
  }
  return ans;
}
struct range {
  int l, h;
};
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s, t;
  cin >> s >> t;

  int ct = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == t[i])
      ct++;
  }
  cout << ct;
  return 0;
}
Problem p02921 (C++)

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

int main() {

  int cnt = 0;
  string s, t;

  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i))
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}

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

int main() {

  int cnt = 0;
  string s, t;
  cin >> s >> t;

  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i))
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}
Problem p02921 (C++)

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);

  string s, t;
  cin >> s >> t;

  int count = 0;

  if (s[0] == t[0])
    count++;
  if (s[1] == t[1])
    count++;
  if (s[2] == t[2])
    count++;

  return count;

  cout << '\n';

  return 0;
}

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);

  string s, t;
  cin >> s >> t;

  int count = 0;

  if (s[0] == t[0])
    count++;
  if (s[1] == t[1])
    count++;
  if (s[2] == t[2])
    count++;

  cout << count;

  cout << '\n';

  return 0;
}
Problem p02921 (Python)

Buggy submission (status: Runtime Error):
s = input().split()
t = input().split()

ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1

print(ans)


Fixed submission:
s = list(input())
t = list(input())

ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1

print(ans)
Problem p02921 (Python)

Buggy submission (status: Runtime Error):
s, t = input()
print(sum(s[i] == t[i] for i in range(3)))


Fixed submission:
s = input()
t = input()
print(sum(s[i] == t[i] for i in range(3)))
Problem p02921 (Python)

Buggy submission (status: Runtime Error):
def main(S, T):
    count = 0

    for i in range(len(S)):
        if T[i] == S[i]:
            count += 1

    return count


if __name__ == "__main__":
    S, T = map(str, input().split())
    print(main(S, T))


Fixed submission:
def main(S, T):
    count = 0

    for i in range(len(S)):
        if T[i] == S[i]:
            count += 1

    return count


if __name__ == "__main__":
    S = input()
    T = input()
    print(main(S, T))
Problem p02921 (C++)

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

int main() {
  string s, t;
  cin >> s, t;
  int c = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i)) {
      c++;
    }
  }
  cout << c << endl;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int c = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i)) {
      c++;
    }
  }
  cout << c << endl;
}
Problem p02921 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i <= 3; i++) {
    for (int j = 0; j <= 3; j++) {
      if (S.at(i) == T.at(i)) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i <= 2; i++) {
    if (S.at(i) == T.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02921 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define N 100005
#define task "t"
#define mu(x) x *x

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<int, pii>;
const int inf = 1e9 + 7;

string s, t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
#ifndef ONLINE_JUDGE
  freopen(task ".inp", "r", stdin);
  freopen(task ".out", "w", stdout);
#endif // ONLINE_JUDGE
  cin >> s >> t;
  int res = 0;
  for (int i = 0; i < 3; i++)
    if (s[i] == t[i])
      res++;
  cout << res;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define N 100005
#define task "t"
#define mu(x) x *x

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<int, pii>;
const int inf = 1e9 + 7;

string s, t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
#ifndef ONLINE_JUDGE
  //  freopen(task".inp","r",stdin);
  //   freopen(task".out","w",stdout);
#endif // ONLINE_JUDGE
  cin >> s >> t;
  int res = 0;
  for (int i = 0; i < 3; i++)
    if (s[i] == t[i])
      res++;
  cout << res;
  return 0;
}
Problem p02921 (C++)

Buggy submission (status: Runtime Error):
/* while(!cin.eof()) */

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod (int)(1e9 + 7)
#define MAXI (int)(1e18 + 100)
#define N 1000200

int fre[N];

// Driver code to test above functions
int32_t main() {

#ifndef ONLINE_JUDGE
  // for getting input from inpu.txt
  freopen("input.txt", "r", stdin);
// for writing output to output.txt
// freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);

  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < 3; i++)
    if (s[i] == t[i])
      ans++;

  cout << ans;

  return 0;
}

Fixed submission:
/* while(!cin.eof()) */

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod (int)(1e9 + 7)
#define MAXI (int)(1e18 + 100)
#define N 1000200

int fre[N];

// Driver code to test above functions
int32_t main() {

  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);

  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < 3; i++)
    if (s[i] == t[i])
      ans++;

  cout << ans;

  return 0;
}
Problem p02921 (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++)
typedef pair<int, int> P;

string s, t;

int main() {
  int cnt = 0;
  rep(i, 3) {
    if (s.at(i) == t.at(i)) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

string s, t;

int main() {
  cin >> s >> t;
  int cnt = 0;
  rep(i, 3) {
    if (s.at(i) == t.at(i)) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02921 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int main() {
  string s, t;
  rep(i, 3) cin >> s.at(i);
  rep(i, 3) cin >> t.at(i);
  int count = 0;
  rep(i, 3) {
    if (s.at(i) == t.at(i))
      count++;
  }
  cout << count << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int main() {
  string s, t;
  cin >> s >> t;
  int count = 0;
  rep(i, 3) {
    if (s.at(i) == t.at(i))
      count++;
  }
  cout << count << endl;
}
Problem p02921 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>

using namespace std;
int main() {
  string S, T;
  int ans;
  cin >> S;
  cin >> T;
  for (int i = 0; i != 3; i++) {
    if (S[i] == T[i])
      ans++;
  }
  return ans;
}

Fixed submission:
#include <iostream>
#include <string>

using namespace std;
int main() {
  string S, T;
  int ans;
  cin >> S;
  cin >> T;
  for (int i = 0; i != 3; i++) {
    if (S[i] == T[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02921 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main(void) {
  char s[3], t[3];
  int i, c;
  for (i = 0; i < 3; i++) {
    scanf("%c", s[i]);
  }
  for (i = 0; i < 3; i++) {
    scanf("%c", t[i]);
  }
  c = 0;
  for (i = 0; i < 3; i++) {
    if (s[i] == t[i])
      c++;
  }
  printf("%d\n", c);
  return 0;
}


Fixed submission:
#include <stdio.h>
int main(void) {
  char s[3], t[3];
  int i, c;
  scanf("%s", s);
  scanf("%s", t);
  c = 0;
  for (i = 0; i < 3; i++) {
    if (s[i] == t[i])
      c++;
  }
  printf("%d\n", c);
  return 0;
}
Problem p02921 (C++)

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

#ifdef ONLINE_JUDGE
#define freopen(N, M, Q)
#endif

#define ll long long
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(N) N.begin(), N.end()

using namespace std;

const ll INF = 1e9;

int main() {
  ios_base::sync_with_stdio(false);
  freopen("input.txt", "r", stdin);

  string a, b;
  cin >> a >> b;

  int cnt = 0;
  for (int i = 0; i < a.size(); ++i)
    if (a[i] == b[i])
      cnt++;

  cout << cnt << endl;

  return 0;
}


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

#ifdef ONLINE_JUDGE
#define freopen(N, M, Q)
#endif

#define ll long long
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(N) N.begin(), N.end()

using namespace std;

const ll INF = 1e9;

int main() {
  ios_base::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string a, b;
  cin >> a >> b;

  int cnt = 0;
  for (int i = 0; i < a.size(); ++i)
    if (a[i] == b[i])
      cnt++;

  cout << cnt << endl;

  return 0;
}
Problem p02922 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  return max(1, B / A + int(B % A != 0));
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  A--;
  B--;
  cout << B / A + int(B % A != 0) << endl;
  return 0;
}
Problem p02922 (C++)

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  int cnt = 1;
  while (cnt < b) {
    cnt += a - 1;
    ans++;
  }
  cout << ans << endl;
  return 1;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  int cnt = 1;
  while (cnt < b) {
    cnt += a - 1;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02922 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
ll deg(ll n) {
  ll count = 0;
  while (n != 0) {
    n /= 10;
    count++;
  }
  return count;
}
int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  int sum = 1;
  while (sum < b) {
    ans++;
    sum = a - 1;
  }
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
ll deg(ll n) {
  ll count = 0;
  while (n != 0) {
    n /= 10;
    count++;
  }
  return count;
}
int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  int sum = 1;
  while (sum < b) {
    ans++;
    sum += a - 1;
  }
  cout << ans << endl;
}
Problem p02922 (C++)

Buggy submission (status: Runtime Error):
#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 a, b;
  cin >> a >> b;
  int t = a - 1;
  int s = b - 1;
  int ans = (t + s - 1) / s;
  cout << ans << endl;

  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 a, b;
  cin >> a >> b;
  int s = a - 1;
  int t = b - 1;
  int ans = (t + s - 1) / s;
  cout << ans << endl;

  return 0;
}
Problem p02922 (C++)

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

int main() {
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i))
      cnt++;
  }
  cout << cnt;
}

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

int main() {
  int a, b, cnt = 0, x = 1;
  cin >> a >> b;
  while (x < b) {
    x = x - 1 + a;
    cnt++;
  }
  cout << cnt;
}
Problem p02922 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> m >> n;
  m--;
  cout << (m + n - 2) / (n - 1) << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  m--;
  cout << (m + n - 2) / (n - 1) << endl;
  return 0;
}
Problem p02922 (Python)

Buggy submission (status: Runtime Error):
A, B = map(int, input().split())

if B == 1:
    print(0)
else:
    C = A
    cnt = 1
    while C < B:
        C += A - 1
        cnt += 1

print(cnt)


Fixed submission:
A, B = map(int, input().split())

if B == 1:
    print(0)
else:
    C = A
    cnt = 1
    while C < B:
        C += A - 1
        cnt += 1
    print(cnt)
Problem p02922 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main(void) {
  int a, b;
  int i = 0;
  cin >> a >> b;
  int sum = 1;

  while (1) {
    sum = 1;
    if (sum >= b)
      break;
    i++;
    sum--;
    sum += a;
  }

  cout << i;
}

Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  int a, b;
  int i = 0;
  cin >> a >> b;
  int sum = 1;

  while (1) {

    if (sum >= b)
      break;
    i++;
    sum--;
    sum += a;
  }

  cout << i;
}
Problem p02922 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int a;
  cin >> a;
  int b;
  cin >> b;
  if (b == 1) {
    cout << 0 << '\n';
    return 0;
  }
  float x = ceil(float(b - 1) / (a - 1));
  cout << (int)x << '\n';
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a;
  cin >> a;
  int b;
  cin >> b;
  if (b == 1) {
    cout << 0 << '\n';
    return 0;
  }
  float x = ceil(float(b - 1) / (a - 1));
  cout << (int)x << '\n';
  return 0;
}
Problem p02922 (C++)

Buggy submission (status: Time Limit Exceeded):
/// Bismillahir Rahmanir Rahim
/// ALLAH HU AKBAR
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  int count = 1;
  cin >> A >> B;
  int y = A - 1;
  int x = A;
  while (A < B) {
    x--;
    x = x + A;
    count++;
  }
  if (B <= 1)
    count = 0;

  cout << count << endl;
}


Fixed submission:
/// Bismillahir Rahmanir Rahim
/// ALLAH HU AKBAR
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  int count = 1;
  cin >> A >> B;
  int y = A - 1;
  int x = A;
  while (x < B) {
    x--;
    x = x + A;
    count++;
  }
  if (B <= 1)
    count = 0;

  cout << count << endl;
}
Problem p02922 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(x) (x).begin(), (x).end()

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

typedef long long ll;

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  a--;
  int res = 1;
  while (b > res)
    res += a;
  cout << (res - 1) / (a - 1) << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(x) (x).begin(), (x).end()

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

typedef long long ll;

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  a--;
  int res = 1;
  while (b > res)
    res += a;
  cout << (res - 1) / (a) << endl;
  return 0;
}
Problem p02922 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  b--;
  a--;
  cout << (b - 1) / (a - 1) + 1 << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  cout << (b + a - 3) / (a - 1) << endl;
  return 0;
}
Problem p02922 (C++)

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

int main() {
  int a, b;
  cin >> a >> b;

  int ans = 0;
  int x = 1;
  while (x < b) {
    x--;
    ans += a;
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;

  int ans = 0;
  int x = 1;
  while (x < b) {
    x--;
    x += a;
    ans++;
  }

  cout << ans << endl;

  return 0;
}
Problem p02922 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  int c = 1, out = A;
  if (B == 1) {
    c = 0;
  } else {
    while (A < B) {
      out += A - 1;
      c++;
    }
  }
  cout << c << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  int c = 1, out = A;
  if (B == 1) {
    c = 0;
  } else {
    while (out < B) {
      out += A - 1;
      c++;
    }
  }
  cout << c << endl;
  return 0;
}
Problem p02922 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int a, b, cnt = 0;
  cin >> a >> b;
  while (b > 1) {
    b - a + 1;
    cnt++;
  }
  cout << cnt;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int a, b, cnt = 0;
  cin >> a >> b;
  while (b > 1) {
    b -= a - 1;
    cnt++;
  }
  cout << cnt;
  return 0;
}
Problem p02922 (C++)

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

int main() {

  int A, B;
  std::cin >> A >> B;
  int curr = 1;
  int cnt = 0;
  while (curr < B) {
    curr += (A - 1);
    cnt++;
  }

  return cnt;
}

Fixed submission:
#include <iostream>

int main() {

  int A, B;
  std::cin >> A >> B;
  int curr = 1;
  int cnt = 0;
  while (curr < B) {
    curr += (A - 1);
    cnt++;
  }

  std::cout << cnt;
  return 0;
}
Problem p02922 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;

  int tapNum = 0;
  int socket = 1;
  while (socket < b) {
    socket += a - 1;
    tapNum++;
  }
  return tapNum;
}

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

  int tapNum = 0;
  int socket = 1;
  while (socket < b) {
    socket += a - 1;
    tapNum++;
  }
  cout << tapNum << endl;
  return 0;
}
Problem p02922 (C++)

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

using namespace std;

int main() {
  int a, b;
  cin >> b;
  int cur = 1, res = 0;
  while (cur < b) {
    ++res;
    cur += a - 1;
  }
  cout << res << endl;
  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int cur = 1, res = 0;
  while (cur < b) {
    ++res;
    cur += a - 1;
  }
  cout << res << endl;
  return 0;
}
Problem p02922 (C++)

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

using namespace std;

typedef long long ll;

int main() {
  int a, b;
  cin >> a >> b;
  int origin = (b - 1 + a - 2) / (a - 1);
  int cur = 1;
  int cnt = 0;
  while (true) {
    if (cur * a >= b) {
      break;
    }
    cur *= a;
  }
  int has = (cur) / (a - 1);
  for (int i = 0; i <= 50; i++) {
    if (i * (a - 1) >= b - cur and i <= cur) {
      assert(has + i == origin);
      cout << has + i << '\n';
      return 0;
    }
  }
}

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

using namespace std;

typedef long long ll;

int main() {
  int a, b;
  cin >> a >> b;
  int origin = (b - 1 + a - 2) / (a - 1);
  int cur = 1;
  int cnt = 0;
  while (true) {
    if (cur * a >= b) {
      break;
    }
    cur *= a;
  }
  int has = (cur - 1) / (a - 1);
  for (int i = 0; i <= 50; i++) {
    if (i * (a - 1) >= b - cur and i <= cur) {
      assert(has + i == origin);
      cout << has + i << '\n';
      return 0;
    }
  }
}
Problem p02922 (C++)

Buggy submission (status: Time Limit Exceeded):
/*

    author : s@if

*/

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

#define NIL -1
#define fi first
#define sec second
#define MAX INT_MAX
#define INF 99999999
#define ll long long
#define PI acos(-1.0)
#define MOD 1000000007
#define PLL pair<ll, ll>
#define PII pair<int, int>
#define ull unsigned long long
#define For(i, a, b) for (int i = a; i <= (int)b; i++)

inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
bool Check(int N, int pos) { return (bool)(N & (1 << pos)); }
int Set(int N, int pos) { return N = N | (1 << pos); }

int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1};
int hr[] = {-2, -2, -1, +1, +2, +2, -1, +1};
int hc[] = {+1, -1, +2, +2, -1, +1, -2, -2};
int dx[] = {+1, -1, +0, +0};
int dy[] = {+0, +0, +1, -1};

const int MAXN = (int)1e5 + 9;

int main() {
  /*	freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      ios_base::sync_with_stdio(false);
      cin.tie(0);
      cout.tie(0);  */

  int i, j, k, l, m, n, p, q, x, y, u, v, r, tc, t;

  cin >> m >> n;

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

  vector<int> vv;

  p = m;

  for (i = 1; i <= 100; i++) {
    vv.push_back(m);
    m += p - 1;
  }

  for (i = 0; i < vv.size(); i++) {
    if (vv[i] >= n)
      break;
  }

  cout << i + 1 << endl;

  main();

  return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Fixed submission:
/*

    author : s@if

*/

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

#define NIL -1
#define fi first
#define sec second
#define MAX INT_MAX
#define INF 99999999
#define ll long long
#define PI acos(-1.0)
#define MOD 1000000007
#define PLL pair<ll, ll>
#define PII pair<int, int>
#define ull unsigned long long
#define For(i, a, b) for (int i = a; i <= (int)b; i++)

inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
bool Check(int N, int pos) { return (bool)(N & (1 << pos)); }
int Set(int N, int pos) { return N = N | (1 << pos); }

int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1};
int hr[] = {-2, -2, -1, +1, +2, +2, -1, +1};
int hc[] = {+1, -1, +2, +2, -1, +1, -2, -2};
int dx[] = {+1, -1, +0, +0};
int dy[] = {+0, +0, +1, -1};

const int MAXN = (int)1e5 + 9;

int main() {
  /*	freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      ios_base::sync_with_stdio(false);
      cin.tie(0);
      cout.tie(0);  */

  int i, j, k, l, m, n, p, q, x, y, u, v, r, tc, t;

  cin >> m >> n;

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

  vector<int> vv;

  p = m;

  for (i = 1; i <= 100; i++) {
    vv.push_back(m);
    m += p - 1;
  }

  for (i = 0; i < vv.size(); i++) {
    if (vv[i] >= n)
      break;
  }

  cout << i + 1 << endl;

  //  main();

  return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
Problem p02923 (C++)

Buggy submission (status: Runtime Error):

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

long long MOD = 1000000007;

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

  int tempCount = 0;
  int maxCount = 0;

  for (size_t i = 1; i < n; i++) {
    if (h[i] <= h[i - 1]) {
      tempCount++;
      if (maxCount <= tempCount) {
        maxCount = tempCount;
      }
    } else {
      tempCount = 0;
    }
  }

  std::cout << maxCount << std::endl;
  return 0;
}


Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

long long MOD = 1000000007;

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

  int tempCount = 0;
  int maxCount = 0;

  for (size_t i = 1; i < n; i++) {
    if (h[i] <= h[i - 1]) {
      tempCount++;
      if (maxCount <= tempCount) {
        maxCount = tempCount;
      }
    } else {
      tempCount = 0;
    }
  }

  std::cout << maxCount << std::endl;
  return 0;
}
Problem p02923 (C++)

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

int main() {
  int A = 0, N, Z, a;
  cin >> N;
  int B[N];
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  N -= 1;
  for (int s = 0; s < N; s++) {
    Z = 0;
    a = s + 1;
    for (int x = s; B[x] >= B[a] && x < N; x++) {
      Z++;
      a++;
    }
    if (A < Z) {
      A = Z;
    }
  }
  cout << A;
  return 0;
}

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

int main() {
  int A = 0, N, Z, a;
  cin >> N;
  int B[N];
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  N -= 1;
  for (int s = 0; s < N; s++) {
    Z = 0;
    a = s + 1;
    if (A < N - s) {
      for (int x = s; B[x] >= B[a] && x < N; x++) {
        Z++;
        a++;
      }
      if (A < Z) {
        A = Z;
      }
    }
  }
  cout << A;
  return 0;
}
Problem p02923 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
height = list(map(int, input().split()))
max_count = 0
for i in range(n):
    count = 0
    for j in range(i, n):
        if j == n - 1 or height[j] < height[j + 1]:
            break
        count += 1
    max_count = max(max_count, count)
print(max_count)


Fixed submission:
n = int(input())
height = list(map(int, input().split()))
max_count = 0
count = 0
for i in range(n - 1):
    if height[i] < height[i + 1]:
        max_count = max(count, max_count)
        count = 0
        continue
    count += 1
max_count = max(count, max_count)
print(max_count)
Problem p02923 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>
int main() {
  int N;
  std::cin >> N;
  std::vector<int> H(N);
  for (int i = 0; i < N; i++) {
    std::cin >> H[i];
  }
  int max = -1;
  for (int i = 0; i < N; i++) {
    int cnt = 0;
    for (int j = i; j < N - 1; j++) {
      if (H[j + 1] <= H[j])
        cnt++;
      else
        break;
    }
    if (cnt > max)
      max = cnt;
  }
  std::cout << max << std::endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
int main() {
  int N;
  std::cin >> N;
  std::vector<int> H(N);
  for (int i = 0; i < N; i++) {
    std::cin >> H[i];
  }
  int max = -1;
  for (int i = 0; i < N; i++) {
    int cnt = 0;
    for (int j = i; j < N - 1; j++) {
      if (H[j + 1] <= H[j])
        cnt++;
      else
        break;
    }
    if (cnt > 0)
      i += cnt - 1;
    if (cnt > max)
      max = cnt;
  }
  std::cout << max << std::endl;
  return 0;
}
Problem p02923 (Python)

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

max_step = 0
for i in range(n):
    current_step = 0
    for j in range(i + 1, n):
        if h[j - 1] >= h[j]:
            current_step += 1
            if current_step > max_step:
                max_step = current_step
        else:
            i = j
            break
print(max_step)


Fixed submission:
n = int(input())
h = list(map(int, input().split()))

max_step = 0
current_step = 0
for i in range(n - 1):
    if h[i] >= h[i + 1]:
        current_step += 1
        if current_step > max_step:
            max_step = current_step
    else:
        current_step = 0
print(max_step)
Problem p02923 (C++)

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

int main() {
  int A;
  cin >> A;
  vector<int> B(A);
  for (int i = 0; i < A; i++) {
    cin >> B.at(i);
  }
  int ans = 0;
  int tmp = 0;
  for (int i = 0; i < A; i++) {
    if (B.at(i) >= B.at(i + 1)) {
      tmp++;
    } else {
      tmp = 0;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

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

int main() {
  int A;
  cin >> A;
  vector<int> B(A);
  for (int i = 0; i < A; i++) {
    cin >> B.at(i);
  }
  int ans = 0;
  int tmp = 0;
  for (int i = 0; i < A - 1; i++) {
    if (B.at(i) >= B.at(i + 1)) {
      tmp++;
    } else {
      tmp = 0;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
Problem p02923 (C++)

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

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

  long long storedCount = 0;
  long long eachCount = 0;
  for (long long i = 0; i < n; i++) {
    // cout << storedCount << eachCount << endl;
    if (storedCount < eachCount)
      storedCount = eachCount;
    eachCount = 0;
    for (long long j = i; j < n - 1; j++) {
      if (h[j] >= h[j + 1])
        eachCount++;
      else
        break;
    }
  }

  cout << storedCount << endl;
}

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

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

  long long storedCount = 0;
  long long eachCount = 0;
  for (long long i = 0; i < n; i++) {
    // cout << storedCount << eachCount << endl;
    if (storedCount < eachCount)
      storedCount = eachCount;
    if (storedCount >= n - 1)
      break;
    eachCount = 0;
    for (long long j = i; j < n - 1; j++) {
      if (h[j] >= h[j + 1])
        eachCount++;
      else
        break;
    }
  }

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

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  int count = 0;
  vector<int> vec2;
  int a = vec.at(0);
  for (int i = 1; i < N; i++) {
    if (i == N - 1) {
      if (a >= vec.at(i)) {
        count++;
        vec2.push_back(count);
        break;
      } else {
        vec2.push_back(count);
        break;
      }
    }
    if (a >= vec.at(i)) {
      count++;
      a = vec.at(i);
    } else {
      vec2.push_back(count);
      count = 0;
      a = vec.at(i);
    }
  }
  sort(vec2.begin(), vec2.end());
  reverse(vec2.begin(), vec2.end());
  cout << vec2.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<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  int count = 0;
  vector<int> vec2;
  int a = vec.at(0);
  for (int i = 1; i < N; i++) {
    if (i == N - 1) {
      if (a >= vec.at(i)) {
        count++;
        vec2.push_back(count);
        break;
      } else {
        vec2.push_back(count);
        break;
      }
    }
    if (a >= vec.at(i)) {
      count++;
      a = vec.at(i);
    } else {
      vec2.push_back(count);
      count = 0;
      a = vec.at(i);
    }
  }
  sort(vec2.begin(), vec2.end());
  reverse(vec2.begin(), vec2.end());
  cout << vec2.at(0) << 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 ll = long long;
using namespace std;
const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int max = 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 += 1;
      } else {
        break;
      }
    }
    if (cnt > max) {
      max = cnt;
    }
  }
  cout << max << endl;

  return 0;
}


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

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

  return 0;
}
Problem p02923 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int a, h[10005];
  cin >> a;
  int i;
  int Max, ans;
  Max = 0;
  ans = 0;
  for (i = 0; i < a; i++) {
    cin >> h[i];
  }
  for (i = 0; i < a - 1; i++) {
    if (h[i] >= h[i + 1]) {
      Max++;
      if (ans < Max) {
        ans = Max;
      }
    } else {
      Max = 0;
    }
  }
  cout << ans;
  return (0);
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int a, h[100005];
  cin >> a;
  int i;
  int Max, ans;
  Max = 0;
  ans = 0;
  for (i = 0; i < a; i++) {
    cin >> h[i];
  }
  for (i = 0; i < a - 1; i++) {
    if (h[i] >= h[i + 1]) {
      Max++;
      if (ans < Max) {
        ans = Max;
      }
    } else {
      Max = 0;
    }
  }
  cout << ans;
  return (0);
}
Problem p02923 (Python)

Buggy submission (status: Time Limit Exceeded):
#!/usr/bin/env python3
n = int(input())
h = list(map(int, input().split()))
ans = 0
for i in range(n):
    tmp = 0
    for j in range(i, n - 1):
        if h[j] < h[j + 1]:
            tmp = 0
        else:
            tmp += 1
        ans = max(ans, tmp)
print(ans)


Fixed submission:
#!/usr/bin/env python3
n = int(input())
h = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(n - 1):
    if h[i] < h[i + 1]:
        tmp = 0
    else:
        tmp += 1
    ans = max(ans, tmp)
print(ans)