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

#include <iostream>
#include <string>
using namespace std;
int main() {
  while (1) {
    string s1;
    cin >> s1;

    if (s1 == ".")
      break;

    string s2;
    cin >> s2;

    if (s1 == s2) {
      cout << "IDENTICAL" << endl;
      continue;
    }

    string t1 = s1;
    string t2 = s2;

    while (1) {
      size_t d1b = t1.find('\\"');
      if (d1b == string::npos)
        break;
      t1.replace(d1b, 1, "@");

      size_t d1e = t1.find('\\"');
      t1.replace(d1e, 1, "@");

      size_t d2b = t2.find('\\"');
      if (d2b == string::npos)
        break;
      t2.replace(d2b, 1, "@");

      size_t d2e = t2.find('\\"');
      t2.replace(d2e, 1, "@");

      string u1 = s1;
      u1.replace(d1b + 1, d1e - d1b - 1, "");
      string u2 = s2;
      u2.replace(d2b + 1, d2e - d2b - 1, "");

      if (u1 == u2) {
        t1 = u1;
        t2 = u2;
        break;
      }
    }

    if (t1 == t2) {
      cout << "CLOSE" << endl;
    } else {
      cout << "DIFFERENT" << endl;
    }
  }

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  while (1) {
    string s1;
    cin >> s1;

    if (s1 == ".")
      break;

    string s2;
    cin >> s2;

    if (s1 == s2) {
      cout << "IDENTICAL" << endl;
      continue;
    }

    string t1 = s1;
    string t2 = s2;

    while (1) {
      size_t d1b = t1.find('\\"');
      if (d1b == string::npos)
        break;
      t1.replace(d1b, 1, "@");

      size_t d1e = t1.find('\\"');
      t1.replace(d1e, 1, "@");

      size_t d2b = t2.find('\\"');
      if (d2b == string::npos)
        break;
      t2.replace(d2b, 1, "@");

      size_t d2e = t2.find('\\"');
      t1.replace(d2e, 1, "@");

      string u1 = s1;
      u1.replace(d1b + 1, d1e - d1b - 1, "");
      string u2 = s2;
      u2.replace(d2b + 1, d2e - d2b - 1, "");

      if (u1 == u2) {
        t1 = u1;
        t2 = u2;
        break;
      }
    }

    if (t1 == t2) {
      cout << "CLOSE" << endl;
    } else {
      cout << "DIFFERENT" << endl;
    }
  }

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

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int n, m;
  while (true) {
    string s1, s2;
    cin >> s1;
    if (s1 == ".")
      break;
    cin >> s2;
    if (s1 == s2) {
      cout << "IDENTICAL" << endl;
      continue;
    }
    int close = 0;
    bool quo = false;
    int i = 0, j = 0;
    while (true) {
      if (i == s1.size() || j == s2.size())
        break;
      if (s1[i] == '"' && s2[j] == '"') {
        quo = !quo;
        i++;
        j++;
        continue;
      }
      if (s1[i] == s2[j]) {
        i++;
        j++;
        continue;
      }
      if (!quo) {
        close = -1;
        break;
      } else {
        close++;
        while (s1[i++] != '"')
          ;
        i--;
        while (s2[j++] != '"')
          ;
        j--;
      }
    }
    if (!(i == s1.size() && j == s2.size()))
      close = -1;
    cout << (close == 1 ? "CLOSE" : "DIFFERENT") << endl;
  }

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int n, m;
  while (true) {
    string s1, s2;
    cin >> s1;
    if (s1 == ".")
      break;
    cin >> s2;
    if (s1 == s2) {
      cout << "IDENTICAL" << endl;
      continue;
    }
    int close = 0;
    bool quo = false;
    int i = 0, j = 0;
    while (true) {
      if (i == s1.size() || j == s2.size())
        break;
      if (s1[i] == '"' && s2[j] == '"') {
        quo = !quo;
        i++;
        j++;
        continue;
      }
      if (!quo) {
        if (s1[i] != s2[j]) {
          close = 10;
          break;
        } else {
          i++;
          j++;
          continue;
        }
      } else {
        if (s1[i] != s2[j]) {
          close++;
          while (s1[++i] != '"')
            ;
          while (s2[++j] != '"')
            ;
        } else {
          i++;
          j++;
          continue;
        }
      }
    }
    cout << (close == 1 ? "CLOSE" : "DIFFERENT") << endl;
  }

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

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

int main() {
  while (1) {
    string s1, s2;
    cin >> s1;
    if (s1 == ".")
      return 0;
    cin >> s2;
    string s11[201], s22[201];
    for (int i = 0; i < 201; i++) {
      s11[i] = ".";
      s22[i] = ".";
    }
    int now1 = 0, now2 = 0;
    for (int i = 0; i < (int)s1.length(); i++) {
      if (s1[i] == '"') {
        now1++;
        s11[now1] = "";
      } else
        s11[now1] += s1[i];
    }
    for (int i = 0; i < (int)s2.length(); i++) {
      if (s2[i] == '"') {
        now2++;
        s22[now2] = "";
      } else
        s22[now2] += s2[i];
    }
    int d = 0;
    for (int i = 0; i < 201; i++) {
      if (s11[i] != s22[i]) {
        if (i & 1) {
          d++;
        } else
          d += 2;
      }
    }
    if (d == 0)
      cout << "IDENTICAL";
    else if (d == 1)
      cout << "CLOSE";
    else
      cout << "DIFFERENT";
    cout << "\\n";
  }
}


Error: 0

Fixed submission:

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

int main() {
  while (1) {
    string s1, s2;
    cin >> s1;
    if (s1 == ".")
      return 0;
    cin >> s2;
    string s11[200], s22[200];
    for (int i = 0; i < 200; i++) {
      s11[i] = ".";
      s22[i] = ".";
    }
    int now1 = 0, now2 = 0;
    for (int i = 0; i < (int)s1.length(); i++) {
      if (s1[i] == '"') {
        now1++;
        s11[now1] = "";
      } else
        s11[now1] += s1[i];
    }
    for (int i = 0; i < (int)s2.length(); i++) {
      if (s2[i] == '"') {
        now2++;
        s22[now2] = "";
      } else
        s22[now2] += s2[i];
    }
    int d = 0;
    for (int i = 0; i < 200; i++) {
      if (s11[i] != s22[i]) {
        if (i & 1) {
          d++;
        } else
          d += 2;
      }
    }
    if (d == 0)
      cout << "IDENTICAL";
    else if (d == 1)
      cout << "CLOSE";
    else
      cout << "DIFFERENT";
    cout << "\\n";
  }
}
Problem p01102 (C++) — buggy submission, verdict: Runtime Error

#include "string"
#include <iostream>

using namespace std;

int main() {
  while (1) {
    string s1;
    cin >> s1;

    if (s1 == ".")
      break;

    string s2;
    cin >> s2;

    if (s1 == s2) {
      cout << "IDENTICAL" << endl;
      continue;
    }

    string t1 = s1;
    string t2 = s2;

    while (1) {
      size_t d1b = t1.find('\\"');
      if (d1b == string::npos)
        break;
      t1.replace(d1b, 1, "@");

      size_t d1e = t1.find('\\"');
      t1.replace(d1e, 1, "@");

      size_t d2b = t2.find('\\"');
      if (d2b == string::npos)
        break;
      t2.replace(d2b, 1, "@");

      size_t d2e = t2.find('\\"');
      t2.replace(d2e, 1, "@");

      string u1 = s1;
      u1.replace(d1b + 1, d1e - d1b - 1, "");
      string u2 = s2;
      u2.replace(d2b + 1, d2e - d2b - 1, "");

      if (u1 == u2) {
        t1 = u1;
        t2 = u2;
        break;
      }
    }
    if (t1 == t2)
      cout << "CLOSE" << endl;
    else
      cout << "DIFFERENT" << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include "string"
#include <iostream>

using namespace std;

int main() {
  while (1) {
    string s1;
    cin >> s1;

    if (s1 == ".")
      break;

    string s2;
    cin >> s2;

    if (s1 == s2) {
      cout << "IDENTICAL" << endl;
      continue;
    }

    string t1 = s1;
    string t2 = s2;

    while (1) {
      size_t d1b = t1.find('\\"');
      if (d1b == string::npos)
        break;
      t1.replace(d1b, 1, "@");

      size_t d1e = t1.find('\\"');
      t1.replace(d1e, 1, "@");

      size_t d2b = t2.find('\\"');
      if (d2b == string::npos)
        break;
      t1.replace(d2b, 1, "@");

      size_t d2e = t2.find('\\"');
      t1.replace(d2e, 1, "@");

      string u1 = s1;
      u1.replace(d1b + 1, d1e - d1b - 1, "");
      string u2 = s2;
      u2.replace(d1b + 2, d1e - d1b - 2, "");

      if (u1 == u2) {
        t1 = u1;
        t2 = u2;
        break;
      }
    }
    if (t1 == t2)
      cout << "CLOSE" << endl;
    else
      cout << "DIFFERENT" << endl;
  }
  return 0;
}
Problem p01102 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

vector<string> split(const string &s, char c = ' ') {
  vector<string> ret;
  stringstream ss(s);
  string t;
  while (getline(ss, t, c)) {
    ret.push_back(t);
  }
  return ret;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  while (1) {
    string s, t;
    cin >> s;
    if (s == ".")
      break;
    cin >> t;
    if (s == t) {
      cout << "IDENTICAL" << endl;
      continue;
    }
    char c = '"';
    vector<string> ss = split(s, c);
    vector<string> tt = split(t, c);
    int cnt = 0;
    if (ss.size() != tt.size())
      cnt = INF;
    rep(i, 0, min(ss.size(), tt.size())) {
      if (i % 2 == 0) {
        if (ss[i] != tt[i])
          cnt = INF;
      } else {
        if (ss[i] != tt[i])
          cnt++;
      }
    }
    if (cnt <= 1) {
      cout << "CLOSE" << endl;
    } else {
      cout << "DIFFERENT" << endl;
    }
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

vector<string> split(const string &s, char c = ' ') {
  vector<string> ret;
  stringstream ss(s);
  string t;
  while (getline(ss, t, c)) {
    ret.push_back(t);
  }
  return ret;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  while (1) {
    string s, t;
    cin >> s;
    if (s == ".")
      break;
    cin >> t;
    if (s == t) {
      cout << "IDENTICAL" << endl;
      continue;
    }
    char c = '"';
    vector<string> ss = split(s, c);
    vector<string> tt = split(t, c);
    int cnt = 0;
    if (ss.size() != tt.size())
      cnt = INF;
    rep(i, 0, ss.size()) {
      if (i % 2 == 0) {
        if (ss[i] != tt[i])
          cnt = INF;
      } else {
        if (ss[i] != tt[i])
          cnt++;
      }
    }
    if (cnt <= 1) {
      cout << "CLOSE" << endl;
    } else {
      cout << "DIFFERENT" << endl;
    }
  }
}
Problem p01104 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  for (int N, M;;) {
    cin >> N >> M;
    if (N == 0 and M == 0) {
      break;
    }
    if (N <= 20) {
      vector<vector<int>> b(N, vector<int>(M));
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
          char c;
          cin >> c, b[i][j] = c - '0';
        }
      }
      const int MASK = 1 << N;
      int ans = 0;
      for (int mask = 0; mask < MASK; mask++) {
        int cnt = 0;
        vector<int> sum(M, 0);
        for (int i = 0; i < N; i++) {
          if (mask & (1 << i)) {
            cnt++;
            for (int j = 0; j < M; j++) {
              sum[j] ^= b[i][j];
            }
          }
        }
        bool ok = true;
        for (int i = 0; i < M; i++) {
          if (sum[i] == 1) {
            ok = false;
          }
        }
        if (ok) {
          ans = max(ans, cnt);
        }
      }
      cout << ans << endl;
    } else {
      vector<int> b(N, 0);
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
          char c;
          cin >> c, b[i] |= (c - '0') << j;
        }
      }
      const int MASK = 1 << M;
      vector<int> dp(MASK, -1);
      dp[0] = 0;
      for (int i = 0; i < N; i++) {
        auto tmp = dp;
        for (int j = 0; j < MASK; j++) {
          if (dp[j] == -1) {
            continue;
          }
          tmp[j ^ b[i]] = max(tmp[j ^ b[i]], dp[j] + 1);
        }
        dp = tmp;
      }
      cout << dp[0] << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  for (int N, M;;) {
    cin >> N >> M;
    if (N == 0 and M == 0) {
      break;
    }
    if (N <= 25) {
      vector<vector<int>> b(N, vector<int>(M));
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
          char c;
          cin >> c, b[i][j] = c - '0';
        }
      }
      const int MASK = 1 << N;
      int ans = 0;
      for (int mask = 0; mask < MASK; mask++) {
        int cnt = 0;
        vector<int> sum(M, 0);
        for (int i = 0; i < N; i++) {
          if (mask & (1 << i)) {
            cnt++;
            for (int j = 0; j < M; j++) {
              sum[j] ^= b[i][j];
            }
          }
        }
        bool ok = true;
        for (int i = 0; i < M; i++) {
          if (sum[i] == 1) {
            ok = false;
          }
        }
        if (ok) {
          ans = max(ans, cnt);
        }
      }
      cout << ans << endl;
    } else {
      vector<int> b(N, 0);
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
          char c;
          cin >> c, b[i] |= (c - '0') << j;
        }
      }
      const int MASK = 1 << M;
      vector<int> dp(MASK, -1);
      dp[0] = 0;
      for (int i = 0; i < N; i++) {
        auto tmp = dp;
        for (int j = 0; j < MASK; j++) {
          if (dp[j] == -1) {
            continue;
          }
          tmp[j ^ b[i]] = max(tmp[j ^ b[i]], dp[j] + 1);
        }
        dp = tmp;
      }
      cout << dp[0] << endl;
    }
  }
  return 0;
}
Problem p01104 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int n, m;
vector<string> b;
int ans;
string kZero;

void dfs(int cur, int cnt, string bit) {
  if (cur == n) {
    if (bit == kZero)
      ans = max(ans, cnt);
    return;
  }
  dfs(cur + 1, cnt, bit);
  string nxt;
  for (int i = 0; i < m; ++i)
    nxt += "01"[(bit[i] ^ b[cur][i]) % 2];
  dfs(cur + 1, cnt + 1, nxt);
}

void bitDP() {
  auto bit = vector<ll>(n);
  for (int i = 0; i < n; ++i)
    bit[i] = stoll(b[i], nullptr, 2);

  auto cur = vector<int>(1 << m, -1);
  auto nxt = vector<int>(1 << m, -1);
  cur[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (ll j = 0; j < 1 << m; ++j) {
      if (cur[j] == -1)
        continue;
      nxt[j] = max(nxt[j], cur[j]);
      nxt[j ^ bit[i]] = max(nxt[j ^ bit[i]], cur[j] + 1);
    }
    swap(cur, nxt);
  }
  ans = cur[0];
}

int main() {
  while (cin >> n >> m, n) {
    b = vector<string>(n);
    for (int i = 0; i < n; ++i)
      cin >> b[i];
    ans = 0;
    if (m <= 22) {
      bitDP();
    } else {
      kZero = string(m, '0');
      dfs(0, 0, kZero);
    }
    cout << ans << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int n, m;
vector<string> b;
int ans;
string kZero;

void dfs(int cur, int cnt, string bit) {
  if (cur == n) {
    if (bit == kZero)
      ans = max(ans, cnt);
    return;
  }
  dfs(cur + 1, cnt, bit);
  string nxt;
  for (int i = 0; i < m; ++i)
    nxt += "01"[(bit[i] ^ b[cur][i]) % 2];
  dfs(cur + 1, cnt + 1, nxt);
}

void bitDP() {
  auto bit = vector<ll>(n);
  for (int i = 0; i < n; ++i)
    bit[i] = stoll(b[i], nullptr, 2);

  auto dp = vector<vector<int>>(n + 1, vector<int>(1 << m, -1));
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i) {
    for (ll j = 0; j < 1 << m; ++j) {
      if (dp[i][j] == -1)
        continue;
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      dp[i + 1][j ^ bit[i]] = max(dp[i + 1][j ^ bit[i]], dp[i][j] + 1);
    }
  }
  ans = dp[n][0];
}

int main() {
  while (cin >> n >> m, n) {
    b = vector<string>(n);
    for (int i = 0; i < n; ++i)
      cin >> b[i];
    ans = 0;
    if (m < 22) {
      bitDP();
    } else {
      kZero = string(m, '0');
      dfs(0, 0, kZero);
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p01104 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
map<string, int> Map;
int M, N;
string ss;
string x;
vector<pair<string, int>> Ready;
int cnt;
void test() {
  cout << "test: " << endl;
  for (map<string, int>::iterator iter = Map.begin(); iter != Map.end();
       iter++) {
    cout << iter->first << " " << iter->second << endl;
  }
  return;
}
void add() {
  map<string, int>::iterator iter = Map.begin();
  cnt = 0;
  Ready.clear();
  for (; iter != Map.end(); iter++) {
    string a = iter->first;
    x = "";
    for (int i = 0; i < M; i++) {
      if (a[i] == ss[i]) {
        x += '0';
      } else {
        x += '1';
      }
    }
    if (Map.find(x) != Map.end()) {
      if (Map[x] < 1 + iter->second) {
        Ready.push_back(make_pair(x, 1 + iter->second));
        cnt++;
      }
    } else {
      Ready.push_back(make_pair(x, 1 + iter->second));
      cnt++;
    }
  }
  for (int i = 0; i < cnt; i++) {
    if (Map.find(Ready[i].first) == Map.end()) {
      Map.insert(Ready[i]);
    } else {
      Map[Ready[i].first] = Ready[i].second;
    }
  }
  return;
}
int main() {

  std::ios::sync_with_stdio(false);
  while (cin >> N >> M) {
    if (M == 0 && N == 0) {
      return 0;
    }
    Map.clear();
    ss = "";
    for (int i = 0; i < M; i++) {
      ss += '0';
    }
    Map.insert(make_pair(ss, 0));
    for (int i = 0; i < N; i++) {
      cin >> ss;
      add();
    }
    ss = "";
    for (int i = 0; i < M; i++) {
      ss += '0';
    }
    cout << Map[ss] << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int AX = 5e2 + 66;
char s[AX][AX];
int ibest;
int a[AX][AX];
int sta[AX];
int temp[AX][AX];
int n, m;
void dfs(int x, int num, int lim) {
  if (x > n)
    return;
  if (num > lim)
    return;
  if (num == lim) {
    int f = 1;
    for (int i = 0; i < m; i++) {
      if (sta[i]) {
        f = 0;
        break;
      }
    }
    if (f)
      ibest = num;
    return;
  }
  dfs(x + 1, num, lim);
  for (int i = 0; i < m; i++)
    temp[num][i] = sta[i];
  for (int i = 0; i < m; i++)
    sta[i] ^= a[x][i];
  dfs(x + 1, num + 1, lim);
  for (int i = 0; i < m; i++)
    sta[i] = temp[num][i];
}

int main() {
  while (scanf("%d%d", &n, &m) && n && m) {
    ibest = 0;
    for (int i = 0; i < n; i++) {
      scanf("%s", s[i]);
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        a[i][j] = s[i][j] - '0';
      }
    }
    for (int i = n; i >= 2; i--) {
      dfs(0, 0, i);
      if (ibest)
        break;
    }
    printf("%d\\n", ibest);
  }
  return 0;
}
Problem p01104 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <vector>

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)

using namespace std;

int n, m, b[510][510];
int pc[1 << 24], dp[2][1 << 24], bits[510];

void compute() {
  int maxi = 0;
  if (n <= m) {
    rep(i, (1 << n)) {
      if (maxi >= pc[i])
        continue;
      bool ok = true;
      rep(x, m) {
        int cnt = 0;
        rep(y, n) if (((i >> y) & 1) && b[y][x])++ cnt;
        if (cnt & 1) {
          ok = false;
          break;
        }
      }
      if (ok)
        maxi = max(maxi, pc[i]);
    }
  } else { // n > m
    rep(y, n) {
      bits[y] = 0;
      rep(x, m) if (b[y][x]) bits[y] = bits[y] | (1 << x);
    }
    memset(dp, -1, sizeof dp);
    dp[0][0] = 0;
    rep(y, n) {
      rep(i, (1 << m)) dp[(y + 1) & 1][i] = -1;
      rep(state, (1 << m)) if (dp[y & 1][state] != -1) {
        dp[(y + 1) & 1][state] = max(dp[(y + 1) & 1][state], dp[y & 1][state]);
        dp[(y + 1) & 1][state ^ bits[y]] =
            max(dp[(y + 1) & 1][state ^ bits[y]], dp[y & 1][state] + 1);
      }
    }
    if (dp[n & 1][0] != -1)
      maxi = dp[n & 1][0];
  }
  cout << maxi << endl;
}

int main() {
  rep(i, (1 << 23)) pc[i] = __builtin_popcount(i);
  while (cin >> n >> m, n | m) {
    rep(i, n) {
      string s;
      cin >> s;
      rep(j, m) b[i][j] = (s[j] == '1');
    }
    compute();
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <vector>

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)

using namespace std;

int n, m, b[510][510];
int pc[1 << 24], dp[2][1 << 24], bits[24];

void compute() {
  int maxi = 0;
  if (n <= m) {
    while (n > 23)
      ;
    rep(i, (1 << n)) {
      if (maxi >= pc[i])
        continue;
      bool ok = true;
      rep(x, m) {
        int cnt = 0;
        rep(y, n) if (((i >> y) & 1) && b[y][x])++ cnt;
        if (cnt & 1) {
          ok = false;
          break;
        }
      }
      if (ok)
        maxi = max(maxi, pc[i]);
    }
  } else {
    while (m > 23)
      ;
    rep(y, n) {
      bits[y] = 0;
      rep(x, m) if (b[y][x]) bits[y] = bits[y] | (1 << x);
    }
    memset(dp, -1, sizeof dp);
    dp[0][0] = 0;
    rep(y, n) {
      rep(i, (1 << m)) dp[(y + 1) & 1][i] = -1;
      rep(state, (1 << m)) if (dp[y & 1][state] != -1) {
        dp[(y + 1) & 1][state] = max(dp[(y + 1) & 1][state], dp[y & 1][state]);
        dp[(y + 1) & 1][state ^ bits[y]] =
            max(dp[(y + 1) & 1][state ^ bits[y]], dp[y & 1][state] + 1);
      }
    }
    if (dp[n & 1][0] != -1)
      maxi = dp[n & 1][0];
  }
  cout << maxi << endl;
}

int main() {
  rep(i, (1 << 23)) pc[i] = __builtin_popcount(i);
  while (cin >> n >> m, n | m) {
    rep(i, n) {
      string s;
      cin >> s;
      rep(j, m) b[i][j] = (s[j] == '1');
    }
    compute();
  }
  return 0;
}