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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <limits>
#include <map>
#include <numeric> // 最大公約数が使える
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; // 10^9

int main() {

  int N, K;
  cin >> N >> K;
  int ans = 0;
  vector<int> A(N, 0);

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

  /*
  vector<int> A(N);
  iota(A.begin(),A.end(),1);
  int ans=0;


   for(int i=0;i<K;i++){
       int d;
       cin >> d;
       cout << d << endl;

       vector<int>B(N);
       for(int j=0;j<N;j++){
           int a;
           cin >> a;
       cout << a << endl;
           B.push_back(a);
       }
           int b = B.size();

      for (int j = 0; j < b; j++)
      {
          for (int k = 0; k < N; k++)
          {
              if(A[k]==B[j]){
                  A[k]=0;
              }
          }

      }
   }





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

  cout << ans << endl;
  */
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <limits>
#include <map>
#include <numeric> // 最大公約数が使える
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; // 10^9

int main() {

  int N, K;
  cin >> N >> K;
  int ans = 0;
  vector<int> A(N, 0);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      A[a] = 1;
    }
  }
  for (int i = 0; i < N; i++) {
    if (A[i] == 1) {
      ans++;
    }
  }
  cout << ans << endl;

  /*
  vector<int> A(N);
  iota(A.begin(),A.end(),1);
  int ans=0;


   for(int i=0;i<K;i++){
       int d;
       cin >> d;
       cout << d << endl;

       vector<int>B(N);
       for(int j=0;j<N;j++){
           int a;
           cin >> a;
       cout << a << endl;
           B.push_back(a);
       }
           int b = B.size();

      for (int j = 0; j < b; j++)
      {
          for (int k = 0; k < N; k++)
          {
              if(A[k]==B[j]){
                  A[k]=0;
              }
          }

      }
   }





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

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
const int mod = 1000000007;
int main() {
  int n, k, i, d, j, x, c = 0;
  cin >> n >> k;
  int f[n];
  for (i = 0; i < n; i++)
    f[i] = 0;
  for (i = 0; i < k; i++) {
    cin >> d;
    for (j = 0; j < d; j++) {
      cin >> x;
      f[x - 1] = 1;
    }
  }
  for (i = 0; i < n; i++) {
    if (f[i] == 0)
      c++;
  }
  cout << c;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
const int mod = 1000000007;
int main() {
  int n, k, i, d, j, x, c = 0;
  cin >> n >> k;
  int f[k];
  for (i = 0; i < n; i++)
    f[i] = 0;
  for (i = 0; i < k; i++) {
    cin >> d;
    for (j = 0; j < d; j++) {
      cin >> x;
      f[x - 1] = 1;
    }
  }
  for (i = 0; i < n; i++) {
    if (f[i] == 0)
      c++;
  }
  cout << c;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n; i++)
#define ll long long
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int d[k];
  int ans = 0;
  map<int, int> mp;
  rep(i, k) {
    cin >> d[i];
    int tmp[d[i]];
    rep(j, d[i]) {
      cin >> tmp[j];
      mp[tmp[j] - 1]++;
    }
  }
  for (auto p : mp) {
    ans++;
  }
  cout << n - ans;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n; i++)
#define ll long long
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int d[k];
  int ans = 0;
  map<int, int> mp;
  rep(i, n) {
    cin >> d[i];
    int tmp[d[i]];
    rep(j, d[i]) {
      cin >> tmp[j];
      mp[tmp[j] - 1]++;
    }
  }
  for (auto p : mp) {
    ans++;
  }
  cout << n - ans;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, d, a, c = 0;

  cin >> n >> k;
  vector<int> v(n + 1);
  for (int i = 0; i < k; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> a;
      v[a] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (v[i] == 0)
      c++;
  }
  cout << c << endl;
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::length_error'
  what():  cannot create std::vector larger than max_size()


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, d, a, c = 0;
  vector<int> v(n);
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> a;
      v[a] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (v[i] == 0)
      c++;
  }
  cout << c << endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, ans = 0;
  bool k[1005];
  for (int i = 0; i < 1005; i++)
    k[i] = false;
  cin >> a >> b;
  for (int i = 0; i < b; i++) {
    int u;
    cin >> u;
    for (int j = 0; j < u; j++) {
      int f;
      cin >> f;
      k[f - 1] = true;
    }
  }
  for (int i = 0; i < a; i++)
    if (k[i] == false)
      ans++;
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
bool k[105] = {0};
int main() {
  int a, b, ans = 0;
  cin >> a >> b;
  for (int i = 0; i < b; i++) {
    int u;
    cin >> u;
    for (int j = 0; j < u; j++) {
      int f;
      cin >> f;
      k[f] = 1;
    }
  }
  for (int i = b - 1; i >= 0; i++)
    if (k[i] == 0)
      ans++;
  cout << ans;
  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> cnt(N);
  int d;
  int count = 0;
  for (int i = 0; i < K; i++) {
    cin >> d;
    vector<int> A(d);
    for (int j = 0; j < d; j++) {
      cin >> A.at(j);
      cnt.at(A.at(j) - 1) = true;
    }
  }
  for (int i = 0; i < N; i++) {
    if (cnt.at(i) == false) {
      count++;
    }
  }
  cout << count << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<bool> cnt(N);
  int d;
  int count = 0;
  for (int i = 0; i < K; i++) {
    cin >> d;
    vector<int> A(d);
    for (int j = 0; j < d; j++) {
      cin >> A.at(j);
      cnt.at(A.at(j) - 1) = true;
    }
  }
  for (int i = 0; i < K; i++) {
    if (cnt.at(i) == false) {
      count++;
    }
  }
  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++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main() {
  int n, k;
  cin >> n >> k;
  int d[k];
  int a[k][n];
  int count = 0;

  for (int i = 0; i < k; i++) {
    cin >> d[i];
    // printf("%d\\n", d[i]);

    for (int j = 0; j < d[i]; j++) {
      cin >> a[i][j];
      // printf("%d ", a[i][j]);
    }
  }

  int s[n];

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

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

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

  printf("%d", count);
}

int main() {
  std::cout << std::fixed << std::setprecision(15);
  Main();
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main() {
  int n, k;
  cin >> n >> k;
  int d[k];
  int a[n][n];
  int count = 0;

  for (int i = 0; i < k; i++) {
    cin >> d[i];
    // printf("%d\\n", d[i]);

    for (int j = 0; j < d[i]; j++) {
      cin >> a[i][j];
      // printf("%d ", a[i][j]);
    }
  }

  int s[n];

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

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

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

  printf("%d", count);
}

int main() {
  std::cout << std::fixed << std::setprecision(15);
  Main();
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, K;
  cin >> N >> K;
  int t[N];
  for (int i = 0; i < N; i++) {
    t[i] = 0;
  }
  vector<int> d(K);
  for (int i = 0; i < K; i++) {
    cin >> d.at(i);
    vector<int> A(d.at(i));
    for (int j = 0; j < d.at(i); j++) {
      cin >> A.at(j);
      t[A.at(j) - 1]++;
    }
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (t[i] == 0) {
      count++;
    }
  }
  cout << count << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, K;
  cin >> N >> K;
  int t[N];
  for (int i = 0; i < N; i++) {
    t[i] = 0;
  }
  vector<int> d(K);
  for (int i = 0; i < K; i++) {
    cin >> d.at(i);
    vector<int> A(d.at(i));
    for (int j = 0; j < d.at(i); j++) {
      cin >> A.at(j);
      t[A.at(j)]++;
    }
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (t[i] == 0) {
      count++;
    }
  }
  cout << count - 1 << 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 repe(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep_bit(n) for (int bit = 0; bit < (1 << n); ++bit)
#define ll long long
using namespace std;
typedef vector<vector<int>> Graph;

int main() {

  int N, K;
  cin >> N >> K;
  vector<bool> exist(N, false);
  rep(i, K) {
    int d;
    cin >> d;
    rep(j, d) {
      int A;
      cin >> A;
      exist.at(A - 1) = true;
    }
  }
  int cnt = 0;
  rep(i, N) {
    if (!exist.at(i))
      cnt++;
  }
  cout << cnt << 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>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repe(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep_bit(n) for (int bit = 0; bit < (1 << n); ++bit)
#define ll long long
using namespace std;
typedef vector<vector<int>> Graph;

int main() {

  int N, K;
  cin >> N >> K;
  vector<bool> exist(N, false);
  rep(i, K) {
    int d;
    cin >> d;
    rep(j, d) {
      int A;
      cin >> A;
      exist.at(A) = true;
    }
  }
  int cnt = 0;
  rep(i, N) {
    if (!exist.at(i))
      cnt++;
  }
  cout << cnt << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, k, x, nn;
  cin >> n >> k;
  vector<int> d[n + 2];
  for (int i = 1; i <= k; ++i) {
    cin >> nn;
    for (int j = 0; j < nn; ++j) {
      cin >> x;
      d[x].pb(i);
    }
  }
  int ct = 0;
  for (int i = 1; i <= n; ++i) {
    if (d[i].size() == 0)
      ++ct;
  }
  cout << ct << '\\n';
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, k, d, x;
  bool vis[n + 5];
  cin >> n >> k;
  for (int i = 0; i < k; ++i) {
    cin >> d;
    for (int j = 0; j < d; ++j) {
      cin >> x;
      vis[x] = true;
    }
  }
  int ct = 0;
  for (int i = 1; i <= n; ++i) {
    if (!vis[i])
      ++ct;
  }
  cout << ct << '\\n';
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

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


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int N, K, result = 0;
  cin >> N >> K;
  vector<int> d(K), a(N), b(N);
  REP(i, N) { b[i] = 0; }
  REP(i, K) {
    cin >> d[i];
    REP(j, d[i]) {
      cin >> a[i];
      b[a[i] - 1]++;
    }
  }
  REP(i, N) {
    if (b[i] == 0) {
      result++;
    }
  }
  cout << result << 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)
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  vec s(n, 0);

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

  cout << c << endl;
}


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 int;
using vec = vector<int>;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  vec d(k);
  vector<vec> a(n);
  vec s(n, 0);

  rep(i, k) {
    cin >> d[i];
    a[i] = vec(d[i]);
    rep(j, d[i]) {
      cin >> a[i][j];
      s[a[i][j] - 1]++;
    }
  }
  int c = 0;
  rep(i, n) {
    if (s[i] == 0) {
      c++;
    }
  }

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

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

int main() {
  int N, K;
  cin >> N >> K;
  bitset<100> A;
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int k;
      cin >> k;
      A.set(k - 1);
    }
  }

  cout << N - A.count() << endl;
}

Error: 0

Fixed submission:

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

int main() {
  int N, K;
  cin >> N >> K;
  bitset<100> A;
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int k;
      cin >> k;
      A.set(k);
    }
  }

  cout << N - A.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;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> have(n);
  vector<int> d(k);
  rep(i, k) {
    int a;
    cin >> a;
    rep(j, a) {
      int b;
      cin >> b;
      have.at(b - 1) = 1;
    }
  }
  int count = 0;
  rep(i, n) {
    if (have.at(i) == 1)
      continue;
    count++;
  }
  cout << count;
}


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>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> have(n);
  vector<int> d(k);
  rep(i, k) {
    int a;
    cin >> a;
    rep(j, a) {
      int b;
      cin >> b;
      have.at(b) = 1;
    }
  }
  int count = 0;
  rep(i, n) {
    if (have.at(i) == 1)
      continue;
    count++;
  }
  cout << count;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

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

  int d;
  vector<int> A(110);

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

    for (int j = 0; j < d; j++) {
      int tmp = 0;
      cin >> tmp;
      A[tmp] = 1;
    }
  }

  int res = 0;

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

  return 0;
}

Error: WA

Fixed submission:

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

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

  int d;
  vector<int> A(N);

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

    for (int j = 0; j < d; j++) {
      int tmp = 1;
      cin >> tmp;
      A[tmp] = 1;
    }
  }

  int res = 0;

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

  cout << res;

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

#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
int visit[101];
int main() {
  int N, K;
  cin >> N >> K;
  for (int i = 1; i <= K; i++) {
    int d1, v;
    cin >> d1;
    for (int j = 1; j <= d1; j++) {
      cin >> v;
      visit[v] = 1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (!visit[i])
      ans++;
  }
  cout << ans;
  return 0;
}

Error: WA

Fixed submission:

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

const int N = 2e5 + 7;
struct node {
  int a, b, c, d;
} Q[55];

int n, m, q;
int s[15], ans;

void check() {
  int num = 0;
  for (int i = 0; i < q; i++) {
    if (s[Q[i].b] - s[Q[i].a] == Q[i].c)
      num += Q[i].d;
  }
  ans = max(ans, num);
}
void dfs(int pos, int val) {
  s[pos] = val;
  if (pos == n) {
    check();
    return;
  }
  for (int i = val; i <= m; i++) {
    dfs(pos + 1, i);
  }
}
int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    Q[i] = (node){a, b, c, d};
  }
  dfs(1, 1);
  cout << ans << endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  int k;
  int P[N + 1] = {0};
  int count = 0;

  for (i = 1; i <= N; i++) {
    for (j = 1; j <= K; j++) {
      for (k = 1; k <= d[j]; k++) {
        if (i == A[j][k]) {
          P[i] = P[i] + A[j][k];
        }
      }
    }
    if (P[i] == 0)
      count++;
  }

  cout << count << endl;
}

Error: TLE

Fixed submission:

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

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

  int d[K + 1];
  int A[K + 1][N + 1];
  int i, j, k;
  for (i = 1; i <= K; i++) {
    cin >> d[i];
    for (j = 1; j <= d[i]; j++) {
      cin >> A[i][j];
    }
  }

  int P[N + 1];
  int count = 0;

  for (i = 1; i <= N; i++) {
    for (j = 1; j <= K; i++) {
      for (k = 1; k <= d[j]; k++) {
        if (i == A[j][k]) {
          P[i] = P[i] + A[j][k];
        }
      }
    }
    if (P[i] == 0)
      count++;
  }

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

#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int N, K;
  int d;
  int a[10100];
  int t = 0;
  int count = 0;
  cin >> N >> K;
  for (int i = 0; i < K; ++i) {
    cin >> d;
    for (int j = 0; j < d; ++j) {
      cin >> a[t];
      ++t;
    }
  }

  sort(a, a + t);
  for (int i = 0; i < t; ++i) {
    if (a[i] == a[i + 1]) {
      ++count;
    }
  }
  cout << N - (t - count);
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int N, K;
  int d;
  int a[110];
  int t = 0;
  int count = 0;
  cin >> N >> K;
  for (int i = 0; i < K; ++i) {
    cin >> d;
    for (int j = 0; j < d; ++j) {
      cin >> a[t];
      ++t;
    }
  }

  sort(a, a + N);
  for (int i = 0; i < t; ++i) {
    if (a[i] == a[i + 1]) {
      ++count;
    }
  }
  cout << N - (t - count);
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for (auto &i : mp)

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 10), d(n + 10), b(n + 10);
  int tmp, dd;
  rep(i, k) {
    cin >> dd;
    rep(j, dd) {
      cin >> tmp;
      b[tmp] = 1;
    }
  }

  ll ans = 0;
  repr(i, 1, n + 1) {
    if (b[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for (auto &i : mp)

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 10), d(n + 10), b(n + 10);
  rep(i, k) {
    cin >> d[i];
    rep(j, d[i]) {
      cin >> a[j];
      b[a[j]] = 1;
    }
  }

  ll ans = 0;
  repr(i, 1, n + 1) {
    if (b[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}