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

#include <iostream>
using namespace std;

int main() {
  string s;
  cin >> s;
  if (s == "ABC")
    cout << "ARC"
         << "\\n";
  else
    cout << "ABC"
         << "\\n";
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int solve() {
  string s;
  cin >> s;
  if (s == "ABC")
    puts("ARC");
  else
    puts("ABC");
}

int main() { solve(); }
Problem p02687 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <tuple>
#include <unordered_map>
#include <vector>

#include <boost/range/adaptors.hpp>

int main() {
  std::string S;
  std::cin >> S;
  if (S == "ABC") {
    std::cout << "ARC" << std::endl;
  } else {
    std::cout << "ABC" << std::endl;
  }

  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <tuple>
#include <unordered_map>
#include <vector>

#include <boost/range/adaptors.hpp>

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

  std::vector<int> having(N, 0);
  for (int i = 0; i < K; ++i) {
    int d;
    std::cin >> d;
    for (int j = 0; j < d; ++j) {
      int x;
      std::cin >> x;
      having[x - 1] = 1;
    }
  }
  int count = 0;
  for (auto x : having) {
    if (x == 0)
      ++count;
  }
  std::cout << count << std::endl;

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

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

#define E "\\n"
#define int long long
#define f(i, l, n) for (int i = l; i < n; i++)

int solve() {
  string s;
  cin >> s;
  if (s == "ARC")
    cout << "ABC";
  else
    cout << "ARC";
  return 0;
}

int32_t main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int t = 1;
  // cin >>t;
  while (t--)
    solve();
}

Error: WA

Fixed submission:

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

#define E "\\n"
#define int long long
#define f(i, l, n) for (int i = l; i < n; i++)

int solve() {
  string s;
  cin >> s;
  if (s == "ARC")
    cout << "ABC";
  else
    cout << "ARC";
}

int32_t main() {

  int t = 1;
  // cin >>t;
  while (t--)
    solve();
}
Problem p02687 (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++)

int gcd(int p, int q) {
  if (p % q == 0) {
    return q;
  }
  return gcd(q, p % q);
}

int main() {
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}

Error: -8

Fixed submission:

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

int gcd(int p, int q) {
  if (p % q == 0) {
    return q;
  }
  return gcd(q, p % q);
}

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  bool f = false;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      f = true;
    }
  }

  if (f) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
}
Problem p02687 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define repo(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  string S;
  cin >> S;

  if (S == "ARC") {
    cout << "ABC" << endl;
  } else {
    cout << "ARC" << endl;
  }

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

#define repo(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;

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

#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end)                                                     \\
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \\
       i != (end) - ((begin) > (end));                                         \\
       i += 1 - 2 * ((begin) >                                                 \\
                     (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) -->
                             // {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main() {
  string s;
  cin >> s;
  cout << (s == "ABC" ? "ARC" : "ABC");
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end)                                                     \\
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \\
       i != (end) - ((begin) > (end));                                         \\
       i += 1 - 2 * ((begin) >                                                 \\
                     (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) -->
                             // {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> mp(n + 1, 0);
  rep(i, 1, n) {
    int a;
    cin >> a;
    mp[a]++;
  }
  rep(x, 1, n + 1) cout << mp[x] << endl;
  return 0;
}
Problem p02687 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  char a[10];
  cin >> a;
  if (a[0] == 'A' && a[1] == 'B' && a[2] == 'C')
    cout << "ARC" << endl;
  else if (a[0] == 'A' && a[1] == 'R' && a[2] == 'C')
    cout << "ABC" << endl;
  return 0;
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <iostream>
using namespace std;
int main() {
  char a[5];
  cin >> a[5];
  if (a[1] == 'B')
    cout << "ARC";
  else
    cout << "ABC";
  return 0;
}
Problem p02687 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s == "ABC")
    cout << "ARC" << endl;
  else if (s == "ARC")
    cout << "ABC" << endl;
}


Error: -8

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, k;
  cin >> k;
  cin >> a >> b;
  int max = b / k;
  bool flag = false;
  for (int i = 1; i <= max + 2; i++) {
    if (i * k <= b && i * k >= a)
      flag = true;
  }
  if (flag)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
  return 0;
}
Problem p02687 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
int main(int argc, char **argv) {
  std::string S;
  std::cin >> S;
  if (S == "ARC")
    std::cout << "ABC" << std::endl;
  else
    std::cout << "ARC" << std::endl;
  return 0;
}


Error: -6
terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string: construction from null is not valid


Fixed submission:

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
int main(int argc, char **argv) {
  std::string S = argv[1];
  if (S == "ARC")
    std::cout << "ABC" << std::endl;
  else
    std::cout << "ARC" << std::endl;
  return 0;
}
Problem p02687 (C++) — buggy submission, verdict: Runtime Error

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

#define ll long long

string replaceOtherStr(std::string &replacedStr, std::string from,
                       std::string to) {
  const unsigned int pos = replacedStr.find(from);
  const int len = from.length();

  if (pos == std::string::npos || from.empty()) {
    return replacedStr;
  }

  return replacedStr.replace(pos, len, to);
}

int main() {
  string S;
  cin >> S;

  if (S == "ABC")
    replaceOtherStr(S, "BC", "RC");
  else
    replaceOtherStr(S, "RC", "BC");

  cout << S << endl;
}

Error: 0

Fixed submission:

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

#define ll long long

string replaceOtherStr(std::string &replacedStr, std::string from,
                       std::string to) {
  const unsigned int pos = replacedStr.find(from);
  const int len = from.length();

  if (pos == std::string::npos || from.empty()) {
    return replacedStr;
  }

  return replacedStr.replace(pos, len, to);
}

int main() {
  string S;
  cin >> S;

  replaceOtherStr(S, "BC", "RC");

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

#include <iostream>
using namespace std;

int main() {
  string S;
  string ABC = "ABC", ARC = "ARC";
  cin >> S;
  if (S == ABC) {
    cout << " " << ARC << endl;
  }
  if (S == ARC) {
    cout << " " << ABC << endl;
  }
  // A();
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int A(void) {
  string S;
  string ABC = "ABC", ARC = "ARC";
  cin >> S;
  if (S == ABC) {
    cout << " " << ARC << endl;
  }
  if (S == ARC) {
    cout << " " << ABC << endl;
  }
}

int main() {
  A();
  return 0;
}
Problem p02687 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  char input[5];
  scanf("%s", input);
  if (input[1] == 'B') {
    printf("ARC\\n");
  } else if (input[1] == 'R') {
    printf("ABC\\n");
  }

  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>
int main() {
  char S;
  char ABC, ARC;
  scanf("%s", &ABC, &ARC);
  if (S = ABC) {
    printf("ARC");
  } else if (S = ARC) {
    printf("ABC");
  }
  return 0;
}
Problem p02687 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  char a[101];
  scanf("%s", a);
  getchar();
  if (a[1] == 'B') {
    a[1] += 16;
    printf("%s", a);
  } else {
    a[1] -= 16;
    printf("%s", a);
  }

  return 0;
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <stdio.h>
int main() {
  char input[5];
  scanf("%s", &input);
  if (input[5] = 'ABC') {
    printf("ARC\\n");
  } else {
    printf("ABC\\n");
  }

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

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

int main() {
  string S;
  cin >> S;
  if (S == "ARC") {
    cout << "ABC" << endl;
  } else {
    cout << "ARC" << endl;
  }
}

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


Fixed submission:

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N), Ma(M);
  for (int i = 1; i <= N; i++) {
    cin >> H.at(i);
    Ma.at(i) = 0;
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    Ma.at(a) = max(Ma.at(a), H.at(b));
    Ma.at(b) = max(Ma.at(b), H.at(a));
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (H.at(i) > Ma.at(i)) {
      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> sn(n, 1);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a, a--;
      sn[a] = 0;
    }
  }
  cout << accumulate(begin(sn), end(sn), 0) << 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;
  int sum = 0;
  cin >> N >> K;
  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.at(a)++;
    }
  }
  for (int i = 1; i <= N; i++) {
    if (A.at(i) == 0)
      sum++;
  }
  cout << sum << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  // 整数の入力
  int n, k;
  cin >> n >> k;
  // cout << n << " " << k << endl;

  // init
  int hasSweets[n];
  for (int i = 0; i < n; i++) {
    hasSweets[i] = 0;
  }

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

  int sum = 0;
  for (int i = 0; i < n; i++) {
    //        cout << hasSweets[i];
    if (hasSweets[i] == 0) {
      sum++;
    }
  }
  //    cout << endl;

  cout << sum << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  // 整数の入力
  int n, k;
  cin >> n >> k;
  // cout << n << " " << k << endl;

  int hasSweets[k];
  for (int i = 0; i < k; i++) {
    hasSweets[i] = 0;
  }

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

  int sum = 0;
  for (int i = 0; i < k; i++) {
    //        cout << hasSweets[i];
    if (hasSweets[i] == 0) {
      sum++;
    }
  }
  //    cout << endl;

  cout << sum << endl;

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

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

int main() {
  int n, k;
  int d[100];
  cin >> n >> k;

  vector<int> A(n, 0);
  int nu[100][100];

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

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

  for (int i = 0; i < k; i++) {
    for (int j = 0; j < d[i]; j++) {
      A.at(nu[i][j] - 1)++;
    }
  }

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

  cout << sum << 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;
  int d[100];
  cin >> n >> k;

  vector<int> A(n, 0);
  int nu[100][100];

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

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

  for (int i = 0; i < k; i++) {
    for (int j = 0; j < d[i]; j++) {
      A.at(nu[i][j])++;
    }
  }

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

  cout << sum << endl;

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

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n, k;
  cin >> n >> k;
  vi S(101, 0);
  rep(i, k) {
    int d;
    cin >> d;
    vi A(101);
    rep(j, d) {
      cin >> A[i];
      A[i]--;
      S[A[i]]++;
    }
  }
  int cnt = 0;
  rep(i, n) if (S[i] > 0) cnt++;
  cout << n - cnt << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n, k;
  cin >> n >> k;
  vi S(n, 0);
  rep(i, k) {
    int d;
    cin >> d;
    vi A(d);
    rep(j, d) {
      cin >> A[i];
      A[i]--;
      S[A[i]]++;
    }
  }
  int cnt = 0;
  rep(i, n) if (S[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() {
  long long int cnt, ans = 0, N, K;
  string S;
  vector<int> A(200);

  cin >> N >> K;
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int ac;
      cin >> ac;
      A.at(ac - 1) = 1;
    }
  }
  for (int i = 0; i < N; i++) {
    ans += A.at(i);
  }
  cout << N - ans << endl;
  ;
}


Error: WA

Fixed submission:

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

int main() {
  long long int cnt, ans = 0, N, K;
  string S;
  vector<bool> A(100);

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

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

int main() {
  int n, k, d, a, s = 0;
  vector<int> b(200);
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> a;
      b.at(a) = 1;
    }
  }
  for (int i = 0; i < 200; i++) {
    s += b.at(i);
  }
  cout << n - s << endl;
}

Error: WA

Fixed submission:

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

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

#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d(K);
  vector<int> A[200];

  for (int i = 0; i < K; i++) {
    // cout<<K<<" "<<i<<endl;
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      A[i].resize(d[i]);
      cin >> A[i][j];
    }
  }
  // cout<<"fuga";
  int count = 0;
  bool flag = false;
  for (int i = 1; i <= N; i++) {
    flag = false;
    for (int j = 0; j < K; j++) {
      for (int k = 0; k < d[j]; k++) {
        if (i == A[j][k])
          flag = true;
      }
    }
    if (!flag)
      count++;
  }
  cout << count << endl;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d(K);
  vector<vector<int>> A(N);

  for (int i = 0; i < K; i++) {
    // cout<<K<<" "<<i<<endl;
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      A[i].resize(d[i]);
      cin >> A[i][j];
    }
  }
  // cout<<"fuga";
  int count = 0;
  bool flag = false;
  for (int i = 1; i <= N; i++) {
    flag = false;
    for (int j = 0; j < A.size(); j++) {
      for (int k = 0; k < A.at(j).size(); k++) {
        if (i == A[j][k])
          flag = true;
      }
    }
    if (!flag)
      count++;
  }
  cout << count << 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> sunu(n, 0);
  int d;
  int a;
  for (int i = 0; i < k; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> a;
      sunu.at(a - 1) = 1;
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (sunu.at(i) == 0) {
      sum++;
    }
  }
  cout << sum;
}


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> sunu(n, 0);
  int d;
  int a;
  for (int i = 0; i < k; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> a;
      sunu.at(a) = 1;
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (sunu.at(i) == 0) {
      sum++;
    }
  }
  cout << sum;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  int N, K;
  cin >> N >> K;
  map<int, int> S;
  int d[N];

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

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

    if (S[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

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

int main() {

  int N, K;
  cin >> N >> K;
  map<int, int> S;
  int d[N];
  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];
      S[j]++;
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (S[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, d, a[10000], i, f[100000] = {0}, k1 = 0, p[100000] = {0};
  map<int, int> m;
  cin >> n >> k;
  int j = 0;
  while (k--) {
    cin >> d;
    for (i = 0; i < d; i++) {
      cin >> a[i];
      p[j] = a[i];
      j++;
    }
  }
  for (i = 0; i < j; i++) {
    // cout<<p[i]<<endl;
    f[p[i]]++;
  }
  for (i = 0; i < j; i++) {
    if (f[p[i]] != 0) {
      //  cout<<p[i]<<" "<<f[p[i]]<<endl;
      k1++;
      f[p[i]] = 0;
    }
  }
  cout << n - k1 << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, k, d, a[1000], i, f[1000] = {0}, k1 = 0, p[1000] = {0};
  map<int, int> m;
  cin >> n >> k;
  int j = 0;
  while (k--) {
    cin >> d;
    for (i = 0; i < d; i++) {
      cin >> a[i];
      p[j] = a[i];
      j++;
    }
  }
  for (i = 0; i < j; i++) {
    // cout<<p[i]<<endl;
    f[p[i]]++;
  }
  for (i = 0; i < j; i++) {
    if (f[p[i]] != 0) {
      //  cout<<p[i]<<" "<<f[p[i]]<<endl;
      k1++;
      f[p[i]] = 0;
    }
  }
  cout << n - k1 << endl;
}