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

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

using namespace std;

const int MAX_N = 770;

int n, m, color[MAX_N], cnt[2];
bool G[MAX_N][MAX_N], tmp[MAX_N << 1], pack[MAX_N << 1];

void dfs(int u, int col) {
  color[u] = col, cnt[col == 1]++;
  for (int i = 1; i <= n; i++)
    if (G[u][i] == false && i != u)
      if (color[i] == col)
        puts("-1"), exit(0);
      else if (color[i] == 0)
        dfs(i, -col);
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, u, v; i <= n; i++)
    scanf("%d%d", &u, &v), G[u][v] = G[v][u] = true;
  pack[0] = true;
  for (int i = 1; i <= n; i++)
    if (!color[i]) {
      cnt[0] = cnt[1] = 0, dfs(i, 1);
      memset(tmp, false, sizeof(tmp));
      for (int j = 0; j <= n; j++)
        tmp[j + cnt[0]] |= pack[j], tmp[j + cnt[1]] |= pack[j];
      memcpy(pack, tmp, sizeof(pack));
    }
  int ans = 0x7fffffff;
  for (int i = 0; i <= n; i++)
    if (pack[i])
      ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

const int MAX_N = 770;

int n, m, color[MAX_N], cnt[2];
bool G[MAX_N][MAX_N], tmp[MAX_N << 1], pack[MAX_N << 1];

void dfs(int u, int col) {
  color[u] = col, cnt[col == 1]++;
  for (int i = 1; i <= n; i++)
    if (G[u][i] == false && i != u)
      if (color[i] == col)
        puts("-1"), exit(0);
      else if (color[i] == 0)
        dfs(i, -col);
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, u, v; i <= m; i++)
    scanf("%d%d", &u, &v), G[u][v] = G[v][u] = true;
  pack[0] = true;
  for (int i = 1; i <= n; i++)
    if (!color[i]) {
      cnt[0] = cnt[1] = 0, dfs(i, 1);
      memset(tmp, false, sizeof(tmp));
      for (int j = 0; j <= n; j++)
        tmp[j + cnt[0]] |= pack[j], tmp[j + cnt[1]] |= pack[j];
      memcpy(pack, tmp, sizeof(pack));
    }
  int ans = 0x7fffffff;
  for (int i = 0; i <= n; i++)
    if (pack[i])
      ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
  printf("%d\n", ans);
  return 0;
}
Problem p03321 (C++)

Buggy submission (status: Memory Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int color[100005], l[705], r[705], a[1005][1005], w, b, n, m, ans,
    dp[705][705][705];
void dfs(int u, int co) {
  color[u] = co;
  if (co == 1)
    w++;
  else
    b++;
  for (int v = 1; v <= n; v++) {
    if (u != v && a[u][v] == false && color[v] != 0 && color[v] == co) {
      printf("-1\n");
      exit(0);
    }
    if (u != v && a[u][v] == false && color[v] == 0)
      dfs(v, 3 - co);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x][y] = a[y][x] = true;
  }
  for (int i = 1; i <= n; i++) {
    w = b = 0;
    if (color[i] == 0)
      dfs(i, 1);
    l[i] = w;
    r[i] = b;
  }
  dp[0][0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= n; j++)
      for (int k = 0; k <= n; k++) {
        if (j >= l[i] && k >= r[i])
          dp[i][j][k] = dp[i - 1][j - l[i]][k - r[i]];
        if (j >= r[i] && k >= l[i])
          dp[i][j][k] |= dp[i - 1][j - r[i]][k - l[i]];
      }
  }
  ans = 1e9;
  for (int i = 1; i <= n; i++) {
    if (!dp[n][i][n - i])
      continue;
    ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
  }
  printf("%d\n", ans);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int color[705], l[705], r[705], a[705][705], w, b, n, m, ans;
bool dp[705][705][705];
void dfs(int u, int co) {
  color[u] = co;
  if (co == 1)
    w++;
  else
    b++;
  for (int v = 1; v <= n; v++) {
    if (u != v && a[u][v] == false && color[v] != 0 && color[v] == co) {
      printf("-1\n");
      exit(0);
    }
    if (u != v && a[u][v] == false && color[v] == 0)
      dfs(v, 3 - co);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x][y] = a[y][x] = true;
  }
  for (int i = 1; i <= n; i++) {
    w = b = 0;
    if (color[i] == 0)
      dfs(i, 1);
    l[i] = w;
    r[i] = b;
  }
  dp[0][0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= n; j++)
      for (int k = 0; k <= n; k++) {
        if (j >= l[i] && k >= r[i])
          dp[i][j][k] = dp[i - 1][j - l[i]][k - r[i]];
        if (j >= r[i] && k >= l[i])
          dp[i][j][k] |= dp[i - 1][j - r[i]][k - l[i]];
      }
  }
  ans = 1e9;
  for (int i = 1; i <= n; i++) {
    if (!dp[n][i][n - i])
      continue;
    ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
  }
  printf("%d\n", ans);
  return 0;
}
Problem p03321 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> col;
vector<vector<int>> grh;
void err() {
  cout << -1 << '\n';
  exit(0);
}
inline void chmax(int &a, int b) {
  if (a < b)
    a = b;
}
void dfs(int crr, int c, vector<int> &cnt) {
  col[crr] = c;
  cnt[c]++;
  for (int nxt = 0; nxt < n; nxt++) {
    if (!grh[crr][nxt]) {
      if (col[nxt] == -1) {
        dfs(nxt, 1 - c, cnt);
      } else if (col[nxt] == c) {
        err();
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  col.resize(n, -1);
  grh.resize(n, vector<int>(n, 0));
  for (int i = 0; i < n; i++) {
    grh[i][i] = 1;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    grh[a][b] = grh[--b][--a] = 1;
  }
  vector<int> pbl(n + 1, false);
  pbl[0] = true;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (col[i] == -1) {
      vector<int> cnt(2, 0);
      dfs(i, 0, cnt);
      sum += cnt[0] + cnt[1];
      for (int j = sum; j >= 0; j--) {
        pbl[j] = (j >= cnt[0] && pbl[j - cnt[0]]) ||
                 (j >= cnt[1] && pbl[j - cnt[1]]);
      }
    }
  }
  int maxv = 0;
  for (int i = 0; i <= n / 2; i++) {
    if (pbl[i])
      chmax(maxv, i);
  }
  long long ret = (long long)maxv * (maxv - 1) / 2 +
                  (long long)(n - maxv) * (n - maxv - 1) / 2;
  cout << ret << '\n';
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> col;
vector<vector<int>> grh;
void err() {
  cout << -1 << '\n';
  exit(0);
}
inline void chmax(int &a, int b) {
  if (a < b)
    a = b;
}
void dfs(int crr, int c, vector<int> &cnt) {
  col[crr] = c;
  cnt[c]++;
  for (int nxt = 0; nxt < n; nxt++) {
    if (!grh[crr][nxt]) {
      if (col[nxt] == -1) {
        dfs(nxt, 1 - c, cnt);
      } else if (col[nxt] == c) {
        err();
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  col.resize(n, -1);
  grh.resize(n, vector<int>(n, 0));
  for (int i = 0; i < n; i++) {
    grh[i][i] = 1;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    grh[a][b] = grh[b][a] = 1;
  }
  vector<int> pbl(n + 1, false);
  pbl[0] = true;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (col[i] == -1) {
      vector<int> cnt(2, 0);
      dfs(i, 0, cnt);
      sum += cnt[0] + cnt[1];
      for (int j = sum; j >= 0; j--) {
        pbl[j] = (j >= cnt[0] && pbl[j - cnt[0]]) ||
                 (j >= cnt[1] && pbl[j - cnt[1]]);
      }
    }
  }
  int maxv = 0;
  for (int i = 0; i <= n / 2; i++) {
    if (pbl[i])
      chmax(maxv, i);
  }
  long long ret = (long long)maxv * (maxv - 1) / 2 +
                  (long long)(n - maxv) * (n - maxv - 1) / 2;
  cout << ret << '\n';
  return 0;
}
Problem p03321 (C++)

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;

const int len = 705;
ii edge[len * len];
int dp[len][len], vis[len], mat[len][len], n, m;
vector<int> vec, adj[len];

int dfs(int u, int t) {
  vis[u] = t;

  int ans = 0;
  if (t == 1)
    ans++;
  else
    ans--;
  for (int v = 1; v <= n; v++) {
    if (v != u && mat[u][v] && !vis[v]) {
      if (t == 1)
        ans += dfs(v, 2);
      else
        ans += dfs(v, 1);
    }
  }

  return ans;
}

int solve(int i, int j) {
  if (i == vec.size())
    return j;

  int ans = min(solve(i + 1, abs(j - vec[i])), solve(i + 1, abs(j + vec[i])));
  return dp[i][j] = ans;
}

int main() {
  scanf("%d %d", &n, &m);

  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      mat[i][j] = 1;

  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    mat[a][b] = mat[b][a] = 0;
  }

  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      int temp = dfs(i, 1);
      vec.pb(temp);
    }

  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i == j || mat[i][j] == 0)
        continue;

      if (vis[i] == vis[j]) {
        printf("-1\n");
        return 0;
      }
    }

  for (int i = 0; i < vec.size(); i++)
    for (int j = 0; j <= n; j++)
      dp[i][j] = -1;

  int a = (n + solve(0, 0)) / 2, b = n - a;
  printf("%d\n", (a * (a - 1)) / 2 + (b * (b - 1)) / 2);
  return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;

const int len = 705;
ii edge[len * len];
int dp[len][len], vis[len], mat[len][len], n, m;
vector<int> vec, adj[len];

int dfs(int u, int t) {
  vis[u] = t;

  int ans = 0;
  if (t == 1)
    ans++;
  else
    ans--;
  for (int v = 1; v <= n; v++) {
    if (v != u && mat[u][v] && !vis[v]) {
      if (t == 1)
        ans += dfs(v, 2);
      else
        ans += dfs(v, 1);
    }
  }

  return ans;
}

int solve(int i, int j) {
  if (i == vec.size())
    return j;
  if (dp[i][j] != -1)
    return dp[i][j];

  int ans = min(solve(i + 1, abs(j - vec[i])), solve(i + 1, abs(j + vec[i])));
  return dp[i][j] = ans;
}

int main() {
  scanf("%d %d", &n, &m);

  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      mat[i][j] = 1;

  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    mat[a][b] = mat[b][a] = 0;
  }

  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      int temp = dfs(i, 1);
      vec.pb(temp);
    }

  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i == j || mat[i][j] == 0)
        continue;

      if (vis[i] == vis[j]) {
        printf("-1\n");
        return 0;
      }
    }

  for (int i = 0; i < vec.size(); i++)
    for (int j = 0; j <= n; j++)
      dp[i][j] = -1;

  int a = (n + solve(0, 0)) / 2, b = n - a;
  printf("%d\n", (a * (a - 1)) / 2 + (b * (b - 1)) / 2);
  return 0;
}
Problem p03321 (C++)

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

using namespace std;

#define to(k) E[k].to
#define next(k) E[k].next

const int N = 3050;

struct edge {
  int to;
  int next;
} E[N * 2];

int res;
int ctn;
int n, m;
int nienie;
int vis[N];
int clr[N];
int cnt[2];
int head[N];
bool A[N][N];
bitset<N * N> ans;

void add(int x, int y) {
  to(++ctn) = y;
  next(ctn) = head[x];
  head[x] = ctn;
}
void dfs(int x, int c) {
  vis[x] = 1;
  clr[x] = c;
  cnt[c]++;
  for (int k = head[x]; k; k = next(k))
    if (!vis[to(k)])
      dfs(to(k), c ^ 1);
    else if (clr[to(k)] == c)
      return nienie = 1, void();
}
int calc(int x) { return x * (x - 1) + (n - x) * (n - x - 1); }
int main() {
  cin >> n >> m;
  ans[0] = 1;
  int u, v;
  res = 1000000000;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &u, &v);
    A[u][v] = A[v][u] = 1;
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (!A[i][j] && (i ^ j))
        add(i, j);
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      cnt[0] = cnt[1] = 0;
      dfs(i, 0);
      ans = (ans << cnt[0]) | (ans << cnt[1]);
    }
  }
  if (nienie)
    return puts("-1"), 0;
  for (int i = 1; i <= n; ++i)
    if (ans[i])
      res = min(res, calc(i));
  return cout << res / 2 << endl, 0;
}


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

using namespace std;

#define to(k) E[k].to
#define next(k) E[k].next

const int N = 3050;

struct edge {
  int to;
  int next;
} E[N * N];

int res;
int ctn;
int n, m;
int nienie;
int vis[N];
int clr[N];
int cnt[2];
int head[N];
bool A[N][N];
bitset<N * N> ans;

void add(int x, int y) {
  to(++ctn) = y;
  next(ctn) = head[x];
  head[x] = ctn;
}
void dfs(int x, int c) {
  vis[x] = 1;
  clr[x] = c;
  cnt[c]++;
  for (int k = head[x]; k; k = next(k))
    if (!vis[to(k)])
      dfs(to(k), c ^ 1);
    else if (clr[to(k)] == c)
      return nienie = 1, void();
}
int calc(int x) { return x * (x - 1) + (n - x) * (n - x - 1); }
int main() {
  cin >> n >> m;
  ans[0] = 1;
  int u, v;
  res = 1000000000;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &u, &v);
    A[u][v] = A[v][u] = 1;
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (!A[i][j] && (i ^ j))
        add(i, j);
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      cnt[0] = cnt[1] = 0;
      dfs(i, 0);
      ans = (ans << cnt[0]) | (ans << cnt[1]);
    }
  }
  if (nienie)
    return puts("-1"), 0;
  for (int i = 1; i <= n; ++i)
    if (ans[i])
      res = min(res, calc(i));
  return cout << res / 2 << endl, 0;
}
Problem p03322 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;
map<unsigned long long, int> M;
const unsigned long long key = 1e9 + 7, N = 110000;
unsigned long long invkey;
char ch[N + 10];
int n;
unsigned long long quick(unsigned long long k1, unsigned long long k2) {
  unsigned long long k3 = 1;
  while (k2) {
    if (k2 & 1)
      k3 *= k1;
    k1 *= k1;
    k2 >>= 1;
  }
  return k3;
}
unsigned long long mul = 0, add = 0;
unsigned long long getall() {
  unsigned long long k1 = 1, ans = 0;
  for (int i = 1; i <= n; i++)
    if (ch[i] == '+')
      ans += k1;
    else if (ch[i] == '-')
      ans -= k1;
    else if (ch[i] == '>')
      k1 *= key;
    else
      k1 *= invkey;
  return ans;
}
unsigned long long getb(unsigned long long ke, unsigned long long a,
                        unsigned long long b) {
  return (ke - b) * quick(a, (1ull << 63) - 1);
}
int main() {
  scanf("%d", &n);
  scanf("%s", ch + 1);
  invkey = quick(key, (1ull << 63) - 1);
  unsigned long long ke = getall();
  unsigned long long a = 1, b = 0;
  long long ans = 0;
  for (int i = n; i; i--) {
    ans += M[getb(ke, a, b)];
    M[getb(0, a, b)]++;
    if (ch[i] == '+')
      b++;
    else if (ch[i] == '-')
      b--;
    else if (ch[i] == '>')
      b *= key, a *= key;
    else if (ch[i] == '<')
      b *= invkey, a *= invkey;
  }
  ans += M[getb(ke, a, b)];
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;
map<unsigned long long, int> M;
const unsigned long long key = 1e9 + 7, N = 260000;
unsigned long long invkey;
char ch[N + 10];
int n;
unsigned long long quick(unsigned long long k1, unsigned long long k2) {
  unsigned long long k3 = 1;
  while (k2) {
    if (k2 & 1)
      k3 *= k1;
    k1 *= k1;
    k2 >>= 1;
  }
  return k3;
}
unsigned long long mul = 0, add = 0;
unsigned long long getall() {
  unsigned long long k1 = 1, ans = 0;
  for (int i = 1; i <= n; i++)
    if (ch[i] == '+')
      ans += k1;
    else if (ch[i] == '-')
      ans -= k1;
    else if (ch[i] == '>')
      k1 *= key;
    else
      k1 *= invkey;
  return ans;
}
unsigned long long getb(unsigned long long ke, unsigned long long a,
                        unsigned long long b) {
  return (ke - b) * quick(a, (1ull << 63) - 1);
}
int main() {
  scanf("%d", &n);
  scanf("%s", ch + 1);
  invkey = quick(key, (1ull << 63) - 1);
  unsigned long long ke = getall();
  unsigned long long a = 1, b = 0;
  long long ans = 0;
  for (int i = n; i; i--) {
    ans += M[getb(ke, a, b)];
    M[getb(0, a, b)]++;
    if (ch[i] == '+')
      b++;
    else if (ch[i] == '-')
      b--;
    else if (ch[i] == '>')
      b *= key, a *= key;
    else if (ch[i] == '<')
      b *= invkey, a *= invkey;
  }
  ans += M[getb(ke, a, b)];
  cout << ans << endl;
}
Problem p03322 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int n;
int powi(int a, int b, int m) {
  int c = 1;
  for (; b; b >>= 1, a = 1ll * a * a % m)
    if (b & 1)
      c = 1ll * c * a % m;
  return c;
}
const int BAS = 233;
const int MOD1 = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int BIV1 = powi(BAS, MOD1 - 2, MOD1);
const int BIV2 = powi(BAS, MOD2 - 2, MOD2);
const int N = 200000;
char st[N];
pair<int, int> V[N], S[N];
map<pair<int, int>, int> C;
LL res;
int main() {
  scanf("%d", &n);
  scanf("%s", st + 1);
  V[0] = make_pair(1, 1);
  for (int i = 1; i <= n; ++i) {
    if (st[i] == '>')
      V[i] = make_pair(1ll * V[i - 1].first * BAS % MOD1,
                       1ll * V[i - 1].second * BAS % MOD2),
      S[i] = S[i - 1];
    else if (st[i] == '<')
      V[i] = make_pair(1ll * V[i - 1].first * BIV1 % MOD1,
                       1ll * V[i - 1].second * BIV2 % MOD2),
      S[i] = S[i - 1];
    else if (st[i] == '+')
      V[i] = V[i - 1], S[i] = make_pair((S[i - 1].first + V[i].first) % MOD1,
                                        (S[i - 1].second + V[i].second) % MOD2);
    else if (st[i] == '-')
      V[i] = V[i - 1],
      S[i] = make_pair((S[i - 1].first - V[i].first + MOD1) % MOD1,
                       (S[i - 1].second - V[i].second + MOD2) % MOD2);
  }
  for (int i = n; ~i; --i) {
    res += C[make_pair((1ll * S[n].first * V[i].first + S[i].first) % MOD1,
                       (1ll * S[n].second * V[i].second + S[i].second) % MOD2)];
    C[S[i]]++;
  }
  printf("%lld\n", res);
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int n;
int powi(int a, int b, int m) {
  int c = 1;
  for (; b; b >>= 1, a = 1ll * a * a % m)
    if (b & 1)
      c = 1ll * c * a % m;
  return c;
}
const int BAS = 233;
const int MOD1 = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int BIV1 = powi(BAS, MOD1 - 2, MOD1);
const int BIV2 = powi(BAS, MOD2 - 2, MOD2);
const int N = 500000;
char st[N];
pair<int, int> V[N], S[N];
map<pair<int, int>, int> C;
LL res;
int main() {
  scanf("%d", &n);
  scanf("%s", st + 1);
  V[0] = make_pair(1, 1);
  for (int i = 1; i <= n; ++i) {
    if (st[i] == '>')
      V[i] = make_pair(1ll * V[i - 1].first * BAS % MOD1,
                       1ll * V[i - 1].second * BAS % MOD2),
      S[i] = S[i - 1];
    else if (st[i] == '<')
      V[i] = make_pair(1ll * V[i - 1].first * BIV1 % MOD1,
                       1ll * V[i - 1].second * BIV2 % MOD2),
      S[i] = S[i - 1];
    else if (st[i] == '+')
      V[i] = V[i - 1], S[i] = make_pair((S[i - 1].first + V[i].first) % MOD1,
                                        (S[i - 1].second + V[i].second) % MOD2);
    else if (st[i] == '-')
      V[i] = V[i - 1],
      S[i] = make_pair((S[i - 1].first - V[i].first + MOD1) % MOD1,
                       (S[i - 1].second - V[i].second + MOD2) % MOD2);
  }
  for (int i = n; ~i; --i) {
    res += C[make_pair((1ll * S[n].first * V[i].first + S[i].first) % MOD1,
                       (1ll * S[n].second * V[i].second + S[i].second) % MOD2)];
    C[S[i]]++;
  }
  printf("%lld\n", res);
}
Problem p03322 (C++)

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

#define Set(a, b) memset(a, b, sizeof(a))
#define For(i, j, k) for (int i = j; i <= k; ++i)
#define Forr(i, j, k) for (int i = j; i >= k; --i)

using namespace std;

typedef long long ll;

inline void File() {
  freopen("f.in", "r", stdin);
  freopen("f.out", "w", stdout);
}

const int N = 2e5 + 10;
int n;
char s[N];
ll st[N], p[N];

const ll mod = 1000000000000000031ll;
const ll gkk = 1000000000000000003ll;
const ll hany01 = 821428571428571454ll;

ll mul(ll a, ll b) { return (__int128)a * b % mod; }
ll add(ll a, ll b) { return (a += b) >= mod ? a - mod : a; }

unordered_map<ll, int> mp;

int main() {

  cin >> n, scanf("%s", s + 1);

  p[0] = 1;
  For(i, 1, n) {
    st[i] = st[i - 1], p[i] = p[i - 1];
    if (s[i] == '+')
      st[i] = add(st[i], p[i]);
    if (s[i] == '-')
      st[i] = add(st[i], mod - p[i]);
    if (s[i] == '>')
      p[i] = mul(p[i], gkk);
    if (s[i] == '<')
      p[i] = mul(p[i], hany01);
  }

  ll ans = 0;
  Forr(i, n, 1) {
    ++mp[st[i]];
    ans += mp[add(mul(st[n], p[i - 1]), st[i - 1])];
  }

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


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

#define Set(a, b) memset(a, b, sizeof(a))
#define For(i, j, k) for (int i = j; i <= k; ++i)
#define Forr(i, j, k) for (int i = j; i >= k; --i)

using namespace std;

typedef long long ll;

inline void File() {
  freopen("f.in", "r", stdin);
  freopen("f.out", "w", stdout);
}

const int N = 2.5e5 + 10;
int n;
char s[N];
ll st[N], p[N];

const ll mod = 1000000000000000031ll;
const ll gkk = 1000000000000000003ll;
const ll hany01 = 821428571428571454ll;

ll mul(ll a, ll b) { return (__int128)a * b % mod; }
ll add(ll a, ll b) { return (a += b) >= mod ? a - mod : a; }

unordered_map<ll, int> mp;

int main() {

  cin >> n, scanf("%s", s + 1);

  p[0] = 1;
  For(i, 1, n) {
    st[i] = st[i - 1], p[i] = p[i - 1];
    if (s[i] == '+')
      st[i] = add(st[i], p[i]);
    if (s[i] == '-')
      st[i] = add(st[i], mod - p[i]);
    if (s[i] == '>')
      p[i] = mul(p[i], gkk);
    if (s[i] == '<')
      p[i] = mul(p[i], hany01);
  }

  ll ans = 0;
  Forr(i, n, 1) {
    ++mp[st[i]];
    ans += mp[add(mul(st[n], p[i - 1]), st[i - 1])];
  }

  cout << ans << endl;
  return 0;
}
Problem p03323 (Python)

Buggy submission (status: Runtime Error):
a, b = int(input()), int(input())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")


Fixed submission:
a, b = map(int, input().split())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")
Problem p03323 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int d, n, sum, t;
  cin >> d >> n;
  for (int i; i < 100; i++) {
    if (100 % i == 0) {
      sum = i;
      t++;
    }
    if (t == n)
      cout << i;
    break;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a > 8 || b > 8) {
    cout << ":(";
  } else {
    cout << "Yay!";
  }
  return 0;
}
Problem p03323 (Python)

Buggy submission (status: Runtime Error):
a = int(input())
b = int(input())

if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")


Fixed submission:
a, b = map(int, input().split())

if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")
Problem p03323 (C++)

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

using namespace std;

typedef long long ll;
ll mod = 1000000007, oo = 1000000009;

void Emsawy() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

#define clr(v, d) memset(v, d, sizeof(v))
#define sz(v) ((int)((v).size()))
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define V vector
#define MP make_pair
#define bug(n) cout << #n << " = " << n << endl;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

V<V<int>> adj;
const ll N = 100000 + 5;
int n, m, k, w;

int main() {

  Emsawy();
  int a, b;
  while (cin >> a >> b) {
    if (a <= 8 && b <= 8)
      cout << "Yay!" << endl;
    else
      cout << ":(" << endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
ll mod = 1000000007, oo = 1000000009;

void Emsawy() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

#define clr(v, d) memset(v, d, sizeof(v))
#define sz(v) ((int)((v).size()))
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define V vector
#define MP make_pair
#define bug(n) cout << #n << " = " << n << endl;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

V<V<int>> adj;
const ll N = 100000 + 5;
int n, m, k, w;

int main() {

  // Emsawy();
  int a, b;
  while (cin >> a >> b) {
    if (a <= 8 && b <= 8)
      cout << "Yay!" << endl;
    else
      cout << ":(" << endl;
  }
  return 0;
}
Problem p03323 (C++)

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

#define FIO                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0)
#define mod 1000000007
#define setbits __builtin_popcount
#define gcd __gcd
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repr(i, b, a) for (int i = b; i >= a; i--)
#define forn(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define in(a, b) ((b).find(a) != (b).end())
#define pb push_back
#define fill(a, v) memset(a, v, sizeof a)
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define eps 1e-6
#define minin(a) *min_element(all(a))
#define maxin(a) *max_element(all(a))
#define asort(c) sort(all(c))
#define dsort(c) sort(all(c), greater<int>())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef unordered_map<int, int> mii;
typedef vector<ll> vll;
typedef long double ld;

int main() {
  FIO;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  int a, b;
  cin >> a >> b;
  if (abs(a - b) > 1)
    cout << ":(";
  else
    cout << "Yay!";

  return 0;
}

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

#define FIO                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0)
#define mod 1000000007
#define setbits __builtin_popcount
#define gcd __gcd
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repr(i, b, a) for (int i = b; i >= a; i--)
#define forn(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define in(a, b) ((b).find(a) != (b).end())
#define pb push_back
#define fill(a, v) memset(a, v, sizeof a)
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define eps 1e-6
#define minin(a) *min_element(all(a))
#define maxin(a) *max_element(all(a))
#define asort(c) sort(all(c))
#define dsort(c) sort(all(c), greater<int>())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef unordered_map<int, int> mii;
typedef vector<ll> vll;
typedef long double ld;

int main() {
  FIO;
  /* #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
   #endif */

  int a, b;
  cin >> a >> b;
  if (abs(a - b) > 1)
    cout << ":(";
  else
    cout << "Yay!";

  return 0;
}
Problem p03323 (Python)

Buggy submission (status: Runtime Error):
a = int(input())
b = int(input())

if a >= 9 or b >= 9:
    print(":(")
else:
    print("Yay!")


Fixed submission:
a, b = map(int, input().split())

if a >= 9 or b >= 9:
    print(":(")
else:
    print("Yay!")
Problem p03323 (Python)

Buggy submission (status: Runtime Error):
# -*- coding: utf-8 -*-

a = int(input())
b = int(input())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")


Fixed submission:
# -*- coding: utf-8 -*-

a, b = map(int, input().split())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")
Problem p03323 (Python)

Buggy submission (status: Runtime Error):
a = int(input())
b = int(input())

if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")


Fixed submission:
a, b = list(map(int, input().split()))

if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")
Problem p03323 (Python)

Buggy submission (status: Runtime Error):
a = int(input())
b = int(input())

if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")


Fixed submission:
a, b = (int(i) for i in input().split())

if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")
Problem p03323 (Python)

Buggy submission (status: Runtime Error):
a, b = map(int, input())
print("Yay" if a <= 8 and b <= 8 else ":(")


Fixed submission:
a, b = map(int, input().split())
print("Yay!" if a <= 8 and b <= 8 else ":(")
Problem p03323 (Python)

Buggy submission (status: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

a = int(input())
b = int(input())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")


Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

a, b = map(int, input().split())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")
Problem p03323 (C++)

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

using namespace std;

int x, y;

int main() {
  scanf("%d%d", x, y);

  if (x + y > 16) {
    printf(":(");
    return 0;
  }
  if (x > 8 || y > 8) {
    printf(":(");
    return 0;
  }

  printf("Yay!");

  return 0;
}


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

using namespace std;

int x, y;

int main() {
  scanf("%d%d", &x, &y);

  if (x + y > 16) {
    printf(":(");
    return 0;
  }
  if (x > 8 || y > 8) {
    printf(":(");
    return 0;
  }

  printf("Yay!");

  return 0;
}
Problem p03323 (Python)

Buggy submission (status: Runtime Error):
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())

if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")


Fixed submission:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())

if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")
Problem p03324 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int d, n;
  cin >> d >> n;
  int result = 1;
  while (d > 0) {
    result *= 100;
  }
  if (n == 100)
    n++;
  result *= n;
  cout << result;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int d, n;
  cin >> d >> n;
  int result = 1;
  while (d > 0) {
    result *= 100;
    d--;
  }
  if (n == 100)
    n++;
  result *= n;
  cout << result;
}
Problem p03324 (C++)

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1ll << 60;

#define FOR(i, a, b) for (ll i = (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define DEBUG(x) ;
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

int dx[4]{0, 1, 0, -1};
int dy[4]{1, 0, -1, 0};

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll D, N;
  cin >> D >> N;
  if (N == 100) {
    assert(D == 0);
    std::cout << pow(100, D) * (N + 1) << std::endl;
  } else
    std::cout << pow(100, D) * N << std::endl;
  return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1ll << 60;

#define FOR(i, a, b) for (ll i = (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define DEBUG(x) ;
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

int dx[4]{0, 1, 0, -1};
int dy[4]{1, 0, -1, 0};

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll D, N;
  cin >> D >> N;

  auto f = [&](ll n) {
    ll cnt{0};
    while (n) {
      if (n % 100 != 0)
        break;
      n /= 100;
      ++cnt;
    }
    return cnt;
  };

  ll cnt{0};
  ll res{0};
  for (ll i = 1; i < 100 * 100 * 200; ++i) {
    if (f(i) == D) {
      ++cnt;
      if (cnt == N) {
        std::cout << i << std::endl;
        return 0;
      }
    }
  }
  return 0;
}
Problem p03324 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>

using namespace std;

int main() {
  long long i, a, c, d, n;
  while (scanf("%d%d", &d, &n)) {
    for (i = 0, a = 1; i < d; i++)
      a = a * 100;
    c = n * a;
    printf("%lld\n", c);
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int i, a, c, d, n;
  scanf("%d%d", &d, &n);
  for (i = 0, a = 1; i < d; i++)
    a = a * 100;
  // a=pow(100,d);
  c = n * a;
  if (n == 100)
    c += a;
  printf("%d\n", c);
  return 0;
}
Problem p03324 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm> //sort(all(変数),greater<型名>())　で降順に
#include <bits/stdc++.h>
#include <cmath> //切り上げceil(値)
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip> //setprecision(数字)
#include <iostream>
#include <list>
#include <map>
#include <numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include <queue> //priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define rep0(i, n) for (ll i = 0; i < n; i++)
#define rrep0(i, n) for (ll i = n - 1; 0 <= i; i--)
#define rep1(i, n) for (ll i = 1; i <= n; i++)
#define rrep1(i, n) for (ll i = n; 1 <= i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int main() {
  int d, n;
  cin >> d >> n;
  rep0(i, mod) {
    if (i % d * 100 == 0) {
      n--;
    }
    if (n == 0) {
      cout << i;
      return 0;
    }
  }
}


Fixed submission:
#include <algorithm> //sort(all(変数),greater<型名>())　で降順に
#include <bits/stdc++.h>
#include <cmath> //切り上げceil(値)
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip> //setprecision(数字)
#include <iostream>
#include <list>
#include <map>
#include <numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include <queue> //priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define rep0(i, n) for (ll i = 0; i < n; i++)
#define rrep0(i, n) for (ll i = n - 1; 0 <= i; i--)
#define rep1(i, n) for (ll i = 1; i <= n; i++)
#define rrep1(i, n) for (ll i = n; 1 <= i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int main() {
  int d, n;
  cin >> d >> n;
  if (n == 100) {
    cout << (int)pow(100, d) * (n + 1);
  } else {
    cout << (int)pow(100, d) * n;
  }
}
Problem p03324 (C++)

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

int func(int x) {
  if (x % 100 != 0)
    return 0;
  return func(x / 100) + 1;
}

int main() {
  int d, n;
  cin >> d >> n;
  int cnt = 0;
  for (int i = 0;; i++) {
    if (func(i) == n) {
      cout << i;
      return 0;
    }
  }
  return 0;
}


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

int func(int x) {
  if (x % 100 != 0)
    return 0;
  return func(x / 100) + 1;
}

int main() {
  int d, n;
  cin >> d >> n;
  int cnt = 0;
  for (int i = 1;; i++) {
    if (func(i) == d) {
      cnt++;
      if (cnt == n) {
        cout << i;
        return 0;
      }
    }
  }
  return 0;
}
Problem p03324 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <iostream>

using namespace std;

int count_div(int num) {
  int res = 0;
  while (num % 100 == 0) {
    ++res;
    res /= 100;
  }
  return res;
}

int main(void) {
  int D, N;
  cin >> D >> N;
  int count = 0;
  bool find = false;
  for (int i = 1; !find; ++i) {
    if (count_div(i) == D) {
      ++count;
      if (count == N) {
        cout << i << endl;
        find = true;
      }
    }
  }

  return 0;
}


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

using namespace std;

int count_div(int num) {
  int res = 0;
  while (num % 100 == 0) {
    ++res;
    num /= 100;
  }
  return res;
}

int main(void) {
  int D, N;
  cin >> D >> N;
  int count = 0;
  bool find = false;
  for (int i = 1; !find; ++i) {
    if (count_div(i) == D) {
      ++count;
      if (count == N) {
        cout << i << endl;
        find = true;
      }
    }
  }

  return 0;
}
Problem p03324 (Python)

Buggy submission (status: Runtime Error):
D, N = map(int, input().split())
nums = []
for i in range(1, 10**6):
    num = 100**D * i
    if num % 100 == D:
        nums.append(num)

print(nums[N - 1])


Fixed submission:
D, N = map(int, input().split())
nums = []
for i in range(120):
    if i % 100 == 0:
        continue
    nums.append(100**D * i)

print(nums[N - 1])
Problem p03324 (Python)

Buggy submission (status: Time Limit Exceeded):
def main():
    D, N = list(map(int, input().split()))
    mod = 100**D
    cnt = 0
    i = 1
    while True:
        if i % 100 == 0:
            continue
        if i % mod == 0:
            cnt += 1
        if cnt == N:
            print(i)
            break
        i += 1


if __name__ == "__main__":
    main()


Fixed submission:
D, N = map(int, input().split())
if N < 100:
    print(N * (100**D))
else:
    print(101 * (100**D))
Problem p03324 (C++)

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

using namespace std;
int main() {
  int d, n;
  cin >> d >> n;
  vector<int> v;

  int base = 0;
  int inc = 0;
  switch (d) {
  case 0:
    base = 1;
    inc = 1;
    break;
  case 1:
    base = 100;
    inc = 100;
    break;
  case 2:
    base = 10000;
    inc = 10000;
    break;
  }

  for (int i = 0; i < 101; i++) {
    int work = base + inc * i;
    if (work % 100 == 0)
      continue;
    v.push_back(base + inc * i);
  }

  cout << v.at(n - 1) << endl;

  return 0;
}

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

using namespace std;
int main() {
  int d, n;
  cin >> d >> n;
  vector<int> v;

  int base = 0;
  int inc = 0;
  switch (d) {
  case 0:
    base = 1;
    inc = 1;
    break;
  case 1:
    base = 100;
    inc = 100;
    break;
  case 2:
    base = 10000;
    inc = 10000;
    break;
  }

  for (int i = 0; i < 101; i++) {
    int work = base + inc * i;
    if (d == 0 && work % 100 == 0)
      continue;
    if (d == 1 && work % 10000 == 0)
      continue;
    if (d == 2 && work % 1000000 == 0)
      continue;
    v.push_back(base + inc * i);
  }

  cout << v.at(n - 1) << endl;

  return 0;
}
Problem p03324 (C++)

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

int main() {
  int d, n;
  cin >> d >> n;
  int a = pow(100, d);
  cout << a * ((n - 1) / (a - 1) * a + (n - 1) % (a - 1) + 1) << endl;
}

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

int main() {
  int d, n;
  cin >> d >> n;
  int a = 1;
  rep(i, 0, d) a *= 100;
  if (n < 100)
    cout << n * a;
  else
    cout << 101 * a;
}
Problem p03324 (C++)

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

using namespace std;

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

  int d, n;
  cin >> d >> n;

  int ans = 1;
  int n2 = n;

  while (n % 100 == 0) {
    n2++;
    n / 100;
  }

  for (int i = 0; i < d; i++) {
    ans *= 100;
  }

  cout << ans * n2 << endl;

  return 0;
}


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

using namespace std;

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

  int d, n;
  cin >> d >> n;

  int ans = 1;
  int n2 = n;

  while (n % 100 == 0) {
    n2++;
    n /= 100;
  }

  for (int i = 0; i < d; i++) {
    ans *= 100;
  }

  cout << ans * n2 << endl;

  return 0;
}
Problem p03324 (C++)

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

int func(int x) {
  if (x % 100 != 0)
    return 0;
  return func(x / 100) + 1;
}

int main() {
  int D, N;
  cin >> D >> N;
  int cnt = 0;
  for (int i = 1;; i++) {
    if (func(i) == D) {
      cnt++;
      if (cnt == N) {
        cout << i << endl;
      }
    }
  }
  return 0;
}


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

int func(int x) {
  if (x % 100 != 0)
    return 0;
  return func(x / 100) + 1;
}

int main() {
  int D, N;
  cin >> D >> N;
  int cnt = 0;
  for (int i = 1;; i++) {
    if (func(i) == D) {
      cnt++;
      if (cnt == N) {
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}
Problem p03324 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int d, n, m;
  cin >> d >> n;
  n--;
  m = n / 99 * 100 + n % 99 + 1;
  while (d)
    m *= 100;
  cout << m << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int d, n, m;
  cin >> d >> n;
  n--;
  m = n / 99 * 100 + n % 99 + 1;
  while (d--)
    m *= 100;
  cout << m << endl;
}
Problem p03325 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
typedef long long i64;
int main() {
  int N;
  cin >> N;
  long long int a[N];
  rep(i, N) cin >> a[i];
  int count = 0;
  rep(i, N) {
    while (a[i] % 2 == 0) {
      a[i] / 2;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
typedef long long i64;
int main() {
  int N;
  cin >> N;
  long long int a[N];
  rep(i, N) cin >> a[i];
  int count = 0;
  rep(i, N) {
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
Problem p03325 (C++)

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

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

  vector<int> data(n);
  for (int i = 0; i < n; i++) {
    cin >> data.at(n);
  }

  int64_t count = 0;
  for (int i = 0; i < n; i++) {
    while (data.at(i) % 2 == 0) {
      count++;
      data.at(i) /= 2;
    }
  }

  cout << count << endl;
}

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

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

  vector<int> data(n);
  for (int i = 0; i < n; i++) {
    cin >> data.at(i);
  }

  int64_t count = 0;
  for (int i = 0; i < n; i++) {
    while (data.at(i) % 2 == 0) {
      count++;
      data.at(i) /= 2;
    }
  }

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

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

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) { cin >> A[i]; }

  ll ans = 0;
  while (1) {
    ll tar = -1; // 2で割られる数のインデックス
    rep(i, N) {
      if (A[i] % 2 == 0) {
        if (tar == -1)
          tar = i;
        else if (A[i] % 4 == 0)
          tar = i;
      }
    }
    if (tar != -1) {
      A[tar] /= 2;
      ans++;
    } else
      break;
  }

  cout << ans << endl;
}

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

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) { cin >> A[i]; }

  ll ans = 0;
  while (1) {
    ll tar = -1; // 2で割られる数のインデックス
    rep(i, N) {
      if (A[i] % 2 == 0) {
        if (tar == -1)
          tar = i;
        else if (A[i] % 4 == 0) {
          A[i] /= 2;
          ans++;
          break;
        }
      }
    }
    if (tar != -1) {
      A[tar] /= 2;
      ans++;
    } else
      break;
  }

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

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

#define FAST                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie();                                                                   \
  cout.tie();

#define MAXX 10005

#define PI 3.14159265358979323846264338327950

#define F first
#define S second

#define ll long long int

#define mod 1000000007

int main() {
  FAST;
  ll n;
  cin >> n;
  ll a = 0;
  for (ll i = 0; i < n; i++) {
    ll x;
    cin >> x;
    while (x % 2 == 0) {
      a++;
    }
  }
  cout << a;
  return 0;
}

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

#define FAST                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie();                                                                   \
  cout.tie();

#define MAXX 10005

#define PI 3.14159265358979323846264338327950

#define F first
#define S second

#define ll long long int

#define mod 1000000007

int main() {
  FAST;
  ll n;
  cin >> n;
  ll a = 0;
  for (ll i = 0; i < n; i++) {
    ll x;
    cin >> x;
    while (x % 2 == 0) {
      a++;
      x /= 2;
    }
  }
  cout << a;
  return 0;
}
Problem p03325 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <math.h>

int main() {
  int N;
  int mul = 1;
  int a_i;
  int count = 0;
  std::cin >> N;
  for (int i = 1; i < N + 1; i++) {
    std::cin >> a_i;
    mul = mul * a_i;
  }
  while (mul % 2 == 0) {
    count++;
    mul = mul / 2;
  }
  std::cout << count;
}


Fixed submission:
#include <iostream>
#include <math.h>

int main() {
  int N;
  int mul = 1;
  int a_i;
  int count = 0;
  std::cin >> N;
  for (int i = 1; i < N + 1; i++) {
    std::cin >> a_i;
    while (a_i % 2 == 0) {
      count++;
      a_i = a_i / 2;
    }
  }
  std::cout << count;
}
Problem p03325 (C++)

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

int main() {
  int a;
  int count;
  int max = 0;

  cin >> a;
  int total[a];
  for (int i = 0; i < a; i++) {
    cin >> total[i];
  }
  for (int i = 0; i < a; i++) {
    int tmp;
    while (1) {
      tmp = total[i] % 2;
      if (tmp == 1)
        break;
      count++;
    }
    if (max < count)
      max = count;
  }
  cout << count << endl;
}


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

int main() {
  int a;
  int count;
  int max = 0;

  cin >> a;
  int total[a];
  for (int i = 0; i < a; i++) {
    cin >> total[i];
  }
  for (int i = 0; i < a; i++) {
    int tmp;
    while (1) {
      tmp = total[i] % 2;
      if (tmp == 1)
        break;
      total[i] /= 2;
      count++;
    }
    if (max < count)
      max = count;
  }
  cout << count << endl;
}
Problem p03325 (C++)

Buggy submission (status: Runtime Error):
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
  int i, n, cont = 0;
  long long a[10];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%lld", &a[i]);
  for (i = 0; i < n; i++) {
    while (a[i] % 2 == 0) {
      cont++;
      a[i] = a[i] / 2;
    }
  }
  printf("%d\n", cont);
  return 0;
}


Fixed submission:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
  int i, n, cont = 0;
  long long a[10010];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%lld", &a[i]);
  for (i = 0; i < n; i++) {
    while (a[i] % 2 == 0) {
      cont++;
      a[i] = a[i] / 2;
    }
  }
  printf("%d\n", cont);
  return 0;
}