Problem p03133 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll, ll>

using namespace ::std;

const ll maxn = 210;
const ll mod = 998244353;

bitset<maxn> bi[maxn];
ll tav[maxn];

bitset<maxn> f[maxn];
ll cnt = 1;
ll koj[maxn];

bool add(bitset<maxn> bi, ll m) {
  for (ll i = m - 1; i >= 0; i--) {
    if (bi[i]) {
      if (koj[i] == -1) {
        f[cnt] = bi;
        koj[i] = cnt;
        cnt++;
        return 0;
      } else {
        bi ^= f[koj[i]];
      }
    }
  }
  return 1;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  tav[0] = 1;
  for (ll i = 1; i < maxn; i++) {
    tav[i] = (tav[i - 1] * 2) % mod;
  }
  fill(koj, koj + maxn, -1);

  ll n, m;
  cin >> n >> m;
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < m; j++) {
      ll a;
      cin >> a;
      bi[i][j] = a;
    }
  }
  ll sefr = 0;
  for (ll i = 0; i < n; i++) {
    sefr += add(bi[i], m);
  }
  cout << ((tav[m - 1] * (tav[n] - tav[sefr])) % mod + mod) % mod;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll, ll>

using namespace ::std;

const ll maxn = 310;
const ll mod = 998244353;

bitset<maxn> bi[maxn];
ll tav[maxn];

bitset<maxn> f[maxn];
ll cnt = 1;
ll koj[maxn];

bool add(bitset<maxn> bi, ll m) {
  for (ll i = m - 1; i >= 0; i--) {
    if (bi[i]) {
      if (koj[i] == -1) {
        f[cnt] = bi;
        koj[i] = cnt;
        cnt++;
        return 0;
      } else {
        bi ^= f[koj[i]];
      }
    }
  }
  return 1;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  tav[0] = 1;
  for (ll i = 1; i < maxn; i++) {
    tav[i] = (tav[i - 1] * 2) % mod;
  }
  fill(koj, koj + maxn, -1);

  ll n, m;
  cin >> n >> m;
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < m; j++) {
      ll a;
      cin >> a;
      bi[i][j] = a;
    }
  }
  ll sefr = 0;
  for (ll i = 0; i < n; i++) {
    sefr += add(bi[i], m);
  }
  cout << ((tav[m - 1] * (tav[n] - tav[sefr])) % mod + mod) % mod;
}