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

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

using int64 = long long;

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

  vector<int64> x(N), y(N);
  int64 rmax = 0, rmin = (1LL << 40), bmax = 0, bmin = (1LL << 40);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
    rmax = max(rmax, max(x[i], y[i]));
    rmin = min(rmin, max(x[i], y[i]));
    bmax = max(bmax, min(x[i], y[i]));
    bmin = min(bmin, min(x[i], y[i]));
  }

  int64 ans = (rmax - rmin) * (bmax - bmin);

  rmin = min(rmin, bmin);

  set<pair<int64, int>> st;
  for (int i = 0; i < N; i++)
    st.insert({min(x[i], y[i]), i});
  while (!st.empty()) {
    int64 diff = st.rbegin()->first - st.begin()->first;
    ans = min(ans, (rmax - rmin) * diff);

    auto elt = *st.begin();
    if (elt.second >= 364364)
      break;
    st.insert({max(x[elt.second], y[elt.second]), 364364});
  }
  cout << ans << endl;

  return 0;
}

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

using int64 = long long;

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

  vector<int64> x(N), y(N);
  int64 rmax = 0, rmin = (1LL << 40), bmax = 0, bmin = (1LL << 40);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
    rmax = max(rmax, max(x[i], y[i]));
    rmin = min(rmin, max(x[i], y[i]));
    bmax = max(bmax, min(x[i], y[i]));
    bmin = min(bmin, min(x[i], y[i]));
  }

  int64 ans = (rmax - rmin) * (bmax - bmin);

  rmin = min(rmin, bmin);

  set<pair<int64, int>> st;
  for (int i = 0; i < N; i++)
    st.insert({min(x[i], y[i]), i});
  while (!st.empty()) {
    int64 diff = st.rbegin()->first - st.begin()->first;
    ans = min(ans, (rmax - rmin) * diff);

    auto elt = *st.begin();
    if (elt.second >= 364364)
      break;
    st.insert({max(x[elt.second], y[elt.second]), 364364});

    st.erase(elt);
  }
  cout << ans << endl;

  return 0;
}
Problem p03735 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 9;

int n, h[N], t, S, Sa[N], Sb[N], i, j, Ta[N], Tb[N];
long long ans = 8e18;

struct pa {
  int a, b;
} p[N];
bool operator<(const pa &A, const pa &B) { return A.a < B.a; }

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d%d", &p[i].a, &p[i].b), h[++t] = p[i].a, h[++t] = p[i].b;
  sort(h + 1, h + t + 1);
  S = t = unique(h + 1, h + t + 1) - h - 1;
  for (i = 1; i <= n; ++i) {
    if (p[i].a > p[i].b)
      p[i].a ^= p[i].b ^= p[i].a ^= p[i].b;
    p[i].a = lower_bound(h + 1, h + t + 1, p[i].a) - h;
    p[i].b = lower_bound(h + 1, h + t + 1, p[i].b) - h;
    S = min(S, max(p[i].a, p[i].b));
  }
  sort(p + 1, p + n + 1);
  for (Sa[S + 1] = t, i = S, j = n; i; --i)
    for (Sa[i] = Sa[i + 1], Ta[i] = Ta[i + 1]; j && p[j].a >= i; --j) {
      if (p[j].b < Sa[i])
        Sa[i] = p[j].b;
      if (p[j].a > Ta[i])
        Ta[i] = p[j].a;
    }
  for (Sb[0] = t, i = 1, j = 1; i <= S; ++i) {
    for (Sb[i] = Sb[i - 1], Tb[i] = Tb[i - 1]; j <= n && p[j].a < i; ++j) {
      if (p[j].a < Sb[i])
        Sb[i] = p[j].a;
      if (p[j].b > Tb[i])
        Tb[i] = p[j].b;
    }
    if (1ll * (h[t] - h[min(Sb[i], Sa[i])]) * (h[max(Ta[i], Tb[i])] - h[i]) <
        ans)
      ans = 1ll * (h[t] - h[min(Sb[i], Sa[i])]) * (h[max(Ta[i], Tb[i])] - h[i]);
  }
  printf("%lld", ans);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 9;

int n, h[N], t, S, Sa[N], Sb[N], i, j, Ta[N], Tb[N];
long long ans = 8e18;

struct pa {
  int a, b;
} p[N];
bool operator<(const pa &A, const pa &B) { return A.a < B.a; }

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d%d", &p[i].a, &p[i].b), h[++t] = p[i].a, h[++t] = p[i].b;
  sort(h + 1, h + t + 1);
  S = t = unique(h + 1, h + t + 1) - h - 1;
  for (i = 1; i <= n; ++i) {
    if (p[i].a > p[i].b)
      p[i].a ^= p[i].b ^= p[i].a ^= p[i].b;
    p[i].a = lower_bound(h + 1, h + t + 1, p[i].a) - h;
    p[i].b = lower_bound(h + 1, h + t + 1, p[i].b) - h;
    S = min(S, max(p[i].a, p[i].b));
  }
  sort(p + 1, p + n + 1);
  for (Sa[S + 1] = t, i = S, j = n; i; --i)
    for (Sa[i] = Sa[i + 1], Ta[i] = Ta[i + 1]; j && p[j].a >= i; --j) {
      if (p[j].b < Sa[i])
        Sa[i] = p[j].b;
      if (p[j].a > Ta[i])
        Ta[i] = p[j].a;
    }
  for (Sb[0] = t, i = 1, j = 1; i <= S; ++i) {
    for (Sb[i] = Sb[i - 1], Tb[i] = Tb[i - 1]; j <= n && p[j].a < i; ++j) {
      if (p[j].a < Sb[i])
        Sb[i] = p[j].a;
      if (p[j].b > Tb[i])
        Tb[i] = p[j].b;
    }
    if (1ll * (h[t] - h[min(Sb[i], Sa[i])]) * (h[max(Ta[i], Tb[i])] - h[i]) <
        ans)
      ans = 1ll * (h[t] - h[min(Sb[i], Sa[i])]) * (h[max(Ta[i], Tb[i])] - h[i]);
  }
  printf("%lld", ans);
  return 0;
}
Problem p03735 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a), i##_end = (b); i <= i##_end; i++)
#define per(i, b, a) for (int i = (b), i##_st = (a); i >= i##_st; i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x " = " << x << endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x, i) for (Edge *i = G[x]; i; i = i->nex)
typedef pair<int, int> pii;
typedef long long ll;
const int inf = ~0u >> 1, MOD = 1e9 + 7; /*
          char *TT,*mo,but[(1<<15)+2];
          #define getchar()
          ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int rd() {
  int x = 0, c = 0, f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    f = c != '-';
  for (; c >= '0' && c <= '9'; c = getchar())
    x = x * 10 + c - '0';
  return f ? x : -x;
}
const int N = 1e5 + 11;
int n;
pii p[N];
int main() {
  n = rd();
  int mx = -inf, mi = inf;
  rep(i, 1, n) {
    p[i].x = rd();
    p[i].y = rd();
    if (p[i].x > p[i].y)
      swap(p[i].x, p[i].y);
    mx = max(mx, p[i].y);
    mi = min(mi, p[i].y);
  }
  sort(p + 1, p + n + 1);
  ll ans = 1LL * (mx - mi) * (p[n].x - p[1].x);
  int mii, mxx;
  mxx = mii = p[1].y;
  rep(i, 2, n) {
    ll tmp = 1LL * (mx - p[1].x) * (max(mxx, p[n].x) - min(mii, p[i].x));
    ans = min(ans, tmp);
    mxx = max(mxx, p[i].y);
    mii = min(mii, p[i].y);
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a), i##_end = (b); i <= i##_end; i++)
#define per(i, b, a) for (int i = (b), i##_st = (a); i >= i##_st; i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x " = " << x << endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x, i) for (Edge *i = G[x]; i; i = i->nex)
typedef pair<int, int> pii;
typedef long long ll;
const int inf = ~0u >> 1, MOD = 1e9 + 7; /*
          char *TT,*mo,but[(1<<15)+2];
          #define getchar()
          ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int rd() {
  int x = 0, c = 0, f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    f = c != '-';
  for (; c >= '0' && c <= '9'; c = getchar())
    x = x * 10 + c - '0';
  return f ? x : -x;
}
const int N = 2e5 + 11;
int n;
pii p[N];
int main() {
  n = rd();
  int mx = -inf, mi = inf;
  rep(i, 1, n) {
    p[i].x = rd();
    p[i].y = rd();
    if (p[i].x > p[i].y)
      swap(p[i].x, p[i].y);
    mx = max(mx, p[i].y);
    mi = min(mi, p[i].y);
  }
  sort(p + 1, p + n + 1);
  ll ans = 1LL * (mx - mi) * (p[n].x - p[1].x);
  int mii, mxx;
  mxx = mii = p[1].y;
  rep(i, 2, n) {
    ll tmp = 1LL * (mx - p[1].x) * (max(mxx, p[n].x) - min(mii, p[i].x));
    ans = min(ans, tmp);
    mxx = max(mxx, p[i].y);
    mii = min(mii, p[i].y);
  }
  cout << ans << endl;
}
Problem p03735 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

const int maxN = 2e5 + 10;

struct TBag {
  int x, y;

  bool operator<(const TBag &t) const { return x < t.x; }
};

int n;
int x[maxN], y[maxN];
set<int> r, b;
TBag a[maxN];

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    if (x > y)
      swap(x, y);
    a[i] = {x, y};
    r.insert(x);
    b.insert(y);
  }

  sort(a + 1, a + n + 1);

  int res = (*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin());

  for (int i = 1; i <= n; ++i) {
    int x = a[i].x;
    int y = a[i].y;
    r.erase(r.find(x));
    b.insert(x);
    b.erase(b.find(y));
    r.insert(y);
    res = min(res, (*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()));
  }

  cout << res;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

const int maxN = 2e5 + 10;

struct TBag {
  int x, y;

  bool operator<(const TBag &t) const { return x < t.x; }
};

int n;
int x[maxN], y[maxN];
multiset<int> r, b;
TBag a[maxN];

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    if (x > y)
      swap(x, y);
    a[i] = {x, y};
    r.insert(x);
    b.insert(y);
  }

  sort(a + 1, a + n + 1);

  int res = (*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin());

  for (int i = 1; i <= n; ++i) {
    int x = a[i].x;
    int y = a[i].y;
    r.erase(r.find(x));
    b.insert(x);
    b.erase(b.find(y));
    r.insert(y);
    res = min(res, (*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()));
  }

  cout << res;
  return 0;
}
Problem p03735 (C++)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MX = 105;
const int MM = 1000000007;

int N, a, b;
int rl = 1e9, rr, bl = 1e9, br;
pii D[MX];

ll solve() {
  sort(D + 1, D + N + 1);
  int mx = 1;
  for (int i = 2; i <= N; i++)
    if (D[mx].second < D[i].second)
      mx = i;
  if (1 == mx)
    return 2e18;
  swap(D[mx], D[2]);
  sort(D + 3, D + N + 1);
  multiset<int> L;
  L.insert(D[1].second);
  L.insert(D[2].first);
  ll mn = 2e18;
  for (int i = 3; i <= N; i++) {
    L.insert(D[i].first);
  }
  mn = min(mn, (ll)*L.rbegin() - *L.begin());
  for (int i = 3; i <= N; i++) {
    L.erase(L.find(D[i].first));
    L.insert(D[i].second);
    mn = min(mn, (ll)*L.rbegin() - *L.begin());
  }
  return mn * (D[2].second - D[1].first);
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d%d", &a, &b);
    if (a > b)
      swap(a, b);
    D[i] = pii(a, b);

    rl = min(rl, a);
    rr = max(rr, a);
    bl = min(bl, b);
    br = max(br, b);
  }
  printf("%lld\n", min(solve(), (ll)(rr - rl) * (br - bl)));
}


Fixed submission:
#include <algorithm>
#include <set>
#include <stdio.h>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MX = 200005;
const int MM = 1000000007;

int N, a, b;
int rl = 1e9, rr, bl = 1e9, br;
pii D[MX];

ll solve() {
  sort(D + 1, D + N + 1);
  int mx = 1;
  for (int i = 2; i <= N; i++)
    if (D[mx].second < D[i].second)
      mx = i;
  if (1 == mx)
    return 2e18;
  swap(D[mx], D[2]);
  sort(D + 3, D + N + 1);
  multiset<int> L;
  L.insert(D[1].second);
  L.insert(D[2].first);
  ll mn = 2e18;
  for (int i = 3; i <= N; i++) {
    L.insert(D[i].first);
  }
  mn = min(mn, (ll)*L.rbegin() - *L.begin());
  for (int i = 3; i <= N; i++) {
    L.erase(L.find(D[i].first));
    L.insert(D[i].second);
    mn = min(mn, (ll)*L.rbegin() - *L.begin());
  }
  return mn * (D[2].second - D[1].first);
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d%d", &a, &b);
    if (a > b)
      swap(a, b);
    D[i] = pii(a, b);

    rl = min(rl, a);
    rr = max(rr, a);
    bl = min(bl, b);
    br = max(br, b);
  }
  printf("%lld\n", min(solve(), (ll)(rr - rl) * (br - bl)));
}
Problem p03736 (C++)

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

typedef long long ll;

int N, N_, A, B, Q;
int X[200010];
ll INF = 1001001001001001001;
ll seg[2][400010];

void init() {
  N_ = 1;
  while (N_ <= N)
    N_ *= 2;
  for (int i = 0; i < N_ * 2 - 1; i++)
    seg[0][i] = seg[1][i] = INF;
  return;
}

void update(int t, int p, ll x) {
  p += N_ - 1;
  seg[t][p] = min(seg[t][p], x);
  while (p) {
    p = (p - 1) / 2;
    seg[t][p] = min(seg[t][p * 2 + 1], seg[t][p * 2 + 2]);
  }
  return;
}

ll get_min(int t, int a, int b, int k = 0, int l = 0, int r = N_) {
  if (b <= l || r <= a)
    return INF;
  if (a <= l && r <= b)
    return seg[t][k];
  ll L = get_min(t, a, b, k * 2 + 1, l, (l + r) / 2);
  ll R = get_min(t, a, b, k * 2 + 2, (l + r) / 2, r);
  return min(L, R);
}

ll unit() {
  ll ans = INF, mem = 0;
  for (int i = 1; i <= Q; i++) {
    ll L = get_min(0, 0, X[i]) + X[i], R = get_min(1, X[i], N) - X[i];
    ll res = min(L, R) - abs(X[i] - X[i - 1]);
    update(0, X[i - 1], res - X[i - 1]);
    update(1, X[i - 1], res + X[i - 1]);
    mem += abs(X[i] - X[i - 1]);
  }
  for (int i = 0; i < N; i++)
    ans = min(ans, get_min(0, i, i + 1) + i);
  return ans + mem;
}

int main() {
  scanf("%d%d%d%d", &N, &Q, &A, &B);
  A--;
  B--;
  for (int i = 1; i <= Q; i++)
    scanf("%d", X + i), X[i]--;
  ll ans = INF;

  init();
  X[0] = B;
  update(0, A, -A);
  update(1, A, A);
  ans = unit();

  init();
  X[0] = A;
  update(0, B, -B);
  update(1, B, B);
  ans = min(ans, unit());

  printf("%lld\n", ans);
  return 0;
}


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

typedef long long ll;

int N, N_, A, B, Q;
int X[200010];
ll INF = 1001001001001001001;
ll seg[2][800010];

void init() {
  N_ = 1;
  while (N_ <= N)
    N_ *= 2;
  for (int i = 0; i < N_ * 2 - 1; i++)
    seg[0][i] = seg[1][i] = INF;
  return;
}

void update(int t, int p, ll x) {
  p += N_ - 1;
  seg[t][p] = min(seg[t][p], x);
  while (p) {
    p = (p - 1) / 2;
    seg[t][p] = min(seg[t][p * 2 + 1], seg[t][p * 2 + 2]);
  }
  return;
}

ll get_min(int t, int a, int b, int k = 0, int l = 0, int r = N_) {
  if (b <= l || r <= a)
    return INF;
  if (a <= l && r <= b)
    return seg[t][k];
  ll L = get_min(t, a, b, k * 2 + 1, l, (l + r) / 2);
  ll R = get_min(t, a, b, k * 2 + 2, (l + r) / 2, r);
  return min(L, R);
}

ll unit() {
  ll ans = INF, mem = 0;
  for (int i = 1; i <= Q; i++) {
    ll L = get_min(0, 0, X[i]) + X[i], R = get_min(1, X[i], N) - X[i];
    ll res = min(L, R) - abs(X[i] - X[i - 1]);
    update(0, X[i - 1], res - X[i - 1]);
    update(1, X[i - 1], res + X[i - 1]);
    mem += abs(X[i] - X[i - 1]);
  }
  for (int i = 0; i < N; i++)
    ans = min(ans, get_min(0, i, i + 1) + i);
  return ans + mem;
}

int main() {
  scanf("%d%d%d%d", &N, &Q, &A, &B);
  A--;
  B--;
  for (int i = 1; i <= Q; i++)
    scanf("%d", X + i), X[i]--;
  ll ans = INF;

  init();
  X[0] = B;
  update(0, A, -A);
  update(1, A, A);
  ans = unit();

  init();
  X[0] = A;
  update(0, B, -B);
  update(1, B, B);
  ans = min(ans, unit());

  printf("%lld\n", ans);
  return 0;
}
Problem p03736 (C++)

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

using namespace std;
typedef long long LL;
const LL inf = 0x3f3f3f3f3f3f3f3fll;
const int MX = 200005;
int n, m, x, y;
LL ad, f[MX], ans;
LL f1[MX], f2[MX];
void add1(int x, LL k) {
  for (; x <= n && k < f1[x]; x += x & -x)
    f1[x] = k;
}
LL que1(int x) {
  LL k = inf;
  for (; x; x -= x & -x)
    k = min(k, f1[x]);
  return k;
}
void add2(int x, LL k) {
  for (; x && k < f2[x]; x -= x & -x)
    f2[x] = k;
}
LL que2(int x) {
  LL k = inf;
  for (; x <= n; x += x & -x)
    k = min(k, f2[x]);
  return k;
}
void wk() {
  y = x, cin >> x;
  LL v = min(que1(x) + x, que2(x) - x) + ad;
  ad += abs(x - y);
  if (v - ad < f[y])
    f[y] = v - ad, add1(y, f[y] - y), add2(y, f[y] + y);
}
int main() {
  int i;
  cin >> n >> m >> x >> y;
  for (i = 1; i <= n; i++)
    f[i] = f1[i] = f2[i] = inf;
  for (i = 1, f[y] = 0, add1(y, -y), add2(y, y); i <= m;)
    wk();
  for (ans = inf, i = 1; i <= n; i++)
    ans = min(ans, f[i]);
  cout << ans + ad << endl;
  return 0;
}

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

using namespace std;
typedef long long LL;
const LL inf = 0x3f3f3f3f3f3f3f3fll;
const int MX = 200005;
int n, m, x, y;
LL ad, f[MX], ans;
LL f1[MX], f2[MX];
void add1(int x, LL k) {
  for (; x <= n && k < f1[x]; x += x & -x)
    f1[x] = k;
}
LL que1(int x) {
  LL k = inf;
  for (; x; x -= x & -x)
    k = min(k, f1[x]);
  return k;
}
void add2(int x, LL k) {
  for (; x && k < f2[x]; x -= x & -x)
    f2[x] = k;
}
LL que2(int x) {
  LL k = inf;
  for (; x <= n; x += x & -x)
    k = min(k, f2[x]);
  return k;
}
void wk() {
  y = x, cin >> x;
  LL v = min(que1(x) + x, que2(x) - x) + ad;
  ad += abs(x - y);
  if (v - ad < f[y])
    f[y] = v - ad, add1(y, f[y] - y), add2(y, f[y] + y);
}
int main() {
  int i;
  cin >> n >> m >> x >> y;
  for (i = 1; i <= n; i++)
    f[i] = f1[i] = f2[i] = inf;
  for (f[y] = 0, add1(y, -y), add2(y, y); m--;)
    wk();
  for (ans = inf, i = 1; i <= n; i++)
    ans = min(ans, f[i]);
  cout << ans + ad << endl;
  return 0;
}
Problem p03737 (C++)

Buggy submission (status: Runtime Error):
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
  char dif = 'A' - 'a';
  str a, b, c;
  cout << a[0 + dif] << b[0 + dif] << c[0 + dif] << endl;
}


Fixed submission:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
  char dif = 'A' - 'a';
  str a, b, c;
  cin >> a >> b >> c;
  printf("%c%c%c\n", a[0] + dif, b[0] + dif, c[0] + dif);
  return 0;
}
Problem p03737 (Python)

Buggy submission (status: Runtime Error):
print(str.upper(input()[0]) + str.upper(input()[0]) + str.upper(input()[0]))


Fixed submission:
s1, s2, s3 = input().split()
print(str.upper(s1[0] + s2[0] + s3[0]))
Problem p03737 (C++)

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

int main() {
  vector<string> s;
  cin >> s[0] >> s[1] >> s[2];
  for (int i = 0; i < 3; i++)
    transform(s[i].begin(), s[i].end(), s[i].begin(), ::toupper);
  for (int i = 0; i < 3; i++)
    cout << s[i][0];
  return 0;
}

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  string ans;
  ans += a[0];
  ans += b[0];
  ans += c[0];
  transform(ans.begin(), ans.end(), ans.begin(), ::toupper);
  cout << ans << endl;
}
Problem p03737 (C++)

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

int abs(int num) {
  if (num > 0)
    return num;
  else
    return -num;
}

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  string ans;
  ans.at(0) = A.at(0) + 32;
  ans.at(1) = B.at(0) + 32;
  ans.at(2) = C.at(0) + 32;
  cout << ans << endl;
}

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

int abs(int num) {
  if (num > 0)
    return num;
  else
    return -num;
}

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  string ans = "AAA";
  ans.at(0) = A.at(0) - 32;
  ans.at(1) = B.at(0) - 32;
  ans.at(2) = C.at(0) - 32;
  cout << ans << endl;
}
Problem p03737 (C++)

Buggy submission (status: Runtime Error):
/******* all required header files *******/
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;

/*****All definitions*******/
#define w(t)                                                                   \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define mp make_pair
#define ll long long int
#define pb push_back
#define F first
#define S second
/***************************/

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

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

  string str1, str2, str3;
  cin >> str1 >> str2 >> str3;

  char a, b, c;
  a = str1[0];
  b = str2[0];
  c = str3[0];

  a = a ^ 32;
  b = b ^ 32;
  c = c ^ 32;

  cout << a << b << c;

  return 0;
}


Fixed submission:
/******* all required header files *******/
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;

/*****All definitions*******/
#define w(t)                                                                   \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define mp make_pair
#define ll long long int
#define pb push_back
#define F first
#define S second
/***************************/

int main() {
  /*#ifndef ONLINE_JUDGE
          freopen("input.txt", "r", stdin);
          freopen("output.txt", "w", stdout);
  #endif*/

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

  string str1, str2, str3;
  cin >> str1 >> str2 >> str3;

  char a, b, c;
  a = str1[0];
  b = str2[0];
  c = str3[0];

  a = a ^ 32;
  b = b ^ 32;
  c = c ^ 32;

  cout << a << b << c;

  return 0;
}
Problem p03737 (C++)

Buggy submission (status: Runtime Error):
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; (i) < (n); (i)++)
#define ll long long

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

  printf("%s%s%s", a[0] - 'a' + 'A', b[0] - 'a' + 'A', c[0] - 'a' + 'A');
  return 0;
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; (i) < (n); (i)++)
#define ll long long

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

  printf("%c%c%c", a[0] - 'a' + 'A', b[0] - 'a' + 'A', c[0] - 'a' + 'A');
  return 0;
}
Problem p03737 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main(void) {
  char s1[10];
  char s2[10];
  char s3[10];
  scanf("%s %s %s", s1, s2, s3);
  printf("%c %c %c", s1[0], s2[0], s3[0]);
}


Fixed submission:
#include <stdio.h>
int main(void) {
  char S1[11];
  char S2[11];
  char S3[11];
  scanf("%s %s %s", S1, S2, S3);
  printf("%c%c%c", S1[0] - 0x20, S2[0] - 0x20, S3[0] - 0x20);
  return 0;
}
Problem p03737 (C++)

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

int main() {
  std::string s1, s2, s3;
  std::cin >> s1 >> s2 >> s3;
  std::cout << s1.at(1) + 32 << s2.at(1) + 32 << s3.at(1) + 32;
  return 0;
}

Fixed submission:
#include <iostream>

int main() {
  std::string s1, s2, s3;
  std::cin >> s1 >> s2 >> s3;
  char x = s1.at(0) - 32, y = s2.at(0) - 32, z = s3.at(0) - 32;
  std::cout << x << y << z;
  return 0;
}
Problem p03737 (C++)

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

using namespace std;

int main() {
  string a, b, c;

  cin >> a >> b >> c;

  transform(a.begin(), b.begin(), c.begin(), ::toupper);

  cout << a[0] << b[0] << c[0] << endl;
  return 0;
}


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

using namespace std;

int main() {
  string a, b, c;

  cin >> a >> b >> c;
  transform(a.begin(), a.end(), a.begin(), ::toupper);
  transform(b.begin(), b.end(), b.begin(), ::toupper);
  transform(c.begin(), c.end(), c.begin(), ::toupper);

  cout << a[0] << b[0] << c[0] << endl;
  return 0;
}
Problem p03737 (C++)

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << a.at(0) - 0x20 << b.at(0) - 0x20 << c.at(0 - 0x20) << endl;
}


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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  char a1 = a.at(0) - 0x20;
  char b1 = b.at(0) - 0x20;
  char c1 = c.at(0) - 0x20;
  cout << a1 << b1 << c1 << endl;
}
Problem p03737 (C++)

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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  string result = s1.substr(0, 1) + s2.substr(1, 1) + s3.substr(2, 1);

  transform(result.begin(), result.end(), result.begin(), ::toupper);
  cout << result;
  cout << endl;

  return 0;
}

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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  string result = s1.substr(0, 1) + s2.substr(0, 1) + s3.substr(0, 1);

  transform(result.begin(), result.end(), result.begin(), ::toupper);
  cout << result;
  cout << endl;

  return 0;
}
Problem p03737 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  int y;
  cin >> y;
  data.at(0) = y;
  for (int i = 1; i < N; i++) {
    int x;
    cin >> x;
    data.at(i) = data.at(i - 1) + x;
  }
  int64_t sei_ans = 0;
  int64_t hu_ans = 0;
  int zyoutai = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      int a = max(0, 1 - data.at(i) - zyoutai);
      zyoutai += a;
      sei_ans += a;
    } else {
      int a = max(0, 1 + data.at(i) + zyoutai);
      zyoutai -= a;
      sei_ans += a;
    }
  }
  zyoutai = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 != 0) {
      int a = max(0, 1 - data.at(i) - zyoutai);
      zyoutai += a;
      hu_ans += a;
    } else {
      int a = max(0, 1 + data.at(i) + zyoutai);
      zyoutai -= a;
      hu_ans += a;
    }
  }
  cout << min(sei_ans, hu_ans) << endl;
}


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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << char(s1.at(0) - 32) << char(s2.at(0) - 32) << char(s3.at(0) - 32)
       << endl;
}
Problem p03737 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  for (;;) {
    string a, b, c;
    vector<string> v;
    cin >> a;
    v.push_back(a);
    cin >> b;
    v.push_back(b);
    cin >> c;
    v.push_back(c);
    printf("%c%c%c\n", a[0] - 32, b[0] - 32, c[0] - 32);
    v.clear();
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b, c;
  while (cin >> a >> b >> c) {
    string s;
    s += a[0] - 32;
    s += b[0] - 32;
    s += c[0] - 32;
    cout << s << endl;
  }
  return 0;
}
Problem p03738 (Python)

Buggy submission (status: Runtime Error):
a, b = map(int, input().split())

if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
else:
    print("EQUAL")


Fixed submission:
a = int(input())
b = int(input())

if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
else:
    print("EQUAL")
Problem p03738 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stdlib.h>
#include <string>

using namespace std;

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

  if (a.size() < b.size())
    printf("LESS");
  else if (a.size() > b.size())
    printf("GREATER");
  else if (a.size() == b.size()) {
    if (a == b) {
      printf("EQUAL");
    } else {
      if (stof(a) > stof(b)) {
        printf("GREATER");
      } else if (stof(a) < stof(b)) {
        printf("LESS");
      }
    }
  }

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stdlib.h>
#include <string>

using namespace std;

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

  if (a.size() < b.size())
    printf("LESS");
  else if (a.size() > b.size())
    printf("GREATER");
  else if (a.size() == b.size()) {
    if (a == b) {
      printf("EQUAL");
    } else {
      for (int i = 0; i < a.size(); i++) {
        if (a[i] > b[i]) {
          printf("GREATER");
          break;
        } else if (a[i] < b[i]) {
          printf("LESS");
          break;
        } else if (a[i] == b[i]) {
          i++;
        }
      }
    }
  }

  return 0;
}
Problem p03738 (Python)

Buggy submission (status: Runtime Error):
a, b = map(int, input().split())

if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
elif a == b:
    print("EQUAL")


Fixed submission:
a = int(input())
b = int(input())

if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
elif a == b:
    print("EQUAL")
Problem p03738 (Python)

Buggy submission (status: Runtime Error):
a, b = map(int, input().split())
print("GREATER" if a > b else "LESS" if a < b else "EQUAL")


Fixed submission:
a, b = [int(input()) for _ in range(2)]
print("GREATER" if a > b else "LESS" if a < b else "EQUAL")
Problem p03738 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i, a, b) for (int i = a, almo5t = b; i < almo5t; ++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN                                                                    \
  std::ios_base::sync_with_stdio(false);                                       \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main() {
  FIN;
#ifndef ONLINE_JUDGE
  freopen("../in.txt", "r", stdin);
  freopen("../out.txt", "w", stdout);
#endif
  string a, b;
  cin >> a >> b;
  int sA = SZ(a);
  int sB = SZ(b);
  if (a == b) {
    cout << "EQUAL";
  } else if (sA > sB) {
    cout << "GREATER";
  } else if (sA < sB) {
    cout << "LESS";
  } else {
    for (int i = 0; i <= sA; i++) {
      if (a[i] > b[i]) {
        cout << "GREATER";
        break;
      } else if (a[i] < b[i]) {
        cout << "LESS";
        break;
      }
    }
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i, a, b) for (int i = a, almo5t = b; i < almo5t; ++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN                                                                    \
  std::ios_base::sync_with_stdio(false);                                       \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  int sA = SZ(a);
  int sB = SZ(b);
  if (a == b) {
    cout << "EQUAL";
  } else if (sA > sB) {
    cout << "GREATER";
  } else if (sA < sB) {
    cout << "LESS";
  } else {
    for (int i = 0; i <= sA; i++) {
      if (a[i] > b[i]) {
        cout << "GREATER";
        break;
      } else if (a[i] < b[i]) {
        cout << "LESS";
        break;
      }
    }
  }
  return 0;
}
Problem p03738 (Python)

Buggy submission (status: Runtime Error):
a, b = map(int, input().split())
print("GREATER" if a > b else "LESS" if a < b else "EQUAL")


Fixed submission:
a = int(input())
b = int(input())
print("GREATER" if a > b else "LESS" if a < b else "EQUAL")
Problem p03738 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  string A, B;
  cin >> A >> B;
  for (int i = 0; i < B.size() - A.size(); i++)
    A.insert(0, "0");
  for (int i = 0; i < A.size() - B.size(); i++)
    B.insert(0, "0");
  if (A > B)
    cout << "GREATER";
  else if (A < B)
    cout << "LESS";
  else
    cout << "EQUAL";
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  string A, B;
  cin >> A >> B;
  int diff = A.size() - B.size();
  string z = "";
  for (int i = 0; i < abs(diff); i++)
    z += "0";
  if (diff < 0)
    A = z + A;
  else if (diff > 0)
    B = z + B;
  if (A > B)
    cout << "GREATER";
  else if (A < B)
    cout << "LESS";
  else
    cout << "EQUAL";
}
Problem p03738 (C++)

Buggy submission (status: Runtime Error):
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define clr(a) memset(a, 0, sizeof(a))
#define mem(a, b) memset(a, b, sizeof(a))
#define fastIO ios::sync_with_stdio(false)
#define rep(i, n) for (int i = 0; i < n; i++)
#define dep(i, n) for (int i = n - 1; i >= 0; i--)
#define mp make_pair
#define all(a) a.begin(), a.end()
#define sqr (x)(x * x)
#define ang(a, b, c) acos((sqr(b) + sqr(c) - sqr(a)) / (2.0 * b * c))
#define dist(x1, y1, x2, y2) sqrt(sqr(x1 - x2) + sqr(y1 - y2))
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define PI 3.1415926535897932385
#define inf 1000000000
#define eps 1e-7
#define mod 1000000007
#define N 1002

int main() {
#ifndef ONLINE_JUDGE
  freopen("in.in", "r", stdin);
  freopen("out.out", "w", stdout);
#endif
  fastIO;
  string a, b;
  cin >> a >> b;
  if (a.size() > b.size())
    cout << "GREATER" << endl;
  else if (b.size() > a.size())
    cout << "LESS" << endl;
  else {
    int i;
    for (i = 0; i < a.size(); i++) {
      if (a[i] == b[i])
        continue;
      if (a[i] > b[i]) {
        cout << "GREATER" << endl;
        break;
      } else {
        cout << "LESS" << endl;
        break;
      }
    }
    if (i == a.size())
      cout << "EQUAL" << endl;
  }
  return 0;
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define clr(a) memset(a, 0, sizeof(a))
#define mem(a, b) memset(a, b, sizeof(a))
#define fastIO ios::sync_with_stdio(false)
#define rep(i, n) for (int i = 0; i < n; i++)
#define dep(i, n) for (int i = n - 1; i >= 0; i--)
#define mp make_pair
#define all(a) a.begin(), a.end()
#define sqr (x)(x * x)
#define ang(a, b, c) acos((sqr(b) + sqr(c) - sqr(a)) / (2.0 * b * c))
#define dist(x1, y1, x2, y2) sqrt(sqr(x1 - x2) + sqr(y1 - y2))
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define PI 3.1415926535897932385
#define inf 1000000000
#define eps 1e-7
#define mod 1000000007
#define N 1002

int main() {
  // #ifndef ONLINE_JUDGE
  //	freopen("in.in", "r", stdin);
  //	freopen("out.out", "w", stdout);
  // #endif
  fastIO;
  string a, b;
  cin >> a >> b;
  if (a.size() > b.size())
    cout << "GREATER" << endl;
  else if (b.size() > a.size())
    cout << "LESS" << endl;
  else {
    int i;
    for (i = 0; i < a.size(); i++) {
      if (a[i] == b[i])
        continue;
      if (a[i] > b[i]) {
        cout << "GREATER" << endl;
        break;
      } else {
        cout << "LESS" << endl;
        break;
      }
    }
    if (i == a.size())
      cout << "EQUAL" << endl;
  }
  return 0;
}
Problem p03738 (C++)

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

int main() {
  string strA, strB;
  bool chk = true;

  cin >> strA >> strB;

  if (strA.size() > strB.size())
    cout << "GREATER";
  else if (strA.size() < strB.size())
    cout << "LESS";
  else {
    while (chk == true) {
      if (stoi(strA.substr(0, 1)) > stoi(strB.substr(0, 1))) {
        cout << "GREATER";
        chk = false;
      } else if (stoi(strA.substr(0, 1)) < stoi(strB.substr(0, 1))) {
        cout << "LESS";
        chk = false;
      } else {
        strA.erase(0, 1);
        strB.erase(0, 1);
      }
    }
  }
}

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

int main() {
  string strA, strB;
  bool chk = true;

  cin >> strA >> strB;

  if (strA.size() > strB.size())
    cout << "GREATER";
  else if (strA.size() < strB.size())
    cout << "LESS";
  else {
    while (chk == true) {
      if (stoi(strA.substr(0, 1)) > stoi(strB.substr(0, 1))) {
        cout << "GREATER";
        chk = false;
      } else if (stoi(strA.substr(0, 1)) < stoi(strB.substr(0, 1))) {
        cout << "LESS";
        chk = false;
      } else {
        if (strA.size() == 1) {
          cout << "EQUAL";
          chk = false;
        } else {
          strA.erase(0, 1);
          strB.erase(0, 1);
        }
      }
    }
  }
}
Problem p03738 (C++)

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
  string A, B;
  cin >> A >> B;
  A.insert(0, string("0", max(0UL, B.size() - A.size())));
  B.insert(0, string("0", max(0UL, A.size() - B.size())));
  cout << (A > B ? "GREATER" : (A < B ? "LESS" : "EQUAL")) << endl;
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
  string A, B;
  cin >> A >> B;
  if (A.size() > B.size()) {
    cout << "GREATER" << endl;
  } else if (A.size() < B.size()) {
    cout << "LESS" << endl;
  } else {
    cout << (A > B ? "GREATER" : (A < B ? "LESS" : "EQUAL")) << endl;
  }
  return 0;
}
Problem p03738 (C++)

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  string s = "abc";
  s.at(0) = a.at(0) + ('A' - 'a');
  s.at(1) = b.at(0) + ('A' - 'a');
  s.at(2) = c.at(0) + ('A' - 'a');
  cout << s << endl;
}


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

int main() {
  string a, b;
  cin >> a >> b;
  string ans;
  string more = "GREATER";
  string less = "LESS";
  string same = "EQUAL";
  if (a.size() > b.size())
    ans = more;
  else if (a.size() < b.size())
    ans = less;
  else if (a > b)
    ans = more;
  else if (a < b)
    ans = less;
  else
    ans = same;

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

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

typedef long long ll;
using namespace std;

#define F first
#define S second
#define sqr(x) x *x
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for (auto it = n.begin(); it != n.end(); ++it)

const ll mod = 1000000007;
ll powmod(ll a, ll b) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) { return abs(a * b) / gcd(a, b); }

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s1, s2;
  cin >> s1 >> s2;
  ll a = stoi(s1);
  ll b = stoi(s2);
  if (a > b) {
    cout << "GREATER";
  } else {
    cout << "LESS";
  }
}


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

typedef long long ll;
using namespace std;

#define F first
#define S second
#define sqr(x) x *x
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for (auto it = n.begin(); it != n.end(); ++it)

const ll mod = 1000000007;
ll powmod(ll a, ll b) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) { return abs(a * b) / gcd(a, b); }

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s1, s2;
  cin >> s1 >> s2;
  if (sz(s1) == sz(s2)) {
    if (s1 < s2) {
      cout << "LESS";
    } else if (s1 > s2) {
      cout << "GREATER";
    } else {
      cout << "EQUAL";
    }
  } else if (sz(s1) > sz(s2)) {
    cout << "GREATER";
  } else {
    cout << "LESS";
  }
}
Problem p03739 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n;
  long long ans = 0;
  long long ans2 = 0;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long dp[10010];
  dp[0] = 0;
  bool flag = true;
  for (int i = 0; i < n; i++) {
    if (flag == true && dp[i] + a[i] >= 0) {
      dp[i + 1] = -1;
      ans += abs(a[i] - (-1 - dp[i]));
    } else if (flag == false && dp[i] + a[i] <= 0) {
      dp[i + 1] = 1;
      ans += abs(a[i] - (1 - dp[i]));
    } else {
      dp[i + 1] = dp[i] + a[i];
    }
    flag = !flag;
  }
  flag = false;
  for (int i = 0; i < n; i++) {
    if (flag == true && dp[i] + a[i] >= 0) {
      dp[i + 1] = -1;
      ans2 += abs(a[i] - (-1 - dp[i]));
    } else if (flag == false && dp[i] + a[i] <= 0) {
      dp[i + 1] = 1;
      ans2 += abs(a[i] - (1 - dp[i]));
    } else {
      dp[i + 1] = dp[i] + a[i];
    }
    flag = !flag;
  }
  cout << min(ans, ans2) << endl;
}

Fixed submission:
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n;
  long long ans = 0;
  long long ans2 = 0;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long dp[100100];
  dp[0] = 0;
  bool flag = true;
  for (int i = 0; i < n; i++) {
    if (flag == true && dp[i] + a[i] >= 0) {
      dp[i + 1] = -1;
      ans += abs(a[i] - (-1 - dp[i]));
    } else if (flag == false && dp[i] + a[i] <= 0) {
      dp[i + 1] = 1;
      ans += abs(a[i] - (1 - dp[i]));
    } else {
      dp[i + 1] = dp[i] + a[i];
    }
    flag = !flag;
  }
  flag = false;
  for (int i = 0; i < n; i++) {
    if (flag == true && dp[i] + a[i] >= 0) {
      dp[i + 1] = -1;
      ans2 += abs(a[i] - (-1 - dp[i]));
    } else if (flag == false && dp[i] + a[i] <= 0) {
      dp[i + 1] = 1;
      ans2 += abs(a[i] - (1 - dp[i]));
    } else {
      dp[i + 1] = dp[i] + a[i];
    }
    flag = !flag;
  }
  cout << min(ans, ans2) << endl;
}
Problem p03739 (C++)

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

int N;
vector<int>
    a(N + 10); // 終了コード136が出る場合は配列を余分に取る。制約最大が望ましい

long calc(long s) {
  long sum = 0, res = 0;
  for (int i = 0; i < N; i++, s *= -1) {
    sum += a[i];
    if (sum * s > 0) {
      continue;
    } // 初項が＋か―かで結果が出る問題である。sの変化を基準にしている。
    res += abs(
        sum -
        s); // abs(sum-s)を算出すると符号を変えるのに必要な操作回数の値がresに入る
    sum += s * abs(sum - s); // sum*sが成り立たないという事は、
  } // sumに新しく入れる数値がsの基準に合致していないためであり、sを掛ける必要がある
  return res; // 操作回数の最小値
}

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

  cout << min(calc(1), calc(-1));
  return 0;
}


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

int N;
vector<int> a(
    100010); // 終了コード136が出る場合は配列を余分に取る。制約最大+αが望ましい

long calc(long s) {
  long sum = 0, res = 0;
  for (int i = 0; i < N; i++, s *= -1) {
    sum += a[i];
    if (sum * s > 0) {
      continue;
    } // 初項が＋か―かで結果が出る問題である。sの変化を基準にしている。
    res += abs(
        sum -
        s); // abs(sum-s)を算出すると符号を変えるのに必要な操作回数の値がresに入る
    sum += s * abs(sum - s); // sum*sが成り立たないという事は、
  } // sumに新しく入れる数値がsの基準に合致していないためであり、sを掛ける必要がある
  return res; // 操作回数の最小値
}

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

  cout << min(calc(1), calc(-1));
  return 0;
}
Problem p03739 (C++)

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

const long long MAX_N = 10001;
long long a[MAX_N];
long long n;

long long choose(int sign) {
  long long sum, count;
  sum = count = 0;
  for (long long i = 1; i <= n; ++i, sign *= -1) {
    sum += a[i];
    if (sum * sign <= 0) {
      count += 1 - sum * sign;
      sum = sign;
    }
  }
  return count;
}

int main() {
  scanf("%lld", &n);

  for (long long i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
  }

  long long res = std::min(choose(1), choose(-1));
  printf("%lld\n", res);
  return 0;
}


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

const long long MAX_N = 100001;
long long a[MAX_N];
long long n;

long long choose(int sign) {
  long long sum, count;
  sum = count = 0;
  for (long long i = 1; i <= n; ++i, sign *= -1) {
    sum += a[i];
    if (sum * sign <= 0) {
      count += 1 - sum * sign;
      sum = sign;
    }
  }
  return count;
}

int main() {
  scanf("%lld", &n);

  for (long long i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
  }

  long long res = std::min(choose(1), choose(-1));
  printf("%lld\n", res);
  return 0;
}
Problem p03739 (C++)

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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  ll cnt = 0;
  ll sub_sum = a[0];
  for (int i = 1; i < n; ++i) {
    ll sum = sub_sum + a[i];
    ll sgn = sub_sum / abs(sub_sum) * sum;
    if (sgn >= 0) {
      ll b = -1 * sub_sum / abs(sub_sum);
      sum = b;
      cnt += abs(b - sub_sum - a[i]);
    }
    sub_sum = sum;
  }
  ll ans = cnt;
  cnt = abs(a[0]) + 1;
  sub_sum = (a[0] > 0 ? -1 : 1);
  for (int i = 1; i < n; ++i) {
    ll sum = sub_sum + a[i];
    ll sgn = sub_sum / abs(sub_sum) * sum;
    if (sgn >= 0) {
      ll b = -1 * sub_sum / abs(sub_sum);
      sum = b;
      cnt += abs(b - sub_sum - a[i]);
    }
    sub_sum = sum;
  }
  ans = min(ans, cnt);
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  ll cnt = 0;
  ll sub_sum = a[0];
  if (sub_sum == 0)
    sub_sum = -1, ++cnt;
  for (int i = 1; i < n; ++i) {
    ll sum = sub_sum + a[i];
    ll sgn = sub_sum / abs(sub_sum) * sum;
    if (sgn >= 0) {
      ll b = -1 * sub_sum / abs(sub_sum);
      sum = b;
      cnt += abs(b - sub_sum - a[i]);
    }
    sub_sum = sum;
  }
  ll ans = cnt;
  cnt = abs(a[0]) + 1;
  sub_sum = (a[0] > 0 ? -1 : 1);
  for (int i = 1; i < n; ++i) {
    ll sum = sub_sum + a[i];
    ll sgn = sub_sum / abs(sub_sum) * sum;
    if (sgn >= 0) {
      ll b = -1 * sub_sum / abs(sub_sum);
      sum = b;
      cnt += abs(b - sub_sum - a[i]);
    }
    sub_sum = sum;
  }
  ans = min(ans, cnt);
  cout << ans << endl;
}