Problem p03031 (C++)

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

#define int long long
#define uint unsigned int
#define ld long double
#define showoff                                                                \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define pb push_back
#define pii pair<int, int>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define f first
#define se second
#define maxn 200005
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int, vector<int>, greater<int>>

using namespace std;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int power(int a, int n) {
  if (n == 1)
    return a;
  if (n == 0)
    return 1;
  if (n % 2)
    return a * power(a * a, n / 2);
  return power(a * a, n / 2);
}
const int md = 998244353;
const int inf = (int)1e18;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/

signed main() {
  showoff;
  /*int n,ans[maxn];
  cin >> n;
  vector<pair<pair<string,int>,int> >v;
  FOR(i,1,n+1){
      int sc;
      string s;
      cin >> s >> sc;
      v.pb({{s,-sc},i});
  }
  sort(v.begin(),v.end());
  FOR(i,0,n)ans[v[i].se] = i+1;
  FOR(i,1,n+1)cout << ans[i] << "\n";*/
  int n, m, p[100];
  cin >> n >> m;
  vector<int> adj[m + 5];
  FOR(i, 1, m + 1) {
    int k;
    cin >> k;
    FOR(i, 1, k + 1) {
      int x;
      cin >> x;
      adj[i].pb(x - 1);
    }
  }
  int ans = 0;
  FOR(i, 1, m + 1) cin >> p[i];
  FOR(i, 0, (1 << n)) {
    bool fo = 1;
    FOR(j, 1, m + 1) {
      int c = 0;
      for (auto &x : adj[j]) {
        if (i & (1 << x))
          ++c;
      }
      if (c % 2 != p[j] % 2)
        fo = 0;
    }
    if (fo)
      ++ans;
  }
  cout << ans;
  return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...

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

#define int long long
#define uint unsigned int
#define ld long double
#define showoff                                                                \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define pb push_back
#define pii pair<int, int>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define f first
#define se second
#define maxn 200005
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int, vector<int>, greater<int>>

using namespace std;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int power(int a, int n) {
  if (n == 1)
    return a;
  if (n == 0)
    return 1;
  if (n % 2)
    return a * power(a * a, n / 2);
  return power(a * a, n / 2);
}
const int md = 998244353;
const int inf = (int)1e18;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/

signed main() {
  showoff;
  /*int n,ans[maxn];
  cin >> n;
  vector<pair<pair<string,int>,int> >v;
  FOR(i,1,n+1){
      int sc;
      string s;
      cin >> s >> sc;
      v.pb({{s,-sc},i});
  }
  sort(v.begin(),v.end());
  FOR(i,0,n)ans[v[i].se] = i+1;
  FOR(i,1,n+1)cout << ans[i] << "\n";*/
  int n, m, p[100];
  cin >> n >> m;
  vector<int> adj[m + 5];
  FOR(i, 1, m + 1) {
    int k;
    cin >> k;
    FOR(j, 1, k + 1) {
      int x;
      cin >> x;
      adj[i].pb(x - 1);
    }
  }
  int ans = 0;
  FOR(i, 1, m + 1) cin >> p[i];
  FOR(i, 0, (1 << n)) {
    bool fo = 1;
    FOR(j, 1, m + 1) {
      int c = 0;
      for (auto &x : adj[j]) {
        if (i & (1 << x))
          ++c;
      }
      if (c % 2 != p[j] % 2)
        fo = 0;
    }
    if (fo)
      ++ans;
  }
  cout << ans;
  return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...