alexjercan/bugnet huggingface dataset:
Problem p00246 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <vector>

using namespace std;

map<vector<int>, int> m;
vector<vector<int>> mp;

int getMax(vector<int> &p, int sum) {
  int a;
  if (m.find(p) != m.end()) {
    return (m[p]);
  }

  if (sum < 10) {
    return (m[p] = 0);
  }

  a = 0;
  for (int i = 0; i < (int)mp.size(); i++) {
    vector<int> c = p;
    bool flag;
    flag = true;

    for (int j = 1; j < (int)mp[i].size(); j++) {
      c[j] -= mp[i][j];
      if (c[j] < 0) {
        flag = false;
        break;
      }
    }

    if (flag == true) {
      a = max(a, 1 + getMax(c, sum - 10));
    }
  }

  return (m[p] = a);
}

void make(vector<int> &t, int n, int lim) {
  if (lim == 0 || n == 10) {
    if (!lim) {
      mp.push_back(t);
      m[t] = 1;
    }
    return;
  }

  for (int i = 0; i * n <= lim; i++) {
    vector<int> tn = t;
    tn.push_back(i);
    make(tn, n + 1, lim - i * n);
  }

  return;
}

int main(void) {
  int n;
  int ans;
  vector<int> num(10);
  vector<int> t;

  t.push_back(0);
  make(t, 1, 10);

  while (scanf("%d", &n) && n) {

    fill(num.begin(), num.end(), 0);

    for (int i = 0; i < n; i++) {
      int t;
      scanf("%d", &t);
      num[t]++;
    }

    ans = 0;

    for (int i = 1; i <= 4; i++) {
      int m = min(num[i], num[10 - i]);
      ans += m;
      num[i] -= m;
      num[10 - i] -= m;
    }
    ans += num[5] / 2;
    num[5] %= 2;

    int s = 0;
    for (int i = 1; i <= 9; i++) {
      s += i * num[i];
    }

    printf("%d\\n", ans + getMax(num, s));
  }

  return (0);
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <vector>

using namespace std;

map<vector<int>, int> m;
vector<vector<int>> mp;

int getMax(vector<int> &p, int sum) {
  int a;
  vector<int> c;
  if (m.count(p) != 0) {
    return (m[p]);
  }

  if (sum < 10) {
    return (m[p] = 0);
  }

  a = 0;
  for (int i = 0; i < (int)mp.size(); i++) {
    c = p;
    bool flag;
    flag = true;

    for (int j = 1; j <= 9; j++) {
      c[j] -= mp[i][j];
      if (c[j] < 0) {
        flag = false;
        break;
      }
    }

    if (flag == true) {
      a = max(a, 1 + getMax(c, sum - 10));
    }
  }

  return (m[p] = a);
}

void make(vector<int> t, int lim, int rem) {
  if (rem == 0) {
    mp.push_back(t);
    m[t] = 1;
    return;
  }

  for (int i = lim; i >= 1; i--) {
    t[i]++;
    make(t, rem - i, rem - i);
    t[i]--;
  }

  return;
}

int main(void) {
  int n;
  int ans;
  vector<int> num(10);
  vector<int> t(10, 0);

  make(t, 9, 10);

  while (scanf("%d", &n) && n) {

    fill(num.begin(), num.end(), 0);

    for (int i = 0; i < n; i++) {
      int t;
      scanf("%d", &t);
      num[t]++;
    }

    ans = 0;

    for (int i = 1; i <= 4; i++) {
      int m = min(num[i], num[10 - i]);
      ans += m;
      num[i] -= m;
      num[10 - i] -= m;
    }
    ans += num[5] / 2;
    num[5] %= 2;

    int s = 0;
    for (int i = 1; i <= 9; i++) {
      s += i * num[i];
    }

    printf("%d\\n", ans + getMax(num, s));
  }

  return (0);
}
Problem p00248 (C++) — buggy submission, verdict: Runtime Error

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

int N, M;
vector<int> G[100000];
bool used[100000];

bool dfs(int v, int p) {
  used[v] = true;
  bool ret = true;

  for (int i = 0; i < G[v].size(); i++) {
    int to = G[v][i];
    if (to == p)
      continue;
    if (used[to])
      return false;
    ret &= dfs(to, v);
  }
  return ret;
}

int main() {
  while (cin >> N >> M, N || M) {
    fill_n(G, N, vector<int>());
    for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    if (M >= N) {
      cout << "no" << endl;
      continue;
    }
    fill_n(used, N, false);
    bool ret = true;

    for (int i = 0; i < N; i++) {
      if (G[i].size() > 2)
        ret = false;
      if (G[i].size() >= 2)
        continue;
      if (used[i])
        continue;
      ret &= dfs(i, -1);
    }

    for (int i = 0; i < N; i++)
      if (!used[i])
        ret = false;
    if (ret)
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

int N, M;
vector<int> G[10000];
bool used[100000];

bool dfs(int v, int p) {
  used[v] = true;
  bool ret = true;

  for (int i = 0; i < G[v].size(); i++) {
    int to = G[v][i];
    if (to == p)
      continue;
    if (used[to])
      return false;
    ret &= dfs(to, v);
  }
  return ret;
}

int main() {
  while (cin >> N >> M, N || M) {
    fill_n(G, N, vector<int>());
    for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    if (M >= N) {
      cout << "no" << endl;
      continue;
    }
    fill_n(used, N, false);
    bool ret = true;

    for (int i = 0; i < N; i++) {
      if (G[i].size() > 2)
        ret = false;
      if (G[i].size() >= 2)
        continue;
      if (used[i])
        continue;
      ret &= dfs(i, -1);
    }

    for (int i = 0; i < N; i++)
      if (!used[i])
        ret = false;
    if (ret)
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}
Problem p00250 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n, m;
  while (cin >> n >> m, n | m) {
    vector<int> K(n), sum(n), rsum(n);
    for (int i = 0; i < n; i++) {
      ll tmp;
      cin >> tmp;
      K[i] = tmp % m;
    }
    sum[0] = K[0];
    rsum[0] = (m - sum[0]) % m;
    for (int i = 1; i < n; i++) {
      sum[i] = (sum[i - 1] + K[i]) % m;
      rsum[i] = (m - sum[i]) % m;
    }
    int res = sum[0];
    set<int> s;
    for (int i = 1; i < n; i++) {
      s.insert(rsum[i - 1]);
      auto ub = s.upper_bound(rsum[i] - 1);
      if (ub != s.begin()) {
        ub--;
        res = max(res, *ub + sum[i]);
      } else {
        res = max(res, sum[i]);
      }
    }
    cout << res << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int n, m;
  unsigned long long k;
  while (cin >> n >> m, n || m) {
    vector<bool> dp(m, false), cp;
    dp[0] = true;
    for (int i = 0; i < n; i++) {
      cin >> k;
      cp = dp;
      for (int j = 0; j < m; j++) {
        if (cp[j]) {
          dp[(j + k) % m] = true;
        }
      }
    }
    for (int i = m - 1; i >= 0; i--) {
      if (dp[i]) {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}
Problem p00250 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cfloat>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 30001

int N;
ll M;
ll table[NUM];
set<ll> SET;

void func() {

  SET.clear();

  table[0] = 0;
  ll ans = 0;

  for (int i = 1; i <= N; i++) {
    scanf("%d", &table[i]);
    table[i] += table[i - 1];
    table[i] %= M;

    if (i == 1) {
      ans = table[i];
      SET.insert(table[i]);
      continue;
    }
    ans = max(ans, table[i]);

    auto it = SET.upper_bound(table[i]);
    if (it != SET.end()) {
      ans = max(ans, (table[i] - *it + M) % M);
    }
    SET.insert(table[i]);
  }

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

int main() {

  while (true) {
    scanf("%d %d", &N, &M);
    if (N == 0 && M == 0)
      break;

    func();
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cfloat>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 30001

int N, M;
int table[NUM];
vector<int> V;

void func() {

  V.clear();

  table[0] = 0;
  int ans = 0;

  int left, right, m;
  int near_num;

  for (int i = 1; i <= N; i++) {
    scanf("%d", &table[i]);
    table[i] += table[i - 1];
    table[i] %= M;

    if (i == 1) {
      ans = table[i];
      V.push_back(table[i]);
      continue;
    }

    ans = max(ans, (table[i] - V[0] + M) % M);

    left = 0, right = V.size() - 1, m = (left + right) / 2;
    near_num = -1;

    while (left <= right) {
      if (V[m] > table[i]) {
        near_num = V[m];
        right = m - 1;
      } else {
        left = m + 1;
      }
      m = (left + right) / 2;
    }

    if (near_num != -1) {
      ans = max(ans, (table[i] - near_num + M) % M);
    }
    V.push_back(table[i]);
    sort(V.begin(), V.end());
    V.erase(unique(V.begin(), V.end()), V.end());
  }

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

int main() {

  while (true) {
    scanf("%d %d", &N, &M);
    if (N == 0 && M == 0)
      break;

    func();
  }

  return 0;
}
Problem p00250 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

const int INF = 1 << 28;

struct SegNode {
  int v;

  SegNode(int v) : v(v) {}

  SegNode operator*(const SegNode &r) const { return (v > r.v ? *this : r); }
} e(-(1 << 30));

struct SegmentTree {
  int sz;
  vector<SegNode> seg;

  SegmentTree(int n) {
    sz = 1;
    while (sz < n)
      sz <<= 1;
    seg.assign(2 * sz - 1, e);
  }

  void update(int k, const SegNode &x) {
    k += sz - 1;
    seg[k] = x;
    while (k > 0) {
      k = (k - 1) >> 1;
      seg[k] = seg[2 * k + 1] * seg[2 * k + 2];
    }
  }

  SegNode query(int a, int b, int k, int l, int r) {
    if (a >= r || b <= l)
      return (e);
    if (a <= l && r <= b)
      return (seg[k]);
    return (query(a, b, 2 * k + 1, l, (l + r) >> 1) *
            query(a, b, 2 * k + 2, (l + r) >> 1, r));
  }

  SegNode query(int a, int b) { return (query(a, b, 0, 0, sz)); }
};

int main() {
  int N, M, X[30000];

  while (cin >> N >> M, N) {
    for (int i = 0; i < N; i++) {
      cin >> X[i];
      X[i] %= M;
    }

    vector<int> first(M, INF), last(2 * M, -INF);
    first[0] = -1;
    int sum = 0;
    for (int i = 0; i < N; i++) {
      sum += X[i];
      sum %= M;
      first[sum] = min(first[sum], i);
      last[sum] = max(last[sum], i);
      last[M + sum] = max(last[M + sum], i);
    }

    int ret = 0;
    SegmentTree seg(N);
    int ptr = 0;
    for (int i = 0; i < M; i++) {
      while (ptr - i < M) {
        if (last[ptr] >= 0) {
          seg.update(last[ptr], ptr);
        }
        ++ptr;
      }
      ret = max(ret, seg.query(first[i] + 1, N).v - i);
    }
    cout << ret << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

const int INF = 1 << 30;

int main() {
  int N, M, X[30000];

  while (cin >> N >> M, N) {
    for (int i = 0; i < N; i++) {
      cin >> X[i];
      X[i] %= M;
    }

    // vector< set< int > > used(M);

    vector<int> first(M, INF), last(2 * M, -INF);
    first[0] = -1;
    int sum = 0;
    for (int i = 0; i < N; i++) {
      sum += X[i];
      sum %= M;
      first[sum] = min(first[sum], i);
      last[sum] = max(last[sum], i);
      last[M + sum] = max(last[M + sum], i);
    }

    int ret = 0;
    for (int i = 0; i < M; i++) {
      for (int j = i; j < i + M; j++) {
        if (first[i] < last[j]) {
          ret = max(ret, j - i);
        }
      }
    }

    cout << ret << endl;
  }
}
Problem p00250 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (cin >> n >> m, n | m) {
    vector<int> scone(n);
    for (auto &i : scone)
      cin >> i;

    vector<int> sum = {0};
    for (auto i : scone)
      sum.push_back((sum.back() + (i % m)) % m);

    int answer = 0;
    set<int> used = {m};
    for (int j = 1; j < sum.size(); ++j) {
      answer = max(answer, (sum[j] - *used.lower_bound(sum[j]) + m + m) % m);
      used.insert(sum[j]);
      used.insert(sum[j] + m);
    }
    cout << answer << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (cin >> n >> m, n | m) {
    vector<int> scone(n);
    for (auto &i : scone)
      cin >> i;

    vector<int> sum = {0};
    for (auto i : scone)
      sum.push_back((sum.back() + (i % m)) % m);

    int answer = 0;
    set<int> used = {m};
    for (int j = 1; j < sum.size(); ++j) {
      answer = max(
          answer,
          (sum[j] - *lower_bound(begin(used), end(used), sum[j]) + m + m) % m);
      used.insert(sum[j]);
      used.insert(sum[j] + m);
    }
    cout << answer << endl;
  }
}
Problem p00250 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define reps(i, f, n) for (int i = f; i < int(n); ++i)
#define rep(i, n) reps(i, 0, n)

int K[30000];

int func(int n, int m) {
  rep(i, n) {
    scanf("%d", &K[i]);
    K[i] %= m;
  }

  int ans = 0;
  int offset = 0;
  set<int> S;

  rep(i, n) {
    S.insert((m - offset) % m);
    offset = (offset + K[i]) % m;

    auto itr = S.lower_bound(m - offset);
    if (itr == S.begin())
      itr = S.end();
    itr = --itr;
    ans = max(ans, (*itr + offset) % m);
  }

  return ans;
}

int main() {
  int n, m;
  while (scanf("%d%d", &n, &m), n) {
    printf("%d\\n", func(n, m));
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define reps(i, f, n) for (int i = f; i < int(n); ++i)
#define rep(i, n) reps(i, 0, n)

int K[30000];

int func(int n, int m) {
  rep(i, n) {
    scanf("%d", &K[i]);
    K[i] %= m;
  }

  int ans = 0;
  rep(i, n) {
    int sum = 0;
    reps(j, i, n) {
      sum += K[j];
      sum = sum - (sum >= m ? m : 0);
      ans = max(ans, sum);
    }

    if (ans == m - 1) {
      break;
    }
  }

  return ans;
}

int main() {
  int n, m;
  while (scanf("%d%d", &n, &m), n) {
    printf("%d\\n", func(n, m));
  }
}
Problem p00250 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ll N, M, K;
  while (cin >> N >> M, N) {
    vector<ll> sum(N + 1, 0);
    for (int i = 0; i < N; i++) {
      cin >> K;
      sum[i + 1] = (sum[i] + K) % M;
    }
    ll res = 0;
    set<ll> st = {0};
    for (int i = 1; i <= N; i++) {
      st.insert(sum[i]);
      res = max(res, sum[i] % M);
      auto x = st.upper_bound(sum[i]);
      if (x == st.end())
        continue;
      res = max(res, (sum[i] - *x + M) % M);
    }
    cout << res << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ll N, M, K;
  while (cin >> N >> M, N) {
    vector<ll> v(N);
    for (int i = 0; i < N; i++) {
      cin >> K;
      v[i] = K % M;
    }
    ll res = 0;
    for (int i = 0; i < N; i++) {
      ll s = 0;
      for (int j = 0; j < N - i; j++) {
        s += v[i + j];
        res = max(res, s % M);
      }
    }
    cout << res << endl;
  }
  return 0;
}
Problem p00250 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

typedef long long ll;
const int MAX_N = 31000;
const int MAX_M = 100010;
int n, m, arr[MAX_N], mod_sum[MAX_N];
int bit[MAX_M];

int sum(int i) {
  ++i;
  int s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(int i, int x) {
  ++i;
  while (i <= m) {
    bit[i] += x;
    i += i & -i;
  }
}

int getMax(int L, int R) {
  int target = sum(R);
  rep(_, 65) {
    int M = (L + R) / 2;
    if (sum(M) >= target)
      R = M;
    else
      L = M;
  }
  if (L != R) {
    int res = -1;
    if (sum(R) >= target)
      res = R;
    if (sum(L) >= target)
      res = L;
    assert(res != -1);
    R = res;
  }
  if (R == 0 && sum(R))
    return 0;
  else if (R == 0)
    return -1;
  if (sum(R) - sum(R - 1))
    return R;
  return -1;
}

inline int convert(int value, int sub) { return (value - sub + m) % m; }

void compute() {
  int maxi = 0;

  rep(i, n) if (arr[i]) add(mod_sum[i], 1), maxi = max(maxi, arr[i]);
  if (maxi == m - 1) {
    printf("%d\\n", maxi);
    return;
  }
  int sub = 0;

  rep(i, n) if (arr[i]) {
    int low = sub;
    int high = (m - 1 + sub) % m;

    if (low < high) {
      int temp = getMax(low, high);
      if (temp != -1)
        maxi = max(maxi, convert(temp, sub));
    } else {
      int temp = getMax(low, m - 1);
      if (temp != -1)
        maxi = max(maxi, convert(temp, sub));
      temp = getMax(0, high);
      if (temp != -1)
        maxi = max(maxi, convert(temp, sub));
    }
    (sub += arr[i]) %= m;
    add(mod_sum[i], -1);
    if (maxi == m - 1)
      break;
  }
  printf("%d\\n", maxi);
}

int main() {
  while (scanf("%d %d", &n, &m), n | m) {
    memset(bit, 0, sizeof(bit));
    rep(i, n) {
      scanf("%d", arr + i);
      arr[i] %= m;
      if (i)
        mod_sum[i] = (mod_sum[i - 1] + arr[i]) % m;
      else
        mod_sum[i] = arr[i];
    }
    compute();
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

int main() {
  int n, m;
  while (cin >> n >> m, n | m) {
    vector<int> arr(n);
    rep(i, n) {
      cin >> arr[i];
      arr[i] %= m;
    }
    int maxi = 0;
    rep(i, n) {
      int sum = 0;
      REP(j, i, n) {
        (sum += arr[j]) %= m;
        maxi = max(maxi, sum);
      }
      if (maxi == m - 1)
        break;
    }
    cout << maxi << endl;
  }
  return 0;
}
Problem p00250 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <set>
using namespace std;

set<int> s[100000];

int main() {
  int i, n, m, p, h, g, ans;
  unsigned int d;
  while (cin >> n >> m && n + m > 0) {
    ans = 0;
    h = 0;
    for (i = 0; i < m; i++)
      s[i].clear();
    for (i = 0; i < n; i++) {
      cin >> d;
      h = (h + (d % m)) % m;
      if (h > ans)
        ans = h;
      s[h].insert(i);
      if (i == 0)
        p = h;
    }
    h = m;
    g = 0;
    for (i = 0; i < m; i++) {
      p = (p + m - 1) % m;
      h--;
      if (s[p].empty())
        continue;
      if (s[p].upper_bound(g) != s[p].end() && ans < h)
        ans = h;
      g = *(s[p].begin());
      h = m;
    }
    cout << ans << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <set>
using namespace std;

set<int> s[100000];

int main() {
  int i, n, m, p, d, h, g, ans;
  set<int>::iterator it;
  while (cin >> n >> m && n + m > 0) {
    ans = 0;
    h = 0;
    for (i = 0; i < m; i++)
      s[i].clear();
    for (i = 0; i < n; i++) {
      cin >> d;
      h += d;
      if ((h % m) > ans)
        ans = h % m;
      s[h % m].insert(i);
      if (i == 0)
        p = h % m;
    }
    h = m;
    g = 0;
    for (i = 0; i < m; i++) {
      p = (p + m - 1) % m;
      h--;
      if (s[p].empty())
        continue;
      if (s[p].upper_bound(g) != s[p].end() && ans < h)
        ans = h;
      g = *(s[p].begin());
      h = m;
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00252 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main(void) {
  int b1, b2, b3;
  scanf("%d %d %d", &b1, &b2, &b3);

  if (b1 == 1 && b2 == 0 && b3 == 0) {
    printf("Close\\n");
  } else if (b1 == 0 && b2 == 1 && b3 == 0) {
    printf("Close\\n");
  } else if (b1 == 1 && b2 == 1 && b3 == 0) {
    printf("Open\\n");
  } else if (b1 == 0 && b2 == 0 && b3 == 1) {
    printf("Open\\n");
  } else if (b1 == 0 && b2 == 0 && b3 == 0) {
    printf("Close\\n");
  }
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
int main(void) {
  int b1, b2, b3;
  scanf("%d %d %d", b1, b2, b3);

  if (b1 == 1 && b2 == 0 && b3 == 0) {
    printf("Close");
  } else if (b1 == 0 && b2 == 1 && b3 == 0) {
    printf("Close");
  } else if (b1 == 1 && b2 == 1 && b3 == 0) {
    printf("Open");
  } else if (b1 == 0 && b2 == 0 && b3 == 1) {
    printf("Open");
  } else if (b1 == 0 && b2 == 0 && b3 == 0) {
    printf("Close");
  }
  return 0;
}
Problem p00252 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main(void) {
  int b1, b2, b3;
  scanf("%d %d %d", &b1, &b2, &b3);
  if (b1 == 1 && b2 == 1 || b3 == 1)
    printf("Open\\n");
  else
    printf("Close\\n");
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
int main(void) {
  int b1, b2, b3;
  scanf("%d %d %d", b1, b2, b3);
  if (b1 == 0 && b2 == 0 && b3 == 1)
    printf("Open\\n");
  else
    printf("Close\\n");
  return 0;
}
Problem p00252 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int b1, b2, b3, i;
  cin >> b1 >> b2 >> b3;
  b1 = b1 * 7 + b2 * 3 + b3;
  if (b1 == 7) {
    cout << "Close" << endl;
  }
  if (b1 == 3) {
    cout << "Close" << endl;
  }
  if (b1 == 10) {
    cout << "Open" << endl;
  }
  if (b1 == 1) {
    cout << "Open" << endl;
  }
  if (b1 == 0) {
    cout << "Close" << endl;
  }

  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int w, e, r, b, c, d, z, i;

  scanf("%d%d%d", w, e, r);
  if (w > 2 || e > 2 || r > 2) {
    return 0;
  }
  b = w * 100;
  c = e * 10;
  d = r;
  z = b + c + d;

  if (z == 100) {
    cout << "Close" << endl;
  } else if (z == 10) {
    cout << "Close" << endl;
  } else if (z == 110) {
    cout << "Open" << endl;
  } else if (z == 1) {
    cout << "Open" << endl;
  } else if (z == 0) {
    cout << "Open" << endl;
  }

  return 0;
}
Problem p00253 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
int n, a[101], b[100];
int main() {
  while (~scanf("%d", &n)) {
    if (!n)
      break;
    for (int i = 0; i <= n; i++)
      scanf("%d", &a[i]);
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) {
        if (j < i)
          b[j] = a[j];
        if (j > i)
          b[j - 1] = a[j];
      }
      bool flag = false;
      for (int j = 2; j < n; j++) {
        if (b[j - 2] - b[j - 1] != b[j - 1] - b[j]) {
          flag = true;
          break;
        }
      }
      if (!flag) {
        printf("%d\\n", a[i]);
        break;
      }
    }
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int n, a[111];

  while (true) {
    cin >> n;

    n += 1;

    if (n == 0) {
      break;
    }

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

    int p = a[1] - a[0];

    if (p != a[2] - a[1] && p != a[3] - a[2]) {
      cout << a[0] << endl;
    } else {
      bool found = false;

      for (int i = 2; i < n; i++) {
        if (a[i] - a[i - 1] != p && found == false) {
          cout << a[i] << endl;
          found = true;
        }
      }
    }
  }

  return 0;
}