alexjercan/bugnet huggingface dataset:
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;
  vector<int> haveList(N);
  vector<vector<int>> A;
  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];
    }
  }
  for (int i = 0; i < N; i++) {
    haveList[i] = 0;
  }

  for (int i = 0; i < K; i++) {
    for (int j = 0; j < d[i]; j++) {
      haveList[A[i][j] - 1]++;
    }
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (haveList[i] == 0) {
      count++;
    }
  }
  cout << count << endl;
}

Error: -11

Fixed submission:

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

int main() {

  int N, K;
  cin >> N >> K;

  vector<int> d;
  vector<vector<int>> A;
  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];
    }
  }

  int count = 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)
      count++;
  }

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

#include <cstdio>
#define MAXN 200
using namespace std;
bool vis[MAXN];
int main() {
  int n, k, d;
  scanf("%d%d", &n, &k);
  for (register int i = 1; i <= k; i++) {
    scanf("%d", &d);
    for (register int j = 1; j <= d; j++) {
      int u;
      scanf("%d", &u);
      vis[u] = 1;
    }
  }
  int ans = 0;
  for (register int i = 1; i <= n; i++) {
    if (!vis[i])
      ans++;
  }
  return !printf("%d", ans);
}

Error: -11

Fixed submission:

#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
  int n, k, i, j, p, count;
  scanf("%d %d", &n, &k);
  int *pd = (int *)malloc(sizeof(int) * n * k);
  int *pt = new int[n];
  count = 0;
  for (i = 0; i < n; i++) {
    pt[i] = 0;
  }
  for (i = 0; i < 2 * k; i += 2) {
    scanf("%d", &p);
    for (j = 0; j < p; j++) {
      scanf("%d", pd[k * (i + 1) / 2 + j]);
      pt[pd[k * (i + 1) / 2 + j]] = 1;
    }
  }
  for (i = 0; i < n; i++) {
    if (pd[i] == 0) {
      count++;
    }
  }
  delete[] pt;
  free(pd);
  printf("%d", count);
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  ll N, K;
  cin >> N >> K;
  set<ll> set;
  rep(i, K) {
    ll a;
    cin >> a;
    for (ll b = 0; b < a; b++) {
      ll c[b];
      cin >> c[b];
      set.insert(c[b]);
    }
  }
  cout << N - set.size();
}

Error: WA

Fixed submission:

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

int main() {
  int N, K;
  cin >> N >> K;
  set<int> set;
  rep(i, K) {
    int a;
    cin >> a;
    for (int b = 0; b < a; b++) {
      int c[b];
      cin >> c[b];
      set.insert(c[b]);
    }
  }
  cout << N - set.size();
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main(void) {

  int N, K, i, j, *n, d, dn, count;

  cin >> N >> K;

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

  count = N;
  for (i = 0; i < K; i++) {
    cin >> d;
    for (j = 0; j < d; j++) {
      cin >> dn;
      if (n[dn] != 0) {
        n[dn] = 0;
        count--;
      }
    }
  }

  cout << count << endl;

  delete n;

  return 0;
}


Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {

  int N, K, i, j, *n, d, dn, count;

  cin >> N >> K;

  n = new int[N + 1];
  n[N + 1] = {1};
  /*for (i = 0; i < N; i++) {
      n[i + 1] = i + 1;
  }*/

  count = N;
  for (i = 0; i < K; i++) {
    cin >> d;
    for (j = 0; j < d; j++) {
      cin >> dn;
      if (n[dn] != 0) {
        n[dn] = 0;
        count--;
      }
    }
  }
  count--;

  cout << count << endl;

  delete n;

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

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

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


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


Fixed submission:

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

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

#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
// #define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL << 60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) FOR(i, 0, (n))
#define RREP(i, n) RFOR(i, 0, (n))
#define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i, a, b) ((a) <= (i) && (i) < (b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int, int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n, k;
  cin >> n >> k;
  vec d(k);
  mat a(k);
  REP(i, k) {
    cin >> d[i];
    REP(j, d[i]) {
      int t;
      cin >> t;
      t--;
      a[i].push_back(t);
    }
  }

  vec b(n, 0);
  REP(i, a.size()) REP(j, a[i].size()) { b[a[i][j]]++; }

  int ans = 0;
  REP(i, n) {
    if (b[i] == 0)
      ans++;
  }

  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
// #define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL << 60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) FOR(i, 0, (n))
#define RREP(i, n) RFOR(i, 0, (n))
#define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i, a, b) ((a) <= (i) && (i) < (b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int, int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n, k;
  cin >> n >> k;
  vec d(k);
  mat a(k);
  REP(i, k) {
    cin >> d[k];
    REP(j, d[k]) {
      int t;
      cin >> t;
      t--;
      a[i].push_back(t);
    }
  }

  vec b(n, 0);
  REP(i, a.size()) REP(j, a[i].size()) { b[a[i][j]]++; }

  int ans = 0;
  REP(i, n) {
    if (b[i] == 0)
      ans++;
  }

  cout << ans << endl;

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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define PRINT(V)                                                               \\
  for (auto v : (V))                                                           \\
  cout << v << " "
const long long INF = 1LL << 60;
using namespace std;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

int main() {

  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  rep(i, n) { x[i] = 0; }
  rep(i, k) {
    int d;
    cin >> d;
    vector<int> a(d);
    rep(i, d) {
      cin >> a[i];
      x[a[i] - 1] = 1;
    }
  }
  int cnt = 0;
  rep(i, n) {
    if (x[i] == 0) {
      cnt++;
    }
  }
  cout << cnt;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define PRINT(V)                                                               \\
  for (auto v : (V))                                                           \\
  cout << v << " "
const long long INF = 1LL << 60;
using namespace std;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

int main() {

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

#include <algorithm>
#include <float.h>
#include <functional>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <type_traits>
#include <vector>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define in cin >>
#define out cout <<
#define sort1(v) sort(v.begin(), v.end())
#define reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(), v.end()
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 3);
  vector<int> d(k + 3);
  int b;

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

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

  ans = n - ans;
  cout << ans;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <float.h>
#include <functional>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <type_traits>
#include <vector>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define in cin >>
#define out cout <<
#define sort1(v) sort(v.begin(), v.end())
#define reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(), v.end()
typedef long long ll;

int main() {
  int n, k;
  vector<int> a(n + 3);
  vector<int> d(k + 3);
  int b;
  cin >> n >> k;

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

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

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

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

int main() {
  int a, b;
  cin >> a >> b;
  int d[b];
  int sum = 0;
  vector<int> N(0);
  for (int i = 0; i < b; i++) {
    cin >> d[i];
    sum += d[i];
    for (int j = 0; j < d[i]; j++) {
      int c;
      cin >> c;
      N.push_back(c);
    }
  }
  int ans = 1;
  sort(N.begin(), N.end());
  for (int i = 0; i < sum - 1; i++) {
    if (N.at(i) != N.at(i + 1)) {
      ans++;
    }
  }
  cout << a - 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 3)


Fixed submission:

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

int main() {
  int a, b;
  cin >> a >> b;
  int d[b];
  int sum = 0;
  vector<int> N(0);
  for (int i = 0; i < b; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      int c;
      cin >> c;
      N.push_back(c);
    }
  }
  int ans = 0;
  sort(N.begin(), N.end());
  for (int i = 0; i < N.size(); i++) {
    if (N.at(i) != N.at(i + 1) && N.at(i) != N.at(i + 1) - 1) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

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

  int d = 0;
  std::map<int, int> snuke;
  // for(int i=0; i<=100; i++)  snuke[i] = -1;

  for (int i = 0; i < k; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      int tmp;
      cin >> tmp;
      snuke[tmp] = 0;
      // cout << tmp << endl;
    }
  }
  cout << n - snuke.size() << endl;
}

Error: 0

Fixed submission:

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

using namespace std;

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

  int d[n];
  int snuke[101];
  for (int i = 0; i <= 100; i++)
    snuke[i] = -1;
  std::vector<int> a[k];
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      int tmp;
      cin >> tmp;
      snuke[tmp] = 1;
      // cout << tmp << endl;
    }
  }
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    if (snuke[i] == -1)
      sum++;
  }
  cout << sum << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n, m) for (int i = (n); i < (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
const int INF = 1e9;
const ll MOD = 1000000007;
const ll LINF = 1e18;
using namespace std;

int main() {
  int n, k, count = 0;

  cin >> n >> k;
  vector<int> d(k);
  vector<bool> b(n, false);
  vector<vector<int>> a(k, vector<int>(n, 0));
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      cin >> a[i][j];
    }
  }

  rep(i, k) {
    rep(j, d[i]) { b[a[i][j] - 1] = true; }
  }

  rep(i, n) {
    if (b[i] == false)
      count++;
  }

  cout << count << endl;

  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n, m) for (int i = (n); i < (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
const int INF = 1e9;
const ll MOD = 1000000007;
const ll LINF = 1e18;
using namespace std;

int main() {
  int n, k, count = 0;
  vector<bool> b(n, false);

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

  rep(i, k) {
    rep(j, d[i]) { b[a[i][j] - 1] = true; }
  }

  rep(i, n) {
    if (b[i] == false)
      count++;
  }

  cout << 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++)
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> cnt(n);
  rep(i, k) {
    int d;
    cin >> d;

    rep(j, d) {
      int a;
      cin >> a;
      cnt[a - 1]++;
    }
  }
  int ans = 0;
  rep(i, n) {
    if (cnt[i] == 0) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(n), cnt(n);
  for (int i = 0; i < k; i++) {
    cin >> d[i];

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

  cout << ans << endl;

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

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

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

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

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

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

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

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

  ll N, K;

  cin >> N >> K;

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

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

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

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

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

  ll tmp = 0;

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


Error: 0

Fixed submission:

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

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

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

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

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

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

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

  ll N, K;

  cin >> N >> K;

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

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

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

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

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

  ll tmp = 0;

  REP(i, vec.size() - 1) {
    if (!(vec.at(i) == vec.at(i + 1))) {
      tmp++;
    }
    // cout << tmp<<endl;
  }
  cout << N - tmp << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

Error: 0

Fixed submission:

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

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

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

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == 0)
      ans++;
  }
  cout << ans << endl;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
  int N, K;
  cin >> N >> K;
  vi d;
  vii A;
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int max = 0;
  for (int i = 0; i < K; i++) {
    for (int j = 0; j < d[i]; j++) {
      if (A.at(i).at(j) > max) {
        max = A.at(i).at(j);
      }
    }
  }
  map<int, int> mp;
  for (int i = 0; i < K; i++) {
    for (int j = 0; j < d.at(i); j++) {
      mp[A.at(i).at(j)]++;
    }
  }
  int a = mp.size();
  int ans = max - a + N - max;
  cout << ans << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int temp[n] = {0};
  for (int i = 0; i < k; i++) {
    int t;
    cin >> t;
    int a[t];
    for (int j = 0; j < t; j++) {
      cin >> a[j];
      temp[a[j] - 1]++;
    }
  }
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (temp[i] == 0) {
      c++;
    }
  }
  cout << c;
  return 0;
}

Error: WA

Fixed submission:

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

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;

  vector<int> d(N + 1, 0);
  bitset<105> db;
  REP(ii, N) db.set(ii + 1);

  int tmp;
  REP(ii, K) {
    cin >> d[ii];
    REP(jj, d[ii]) {
      cin >> tmp;
      db.reset(tmp);
    }
  }
  cout << db.count() << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;

  vector<int> d(N + 1, 0);
  bitset<105> db;
  REP(ii, N) db.set(ii + 1);

  vector<vector<int>> A(K + 1, d);

  REP(ii, K) {
    cin >> d[ii];
    A[ii].clear();
    REP(jj, d[ii]) {
      cin >> A[ii][jj];
      db.reset(A[ii][jj]);
    }
  }
  cout << db.count() << endl;
  return 0;
}