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

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

int x[410], y[410], num[410], n, m;
bool bo[410][410], bb[410];

inline int rd() {
  int x = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = x * 10 + ch - '0';
  return x;
}

int main() {
  n = rd();
  m = rd();
  for (int i = 1; i <= n; i++)
    bb[i] = bo[i][i] = true;
  for (int i = 1; i <= m; i++)
    x[i] = rd(), y[i] = rd();
  for (int i = m; i; i--) {
    for (int j = 1; j <= n; j++) {
      if (!bb[j])
        continue;
      if (bo[j][x[i]] && bo[j][y[i]]) {
        bb[j] = false;
        continue;
      }
      if (bo[j][x[i]])
        bo[j][y[i]] = true;
      else if (bo[j][y[i]])
        bo[j][x[i]] = true;
    }
  }
  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (!bb[i])
      continue;
    for (int j = i + 1; j <= n; j++) {
      if (!bb[j])
        continue;
      for (int k = 1; k <= n; k++)
        num[k] = 0;
      for (int k = 1; k <= n; k++)
        num[k] += bo[i][k] + bo[j][k];
      bool flag = true;
      for (int k = 1; k <= n; k++)
        if (num[k] > 1)
          flag = false;
      if (flag)
        ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

int x[100010], y[100010], num[410], n, m;
bool bo[410][410], bb[410];

inline int rd() {
  int x = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = x * 10 + ch - '0';
  return x;
}

int main() {
  n = rd();
  m = rd();
  for (int i = 1; i <= n; i++)
    bb[i] = bo[i][i] = true;
  for (int i = 1; i <= m; i++)
    x[i] = rd(), y[i] = rd();
  for (int i = m; i; i--) {
    for (int j = 1; j <= n; j++) {
      if (!bb[j])
        continue;
      if (bo[j][x[i]] && bo[j][y[i]]) {
        bb[j] = false;
        continue;
      }
      if (bo[j][x[i]])
        bo[j][y[i]] = true;
      else if (bo[j][y[i]])
        bo[j][x[i]] = true;
    }
  }
  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (!bb[i])
      continue;
    for (int j = i + 1; j <= n; j++) {
      if (!bb[j])
        continue;
      for (int k = 1; k <= n; k++)
        num[k] = 0;
      for (int k = 1; k <= n; k++)
        num[k] += bo[i][k] + bo[j][k];
      bool flag = true;
      for (int k = 1; k <= n; k++)
        if (num[k] > 1)
          flag = false;
      if (flag)
        ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
Problem p03691 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int a[405], b[405];
vector<int> v[405];
int main() {
  int n, m, ans = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    v[i].push_back(-1);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a[i], &b[i]);
    v[a[i]].push_back(i);
    v[b[i]].push_back(i);
  }
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      bool ok = 1;
      multiset<int, greater<int>> s({v[i].back(), v[j].back()});
      while (*s.begin() != -1) {
        if (*s.begin() == *next(s.begin())) {
          ok = 0;
          break;
        }
        int idx = *s.begin();
        s.erase(s.begin());
        s.insert(*prev(lower_bound(v[a[idx]].begin(), v[a[idx]].end(), idx)));
        s.insert(*prev(lower_bound(v[b[idx]].begin(), v[b[idx]].end(), idx)));
      }
      ans += ok;
    }
  }
  printf("%d", ans);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
vector<int> v[405];
int main() {
  int n, m, ans = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    v[i].push_back(-1);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a[i], &b[i]);
    v[a[i]].push_back(i);
    v[b[i]].push_back(i);
  }
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      bool ok = 1;
      multiset<int, greater<int>> s({v[i].back(), v[j].back()});
      while (*s.begin() != -1) {
        if (*s.begin() == *next(s.begin())) {
          ok = 0;
          break;
        }
        int idx = *s.begin();
        s.erase(s.begin());
        s.insert(*prev(lower_bound(v[a[idx]].begin(), v[a[idx]].end(), idx)));
        s.insert(*prev(lower_bound(v[b[idx]].begin(), v[b[idx]].end(), idx)));
      }
      ans += ok;
    }
  }
  printf("%d", ans);
}
Problem p03691 (C++)

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

const int N = 400, M = 100000;

std::bitset<N> s[N];
int x[N], y[M], n, m, ans;

int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  std::cin >> n >> m;
  for (int i = 0; i < m; ++i)
    std::cin >> x[i] >> y[i], --x[i], --y[i];
  for (int i = 0; i < n; ++i) {
    s[i].set(i);
    for (int j = m - 1; ~j; --j) {
      bool a = s[i].test(x[j]), b = s[i].test(y[j]);
      if (a ^ b)
        s[i].set(x[j]), s[i].set(y[j]);
      else if (a && b) {
        s[i].set();
        break;
      }
    }
  }
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j)
      ans += !(s[i] & s[j]).any();
  std::cout << ans << '\n';
  return 0;
}

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

const int N = 400, M = 100000;

std::bitset<N> s[N];
int x[M], y[M], n, m, ans;

int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  std::cin >> n >> m;
  for (int i = 0; i < m; ++i)
    std::cin >> x[i] >> y[i], --x[i], --y[i];
  for (int i = 0; i < n; ++i) {
    s[i].set(i);
    for (int j = m - 1; ~j; --j) {
      bool a = s[i].test(x[j]), b = s[i].test(y[j]);
      if (a ^ b)
        s[i].set(x[j]), s[i].set(y[j]);
      else if (a && b) {
        s[i].set();
        break;
      }
    }
  }
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j)
      ans += !(s[i] & s[j]).any();
  std::cout << ans << '\n';
  return 0;
}
Problem p03691 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
typedef long long ll;
typedef double dd;
#define For(i, j, k) for (int i = (int)j; i <= (int)k; ++i)
#define Forr(i, j, k) for (int i = (int)j; i >= (int)k; --i)
#define Set(a, p) memset(a, p, sizeof(a))
using namespace std;

template <typename T> bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; }

const int maxn = 410;
const int maxm = 5e4;
struct node {
  int x, y;
} s[maxm];
int n, m;
int f[maxn];
int Ans;
bitset<maxn> a[maxn];

inline void file() {
  freopen("c.in", "r", stdin);
  freopen("c.out", "w", stdout);
}

inline int read() {
  int x = 0, p = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-')
      p = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c - '0');
    c = getchar();
  }
  return x * p;
}

inline int calc(int u) {
  a[u][u] = 1;
  Forr(i, m, 1) {
    int x = s[i].x, y = s[i].y;
    if (a[u][x] && a[u][y])
      return 0;
    if (a[u][x] || a[u][y])
      a[u][x] = a[u][y] = 1;
  }
  return 1;
}

int main() {
  //	file();
  n = read();
  m = read();
  For(i, 1, m) s[i].x = read(), s[i].y = read();
  For(i, 1, n) f[i] = calc(i);
  For(i, 1, n) if (f[i]) For(j, i + 1, n) if (f[j]) {
    if ((a[i] & a[j]).any())
      continue;
    ++Ans;
  }
  printf("%d\n", Ans);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
typedef long long ll;
typedef double dd;
#define For(i, j, k) for (int i = (int)j; i <= (int)k; ++i)
#define Forr(i, j, k) for (int i = (int)j; i >= (int)k; --i)
#define Set(a, p) memset(a, p, sizeof(a))
using namespace std;

template <typename T> bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; }

const int maxn = 410;
const int maxm = 1e5 + 1e2;
struct node {
  int x, y;
} s[maxm];
int n, m;
int f[maxn];
int Ans;
bitset<maxn> a[maxn];

inline void file() {
  freopen("c.in", "r", stdin);
  freopen("c.out", "w", stdout);
}

inline int read() {
  int x = 0, p = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-')
      p = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c - '0');
    c = getchar();
  }
  return x * p;
}

inline int calc(int u) {
  a[u][u] = 1;
  Forr(i, m, 1) {
    int x = s[i].x, y = s[i].y;
    if (a[u][x] && a[u][y])
      return 0;
    if (a[u][x] || a[u][y])
      a[u][x] = a[u][y] = 1;
  }
  return 1;
}

int main() {
  //	file();
  n = read();
  m = read();
  For(i, 1, m) s[i].x = read(), s[i].y = read();
  For(i, 1, n) f[i] = calc(i);
  For(i, 1, n) if (f[i]) For(j, i + 1, n) if (f[j]) {
    if ((a[i] & a[j]).any())
      continue;
    ++Ans;
  }
  printf("%d\n", Ans);
  return 0;
}
Problem p03691 (C++)

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

#define maxn 411
#define maxm 11111

bitset<maxn> g[maxn];
bool canalive[maxn];
int a[maxm], b[maxm];
int n, m;

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

  for (int i = 1; i <= m; i++) {
    scanf("%d%d", a + i, b + i);
  }

  for (int i = 1; i <= n; i++) {
    bitset<maxn> &w = g[i];
    w.set(i);
    canalive[i] = true;

    for (int j = m; j >= 1; j--) {
      int p = a[j], q = b[j];

      if (w[p] && w[q]) {
        canalive[i] = false;
        break;
      }

      if (w[p] && !w[q]) {
        g[i].set(q);
      }

      if (!w[p] && w[q]) {
        g[i].set(p);
      }
    }
  }

  int ans = 0;

  for (int i = 1; i <= n; i++) {
    if (!canalive[i]) {
      continue;
    }

    for (int j = i + 1; j <= n; j++) {
      if (!canalive[j]) {
        continue;
      }

      if ((g[i] & g[j]).count() == 0) {
        ans++;
      }
    }
  }

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


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

#define maxn 411
#define maxm 111111

bitset<maxn> g[maxn];
bool canalive[maxn];
int a[maxm], b[maxm];
int n, m;

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

  for (int i = 1; i <= m; i++) {
    scanf("%d%d", a + i, b + i);
  }

  for (int i = 1; i <= n; i++) {
    bitset<maxn> &w = g[i];
    w.set(i);
    canalive[i] = true;

    for (int j = m; j >= 1; j--) {
      int p = a[j], q = b[j];

      if (w[p] && w[q]) {
        canalive[i] = false;
        break;
      }

      if (w[p] && !w[q]) {
        g[i].set(q);
      }

      if (!w[p] && w[q]) {
        g[i].set(p);
      }
    }
  }

  int ans = 0;

  for (int i = 1; i <= n; i++) {
    if (!canalive[i]) {
      continue;
    }

    for (int j = i + 1; j <= n; j++) {
      if (!canalive[j]) {
        continue;
      }

      if ((g[i] & g[j]).count() == 0) {
        ans++;
      }
    }
  }

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

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

using namespace std;

int a[400][400];
int b[400];

int main() {
  int n, m, ans = 0, i, j;

  scanf("%d %d", &n, &m);

  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      a[i][j] = 1;
    }
  }

  for (i = 0; i < m; i++) {
    int x, y;

    scanf("%d %d", &x, &y);

    if (a[x][y] == 0 || b[x] == 1 && b[y] == 1)
      b[x] = b[y] = 1;

    a[x][y] = a[y][x] = 0;

    for (j = 0; j < n; j++) {
      if (a[x][j] == 0 || a[y][j] == 0 || b[x] == 1 || b[y] == 1) {
        a[x][j] = a[j][x] = a[y][j] = a[j][y] = 0;
      }
    }
  }

  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      ans += a[i][j];
    }
  }

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

  return 0;
}


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

using namespace std;

int a[400][400];
int b[400];

int main() {
  int n, m, ans = 0, i, j;

  scanf("%d %d", &n, &m);

  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      a[i][j] = 1;
    }
  }

  for (i = 0; i < m; i++) {
    int x, y;

    scanf("%d %d", &x, &y);

    x--;
    y--;

    if (a[x][y] == 0 || b[x] == 1 && b[y] == 1)
      b[x] = b[y] = 1;

    a[x][y] = a[y][x] = 0;

    for (j = 0; j < n; j++) {
      if (a[x][j] == 0 || a[y][j] == 0 || b[x] == 1 || b[y] == 1) {
        a[x][j] = a[j][x] = a[y][j] = a[j][y] = 0;
      }
    }
  }

  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      ans += a[i][j];
    }
  }

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

  return 0;
}
Problem p03691 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cstdio>
#define rep(i, j, k) for (i = j; i <= k; i++)
#define down(i, j, k) for (i = j; i >= k; i--)
using namespace std;
const int N = 405, M = 1e5 + 5;
int n, m, i, j, ans, u[N], v[N], kill[N];
bitset<N> b[N];
int main() {
  //	freopen("turkey.in","r",stdin);
  //	freopen("turkey.out","w",stdout);
  scanf("%d%d", &n, &m);
  rep(i, 1, m) scanf("%d%d", &u[i], &v[i]);
  rep(i, 1, n) {
    b[i][i] = 1;
    down(j, m, 1) if (b[i][u[j]] || b[i][v[j]]) {
      if (b[i][u[j]] && b[i][v[j]]) {
        kill[i] = 1;
        break;
      }
      b[i][u[j]] = b[i][v[j]] = 1;
    }
  }
  rep(i, 1, n - 1) if (!kill[i])
      rep(j, i + 1, n) if (!kill[j] && (b[i] & b[j]).none()) ans++;
  printf("%d\n", ans);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cstdio>
#define rep(i, j, k) for (i = j; i <= k; i++)
#define down(i, j, k) for (i = j; i >= k; i--)
using namespace std;
const int N = 405, M = 1e5 + 5;
int n, m, i, j, ans, u[M], v[M], kill[N];
bitset<N> b[N];
int main() {
  //	freopen("turkey.in","r",stdin);
  //	freopen("turkey.out","w",stdout);
  scanf("%d%d", &n, &m);
  rep(i, 1, m) scanf("%d%d", &u[i], &v[i]);
  rep(i, 1, n) {
    b[i][i] = 1;
    down(j, m, 1) if (b[i][u[j]] || b[i][v[j]]) {
      if (b[i][u[j]] && b[i][v[j]]) {
        kill[i] = 1;
        break;
      }
      b[i][u[j]] = b[i][v[j]] = 1;
    }
  }
  rep(i, 1, n - 1) if (!kill[i])
      rep(j, i + 1, n) if (!kill[j] && (b[i] & b[j]).none()) ans++;
  printf("%d\n", ans);
  return 0;
}
Problem p03691 (Python)

Buggy submission (status: Time Limit Exceeded):
import sys

from itertools import combinations


def solve(n, pairs):
    survivors = {v: {v} for v in range(1, n + 1)}
    for x, y in reversed(pairs):
        for v, srv in survivors.copy().items():
            if x in srv:
                if y in srv:
                    del survivors[v]
                else:
                    srv.add(y)
            elif y in srv:
                srv.add(x)
    return sum(su.isdisjoint(sv) for su, sv in combinations(survivors.values(), 2))


n, m = map(int, input().split())
pairs = []
for line in sys.stdin.readlines():
    x, y = map(int, line.split())
    pairs.append((x, y))
print(solve(n, pairs))


Fixed submission:
import sys

from itertools import combinations


def solve(n, pairs):
    survivors = {v: {v} for v in range(1, n + 1)}
    for x, y in reversed(pairs):
        for v, srv in survivors.copy().items():
            if x in srv:
                if y in srv:
                    del survivors[v]
                else:
                    srv.add(y)
            elif y in srv:
                srv.add(x)
    return sum(su.isdisjoint(sv) for su, sv in combinations(survivors.values(), 2))


n, m = map(int, input().split())
pairs = [tuple(map(int, line.split())) for line in sys.stdin.readlines()]
print(solve(n, pairs))
Problem p03692 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstring>
#define fo(i, a, b) for (int i = a; i <= b; i++)
#define fd(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

typedef long long ll;

const int N = 15, S = (1 << 15) + 5, Mo = 1e9 + 7;

int n, m, x, y, cnt[N][S], p[N * N], f[S];
bool ok[S];

int main() {
  scanf("%d%d", &n, &m);
  p[0] = 1;
  fo(i, 1, m) {
    scanf("%d%d", &x, &y);
    fo(s, 0, (1 << n) - 1) if (s & (1 << y - 1)) cnt[x][s]++;
    p[i] = (p[i - 1] << 1) % Mo;
  }
  f[0] = 1;
  fo(s, 0, (1 << n) - 1) if (((s & 1) > 0) == ((s & 2) > 0)) ok[s] = 1;
  fo(s, 1, (1 << n) - 1) if (ok[s]) {
    f[s] = 1;
    for (int t = (s - 1) & s; t; t = (t - 1) & s)
      if (ok[t]) {
        int ss = s ^ t, now = f[ss];
        fo(i, 1, n) {
          if (t & (1 << (i - 1)))
            now = (ll)now * p[cnt[i][ss]] % Mo;
          if (ss & (1 << (i - 1)))
            now = (ll)now * (p[cnt[i][t]] - 1) % Mo;
        }
        (f[s] += now) %= Mo;
      }
  }
  printf("%d\n", (p[m] - f[(1 << n) - 1] + Mo) % Mo);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#define fo(i, a, b) for (int i = a; i <= b; i++)
#define fd(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

typedef long long ll;

const int N = 20, S = (1 << 15) + 5, Mo = 1e9 + 7;

int n, m, x, y, cnt[N][S], p[N * N], f[S];
bool ok[S];

int main() {
  scanf("%d%d", &n, &m);
  p[0] = 1;
  fo(i, 1, m) {
    scanf("%d%d", &x, &y);
    fo(s, 0, (1 << n) - 1) if (s & (1 << y - 1)) cnt[x][s]++;
    p[i] = (p[i - 1] << 1) % Mo;
  }
  f[0] = 1;
  fo(s, 0, (1 << n) - 1) if (((s & 1) > 0) == ((s & 2) > 0)) ok[s] = 1;
  fo(s, 1, (1 << n) - 1) if (ok[s]) {
    f[s] = 1;
    for (int t = (s - 1) & s; t; t = (t - 1) & s)
      if (ok[t]) {
        int ss = s ^ t, now = f[ss];
        fo(i, 1, n) {
          if (t & (1 << (i - 1)))
            now = (ll)now * p[cnt[i][ss]] % Mo;
          if (ss & (1 << (i - 1)))
            now = (ll)now * (p[cnt[i][t]] - 1) % Mo;
        }
        (f[s] += now) %= Mo;
      }
  }
  printf("%d\n", (p[m] - f[(1 << n) - 1] + Mo) % Mo);
  return 0;
}
Problem p03692 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define F(i, s, t) for (int i = (s), _ = (t); i <= _; i++)
#define Fo(i, s, t) for (int i = (s), _ = (t); i < _; i++)
#define LL long long
const int N = 20;
const int S = 40000;
const int P = 1000000007;
int n, m, gr[N];
int p2[N * N], fu, cnt[S], edc[N][S];
int f[S];
int rd() {
  int x = 0;
  char c;
  do {
    c = getchar();
  } while (!isdigit(c));
  do {
    x = x * 10 + c - '0', c = getchar();
  } while (isdigit(c));
  return x;
}
int Ju(int s) { return (s & 3) == 0 || (s & 3) == 3; }
int main() {
#ifndef ONLINE_JUDGE
  freopen("F.in", "r", stdin);
#endif
  n = rd(), m = rd();
  F(i, 1, m) {
    int x = rd(), y = rd();
    gr[x] |= (1 << y - 1);
  }
  p2[0] = 1;
  F(i, 1, n * n) p2[i] = p2[i - 1] * 2 % P;
  fu = 1 << n;
  Fo(i, 1, fu) cnt[i] = cnt[i - (i & -i)] + 1;
  F(i, 1, n)
  Fo(s, 0, fu) edc[i][s] = cnt[gr[i] & s];
  f[0] = 1;
  Fo(s, 1, fu) if (Ju(s)) {
    for (int a = (s - 1) & s;; a = (a - 1) & s)
      if (Ju(a) && f[a]) {
        int b = s - a, m = 1;
        F(i, 1, n)
        if (a >> i - 1 & 1)
          m = (LL)m * (p2[edc[i][b]] - 1) % P;
        F(i, 1, n)
        if (b >> i - 1 & 1)
          m = (LL)m * p2[edc[i][a]] % P;
        f[s] = (f[s] + (LL)f[a] * m) % P;
        if (!a)
          break;
      }
  }
  cout << (p2[m] - f[fu - 1] + P) % P << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define F(i, s, t) for (int i = (s), _ = (t); i <= _; i++)
#define Fo(i, s, t) for (int i = (s), _ = (t); i < _; i++)
#define LL long long
const int N = 20;
const int S = 40000;
const int P = 1000000007;
int n, m, gr[N];
int p2[N * N], fu, cnt[S], edc[N][S];
int f[S];
int rd() {
  int x = 0;
  char c;
  do {
    c = getchar();
  } while (!isdigit(c));
  do {
    x = x * 10 + c - '0', c = getchar();
  } while (isdigit(c));
  return x;
}
int Ju(int s) { return (s & 3) == 0 || (s & 3) == 3; }
int main() {
  n = rd(), m = rd();
  F(i, 1, m) {
    int x = rd(), y = rd();
    gr[x] |= (1 << y - 1);
  }
  p2[0] = 1;
  F(i, 1, n * n) p2[i] = p2[i - 1] * 2 % P;
  fu = 1 << n;
  Fo(i, 1, fu) cnt[i] = cnt[i - (i & -i)] + 1;
  F(i, 1, n)
  Fo(s, 0, fu) edc[i][s] = cnt[gr[i] & s];
  f[0] = 1;
  Fo(s, 1, fu) if (Ju(s)) {
    for (int a = (s - 1) & s;; a = (a - 1) & s)
      if (Ju(a) && f[a]) {
        int b = s - a, m = 1;
        F(i, 1, n)
        if (a >> i - 1 & 1)
          m = (LL)m * (p2[edc[i][b]] - 1) % P;
        F(i, 1, n)
        if (b >> i - 1 & 1)
          m = (LL)m * p2[edc[i][a]] % P;
        f[s] = (f[s] + (LL)f[a] * m) % P;
        if (!a)
          break;
      }
  }
  cout << (p2[m] - f[fu - 1] + P) % P << endl;
  return 0;
}
Problem p03693 (Python)

Buggy submission (status: Runtime Error):
n = list(input())
n = int("".join(n))
if n % 4 == 0:
    print("YES")
else:
    print("NO")


Fixed submission:
n = input().split()
n = int("".join(n))
if n % 4 == 0:
    print("YES")
else:
    print("NO")
Problem p03693 (Python)

Buggy submission (status: Runtime Error):
print("NO " if map(int, "".join(input().split())) % 4 else "YES")


Fixed submission:
print("NO " if int("".join(input().split())) % 4 else "YES")
Problem p03693 (Python)

Buggy submission (status: Runtime Error):
print("YES" if int("".join(list(input()))) % 4 == 0 else "NO")


Fixed submission:
print("YES" if int("".join(x for x in input().split())) % 4 == 0 else "NO")
Problem p03693 (Python)

Buggy submission (status: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    print("YES" if int(input()) % 4 == 0 else "NO")


if __name__ == "__main__":
    main()


Fixed submission:
import sys

input = sys.stdin.readline


def main():
    print("YES" if int("".join(input().split())) % 4 == 0 else "NO")


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

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

args = sys.argv
num = args[1] * 100 + args[2] * 10 + args[3]
if num % 4 == 0:
    print("YES")
else:
    print("NO")


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

x = input()
num = int("".join(x.split()))
if num % 4 == 0:
    print("YES")
else:
    print("NO")
Problem p03693 (C++)

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

int main() {
#ifndef ONLINE_JUDGE
  freopen("test.in", "rt", stdin);
#endif
  ios::sync_with_stdio(false);

  int x, n = 0;
  for (int i = 0; i < 3; i++) {
    cin >> x;
    n = n * 10 + x;
  }
  cout << (n % 4 ? "NO" : "YES");
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);

  int x, n = 0;
  for (int i = 0; i < 3; i++) {
    cin >> x;
    n = n * 10 + x;
  }
  cout << (n % 4 ? "NO" : "YES");
  return 0;
}
Problem p03693 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  char r, g, b;
  string x;
  cin >> r >> g >> b;
  x = r + g + b;
  if (stoi(x) % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a * 100 + b * 10 + c) % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
Problem p03693 (C++)

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

int main() {
  string s;
  for (int i = 0; i < 3; i++) {
    cin >> s.at(i);
  }
  int num = stoi(s);

  if (num % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

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

int main() {
  string s = "111";
  for (int i = 0; i < 3; i++) {
    cin >> s.at(i);
  }
  int num = stoi(s);

  if (num % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
Problem p03693 (C++)

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

template <typename First, typename Second, typename Third> struct triple {
  First first;
  Second second;
  Third third;
};
#define ll long long
using namespace std;

void solve() {
  int x, y, z;
  cin >> x >> y >> z;
  string s = to_string(x);
  s += to_string(y);
  s += to_string(z);
  if (stoi(s) % 4 == 0)
    cout << "YES";
  else
    cout << "NO";
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
#endif
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}


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

template <typename First, typename Second, typename Third> struct triple {
  First first;
  Second second;
  Third third;
};
#define ll long long
using namespace std;

void solve() {
  int x, y, z;
  cin >> x >> y >> z;
  string s = to_string(x);
  s += to_string(y);
  s += to_string(z);
  if (stoi(s) % 4 == 0)
    cout << "YES";
  else
    cout << "NO";
}
int main() {

  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
Problem p03693 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
typedef set<ll> sl;
typedef vector<pair<ll, ll>> vll;
typedef map<string, int> msi;

int main() {
  ios::sync_with_stdio(false);

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

  int a, b, c;
  cin >> a >> b >> c;
  if ((10 * b + c) % 4 == 0)
    cout << "YES";
  else
    cout << "NO";

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
typedef set<ll> sl;
typedef vector<pair<ll, ll>> vll;
typedef map<string, int> msi;

int main() {
  ios::sync_with_stdio(false);

  int a, b, c;
  cin >> a >> b >> c;
  if ((10 * b + c) % 4 == 0)
    cout << "YES";
  else
    cout << "NO";

  return 0;
}
Problem p03693 (C++)

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

int main() {
  int r, g, b;
  scanf("%d %d %d ", r, g, b);
  if (g * 10 + b % 4 == 0) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}


Fixed submission:
#include <stdio.h>

int main() {
  int r, g, b;
  scanf("%d %d %d ", &r, &g, &b);
  if ((r * 100 + g * 10 + b) % 4 == 0) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}
Problem p03694 (C++)

Buggy submission (status: Runtime Error):
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i, a, b) for (Int i = a; i < b; ++i)
#define rrep(i, a, b) for (Int i = a; i >= b; --i)
using namespace std;

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

  int N;
  vector<int> A(N);
  rep(i, 0, N) cin >> A[i];
  cout << *max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end())
       << endl;
}


Fixed submission:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i, a, b) for (Int i = a; i < b; ++i)
#define rrep(i, a, b) for (Int i = a; i >= b; --i)
using namespace std;

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

  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, 0, N) cin >> a[i];
  cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end())
       << endl;
}
Problem p03694 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[n - 1] - a[0] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[n - 1] - a[0] << endl;
}
Problem p03694 (C++)

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

int main() {
  int n;
  int a[45];
  int min = 999;
  int max = -1;

  cin >> n;

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

    cin >> a[i];

    if (a[i] < min)
      min = a[i];
    if (a[i] > max)
      max = a[i];
  }
  cout << max - min << endl;
}

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

int main() {
  int n;
  int a[100];
  int min = 999;
  int max = -1;

  cin >> n;

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

    cin >> a[i];

    if (a[i] < min)
      min = a[i];
    if (a[i] > max)
      max = a[i];
  }
  cout << max - min << endl;
}
Problem p03694 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
a = [*map(int, input().split())]
a.sort()
ans = 0
for i in range(n - 1):
    ans += a[i + 1] - a[i]
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(n - 1):
    ans += a[i + 1] - a[i]
print(ans)
Problem p03694 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
print(max(A) - min(A))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
print(max(A) - min(A))
Problem p03694 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
a_list = [int(i) for i in input().split()]
print(max[a_list] - min(a_list))


Fixed submission:
n = int(input())
a_list = [int(i) for i in input().split()]
print(max(a_list) - min(a_list))
Problem p03694 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  cout << A.at(N) - A.at(0) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  cout << A.at(N - 1) - A.at(0) << endl;
}
Problem p03694 (C++)

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

#define o(output) cout << output << endl

using namespace std;

string s;
int a, b, c, d;
char A, B;
priority_queue<int> pr;
vector<int> vec;

int main() {
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  o(vec[a - 1] - vec[0]);
}

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

#define o(output) cout << output << endl

using namespace std;

string s;
int a, b, c, d;
char A, B;
priority_queue<int> pr;
vector<int> vec;

int main() {
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> b;
    vec.push_back(b);
  }
  sort(vec.begin(), vec.end());
  o(vec[a - 1] - vec[0]);
}
Problem p03694 (C++)

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

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a.at(n);
  sort(a.begin(), a.end());
  cout << a.at(n - 1) - a.at(0) << endl;
  return 0;
}

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

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  cout << a.at(n - 1) - a.at(0) << endl;
  return 0;
}
Problem p03694 (C++)

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

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

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

  cout << place.at(n - 1) - place.at(1) << endl;
}

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

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

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

  cout << place.at(n - 1) - place.at(0) << endl;
}
Problem p03694 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))

print(max(a) - min(a))


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

print(max(a) - min(a))
Problem p03694 (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 rep1(i, n) for (int i = 1; i <= n; i++)
#define all(a) a.begin(), a.end()
#define P pair<long long, long long>
#define double long double
using namespace std;
signed main() {
  int a;
  vector<int> b(a);
  rep(i, a) cin >> b.at(i);
  sort(all(b));
  cout << b.at(a - 1) - b.at(0);
}

Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define all(a) a.begin(), a.end()
#define P pair<long long, long long>
#define double long double
using namespace std;
signed main() {
  int a;
  cin >> a;
  vector<int> b(a);
  rep(i, a) cin >> b.at(i);
  sort(all(b));
  cout << b.at(a - 1) - b.at(0);
}
Problem p03694 (C++)

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

int main() {
  // freopen("t.txt","r",stdin);
  int n, a[111] = {0}, b[111] = {0};
  int k = 0;

  cin >> n;
  for (int i = 1; i <= n; i++) {
    int d;
    cin >> d;
    if (b[d] == 0) {
      a[k] = d;
      k++;
      b[d] = 1;
    }
  }
  sort(a, a + k);
  // for (int i=0;i<k;i++) cout<<a[i]<<" ";
  int res = 0;
  for (int i = 1; i < k; i++) {
    int t = a[i] - a[i - 1];
    res += t;
  }
  cout << res;
}


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

int main() {
  // freopen("t.txt","r",stdin);
  int n, a[MAX_N], b[MAX_N] = {0};
  int k = 0;

  cin >> n;
  for (int i = 1; i <= n; i++) {
    int d;
    cin >> d;
    if (b[d] == 0) {
      a[k] = d;
      k++;
      b[d] = 1;
    }
  }
  sort(a, a + k);
  // for (int i=0;i<k;i++) cout<<a[i]<<" ";
  int res = 0;
  for (int i = 1; i < k; i++) {
    int t = a[i] - a[i - 1];
    res += t;
  }
  cout << res;
}
Problem p03694 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  cout << a.at(n) - a.at(0) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  cout << a.at(n - 1) - a.at(0) << endl;
}
Problem p03694 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  cout << abs(a[n - 1] - a[0]) << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  cout << abs(a[n - 1] - a[0]) << endl;
  return 0;
}
Problem p03694 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <new>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N, ans;
  vector<int> A(N, 0);

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

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

  ans = A[N - 1] - A[0];

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

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

using namespace std;

int main() {
  int N, ans;
  cin >> N;
  vector<int> A(N, 0);

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

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

  ans = A[N - 1] - A[0];

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

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

int main() {
  int N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  cout << a[a.size() - 1] - a[0] << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  cout << a[a.size() - 1] - a[0] << endl;
  return 0;
}
Problem p03695 (Python)

Buggy submission (status: Runtime Error):
def main():
    _ = int(input())
    A = list(map(int, input().split()))
    c = [False] * (4800 // 400 - 1)
    d = [0] * (4800 // 400 - 1)
    for a in A:
        c[a // 400] = True
        d[a // 400] += 1
    mn = 1 if c[:8].count(True) == 0 else c[:8].count(True)
    mx = c[:8].count(True) + sum(d[8:])
    print(mn, mx)


main()


Fixed submission:
def main():
    _ = int(input())
    A = list(map(int, input().split()))
    c = [False] * (4800 // 400 + 1)
    d = [0] * (4800 // 400 + 1)
    for a in A:
        c[a // 400] = True
        d[a // 400] += 1
    mn = 1 if c[:8].count(True) == 0 else c[:8].count(True)
    mx = c[:8].count(True) + sum(d[8:])
    print(mn, mx)


main()
Problem p03695 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
an = list(map(int, input().split()))
over_cnt = 0
colors = []
for a in an:
    rate = a // 400
    if rate >= 8:
        over_cnt += 1
    elif rate not in colors:
        colors.append(rate)

min = len(colors)
max = min(len(colors) + over_cnt, 8)
print(min, max)


Fixed submission:
N = int(input())
an = list(map(int, input().split()))
over_cnt = 0
colors = []
for a in an:
    rate = a // 400
    if rate >= 8:
        over_cnt += 1
    elif rate not in colors:
        colors.append(rate)

print(max(len(colors), 1), len(colors) + over_cnt)
Problem p03695 (C++)

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

ll inf = 1ll << 60;

int main() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, i, a[100], b[8] = {0}, t = 0, s = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    if (a[i] <= 399) {
      b[0]++;
    } else if (a[i] <= 799) {
      b[1]++;
    } else if (a[i] <= 1199) {
      b[2]++;
    } else if (a[i] <= 1599) {
      b[3]++;
    } else if (a[i] <= 1999) {
      b[4]++;
    } else if (a[i] <= 2399) {
      b[5]++;
    } else if (a[i] <= 2799) {
      b[6]++;
    } else if (a[i] <= 3199) {
      b[7]++;
    } else {
      t++;
    }
  }
  for (i = 0; i < 8; i++) {
    if (b[i] > 0) {
      s++;
    }
  }
  cout << max(s, 1) << " " << s + t;
  return 0;
}

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

ll inf = 1ll << 60;

int main() {
  // freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, i, a[100], b[8] = {0}, t = 0, s = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    if (a[i] <= 399) {
      b[0]++;
    } else if (a[i] <= 799) {
      b[1]++;
    } else if (a[i] <= 1199) {
      b[2]++;
    } else if (a[i] <= 1599) {
      b[3]++;
    } else if (a[i] <= 1999) {
      b[4]++;
    } else if (a[i] <= 2399) {
      b[5]++;
    } else if (a[i] <= 2799) {
      b[6]++;
    } else if (a[i] <= 3199) {
      b[7]++;
    } else {
      t++;
    }
  }
  for (i = 0; i < 8; i++) {
    if (b[i] > 0) {
      s++;
    }
  }
  cout << max(s, 1) << " " << s + t;
  return 0;
}
Problem p03695 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
colors = [0] * 9
for i in range(N):
    if 1 <= a[i] and a[i] <= 399:
        colors[0] = 1
    elif 400 <= a[i] and a[i] <= 799:
        colors[1] = 1
    elif 800 <= a[i] and a[i] <= 1199:
        colors[2] = 1
    elif 1200 <= a[i] and a[i] <= 1599:
        colors[3] = 1
    elif 1600 <= a[i] and a[i] <= 1999:
        colors[4] = 1
    elif 2000 <= a[i] and a[i] <= 2399:
        colors[5] = 1
    elif 2400 <= a[i] and a[i] <= 2799:
        colors[6] = 1
    elif 2800 <= a[i] and a[i] <= 3199:
        colors[7] = 1
    else:
        colors[8] += 1
if sum(colors[0:8] == 0) and colors[9] >= 1:
    MIN = 1
else:
    MIN = sum(colors[0:8])
MAX = sum(colors)

print(MIN, MAX)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
colors = [0] * 9
for i in range(N):
    if 1 <= a[i] and a[i] <= 399:
        colors[0] = 1
    elif 400 <= a[i] and a[i] <= 799:
        colors[1] = 1
    elif 800 <= a[i] and a[i] <= 1199:
        colors[2] = 1
    elif 1200 <= a[i] and a[i] <= 1599:
        colors[3] = 1
    elif 1600 <= a[i] and a[i] <= 1999:
        colors[4] = 1
    elif 2000 <= a[i] and a[i] <= 2399:
        colors[5] = 1
    elif 2400 <= a[i] and a[i] <= 2799:
        colors[6] = 1
    elif 2800 <= a[i] and a[i] <= 3199:
        colors[7] = 1
    else:
        colors[8] += 1

if sum(colors[0:8]) == 0 and colors[8] >= 1:
    MIN = 1
else:
    MIN = sum(colors[0:8])
MAX = sum(colors)

print(MIN, MAX)
Problem p03695 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, l, r) for (ll i = (l); i < (r); i++)
int main(void) {
  ll n, a;
  cin >> n;
  vector<ll> v;
  rep(i, 0, n) {
    cin >> a;
    if (a < 3200)
      v.at(a / 400) = 1;
    else
      v.at(8)++;
  }
  rep(i, 1, 8) v.at(0) += v.at(i);
  cout << max(v.at(0), (ll)1) << ' ' << (v.at(0) + v.at(8)) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, l, r) for (ll i = (l); i < (r); i++)
int main(void) {
  ll n, a;
  cin >> n;
  vector<ll> v(9);
  rep(i, 0, n) {
    cin >> a;
    if (a < 3200)
      v.at(a / 400) = 1;
    else
      v.at(8)++;
  }
  rep(i, 1, 8) v.at(0) += v.at(i);
  cout << max(v.at(0), (ll)1) << ' ' << (v.at(0) + v.at(8)) << endl;
}
Problem p03695 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int n, c0, c1, c2, c3, c4, c5, c6, c7, cany;
int main() {
  cin >> n;
  int a;
  for (int i = -1; +i - n;) {
    cin >> a;
    a /= 400;
    switch (a) {
    case 0:
      c0 |= 1;
      break;
    case 1:
      c1 |= 1;
      break;
    case 2:
      c2 |= 1;
      break;
    case 3:
      c3 |= 1;
      break;
    case 4:
      c4 |= 1;
      break;
    case 5:
      c5 |= 1;
      break;
    case 6:
      c6 |= 1;
      break;
    case 7:
      c7 |= 1;
      break;
    default:
      ++cany;
      break;
    }
  }
  n = c0 + c1 + c2 + c3 + c4 + c5 + c6 + c7;

  cout << (n ? n : 1) << ' ' << (n + cany) << endl;
}

Fixed submission:
#include <iostream>
using namespace std;
int n, c0, c1, c2, c3, c4, c5, c6, c7, cany;
int main() {
  cin >> n;
  int a;
  for (int i = -1; ++i - n;) {
    cin >> a;
    a /= 400;
    switch (a) {
    case 0:
      c0 |= 1;
      break;
    case 1:
      c1 |= 1;
      break;
    case 2:
      c2 |= 1;
      break;
    case 3:
      c3 |= 1;
      break;
    case 4:
      c4 |= 1;
      break;
    case 5:
      c5 |= 1;
      break;
    case 6:
      c6 |= 1;
      break;
    case 7:
      c7 |= 1;
      break;
    default:
      ++cany;
      break;
    }
  }
  n = c0 + c1 + c2 + c3 + c4 + c5 + c6 + c7;

  cout << (n ? n : 1) << ' ' << (n + cany) << endl;
}
Problem p03695 (C++)

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

using namespace std;

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

  vector<int> color(9);
  for (int i = 0; i < 9; i++) {
    color[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] / 400 < 3200) {
      color[(int)a[i] / 400]++;
    } else {
      color[8]++;
    }
  }

  int base = 0;
  for (int i = 0; i < 8; i++) {
    if (color[i] > 0) {
      base++;
    }
  }

  int mn, mx;
  if (base == 0) {
    mn = 1;
  } else {
    mn = base;
  }

  mx = base + color[8];

  cout << mn << " " << mx << endl;
}

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

using namespace std;

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

  vector<int> color(9);
  for (int i = 0; i < 9; i++) {
    color[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] < 3200) {
      color[(int)(a[i] / 400)]++;
    } else {
      color[8]++;
    }
  }

  int base = 0;
  for (int i = 0; i < 8; i++) {
    if (color[i] > 0) {
      base++;
    }
  }

  int mn, mx;
  if (base == 0) {
    mn = 1;
  } else {
    mn = base;
  }

  mx = base + color[8];

  cout << mn << " " << mx << endl;
}
Problem p03695 (C++)

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

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

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

  vector<int> a(n);
  rep(i, n) cin >> a.at(i);

  vector<int> rate(9);
  rep(i, n) {
    int s = a.at(i) / 400;
    rate.at(s)++;
  }

  int fix = 0;
  int free = rate.at(8);
  rep(i, 8) {
    if (rate.at(i))
      fix++;
  }

  cout << max(fix, 1) << " " << fix + free;
}

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

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

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

  vector<int> a(n);
  rep(i, n) cin >> a.at(i);

  vector<int> rate(9);
  rep(i, n) {
    int s = min(a.at(i) / 400, 8);
    rate.at(s)++;
  }

  int fix = 0;
  int free = rate.at(8);
  rep(i, 8) {
    if (rate.at(i))
      fix++;
  }

  cout << max(fix, 1) << " " << fix + free;
}
Problem p03695 (C++)

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

#define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++)
#define rep(x, to) for (int(x) = 0; (x) < (to); (x)++)
#define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--)
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
const int MD = (int)1e9 + 7;
typedef vector<ll> VL;
void dbg() { cerr << "\n"; }
template <class T, class... T2> void dbg(const T &fst, const T2 &...rst) {
  cerr << fst << ": ";
  dbg(rst...);
}
template <class T, class T2> void amin(T &a, T2 b) {
  if (a > b)
    a = b;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  ;
  cin >> n;
  VI a(n);
  rep(i, n) cin >> a[i];

  VI dt(10);
  rep(i, n) dt[a[i] / 400]++;

  int ct = 0;
  rep(i, 8) ct += dt[i] > 0;
  int mn = ct;
  if (ct == 0 && dt[8] > 0)
    mn = 1;
  int mx = ct + dt[8];
  cout << mn << " " << mx << "\n";

  return 0;
}


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

#define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++)
#define rep(x, to) for (int(x) = 0; (x) < (to); (x)++)
#define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--)
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
const int MD = (int)1e9 + 7;
typedef vector<ll> VL;
void dbg() { cerr << "\n"; }
template <class T, class... T2> void dbg(const T &fst, const T2 &...rst) {
  cerr << fst << ": ";
  dbg(rst...);
}
template <class T, class T2> void amin(T &a, T2 b) {
  if (a > b)
    a = b;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  ;
  cin >> n;
  VI a(n);
  rep(i, n) cin >> a[i];

  VI dt(10);
  rep(i, n) dt[min(a[i], 3200) / 400]++;

  int ct = 0;
  rep(i, 8) ct += dt[i] > 0;
  int mn = ct;
  if (ct == 0 && dt[8] > 0)
    mn = 1;
  int mx = ct + dt[8];
  cout << mn << " " << mx << "\n";

  return 0;
}
Problem p03695 (C++)

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

int main() {
  int N;
  cin >> N;
  int a;
  vector<int> rate(10);
  for (int i = 0; i < N; i++) {
    cin >> a;
    rate[a / 400]++;
  }
  int sum = 0;
  for (int i = 0; i <= 7; i++) {
    if (rate[i])
      sum++;
  }
  cout << max(1, sum) << " " << sum + rate[8] << endl;
}

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

int main() {
  int N;
  cin >> N;
  int a;
  vector<int> rate(10);
  for (int i = 0; i < N; i++) {
    cin >> a;
    if (a < 3200)
      rate[a / 400]++;
    else
      rate[8]++;
  }
  int sum = 0;
  for (int i = 0; i <= 7; i++) {
    if (rate[i])
      sum++;
  }
  cout << max(1, sum) << " " << sum + rate[8] << endl;
}