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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (long long(i) = 0; (i) < (n); ++(i))
#define ref(i, a, b) for (long long(i) = (a); (i) <= (b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const int mx = 1e6 + 5;
long long c[mx];
long long n, d, a;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  /*freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
*/
  cin >> n >> d >> a;
  vector<pair<long long, long long>> v;
  for (int i = 0; i < n; ++i) {
    ll x, y;
    cin >> x >> y;
    v.pb(mp(x, y));
  }
  long long ans = 0;
  sort(v.begin(), v.end());
  ll j = 0;
  for (ll i = 0; i < n; ++i) {
    j = 0;
    while (j < n and v[j].first <= v[i].first + 2 * d)
      ++j;
    ll need = max((v[i].second - c[i] * a + a - 1) / a, 0ll);
    ans += need;
    c[j] = c[j] - need;
    c[i] += need;
    c[i + 1] += c[i];
    // cout << need <<" "<< i << endl;
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (long long(i) = 0; (i) < (n); ++(i))
#define ref(i, a, b) for (long long(i) = (a); (i) <= (b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const int mx = 1e6 + 5;
long long c[mx];
long long n, d, a;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  /*freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
*/
  cin >> n >> d >> a;
  vector<pair<long long, long long>> v;
  for (int i = 0; i < n; ++i) {
    ll x, y;
    cin >> x >> y;
    v.pb(mp(x, y));
  }
  long long ans = 0;
  sort(v.begin(), v.end());
  ll j = 0;
  for (ll i = 0; i < n; ++i) {
    // j=0;
    while (j < n and v[j].first <= v[i].first + 2 * d)
      ++j;
    ll need = max((v[i].second - c[i] * a + a - 1) / a, 0ll);
    ans += need;
    c[j] = c[j] - need;
    c[i] += need;
    c[i + 1] += c[i];
    // cout << need <<" "<< i << endl;
  }
  cout << ans << endl;
}
Problem p02788 (C++)

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

#define ll long long
#define pb push_back

#define loop(i, a, b) for (int i = (a); i < (b); i++)
#define loopb(i, a, b) for (int i = (a); i > (b); --i)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;

const int mod = 1e9 + 7;
const ll inf = 2e18 + 5;

// RUNNING SUMS METHOD

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("fin.txt", "r", stdin);
  freopen("fout.txt", "w", stdout);
#endif
  int n, d, a;
  cin >> n >> d >> a;
  vii monsters;
  loop(i, 0, n) {
    int x, h;
    cin >> x >> h;
    h = (h + a - 1) / a; // ceil(h/a)
    monsters.emplace_back(x, h);
  }
  assert((int)monsters.size() == n);
  sort(monsters.begin(), monsters.end());

  ll running_sum = 0;
  vi change(n + 1, 0);
  ll ans = 0;
  loop(i, 0, n) {
    running_sum += change[i];

    int x = monsters[i].second - running_sum;
    if (x <= 0)
      continue;
    ans += x;
    running_sum += x;
    int lo = i, hi = n - 1, ok;
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      if (monsters[mid].first <= monsters[i].first + 2LL * d) {
        ok = mid;
        lo = mid + 1;
      } else
        hi = mid - 1;
    }
    change[ok + 1] -= x;
  }
  cout << ans;
  return 0;
}


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

#define ll long long
#define pb push_back

#define loop(i, a, b) for (int i = (a); i < (b); i++)
#define loopb(i, a, b) for (int i = (a); i > (b); --i)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;

const int mod = 1e9 + 7;
const ll inf = 2e18 + 5;

// RUNNING SUMS METHOD

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int n, d, a;
  cin >> n >> d >> a;
  vii monsters;
  loop(i, 0, n) {
    int x, h;
    cin >> x >> h;
    h = (h + a - 1) / a; // ceil(h/a)
    monsters.emplace_back(x, h);
  }
  assert((int)monsters.size() == n);
  sort(monsters.begin(), monsters.end());

  ll running_sum = 0;
  vi change(n + 1, 0);
  ll ans = 0;
  loop(i, 0, n) {
    running_sum += change[i];

    int x = monsters[i].second - running_sum;
    if (x <= 0)
      continue;
    ans += x;
    running_sum += x;
    int lo = i, hi = n - 1, ok;
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      if (monsters[mid].first <= monsters[i].first + 2LL * d) {
        ok = mid;
        lo = mid + 1;
      } else
        hi = mid - 1;
    }
    change[ok + 1] -= x;
  }
  cout << ans;
  return 0;
}
Problem p02788 (Python)

Buggy submission (status: Runtime Error):
from bisect import bisect_right

n, d, a = map(int, input().split())
xh = sorted(list(map(int, input().split())) for _ in range(n))
x = [0] * (n + 1)
h = [0] * (n + 1)
s = [0] * (n + 1)

for i, (f, g) in enumerate(xh):
    x[i], h[i] = f, g
x[n] = 10**9 + 1
ans = 0
for i in range(n):
    if i > 0:
        s[i] += s[i - 1]
    h[i] -= s[i]
    if h[i] > 0:
        num = 0 - -h[i] // a
        ans += num
        s[i] += num * a

        j = bisect_right(x, x[i] + d * 2)
        s[j] -= num * a
print(ans)


Fixed submission:
from bisect import bisect_right

n, d, a = map(int, input().split())
xh = sorted(list(map(int, input().split())) for _ in range(n))
x = [0] * (n + 1)
h = [0] * (n + 1)
s = [0] * (n + 1)

for i, (f, g) in enumerate(xh):
    x[i], h[i] = f, g
x[n] = 10**10 + 1
ans = 0
for i in range(n):
    if i > 0:
        s[i] += s[i - 1]
    h[i] -= s[i]
    if h[i] > 0:
        num = 0 - -h[i] // a
        ans += num
        s[i] += num * a

        j = bisect_right(x, x[i] + d * 2)
        s[j] -= num * a
print(ans)
Problem p02788 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
long long int sum[200005];
int main() {
  long long int n, d, a;
  cin >> n >> d >> a;
  pair<int, long long int> p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
    p[i].second = (p[i].second + a - 1) / a;
  }
  sort(p, p + n);
  int r[n];
  int tmp = n - 1;
  for (int i = n - 1; i > 0; i--) {
    while (p[tmp].first + 2 * d >= p[i].first && tmp >= 0)
      tmp--;
    r[i] = tmp + 1;
  }
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    p[i].second -= (sum[i] - sum[r[i]]);
    sum[i + 1] = sum[i] + max(0LL, p[i].second);
    ans += max(0LL, p[i].second);
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long long int sum[200005];
int main() {
  long long int n, d, a;
  cin >> n >> d >> a;
  pair<int, long long int> p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
    p[i].second = (p[i].second + a - 1) / a;
  }
  sort(p, p + n);
  int r[n];
  int tmp = n - 1;
  for (int i = n - 1; i >= 0; i--) {
    while (p[tmp].first + 2 * d >= p[i].first && tmp >= 0)
      tmp--;
    r[i] = tmp + 1;
  }
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    p[i].second -= (sum[i] - sum[r[i]]);
    sum[i + 1] = sum[i] + max(0LL, p[i].second);
    ans += max(0LL, p[i].second);
  }
  cout << ans << endl;
}
Problem p02788 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
using namespace std;
struct point {
  long long x, h;
} p[1000000001];
bool cmp(point const &p1, point const &p2) { return p1.x < p2.x; }
int main() {
  // 读入数据
  long long N, D, A;
  scanf("%lld%lld%lld", &N, &D, &A);
  D <<= 1; // 先将半个宽度乘2使之成为左右区间宽度
  for (int i = 1; i <= N; i++) {
    scanf("%lld%lld", &p[i].x, &p[i].h);
  }

  sort(p + 1, p + N + 1, cmp); // 按坐标升序

  long long tmp = 0;            // 炸弹伤害
  long long hurt[200001] = {0}; // 记录每个点的伤害
  long long ans = 0;            // 记录答案
  for (int i = 1; i <= N; i++)  // 循环处理每个Monster
  {
    p[i].h -= tmp;  // 先减去上几次投弹的伤害
    if (p[i].h > 0) // 第i个还没死，考虑继续炸
    {
      long long n = (p[i].h + A - 1) / A; // 至少还需要炸的次数
      long long h = n * A;                // 本次投弹伤害
      tmp += h;                           // 更新伤害
      ans += n;                           // 更新答案

      long long l = i,
                r = N + 1; // 二分查找，寻找轰炸点使得i恰好在爆炸范围的左端
      while (l < r - 1) {
        long long mid = (l + r) >> 1;
        if (p[mid].x - D <= p[i].x) // 更新后能否炸到i
          l = mid;
        else
          r = mid;
      }
      hurt[l] += h; // 最终在l处投弹，记录该处伤害
    }
    tmp -=
        hurt[i]; // 处理完第i个，轰炸区间向右移动，不再计算i点投弹所产生的伤害
  }

  printf("%lld", ans); // 输出答案
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
using namespace std;
struct point {
  long long x, h;
} p[200001];
bool cmp(point const &p1, point const &p2) { return p1.x < p2.x; }
int main() {
  // 读入数据
  long long N, D, A;
  scanf("%lld%lld%lld", &N, &D, &A);
  D <<= 1; // 先将半个宽度乘2使之成为左右区间宽度
  for (int i = 1; i <= N; i++) {
    scanf("%lld%lld", &p[i].x, &p[i].h);
  }

  sort(p + 1, p + N + 1, cmp); // 按坐标升序

  long long tmp = 0;            // 炸弹伤害
  long long hurt[200001] = {0}; // 记录每个点的伤害
  long long ans = 0;            // 记录答案
  for (int i = 1; i <= N; i++)  // 循环处理每个Monster
  {
    p[i].h -= tmp;  // 先减去上几次投弹的伤害
    if (p[i].h > 0) // 第i个还没死，考虑继续炸
    {
      long long n = (p[i].h + A - 1) / A; // 至少还需要炸的次数
      long long h = n * A;                // 本次投弹伤害
      tmp += h;                           // 更新伤害
      ans += n;                           // 更新答案

      long long l = i,
                r = N + 1; // 二分查找，寻找轰炸点使得i恰好在爆炸范围的左端
      while (l < r - 1) {
        long long mid = (l + r) >> 1;
        if (p[mid].x - D <= p[i].x) // 更新后能否炸到i
          l = mid;
        else
          r = mid;
      }
      hurt[l] += h; // 最终在l处投弹，记录该处伤害
    }
    tmp -=
        hurt[i]; // 处理完第i个，轰炸区间向右移动，不再计算i点投弹所产生的伤害
  }

  printf("%lld", ans); // 输出答案
  return 0;
}
Problem p02788 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <forward_list>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void) {
  int n, d, a;
  vector<P> monster;
  int x, h;
  int i, j;
  int target, targetx, targeth;
  int mid;
  ll count;
  ll ans = 0;
  vector<int> damage(100010, 0);

  cin >> n >> d >> a;

  monster.emplace_back(0, 0);

  rep(i, 1, n + 1) {
    cin >> x >> h;
    monster.emplace_back(x, h);
  }

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

  rep(i, 1, n + 1) {
    damage[i] += damage[i - 1];

    if (damage[i] < monster[i].second) {
      target = i;
    } else {
      continue;
    }

    targetx = monster[target].first;
    targeth = monster[target].second - damage[target];

    count = (targeth + a - 1) / a;

    ans += count;

    int ok = 0, ng = n + 1;

    while (ng - ok > 1) {
      mid = (ok + ng) / 2;

      if (monster[mid].first <= targetx + d * 2) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    damage[target] += count * a;
    damage[ok + 1] += -count * a;
  }

  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <forward_list>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void) {
  int n, d, a;
  vector<P> monster;
  int x, h;
  int i, j;
  int target, targetx, targeth;
  int mid;
  ll count;
  ll ans = 0;
  vector<int> damage(200010, 0);

  cin >> n >> d >> a;

  monster.emplace_back(0, 0);

  rep(i, 1, n + 1) {
    cin >> x >> h;
    monster.emplace_back(x, h);
  }

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

  rep(i, 1, n + 1) {
    damage[i] += damage[i - 1];

    if (damage[i] < monster[i].second) {
      target = i;
    } else {
      continue;
    }

    targetx = monster[target].first;
    targeth = monster[target].second - damage[target];

    count = (targeth + a - 1) / a;

    ans += count;

    int ok = 0, ng = n + 1;

    while (ng - ok > 1) {
      mid = (ok + ng) / 2;

      if (monster[mid].first <= targetx + d * 2) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    damage[target] += count * a;
    damage[ok + 1] += -count * a;
  }

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

Buggy submission (status: Time Limit Exceeded):
// --------------
// Tejas Pandey  |
// 26 - 01 - 20  |
// ATCODER #153  |
// --------------

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

#define mod 1000000007
#define lim 100000000000000000
#define vi vector<int>
typedef long long int ll;

int main(void) {
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  // cin >> t;
  while (t--) {
    // cout << "Case #" << c-t << ": ";
    ll n, d, a;
    cin >> n >> d >> a;
    vector<pair<ll, ll>> nd(n);
    for (int i = 0; i < n; i++)
      cin >> nd[i].first >> nd[i].second;
    sort(nd.begin(), nd.end());
    ll cur = 0, cnt = 0;
    queue<pair<ll, ll>> qt;
    for (int i = 0; i < n; i++) {
      while (!qt.empty() && qt.front().first < nd[i].first)
        cur -= qt.front().second, qt.pop();
      ll ti = 0;
      while (cur < nd[i].second)
        cur += a, ti++;
      cnt += ti;
      qt.push({nd[i].first + d + d, ti * a});
    }
    cout << cnt << "\n";
  }
  return 0;
}

Fixed submission:
// --------------
// Tejas Pandey  |
// 26 - 01 - 20  |
// ATCODER #153  |
// --------------

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

#define mod 1000000007
#define lim 100000000000000000
#define vi vector<int>
typedef long long int ll;

int main(void) {
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  // cin >> t;
  while (t--) {
    // cout << "Case #" << c-t << ": ";
    ll n, d, a;
    cin >> n >> d >> a;
    vector<pair<ll, ll>> nd(n);
    for (int i = 0; i < n; i++)
      cin >> nd[i].first >> nd[i].second;
    sort(nd.begin(), nd.end());
    ll cur = 0, cnt = 0;
    queue<pair<ll, ll>> qt;
    for (int i = 0; i < n; i++) {
      while (!qt.empty() && qt.front().first < nd[i].first)
        cur -= qt.front().second, qt.pop();
      ll ti = 0;
      if (cur < nd[i].second)
        ti = (ll)ceil((nd[i].second - cur) / (a * 1.0));
      cur += ti * a;
      cnt += ti;
      qt.push({nd[i].first + d + d, ti * a});
    }
    cout << cnt << "\n";
  }
  return 0;
}
Problem p02789 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S, T, U;
  int A, B;
  cin >> A >> B;
  if (A % B == 0)
    S = "Yes";
  else
    S = "No";
  cout << S << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S, T, U;
  int A, B;
  cin >> A >> B;
  if (A - B == 0)
    S = "Yes";
  else
    S = "No";
  cout << S << endl;
}
Problem p02789 (Python)

Buggy submission (status: Runtime Error):
n, m = map(int, input().split())

if n / m == 1:
    print("Yes")
else:
    print("No")


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

if n == m:
    print("Yes")
else:
    print("No")
Problem p02789 (C++)

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

int main() {
  int h, a;
  cin >> h >> a;
  if (h % a != 0)
    cout << h / a + 1 << endl;
  else if (h % a == 0)
    cout << h / a << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  if (n == m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02789 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

#ifndef ONLINE_JUDGE
  FILE *f1 = freopen("input.txt", "r", stdin);
  FILE *f2 = freopen("output.txt", "w", stdout);
#endif

  ll a, b;
  cin >> a >> b;
  if (a == b)
    cout << "Yes\n";
  else
    cout << "No\n";
}

Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  ll a, b;
  cin >> a >> b;
  if (a == b)
    cout << "Yes\n";
  else
    cout << "No\n";
}
Problem p02789 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long int ull;
#define pb push_back
#define For(ii, aa, bb) for (ll ii = aa; ii < bb; ii++)
#define Rof(ii, aa, bb) for (ll ii = aa; ii >= bb; ii--)
#define st first
#define nd second
#define MP make_pair
#define MAX 1000000009
#define MOD 1000000007
#define all(v6) v6.begin(), v6.end()
#define IT iterator
#define ln "\n"
#define F(ii) ((abs(ii) + ii) / 2)
#define N 500005
using namespace std;
ll n, x;
int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> x;
  cout << (n == x ? "Yes" : "No");
}

Fixed submission:
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long int ull;
#define pb push_back
#define For(ii, aa, bb) for (ll ii = aa; ii < bb; ii++)
#define Rof(ii, aa, bb) for (ll ii = aa; ii >= bb; ii--)
#define st first
#define nd second
#define MP make_pair
#define MAX 1000000009
#define MOD 1000000007
#define all(v6) v6.begin(), v6.end()
#define IT iterator
#define ln "\n"
#define F(ii) ((abs(ii) + ii) / 2)
#define N 500005
using namespace std;
ll n, x;
int main() {
#ifndef ONLINE_JUDGE
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> x;
  cout << (n == x ? "Yes" : "No");
}
Problem p02789 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>

int main() {
  int n, m;
  scanf("%d%d", n, m);
  if (n == m) {
    printf("Yes");
  } else {
    printf("No");
  }
}

Fixed submission:
#include <stdio.h>

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  if (n == m) {
    printf("Yes");
  } else {
    printf("No");
  }
}
Problem p02789 (C++)

Buggy submission (status: Runtime Error):
/*

Auther: Ganesh Bhandarkar
                                                        #   RUN   #
                <<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/

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

/* KEYWORDS */
#define FASTIO                                                                 \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define sq(a) (a) * (a)
#define rep(i, a, b) for (int i = a; i < b; ++i)

/*DATATYPES */
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef pair<int, int> pi;
typedef pair<int, char> pic;
typedef pair<char, char> pc;
typedef pair<char, int> pci;

/*Constants */
const ll mod = 10000000007;

/* Booleans */
// bool OE(int n)  if(n & 1){ return true; } else false;

int main() {

  // #ifndef OJ
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif

#ifndef OJ
  freopen("C:/Users/KIIT/CP/input.txt", "r", stdin);
  freopen("C:/Users/KIIT/CP/output.txt", "w", stdout);
#endif

  FASTIO

  int n, m;
  cin >> n >> m;
  if (n > m) {
    cout << "No";
  } else if (n == m) {
    cout << "Yes";
  }

  return 0;
}

Fixed submission:
/*

Auther: Ganesh Bhandarkar
                                                        #   RUN   #
                <<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/

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

/* KEYWORDS */
#define FASTIO                                                                 \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define sq(a) (a) * (a)
#define rep(i, a, b) for (int i = a; i < b; ++i)

/*DATATYPES */
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef pair<int, int> pi;
typedef pair<int, char> pic;
typedef pair<char, char> pc;
typedef pair<char, int> pci;

/*Constants */
const ll mod = 10000000007;

/* Booleans */
// bool OE(int n)  if(n & 1){ return true; } else false;

int main() {

  // #ifndef OJ
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif

  FASTIO

  int n, m;
  cin >> n >> m;
  if (n > m) {
    cout << "No";
  } else if (n == m) {
    cout << "Yes";
  }

  return 0;
}
Problem p02789 (C++)

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

  //*
  int a, b;
  cin >> a >> b;
  //*/

  /*
  vector<int> vec(3);
  cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;

  sort(vec.begin(), vec.end());
  //*/

  //*
  if (a == b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  //*/

  cout << a / b + min(a % b, 1) << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {

  //*
  int a, b;
  cin >> a >> b;
  //*/

  /*
  vector<int> vec(3);
  cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;

  sort(vec.begin(), vec.end());
  //*/

  //*
  if (a == b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  //*/

  // cout << a / b + min(a % b, 1) << endl;

  return 0;
}
Problem p02789 (C++)

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

#define itn int
#define vi vector<int>
#define pb push_back
#define srt sort(v.begin(), v.end())

// int infiint = std::numeric_limits<int>::max();
// float infiflt = std::numeric_limits<float>::infinity();

void solve() {
  int n, m;
  cin >> n >> m;
  if (n <= m) {
    cout << "Yes";
  } else
    cout << "No";
}

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  freopen("input.txt", "rt", stdin);

  solve();

  return 0;
}

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

#define itn int
#define vi vector<int>
#define pb push_back
#define srt sort(v.begin(), v.end())

// int infiint = std::numeric_limits<int>::max();
// float infiflt = std::numeric_limits<float>::infinity();

void solve() {
  int n, m;
  cin >> n >> m;
  if (n <= m) {
    cout << "Yes";
  } else
    cout << "No";
}

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  // freopen("input.txt", "rt", stdin);

  solve();

  return 0;
}
Problem p02789 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void IO() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

void solve() {
  int n, m;
  cin >> n >> m;
  if (m >= n) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

int main() {
  IO();
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void IO() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

void solve() {
  int n, m;
  cin >> n >> m;
  if (m >= n) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

int main() {
  // IO();
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem p02789 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
const ll INF = 1e18;

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
  ll int n, m;
  cin >> n >> m;
  if (n == m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
const ll INF = 1e18;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll int n, m;
  cin >> n >> m;
  if (n == m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02789 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) (v).begin(), (v).end()
#define endl "\n"
#define deb(x) cout << #x << " : " << x << endl;
template <class A> ostream &operator<<(ostream &out, const vector<A> &a) {
  for (const A &it : a)
    out << it << " ";
  return out;
}
template <class A> istream &operator>>(istream &in, vector<A> &a) {
  for (A &i : a)
    in >> i;
  return in;
}

signed 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 n, m;
  cin >> n >> m;
  cout << (n == m ? "Yes" : "No");
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) (v).begin(), (v).end()
#define endl "\n"
#define deb(x) cout << #x << " : " << x << endl;
template <class A> ostream &operator<<(ostream &out, const vector<A> &a) {
  for (const A &it : a)
    out << it << " ";
  return out;
}
template <class A> istream &operator>>(istream &in, vector<A> &a) {
  for (A &i : a)
    in >> i;
  return in;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int n, m;
  cin >> n >> m;
  cout << (n == m ? "Yes" : "No");
}
Problem p02789 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  string a, b;
  cin >> a >> b;
  int a1 = stoi(a);
  int b2 = stoi(b);
  int result = a1 / b2;
  if (result == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  string n, m;
  cin >> n >> m;
  int n1 = stoi(n);
  int m1 = stoi(m);
  if (n1 == 0) {
    cout << "No" << endl;
  }
  int result = m1 / n1;
  if (result == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02790 (C++)

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

using namespace std;

string replicate(string s, int n) {
  string ret = "";
  for (int i = 0; i < n; i++) {
    ret += s;
  }
}

int main() {
  int a, b;
  cin >> a >> b;
  string s = replicate(to_string(a), b);
  string t = replicate(to_string(b), a);
  cout << (s < t ? s : t) << endl;
  return 0;
}

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

using namespace std;

string replicate(string s, int n) {
  string ret = "";
  for (int i = 0; i < n; i++) {
    ret += s;
  }
  return ret;
}

int main() {
  int a, b;
  cin >> a >> b;
  string s = replicate(to_string(a), b);
  string t = replicate(to_string(b), a);
  cout << (s < t ? s : t) << endl;
  return 0;
}
Problem p02790 (Python)

Buggy submission (status: Runtime Error):
a, b = [input() for i in range(2)]
a_array = []
for i in range(int(b)):
    a_array.append(a)
a_str = "".join(a_array)

b_array = []
for i in range(int(a)):
    b_array.append(b)
b_str = "".join(b_array)


if a_str < b_str:
    print(a_str)
elif b_str < a_str:
    print(b_str)
else:
    print(a_str)


Fixed submission:
a, b = input().split()

a_array = []
for i in range(int(b)):
    a_array.append(a)
a_str = "".join(a_array)

b_array = []
for i in range(int(a)):
    b_array.append(b)
b_str = "".join(b_array)


if a_str < b_str:
    print(a_str)
elif b_str < a_str:
    print(b_str)
else:
    print(a_str)
Problem p02790 (Python)

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

a = data[0]
b = data[1]

ans = min(a, b) * max(a, b)

print(ans)


Fixed submission:
data = input().split()

a = data[0]
b = data[1]

ans = min(a, b) * int(max(a, b))

print(ans)
Problem p02790 (Python)

Buggy submission (status: Runtime Error):
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    a, b = input_to_int_map()
    import itertools

    _a = itertools.repeat(str(a), b)
    _b = itertools.repeat(str(b), a)
    ret = _b
    if _a < _b:
        ret = _a

    return ret


if __name__ == "__main__":
    print(main())


Fixed submission:
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    a, b = input_to_int_map()
    import itertools

    _a = "".join(itertools.repeat(str(a), b))
    _b = "".join(itertools.repeat(str(b), a))
    ret = _b
    if _a < _b:
        ret = _a

    return ret


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

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

char a, b;

int main() {
  cin >> a >> b;
  int ia = atoi((const char *)a);
  int ib = atoi((const char *)b);
  if (a < b) {
    for (int i = 0; i < ib; ++i) {
      cout << a;
    }
    cout << endl;
  } else {
    for (int i = 0; i < ia; ++i) {
      cout << b;
    }
    cout << endl;
  }
}

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

char a, b;

int main() {
  cin >> a >> b;
  int ia = a - '0';
  int ib = b - '0';
  if (a < b) {
    for (int i = 0; i < ib; ++i) {
      cout << a;
    }
    cout << endl;
  } else {
    for (int i = 0; i < ia; ++i) {
      cout << b;
    }
    cout << endl;
  }
}
Problem p02790 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int p, q;
  cin >> p >> q;
  int cnt;
  if (p > q) {
    cnt = 1;
  } else if (q > p) {
    cnt = 0;
  }
  int r = q, s = p;
  for (int i = 0; i <= p; i = i * 10) {
    r = r * (10 ^ i);
  }
  for (int i = 0; i <= q; i++) {
    s = s * (10 ^ i);
  }
  if (cnt == 0) {
    cout << s << endl;
  } else if (cnt == 1) {
    cout << r << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int p, q;
  cin >> p >> q;
  if (p == q || p > q) {
    int x = 0;
    for (int i = 0; i < p; i++) {
      x = (x * 10) + q;
    }
    cout << x << endl;
  } else {
    int x = 0;
    for (int i = 0; i < q; i++) {
      x = (x * 10) + p;
    }
    cout << x << endl;
  }
}
Problem p02790 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
const ll INF = 1e18;

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
  ll int a, b;
  cin >> a >> b;
  ll int r = min(a, b), s = max(a, b);
  while (s != 0) {
    cout << r;
    s--;
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
const ll INF = 1e18;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll int a, b;
  cin >> a >> b;
  ll int r = min(a, b), s = max(a, b);
  while (s != 0) {
    cout << r;
    s--;
  }
}
Problem p02790 (C++)

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

int main() {
  string A, B;
  int i = 0, temp;
  string result;
  do {
    temp = (int)(A[i] - '0') - (int)(B[i] - '0');
    if (temp < 0)
      result = A;
    else if (temp > 0)
      result = B;
    i++;
  } while (temp == 0);

  cout << result << endl;

  return 0;
}


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

int main() {
  int a, b;
  string result = "";
  cin >> a >> b;
  if (a >= b)
    cout << result.append(a, (char)(b + '0')) << endl;
  else
    cout << result.append(b, (char)(a + '0')) << endl;

  return 0;
}
Problem p02790 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
//*************** Constraints are always Imaginary,I'm real **************
using namespace std;
#define int long long
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define fi first
#define se second
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int a, b, rep;
  string ans, who;
  cin >> a >> b;
  if (a == b) {
    rep = a, who = to_string(a);
  } else {
    who = to_string(min(a, b));
    rep = max(a, b);
  }
  for (int i = 1; i <= rep; i++) {
    ans += who;
  }
  cout << ans;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
//*************** Constraints are always Imaginary,I'm real **************
using namespace std;
#define int long long
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define fi first
#define se second
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif
  int a, b, rep;
  string ans, who;
  cin >> a >> b;
  if (a == b) {
    rep = a, who = to_string(a);
  } else {
    who = to_string(min(a, b));
    rep = max(a, b);
  }
  for (int i = 1; i <= rep; i++) {
    ans += who;
  }
  cout << ans;
  return 0;
}
Problem p02790 (C++)

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 998244353
#define boost                                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0)
#define prec(n) fixed << setprecision(n)

#define mii unordered_map<int, int>
#define mll unordered_map<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first

#define se second
#define pb push_backP
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(), c.end()
#define tr(it, c) for (it = c.begin(); it != c.end(); it++)
int inf = INT_MAX;
ll modulo(ll num, ll MOD = mod) {
  return ((num % MOD) + MOD) % MOD;
} // for negative integer
ll power(ll b, ll e, ll MOD = mod) {
  ll ans = 1;
  while (e) {
    if (e % 2)
      ans = (ans * b) % MOD;
    b = (b * b) % MOD;
    e /= 2;
  }
  return ans;
}
ll inv(ll num, ll MOD = mod) { return power(modulo(num), MOD - 2, MOD); }
ll gcd(ll a, ll b) { return ((b == 0) ? a : gcd(b, a % b)); }

int main() {
  boost;
#ifndef ONLINE_JUDGE
  freopen("D:/Disk D/Work/c++ workspace/input.txt", "r", stdin);
  freopen("D:/Disk D/Work/c++ workspace/output.txt", "w", stdout);
#endif

  int a, b;
  cin >> a >> b;
  if (a < b) {
    for (int i = 0; i < b; ++i) {
      cout << a;
    }
  } else {
    for (int i = 0; i < a; ++i) {
      cout << b;
    }
  }
  return 0;
}

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 998244353
#define boost                                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0)
#define prec(n) fixed << setprecision(n)

#define mii unordered_map<int, int>
#define mll unordered_map<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first

#define se second
#define pb push_backP
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(), c.end()
#define tr(it, c) for (it = c.begin(); it != c.end(); it++)
int inf = INT_MAX;
ll modulo(ll num, ll MOD = mod) {
  return ((num % MOD) + MOD) % MOD;
} // for negative integer
ll power(ll b, ll e, ll MOD = mod) {
  ll ans = 1;
  while (e) {
    if (e % 2)
      ans = (ans * b) % MOD;
    b = (b * b) % MOD;
    e /= 2;
  }
  return ans;
}
ll inv(ll num, ll MOD = mod) { return power(modulo(num), MOD - 2, MOD); }
ll gcd(ll a, ll b) { return ((b == 0) ? a : gcd(b, a % b)); }

int main() {
  boost;

  int a, b;
  cin >> a >> b;
  if (a < b) {
    for (int i = 0; i < b; ++i) {
      cout << a;
    }
  } else {
    for (int i = 0; i < a; ++i) {
      cout << b;
    }
  }
  return 0;
}
Problem p02791 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int n, count = 0;
  int min;
  int p[200010];
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }

  min = p[0];

  for (int i = 0; i < n; i++) {
    int flag = 1;
    if (min > p[i]) {
      min = p[i];
    }
    for (int j = 0; j <= i; j++) {
      if (p[i] > p[j] || min < p[i]) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n, count = 0;
  int min;
  int p[200010];
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }

  min = p[0];

  for (int i = 0; i < n; i++) {
    int flag = 1;
    if (min > p[i]) {
      min = p[i];
    }
    if (min < p[i]) {
      flag = 0;
    }
    if (flag) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}
Problem p02791 (C++)

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

using namespace std;
int P[100010];
int main() {
  int N, i, cnt = 0, min;
  cin >> N;
  for (i = 1; i <= N; i++) {
    cin >> P[i];
    if (min > P[i]) {
      cnt++;
      //		} else {
      min = P[i];
    }
    //		cout << i << " " << min << " " << cnt << endl;
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;
int P[330010];
int main() {
  int N, i, cnt = 0, min;
  cin >> N;
  for (i = 1; i <= N; i++) {
    cin >> P[i];
    if (min > P[i]) {
      cnt++;
      //		} else {
      min = P[i];
    }
    //		cout << i << " " << min << " " << cnt << endl;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02791 (C++)

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

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    bool flg = true;
    for (int j = 0; j < i; j++) {
      if (p[i] <= p[j]) {
        ;
      } else {
        flg = false;
        break;
      }
    }
    if (flg == true) {
      ans = ans + 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
// 152

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int ans = 1;
  int data = p[0];
  for (int i = 1; i < n; i++) {
    if (data > p[i]) {
      data = p[i];
      ans = ans + 1;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02791 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define srep(i, n, m) for (int i = n; i < m; i++)
#define elif else if
#define INF 1000000007
using namespace std;
int n, k, s, aa[110000], cnt = 0, cnta = INF;
signed main() {
  cin >> n;
  rep(i, n) {
    cin >> aa[i];
    if (cnta > aa[i]) {
      cnta = aa[i];
      cnt++;
    }
  }
  cout << cnt;
}

Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define srep(i, n, m) for (int i = n; i < m; i++)
#define elif else if
#define INF 1000000007
using namespace std;
int n, k, s, aa[220000], cnt = 0, cnta = INF;
signed main() {
  cin >> n;
  rep(i, n) {
    cin >> aa[i];
    if (cnta > aa[i]) {
      cnta = aa[i];
      cnt++;
    }
  }
  cout << cnt;
}
Problem p02791 (C++)

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

int main() {

  int n;
  cin >> n;

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

  int ans = n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (lists.at(i) >= lists.at(j)) {
        ans -= 1;
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {

  int n;
  cin >> n;

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

  int ans = 1;
  int std = lists.at(0);

  for (int i = 1; i < n; i++) {
    if (lists.at(i) < std) {
      ans += 1;
      std = lists.at(i);
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p02791 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int n, p[100000], mini[100000], ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  mini[0] = p[0];
  for (int i = 1; i < n; i++) {
    mini[i] = min(mini[i - 1], p[i]);
  }
  for (int i = 0; i < n; i++) {
    if (mini[i] == p[i]) {
      ans++;
    }
  }
  printf("%d\n", ans);
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int n, p[200000], mini[200000], ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  mini[0] = p[0];
  for (int i = 1; i < n; i++) {
    mini[i] = min(mini[i - 1], p[i]);
  }
  for (int i = 0; i < n; i++) {
    if (mini[i] == p[i]) {
      ans++;
    }
  }
  printf("%d\n", ans);
}
Problem p02791 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int main() {
  int n, x, ans = 1, ma;
  cin >> n;
  for (int i = 0; i < n; i++)
    scanf("%d", a + i);
  ma = a[0];
  for (int i = 1; i < n; i++) {
    ma = min(ma, a[i]);
    if (a[i] <= ma)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N];
int main() {
  int n, x, ans = 1, ma;
  cin >> n;
  for (int i = 0; i < n; i++)
    scanf("%d", a + i);
  ma = a[0];
  for (int i = 1; i < n; i++) {
    ma = min(ma, a[i]);
    if (a[i] <= ma)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02791 (C++)

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

#define rep(i, c) for (int i = 0; i < (int)c; ++i)
using llint = long long int;
using namespace std;

int main() {
  int N;
  int P[100005];
  cin >> N;
  rep(i, N) cin >> P[i];

  int count = 0;
  int m = P[0];
  rep(i, N) {
    if (m >= P[i])
      count++;
    m = min(m, P[i]);
  }
  cout << count << endl;
  return 0;
}

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

#define rep(i, c) for (int i = 0; i < (int)c; ++i)
using llint = long long int;
using namespace std;

int main() {
  int N;
  int P[200005];
  cin >> N;
  rep(i, N) cin >> P[i];

  int count = 0;
  int m = P[0];
  rep(i, N) {
    if (m >= P[i])
      count++;
    m = min(m, P[i]);
  }
  cout << count << endl;
  return 0;
}
Problem p02791 (C++)

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

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

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

  int ans = 0;
  int currentMin = 1e9;
  for (int i = 0; i < N; ++i) {
    currentMin = min(currentMin, P.at(i));
    if (currentMin == P.at(i)) {
      ans++;
    }
  }

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

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

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

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

  int ans = 0;
  int currentMin = 1e9;
  for (int i = 0; i < N; ++i) {
    currentMin = min(currentMin, P.at(i));
    if (currentMin == P.at(i)) {
      ans++;
    }
  }

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

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

using namespace std;

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

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

  int count = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= i; j++) {
      if (p[i] > p[j])
        break;
      if (j == i)
        count++;
    }

  cout << count;
}


Fixed submission:
#include <iostream>

using namespace std;

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

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

  int count = 1;
  int min = p[0];
  for (int i = 1; i < n; i++)
    if (p[i] < min) {
      min = p[i];
      count++;
    }

  cout << count;
}
Problem p02791 (C++)

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

int main() {
  int N;
  int P[120000];
  int i;
  int ans = 0;
  int min = 0;

  cin >> N;

  for (i = 0; i < N; i++)
    cin >> P[i];

  min = P[0];

  for (i = 0; i < N; i++) {
    if (P[i] <= min) {
      min = P[i];
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N;
  int P[240000];
  int i;
  int ans = 0;
  int min = 0;

  cin >> N;

  for (i = 0; i < N; i++)
    cin >> P[i];

  min = P[0];

  for (i = 0; i < N; i++) {
    if (P[i] <= min) {
      min = P[i];
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}