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

#include <cstdio>
#include <iostream>
#include <vector>
#define rep(i, n) for (ll i = 0; i < n; i++)
typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  ll n, k;
  std::cin >> n >> k;
  std::vector<ll> c(n);
  rep(i, k) {
    ll d;
    std::cin >> d;
    rep(j, d) {
      ll a;
      std::cin >> a;
      a--;
      c[a]++;
    }
  }
  ll cnt = 0;
  rep(i, n) {
    if (c[i] == 0)
      cnt++;
  }
  std::cout << cnt << std::endl;
}

Error: 0

Fixed submission:

#include <iostream>
#include <set>
typedef long long ll;

int main() {
  ll n, k;
  std::cin >> n >> k;
  ll d[k];
  ll a[k][k];
  std::set<ll> ans;
  for (ll i = 0; i < k; ++i) {
    std::cin >> d[i];
    for (ll j = 0; j < d[i]; ++j) {
      std::cin >> a[i][j];
      ans.insert(a[i][j]);
    }
  }
  std::cout << n - ans.size() << std::endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bits/stdc++.h>
#define Freopen(x)                                                             \\
  freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout);
#define int long long
using namespace std;
int a[10010], n, k;
signed main() {
  scanf("%lld%lld", &n, &k);
  for (int i = 1; i <= k; i++) {
    int di, A;
    scanf("%lld\\n", &di);
    for (int j = 1; j <= di; j++)
      scanf("%lld\\n", &A), a[A]++;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (!a[i])
      ans++;
  printf("%lld\\n", ans);
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#define Freopen(x)                                                             \\
  freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout);
#define int long long
using namespace std;
int a[110], n, k;
signed main() {
  scanf("%lld%lld", &n, &k);
  for (int i = 1; i <= k; i++) {
    int di, A;
    scanf("%lld\\n", di);
    for (int j = 1; j <= di; j++)
      scanf("%lld\\n", A), a[A]++;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (!a[i])
      ans++;
  printf("%lld\\n", ans);
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
#define rep(i, a, b) for (long long i = a; i < b; i += 1)
#define repr(i, a, b) for (long long i = a; i <= b; i += 1)
#define vec vector<ll>
#define map map<string, int>
#define repa(p, A) for (auto p : A)
#define pb push_back
#define sort(a) sort(a.begin(), a.end())
#define reverse(a) reverse(a.begin(), a.end())

using namespace std;
int main() {
  ll N, K;
  cin >> N >> K;
  vec A(N, 0);
  rep(i, 0, K) {
    ll d;
    cin >> d;
    rep(i, 0, d) {
      ll a;
      cin >> a;
      A[a - 1] = 1;
    }
  }
  ll count = 0;
  rep(i, 0, N) {
    if (A[i] == 0) {
      count += 1;
    }
  }
  cout << count << endl;
}

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


Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define rep(i, a, b) for (long long i = a; i < b; i += 1)
#define repr(i, a, b) for (long long i = a; i <= b; i += 1)
#define vec vector<ll>
#define map map<string, int>
#define repa(p, A) for (auto p : A)
#define pb push_back
#define sort(a) sort(a.begin(), a.end())
#define reverse(a) reverse(a.begin(), a.end())

using namespace std;
int main() {
  ll N, K;
  vec A(N, 0);
  cin >> N >> K;
  rep(i, 0, K) {
    ll d;
    cin >> d;
    rep(i, 0, d) {
      ll a;
      cin >> a;
      A[a - 1] = 1;
    }
  }
  ll count = 0;
  rep(i, 0, N) {
    if (A[i] != 1) {
      count += 1;
    }
  }
  cout << count << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, k, d, i, j, count = 0, a;
  cin >> n >> k;
  vector<int> t(n, 0);
  for (i = 0; i < k; i++) {
    cin >> d;
    for (j = 0; j < d; j++) {
      cin >> a;
      t[a - 1]++;
    }
  }
  for (j = 0; j < n; j++)
    if (t[j] == 0)
      count++;
  cout << count << endl;
}

Error: 0

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, k, d, i, j, count = 0, a;
  cin >> n >> k;
  vector<int> t(n - 1, 0);
  for (i = 0; i < k; i++) {
    cin >> d;
    for (j = 0; j < d; j++) {
      cin >> a;
      t[a]++;
    }
  }
  for (j = 0; j < n - 1; j++)
    if (t[j] == 0)
      count++;
  cout << count << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF = (ll)1e9;
const ll MOD = (ll)1e9 + 7;
const ll MAX = 510000;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
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;
}
int main() {
  int N, K, cnt = 0;
  cin >> N >> K;
  vector<int> d(K), ans(N + 5, 0);
  vector<vector<int>> A(K);
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      int a;
      cin >> a;
      ans[a]++;
    }
  }
  for (int i = 1; i <= N; i++) {
    if (ans[i] == 0)
      cnt++;
  }
  cout << cnt << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF = (ll)1e9;
const ll MOD = (ll)1e9 + 7;
const ll MAX = 510000;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
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;
}
int main() {
  int N, K, cnt = 0;
  cin >> N >> K;
  vector<int> d(K), ans(N + 5, 0);
  vector<vector<int>> A(K, vector<int>(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]]++;
    }
  }
  for (int i = 1; i <= N; i++) {
    if (ans[i] == 0)
      cnt++;
  }
  cout << cnt << 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[k];
  int sunuke[n];
  for (int i = 0; i < n; i++) {
    sunuke[i] = 0;
  }
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    int a;
    for (int j = 0; j < d[i]; j++) {
      cin >> a;
      sunuke[a - 1]++;
    }
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (sunuke[i] == 0)
      count++;
  }
  cout << count << 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 3)


Fixed submission:

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

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

template <typename T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}
template <typename T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

int in() {
  int x;
  scanf("%d", &x);
  return x;
}
ll lin() {
  ll x;
  scanf("%lld", &x);
  return x;
}
#define INF 1LL << 60

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

  vector<int> total(N);
  REP(i, K) {
    int d;
    cin >> d;
    REP(j, d) {
      int tmp;
      cin >> tmp;
      total[tmp - 1]++;
    }
  }

  int ans = 0;
  REP(i, N) if (total[i] == 0) ans++;

  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

template <typename T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}
template <typename T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

int in() {
  int x;
  scanf("%d", &x);
  return x;
}
ll lin() {
  ll x;
  scanf("%lld", &x);
  return x;
}
#define INF 1LL << 60

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d(N);
  vector<int> total(N);
  vector<vector<int>> A(K, vector<int>(N));
  REP(i, K) {
    cin >> d[i];
    REP(j, d[i]) {
      int tmp;
      cin >> tmp;
      total[tmp - 1]++;
    }
  }

  int ans = 0;
  REP(i, N) if (total[i] == 0) ans++;

  cout << ans << endl;

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

#include <bits/stdc++.h>

#define ll long long

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

  std::map<int, int> data;

  for (int i = 0; i < K; i++) {
    int a;
    std::cin >> a;
    for (int j = 0; j < a; j++) {
      int value;
      std::cin >> value;
      data[value]++;
    }
  }

  int count = 0;
  for (int i = 1; i <= N; i++) {
    if (data[i] == 0) {
      count++;
    }
  }

  std::cout << count << std::endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define ll long long

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

  std::vector<int> d(K);
  std::vector<std::vector<int>> A(K, std::vector<int>(K));
  std::map<int, int> data;

  for (int i = 0; i < K; i++) {
    std::cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      std::cin >> A[i][j];
      data[A[i][j]]++;
    }
  }

  int count = 0;
  for (int i = 1; i <= N; i++) {
    if (data[i] == 0) {
      count++;
    }
  }

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

#include <bits/stdc++.h>
#include <map>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100009
#define endl '\\n'
#define mp make_pair
#define INF 100000000
#define fast                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define ff first
#define ss second
#define ps(x, y) fixed << setprecision(y) << x
#define pii pair<long long int, long int>
#define mii map<long long int, long long int>
#define w(t)                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)

using namespace std;

// ll c[MAX];

int main() {
  int n, k;
  cin >> n >> k;
  int cnt = 0;
  vector<int> v;
  forn(i, n) v.pb(0);
  forn(i, k) {
    int d;
    cin >> d;
    forn(j, d) {
      int x;
      cin >> x;
      v[x - 1]++;
    }
  }
  forn(i, n) {
    if (v[i] == 0)
      cnt++;
  }
  cout << cnt;
}


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


Fixed submission:

#include <bits/stdc++.h>
#include <map>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100009
#define endl '\\n'
#define mp make_pair
#define INF 100000000
#define fast                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define ff first
#define ss second
#define ps(x, y) fixed << setprecision(y) << x
#define pii pair<long long int, long int>
#define mii map<long long int, long long int>
#define w(t)                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)

using namespace std;

// ll c[MAX];

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v, v2;
  forn(i, n) v2.pb(0);
  int d[k];
  forn(i, n) {
    cin >> d[i];
    forn(j, d[i]) {
      int x;
      cin >> x;
      v.pb(x);
    }
    v2[d[i] - 1]++;
  }
  int cnt = 0;
  forn(i, n) {
    if (v2[i] == 0)
      cnt++;
  }
  cout << cnt;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {

  int N, K;
  cin >> N >> K;
  int A[K][N]; // 1:お菓子の種類　2:人　持っていれば:1 持っていなければ0
  int count = 0; // どれかもっているひと
                 //  初期値を0
  for (int i = 0; i != K; ++i) {
    for (int j = 0; j != N; ++j) {
      A[i][j] = 0;
    }
  }

  for (int k = 0; k != K; ++k) {
    int d; // k種類のおかしにd人います
    cin >> d;
    for (int i = 0; i != d; ++i) {
      int n;
      cin >> n;
      A[k][n - 1] = 1;
    }
  }

  for (int j = 0; j != N; ++j) {
    int sum = 0;
    for (int i = 0; i != K; ++i) {
      sum += A[i][j];
      if (sum > 0) {
        ++count;
        break;
      }
    }
  }
  cout << N - count << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main() {

  int N, K;
  cin >> N >> K;
  int A[K][N]; // 1:お菓子の種類　2:人　持っていれば:1 持っていなければ0
  int count = 0; // どれかもっているひと
                 //  初期値を0
  for (int i = 0; i != K; ++i) {
    for (int j = 0; j != N; ++j) {
      A[i][j] = 0;
    }
  }

  for (int k = 0; k != K; ++k) {
    int d;
    cin >> d;
    for (int i = 0; i != d; ++i) {
      int n;
      cin >> n;
      A[i][n - 1] = 1;
    }
  }

  for (int j = 0; j != N; ++j) {
    int sum = 0;
    for (int i = 0; i != K; ++i) {
      sum += A[i][j];
      if (sum > 0) {
        ++count;
        break;
      }
    }
  }
  cout << N - count << 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 all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k), b(n);
  vector<vector<int>> a(k, vector<int>(n));
  rep(i, k) {
    cin >> d[i];
    rep(j, d[i]) {
      cin >> a[i][j];
      a[i][j]--;
      b[a[i][j]]++;
    }
  }
  int ans = 0;
  rep(i, n) {
    if (b[i] == 0)
      ans++;
  }
  cout << ans << 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 all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k), b(n);
  vector<vector<int>> a(k, vector<int>(k));
  rep(i, k) {
    cin >> d[i];
    rep(j, d[i]) {
      cin >> a[i][j];
      a[i][j]--;
      b[a[i][j]]++;
    }
  }
  int ans = 0;
  rep(i, n) {
    if (b[i] == 0)
      ans++;
  }
  cout << ans << endl;
}
Problem p02688 (C++) — buggy submission, verdict: 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++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
  int N, K;
  cin >> N >> K;
  int d[110], A[110][110];
  vector<bool> flg(110, false);
  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]] = true;
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (!flg[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Error: 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++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
  int N, K;
  cin >> N >> K;
  int d[K], A[K][K];
  vector<bool> flg(N, false);
  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] = true;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (!flg[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

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


Error: 0

Fixed submission:

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

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

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll a, i, b, n, j;
  set<ll> s;
  cin >> a >> b;
  for (i = 0; i < b; i++) {
    cin >> n;
    ll c;
    for (j = 0; j < n; j++) {
      cin >> c;
      s.insert(c);
    }
  }
  cout << a - s.size() << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll a, i, b, n, j;
  set<ll> s;
  cin >> a >> b;
  for (i = 0; i < b; i++) {
    cin >> n;
    ll c[n];
    for (j = 0; j < n; j++) {
      cin >> c[n];
      s.insert(c[n]);
    }
  }
  cout << a - s.size() << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> d;
  vector<vector<int>> A;
  d.resize(K);
  A.resize(K, vector<int>());
  REP(i, K) {
    cin >> d[i];
    A[i].resize(d[i]);
    REP(j, d[i]) { cin >> A[i][j]; }
  }
  int cnt = 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)
      cnt++;
  }

  cout << cnt << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> d(N + 1);
  vector<vector<int>> A(K + 1, vector<int>(N + 1));
  REP(i, K) {
    cin >> d[i];
    REP(j, d[i]) { cin >> A[i][j]; }
  }
  int cnt = 0;
  FOR(i, 1, N) {
    bool have = false;
    for (auto v : A) {
      for (auto p : v) {
        if (p == i)
          have = true;
      }
    }
    if (!have)
      cnt++;
  }

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

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> f(n);
  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];
      f[a[j] - 1] = 1;
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (f[i] == 0)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> f(k);
  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];
      f[a[j] - 1] = 1;
    }
  }
  int cnt = 0;
  for (int i = 0; i < k; i++) {
    if (f[i] == 0)
      cnt++;
  }
  cout << cnt << 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 < K; i++) {
    int d;
    cin >> d;

    vector<int> vec2(d);
    for (int j = 0; j < d; j++) {
      cin >> vec2.at(j);
      vec.at(vec2.at(j) - 1)++;
    }
  }

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

  cout << ans << endl;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 18446744073709551615) >= 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 = 0; i < K; i++) {
    int d;
    cin >> d;

    vector<int> vec2(d);
    for (int j = 0; j < d; j++) {
      cin >> vec2.at(j);
      vec.at(vec.at(j) - 1)++;
    }
  }

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

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


Error: 0

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 < K; i++) {
    if (vec.at(i) == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}