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

#include <iostream>
#include <string>
using namespace std;
int main() {
  int N, K, j, d[110], A[110][110], p[110], x = 0;
  cin >> N >> K;
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    for (int k = 0; k < d[i]; k++) {
      cin >> A[i][k];
      for (int j = 1; j <= N; j++) {
        if (A[i][k] == j) {
          p[j] = j;
        }
      }
    }
  }

  for (int j = 1; j <= N; j++) {
    if (p[j] == j)
      x++;
  }

  cout << N - x << endl;
  return 0;
}


Error: WA

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int N, K, j, d[110], A[110][110], p[j], x = 0;
  p[j] = -1;
  cin >> N >> K;
  for (int i = 1; i <= K; i++) {
    cin >> d[i];
    for (int k = 1; k <= d[i]; k++) {
      cin >> A[i][k];

      for (j = 1; j <= N; j++) {
        if (A[i][k] == j) {
          p[j] = 0;
        }
      }
    }
  }

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

#include <iostream>
#include <vector>

int main() {
  int N, K;
  std::cin >> N >> K;
  std::vector<int> flag(N, 1);
  for (int i = 0; i < K; i++) {
    int di;
    std::cin >> di;
    for (int j = 0; j < di; j++) {
      int a;
      std::cin >> a;
      flag[a - 1] = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += flag[i];
  }
  std::cout << ans << std::endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <vector>

int main() {
  int N, K;
  std::cin >> N >> K;
  std::vector<int> flag(K, 1);
  for (int i = 0; i < K; i++) {
    int di;
    std::cin >> di;
    for (int j = 0; j < di; j++) {
      int a;
      std::cin >> a;
      flag[a - 1] = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += flag[i];
  }
  std::cout << ans << std::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 A[n];
  for (int i = 0; i < n; i++)
    A[i] = 0;
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      A[a - 1]++;
    }
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (A[i] == 0)
      count++;
  }
  cout << count << endl;
}


Error: 0

Fixed submission:

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

int main() {
  int n, k;
  cin >> n >> k;
  int A[n];
  for (int i = 0; i < n; i++)
    A[i] = 0;
  int d[k];
  for (int i = 0; i < k; i++) {
    cin >> d[k];
    // cout <<d[k]<<endl;
    int a[d[k]];
    for (int j = 0; j < d[k]; j++) {
      cin >> a[j];
      A[a[j] - 1]++;
    }
  }
  // for(int x:A) cout << x << endl;

  int count = 0;
  for (int i = 0; i < n; i++) {
    if (A[i] == 0)
      count++;
  }
  cout << count << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

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

  int64_t d = 0;
  int64_t hito = 0;
  vector<vector<int64_t>> A(K);
  for (int64_t i = 0; i < K; i++) {
    cin >> d;
    for (int64_t j = 0; j < d; j++) {
      cin >> hito;
      A.at(i).push_back(hito);
    }
  }

  set<int64_t> array;
  for (auto v : A) {
    for (auto p : v) {
      array.insert(p);
    }
  }
  cout << (N - array.size()) << endl;
}


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


Fixed submission:

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

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

  int64_t d = 0;
  int64_t hito = 0;
  vector<vector<int64_t>> A(K);
  for (int64_t i = 0; i < K; i++) {
    cin >> d;
    for (int64_t j = 0; j < d; j++) {
      cin >> hito;
      A.at(i).at(j) = hito;
    }
  }

  set<int64_t> array;
  for (int64_t i = 0; i < K; i++) {
    for (int64_t j = 0; j < d; j++) {
      array.insert(A.at(i).at(j));
    }
  }
  cout << (N - array.size()) << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <math.h>
#include <set>
using namespace std;

int main() {
  int N, K;
  int d[200], A[200][200];
  set<int> ans;
  // int ans[200] = {};
  cin >> N >> K;
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      cin >> A[i][j];
      ans.insert(A[i][j]);
    }
  }

  int result = 0;
  // for(int i=0;i<K;i++)if(ans[i]==0) result++;
  cout << N - ans.size() << endl;
}

Error: 0

Fixed submission:

#include <iostream>
#include <math.h>
// #include<set>
using namespace std;

int main() {
  int N, K;
  int d[200], A[200][200];
  // set<int> ans;
  int ans[K];
  cin >> N >> K;
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      cin >> A[i][j];
      ans[A[i][j] - 1]++;
    }
  }

  int result = 0;
  for (int i = 0; i < K; i++)
    if (ans[i] == 0)
      result++;
  cout << result << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

// マクロ
// forループ関係
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   // 最大値を求める
#define MIN(x) *min_element(ALL(x))   // 最小値を求める
#define D()
// 定数
#define INF 1000000000000 // 10^12:極めて大きい値,∞
#define MOD 10000007      // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
// 略記
#define PB push_back // vectorヘの挿入
#define MP make_pair // pairのコンストラクタ
#define F first      // pairの一つ目の要素
#define S second     // pairの二つ目の要素

int main(void) {
  int N, K, d;
  int A;

  cin >> N >> K;
  int B[N];
  for (int i = 0; i < N; ++i) {
    B[i] = 0;
  }
  for (int i = 0; i < K; ++i) {
    cin >> d;
    for (int j = 0; j < d; ++j) {
      cin >> A;
      B[A - 1] = 1;
    }
  }
  int g = 0;
  for (int i = 0; i < N; ++i) {
    // printf("%d ", B[i]);
    if (B[i] == 0) {
      g = g + 1;
    }
  }

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

Error: 0

Fixed submission:

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

// マクロ
// forループ関係
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   // 最大値を求める
#define MIN(x) *min_element(ALL(x))   // 最小値を求める
#define D()
// 定数
#define INF 1000000000000 // 10^12:極めて大きい値,∞
#define MOD 10000007      // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
// 略記
#define PB push_back // vectorヘの挿入
#define MP make_pair // pairのコンストラクタ
#define F first      // pairの一つ目の要素
#define S second     // pairの二つ目の要素

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

  for (int i = 0; i < K; ++i) {
    cin >> d;
    for (int j = 0; j < d; ++j) {
      cin >> A;
      B[A - 1] = 1;
    }
  }
  int g = 0;
  for (int i = 0; i < N; ++i) {
    // printf("%d ", B[i]);
    if (B[i] == 0) {
      g = g + 1;
    }
  }

  printf("%d\\n", g);
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

#define ll long long

using namespace std;

int main() {
  bool ans[101];
  int n, m, d, a, num = 0;
  cin >> n >> m;
  for (int i = 0; i <= n; i++) {
    ans[i] = false;
  }
  for (int j = 0; j < m; j++) {
    cin >> d;
    for (int k = 0; k < d; k++) {
      cin >> a;
      ans[a] = true;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!ans[i]) {
      num++;
    }
  }
  cout << num << endl;
}

Error: -11

Fixed submission:

#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

#define ll long long

using namespace std;

int main() {
  bool ans[101];
  int n, m, d, a, num = 0;
  for (int i = 0; i <= n; i++) {
    ans[i] = false;
  }
  cin >> n >> m;
  for (int j = 0; j < m; j++) {
    cin >> d;
    for (int k = 0; k < d; k++) {
      cin >> a;
      ans[a] = true;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!ans[i]) {
      num++;
    }
  }
  cout << num << 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<int> vec(N);
  for (int i = 0; i < N; i++) {
    vec.at(i) = i + 1;
  }
  for (int i = 0; i < K; i++) {
    int j, d;
    j = 0;
    d = 0;
    cin >> d;
    for (j = 0; j < d; j++) {
      int A;
      cin >> A;
      vec.at(A - 1) = 0;
    }
  }
  int count = 0;
  for (int n = 0; n < N; n++) {
    if (vec.at(n) != 0)
      count++;
  }
  cout << count << endl;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_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<int> vec(N);
  for (int i = 1; i < N + 1; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < K; i++) {
    int j, d;
    j = 0;
    d = 0;
    cin >> d;
    for (j = 0; j < d; j++) {
      int A;
      cin >> A;
      vec.at(A) = 0;
    }
  }
  int count = 0;
  for (int n = 0; n < N; n++) {
    if (vec.at(n) != 0)
      count++;
  }
  cout << count << endl;
}
Problem p02688 (C++) — buggy submission, verdict: 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, n) {
    // cout << flag.at(i);
    if (flag.at(i) == 0)
      sum += 1;
  }

  cout << sum;
}

Error: WA

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, k) {
    // cout << flag.at(i);
    if (flag.at(i) == 0)
      sum += 1;
  }

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

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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;
}
const long long INFLL = 1LL << 62;
const int INF = 1 << 30;
const double PI = acos(-1);
int main() {
  int n, k;
  cin >> n >> k;
  set<int> ans;
  int ansv = 0;
  int d;
  int bef;
  //	vector<vector<int>>a(k);
  rep(i, k) {
    cin >> d;
    rep(i, d) {
      cin >> bef;
      // a[i].push_back(bef);
      ans.insert(bef);
    }
  }
  for (int i = 1; i <= n; i++) {

    if (ans.lower_bound(i) == ans.end() or *ans.lower_bound(i) != i) {
      ansv++;
    }
  }
  cout << ansv << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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;
}
const long long INFLL = 1LL << 62;
const int INF = 1 << 30;
const double PI = acos(-1);
int main() {
  int n, k;
  cin >> n >> k;
  set<int> ans;
  int ansv = 0;
  int d;
  int bef;
  vector<vector<int>> a(k);
  rep(i, k) {
    cin >> d;
    rep(i, d) {
      cin >> bef;
      a[i].push_back(bef);
      ans.insert(bef);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (*ans.lower_bound(i) != i) {
      ansv++;
    }
  }
  cout << ansv << 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<int> list(n);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int di;
      cin >> di;
      list[di - 1] = 1;
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (list[i] == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Error: 0

Fixed submission:

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> list(k);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int di;
      cin >> di;
      list[di - 1] = 1;
    }
  }
  int cnt = 0;
  for (int i = 0; i < k; i++) {
    if (list[i] == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <iostream>

using namespace std;
set<int> s1;
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    int x;
    cin >> x;
    while (x--) {
      // cout<<x<<endl;
      int y;
      cin >> y;
      s1.insert(y);
    }
  }
  cout << n - (int)s1.size() << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>

using namespace std;
set<int> s1;
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    while (x--) {
      int y;
      cin >> y;
      s1.insert(y);
    }
  }
  cout << n - (int)s1.size() << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}
template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\\n";
}
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n, 0);
  REP(i, k) {
    ll d;
    cin >> d;
    // cout << d << endl;
    REP(j, d) {
      ll ina;
      cin >> ina;
      a[ina - 1]++;
    }
  }
  // cout << a<< endl;
  ll res = 0;
  REP(i, n) {
    if (a[i] == 0)
      res++;
  }
  cout << res << endl;
}

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


Error: -6
munmap_chunk(): invalid pointer


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}
template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\\n";
}
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n, 0);
  REP(i, k) {
    ll d;
    cin >> d;
    // cout << d << endl;
    REP(j, d) { cin >> a[j - 1]; }
  }
  ll res = 0;
  REP(i, n) {
    if (a[i] == 0)
      res++;
  }
  cout << res << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}
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<int> d(k);
  vector<vector<int>> a(k, vector<int>(n));
  vector<int> c(n); // check
  for (int i = 0; i < k; i++) {
    cin >> d.at(i);
    for (int j = 0; j < d.at(i); j++) {
      cin >> a.at(i).at(j);
      c.at(a.at(i).at(j) - 1)++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (c.at(i) == 0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


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


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> d(k);
  vector<vector<int>> a(k, vector<int>(n));
  vector<int> c(n);
  for (int i = 0; i < k; i++) {
    cin >> d.at(i);
    for (int j = 0; j < d.at(i); j++) {
      cin >> a.at(i).at(j);
      d.at(a.at(i).at(j))++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (c.at(i) == 0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#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;
}

Error: 0

Fixed submission:

#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;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
int main() {
  int N, K;
  std::cin >> N >> K;
  int snk[N];
  for (auto &s : snk)
    s = 0;
  for (int i = 0; i < K; i++) {
    int x;
    std::cin >> x;
    for (int j = 0; j < x; j++) {
      int y;
      std::cin >> y;
      snk[y - 1] = 1;
    }
  }
  int count = 0;
  for (auto s : snk)
    if (!s)
      count++;
  std::cout << count << "\\n";
}

Error: 0

Fixed submission:

#include <iostream>
int main() {
  int N, K;
  std::cin >> N >> K;
  int d[K], A[K][K], snk[N];
  for (auto &s : snk)
    s = 0;
  for (int i = 0; i < K; i++) {
    std::cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      std::cin >> A[i][j];
      snk[A[i][j] - 1] = 1;
    }
  }
  int count = 0;
  for (auto s : snk)
    if (!s)
      count++;
  std::cout << count << "\\n";
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  int n;
  int k;
  int p = 0;
  int ans = 0;
  int an = 0;
  int l = 1;

  vector<int> a;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    int mi;
    cin >> mi;
    for (l = 1; l <= mi; l++) {
      int nl;
      cin >> nl;
      p += 1;
      a.push_back(nl);
    }
    l = 1;
  }

  for (int r = 1; r <= n; r++) {
    for (int q = 0; q < p; q++) {
      if (a[q] == r) {
        an += 1;
      }
    }
    if (an == 0) {
      ans += 1;
    }
    an = 0;
  }

  cout << ans << endl;
}


Error: -11

Fixed submission:

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

int main() {

  int n, k, l, p, ans, an;
  vector<int> a;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    int mi;
    cin >> mi;
    for (int l = 1; l <= mi; l++) {
      int nl;
      cin >> nl;
      p += 1;
      a.push_back(nl);
    }
    l = 1;
  }

  for (int r = 1; r <= n; r++) {
    for (int q = 0; q < p; q++) {
      if (a[q] == r) {
        an += 1;
      }
    }
    if (an == 0) {
      ans += 1;
    }
    an = 0;
  }

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int les[n], of[k];
  for (int i = 0; i < n; i++)
    les[i] = 1;
  for (int i = 0; i < k; i++) {
    cin >> of[i];
    int sub[of[i]];
    for (int j = 0; j < of[i]; j++) {
      cin >> sub[j];

      les[sub[j] - 1] = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (les[i] == 1)
      ans++;
    cerr << les[i] << endl;
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int d[k], les[n];
  for (int i = 0; i < n; i++)
    les[i] = 0;
  for (int i = 0; i < k; i++) {
    int d[i];
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      int sub;
      cin >> sub;
      les[sub] = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    if (les[i] == 0)
      ans++;
  cout << ans << endl;
}