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

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  vector<int> v;
  rep(i, 0, k) {
    cin >> d[i];
    vector<vector<int>> a(k, vector<int>(d[i]));
    rep(j, 0, d[i]) {
      cin >> a[i][j];
      v.push_back(a[i][j]);
    }
  }
  set<int> ans(v.begin(), v.end());
  cout << n - ans.size() << endl;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  vector<vector<int>> a(k, vector<int>(k));
  vector<int> v;
  rep(i, 0, k) {
    cin >> d[i];
    rep(j, 0, d[i]) {
      cin >> a[i][j];
      v.push_back(a[i][j]);
    }
  }
  set<int> ans(v.begin(), v.end());
  cout << n - ans.size() << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

/*
 * Project: AtCoder Beginners Contest 166
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/05/02
 * Copyright (c) 2020 toms74209200
 *
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cmath>
#include <cstdio>
using namespace std;

int n;
int k;
int d[100];
int a[100][100];

void solve() {
  int bin[n];
  for (int i = 0; i < n; i++) {
    bin[i] = 0;
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < d[i]; j++) {
      bin[a[i][j] - 1]++;
    }
  }

  int cnt = 0;

  for (int i = 0; i < n; i++) {
    if (bin[i] == 0)
      cnt++;
    // printf("%d\\n", bin[i]);
  }
  printf("%d\\n", cnt);
}

int main() {

  scanf("%d", &n);
  scanf("%d", &k);
  for (int i = 0; i < k; i++) {
    scanf("%d", &d[i]);
    for (int j = 0; j < d[i]; j++) {
      scanf("%d", &a[i][j]);
    }
  }

  solve();
}

Error: 0

Fixed submission:

/*
 * Project: AtCoder Beginners Contest 166
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/05/02
 * Copyright (c) 2020 toms74209200
 *
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cmath>
#include <cstdio>
using namespace std;

int n;
int k;
int d[100];
int a[100][100];

void solve() {
  int bin[n];
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < d[i]; j++) {
      bin[a[i - 1][j - 1]]++;
    }
  }

  int cnt = 0;

  for (int i = 0; i < n; i++) {
    if (bin[i] == 0)
      cnt++;
    // printf("%d\\n", bin[i]);
  }
  printf("%d\\n", cnt);
}

int main() {

  scanf("%d", &n);
  scanf("%d", &k);
  for (int i = 0; i < k; i++) {
    scanf("%d", &d[i]);
    for (int j = 0; j < d[i]; j++) {
      scanf("%d", &a[i][j]);
    }
  }

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

#include <iostream>
using namespace std;

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

  int d[K];
  int A[K][N];

  for (int k = 0; k < K; k++)
    for (int i = 0; i < N; i++)
      A[k][i] = 0;

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

  bool holder[N];
  for (int i = 0; i < N; i++)
    holder[i] = false;

  for (int k = 0; k < K; k++) {
    for (int i = 0; i < d[k]; i++) {
      if (A[k][i] != 0)
        holder[A[k][i] - 1] = true;
    }
  }

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (holder[i])
      cnt++;
  }

  cout << N - cnt << endl;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

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

  int d[N];
  int A[K][N];

  for (int k = 0; k < K; k++)
    for (int i = 0; i < N; i++)
      A[k][i] = 0;

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

  bool holder[N];
  for (int i = 0; i < N; i++)
    holder[i] = false;

  for (int k = 0; k < K; k++) {
    for (int i = 0; i < d[k]; i++) {
      if (A[k][i] != 0)
        holder[A[k][i] - 1] = true;
    }
  }

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (holder[i])
      cnt++;
  }

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

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

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

Error: 0

Fixed submission:

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

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

#include <algorithm>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <string>
#include <vector>
using namespace std;

// int main() {
//   int n,k;
//   cin >> n >> k;
//   int a[k][n];
//   int res=0;
//   int d[k];
//   for(int i = 0; i < k; ++i){
//     cin >> d[i];
//     for(int j=0; j < d[i]; ++j){
//       cin >> a[i][j];
//     }
//   }
//   int s[n];
//   for(int i = 0; i < n; ++i){
//     for(int j = 0; j < n; ++j){
//       s[a[i][j]]++;
//     }
//   }
//   for(int i = 0; i < n; ++i){
//     if(s[i] == 0){
//       res++;
//     }
//   }
//   cout << res << endl;
// }

int N, K;
vector<int> d;
vector<vector<int>> A;

void input() {
  cin >> N >> K;
  d.resize(K);
  A.resize(K, vector<int>());
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    A[i].resize(d[i]);
    for (int j = 0; j < d[i]; j++) {
      cin >> A[i][j];
    }
  }
}

void 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: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <string>
#include <vector>
using namespace std;

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

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

  for (int i = 0; i < n; ++i) {
    if (s[i] == 0) {
      res++;
    }
  }

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

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

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

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (flag[i] == 0)
      ans++;
  }
  cout << ans;
  return 0;
}


Error: WA

Fixed submission:

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> flag(n);
  for (int i = 0; i < n; i++)
    flag[i] = 0;
  for (int i = 0; i < k; i++) {
    int a;
    cin >> a;
    vector<int> b(a);
    for (int i = 0; i < a; i++) {
      cin >> b[i];
    }
    for (int i = 0; i < a; i++) {
      flag[b[i]] = 1;
    }
  }

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

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

int main() {
  /* Input */
  int N, K;
  cin >> N >> K;

  vector<bool> snukes(N);
  rep(i, N) snukes.at(i) = false;

  rep(i, K) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      snukes.at(a - 1) = true;
    }
  }
  int ans = 0;
  rep(i, N) if (!snukes.at(i)) ans++;

  /* Output */
  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  /* Input */
  int N, K;
  cin >> N >> K;

  vector<bool> snukes(N);
  rep(i, N) snukes.at(i) = false;

  rep(i, K) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      snukes.at(a - 1) = true;
    }
  }
  int ans = 0;
  rep(i, K) if (!snukes.at(i)) ans++;

  /* Output */
  cout << ans << endl;

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

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

int main() {
  int n, k;
  int ans = 0;
  cin >> n >> k;
  vector<int> flag_n(n);
  rep(i, n) { flag_n[i] = 0; }
  rep(i, k) {
    int tcnt;
    cin >> tcnt;
    rep(j, tcnt) {
      int temp;
      cin >> temp;
      if (flag_n[temp - 1] == 0)
        flag_n[temp - 1] = 1;
    }
  }
  rep(i, n) {
    if (flag_n[i] == 0)
      ans++;
  }
  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int n, k;
  int ans = 0;
  cin >> n >> k;
  vector<int> flag_n(n);
  rep(i, k) { flag_n[i] = 0; }
  rep(i, k) {
    int tcnt;
    cin >> tcnt;
    rep(j, tcnt) {
      int temp;
      cin >> temp;
      if (flag_n[temp - 1] == 0)
        flag_n[temp - 1] = 1;
    }
  }
  rep(i, n) {
    if (flag_n[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> vec(n, 1);

  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) = 0;
    }
  }

  int ans = 0;

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

  cout << ans << 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, 1);

  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) = 0;
    }
  }

  int ans = 0;

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

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

#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define ALL(x) (x).begin(), (x).end()
#define rALL(x) (x).rbegin(), (x).rend()
typedef long double ld;
using ll = long long;
using namespace std;
const int mod = 1e9 + 7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  int n, k;
  cin >> n >> k;
  vector<int> snk(n);
  rep(i, 0, k) {
    int d;
    cin >> d;
    rep(i, 1, d + 1) {
      int a;
      cin >> a;
      snk[a - 1]++;
    }
  }
  int ans = 0;
  rep(i, 0, n) {
    if (!snk[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define ALL(x) (x).begin(), (x).end()
#define rALL(x) (x).rbegin(), (x).rend()
typedef long double ld;
using ll = long long;
using namespace std;
const int mod = 1e9 + 7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

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

#include <iostream>
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 num;
  int y;
  for (int i = 0; i < k; ++i) {
    cin >> num;
    for (int x = 0; x < num; ++x) {
      cin >> y;
      a[y - 1] += 1;
    }
  }

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

  cout << count << endl;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;

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

  int num;
  int y;
  for (int i = 0; i < k; ++i) {
    cin >> num;
    for (int x = 0; x < num; ++x) {
      cin >> y;
      a[y - 1] += 1;
    }
  }

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

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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const unsigned int M = 1000000007;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(n);
  rep(i, k) {
    int m;
    cin >> m;
    rep(j, m) {
      int a;
      cin >> a;
      d[a - 1] = 1;
    }
  }
  int ans = 0;
  rep(i, n) if (d[i] == 0)++ ans;
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const unsigned int M = 1000000007;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  rep(i, k) {
    int m;
    cin >> m;
    rep(j, m) {
      int a;
      cin >> a;
      d[a - 1] = 1;
    }
  }
  int ans = 0;
  rep(i, n) if (d[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<bool> s(n, false);

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

    for (int j = 0; j < d; j++) {
      s.at(a.at(j) - 1) = true;
    }
  }

  int count = 0;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == false)
      count++;
  }
  cout << count << endl;
}

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


Fixed submission:

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

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

  vector<bool> s(n, false);

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

    for (int j = 0; j < d; j++) {
      s.at(a.at(j)) = true;
    }
  }

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

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

int main() {

  int a, b, c[110][110], d[110], e[110] = {0};

  cin >> a >> b;

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

    cin >> d[i];

    for (int j = 0; j < d[i]; j++)
      cin >> c[d[i]][j];

    for (int k = 0; k < d[i]; k++) {
      e[c[d[i]][k]]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= a; i++) {
    if (e[i] > 0) {
      ans++;
    }
  }

  cout << a - ans << endl;
}


Error: -11

Fixed submission:

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

int main() {

  long long int a, b, d[110], e[110] = {0};

  cin >> a >> b;
  for (int i = 0; i < b; i++) {

    cin >> d[i];

    int c[d[i]];
    for (int j = 0; j < d[i]; j++)
      cin >> c[j];

    for (int i = 0; i < d[i]; i++) {
      e[c[i]]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= a; i++) {
    if (e[i] > 0) {
      ans++;
    }
  }

  cout << a - 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 d[K];
  int A[K][N];
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      cin >> A[i][j];
    }
  }
  int sum = 0;
  int a[N];
  for (int i = 0; i < N; i++) {
    a[i] = 0;
  }
  for (int i = 0; i < K; i++) {
    for (int j = 0; j < d[i]; j++) {
      if (a[A[i][j] - 1] == 0) {
        a[A[i][j] - 1] = 1;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (a[i] == 0) {
      sum++;
    }
  }
  cout << sum << endl;
}

Error: -11

Fixed submission:

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

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

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

int main() {
  int n, k, cnt = 0;
  cin >> n >> k;
  map<int, int> mp;
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      mp[a]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (mp[i] == 0)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Error: 0

Fixed submission:

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

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

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

int main() { /* ここに書く */

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

  vector<bool> child(N);

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

    int d;
    cin >> d;

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

      int A;
      cin >> A;
      A--;
      child.at(A) = 1;
    }
  }

  int f;

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

    if (child.at(i) == 0) {
      f = f + 1;
    }
  }

  cout << f << endl;
}


Error: WA

Fixed submission:

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

int main() { /* ここに書く */

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

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

    cin >> d;

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

      cin >> A;
      A = A - 1;
      vec.at(A) = 1;
    }
  }

  int Ans;

  for (int i = 0; i < K; 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;
  int d[k];
  int a[1100];
  int q;
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      cin >> q;
      a[q - 1] = -1;
    }
  }
  int p = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != -1)
      p++;
  }

  cout << p << endl;
}

Error: 0

Fixed submission:

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

int main() {
  int n, k;
  cin >> n >> k;
  // int d[k];
  /*vector<vector<int>> d(k, vector<int>(110))

  for (int i=0; i<k; i++){
     cin >>
     for (int j=0; j<)
  }*/
  int p = 0;
  // int s[1000];
  int l = k;
  /*for(int i=0; i<l+1; i++){
     if(p==0){
        cin >> p;
        k += p;

     }else{
        cin >> s[i];
        p--;

     }

  }*/
  int d[1000];
  int a[1000];

  vector<int> s(1000);

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

  int ans = 0;

  for (int i = 1; i < p + 1; i++) {
    auto result = find(s.begin(), s.end(), i);
    if (result == s.end()) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define For(i, m, n) for (int i = m; i < n; i++)
#define FOR(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
#define all(x) x.begin(), x.end()
ll mob = 1000000007;
using namespace std;
int main() {
  int n, k;

  cin >> n >> k;
  int a[n + 1];
  memset(a, 0, sizeof(a));
  while (k--) {
    int d;
    cin >> d;
    FOR(i, d) {
      int y;
      cin >> y;
      a[y]++;
    }
  }
  int r = 0;
  For(i, 1, n + 1) {
    if (!a[i])
      r++;
  }

  cout << r;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define For(i, m, n) for (int i = m; i < n; i++)
#define FOR(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
#define all(x) x.begin(), x.end()
ll mob = 1000000007;
using namespace std;
int main() {

  int n, k;
  int a[n + 1];
  memset(a, 0, sizeof(a));
  cin >> n >> k;
  while (k--) {
    int d;
    cin >> d;
    FOR(i, d) {
      int y;
      cin >> y;
      a[y]++;
    }
  }
  int r = 0;
  For(i, 1, n + 1) {
    if (!a[i])
      r++;
  }

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

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

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

  vector<ll> sunuke(N);
  for (size_t i = 0; i < K; i++) {
    ll d;
    cin >> d;
    vector<ll> A(d);
    for (size_t i = 0; i < d; i++) {
      cin >> A[i];
      sunuke[A[i] - 1]++;
    }
  }

  ll ans = 0;
  for (size_t i = 0; i < N; i++) {
    if (sunuke[i] == 0) {
      ans++;
    }
  }

  cout << ans << endl;
}


Error: -6
munmap_chunk(): invalid pointer


Fixed submission:

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

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

  vector<ll> sunuke(N);
  for (size_t i = 0; i < K; i++) {
    ll d;
    cin >> d;
    vector<ll> A(d);
    for (size_t i = 0; i < d; i++) {
      cin >> A[i];
      sunuke[A[i]]++;
    }
  }

  ll ans = 0;
  for (size_t i = 1; i <= N; i++) {
    if (sunuke[i] == 0) {
      ans++;
    }
  }

  cout << ans << endl;
}