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

Buggy submission (status: Runtime Error):
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
char ca[8005];
bool dp[2005][8005];
vector<int> v1[2];

void check(int p, int q, int t, int n) {
  int i, j, k;
  memset(dp, false, sizeof(dp));
  dp[0][0] = true;
  for (i = 0; i < v1[p].size(); i++) {
    for (j = 0; j <= n; j++) {
      if (!dp[i][j])
        continue;
      dp[i + 1][abs(j - v1[p][i])] = true;
      dp[i + 1][j + v1[p][i]] = true;
    }
  }
}

int main() {
  int x, y;
  int i, j, k;
  int fir = -1;
  bool s1, s2;
  cin >> ca;
  cin >> x >> y;
  for (i = 0, j = 0, k = 0; i < strlen(ca); i++) {
    if (ca[i] == 'T') {
      if (fir == -1)
        fir = k;
      else if (k != 0)
        v1[j].push_back(k);
      j = 1 - j, k = 0;
    } else
      k++;
  }
  if (fir == -1)
    fir = k;
  else if (k != 0)
    v1[j].push_back(k);
  check(0, fir, x, strlen(ca));
  s1 = dp[v1[0].size()][abs(fir - x)];
  check(1, 0, y, strlen(ca));
  s2 = dp[v1[1].size()][abs(y)];
  if (s1 && s2) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
  return 0;
}


Fixed submission:
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
char ca[8005];
bool dp[4005][8005];
vector<int> v1[2];

void check(int p, int q, int t, int n) {
  int i, j, k;
  memset(dp, false, sizeof(dp));
  dp[0][0] = true;
  for (i = 0; i < v1[p].size(); i++) {
    for (j = 0; j <= n; j++) {
      if (!dp[i][j])
        continue;
      dp[i + 1][abs(j - v1[p][i])] = true;
      dp[i + 1][j + v1[p][i]] = true;
    }
  }
}

int main() {
  int x, y;
  int i, j, k;
  int fir = -1;
  bool s1, s2;
  cin >> ca;
  cin >> x >> y;
  for (i = 0, j = 0, k = 0; i < strlen(ca); i++) {
    if (ca[i] == 'T') {
      if (fir == -1)
        fir = k;
      else if (k != 0)
        v1[j].push_back(k);
      j = 1 - j, k = 0;
    } else
      k++;
  }
  if (fir == -1)
    fir = k;
  else if (k != 0)
    v1[j].push_back(k);
  check(0, fir, x, strlen(ca));
  s1 = dp[v1[0].size()][abs(fir - x)];
  check(1, 0, y, strlen(ca));
  s2 = dp[v1[1].size()][abs(y)];
  if (s1 && s2) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
  return 0;
}
Problem p03490 (C++)

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

int dp[4001][16001];
int ax[4001];
int ay[4001];
int tx, ty;

void dfsx(int n, int m) {
  if (dp[n][m + 8000])
    return;

  if (n < tx) {
    dfsx(n + 1, m + 8000 - ax[n]);
    dfsx(n + 1, m + 8000 + ax[n]);
  }

  dp[n][m + 8000] = 1;
}

void dfsy(int n, int m) {
  if (dp[n][m + 8000])
    return;

  if (n < ty) {
    dfsy(n + 1, m - ay[n]);
    dfsy(n + 1, m + ay[n]);
  }

  dp[n][m + 8000] = 1;
}

int main() {
  string s;
  int x, y;
  cin >> s >> x >> y;

  int dir = 1;

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'F') {
      if (dir)
        ax[tx]++;
      else
        ay[ty]++;
    } else if (s[i] == 'T') {
      if (dir)
        dir = 0, tx++;
      else
        dir = 1, ty++;
    }
  }

  if (s[s.size() - 1] == 'F') {
    if (dir)
      tx++;
    else
      ty++;
  }

  dfsx(1, ax[0]);
  bool xx = dp[tx][8000 + x];
  memset(dp, 0, sizeof(dp));

  dfsy(0, 0);
  bool yy = dp[ty][8000 + y];

  if (yy && xx)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

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

int dp[4001][16001];
int ax[4001];
int ay[4001];
int tx, ty;

void dfsx(int n, int m) {
  if (dp[n][m + 8000])
    return;

  if (n < tx) {
    dfsx(n + 1, m - ax[n]);
    dfsx(n + 1, m + ax[n]);
  }

  dp[n][m + 8000] = 1;
}

void dfsy(int n, int m) {
  if (dp[n][m + 8000])
    return;

  if (n < ty) {
    dfsy(n + 1, m - ay[n]);
    dfsy(n + 1, m + ay[n]);
  }

  dp[n][m + 8000] = 1;
}

int main() {
  string s;
  int x, y;
  cin >> s >> x >> y;

  int dir = 1;

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'F') {
      if (dir)
        ax[tx]++;
      else
        ay[ty]++;
    } else if (s[i] == 'T') {
      if (dir)
        dir = 0, tx++;
      else
        dir = 1, ty++;
    }
  }

  if (s[s.size() - 1] == 'F') {
    if (dir)
      tx++;
    else
      ty++;
  }

  dfsx(1, ax[0]);
  bool xx = dp[tx][8000 + x];
  memset(dp, 0, sizeof(dp));

  dfsy(0, 0);
  bool yy = dp[ty][8000 + y];

  if (yy && xx)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}
Problem p03490 (C++)

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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = 8000 + 10;
int x, y;
char S[MAXN];

int len, n, m, a[MAXN], b[MAXN];
int dp[2][MAXN * 2];

int Compute(int a[], int n, int target) {
  const int OFFSET = 8000;
  for (int i = -OFFSET; i <= OFFSET; ++i)
    dp[0][i + OFFSET] = 0;
  dp[0][0 + OFFSET] = 1;
  int cur = 1, nxt = 0;
  for (int i = 1; i <= n; ++i) {
    cur ^= 1;
    nxt ^= 1;
    for (int j = -OFFSET; j <= OFFSET; ++j)
      dp[nxt][j + OFFSET] = 0;
    for (int j = -OFFSET; j <= OFFSET; ++j) {
      if (dp[cur][j + OFFSET] == 0)
        continue;
      if (j - a[i] >= -OFFSET)
        dp[nxt][j - a[i] + OFFSET] = 1;
      if (j + a[i] <= OFFSET)
        dp[nxt][j + a[i] + OFFSET] = 1;
    }
  }
  return dp[nxt][target + OFFSET];
}

int main() {
  scanf("%s", S + 1);
  len = strlen(S + 1);
  scanf("%d%d", &x, &y);

  int p = 0;
  while (p < len && S[p + 1] == 'F')
    p++;
  x -= p;

  n = 0;
  m = 0;
  for (int i = p + 1, dir = 0; i <= len; ++i) {
    if (S[i] == 'T') {
      dir ^= 1;
      continue;
    }
    int j = i;
    while (j < len && S[j + 1] == 'F')
      j++;
    if (dir == 0)
      a[++n] = j - i + 1;
    else
      b[++m] = j - i + 1;
    i = j;
  }

  puts((Compute(a, n, x) && Compute(b, m, y)) ? "Yes" : "No");
  return 0;
}

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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = 8000 + 10;
int x, y;
char S[MAXN];

int len, n, m, a[MAXN], b[MAXN];
int dp[2][MAXN * 2];

int Compute(int a[], int n, int target) {
  const int OFFSET = 8000;
  for (int i = -OFFSET; i <= OFFSET; ++i)
    dp[0][i + OFFSET] = 0;
  dp[0][0 + OFFSET] = 1;
  int cur = 1, nxt = 0;
  for (int i = 1; i <= n; ++i) {
    cur ^= 1;
    nxt ^= 1;
    for (int j = -OFFSET; j <= OFFSET; ++j)
      dp[nxt][j + OFFSET] = 0;
    for (int j = -OFFSET; j <= OFFSET; ++j) {
      if (dp[cur][j + OFFSET] == 0)
        continue;
      if (j - a[i] >= -OFFSET)
        dp[nxt][j - a[i] + OFFSET] = 1;
      if (j + a[i] <= OFFSET)
        dp[nxt][j + a[i] + OFFSET] = 1;
    }
  }
  if (target < -OFFSET || target > OFFSET)
    return 0;
  return dp[nxt][target + OFFSET];
}

int main() {
  scanf("%s", S + 1);
  len = strlen(S + 1);
  scanf("%d%d", &x, &y);

  int p = 0;
  while (p < len && S[p + 1] == 'F')
    p++;
  x -= p;

  n = 0;
  m = 0;
  for (int i = p + 1, dir = 0; i <= len; ++i) {
    if (S[i] == 'T') {
      dir ^= 1;
      continue;
    }
    int j = i;
    while (j < len && S[j + 1] == 'F')
      j++;
    if (dir == 0)
      a[++n] = j - i + 1;
    else
      b[++m] = j - i + 1;
    i = j;
  }

  puts((Compute(a, n, x) && Compute(b, m, y)) ? "Yes" : "No");
  return 0;
}
Problem p03490 (C++)

Buggy submission (status: Memory Limit Exceeded):
#include <bits/stdc++.h>
#define F first
#define S second
#define SZ size()

using namespace std;
typedef long long ll;

int in() {
  int a;
  scanf("%d", &a);
  return a;
}
ll inll() {
  ll a;
  scanf("%lld", &a);
  return a;
}

//--------------------------------------------------

const int MAX = 1e4 + 5;
const int INF = 0x3f3f3f3f;

string s;
int X, Y;
vector<int> xsteps, ysteps;

int memx[MAX][MAX];

bool dpx(int i, int curX) {

  if (i == xsteps.SZ)
    return curX == X;
  int &res = memx[i][curX];
  if (res != -1)
    return res;
  res = 0;
  res = dpx(i + 1, curX + xsteps[i]) || dpx(i + 1, curX - xsteps[i]);
  return res;
}

int memy[MAX][MAX];

bool dpy(int i, int curY) {

  if (i == ysteps.SZ)
    return curY == Y;
  int &res = memy[i][curY];
  if (res != -1)
    return res;
  res = 0;
  res = dpy(i + 1, curY + ysteps[i]) || dpy(i + 1, curY - ysteps[i]);
  return res;
}

int main() {

  memset(memx, -1, sizeof memx);
  memset(memy, -1, sizeof memy);

  cin >> s;
  s = s + 'T';

  X = in(), Y = in();

  int steps = 0;
  int turns = 0;
  int xstart = 0;

  for (int i = 0; i < s.SZ; i++) {

    if (s[i] == 'F')
      steps++;

    else {

      if (turns == 0) {
        xstart = steps;
      }

      else if (steps > 0) {
        if (turns % 2 == 0)
          xsteps.push_back(steps);
        else
          ysteps.push_back(steps);
      }

      turns++;
      steps = 0;
    }
  }

  if (dpx(0, xstart) && dpy(0, 0))
    printf("Yes\n");
  else
    printf("No\n");
}


Fixed submission:
#include <bits/stdc++.h>
#define F first
#define S second
#define SZ size()

using namespace std;
typedef long long ll;

int in() {
  int a;
  scanf("%d", &a);
  return a;
}
ll inll() {
  ll a;
  scanf("%lld", &a);
  return a;
}

//--------------------------------------------------

const int MAX = 8e3 + 5;
const int INF = 0x3f3f3f3f;

string s;
int X, Y;
vector<int> xsteps, ysteps;

int memx[MAX][MAX];

bool dpx(int i, int curX) {

  if (i == xsteps.SZ)
    return curX == X;
  int &res = memx[i][curX];
  if (res != -1)
    return res;
  res = 0;
  res = dpx(i + 1, curX + xsteps[i]) || dpx(i + 1, curX - xsteps[i]);
  return res;
}

int memy[MAX][MAX];

bool dpy(int i, int curY) {

  if (i == ysteps.SZ)
    return curY == Y;
  int &res = memy[i][curY];
  if (res != -1)
    return res;
  res = 0;
  res = dpy(i + 1, curY + ysteps[i]) || dpy(i + 1, curY - ysteps[i]);
  return res;
}

int main() {

  memset(memx, -1, sizeof memx);
  memset(memy, -1, sizeof memy);

  cin >> s;
  s = s + 'T';

  X = in(), Y = in();

  int steps = 0;
  int turns = 0;
  int xstart = 0;

  for (int i = 0; i < s.SZ; i++) {

    if (s[i] == 'F')
      steps++;

    else {

      if (turns == 0) {
        xstart = steps;
      }

      else if (steps > 0) {
        if (turns % 2 == 0)
          xsteps.push_back(steps);
        else
          ysteps.push_back(steps);
      }

      turns++;
      steps = 0;
    }
  }

  if (dpx(0, xstart) && dpy(0, 0))
    printf("Yes\n");
  else
    printf("No\n");
}
Problem p03490 (C++)

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

using namespace std;
int a[8005];
bool f[4005][16005];
int j = 0;
void findx(int t, int x) {
  if (f[t][x + 8000])
    return;
  if (t + 2 <= j) {
    findx(t + 2, x + a[t + 2]);
    findx(t + 2, x - a[t + 2]);
  }
  f[t][x + 8000] = true;
}
void findy(int t, int y) {
  if (f[t][y + 8000])
    return;
  if (t + 2 <= j) {
    findy(t + 2, y + a[t + 2]);
    findy(t + 2, y - a[t + 2]);
  }
  f[t][y + 8000] = true;
}
int main() {
  memset(f, 0, sizeof(f));
  int x, y;
  string s;
  cin >> s >> x >> y;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'F') {
      cnt++;
    } else {
      a[++j] = cnt;
      cnt = 0;
    }
  }
  if (cnt != 0)
    a[++j] = cnt;
  a[0] = 0;
  findx(1, a[1]);
  findy(0, 0);
  if (j % 2 == 0) {
    if (f[j - 1][x + 8000] == 1 && f[j][y + 8000] == 1)
      cout << "Yes";
    else
      cout << "No";
  } else {
    if (f[j][x + 8000] == 1 && f[j - 1][y + 8000] == 1)
      cout << "Yes";
    else
      cout << "No";
  }
  return 0;
}

Fixed submission:
#include <cstring>
#include <iostream>

using namespace std;
int a[8005];
bool f[8005][16005];
int j = 0;
void findx(int t, int x) {
  if (f[t][x + 8000])
    return;
  if (t + 2 <= j) {
    findx(t + 2, x + a[t + 2]);
    findx(t + 2, x - a[t + 2]);
  }
  f[t][x + 8000] = true;
}
void findy(int t, int y) {
  if (f[t][y + 8000])
    return;
  if (t + 2 <= j) {
    findy(t + 2, y + a[t + 2]);
    findy(t + 2, y - a[t + 2]);
  }
  f[t][y + 8000] = true;
}
int main() {
  memset(f, 0, sizeof(f));
  int x, y;
  string s;
  cin >> s >> x >> y;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'F') {
      cnt++;
    } else {
      a[++j] = cnt;
      cnt = 0;
    }
  }
  if (cnt != 0)
    a[++j] = cnt;
  a[0] = 0;
  findx(1, a[1]);
  findy(0, 0);
  if (j % 2 == 0) {
    if (f[j - 1][x + 8000] == 1 && f[j][y + 8000] == 1)
      cout << "Yes";
    else
      cout << "No";
  } else {
    if (f[j][x + 8000] == 1 && f[j - 1][y + 8000] == 1)
      cout << "Yes";
    else
      cout << "No";
  }
  return 0;
}
Problem p03491 (C++)

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

int g(int a) {
  int t = 1;
  while (t < a)
    t <<= 1;
  while (true) {
    while (t > a)
      t >>= 1;
    if (t == a)
      return t;
    a -= t;
  }
  return -1;
}
int ans;
map<int, int> m;
void f(int l, int r) {
  int wi = r - l;
  if (!wi)
    return;
  if (wi == 1) {
    ans ^= g(l);
    return;
  }
  int t = 1;
  while (t < wi)
    t <<= 1;
  t >>= 1;
  t >>= 1;
  for (int i = l; i < r; i++) {
    if (i % t == 1 && i + t + t - 2 < r) {
      ans ^= t;
      return f(i + t + t - 1, r);
    } else
      ans ^= g(i);
  }
}

signed main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  for (int i = 0; i < n; i++)
    cin >> s[i];
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    int a = 0;
    if (i)
      while (s[i - 1][a] == s[i][a])
        a++;
    int sl = s[i].size() - a;
    int ll = l - a;
    m[ll + 1] ^= 1;
    m[ll - sl + 1] ^= 1;
  }
  vector<int> v;
  for (auto p : m)
    if (p.second)
      v.push_back(p.first);
  for (int i = 0; i < v.size(); i += 2)
    f(v[i], v[i + 1]);
  cout << (ans ? "Alice" : "Bob") << endl;
}


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

int g(int a) {
  int t = 1;
  while (t < a)
    t <<= 1;
  while (true) {
    while (t > a)
      t >>= 1;
    if (t == a)
      return t;
    a -= t;
  }
  return -1;
}
int ans;
map<int, int> m;
void f(int l, int r) {
  int wi = r - l;
  if (wi <= 10) {
    for (int i = l; i < r; i++)
      ans ^= g(i);
    return;
  }
  int t = 1;
  while (t < wi)
    t <<= 1;
  t >>= 1;
  t >>= 1;
  for (int i = l; i < r; i++) {
    if (i % t == 1 && i + t + t - 2 < r) {
      ans ^= t;
      return f(i + t + t - 1, r);
    } else
      ans ^= g(i);
  }
}

signed main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  for (int i = 0; i < n; i++)
    cin >> s[i];
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    int a = 0;
    if (i)
      while (s[i - 1][a] == s[i][a])
        a++;
    int sl = s[i].size() - a;
    int ll = l - a;
    m[ll + 1] ^= 1;
    m[ll - sl + 1] ^= 1;
  }
  vector<int> v;
  for (auto p : m)
    if (p.second)
      v.push_back(p.first);
  for (int i = 0; i < v.size(); i += 2)
    f(v[i], v[i + 1]);
  cout << (ans ? "Alice" : "Bob") << endl;
}
Problem p03491 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

long long g = 0;
long long L;

class T {
public:
  T *l, *r;
  int dep;
  T(int d, string s) {
    l = r = nullptr;
    dep = d;
    if (d == s.size()) {
    } else {
      if (s[d] == '0') {
        l = new T(d + 1, s);
      } else {
        r = new T(d + 1, s);
      }
    }
  }
  ~T() {
    if (l != nullptr) {
      delete l;
    }
    if (r != nullptr) {
      delete r;
    }
  }
  void append(string &s) {
    if (s.size() == dep) {
      return;
    }
    if (s[dep] == '0') {
      if (l == nullptr) {
        l = new T(dep + 1, s);
      } else {
        l->append(s);
      }
    } else {
      if (r == nullptr) {
        r = new T(dep + 1, s);
      } else {
        r->append(s);
      }
    }
  }
  void solve() {
    if (l == nullptr && r == nullptr) {
      return;
    } else {
      if (l != nullptr)
        l->solve();
      if (r != nullptr)
        r->solve();
      if (l == nullptr || r == nullptr) {
        int r = 0;
        while ((((L - dep) >> r) & 1) == 0)
          r++;
        g ^= (1 << r);
      }
    }
  }
};

int main() {
  int n;
  cin >> n >> L;
  vector<string> v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  T t(0, v[0]);
  for (int i = 1; i < n; i++)
    t.append(v[i]);
  t.solve();
  if (g == 0)
    cout << "Bob" << endl;
  else
    cout << "Alice" << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

long long g = 0;
long long L;

class T {
public:
  T *l, *r;
  int dep;
  T(int d, string &s) {
    l = r = nullptr;
    dep = d;
    if (d == s.size()) {
    } else {
      if (s[d] == '0') {
        l = new T(d + 1, s);
      } else {
        r = new T(d + 1, s);
      }
    }
  }
  ~T() {
    if (l != nullptr) {
      delete l;
    }
    if (r != nullptr) {
      delete r;
    }
  }
  void append(string &s) {
    if (s.size() == dep) {
      return;
    }
    if (s[dep] == '0') {
      if (l == nullptr) {
        l = new T(dep + 1, s);
      } else {
        l->append(s);
      }
    } else {
      if (r == nullptr) {
        r = new T(dep + 1, s);
      } else {
        r->append(s);
      }
    }
  }
  void solve() {
    if (l == nullptr && r == nullptr) {
      return;
    } else {
      if (l != nullptr)
        l->solve();
      if (r != nullptr)
        r->solve();
      if (l == nullptr || r == nullptr) {
        int r = 0;
        while ((((L - dep) >> r) & 1) == 0)
          r++;
        g ^= (1 << r);
      }
    }
  }
};

int main() {
  int n;
  cin >> n >> L;
  vector<string> v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  T t(0, v[0]);
  for (int i = 1; i < n; i++)
    t.append(v[i]);
  t.solve();
  if (g == 0)
    cout << "Bob" << endl;
  else
    cout << "Alice" << endl;

  return 0;
}
Problem p03491 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PP pair<int, pair<int, int>>
const int MAX = 1000001;
const int MOD = 1000000007;
const int INV2 = (MOD + 1) / 2;

signed main() {
  int n, l;
  cin >> n >> l;
  string s[n], t;
  for (int i = 0; i < n; i++)
    cin >> s[i];
  set<string> x;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    while (!s[i].empty()) {
      if (x.find(s[i]) == x.end()) {
        int k = 1;
        while ((l - s[i].size() + 1) % k == 0)
          k <<= 1;
        ans ^= k;
        x.insert(s[i]);
        s[i].pop_back();
      } else
        break;
    }
  }
  if (ans)
    cout << "Alice" << endl;
  else
    cout << "Bob" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PP pair<int, pair<int, int>>
const int MAX = 1000001;
const int MOD = 1000000007;
const int INV2 = (MOD + 1) / 2;

signed main() {
  int n, l;
  cin >> n >> l;
  string s[n], t;
  for (int i = 0; i < n; i++)
    cin >> s[i];
  set<string> x;
  int ans = 0;
  sort(s, s + n);
  for (int i = 0; i < s[0].size(); i++) {
    int k = 1;
    while ((l - i) % k == 0)
      k <<= 1;
    ans ^= k;
  }
  for (int i = 1; i < n; i++) {
    int j0 = 0;
    while (j0 < s[i].size() && j0 < s[i - 1].size() && s[i - 1][j0] == s[i][j0])
      j0++;
    for (int j = j0; j < s[i].size(); j++) {
      int k = 1;
      while ((l - j) % k == 0)
        k <<= 1;
      ans ^= k;
    }
  }
  if (ans)
    cout << "Alice" << endl;
  else
    cout << "Bob" << endl;
}
Problem p03491 (C++)

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

typedef long long ll;

ll N, L;
multiset<ll> X;

struct Node {
  ll x;
  Node *kids[2];
  Node(ll x) {
    this->x = x;
    kids[0] = kids[1] = nullptr;
  }
};
Node *Root;

ll R;

void go(string s, ll i, Node *node) {
  assert(node != nullptr);
  ll x = node->x;
  assert(x != 0);
  if (i == s.size()) {
    assert(x > 0);
    X.erase(X.find(x));
    node->x = 0;
    return;
  }
  if (x > 0) {
    assert(node->kids[0] == nullptr && node->kids[1] == nullptr);
    X.erase(X.find(x));
    node->x = -1;
    for (ll b : {0, 1}) {
      node->kids[b] = new Node(x - 1);
      X.insert(x - 1);
    }
  }
  go(s, i + 1, node->kids[s[i] - '0']);
}
int main() {
  cin >> N >> L;
  Root = new Node(L + 1);
  X.insert(L + 1);
  for (ll i = 0; i < N; ++i) {
    string s;
    cin >> s;
    go(s, 0, Root);
  }
  for (ll x : X) {
    R ^= x & (-x);
  }
  cout << (R != 0 ? "Alice" : "Bob") << endl;
}


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

typedef long long ll;

ll N, L;
multiset<ll> X;

struct Node {
  ll x;
  Node *kids[2];
  Node(ll x) {
    this->x = x;
    kids[0] = kids[1] = nullptr;
  }
};
Node *Root;

ll R;

void go(const string &s, ll i, Node *node) {
  assert(node != nullptr);
  ll x = node->x;
  assert(x != 0);
  if (i == s.size()) {
    assert(x > 0);
    X.erase(X.find(x));
    node->x = 0;
    return;
  }
  if (x > 0) {
    assert(node->kids[0] == nullptr && node->kids[1] == nullptr);
    X.erase(X.find(x));
    node->x = -1;
    for (ll b : {0, 1}) {
      node->kids[b] = new Node(x - 1);
      X.insert(x - 1);
    }
  }
  go(s, i + 1, node->kids[s[i] - '0']);
}
int main() {
  cin >> N >> L;
  Root = new Node(L + 1);
  X.insert(L + 1);
  for (ll i = 0; i < N; ++i) {
    string s;
    cin >> s;
    go(s, 0, Root);
  }
  for (ll x : X) {
    R ^= x & (-x);
  }
  cout << (R != 0 ? "Alice" : "Bob") << endl;
}
Problem p03491 (C++)

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

#define SIZE(a) ((int)(a).size())
#define REP(i, n) for (int i = 0; i < (n); ++i)

typedef long long ll;

const int N = 200005;
const int A = 2;

int n;
ll l;

int trie[N][A], str[N], sz = 1;

void add(const string &s) {
  int v = 1;
  for (auto c : s) {
    c -= '0';
    if (!trie[v][c])
      trie[v][c] = ++sz;
    v = trie[v][c];
  }
  str[v] = 1;
}

ll go(int v, int depth = 0) {
  if (!v) {
    int now = 0;
    while ((1 << now) <= (l - depth))
      ++now;
    return 1 + now % 2;
  }
  if (str[v])
    return 0;
  auto lf = go(trie[v][0], depth + 1);
  auto rt = go(trie[v][1], depth + 1);
  return lf ^ rt;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> n >> l;
  REP(i, n) {
    string s;
    cin >> s;
    add(s);
  }
  cout << (go(1) > 0 ? "Alice" : "Bob") << '\n';

  return 0;
}

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

#define SIZE(a) ((int)(a).size())
#define REP(i, n) for (int i = 0; i < (n); ++i)

typedef long long ll;

const int N = 200005;
const int A = 2;

int n;
ll l;

int trie[N][A], str[N], sz = 1;

void add(const string &s) {
  int v = 1;
  for (auto c : s) {
    c -= '0';
    if (!trie[v][c])
      trie[v][c] = ++sz;
    v = trie[v][c];
  }
  str[v] = 1;
}

ll go(int v, int depth = 0) {
  if (!v) {
    int now = 1;
    ll h = l - depth + 1;
    while (h % 2 == 0)
      h /= 2, now *= 2;
    return 1 + now;
  }
  if (str[v])
    return 0;
  auto lf = go(trie[v][0], depth + 1);
  auto rt = go(trie[v][1], depth + 1);
  return lf ^ rt;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> n >> l;
  REP(i, n) {
    string s;
    cin >> s;
    add(s);
  }
  cout << (go(1) > 0 ? "Alice" : "Bob") << '\n';

  return 0;
}
Problem p03491 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N, L;
  cin >> N >> L;
  set<string> ST[100001];
  ll G = 0;
  rep(i, N) {
    string S;
    cin >> S;
    int M = S.size();
    ST[M].insert(S);
  }
  for (int i = 100000; i > 0; i--) {
    if (ST[i].size() & 1) {
      ll K = L - i + 1;
      ll GK = 1;
      while (K % 2 == 0) {
        GK <<= 1;
        K /= 2;
      }
      G ^= GK;
    }
    for (string S : ST[i]) {
      S.pop_back();
      ST[i - 1].insert(S);
    }
  }
  if (G)
    co("Alice");
  else
    co("Bob");

  Would you please return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N, L;
  cin >> N >> L;
  set<string> ST[100001];
  ll G = 0;
  rep(i, N) {
    string S;
    cin >> S;
    int M = S.size();
    ST[M].insert(S);
  }
  for (int i = 100000; i > 0; i--) {
    if (ST[i].size() & 1) {
      ll K = L - i + 1;
      ll GK = 1;
      while (K % 2 == 0) {
        GK <<= 1;
        K /= 2;
      }
      G ^= GK;
    }
    for (string S : ST[i]) {
      S.pop_back();
      ST[i - 1].insert(S);
    }
    ST[i].clear();
  }
  if (G)
    co("Alice");
  else
    co("Bob");

  Would you please return 0;
}
Problem p03493 (C++)

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

int main() {
  string s;
  int t = 0;
  cin >> s;
  for (int i = 1; i < 4; i++) {
    if (s.at(i) = 1) {
      t += 1;
    }
  }
  cout << t << endl;
}


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

int main() {
  string s;
  int t = 0;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == '1') {
      t += 1;
    }
  }
  cout << t << endl;
}
Problem p03493 (C++)

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

int main() {
  string a;
  int b;
  b = 0;
  if (a.at(0) == '1') {
    b++;
  }
  if (a.at(1) == '1') {
    b++;
  }
  if (a.at(2) == '1') {
    b++;
  }
  cout << b << endl;
}


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

int main() {
  string a;
  int b;
  cin >> a;
  b = 0;
  if (a.at(0) == '1') {
    b++;
  }
  if (a.at(1) == '1') {
    b++;
  }
  if (a.at(2) == '1') {
    b++;
  }
  cout << b << endl;
}
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
li = input().split("")
print(len([a for a in li if a == "1"]))


Fixed submission:
s = input()
print(len([a for a in s if a == "1"]))
Problem p03493 (C++)

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

int main() {
  int a, s1, s2, s3;
  cin >> a;

  s3 = a % 10;
  s2 = (a - s3) % 100 * 0.1;
  s1 = (a - s2 * 10 - s3) * 0.01;
  return (s1 + s2 + s3);
}


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

int main() {
  int a, s1, s2, s3;
  cin >> a;

  s3 = a % 10;
  s2 = (a - s3) % 100 * 0.1;
  s1 = (a - s2 * 10 - s3) * 0.01;
  cout << (s1 + s2 + s3);
  return 0;
}
Problem p03493 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  string a;
  int s = 0;
  cin >> a;

  for (int i = 0; i < 3; i++) {
    while (a[i] == '1')
      s++;
  }
  cout << s << endl;
}


Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  string a;
  int s = 0;
  cin >> a;

  for (int i = 0; i < 3; i++) {
    if (a[i] == '1')
      s++;
  }
  cout << s << endl;
}
Problem p03493 (C++)

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

#define lli long long int
#define LLI(n)                                                                 \
  lli n;                                                                       \
  scanf("%lld", &n);
#define STR(n)                                                                 \
  string n;                                                                    \
  scanf("%s", &n);
#define Sort(n) sort(n.begin(), n.end());
#define Reve(n) reverse(n.begin(), n.end());
#define yes puts("Yes");
#define no puts("No");
#define C45(n) (n + 1) / 2

// 素数
bool IsPrime(lli num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0)
      return false;
  }
  return true;
}
// 各桁の和
lli Sum(lli n) {
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(void) {
  lli flag = 0;
  STR(s)
  for (lli i = 0; i < s.size(); i++) {
    if (s.at(i) == '1') {
      flag++;
    }
  }
  cout << flag << endl;
  return 0;
}


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

#define lli long long int
#define LLI(n)                                                                 \
  lli n;                                                                       \
  scanf("%lld", &n);
#define STR(n)                                                                 \
  string n;                                                                    \
  cin >> s;
#define Sort(n) sort(n.begin(), n.end());
#define Reve(n) reverse(n.begin(), n.end());
#define yes puts("Yes");
#define no puts("No");
#define C45(n) (n + 1) / 2

// 素数
bool IsPrime(lli num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0)
      return false;
  }
  return true;
}
// 各桁の和
lli Sum(lli n) {
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(void) {
  lli flag = 0;
  STR(s)
  for (lli i = 0; i < s.size(); i++) {
    if (s.at(i) == '1') {
      flag++;
    }
  }
  cout << flag << endl;
  return 0;
}
Problem p03493 (C++)

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

int main() {
  const static int NUM_OF_BOXES = 3;
  char boxes[3];
  std::cin >> boxes;
  int numOfBalls = 0;
  for (size_t i = 0U; i << NUM_OF_BOXES; ++i) {
    if (boxes[i] == '1') {
      numOfBalls++;
    }
  }
  std::cout << numOfBalls;
}

Fixed submission:
#include <iostream>

int main() {
  const static int NUM_OF_BOXES = 3;
  char boxes[3];
  std::cin >> boxes;
  int numOfBalls = 0;
  for (size_t i = 0U; i < NUM_OF_BOXES; ++i) {
    if (boxes[i] == '1') {
      numOfBalls++;
    }
  }
  std::cout << numOfBalls;
}
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
s = input()
print(s.count(1))


Fixed submission:
s = input()
print(s.count("1"))
Problem p03493 (C++)

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

int main() {
  int i;
  int k = 0;
  cin >> i;
  for (i = 0; i < 3; i--) {
    int j;
    j = i % 100;
    k += j;
    i == i / 10;
  }
  cout << k;
}

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

int main() {
  int a;
  cin >> a;
  cout << (a & 100) / 100 + (a & 10) / 10 + (a & 1) << endl;
}
Problem p03493 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int a;
  int total = 0;
  cin >> a;

  while (a != 0) {
    total += a % 2;
  }

  cout << total << endl;
}

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

int main() {
  int a;
  int total = 0;
  cin >> a;

  while (a != 0) {
    total += a % 2;
    a = a / 10;
  }

  cout << total << endl;
}
Problem p03493 (C++)

Buggy submission (status: Runtime Error):

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

int main() {
  string s;
  cin >> s;
  int counter = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '1')
      counter++;
  }
  return counter;
}

Fixed submission:

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

int main() {
  string s;
  cin >> s;
  int counter = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '1')
      counter++;
  }
  cout << counter;
}
Problem p03493 (C++)

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

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c;
  d = a % (a - 1);
  e = b % (b - 1);
  f = c % (c - 1);
  cout << d + e + f << endl;
}

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

int main() {

  int s, s1, s2, s3;
  cin >> s;
  s1 = s / 100;
  s2 = s % 100;
  s3 = s2 % 10;
  s2 = s2 / 10;

  cout << s1 + s2 + s3 << endl;
}
Problem p03493 (C++)

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

int main(void) {
  string S;
  int count = 0;

  for (int i = 0; i < 3; i++) {
    if (S.at(i) == '1')
      count++;
  }
  cout << count << endl;
}


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

int main(void) {
  string S;
  cin >> S;
  int count = 0;

  for (int i = 0; i < 3; i++) {
    if (S.at(i) == '1')
      count++;
  }
  cout << count << endl;
}
Problem p03493 (C++)

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

int main() {
  int a;
  cin >> a;
  int one = a % 10;
  int ten = a % 100 - one;
  int hundred = a % 1000 - ten - one;
  ten = ten / 10;
  hundred = hundred / 100;
  // ここまでで位ごとに分解した
  cout << (1 - 1 % one) + (1 - 1 % ten) + (1 - 1 % hundred);
}

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

int main() {
  int a;
  cin >> a;
  int one = a % 10;
  int ten = a % 100 - one;
  int hundred = a % 1000 - ten - one;
  ten = ten / 10;
  hundred = hundred / 100;
  // ここまでで位ごとに分解した
  cout << one + ten + hundred;
}
Problem p03493 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, sum = 0;
  cin >> s;
  if (s[0] == 1)
    sum += 1;
  if (s[1] == 1)
    sum += 1;
  if (s[2] == 1)
    sum += 1;
  cout << sum;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  int cnt = 0;
  if (a[0] == '1')
    cnt++;
  if (a[1] == '1')
    cnt++;
  if (a[2] == '1')
    cnt++;
  cout << cnt;
  return 0;
}
Problem p03493 (C++)

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

int main() {
  int count = 0;
  string s;

  for (int i = 0; i < 3; i++) {
    if (s.at(i) == '1') {
      count += 1;
    }
  }
  cout << count << endl;
}

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

int main() {
  int count = 0;
  string s;
  cin >> s;

  for (int i = 0; i < 3; i++) {
    if (s.at(i) == '1') {
      count += 1;
    }
  }
  cout << count << endl;
}
Problem p03493 (C++)

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

int main() {
  int a;
  cin >> a;
  int b1, b2, b3;
  b1 = 10 % (a + 10);
  b2 = (100 % (a + 100 - b1)) / 10;
  b3 = 100 / a;
  cout << b1 + b2 + b3 << endl;
}

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

int main() {
  int a;
  cin >> a;
  int b1, b2, b3;
  b1 = (a + 10) % 10;
  b2 = ((a + 100 - b1) % 100) / 10;
  b3 = a / 100;
  cout << b1 + b2 + b3 << endl;
}
Problem p03493 (C++)

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

int main() {
  string a = 0;
  int ans;
  cin >> a;
  if (a[0] == '1')
    ans++;
  if (a[1] == '1')
    ans++;
  if (a[2] == '1')
    ans++;
  cout << ans << endl;
}


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

int main() {
  string a;
  int ans = 0;
  cin >> a;
  if (a[0] == '1')
    ans++;
  if (a[1] == '1')
    ans++;
  if (a[2] == '1')
    ans++;
  cout << ans << endl;
}
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
print(input().count(1))


Fixed submission:
print(input().count("1"))
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
marbles = input()
num = marbles.count(1)
print(num)


Fixed submission:
ans = input().count("1")
print(ans)
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
a, b, c = map(int, input().split())
print(a + b + c)


Fixed submission:
a, b, c = map(int, input())
print(a + b + c)
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
iter_num = input()
variables = input()

raw_variables = variables.split(" ")
variables = list()

for raw_variable in raw_variables:
    variables.append(int(raw_variable))


def calc(variable):
    process_count = 0
    while variable % 2 == 0:
        process_count += 1
        variable = variable / 2
    return process_count


min_count = None

for variable in variables:
    process_count = calc(variable)
    if min_count is None:
        min_count = process_count
    if process_count < min_count:
        min_count = process_count

print(min_count)


Fixed submission:
chars = input()
count = 0
for char in chars:
    if char == "1":
        count += 1
print(count)
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
print(sum([int(x) for x in input().split()]))


Fixed submission:
print(sum([int(x) for x in input()]))
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
print(sum(list(map(int, list(a)))))


Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
s = str(a)
print(sum(list(map(int, list(s)))))
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
a = list(str(int(input)))
print(a.count("1"))


Fixed submission:
a = list(str(int(input())))
print(a.count("1"))
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
print(input().cont("1"))


Fixed submission:
print(input().count("1"))
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
from sys import stdin

s1, s2, s3 = [x for x in list(stdin.readline())]


Fixed submission:
from sys import stdin

s1, s2, s3 = [int(x) for x in list(stdin.readline().rstrip())]

print(s1 + s2 + s3)
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
sss = input()
print(sss.count(1))


Fixed submission:
sss = input()
print(sss.count("1"))
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
a = int(input())
b = a.count(int(1))
print(b)


Fixed submission:
a = input()
b = a.count("1")
print(b)
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
a = map(int, input().split())
print(a.count(1))


Fixed submission:
a = list(input())
print(a.count("1"))
Problem p03493 (Python)

Buggy submission (status: Runtime Error):
print(input.count("1"))


Fixed submission:
print(input().count("1"))
Problem p03494 (C++)

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

int main() {

  int N;
  vector<int> A(200);
  int res = 0;
  for (int i = 0; i < N; i++)
    cin >> A.at(i);

  while (true) {
    bool fl = false;
    for (int i = 0; i < N; i++) {
      if (A.at(i) % 2 != 0)
        fl = true;
    }

    if (fl)
      break;

    for (int i = 0; i < N; i++) {
      A.at(i) /= 2;
    }
    ++res;
  }
  cout << res << endl;
}


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

int main() {

  int N;
  cin >> N;
  vector<int> A(200);
  int res = 0;
  for (int i = 0; i < N; i++)
    cin >> A.at(i);

  while (true) {
    bool fl = false;
    for (int i = 0; i < N; i++) {
      if (A.at(i) % 2 != 0)
        fl = true;
    }

    if (fl)
      break;

    for (int i = 0; i < N; i++) {
      A.at(i) /= 2;
    }
    ++res;
  }
  cout << res << endl;
}
Problem p03494 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a, b) memset((a), (b), sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
struct str_hash {
  size_t operator()(const string &str) const {
    return __stl_hash_string(str.c_str());
  }
};
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-4;
const int MAX = 1e5 + 10;
const ll mod = 1e9 + 7;
/***************************************  head
 * **********************************************/
int main() {
  int n, i, a[333], ans;
  while (~scanf("%d", &a[i])) {
    ans = 0;
    for (i = 0; i < n; i++)
      scanf("%d", &a[i]);
    while (1) {
      for (i = 0; i < n; i++) {
        if (a[i] % 2 == 0)
          a[i] /= 2;
        else
          goto end;
      }
      ans++;
    }
  end:;
    printf("%d\n", ans);
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a, b) memset((a), (b), sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
struct str_hash {
  size_t operator()(const string &str) const {
    return __stl_hash_string(str.c_str());
  }
};
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-4;
const int MAX = 1e5 + 10;
const ll mod = 1e9 + 7;
/***************************************  head
 * **********************************************/
int main() {
  int n, i, a[333], ans;
  while (~scanf("%d", &n)) {
    ans = 0;
    for (i = 0; i < n; i++)
      scanf("%d", &a[i]);
    while (1) {
      for (i = 0; i < n; i++) {
        if (a[i] % 2 == 0)
          a[i] /= 2;
        else
          goto end;
      }
      ans++;
    }
  end:;
    printf("%d\n", ans);
  }
  return 0;
}
Problem p03494 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) { cin >> A.at(i); }
  vector<int> count(100);
  rep(i, N) {
    while (A.at(i) % 2 == 0) {
      count.at(i)++;
      A.at(i) /= 2;
    }
  }
  int mini = 1e10;
  rep(i, N) { mini = min(mini, count.at(i)); }
  cout << mini << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) { cin >> A.at(i); }
  vector<int> count(1000);
  rep(i, N) {
    while (A.at(i) % 2 == 0) {
      count.at(i)++;
      A.at(i) /= 2;
    }
  }
  int mini = 1e10;
  rep(i, N) { mini = min(mini, count.at(i)); }
  cout << mini << endl;
  return 0;
}
Problem p03494 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) { cin >> A.at(i); }
  vector<int> count(100);
  rep(i, N) {
    while (A.at(i) % 2 == 0) {
      count.at(i)++;
      A.at(i) /= 2;
    }
  }
  int mini = 1e100;
  rep(i, N) { mini = min(mini, count.at(i)); }
  cout << mini << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) { cin >> A.at(i); }
  vector<int> count(1000);
  rep(i, N) {
    while (A.at(i) % 2 == 0) {
      count.at(i)++;
      A.at(i) /= 2;
    }
  }
  int mini = 1e100;
  rep(i, N) { mini = min(mini, count.at(i)); }
  cout << mini << endl;
  return 0;
}
Problem p03494 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int A[210];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int res = 0;
  while (true) {
    bool exsist_odd = false;
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 != 0) {
        exsist_odd = true;
      }
    }
    if (exsist_odd) {
      break;
    }
    for (int i = 0; i < N; i++) {
      A[i] / 2;
    }
    res++;
  }
  cout << res << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int A[210];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int res = 0;
  while (true) {
    bool exsist_odd = false;
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 != 0) {
        exsist_odd = true;
      }
    }
    if (exsist_odd) {
      break;
    }
    for (int i = 0; i < N; i++) {
      A[i] /= 2;
    }
    res++;
  }
  cout << res << endl;
}
Problem p03494 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  bool h = false;
  int n, ans = 0, a[200];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  while (1) {
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 0)
        a[i] /= 2;
      else {
        h = true;
        break;
      }
    }
    if (h)
      break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  bool h = false;
  int n, ans = 0, a[200];
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  while (1) {
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 0)
        a[i] /= 2;
      else {
        h = true;
        break;
      }
    }
    if (h)
      break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p03494 (C++)

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

int main() {
  int i, n, a, c, m = 100;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    c = 0;
    while (a % 2 == 0) {
      a / -2;
      c++;
    }
    m = min(m, c);
  }
  cout << m;
  return 0;
}

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

int main() {
  int i, n, a, c, m = 100;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    c = 0;
    while (a % 2 == 0) {
      a /= 2;
      c++;
    }
    m = min(m, c);
  }
  cout << m;
  return 0;
}
Problem p03494 (C++)

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

int main() {
  int N;
  bool even = true;
  int count = 0;
  vector<int> a;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int b;
    cin >> b;
    a.push_back(b);
  }

  while (even) {
    for (int i = 0; i < N; i++) {
      if (a.at(i) % 2 == 1)
        goto OUT;
    }
    count++;
  }
OUT:

  cout << count << endl;
}


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

int main() {
  int N;
  bool even = true;
  int count = 0;
  vector<int> a;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int b;
    cin >> b;
    a.push_back(b);
  }

  while (even) {
    for (int i = 0; i < N; i++) {
      if (a.at(i) % 2 == 1)
        goto OUT;
      a.at(i) /= 2;
    }
    count++;
  }
OUT:

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

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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) { cin >> A.at(i); }
  int count = 0;
  while (true) {
    bool a = false;
    rep(i, N) {
      if (A.at(i) % 2 == 1)
        a = true;
    }
    if (a) {
      break;
    } else {
      rep(i, N) { A.at(i) / 2; }
      count++;
    }
  }
  cout << count << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) { cin >> A.at(i); }
  int count = 0;
  while (true) {
    bool a = false;
    rep(i, N) {
      if (A.at(i) % 2 == 1)
        a = true;
    }
    if (a) {
      break;
    } else {
      rep(i, N) { A.at(i) /= 2; }
      count++;
    }
  }
  cout << count << endl;
}