prithivMLmods/Coder-Stat huggingface dataset:
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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;
}
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
const ll INF = 1LL << 60;

int main() {
  ll n, m, k;
  cin >> n >> m;
  vector<ll> tab(m, 0);
  ll ans = 0;
  rep(i, n) {
    cin >> k;
    vector<ll> a(k);
    rep(j, k) {
      cin >> a[j];
      ++tab[a[j]];
    }
  }

  for (auto itr = tab.begin(); itr != tab.end(); ++itr) {
    if (*itr == n) {
      ++ans;
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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;
}
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
const ll INF = 1LL << 60;

int main() {
  ll n, m, k;
  cin >> n >> m;
  vector<ll> tab(m, 0);
  ll ans = 0;
  rep(i, n) {
    cin >> k;
    vector<ll> a(k);
    rep(j, k) {
      cin >> a[j];
      ++tab[a[j] - 1];
    }
  }

  for (auto itr = tab.begin(); itr != tab.end(); ++itr) {
    if (*itr == n) {
      ++ans;
    }
  }
  cout << ans << endl;
}
Problem p03126 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> suki(m, 0);
  string line;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int id;
      cin >> id;
      suki[id - 1]++;
    }
  }
  int likecount = 0;
  for (int l : suki) {
    if (l == n)
      likecount++;
  }
  cout << likecount << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> suki(m, 0);
  string line;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int id;
      cin >> id;
      suki[id - 1]++;
    }
  }
  int likecount = 0;
  for (int i = 0; i < suki.size(); i++) {
    if (suki[i] == n)
      likecount++;
  }
  cout << likecount << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m, i, r = 0;
  cin >> n >> m;
  set<int> s[i];
  for (i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      s[i].insert(a);
    }
  }
  for (int j = 1; j <= m; j++) {
    bool b = 1;
    for (i = 0; i < n; i++) {
      if (s[i].count(j)) {
      } else {
        b = 0;
        break;
      }
    }
    if (b)
      r++;
  }
  cout << r << endl;
  return 0;
}


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

int main() {
  int n, m, i, r = 0;
  cin >> n >> m;
  set<int> s[n];
  for (i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      s[i].insert(a);
    }
  }
  for (int j = 1; j <= m; j++) {
    bool b = 1;
    for (i = 0; i < n; i++) {
      if (s[i].count(j)) {
      } else {
        b = 0;
        break;
      }
    }
    if (b)
      r++;
  }
  cout << r << endl;
  return 0;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

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

  vector<int> like(M);
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < K[i]; ++j) {
      like[A[i][j] - 1]++;
    }
  }

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

  cout << ans << endl;
  return 0;
}


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

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

  vector<int> like(M);
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < K[i]; ++j) {
      like[A[i][j] - 1]++;
    }
  }

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

  cout << ans << endl;
  return 0;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
// おまじない
#include <bits/stdc++.h>
using namespace std;

int main() {

  int n, m;
  cin >> n >> m;

  vector<long int> v(m);

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

    int f = 0;
    cin >> f;

    for (int j = 0; j < f; j++) {
      int a = 0;
      cin >> a;
      v.at(a) += 1;
    }
  }
  int s = 0;
  for (int i = 0; i < m; i++) {
    if (v.at(i) == n) {
      s++;
    }
  }

  cout << s << endl;
}


Fixed submission:
// おまじない
#include <bits/stdc++.h>
using namespace std;

int main() {

  int n, m;
  cin >> n >> m;

  vector<long int> v(m);

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

    int f = 0;
    cin >> f;

    for (int j = 0; j < f; j++) {
      int a = 0;
      cin >> a;
      v.at(a - 1) += 1;
    }
  }
  int s = 0;
  for (int i = 0; i < m; i++) {
    if (v.at(i) == n) {
      s++;
    }
  }

  cout << s << endl;
}
Problem p03126 (C++)

Buggy submission (status: 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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> food(n, 0);
  REP(i, n) {
    int k;
    cin >> k;
    REP(j, k) {
      int food_num;
      cin >> food_num;
      food[food_num - 1]++;
    }
  }
  int ans = 0;
  REP(i, m) {
    if (food[i] == n)
      ans++;
  }
  cout << ans << endl;
}

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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> food(m, 0);
  REP(i, n) {
    int k;
    cin >> k;
    REP(j, k) {
      int food_num;
      cin >> food_num;
      food[food_num - 1]++;
    }
  }
  int ans = 0;
  REP(i, m) {
    if (food[i] == n)
      ans++;
  }
  cout << ans << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
  int N, M;
  scanf("%d %d", &N, &M);
  int menu[30] = {0};
  for (int i = 0; i < N; i++) {
    int K;
    scanf("%d", &K);
    for (int i = 0; i < K; i++) {
      int A;
      scanf("%d", &A);
      menu[A]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (menu[i] == N)
      ans++;
  }
  printf("%d\n", ans);

  return 0;
}


Fixed submission:
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
  int N, M;
  scanf("%d %d", &N, &M);
  int menu[30] = {0};
  for (int i = 0; i < N; i++) {
    int K;
    scanf("%d", &K);
    for (int i = 0; i < K; i++) {
      int A;
      scanf("%d", &A);
      menu[A - 1]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (menu[i] == N)
      ans++;
  }
  printf("%d\n", ans);

  return 0;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)

typedef long long ll;

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> like(N, 0);

  rep(i, N) {
    int K;
    cin >> K;
    rep(j, K) {
      int id;
      cin >> id;
      like[id - 1]++;
    }
  }
  int ans = 0;
  rep(i, M) {
    // cout << i << ":" << like[i] << endl;
    if (like[i] == N)
      ans++;
  }

  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)

typedef long long ll;

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> like(M, 0);

  rep(i, N) {
    int K;
    cin >> K;
    rep(j, K) {
      int id;
      cin >> id;
      like[id - 1]++;
    }
  }
  int ans = 0;
  rep(i, M) {
    // cout << i << ":" << like[i] << endl;
    if (like[i] == N)
      ans++;
  }

  cout << ans << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
// Foods Loved by Everyone

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, x, y) for (int i = x; i < y; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a / __gcd(a, b) * b)
#define range(a) (a).begin(), (a).end()
#define pb push_back
const int inf = 2147483647;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n);
  rep(i, 0, n) {
    int k;
    cin >> k;
    a[i].resize(k);
    rep(j, 0, k) {
      int c;
      cin >> c;
      a[i].pb(c);
    }
  }
  vector<int> t(m);
  rep(i, 0, n) {
    rep(j, 0, a[i].size()) { t[a[i][j] - 1]++; }
  }
  int ans = 0;
  rep(i, 0, m) if (t[i] == n) ans++;
  cout << ans << endl;
  return 0;
}

Fixed submission:
// Foods Loved by Everyone

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, x, y) for (int i = x; i < y; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a / __gcd(a, b) * b)
#define range(a) (a).begin(), (a).end()
#define pb push_back
const int inf = 2147483647;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n);
  rep(i, 0, n) {
    int k;
    cin >> k;
    rep(j, 0, k) {
      int c;
      cin >> c;
      a[i].pb(c);
    }
  }
  vector<int> t(m);
  rep(i, 0, n) {
    rep(j, 0, a[i].size()) { t[a[i][j] - 1]++; }
  }
  int ans = 0;
  rep(i, 0, m) if (t[i] == n) ans++;
  cout << ans << endl;
  return 0;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

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

  vector<int> food(M);

  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      food.at(A)++;
    }
  }

  int count = 0;
  for (int i = 0; i < M; i++) {
    if (food.at(i) == N) {
      count++;
    }
  }

  cout << count << endl;
}


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

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

  vector<int> food(M);

  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      food.at(A - 1)++;
    }
  }

  int count = 0;
  for (int i = 0; i < M; i++) {
    if (food.at(i) == N) {
      count++;
    }
  }

  cout << count << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 10e9 + 7;
typedef long long ll;
const double rate = 380000.0;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> CH(M, 0);
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      CH.at(A)++;
    }
  }
  int cnt = 0;
  for (int i = 0; i < M; i++) {
    if (CH.at(i) == N)
      cnt++;
  }
  cout << cnt << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 10e9 + 7;
typedef long long ll;
const double rate = 380000.0;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> CH(M, 0);
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      CH.at(A - 1)++;
    }
  }
  int cnt = 0;
  for (int i = 0; i < M; i++) {
    if (CH.at(i) == N)
      cnt++;
  }
  cout << cnt << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  rep(i, 0, n) {
    int k;
    cin >> k;
    vector<int> a(k);
    rep(j, 0, k) {
      cin >> a[i];
      mp[a[i]]++;
    }
  }
  int ans = 0;
  for (auto i : mp) {
    if (i.second == n)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  rep(i, 0, n) {
    int k;
    cin >> k;
    vector<int> a(k);
    rep(j, 0, k) {
      cin >> a[j];
      mp[a[j]]++;
    }
  }
  int ans = 0;
  for (auto i : mp) {
    if (i.second == n)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main() {
  ll n, m;
  ll ans = 0;
  cin >> n >> m;
  vector<ll> a(m, 0);
  ll k, kk;
  for (ll i = 0; i < n; i++) {
    cin >> k;
    for (ll j = 0; j < k; j++) {
      cin >> kk;
      a[kk]++;
    }
  }
  for (ll i = 0; i < m; i++) {
    if (a[i] == n)
      ans++;
  }
  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main() {
  ll n, m;
  ll ans = 0;
  cin >> n >> m;
  vector<ll> a(m, 0);
  ll k, kk;
  for (ll i = 0; i < n; i++) {
    cin >> k;
    for (ll j = 0; j < k; j++) {
      cin >> kk;
      a[kk - 1]++;
    }
  }
  for (ll i = 0; i < m; i++) {
    if (a[i] == n)
      ans++;
  }
  cout << ans << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(n);
  vector<vector<int>> a(m, vector<int>(m));
  vector<vector<int>> result(n);
  for (int i = 0; i < n; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> a[i][j];
      if (i == 0) {
        result[i].push_back(a[i][j]);
      } else {
        auto res = find(result[i - 1].begin(), result[i - 1].end(), a[i][j]);
        if (!(res == result[i - 1].end())) {
          result[i].push_back(a[i][j]);
        }
      }
    }
  }
  cout << result[n - 1].size() << endl;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(n);
  vector<vector<int>> a(n, vector<int>(m));
  vector<vector<int>> result(n);
  for (int i = 0; i < n; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> a[i][j];
      if (i == 0) {
        result[i].push_back(a[i][j]);
      } else {
        auto res = find(result[i - 1].begin(), result[i - 1].end(), a[i][j]);
        if (!(res == result[i - 1].end())) {
          result[i].push_back(a[i][j]);
        }
      }
    }
  }
  cout << result[n - 1].size() << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using p = pair<int, int>;
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)

signed main() {
  int N, M;
  cin >> N >> M;
  int A[N];
  rep(i, N) A[i] = 0;
  int a, k;
  rep(i, N) {
    cin >> k;
    rep(i, k) {
      cin >> a;
      A[a - 1]++;
    }
  }
  int ans = 0;
  rep(i, M) {
    if (A[i] == N)
      ans++;
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using p = pair<int, int>;
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)

signed main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M, 0);
  int a, k;
  rep(i, N) {
    cin >> k;
    rep(i, k) {
      cin >> a;
      A[a - 1]++;
    }
  }
  int ans = 0;
  rep(i, M) {
    if (A[i] == N)
      ans++;
  }
  cout << ans << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ((n) ? "Yes" : "No") << '\n';
#define CFYN(n) cout << ((n) ? "YES" : "NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main(void) {
  IOS int N, M;
  cin >> N >> M;
  vector<int> A;
  REP(i, N) {
    int K;
    cin >> K;
    REP(j, K) {
      int a;
      cin >> a;
      a--;
      A[a]++;
    }
  }
  int ans = 0;
  REP(i, M) if (A[i] == N) ans++;
  cout << ans << '\n';

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ((n) ? "Yes" : "No") << '\n';
#define CFYN(n) cout << ((n) ? "YES" : "NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main(void) {
  IOS int N, M;
  cin >> N >> M;
  vector<int> A(M);
  REP(i, N) {
    int K;
    cin >> K;
    REP(j, K) {
      int a;
      cin >> a;
      a--;
      A[a]++;
    }
  }
  int ans = 0;
  REP(i, M) if (A[i] == N) ans++;
  cout << ans << '\n';

  return 0;
}
Problem p03126 (C++)

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

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

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> food(m);
  rep(i, n) {
    int k;
    cin >> k;
    rep(j, k) {
      int a;
      cin >> a;
      food[a - 1]++;
    }
  }
  int ans = 0;
  rep(i, m) {
    if (food[i] == n)
      ans++;
  }
  cout << ans << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, ans = 0;
  cin >> N >> M;
  vector<int> B(M);

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


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

int main() {
  int N, M, ans = 0;
  cin >> N >> M;
  vector<int> B(M);

  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      B.at(A - 1)++;
    }
  }
  for (int i = 0; i < M; i++) {
    if (B.at(i) == N) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

#define INF 1000007
#define MOD 998244353
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int N, int P, int M) // 繰り返し自乗法
{
  if (P == 0)
    return 1;
  if (P % 2 == 0) {
    int t = mpow(N, P / 2, M);
    return t * t % M;
  }
  return N * mpow(N, P - 1, M) % M;
}
signed main() {
  int N, M;
  cin >> N >> M;
  int A[M][M];
  int K[N];
  rep(i, N) {
    cin >> K[i];
    rep(j, K[i]) { cin >> A[i][j]; }
  }
  int ans = 0;
  rep(k, M + 1) {
    int count = 0;
    rep(i, N) {
      rep(j, K[i]) {
        if (k == A[i][j]) {
          count++;
        }
      }
    }
    if (count == N) {
      ans++;
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define INF 1000007
#define MOD 998244353
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int N, int P, int M) // 繰り返し自乗法
{
  if (P == 0)
    return 1;
  if (P % 2 == 0) {
    int t = mpow(N, P / 2, M);
    return t * t % M;
  }
  return N * mpow(N, P - 1, M) % M;
}
signed main() {
  int N, M;
  cin >> N >> M;
  int A[N][M];
  int K[N];
  rep(i, N) {
    cin >> K[i];
    rep(j, K[i]) { cin >> A[i][j]; }
  }
  int ans = 0;
  rep(k, M + 1) {
    int count = 0;
    rep(i, N) {
      rep(j, K[i]) {
        if (k == A[i][j]) {
          count++;
        }
      }
    }
    if (count == N) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p03126 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define mk(a, b) make_pair(a, b)
#define pii pair<int, int>
using namespace std;
inline int read() {
  int X = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    X = (X << 3) + (X << 1) + c - '0', c = getchar();
  return X * w;
}
typedef long long ll;
const int N = 1e5 + 5;
int num[55];
int main() {
  int n, m, k, x;
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) {
    k = read();
    for (int j = 1; j <= k; k++) {
      x = read();
      num[x]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    if (num[i] == n)
      ans++;
  }
  cout << ans;
}

Fixed submission:
#include <bits/stdc++.h>
#define mk(a, b) make_pair(a, b)
#define pii pair<int, int>
using namespace std;
inline int read() {
  int X = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    X = (X << 3) + (X << 1) + c - '0', c = getchar();
  return X * w;
}
typedef long long ll;
const int N = 1e5 + 5;
int num[55];
int main() {
  int n, m, k, x;
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) {
    k = read();
    for (int j = 1; j <= k; j++) {
      x = read();
      num[x]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    if (num[i] == n)
      ans++;
  }
  cout << ans;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int N, M;
  cin >> N;
  cin >> M;
  int K[N];
  int A[M][M];
  int min = 30;
  int num = 0;
  for (int j = 0; j < N; j++) {
    cin >> K[j];
    if (min > K[j]) {
      min = K[j];
      num = j;
    }
    for (int i = 0; i < K[j]; i++) {
      cin >> A[j][i];
    }
  }
  int count = 0;
  int sum = 0;
  for (int k = 0; k < min; k++) {
    count = 0;
    for (int j = 0; j < N; j++) {
      for (int i = 0; i < K[j]; i++) {
        if (A[num][k] == A[j][i])
          count = count + 1;
      }
    }
    if (count == N)
      sum = sum + 1;
  }

  cout << sum << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int N, M;
  cin >> N;
  cin >> M;
  int K[N];
  int A[N][M];
  int min = 30;
  int num = 0;
  for (int j = 0; j < N; j++) {
    cin >> K[j];
    if (min > K[j]) {
      min = K[j];
      num = j;
    }
    for (int i = 0; i < K[j]; i++) {
      cin >> A[j][i];
    }
  }
  int count = 0;
  int sum = 0;
  for (int k = 0; k < min; k++) {
    count = 0;
    for (int j = 0; j < N; j++) {
      for (int i = 0; i < K[j]; i++) {
        if (A[num][k] == A[j][i])
          count = count + 1;
      }
    }
    if (count == N)
      sum = sum + 1;
  }

  cout << sum << endl;
  return 0;
}
Problem p03126 (Python)

Buggy submission (status: Runtime Error):
N, M = map(int, input().split())

inputs = [[i for i in input().split()] for _ in range(N)]

ans = set(inputs[0])
for item in inputs:
    ans &= set(inputs[1:])

print(len(ans))


Fixed submission:
N, M = map(int, input().split())

inputs = [[i for i in input().split()] for _ in range(N)]

ans = set(inputs[0])
for item in inputs:
    ans &= set(item[1:])

print(len(ans))
Problem p03126 (Python)

Buggy submission (status: Runtime Error):
N, M = map(int, input().split())
favorites = {*tuple(range(1, M + 1))}
for _ in range(N):
    K, *fav = map(int, input().split())
    favorites = favorites & set(fav)
print(len(favorites))


Fixed submission:
N, M = map(int, input().split())
favorites = set(i for i in range(1, M + 1))
for _ in range(N):
    K, *fav = map(int, input().split())
    favorites = favorites & set(fav)
print(len(favorites))
Problem p03126 (Python)

Buggy submission (status: Runtime Error):
N, M = map(int, input().split())
loved_by_everyone = [0] * M
for _ in range(N):
    like_list = list(map(int, input().split()))
    for like in like_list[1:]:
        loved_by_everyone[like] += 1

kinds = 0
for food in loved_by_everyone:
    kinds += 1 if food == N else 0
print(kinds)


Fixed submission:
N, M = map(int, input().split())
loved_by_everyone = [0] * M
for _ in range(N):
    like_list = list(map(int, input().split()))
    for like in like_list[1:]:
        loved_by_everyone[like - 1] += 1

kinds = 0
for food in loved_by_everyone:
    kinds += 1 if food == N else 0
print(kinds)
Problem p03126 (Python)

Buggy submission (status: Runtime Error):
n, m = map(int, input().split())
res = [0] * m

for i in range(n):
    o = list(map(int, input().split()))
    for j, x in enumerate(o):
        if j != 0:
            res[x] += 1

ans = sum(1 for x in res if x == n)

print(ans)


Fixed submission:
n, m = map(int, input().split())
res = [0] * m

for i in range(n):
    o = list(map(int, input().split()))
    for j, x in enumerate(o):
        if j != 0:
            res[x - 1] += 1

ans = sum(1 for x in res if x == n)

print(ans)
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n + 1); i++)

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  vector<int> K(N);
  rep(i, N) {
    cin >> K[i];
    vector<int> C(K[i]);
    rep(j, K[i]) {
      cin >> C[i];
      A[C[i] - 1]++;
    }
  }
  int cnt = 0;
  rep(i, M) {
    if (A[i] == N) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n + 1); i++)

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  vector<int> K(N);
  rep(i, N) {
    cin >> K[i];
    vector<int> C(K[i]);
    rep(j, K[i]) {
      cin >> C[j];
      A[C[j] - 1]++;
    }
  }
  int cnt = 0;
  rep(i, M) {
    if (A[i] == N) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {

  int N, M;
  cin >> N >> M;

  vector<int> A(M);

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

    int K;
    cin >> K;

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

      int As;
      cin >> As;

      A.at(As - 1)++;
    }
  }

  int ans = 0;

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

    if (A.at(i) == N) {

      ans++;
    }
  }

  cout << ans << endl;
}


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

int main() {

  int N, M;
  cin >> N >> M;

  vector<int> A(M);

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

    int K;
    cin >> K;

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

      int As;
      cin >> As;

      A.at(As - 1)++;
    }
  }

  int ans = 0;

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

    if (A.at(i) == N) {

      ans++;
    }
  }

  cout << ans << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, K, a, count = 0;
  cin >> N >> M;
  vector<int> menu(M);
  for (int i = 0; i < N; i++) {
    cin >> K;
    for (int j = 0; j < K; j++) {
      cin >> a;
      menu.at(a - 1)++;
    }
  }

  for (int i = 0; i < N; i++)
    if (menu.at(i) == N)
      count++;
  cout << count << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, K, a, count = 0;
  cin >> N >> M;
  vector<int> menu(M);
  for (int i = 0; i < N; i++) {
    cin >> K;
    for (int j = 0; j < K; j++) {
      cin >> a;
      menu.at(a - 1)++;
    }
  }

  for (int i = 0; i < M; i++)
    if (menu.at(i) == N)
      count++;
  cout << count << endl;
}
Problem p03126 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

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

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

int main() {
  int n, m, k, a, c = 0;
  cin >> n >> m;
  vector<int> v(m, 0);
  for (int i = 0; i < n; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> a;
      v[a - 1]++;
    }
  }
  for (int i = 0; i < m; i++)
    if (v[i] == n)
      c++;
  cout << c << endl;
  return 0;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vin = vector<int>;
using vll = vector<long long>;
using vdo = vector<double>;
using vvin = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vvdo = vector<vector<double>>;
using vstr = vector<string>;
using vvstr = vector<vector<string>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
int main() {
  int n, m;
  cin >> n >> m;
  vin k(n);
  vvin a(n, vin(m));
  rep(i, n) {
    cin >> k[i];
    rep(j, k[i]) cin >> a[i][j];
  }
  vin b(m, 0);
  for (int i = 1; i <= m; i++) {
    rep(j, n) {
      rep(l, k[j]) {
        if (a[j][l] == i)
          b[i]++;
      }
    }
  }
  int sum = 0;
  rep(i, m) {
    if (b[i] == n)
      sum++;
  }
  cout << sum << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vin = vector<int>;
using vll = vector<long long>;
using vdo = vector<double>;
using vvin = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vvdo = vector<vector<double>>;
using vstr = vector<string>;
using vvstr = vector<vector<string>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
int main() {
  int n, m;
  cin >> n >> m;
  vin k(n);
  vvin a(n, vin(m));
  rep(i, n) {
    cin >> k[i];
    rep(j, k[i]) cin >> a[i][j];
  }
  vin b(m, 0);
  for (int i = 1; i <= m; i++) {
    rep(j, n) {
      rep(l, k[j]) {
        if (a[j][l] == i)
          b[i - 1]++;
      }
    }
  }
  int sum = 0;
  rep(i, m) {
    if (b[i] == n)
      sum++;
  }
  cout << sum << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;

int main() {

  int N, M;
  cin >> N >> M;
  vector<vector<int>> A(N, vector<int>(M, 0));
  vector<int> K(M);
  for (int i = 0; i < N; i++) {
    cin >> K.at(i);
    for (int j = 0; j < K.at(i); j++) {
      int temp;
      cin >> temp;
      A.at(i).at(temp - 1) = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int count = 0;
    for (int j = 0; j < N; j++) {
      count += A.at(j).at(i);
    }
    if (count == N)
      ans++;
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;

int main() {

  int N, M;
  cin >> N >> M;
  vector<vector<int>> A(N, vector<int>(M, 0));
  vector<int> K(M);
  for (int i = 0; i < N; i++) {
    int ind;
    cin >> ind;
    for (int j = 0; j < ind; j++) {
      int temp;
      cin >> temp;
      A.at(i).at(temp - 1) = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int count = 0;
    for (int j = 0; j < N; j++) {
      count += A.at(j).at(i);
    }
    if (count == N)
      ans++;
  }
  cout << ans << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):

#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;

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

  int ans = 0;

  for (int i = 0; i < m; i++) {
    if (kk[i] == n) {
      ++ans;
    }
  }
  cout << ans << endl;

  return 0;
}


Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;

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

  int ans = 0;

  for (int i = 0; i < m; i++) {
    if (kk[i] == n) {
      ++ans;
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

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

  int typeArray[m];
  int like[n][m];
  for (int i = 0; i < n; i++) {
    int typeCount;
    cin >> typeCount;
    typeArray[i] = typeCount;
    for (int j = 0; j < typeCount; j++) {
      cin >> like[i][j];
    }
  }

  if (n == 1) {
    cout << typeArray[0] << endl;
    return 0;
  }

  int count = 0;
  for (int i = 0; i < typeArray[0]; i++) {
    int matchNum = like[0][i];
    for (int j = 1; j < n; j++) {
      bool isMatch = false;
      for (int k = 0; k < typeArray[j]; k++) {
        if (matchNum == like[j][k]) {
          isMatch = true;
          break;
        }
      }
      if (!isMatch) {
        break;
      }

      if (j == n - 1) {
        count++;
      }
    }
  }

  cout << count << endl;
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

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

  int typeArray[n];
  int like[n][m];
  for (int i = 0; i < n; i++) {
    int typeCount;
    cin >> typeCount;
    typeArray[i] = typeCount;
    for (int j = 0; j < typeCount; j++) {
      cin >> like[i][j];
    }
  }

  if (n == 1) {
    cout << typeArray[0] << endl;
    return 0;
  }

  int count = 0;
  for (int i = 0; i < typeArray[0]; i++) {
    int matchNum = like[0][i];
    for (int j = 1; j < n; j++) {
      bool isMatch = false;
      for (int k = 0; k < typeArray[j]; k++) {
        if (matchNum == like[j][k]) {
          isMatch = true;
          break;
        }
      }
      if (!isMatch) {
        break;
      }

      if (j == n - 1) {
        count++;
      }
    }
  }

  cout << count << endl;
  return 0;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> K(N);
  vector<vector<int>> A(N, vector<int>(N));
  for (int i = 0; i < N; i++) {
    cin >> K[i];
    int j = 0;
    while (j < K[i]) {
      cin >> A[i][j];
      j++;
    }
  }
  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < K[i]; j++) {
      if (mp.count(A[i][j]))
        mp[A[i][j]]++;
      else
        mp[A[i][j]] = 1;
    }
  }

  int Count = 0;

  for (auto p : mp) {
    if (N == p.second)
      Count++;
  }

  cout << Count << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> K(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    cin >> K[i];
    int j = 0;
    while (j < K[i]) {
      cin >> A[i][j];
      j++;
    }
  }
  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < K[i]; j++) {
      if (mp.count(A[i][j]))
        mp[A[i][j]]++;
      else
        mp[A[i][j]] = 1;
    }
  }

  int Count = 0;

  for (auto p : mp) {
    if (N == p.second)
      Count++;
  }

  cout << Count << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> K(N, 0);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      int A;
      cin >> A;
      A--;
      K[A]++;
    }
  }
  int count = 0;
  for (int i = 0; i < M; i++) {
    if (K[i] == N) {
      count++;
    }
  }
  cout << count << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> K(M, 0);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      int A;
      cin >> A;
      A--;
      K[A]++;
    }
  }
  int count = 0;
  for (int i = 0; i < M; i++) {
    if (K[i] == N) {
      count++;
    }
  }
  cout << count << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N, M;
  int ans = 0;
  cin >> N >> M;
  vector<int> like_foods(M, 0);

  rep(i, N) {
    int k;
    cin >> k;
    vector<int> A(k);
    rep(j, k) cin >> A[j];
    for (int a : A) {
      like_foods[a] += 1;
    }
  }
  for (int food : like_foods) {
    if (food == N) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
  int N, M;
  int ans = 0;
  cin >> N >> M;
  vector<int> like_foods(M, 0);

  rep(i, N) {
    int k;
    cin >> k;
    vector<int> A(k);
    rep(j, k) cin >> A[j];
    for (int a : A) {
      like_foods[a - 1] += 1;
    }
  }
  for (int food : like_foods) {
    if (food == N) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  int K[N], A[N][M];
  int ansv = 0;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      cin >> A[i][j];
    }
  }

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

    for (int j = 0; j < N; j++) {
      for (int k = 0; k < K[i]; k++) {
        if (A[0][i] == A[j][k]) {
          ansv++;
        }
      }
    }
    if (ansv == N) {
      ans++;
    }
  }

  cout << ans << endl;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  int K[N], A[N][M];
  int ansv = 0;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      cin >> A[i][j];
    }
  }

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

    for (int j = 0; j < N; j++) {
      for (int k = 0; k < K[j]; k++) {
        if (A[0][i] == A[j][k]) {
          ansv++;
        }
      }
    }
    if (ansv == N) {
      ans++;
    }
  }

  cout << ans << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> cnt(N);
  rep(i, N) {
    int K;
    cin >> K;
    rep(j, K) {
      int A;
      cin >> A;
      A--;
      cnt[A]++;
    }
  }

  int ans = 0;
  rep(i, M) {
    if (cnt[i] == N) {
      ans++;
    }
  }

  cout << ans;

  cout << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> cnt(M);
  rep(i, N) {
    int K;
    cin >> K;
    rep(j, K) {
      int A;
      cin >> A;
      A--;
      cnt[A]++;
    }
  }

  int ans = 0;
  rep(i, M) {
    if (cnt[i] == N) {
      ans++;
    }
  }

  cout << ans;

  cout << endl;
  return 0;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n - 1);
  return ans * n;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
bool is_prime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0)
    return 1;
  ll res = mod_pow(x * x % mod, n / 2, mod);
  if (n & 1)
    res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> v(m, 0);
  rep(i, n) {
    ll k;
    cin >> k;
    rep(j, k) {
      ll tmp;
      v.at(tmp - 1)++;
    }
  }
  ll res = 0;
  rep(i, m) {
    if (v.at(i) == n)
      res++;
  }
  cout << res << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n - 1);
  return ans * n;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
bool is_prime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0)
    return 1;
  ll res = mod_pow(x * x % mod, n / 2, mod);
  if (n & 1)
    res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> v(m, 0);
  rep(i, n) {
    ll k;
    cin >> k;
    rep(j, k) {
      ll tmp;
      cin >> tmp;
      v.at(tmp - 1)++;
    }
  }
  ll res = 0;
  rep(i, m) {
    if (v.at(i) == n)
      res++;
  }
  cout << res << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> v(M);

  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    vector<int> foods(K);
    for (int j = 0; j < K; j++)
      cin >> foods[j];
    for (int f : foods)
      v[f]++;
  }

  int count = 0;
  for (int ff : v)
    if (ff == N)
      count++;

  cout << count << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> v(M);

  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    vector<int> foods(K);
    for (int j = 0; j < K; j++)
      cin >> foods[j];
    for (int f : foods)
      v[f - 1]++;
  }

  int count = 0;
  for (int ff : v)
    if (ff == N)
      count++;

  cout << count << endl;

  return 0;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> f(m);
  int a, b, c;

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

  for (int i = 0; i < n; i++) {
    cin >> a;
    for (int j = 0; j < a; j++) {
      cin >> b;
      f.at(b - 1) += 1;
    }
  }
  for (int i = 0; i < m; i++) {
    if (f.at(i) == n) {
      c += 1;
    }
  }
  cout << c << endl;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> f(m);
  int a, b, c;

  for (int i = 0; i < m; i++) {
    f.at(i) = 0;
  }

  for (int i = 0; i < n; i++) {
    cin >> a;
    for (int j = 0; j < a; j++) {
      cin >> b;
      f.at(b - 1) += 1;
    }
  }
  for (int i = 0; i < m; i++) {
    if (f.at(i) == n) {
      c += 1;
    }
  }
  cout << c << endl;
}
Problem p03126 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  auto k = vector<int>(n, 0);
  auto a = vector<vector<int>>(n, vector<int>(n, 0));

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

  auto v = vector<int>(m + 1, 0);

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

  cout << count_if(v.begin(), v.end(), [&n](int i) { return n == i; });
}

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

int main() {
  int n, m;
  cin >> n >> m;
  auto k = vector<int>(n, 0);
  auto a = vector<vector<int>>(n, vector<int>(m, 0));

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

  auto v = vector<int>(m + 1, 0);

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

  cout << count_if(v.begin(), v.end(), [&n](int i) { return n == i; });
}