alexjercan/bugnet huggingface dataset:
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

template <typename T> void printVec(vector<T> &vec) {
  cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}

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

  vector<int> sunuke(n, 0);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    vector<int> a(d);

    for (int j = 0; j < d; j++) {
      cin >> a[j];
      sunuke[a[j] - 1] = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (sunuke[i] == 0) {
      ans = ans + 1;
    }
  }
  // printVec(sunuke);
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

template <typename T> void printVec(vector<T> &vec) {
  cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}

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

  vector<int> sunuke(n, 0);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    vector<int> a(d);

    for (int j = 0; j < d; j++) {
      cin >> a[i];
      sunuke[a[i] - 1] = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (sunuke[i] == 0) {
      ans = ans + 1;
    }
  }
  // printVec(sunuke);
  cout << ans << endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d(K);
  vector<int> S(N, 1);
  vector<vector<int>> A(K, vector<int>(N));
  for (int i = 0; i < K; ++i) {
    int d[i];
    cin >> d[i];
    for (int j = 0; j < d[i]; ++j) {
      cin >> A[i][j];
      S[A[i][j] - 1] = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += S[i];
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d(K);
  vector<int> S(N, 1);
  vector<vector<int>> A(K, vector<int>(N));
  for (int i = 0; i < K; ++i) {
    int d[i];
    cin >> d[i];
    for (int j = 0; j <= d[i]; ++j) {
      cin >> A[i][j];
      S[A[i][j]] = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += S[i];
  }
  cout << ans << endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <cstdint> // int64_t, int*_t
#include <cstdio>  // printf
#include <cstring>
#include <deque>    // deque
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d(101);
  set<int> S;
  vector<vector<int>> A(101, vector<int>(101));
  rep(i, K) {
    cin >> d[i];
    rep(j, d[i]) {
      cin >> A[i][j];
      S.insert(A[i][j]);
    }
  }

  int count = 0;
  for (int i = 1; i <= N; i++) {
    if (S.count(i)) {
      count++;
    }
  }
  cout << N - count << endl;
}

Error: 0

Fixed submission:

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <cstdint> // int64_t, int*_t
#include <cstdio>  // printf
#include <cstring>
#include <deque>    // deque
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d(N);
  set<int> S;
  vector<vector<int>> A(101, vector<int>(101));
  rep(i, K) {
    cin >> d[i];
    rep(j, d[i]) {
      cin >> A[i][j];
      S.insert(A[i][j]);
    }
  }

  int count = 0;
  for (int i = 1; i <= N; i++) {
    if (S.count(i)) {
      count++;
    }
  }
  cout << N - count << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<vector<int>> hito(K);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int bango;
      cin >> bango;
      hito[i].push_back(bango);
    }
  }
  int key = 0;
  vector<int> count(N + 1);
  for (int h = 1; h <= N; h++) {
    for (int i = 0; i < K; i++) {
      for (int j = 0; j < hito[i].size(); j++) {
        if (hito[i][j] == h) {
          count[h]++;
        }
      }
    }
    if (count[h] > 0) {
      key++;
    }
  }
  cout << N - key << endl;
}

Error: -11

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<vector<int>> hito(K);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int bango;
      cin >> bango;
      hito[i].push_back(bango);
    }
  }
  int bee = 0;
  vector<int> count;
  for (int h = 1; h <= N; h++) {
    for (int i = 0; i < K; i++) {
      for (int j = 0; j < hito[i].size(); j++) {
        if (hito[i][j] == h) {
          count[h]++;
        }
      }
    }
    if (count[h] > 0) {
      bee++;
    }
  }
  cout << N - bee << endl;
}
Problem p02688 (C++) — buggy submission, verdict: 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<bool> ans(N, false);

  rep(i, K) {
    int d;
    cin >> d;
    vector<int> A(d);
    rep(j, d) cin >> A[j];

    rep(j, d) { ans[A[j] - 1] = true; }
  }
  int cnt = 0;
  rep(i, N) {
    if (ans[i] == false) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Error: 0

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<bool> ans(N, false);

  rep(i, K) {
    int d;
    cin >> d;
    vector<int> A(d);
    cin >> A[i];

    rep(k, d) { ans[A[k]] = true; }
  }
  int cnt = 0;
  rep(i, N) {
    if (ans[i] == false) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, k, cnt = 0;
  cin >> n >> k;
  vector<int> d(k), ans(n);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int c;
      cin >> c;
      ans.at(c - 1)++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (ans.at(i) == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Error: 0

Fixed submission:

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

int main() {
  int n, k, res = 0;
  cin >> n >> k;
  vector<int> ans(n, 0);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int s;
      cin >> s;
      ans.at(s - 1)++;
    }
  }
  for (int i = 0; i < k; i++) {
    if (ans.at(i) == 0) {
      res++;
    }
  }
  cout << res << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i <= end; i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> auto MAX(const T &a) {
  return *max_element(a.begin(), a.end());
}
template <class T> auto MIN(const T &a) {
  return *min_element(a.begin(), a.end());
}
template <class T, class U> U SUM(const T &a, const U &v) {
  return accumulate(a.begin(), a.end(), v);
}
template <class T, class U> U COUNT(const T &a, const U &v) {
  return count(a.begin(), a.end(), v);
}
template <class T, class U> int LOWER(const T &a, const U &v) {
  return lower_bound(a.begin(), a.end(), v) - a.begin();
}
template <class T, class U> int UPPER(const T &a, const U &v) {
  return upper_bound(a.begin(), a.end(), v) - a.begin();
}
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int LCM(int a, int b) {
  int g = GCD(a, b);
  return a / g * b;
}

int main(void) {
  // Your code here!
  int n, k;
  cin >> n >> k;
  vector<int> snuke(n);
  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      a--;
      snuke[a]++;
    }
  }
  ll ans = 0;
  rep(i, n) {
    if (snuke[i] == 0)
      ans++;
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i <= end; i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> auto MAX(const T &a) {
  return *max_element(a.begin(), a.end());
}
template <class T> auto MIN(const T &a) {
  return *min_element(a.begin(), a.end());
}
template <class T, class U> U SUM(const T &a, const U &v) {
  return accumulate(a.begin(), a.end(), v);
}
template <class T, class U> U COUNT(const T &a, const U &v) {
  return count(a.begin(), a.end(), v);
}
template <class T, class U> int LOWER(const T &a, const U &v) {
  return lower_bound(a.begin(), a.end(), v) - a.begin();
}
template <class T, class U> int UPPER(const T &a, const U &v) {
  return upper_bound(a.begin(), a.end(), v) - a.begin();
}
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int LCM(int a, int b) {
  int g = GCD(a, b);
  return a / g * b;
}

int main(void) {
  // Your code here!
  int n, k;
  cin >> n >> k;
  vector<int> snuke(n);
  rep(i, k) {
    int d;
    cin >> d;
    vector<int> a(d);
    rep(j, d) {
      cin >> a[i];
      a[i]--;
      snuke[a[i]]++;
    }
  }
  ll ans = 0;
  rep(i, n) {
    if (snuke[i] == 0)
      ans++;
  }
  cout << ans << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<int> d;
vector<vector<int>> A;
void first() {
  cin >> N >> K;
  d.resize(K);
  A.resize(K, vector<int>());
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    A[i].resize(d[i]);
    for (int j = 0; j < d[i]; j++) {
      cin >> A[i][j];
    }
  }
}

void second() {
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    bool have = false;
    for (auto x : A) {
      for (auto y : x) {
        if (i == y)
          have = true;
      }
    }
    if (!have)
      ans++;
  }
  cout << ans << endl;
}

int main() {
  first();
  second();
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  vector<vector<int>> a(k, vector<int>(d));
  vector<int> ans(n, 0);
  for (int i = 0; i < k; i++) {
    cin >> d.at(i);
    for (int j = 0; j < d.at(i); j++) {
      cin >> a[i][j];
      int b;
      b = a[i][j];
      b--;
      ans[b]++;
    }
  }
  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (ans[i] == 0)
      count++;
  }
  cout << count << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for ((i) = 0; (i) < (int)(n); (i)++)
#define ll long long
using namespace std;

ll i, j, k;
const ll MOD = 1000000000 + 7;

ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  int d[k];
  int tmp;
  int child[n];
  REP(i, n) child[i] = 0;

  REP(i, k) {
    cin >> d[i];
    REP(j, d[i]) {
      cin >> tmp;
      child[tmp - 1]++;
    }
  }
  REP(i, n) {
    if (child[i] == 0) {
      ans++;
    }
  }

  cout << ans << '\\n';

  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for ((i) = 0; (i) < (int)(n); (i)++)
#define ll long long
using namespace std;

ll i, j, k;
const ll MOD = 1000000000 + 7;

ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  int d[k];
  int a[k][k];
  int child[n];
  REP(i, n) child[i] = 0;

  REP(i, k) {
    cin >> d[i];
    REP(j, d[i]) {
      cin >> a[i][j];
      child[a[i][j] - 1]++;
    }
  }
  REP(i, n) {
    if (child[i] == 0) {
      ans++;
    }
  }

  cout << ans << '\\n';

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

#include <bits/stdc++.h>
using namespace std;
using l1 = long long;
#define rep(i, n) for (int i = 0, i < (n); ++i)
int main() {

  int a, b, c, d;
  l1 e, f, g, h;

  cin >> a >> b;
  int x[a], memo[a];

  for (int i = 0; i < a; i++) {
    memo[i] = 0;
  }
  for (int i = 0; i < a; i++) {
    cin >> c;
    for (int l = 0; l < c; l++) {
      int me;
      cin >> me;
      memo[me - 1] = 1;
    }
  }
  d = 0;
  for (int i = 0; i < a; i++) {
    if (memo[i] == 0)
      d++;
  }

  cout << d;

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using l1 = long long;
#define rep(i, n) for (int i = 0, i < (n); ++i)
int main() {

  int a, b, c, d;
  l1 e, f, g, h;

  cin >> a >> b;
  int x[b], memo[b];

  for (int i = 0; i < b; i++) {
    memo[i] = 0;
  }
  for (int i = 0; i < b; i++) {
    cin >> c;
    for (int l = 0; l < c; l++) {
      int me;
      cin >> me;
      memo[me - 1] = 1;
    }
  }
  d = 0;
  for (int i = 0; i < b; i++) {
    if (memo[i] == 0)
      d++;
  }

  cout << d;

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

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int d[100];
  int a[100][100];
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }

  bool judge[n];
  for (int i = 0; i < n; i++) {
    judge[i] = false;
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < d[i]; j++) {
      for (int p = 0; p < n; p++) {
        if (a[i][j] == p) {
          judge[p] = true;
        }
      }
    }
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (judge[i] == false)
      count++;
  }
  cout << count << endl;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int d[n];
  int a[n][n];
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }

  bool judge[n];
  for (int i = 0; i < n; i++) {
    judge[i] = false;
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < d[i]; j++) {
      for (int p = 0; p < n; p++) {
        if (a[i][j] == p) {
          judge[p] = true;
        }
      }
    }
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (judge[i] == false)
      count++;
  }
  cout << count << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

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

  vector<bool> chk(N, false);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A;
      cin >> A;
      chk.at(A - 1) = true;
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (!chk.at(i)) {
      ans++;
    }
  }

  cout << ans << endl;
}

Error: 0

Fixed submission:

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

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

  vector<bool> chk(N, false);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A;
      cin >> A;
      chk.at(A - 1) = true;
    }
  }

  int ans = 0;
  for (int i = 0; i < K; i++) {
    if (!chk.at(i)) {
      ans++;
    }
  }

  cout << ans << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll = long long;
int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> vec(N, 0);
  for (ll i = 0; i < K; i++) {
    ll a;
    cin >> a;
    for (ll j = 0; j < a; j++) {
      ll b;
      cin >> b;
      vec.at(b - 1) = 1;
    }
  }
  ll c = 0;
  for (ll i = 0; i < N; i++) {
    if (vec.at(i) == 0) {
      c += 1;
    }
  }
  cout << c << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll = long long;
int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> vec(N, 0);
  for (ll i = 0; i < K; i++) {
    ll a;
    cin >> a;
    for (ll j = 0; j < a; j++) {
      ll b;
      cin >> b;
      vec.at(b - 1) = 1;
    }
  }
  ll c = 0;
  for (ll i = 0; i < K; i++) {
    if (vec.at(i) == 0) {
      c += 1;
    }
  }
  cout << c << endl;
}
Problem p02688 (C++) — buggy submission, verdict: 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(void) {
  ll N, K;
  cin >> N >> K;

  ll d, A, B[N + 1], sum = 0;
  for (ll i = 0; i <= N + 1; i++) {
    B[i] = 0;
  }
  for (ll i = 0; i < K; i++) {
    cin >> d;
    for (ll j = 0; j < d; j++) {
      cin >> A;
      B[A]++;
    }
  }

  for (ll i = 1; i <= N; i++) {
    if (B[i] == 0)
      sum++;
  }
  cout << sum << endl;
  return 0;
}


Error: 0

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(void) {
  int N, K;
  cin >> N >> K;

  int d[N], B[N + 1], sum = 0;
  for (int i = 0; i <= N + 1; i++) {
    B[i] = 0;
  }
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    int A[d[i]];
    for (int j = 0; j < d[i]; j++) {
      cin >> A[i];
      B[A[i]]++;
    }
  }

  for (int i = 0; i < N + 1; i++) {
    if (B[i] == 0)
      sum++;
  }
  cout << sum - 1 << endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;

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


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  int nos[n];
  for (int i = 0; i < n; i++) {
    nos[i] = 0;
  }
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      nos[a - 1]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (nos[i] == 0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {

  int N, K;

  set<int> cake;

  cin >> N >> K;
  int d[K];
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      int A;
      cin >> A;
      cake.insert(A);
    }
  }

  int ans = N - cake.size();

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

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {

  int N, K;
  int d[K];

  set<int> cake;

  cin >> N >> K;
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      int A;
      cin >> A;
      cake.insert(A);
    }
  }

  int ans = N - cake.size();

  cout << ans << endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> a(n, false);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int s;
      cin >> s;
      a[s - 1] = true;
    }
  }
  int countt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == false) {
      countt++;
    }
  }
  cout << countt << endl;
}


Error: -11

Fixed submission:

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

int main() {
  int n, k, b[n + 1], nm = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    b[i] = 0;
  }
  vector<int> d(k);
  for (int i = 1; i <= k; i++) {
    cin >> d[i];
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= d[i]; j++) {
      int a;
      cin >> a;
      b[a]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (b[i] == 0) {
      nm++;
    }
  }
  cout << nm << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> vec(n);
  for (int i = 0; i < n; i++) {
    vec.at(i) = false;
  }

  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) = true;
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (vec.at(i) == false) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector<bool>::_M_range_check: __n (which is 3) >= this->size() (which is 3)


Fixed submission:

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> vec(n);
  for (int i = 0; i < n; i++) {
    vec.at(i) = false;
  }

  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) = true;
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (vec.at(i) == false) {
      cnt++;
    }
  }
  cout << cnt << endl;
}