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

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

int main() {
  int n, k, d;
  int flag = 0;
  int pt[100];
  int N[100];

  cin >> n >> k;

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

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

    for (int i = 0; i < d; i++) {
      cin >> N[i];
    }
    for (int i = 0; i < n; i++) {
      for (int k = 0; k < d; k++) {
        if (pt[i] == N[k]) {
          pt[i] = 0;
        }
      }
    }
  }

  for (int i = 0; i < n; i++) {
    if (pt[i] == 0) {
      flag += 1;
    }
  }

  cout << n - flag << endl;

  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  int n, k, d;
  int flag = 0;
  int *pt;
  int N[100];

  cin >> n >> k;

  pt = new int[n];

  for (int i = 1; i <= n; i++) {
    pt[i] = i;
  }

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

    for (int i = 0; i < d; i++) {
      cin >> N[i];
    }
    for (int i = 0; i < n; i++) {
      for (int k = 0; k < d; k++) {
        if (pt[i] == N[k]) {
          pt[i] = 0;
        }
      }
    }
  }

  for (int i = 0; i < n; i++) {
    if (pt[i] == 0) {
      flag += 1;
    }
  }

  cout << flag << endl;

  return 0;
}
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++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> snuke(N, 0);
  rep(i, K) {
    int d;
    cin >> d;
    rep(j, d) {
      int okashi;
      cin >> okashi;
      okashi--;
      snuke[okashi]++;
    }
  }
  int cnt = 0;
  rep(i, N) {
    if (snuke[i] == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> snuke(N);
  rep(i, N) { snuke[i] = 0; }
  rep(i, K) {
    int d;
    cin >> d;
    vector<int> okashi(d);
    rep(j, d) {
      cin >> okashi[i];
      okashi[i]--;
      snuke[okashi[i]]++;
    }
  }
  int cnt = 0;
  rep(i, N) {
    if (snuke[i] == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

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

  int n, k;
  cin >> n >> k;
  int ans = 0;
  vector<int> sunuke(2 * n);
  vector<int> A(n);
  for (int i = 0; i < n; i++)
    sunuke[i] = 0;
  int d;
  for (int i = 0; i < k; i++) {
    cin >> d;
    A.clear();
    for (int j = 0; j < d; j++) {
      cin >> A[i];
      A[i];
      sunuke[A[i]]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (sunuke[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

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

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

  int n, k;
  cin >> n >> k;
  int ans = 0;
  vector<int> sunuke(n);
  for (int i = 0; i < n; i++)
    sunuke[i] = 0;
  int d;
  for (int i = 0; i < k; i++) {
    cin >> d;
    vector<int> A(d);
    A.clear();
    for (int j = 0; j < d; j++) {
      cin >> A[i];
      A[i]--;
      sunuke[A[i]]++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (sunuke[i] == 0) {
      ans++;
    }
  }
  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<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;
}

Error: 0

Fixed submission:

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


Error: TLE

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, count = 0;
  cin >> n >> k;
  vector<int> data(n, 1);
  for (int i = 0; i < k; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      int b;
      cin >> b;
      data.at(b - 1) = 0;
    }
  }

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

  cout << n - count << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, count = 0;
  cin >> n >> k;
  vector<int> data(n, 1);
  for (int i = 0; i < k; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      int b;
      cin >> b;
      data.at(b - 1) = 0;
    }
  }

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

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

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

int main() {
  int n, k, m = 0; // n人，k样东西
  cin >> n >> k;
  int a[k + 1], b[n + 1], x;
  for (int i = 1; i <= n; i++)
    b[i] = 0;
  for (int i = 1; i <= k; i++) {
    cin >> a[i];
    for (int p = 1; p <= a[i]; p++) {
      cin >> x;
      b[x]++;
    }
  }
  for (int i = 1; i <= n; i++)
    if (b[i] == 0)
      m++;
  cout << m;
  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  int n, k, m = 0; // n人，k样东西
  cin >> n >> k;
  int a[k + 1], b[k + 1], x;
  for (int i = 1; i <= k; i++)
    b[i] = 0;
  for (int i = 1; i <= k; i++) {
    cin >> a[i];
    for (int p = 1; p <= a[i]; p++) {
      cin >> x;
      b[x]++;
    }
  }
  for (int i = 1; i <= k; i++)
    if (b[i] == 0)
      m++;
  cout << m;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

int main() {

  int n, k;

  cin >> n >> k;

  // cout << n << " " << k << endl;

  vector<int> snukes(n, 0);

  int snackQ[k];

  for (int i = 0; i < k; i++) {
    int quantity;

    cin >> quantity;

    snackQ[i] = quantity;

    // cout << quantity << endl;

    for (int j = 0; j < quantity; j++) {
      int snuke;
      cin >> snuke;
      snukes[snuke - 1]++;
      // cout << snuke << " ";
    }
    // cout<<endl;
  }

  int count = 0;
  for (int i = 0; i < n; i++) {
    if (snukes[i] == 0) {
      count++;
    }
  }
  cout << count << endl;
}

Error: 0

Fixed submission:

#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

int main() {

  int n, k;

  cin >> n >> k;

  vector<int> list[k];

  int snackQ[k];

  for (int i = 0; i < k; i++) {
    int quantity;

    cin >> quantity;

    snackQ[i] = quantity;

    for (int j = 0; j < quantity; j++) {
      int snuke;
      cin >> snuke;
      list[i].push_back(snuke - 1);
    }
  }

  vector<bool> found(n - 1, false);

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

    int cur;

    for (int j = 0; j < snackQ[i]; j++) {
      cur = list[i][j];
      if (found[j] == false) {
        found[j] = true;
      }
    }
  }

  int countVic = 0;
  for (int i = 0; i < n; i++) {
    if (found[i] == false) {
      countVic++;
    }
  }

  cout << countVic << 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 D;
  vector<int> A(N);
  map<int, int> record;
  for (int i = 0; i < K; i++) {
    cin >> D;
    for (int j = 0; j < D; j++) {
      cin >> A.at(j);
    }
    for (int x : A) {
      if (record.count(x)) {
        record[x]++;
      } else {
        record[x] = 1;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i < N + 1; i++) {
    if (record.count(i)) {
      ans += 0;
    } else {
      ans++;
    }
  }
  cout << ans << endl;
}


Error: WA

Fixed submission:

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

int main() {
  int N, K;
  cin >> N >> K;
  int D;
  vector<int> A(D);
  map<int, int> record;
  for (int i = 0; i < K; i++) {
    cin >> D;
    for (int j = 0; j < D; j++) {
      cin >> A.at(i);
    }
    for (int x : A) {
      if (record.count(x)) {
        record[x]++;
      } else {
        record[x] = 1;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i < N + 1; i++) {
    if (record.count(i)) {
      ans += 0;
    } else {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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


Error: 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[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;
}
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> moto(n);
  for (int i = 0; i < n; i++) {
    moto.at(i) = i + 1;
  }
  for (int i = 0; i < k; i++) {
    int kazu;
    cin >> kazu;
    vector<int> data(kazu);
    for (int k = 0; k < kazu; k++) {
      cin >> data.at(k);
    }
    for (int k = 0; k < kazu; k++) {
      for (int j = 0; j < n; j++) {
        if (data.at(k) == moto.at(j)) {
          moto.at(j) = 0;
        }
      }
    }
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (!(moto.at(i) == 0)) {
      count++;
    }
  }
  cout << count << endl;
}


Error: WA

Fixed submission:

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> kazu(k);
  vector<int> moto(n);
  for (int i = 0; i < n; i++) {
    moto.at(i) = i + 1;
  }
  for (int i = 0; i < k; i++) {
    cin >> kazu.at(i);
    vector<int> data(kazu.at(i));
    cin >> data.at(i);
    for (int j = 0; j < n; j++) {
      if (data.at(i) == moto.at(j)) {
        moto.at(j) = 0;
      }
    }
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (!(moto.at(i) == 0)) {
      count++;
    }
  }
  cout << count << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; // 10^9
const ll MOD = 1e9 + 7;
// 加算代入演算子は+=！！！！！
// int 2^31 10^9まで
int n, k;
vector<int> d;
vector<vector<int>> a;

void input() {
  cin >> n >> k;
  d.resize(k); // resizeは要素の数変える
  a.resize(k, vector<int>());
  rep(i, k) {
    cin >> d[i];
    a[i].resize(d[i]);
    rep(j, d[i]) { cin >> a[i][j]; }
  }
}

void solve() {
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    bool have = false;
    for (auto v : a) {
      for (auto p : v) {
        if (p == i)
          have = true;
      }
    }
    if (!have)
      ans++;
  }
  cout << ans << endl;
}

int main() {
  input();
  solve();
  return 0;
}

Error: 0

Fixed submission:

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; // 10^9
const ll MOD = 1e9 + 7;
// 加算代入演算子は+=！！！！！
// int 2^31 10^9まで
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(100);
  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) { cin >> a[d]; }
  }
  int ans = 0;
  rep(i, n) {
    if (a[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdio.h>
#include <string>

using namespace std;

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

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdio.h>
#include <string>

using namespace std;

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

#include <algorithm>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath>
#include <cstdlib> // abs(int)
#include <iostream>
#include <string>
#include <vector>

#define roundup(n, d) (((n) + ((d)-1)) / (d))
#define ll long long
#define llv vector<long long>
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i, n) for (long long i = 0; i < n; i++)

using namespace std;

int main(void) {
  ll n, k;
  cin >> n >> k;
  llv v(n, 0);
  rep(i, k) {
    ll d;
    cin >> d;
    rep(j, d) {
      ll a;
      cin >> a;
      v[a - 1] = 1;
    }
  }
  ll cnt = 0;
  rep(i, n) if (v[i] == 0) cnt++;
  cout << cnt;
  return 0;
}

Error: -6
free(): invalid pointer


Fixed submission:

#include <algorithm>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath>
#include <cstdlib> // abs(int)
#include <iostream>
#include <string>
#include <vector>

#define roundup(n, d) (((n) + ((d)-1)) / (d))
#define ll long long
#define llv vector<long long>
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i, n) for (long long i = 0; i < n; i++)

using namespace std;

int main(void) {
  ll n, k;
  cin >> n >> k;
  llv v(n, 0);
  rep(i, k) {
    ll d;
    cin >> d;
    rep(j, d) {
      ll a;
      cin >> a;
      v[i - 1] = 1;
    }
  }
  ll cnt;
  rep(i, n) if (v[i] == 0) cnt++;
  cout << cnt;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
  if (x >= 0)
    return;
  else
    x = -x;
  return;
}

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 ll INF = 1LL << 60;

int N;

// DPテーブル
vector<ll> dp(100010);

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> ans(n, false);
  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      ans.at(a - 1) = true;
    }
  }
  int cnt = 0;
  rep(i, n) {
    if (!ans.at(i))
      cnt++;
  }
  cout << cnt << endl;
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
  if (x >= 0)
    return;
  else
    x = -x;
  return;
}

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 ll INF = 1LL << 60;

int N;

// DPテーブル
vector<ll> dp(100010);

int main() {
  int n, k;
  vector<bool> ans(n, false);
  cin >> n >> k;
  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      ans.at(a - 1) = true;
    }
  }
  int cnt = 0;
  rep(i, n) {
    if (!ans.at(i))
      cnt++;
  }
  cout << cnt << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <iostream> //cout
#include <vector>   //vector
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

  vector<int> sunuke(N, 0);
  // cout << "test1" << endl;
  rep(i, K) {
    int Di = 0;
    cin >> Di;
    // cout << ":" << d.at(i) << endl;

    rep(j, Di) {
      int temp;
      cin >> temp;
      // cout << temp << ",";
      sunuke.at(temp - 1)++;
    }
    // cout << endl;
  }

  // cout << "test2" << endl;

  int sum = 0;
  rep(i, N) {
    if (sunuke.at(i) == 0) {
      sum++;
    }
  }
  cout << sum << endl;
}


Error: 0

Fixed submission:

#include <iostream> //cout
#include <vector>   //vector
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

  vector<int> sunuke(N, 0);
  vector<int> d(N);
  // cout << "test1" << endl;
  rep(i, K) {
    cin >> d.at(i);
    // cout << ":" << d.at(i) << endl;

    rep(j, d.at(i)) {
      int temp;
      cin >> temp;
      // cout << temp << ",";
      sunuke.at(temp - 1)++;
    }
    // cout << endl;
  }

  // cout << "test2" << endl;

  int sum = 0;
  rep(i, sunuke.size()) {
    if (sunuke.at(i) == 0) {
      sum++;
    }
  }
  cout << sum << 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> d(k);
  vector<vector<int>> a(k, vector<int>(n));

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

  set<int> s;
  for (int x = 0; x < k; x++) {
    for (int y = 0; y < d[x]; y++) {
      s.insert(a[x][y]);
    }
  }

  if (s.count(0)) {
    cout << n - s.size() - 1 << endl;
  } else {
    cout << n - s.size() << endl;
  }
}


Error: 0

Fixed submission:

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

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

  vector<int> d(k);

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

  vector<vector<int>> A(k, vector<int>(n));

  for (int j = 0; j < k; j++) {
    for (int m = 0; m < d.at(j); m++) {
      cin >> A.at(j).at(m);
    }
  }

  set<int> S;

  for (int q = 0; q < k; q++) {
    for (int p = 0; p < d.at(q); p++) {
      S.insert(A.at(p).at(q));
    }
  }

  S.erase(0);

  cout << n - S.size() << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

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

  for (int k = 1; k < N + 1; k++) {
    bool finished = false;
    for (int i = 0; i < K; i++) {
      for (int j = 0; j < d1.at(i); j++) {
        if (k == vec.at(i).at(j)) {
          finished = true;
        }
      }
    }
    if (!finished) {
      count++;
    }
  }
  cout << count << endl;
}


Error: WA

Fixed submission:

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d1(N);
  vector<vector<int>> vec(100, vector<int>(100));
  for (int i = 0; i < K; i++) {
    cin >> d1.at(i);
    for (int j = 0; j < d1.at(i); j++) {
      cin >> vec.at(i).at(j);
    }
  }
  int count = 0;
  for (int k = 1; k < N + 1; k++) {
    for (int i = 0; i < K - 1; i++) {
      for (int j = 0; j < d1.at(i); j++) {
        if (k == vec.at(i).at(j)) {
          count++;
          break;
        }
        break;
      }
      break;
    }
  }
  cout << N - count << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, k, ans = 0;
  cin >> n >> k;
  vector<bool> ok(n);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      a--;
      ok[a] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    if (!ok[i])
      ans++;
  }
  cout << ans;
}


Error: WA

Fixed submission:

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

int main() {
  int n, k, ans = 0;
  vector<bool> ok(n);
  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;
      a--;
      ok[a] = 1;
    }
    for (int i = 0; i < n; i++) {
      if (!ok[i])
        ans++;
    }
    cout << ans;
  }
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b;
  vector<int> m(a + 1, 0);
  m[0] = 1;
  for (int i = 0; i < b; i++) {
    cin >> c;
    vector<int> n(c);
    for (int j = 0; j < c; j++) {
      cin >> n[j];
      m[n[j]]++;
    }
  }
  int p = 0;
  for (int k = 0; k < a + 1; k++) {
    if (m[k] == 0)
      p++;
  }
  cout << p << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b;
  vector<int> m(a + 1, 0);
  m[0] = 1;
  for (int i = 0; i < b; i++) {
    cin >> c;
    vector<int> n(c);
    for (int j = 0; j < c; j++) {
      cin >> n[i];
      m[n[i]]++;
    }
  }
  int p = 0;
  for (int k = 0; k < a + 1; k++) {
    if (m[k] == 0)
      p++;
  }
  cout << p << endl;
}