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

Buggy submission (status: Runtime Error):
#include <iostream>
#include <set>
#include <string>
#include <utility>
using namespace std;
string s[200010];
int a[200010], b[200100];
multiset<pair<int, int>> s1, s2, s3;
int main() {
  int i, j, n;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s[i];
    int cnt = 0;
    b[i] = 0;
    for (j = 0; j < s[i].size(); j++) {
      if (s[i][j] == '(')
        cnt++;
      else
        cnt--;
      b[i] = min(b[i], cnt);
    }
    a[i] = cnt;
  }
  int sum = 0;
  for (i = 0; i < n; i++) {
    sum += a[i];
  }
  if (sum != 0) {
    cout << "No" << endl;
    return 0;
  }
  for (i = 0; i < n; i++) {
    if (a[i] >= 0) {
      s1.insert({-b[i], a[i]});
    }
    if (a[i] == 0) {
      s2.insert({b[i], a[i]});
    }
    if (a[i] < 0) {
      s3.insert({-(b[i] - a[i]), -a[i]});
    }
  }
  sum = 0;
  while (s1.size()) {
    auto it = s1.begin();
    pair<int, int> p = *it;
    if (sum - p.first < 0) {
      cout << "No" << endl;
      return 0;
    }
    s1.erase(it);
    sum += p.second;
  }
  while (s2.size()) {
    auto it = s2.begin();
    pair<int, int> p = *it;
    if (sum + p.first < 0) {
      cout << "No" << endl;
      return 0;
    }
    s2.erase(it);
  }
  sum = 0;
  while (s3.size()) {
    auto it = s3.begin();
    pair<int, int> p = *it;
    if (sum - p.first < 0) {
      cout << "No" << endl;
      return 0;
    }
    s3.erase(it);
    sum += p.second;
  }
  cout << "Yes" << endl;
}

Fixed submission:
#include <iostream>
#include <set>
#include <string>
#include <utility>
using namespace std;
string s[1000010];
int a[1000010], b[1000100];
multiset<pair<int, int>> s1, s2, s3;
int main() {
  int i, j, n;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s[i];
    int cnt = 0;
    b[i] = 0;
    for (j = 0; j < s[i].size(); j++) {
      if (s[i][j] == '(')
        cnt++;
      else
        cnt--;
      b[i] = min(b[i], cnt);
    }
    a[i] = cnt;
  }
  int sum = 0;
  for (i = 0; i < n; i++) {
    sum += a[i];
  }
  if (sum != 0) {
    cout << "No" << endl;
    return 0;
  }
  for (i = 0; i < n; i++) {
    if (a[i] >= 0) {
      s1.insert({-b[i], a[i]});
    }
    if (a[i] == 0) {
      s2.insert({b[i], a[i]});
    }
    if (a[i] < 0) {
      s3.insert({-(b[i] - a[i]), -a[i]});
    }
  }
  sum = 0;
  while (s1.size()) {
    auto it = s1.begin();
    pair<int, int> p = *it;
    if (sum - p.first < 0) {
      cout << "No" << endl;
      return 0;
    }
    s1.erase(it);
    sum += p.second;
  }
  while (s2.size()) {
    auto it = s2.begin();
    pair<int, int> p = *it;
    if (sum + p.first < 0) {
      cout << "No" << endl;
      return 0;
    }
    s2.erase(it);
  }
  sum = 0;
  while (s3.size()) {
    auto it = s3.begin();
    pair<int, int> p = *it;
    if (sum - p.first < 0) {
      cout << "No" << endl;
      return 0;
    }
    s3.erase(it);
    sum += p.second;
  }
  cout << "Yes" << endl;
}
Problem p02686 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#define maxn 1000010
using namespace std;
char s[maxn];
struct node {
  int l, r;
} a[maxn];
int tot;
int cmp(node a, node b) { a.l - a.r > b.l - b.r; }
int main() {
  int n, i, j, l, r, ln, rn;
  ln = rn = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    l = r = 0;
    scanf("%s", s + 1);
    for (j = 1; s[j]; j++) {
      if (s[j] == '(')
        l++;
      else if (s[j] == ')') {
        if (l)
          l--;
        else
          r++;
      }
    }
    if (l && !r)
      ln += l;
    else if (!l && r)
      rn += r;
    else if (l && r)
      a[++tot] = (node){l, r};
  }
  sort(a + 1, a + 1 + tot, cmp);
  for (i = 1; i <= tot; i++) {
    if (ln < a[i].r)
      return printf("No\n") * 0;
    ln -= a[i].r, ln += a[i].l;
  }
  if (ln != rn)
    return printf("No\n") * 0;
  printf("Yes\n");
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#define maxn 1000010
using namespace std;
char s[maxn];
struct node {
  int l, r;
} a[maxn];
int tot;
int cmp(node a, node b) { return a.l - a.r > b.l - b.r; }
int main() {
  int n, i, j, l, r, ln, rn;
  ln = rn = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    l = r = 0;
    scanf("%s", s + 1);
    for (j = 1; s[j]; j++) {
      if (s[j] == '(')
        l++;
      else if (s[j] == ')') {
        if (l)
          l--;
        else
          r++;
      }
    }
    if (l && !r)
      ln += l;
    else if (!l && r)
      rn += r;
    else if (l && r)
      a[++tot] = (node){l, r};
  }
  sort(a + 1, a + 1 + tot, cmp);
  for (i = 1; i <= tot; i++) {
    if (ln < a[i].r)
      return printf("No\n") * 0;
    ln -= a[i].r, ln += a[i].l;
  }
  if (ln != rn)
    return printf("No\n") * 0;
  printf("Yes\n");
  return 0;
}
Problem p02686 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, i;
  bool operator<(const node &x) const {
    if ((l >= r) == (x.l >= x.r)) {
      if ((l >= r))
        return r < x.r;
      return l > x.l;
    }
    return l - r > x.l - x.r;
  }
} arr[200007], brr[200007];
int main() {
  int n;
  cin >> n;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    int l = 0, r = 0;
    for (int j = 0; j < (int)s.length(); j++) {
      if (s[j] == '(')
        l++;
      else if (l)
        l--;
      else
        r++;
    }
    arr[i] = {l, r, i};
    brr[i] = {r, l, i};
  }
  sort(arr, arr + n);
  sort(brr, brr + n);
  int ll = 0;
  for (int i = 0; i < n; i++) {
    if (ll < arr[i].r) {
      cout << "No" << endl;
      return 0;
    } else
      ll += arr[i].l - arr[i].r;
  }

  if (ll == 0) {
    cout << "Yes" << endl;
    /* for(int i=0; i<n; i++)
         cout<<arr[i].i+1<<' ';
     cout<<endl;*/
  } else
    cout << "No" << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, i;
  bool operator<(const node &x) const {
    if ((l >= r) == (x.l >= x.r)) {
      if ((l >= r))
        return r < x.r;
      return l > x.l;
    }
    return l - r > x.l - x.r;
  }
} arr[2000007], brr[2000007];
int main() {
  int n;
  cin >> n;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    int l = 0, r = 0;
    for (int j = 0; j < (int)s.length(); j++) {
      if (s[j] == '(')
        l++;
      else if (l)
        l--;
      else
        r++;
    }
    arr[i] = {l, r, i};
    brr[i] = {r, l, i};
  }
  sort(arr, arr + n);
  sort(brr, brr + n);
  int ll = 0;
  for (int i = 0; i < n; i++) {
    if (ll < arr[i].r) {
      cout << "No" << endl;
      return 0;
    } else
      ll += arr[i].l - arr[i].r;
  }

  if (ll == 0) {
    cout << "Yes" << endl;
    /* for(int i=0; i<n; i++)
         cout<<arr[i].i+1<<' ';
     cout<<endl;*/
  } else
    cout << "No" << endl;
  return 0;
}
Problem p02686 (C++)

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

#define ln '\n'
#define all(dat) dat.begin(), dat.end()
#define loop(i, to) for (int i = 0; i < to; ++i)
#define cont(i, to) for (int i = 1; i <= to; ++i)
#define circ(i, fm, to) for (int i = fm; i <= to; ++i)
#define foreach(i, dat)                                                        \
  for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long num;

using namespace std;

const int nsz = int(1e3);
int n, sum, pre[nsz + 5], mn[nsz + 5];
pair<int, int> dat[nsz + 5];
string s[nsz + 5];

bool inline cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first > 0 && b.first > 0)
    return a.second > b.second;
  if (a.first < 0 && b.first < 0)
    return a.second - a.first < b.second - b.first;
  return a.first > b.first;
}

int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  cont(i, n) {
    cin >> s[i];
    int cur = 0;
    loop(j, s[i].size()) {
      char c = s[i][j];
      cur += c == '(' ? +1 : -1;
      mn[i] = min(mn[i], cur);
    }
    pre[i] = cur;
    sum += cur;
    dat[i] = make_pair(pre[i], mn[i]);
  }
  if (sum != 0) {
    cout << "No" << ln;
    return 0;
  }
  sort(dat + 1, dat + n + 1, cmp);
  int cur = 0;
  cont(i, n) {
    int a = dat[i].first, b = dat[i].second;
    if (cur + b < 0) {
      cout << "No" << ln;
      return 0;
    }
    cur += a;
  }
  cout << "Yes" << ln;
}

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

#define ln '\n'
#define all(dat) dat.begin(), dat.end()
#define loop(i, to) for (int i = 0; i < to; ++i)
#define cont(i, to) for (int i = 1; i <= to; ++i)
#define circ(i, fm, to) for (int i = fm; i <= to; ++i)
#define foreach(i, dat)                                                        \
  for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long num;

using namespace std;

const int nsz = int(1e6);
int n, sum, pre[nsz + 5], mn[nsz + 5];
pair<int, int> dat[nsz + 5];
string s[nsz + 5];

bool inline cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first > 0 && b.first > 0)
    return a.second > b.second;
  if (a.first < 0 && b.first < 0)
    return a.second - a.first < b.second - b.first;
  return a.first > b.first;
}

int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  cont(i, n) {
    cin >> s[i];
    int cur = 0;
    loop(j, s[i].size()) {
      char c = s[i][j];
      cur += c == '(' ? +1 : -1;
      mn[i] = min(mn[i], cur);
    }
    pre[i] = cur;
    sum += cur;
    dat[i] = make_pair(pre[i], mn[i]);
  }
  if (sum != 0) {
    cout << "No" << ln;
    return 0;
  }
  sort(dat + 1, dat + n + 1, cmp);
  int cur = 0;
  cont(i, n) {
    int a = dat[i].first, b = dat[i].second;
    if (cur + b < 0) {
      cout << "No" << ln;
      return 0;
    }
    cur += a;
  }
  cout << "Yes" << ln;
}
Problem p02687 (C++)

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

int main() {
  char a[3];
  cin >> a[1] >> a[2] >> a[3];
  if (a[2] == 'B')
    cout << "ARC";
  else
    cout << "ABC";
  return 0;
}


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

int main() {
  char a[3];
  cin >> a[0] >> a[1] >> a[2];
  if (a[1] == 'B')
    cout << "ARC";
  else
    cout << "ABC";
  return 0;
}
Problem p02687 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)-1); i > 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  string s;
  scanf("%s", &s);
  if (s == "ARC")
    cout << "ABC" << endl;
  else
    cout << "ARC" << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)-1); i > 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  string s;
  cin >> s;
  if (s == "ARC")
    cout << "ABC" << endl;
  else
    cout << "ARC" << endl;
  return 0;
}
Problem p02687 (C++)

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

int main() {
  char contest;
  scanf("%s", &contest);

  if (contest = 'B') {
    printf("ARC");
  } else if (contest = 'R') {
    printf("ABC");
  }
  return 0;
}

Fixed submission:
#include <stdio.h>

int main() {
  char S[6];
  scanf("%s", &S);
  if (S[1] == 'B')
    printf("ARC\n");
  else
    printf("ABC\n");
  return 0;
}
Problem p02687 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, k;
  cin >> k;
  cin >> a >> b;
  int max = b / k;
  bool flag = false;
  for (int i = 1; i <= max + 2; i++) {
    if (i * k <= b && i * k >= a)
      flag = true;
  }
  if (flag)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s == "ABC")
    cout << "ARC" << endl;
  else if (s == "ARC")
    cout << "ABC" << endl;
}
Problem p02687 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
int main(int argc, char **argv) {
  std::string S = argv[1];
  if (S == "ARC")
    std::cout << "ABC" << std::endl;
  else
    std::cout << "ARC" << std::endl;
  return 0;
}

Fixed submission:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
int main(int argc, char **argv) {
  std::string S;
  std::cin >> S;
  if (S == "ARC")
    std::cout << "ABC" << std::endl;
  else
    std::cout << "ARC" << std::endl;
  return 0;
}
Problem p02687 (C++)

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

#define ll long long

string replaceOtherStr(std::string &replacedStr, std::string from,
                       std::string to) {
  const unsigned int pos = replacedStr.find(from);
  const int len = from.length();

  if (pos == std::string::npos || from.empty()) {
    return replacedStr;
  }

  return replacedStr.replace(pos, len, to);
}

int main() {
  string S;
  cin >> S;

  replaceOtherStr(S, "BC", "RC");

  cout << S << endl;
}

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

#define ll long long

string replaceOtherStr(std::string &replacedStr, std::string from,
                       std::string to) {
  const unsigned int pos = replacedStr.find(from);
  const int len = from.length();

  if (pos == std::string::npos || from.empty()) {
    return replacedStr;
  }

  return replacedStr.replace(pos, len, to);
}

int main() {
  string S;
  cin >> S;

  if (S == "ABC")
    replaceOtherStr(S, "BC", "RC");
  else
    replaceOtherStr(S, "RC", "BC");

  cout << S << endl;
}
Problem p02687 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  char a[5];
  cin >> a[5];
  if (a[1] == 'B')
    cout << "ARC";
  else
    cout << "ABC";
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  char a[10];
  cin >> a;
  if (a[0] == 'A' && a[1] == 'B' && a[2] == 'C')
    cout << "ARC" << endl;
  else if (a[0] == 'A' && a[1] == 'R' && a[2] == 'C')
    cout << "ABC" << endl;
  return 0;
}
Problem p02687 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end)                                                     \
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \
       i != (end) - ((begin) > (end));                                         \
       i += 1 - 2 * ((begin) >                                                 \
                     (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) -->
                             // {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> mp(n + 1, 0);
  rep(i, 1, n) {
    int a;
    cin >> a;
    mp[a]++;
  }
  rep(x, 1, n + 1) cout << mp[x] << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end)                                                     \
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \
       i != (end) - ((begin) > (end));                                         \
       i += 1 - 2 * ((begin) >                                                 \
                     (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) -->
                             // {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main() {
  string s;
  cin >> s;
  cout << (s == "ABC" ? "ARC" : "ABC");
  return 0;
}
Problem p02688 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  int d;
  int e;
  int c;
  cin >> N >> K;
  vector<int> a(N);
  for (int j = 0; j < K; j++) {
    a.at(j) = 0;
  }
  for (int l = 0; l < K; l++) {
    cin >> d;
    for (int i = 0; i < d; i++) {
      cin >> e;
      a.at(e - 1) = 1;
    }
  }
  for (int m = 0; m < N; m++) {
    if (a.at(m) == 0)
      c++;
  }
  cout << c << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  int d;
  int e;
  int c;
  cin >> N >> K;
  vector<int> a(N);
  for (int j = 0; j < N; j++) {
    a.at(j) = 0;
  }
  for (int l = 0; l < K; l++) {
    cin >> d;
    for (int i = 0; i < d; i++) {
      cin >> e;
      a.at(e - 1) = 1;
    }
  }
  for (int m = 0; m < N; m++) {
    if (a.at(m) == 0)
      c++;
  }
  cout << c << endl;
}
Problem p02688 (C++)

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);

  int d;
  for (int i = 0; i < k; ++i) {
    cin >> d;
    if (d != 0) {
      vector<int> a(d);
      for (int j = 0; j < d; ++j) {
        cin >> a[i];
        vec[a[i] - 1]++;
      }
    }
  }
  int count = 0;
  for (int i = 0; i < n; ++i) {
    if (vec[i] == 0) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);

  int d;
  for (int i = 0; i < k; ++i) {
    cin >> d;
    vector<int> a(d);
    for (int j = 0; j < d; ++j) {
      cin >> a[j];
      vec[a[j] - 1]++;
    }
  }
  int count = 0;
  for (int i = 0; i < n; ++i) {
    if (vec[i] == 0) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
Problem p02688 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
// 型名省略
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<long long>> vvl;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
// マクロ
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep2(i, x, n) for (ll i = (ll)x; i < (ll)n; i++)
#define all(A) A.begin(), A.end()
// 正誤判定
void Yes(bool ans) { cout << (ans ? "Yes" : "No") << endl; }
void YES(bool ans) { cout << (ans ? "YES" : "NO") << endl; }

// main関数
int main() {
  ll n, k;
  cin >> n >> k;
  vl have(n), d(k);
  vvl a(n, vl(k));
  rep(i, k) {
    cin >> d[i];
    rep(j, d[i]) {
      cin >> a[i][j];
      a[i][j]--;
      have[a[i][j]]++;
    }
  }

  ll ans = 0;
  rep(i, n) {
    if (have[i] == 0)
      ans++;
  }

  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
// 型名省略
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<long long>> vvl;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
// マクロ
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep2(i, x, n) for (ll i = (ll)x; i < (ll)n; i++)
#define all(A) A.begin(), A.end()
// 正誤判定
void Yes(bool ans) { cout << (ans ? "Yes" : "No") << endl; }
void YES(bool ans) { cout << (ans ? "YES" : "NO") << endl; }

// main関数
int main() {
  ll n, k;
  cin >> n >> k;
  vl have(n), d(k);
  vvl a(k, vl(n));
  rep(i, k) {
    cin >> d[i];
    rep(j, d[i]) {
      cin >> a[i][j];
      a[i][j]--;
      have[a[i][j]]++;
    }
  }

  ll ans = 0;
  rep(i, n) {
    if (have[i] == 0)
      ans++;
  }

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

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

int main() {
  int N, K;
  cin >> N >> K;
  int d;
  int a;
  vector<bool> S(N, true);
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int i = 0; i < d; i++) {
      cin >> a;
      S.at(a) = false;
    }
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i)) {
      count++;
    }
  }
  cout << count << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int d;
  int a;
  vector<bool> S(N, true);
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int i = 0; i < d; i++) {
      cin >> a;
      S.at(a - 1) = false;
    }
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i)) {
      count++;
    }
  }
  cout << count << endl;
}
Problem p02688 (C++)

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

int main() {
  int N, K;
  cin >> N >> K;
  int d[K];
  int A[N][N];
  int have_bool[N];
  for (int i = 0; i < N; i++) {
    have_bool[i] = false;
  }

  for (int i = 0; i < K; ++i) {
    cin >> d[i];

    for (int j = 0; j < d[i]; ++j) {
      cin >> A[i][j];
      have_bool[A[i][j] - 1] = true;
    }
  }

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (!have_bool[i])
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int d[K];
  int A[K][N];
  int have_bool[N];
  for (int i = 0; i < N; i++) {
    have_bool[i] = false;
  }

  for (int i = 0; i < K; ++i) {
    cin >> d[i];

    for (int j = 0; j < d[i]; ++j) {
      cin >> A[i][j];
      have_bool[A[i][j] - 1] = true;
    }
  }

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (!have_bool[i])
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}
Problem p02688 (C++)

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

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

  vector<int> sunuke(N);

  for (int j = 0; j < K; j++) {

    int d;
    cin >> d;

    for (int i = 0; i < d; i++) {
      int A;
      cin >> A;
      sunuke.at(A) = 1;
    }
  }

  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += sunuke.at(i);
  }

  cout << N - sum << endl;
}


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

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

  vector<int> sunuke(N);

  for (int j = 0; j < K; j++) {

    int d;
    cin >> d;

    for (int i = 0; i < d; i++) {
      int A;
      cin >> A;
      sunuke.at(A - 1) = 1;
    }
  }

  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += sunuke.at(i);
  }

  cout << N - sum << endl;
}
Problem p02688 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(a, b)                                                            \
  if ((a) > (b))                                                               \
    (a) = (b);
#define chmax(a, b)                                                            \
  if ((a) < (b))                                                               \
    (a) = (b);
#define vi vector<int>
#define pii pair<int, int>
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define pb push_back
#define pf push_front
int gcd(int a, int b) { /*a>=0,b>=0,￢(a=b=0)*/
  while (min(a, b) > 0) {
    if (a < b)
      swap(a, b);
    a %= b;
  }
  return max(a, b);
}
int dx[] = {0, 1, 0, -1, 1, -1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int MOD = 1e9 + 7;
const int INF = 1e18 + 10;

/*----------------------------------------------*/

signed main() {
  int n, k;
  cin >> n >> k;
  vi d(k);
  vector<vi> a(k, vi(n));
  rep(i, k) {
    cin >> d[i];
    rep(j, d[i]) cin >> a[i][j];
  }
  vi cnt(n + 1, 0);
  rep(i, n) rep(j, d[i]) { cnt[a[i][j]]++; }
  int ans = 0;
  FOR(i, 1, n) if (cnt[i] == 0) ans++;

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(a, b)                                                            \
  if ((a) > (b))                                                               \
    (a) = (b);
#define chmax(a, b)                                                            \
  if ((a) < (b))                                                               \
    (a) = (b);
#define vi vector<int>
#define pii pair<int, int>
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define pb push_back
#define pf push_front
int gcd(int a, int b) { /*a>=0,b>=0,￢(a=b=0)*/
  while (min(a, b) > 0) {
    if (a < b)
      swap(a, b);
    a %= b;
  }
  return max(a, b);
}
int dx[] = {0, 1, 0, -1, 1, -1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int MOD = 1e9 + 7;
const int INF = 1e18 + 10;

/*----------------------------------------------*/

signed main() {
  int n, k;
  cin >> n >> k;
  vi d(k);
  vector<vi> a(k, vi(n));
  rep(i, k) {
    cin >> d[i];
    rep(j, d[i]) cin >> a[i][j];
  }
  vi cnt(n + 1, 0);
  rep(i, k) rep(j, d[i]) { cnt[a[i][j]]++; }
  int ans = 0;
  FOR(i, 1, n) if (cnt[i] == 0) ans++;

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

Buggy submission (status: Runtime Error):
// in the name of ALLAH
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n, k;
  cin >> n >> k;
  set<int> s;
  int d[n];
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    int a[d[i] + 1];
    for (int j = 0; j < d[i]; j++) {
      cin >> a[j];
      s.insert(a[j]);
    }
  }
  cout << n - s.size() << endl;
}


Fixed submission:
// in the name of ALLAH
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n, k;
  cin >> n >> k;
  set<int> s;
  int d[k + 1];
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    int a[d[i] + 1];
    for (int j = 0; j < d[i]; j++) {
      cin >> a[j];
      s.insert(a[j]);
    }
  }
  cout << n - s.size() << endl;
}
Problem p02688 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N); // N人の子供を宣言
  // どの子供がどれだけお菓子をもらったかを入力
  for (int i = 0; i < K; i++) {
    int di; // i番目のお菓子をもってる人数
    cin >> di;
    int Ai; // i番目のお菓子を持ってる人の番号
    for (int j = 0; j < di; j++) {
      cin >> Ai;     // お菓子を持ってる人の番号を入力
      A.at(Ai) += 1; // お菓子をもらった人のお菓子の数を＋１
    }
  }
  // A(N)の値を順に調べていって値が0の人数をカウントする
  int count = 0;
  for (int x : A) { // Aの値xをすべて調べる
    if (x == 0)
      count++;
  }
  cout << count << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N); // N人の子供を宣言
  // どの子供がどれだけお菓子をもらったかを入力
  for (int i = 0; i < K; i++) {
    int di; // i番目のお菓子をもってる人数
    cin >> di;
    int Ai; // i番目のお菓子を持ってる人の番号
    for (int j = 0; j < di; j++) {
      cin >> Ai;         // お菓子を持ってる人の番号を入力
      A.at(Ai - 1) += 1; // お菓子をもらった人のお菓子の数を＋１
    }
  }
  // A(N)の値を順に調べていって値が0の人数をカウントする
  int count = 0;
  for (int x : A) { // Aの値xをすべて調べる
    if (x == 0)
      count++;
  }
  cout << count << endl;
}
Problem p02688 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, K;
  int d, x;
  int count = 0;

  cin >> N >> K;
  vector<int> sunuke(N);
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> x;
      sunuke.at(x - 1) = 1;
    }
  }

  for (int i = 0; i < K; i++) {
    if (sunuke.at(i) == 0)
      count++;
  }

  cout << count;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, K;
  int d, x;
  int count = 0;

  cin >> N >> K;
  vector<int> sunuke(N);
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> x;
      sunuke.at(x - 1) = 1;
    }
  }

  for (int i = 0; i < N; i++) {
    if (sunuke.at(i) == 0)
      count++;
  }

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

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;
int main(void) {

  int n, k, p, a, ni = 0;
  string s;

  cin >> n >> k;

  for (int i = 0; i < n; i++) {
    s[i] = 0;
  }

  for (int j = 0; j < k; j++) {

    cin >> p;
    for (int z = 0; z < p; z++) {

      cin >> a;
      s[a - 1] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == 0)
      ni++;
  }
  cout << ni << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main(void) {

  int n, k, p, a, ni = 0;
  int s[100];

  cin >> n >> k;

  for (int i = 0; i < n; i++) {
    s[i] = 0;
  }

  for (int j = 0; j < k; j++) {

    cin >> p;
    for (int z = 0; z < p; z++) {

      cin >> a;
      s[a - 1] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == 0)
      ni++;
  }
  cout << ni << endl;

  return 0;
}
Problem p02688 (C++)

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

int main() {
  int n, k;

  cin >> n >> k;

  int d, a;
  int sum = 0;

  vector<int> flag(n, 0);

  rep(i, k) {
    cin >> d;
    rep(i, d) {
      cin >> a;
      flag.at(a - 1) = 1;
    }
  }

  rep(i, k) {
    // cout << flag.at(i);
    if (flag.at(i) == 0)
      sum += 1;
  }

  cout << sum;
}

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

int main() {
  int n, k;

  cin >> n >> k;

  int d, a;
  int sum = 0;

  vector<int> flag(n, 0);

  rep(i, k) {
    cin >> d;
    rep(i, d) {
      cin >> a;
      flag.at(a - 1) = 1;
    }
  }

  rep(i, n) {
    // cout << flag.at(i);
    if (flag.at(i) == 0)
      sum += 1;
  }

  cout << sum;
}
Problem p02688 (C++)

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

int main() {
  int N, K, x = 0;
  cin >> N >> K;
  vector<vector<int>> sunuke(N, vector<int>(0));
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A;
      cin >> A;
      sunuke.at(A).push_back(i);
    }
  }
  for (int i = 0; i < N; i++) {
    if (sunuke.at(i).size() == 0)
      x++;
  }
  cout << x << endl;
}

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

int main() {
  int N, K, x = 0;
  cin >> N >> K;
  vector<vector<int>> sunuke(N, vector<int>(0));
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A;
      cin >> A;
      sunuke.at(A - 1).push_back(i);
    }
  }
  for (int i = 0; i < N; i++) {
    if (sunuke.at(i).size() == 0)
      x++;
  }
  cout << x << endl;
}
Problem p02688 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main() {
  int c = 0, i = 0, k, d, n = 0, x, s[1000];
  cin >> x >> k;
  while (k--) {
    cin >> d;
    n += d;
    while (d--) {
      cin >> s[i++];
    }
  }
  sort(s, s + n);
  c = 0;
  for (i = 0; i < n; i++) {
    if (s[i] != s[i + 1])
      c++;
  }
  cout << x - c << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main() {
  int c = 0, i = 0, k, d, n = 0, x, s[10010];
  cin >> x >> k;
  while (k--) {
    cin >> d;
    n += d;
    while (d--) {
      cin >> s[i++];
    }
  }
  sort(s, s + n);
  c = 0;
  for (i = 0; i < n; i++) {
    if (s[i] != s[i + 1])
      c++;
  }
  cout << x - c << endl;
  return 0;
}
Problem p02688 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int m, n, i, j, x, y, g;
bool f[101];
int main() {
  cin >> m >> n;
  for (i = 1; i <= n; i++) {
    cin >> x;
    for (i = j = 1; j <= x; j++) {
      cin >> y;
      f[y] = 1;
    }
  }
  for (i = 1; i <= m; i++)
    if (f[i] == 0)
      g++;
  cout << g;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int m, n, i, j, x, y, g;
bool f[101];
int main() {
  cin >> m >> n;
  for (i = 1; i <= n; i++) {
    cin >> x;
    for (j = 1; j <= x; j++) {
      cin >> y;
      f[y] = 1;
    }
  }
  for (i = 1; i <= m; i++)
    if (f[i] == 0)
      g++;
  cout << g;
  return 0;
}
Problem p02688 (C++)

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> d(k);
  for (int i = 0; i < n + 1; i++)
    a[i] = 0;
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      int x;
      cin >> x;
      a[x]++;
    }
  }
  int cnt = 0;
  for (int i = 1; i < n + 1; i++) {
    if (a[i] == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  vector<int> d(k);
  for (int i = 0; i < n + 1; i++)
    a[i] = 0;
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      int x;
      cin >> x;
      a[x]++;
    }
  }
  int cnt = 0;
  for (int i = 1; i < n + 1; i++) {
    if (a[i] == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p02688 (C++)

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> have(n);
  vector<int> d(k);
  rep(i, k) {
    int a;
    cin >> a;
    rep(j, a) {
      int b;
      cin >> b;
      have.at(b) = 1;
    }
  }
  int count = 0;
  rep(i, n) {
    if (have.at(i) == 1)
      continue;
    count++;
  }
  cout << count;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> have(n);
  vector<int> d(k);
  rep(i, k) {
    int a;
    cin >> a;
    rep(j, a) {
      int b;
      cin >> b;
      have.at(b - 1) = 1;
    }
  }
  int count = 0;
  rep(i, n) {
    if (have.at(i) == 1)
      continue;
    count++;
  }
  cout << count;
}
Problem p02688 (C++)

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

int main() {
  int N, K;
  cin >> N >> K;
  bitset<100> A;
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int k;
      cin >> k;
      A.set(k);
    }
  }

  cout << N - A.count() << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  bitset<100> A;
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int k;
      cin >> k;
      A.set(k - 1);
    }
  }

  cout << N - A.count() << endl;
}
Problem p02688 (C++)

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

int main() {

  int N, K;
  cin >> N >> K;
  vector<bool> exist(N, false);
  rep(i, K) {
    int d;
    cin >> d;
    rep(j, d) {
      int A;
      cin >> A;
      exist.at(A) = true;
    }
  }
  int cnt = 0;
  rep(i, N) {
    if (!exist.at(i))
      cnt++;
  }
  cout << cnt << endl;
}


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

int main() {

  int N, K;
  cin >> N >> K;
  vector<bool> exist(N, false);
  rep(i, K) {
    int d;
    cin >> d;
    rep(j, d) {
      int A;
      cin >> A;
      exist.at(A - 1) = true;
    }
  }
  int cnt = 0;
  rep(i, N) {
    if (!exist.at(i))
      cnt++;
  }
  cout << cnt << endl;
}
Problem p02688 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (i = 0; i < n; i++)
#define rep1(i, n) for (i = 1; i <= n; i++)
#define test(a) cout << "*" << a << endl
#define ll long long
int main() {
  int n, k;
  int d[100];
  int A[100][100];
  int i, j;
  bool human[101] = {false};
  int humanNo = 0;

  cin >> n >> k;
  rep1(i, k) {
    cin >> d[i];
    rep1(j, d[i]) {
      cin >> A[i][j];
      human[A[i][j]] = true;
    }
  }
  rep1(i, n) {
    if (human[i] == false) {
      humanNo++;
      // test(i);
    }
  }
  cout << humanNo << endl;

  /*rep1(i,k){
    test(d[i]);
    rep1(j,d[i]){
      test(A[i][j]);
    }
  }*/
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (i = 0; i < n; i++)
#define rep1(i, n) for (i = 1; i <= n; i++)
#define test(a) cout << "*" << a << endl
#define ll long long
int main() {
  int n, k;
  int d[101];
  int A[101][101];
  int i, j;
  bool human[101] = {false};
  int humanNo = 0;

  cin >> n >> k;
  rep1(i, k) {
    cin >> d[i];
    rep1(j, d[i]) {
      cin >> A[i][j];
      human[A[i][j]] = true;
    }
  }
  rep1(i, n) {
    if (human[i] == false) {
      humanNo++;
      // test(i);
    }
  }
  cout << humanNo << endl;

  /*rep1(i,k){
    test(d[i]);
    rep1(j,d[i]){
      test(A[i][j]);
    }
  }*/
}
Problem p02688 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int index = 0;
  int p = k * (k + 1) / 2;
  int arr[p];
  while (k--) {
    int s;

    cin >> s;
    for (int i = 0; i < s; i++) {
      cin >> arr[index];
      index++;
    }
  }
  sort(arr, arr + index);

  int count = 1;
  for (int i = 1; i < index; i++) {
    if (arr[i] != arr[i - 1])
      count++;
  }
  cout << n - count;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int index = 0;

  int arr[10000];
  while (k--) {
    int s;

    cin >> s;
    for (int i = 0; i < s; i++) {
      cin >> arr[index];
      index++;
    }
  }
  sort(arr, arr + index);

  int count = 1;
  for (int i = 1; i < index; i++) {
    if (arr[i] != arr[i - 1])
      count++;
  }
  cout << n - count;
  return 0;
}
Problem p02688 (C++)

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

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

  vector<vector<int>> vec(K, vector<int>(N, 0));

  // おかしを持っているかどうかに印を付ける//
  for (int i = 0; i < K; i++) {
    int T; // Tは持ってる人間の数、i番目のおかしの数//
    cin >> T;
    for (int j = 0; j < T; j++) {
      int f; // fが持ってる人間の番号//
      cin >> f;
      vec.at(i).at(f - 1) = 1; // 持っている人間を1と置く(持っている判定にする)//
    }
  }
  // 作成した表を用いて持っていない人間を判定する//
  int count = 0;
  for (int i = 0; i < N; i++) { // N人について、１番から順に確かめる//
    for (int j = 0; j < K; j++) {
      if (vec.at(j).at(i) == 1) {
        break;
      } else if (j = K - 1 && vec.at(j).at(i) == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
}

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

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

  vector<vector<int>> vec(K, vector<int>(N, 0));

  // おかしを持っているかどうかに印を付ける//
  for (int i = 0; i < K; i++) {
    int T; // Tは持ってる人間の数、i番目のおかしの数//
    cin >> T;
    for (int j = 0; j < T; j++) {
      int f; // fが持ってる人間の番号//
      cin >> f;
      vec.at(i).at(f - 1) = 1; // 持っている人間を1と置く(持っている判定にする)//
    }
  }
  // 作成した表を用いて持っていない人間を判定する//
  int count = 0;
  for (int i = 0; i < N; i++) { // N人について、１番から順に確かめる//
    for (int j = 0; j < K; j++) {
      if (vec.at(j).at(i) == 1) {
        break;
      } else if (j == K - 1 && vec.at(j).at(i) == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p02688 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define FAST                                                                   \
  ios_base ::sync_with_stdio(false);                                           \
  cin.tie(NULL);

int main() {
  FAST;
  int N, K, d, A;
  cin >> N >> K;
  vector<int> X(N, 1);
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int i = 0; i < d; i++) {
      cin >> A;
      X.at(A - 1) = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += X.at(i);
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define FAST                                                                   \
  ios_base ::sync_with_stdio(false);                                           \
  cin.tie(NULL);

int main() {
  FAST;
  int N, K, d, A;
  cin >> N >> K;
  vector<int> X(N, 1);
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int i = 0; i < d; i++) {
      cin >> A;
      X.at(A - 1) = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += X.at(i);
  }
  cout << ans << endl;
}
Problem p02688 (C++)

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>>
    vec_p; // vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1; // llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

  ll N, K;

  cin >> N >> K;

  vector<ll> d(K);
  vector<vector<ll>> A(K, vector<ll>(K));

  REP(i, K) {
    cin >> d.at(i);
    REP(j, d.at(i)) { cin >> A.at(i).at(j); }
  }

  vector<ll> vec;
  vec.push_back(0);

  REP(i, K) {
    REP(j, d.at(i)) { vec.push_back(A.at(i).at(j)); }
  }

  sort(vec.begin(), vec.end());
  // cout << vec.size() << endl;

  ll tmp = 0;

  REP(i, vec.size() - 1) {
    if (!(vec.at(i) == vec.at(i + 1))) {
      tmp++;
    }
    // cout << tmp<<endl;
  }
  cout << N - tmp << endl;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>>
    vec_p; // vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1; // llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

  ll N, K;

  cin >> N >> K;

  vector<ll> d(K);
  vector<vector<int>> A(K, vector<int>(N));

  REP(i, K) {
    cin >> d.at(i);
    REP(j, d.at(i)) { cin >> A.at(i).at(j); }
  }

  vector<ll> vec;
  vec.push_back(0);

  REP(i, K) {
    REP(j, d.at(i)) { vec.push_back(A.at(i).at(j)); }
  }

  sort(vec.begin(), vec.end());
  // cout << vec.size() << endl;

  ll tmp = 0;

  REP(i, vec.size() - 1) {
    if (!(vec.at(i) == vec.at(i + 1))) {
      tmp++;
    }
    // cout << tmp<<endl;
  }
  cout << N - tmp << endl;
}
Problem p02688 (C++)

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

using namespace std;

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

  int arr[n];
  for (int i = 0; i < k; i++) {
    arr[i] = 0;
  }

  for (int i = 0; i < k; i++) {
    int n1;
    cin >> n1;

    for (int j = 0; j < n1; j++) {
      int x;
      cin >> x;
      arr[x - 1]++;
    }
  }

  int ans = 0;

  for (int i = 0; i < n; i++) {
    if (arr[i] == 0) {
      ans++;
    }
  }

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

  return 0;
}


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

using namespace std;

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

  int arr[n];
  for (int i = 0; i < n; i++) {
    arr[i] = 0;
  }

  for (int i = 0; i < k; i++) {
    int n1;
    cin >> n1;

    for (int j = 0; j < n1; j++) {
      int x;
      cin >> x;
      arr[x - 1]++;
    }
  }

  int ans = 0;

  for (int i = 0; i < n; i++) {
    if (arr[i] == 0) {
      ans++;
    }
  }

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

  return 0;
}
Problem p02688 (C++)

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

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

  int d[N];
  int A[K][N];

  for (int k = 0; k < K; k++)
    for (int i = 0; i < N; i++)
      A[k][i] = 0;

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

  bool holder[N];
  for (int i = 0; i < N; i++)
    holder[i] = false;

  for (int k = 0; k < K; k++) {
    for (int i = 0; i < d[k]; i++) {
      if (A[k][i] != 0)
        holder[A[k][i] - 1] = true;
    }
  }

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (holder[i])
      cnt++;
  }

  cout << N - cnt << endl;
}

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

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

  int d[K];
  int A[K][N];

  for (int k = 0; k < K; k++)
    for (int i = 0; i < N; i++)
      A[k][i] = 0;

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

  bool holder[N];
  for (int i = 0; i < N; i++)
    holder[i] = false;

  for (int k = 0; k < K; k++) {
    for (int i = 0; i < d[k]; i++) {
      if (A[k][i] != 0)
        holder[A[k][i] - 1] = true;
    }
  }

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (holder[i])
      cnt++;
  }

  cout << N - cnt << endl;
}
Problem p02688 (Python)

Buggy submission (status: Runtime Error):
N, K = map(int, input().split())

have_snack = [0 for i in range(N)]

for k in range(K):
    hito_len = int(input())
    have_hito = map(int, input().split())
    for hh in range(have_hito):
        have_snack[hh - 1] = 1

print(have_snack.count(0))


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

have_snack = [0 for i in range(N)]

for k in range(K):
    hito_len = int(input())
    have_hito = list(map(int, input().split()))
    for hh in have_hito:
        have_snack[hh - 1] = 1

print(have_snack.count(0))
Problem p02688 (Python)

Buggy submission (status: Runtime Error):
def main(n, a):
    indexes = {i + 1 for i in range(n)}
    reduced = set()
    for s in a:
        reduced |= s
    return len(indexes - reduced)


if __name__ == "__main__":
    S = input().rstrip()
    N, K = map(int, input().split())
    A = []
    for _ in range(K):
        input()
        A.append(set(tuple(map(int, input().split(" ")))))
    print(main(N, A))


Fixed submission:
def main(n, a):
    indexes = {i + 1 for i in range(n)}
    reduced = set()
    for s in a:
        reduced |= s
    return len(indexes - reduced)


if __name__ == "__main__":
    N, K = map(int, input().split())
    A = []
    for _ in range(K):
        input()
        A.append(set(tuple(map(int, input().split(" ")))))
    print(main(N, A))
Problem p02688 (Python)

Buggy submission (status: Runtime Error):
N, K = map(int, input().split())

check = [0] * N

for i in range(K):
    d_i = int(input())
    A_i = map(int, input().split())
    for j in A_i:
        check[j] = 1

print(sum(1 for x in check if x == 0))


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

check = [0] * N

for i in range(K):
    d_i = int(input())
    A_i = map(int, input().split())
    for j in A_i:
        check[j - 1] = 1

print(sum(1 for x in check if x == 0))
Problem p02688 (C++)

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> vec(N, 0);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      vec.at(a - 1)++;
    }
  }

  int ans = 0;
  for (int i = 0; i < K; i++) {
    if (vec.at(i) == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> vec(N, 0);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      vec.at(a - 1)++;
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (vec.at(i) == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}