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

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

using namespace std;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  int sup = h;
  vector<vector<int>> cnt(h);
  string *s = new string[h];
  int **ans = new int *[h];

  for (int i = 0; i < h; i++) {
    ans[i] = new int[w];
    cin >> s[i];
    int sz = 0;
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        cnt[i].push_back(j);
        sz++;
      }
    }
    if (sz == 0 && sup == h)
      sup = i;
  }

  int l = 1;
  for (int i = 0; i < h; i++) {

    if (cnt[i].size() == 0)
      continue;

    else {
      int m = 0;
      int sz = cnt[i].size();
      while (sz > 1) {
        bool can = false;
        while (s[i][m] != '#' || !can) {
          if (s[i][m] == '#')
            can = true;
          ans[i][m] = l;
          m++;
        }
        l++;
        sz--;
      }
      for (int a = m; a < w; a++)
        ans[i][a] = l;
      l++;
    }
  }

  for (int i = 0; i < h; i++) {
    if (cnt[i].size() == 0 && i == 0) {
      int m = i + 1;
      while (!cnt[m].size())
        m++;
      for (int j = 0; j < w; j++) {
        ans[i][j] = ans[m][j];
      }
    } else if (cnt[i].size() == 0) {
      int m = i - 1;
      while (!cnt[m].size())
        m--;
      for (int j = 0; j < w; j++) {
        ans[i][j] = ans[m][j];
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
}

Fixed submission:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  int sup = h;
  vector<vector<int>> cnt(h);
  string *s = new string[h];
  int **ans = new int *[h];

  for (int i = 0; i < h; i++) {
    ans[i] = new int[w];
    cin >> s[i];
    int sz = 0;
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        cnt[i].push_back(j);
        sz++;
      }
    }
    if (sz == 0 && sup == h)
      sup = i;
  }

  int l = 1;
  for (int i = 0; i < h; i++) {

    if (cnt[i].size() == 0)
      continue;

    else {
      int m = 0;
      int sz = cnt[i].size();
      while (sz > 1) {
        bool can = false;
        while (s[i][m] != '#' || !can) {
          if (s[i][m] == '#')
            can = true;
          ans[i][m] = l;
          m++;
        }
        l++;
        sz--;
      }
      for (int a = m; a < w; a++)
        ans[i][a] = l;
      l++;
    }
  }

  for (int i = 0; i < h; i++) {
    if (cnt[i].size() == 0 && i == 0) {
      int m = i + 1;
      while (!cnt[m].size())
        m++;
      for (int j = 0; j < w; j++) {
        ans[i][j] = ans[m][j];
      }
    } else if (cnt[i].size() == 0) {
      int m = i - 1;
      while (!ans[m][0])
        m--;
      for (int j = 0; j < w; j++) {
        ans[i][j] = ans[m][j];
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
}
Problem p02855 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <random>
#include <string>
#include <vector>

// 使い方がよくわからない
#include <bitset>
#include <queue>
#include <sstream>
#include <stack>

#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 << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  vector<vector<int>> vec(h, vector<int>(w, 0));
  ll fi = 0;
  ll ki = 0;

  rep(i, h) {
    vector<int> pl;
    pl.push_back(-1);
    rep(j, w) {
      if (s[i][j] == '#') {
        pl.push_back(j);
      }
    }
    pl[pl.size() - 1] = w;
    rep(l, pl.size() - 1) {
      ki++;
      for (int wi = pl[l] + 1; wi <= pl[l + 1]; wi++) {
        for (int hi = fi; hi <= i; hi++) {
          vec[hi][wi] = ki;
        }
      }
    }
    if (pl.size() > 1)
      fi = i + 1;
  }
  if (fi > 0) {
    for (int i = fi; i < h; i++) {
      rep(j, w) { vec[i][j] = vec[fi - 1][j]; }
    }
  }

  rep(i, h) {
    rep(j, w - 1) { cosp(vec[i][j]); }
    co(vec[i][w - 1]);
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <random>
#include <string>
#include <vector>

// 使い方がよくわからない
#include <bitset>
#include <queue>
#include <sstream>
#include <stack>

#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 << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  vector<vector<int>> vec(h, vector<int>(w, 0));
  ll fi = 0;
  ll ki = 0;

  rep(i, h) {
    vector<int> pl;
    pl.push_back(-1);
    rep(j, w) {
      if (s[i][j] == '#') {
        pl.push_back(j);
      }
    }
    pl[pl.size() - 1] = w - 1;
    rep(l, pl.size() - 1) {
      ki++;
      for (int wi = pl[l] + 1; wi <= pl[l + 1]; wi++) {
        for (int hi = fi; hi <= i; hi++) {
          vec[hi][wi] = ki;
        }
      }
    }
    if (pl.size() > 1)
      fi = i + 1;
  }
  if (fi > 0) {
    for (int i = fi; i < h; i++) {
      rep(j, w) { vec[i][j] = vec[fi - 1][j]; }
    }
  }

  rep(i, h) {
    rep(j, w - 1) { cosp(vec[i][j]); }
    co(vec[i][w - 1]);
  }
  return 0;
}
Problem p02855 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll H, W, K;
  cin >> H >> W >> K;
  vector<string> s(H);
  vector<vector<ll>> ans(H, vector<ll>(W, 0));
  vector<bool> hit(H, false);
  REP(i, H) {
    cin >> s[i];
    REP(j, W) {
      if (s[i][j] == '#') {
        hit[i] = true;
      }
    }
  }

  ll cnt = 1;
  REP(i, H) if (hit[i]) {
    REP(j, W) {
      ans[i][j] = cnt;
      if (s[i][j] == '#') {
        cnt++;
      }
    }

    if (s[i][W - 1] == '#') {
      continue;
    }
    ll p = W - 1;
    while (s[i][p] == '.') {
      ans[i][p] = cnt - 1;
      p--;
    }
  }

  REP(i, H) if (!hit[i]) {
    ll p = i;
    while (p < H && !hit[p]) {
      p++;
    }
    // 上からコピー
    if (p == W) {
      p = i;
      while (p > 0 && !hit[p]) {
        p--;
      }
    }
    REP(j, W) { ans[i][j] = ans[p][j]; }
    hit[i] = true;
  }

  REP(i, H) {
    REP(j, W) { cout << ans[i][j] << " \n"[j == W - 1]; }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll H, W, K;
  cin >> H >> W >> K;
  vector<string> s(H);
  vector<vector<ll>> ans(H, vector<ll>(W, 0));
  vector<bool> hit(H, false);
  REP(i, H) {
    cin >> s[i];
    REP(j, W) {
      if (s[i][j] == '#') {
        hit[i] = true;
      }
    }
  }

  ll cnt = 1;
  REP(i, H) if (hit[i]) {
    REP(j, W) {
      ans[i][j] = cnt;
      if (s[i][j] == '#') {
        cnt++;
      }
    }

    if (s[i][W - 1] == '#') {
      continue;
    }
    ll p = W - 1;
    while (s[i][p] == '.') {
      ans[i][p] = cnt - 1;
      p--;
    }
  }

  REP(i, H) if (!hit[i]) {
    ll p = i;
    while (p < H && !hit[p]) {
      p++;
    }
    // 上からコピー
    if (p == H) {
      p = i;
      while (p > 0 && !hit[p]) {
        p--;
      }
    }
    REP(j, W) { ans[i][j] = ans[p][j]; }
    hit[i] = true;
  }

  REP(i, H) {
    REP(j, W) { cout << ans[i][j] << " \n"[j == W - 1]; }
  }
}
Problem p02855 (C++)

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef vector<int> vi;
typedef vector<vi> vvi;

/*{
  }*/
int h, w, k;
string S[300];

int ans[301][301];
int s[301][301];

signed main() {
  cin >> h >> w >> k;
  rep(i, 0, h) cin >> S[i];

  rep(i, 0, h) rep(j, 0, w) {
    if (S[i][j] == '#') {
      s[i + 1][j + 1] = 1;
    }
  }

  rep(i, 0, h + 1) rep(j, 0, w) s[i][j + 1] += s[i][j];
  rep(i, 0, w + 1) rep(j, 0, h) s[j + 1][i] += s[j][i];

  int num = 1, cnt = 0;
  rep(i, 0, h) {
    int c = 0, next = 0;
    rep(j, 0, w) {
      if (S[i][j] == '#')
        c++;
      if (c == 2) {
        rep(u, i - cnt, i + 1) rep(k, next, j) ans[u][k] = num;
        c--;
        num++;
        next = j;
      }
    }

    if (c == 0)
      cnt++;
    else {
      rep(u, i - cnt, i + 1) rep(j, next, w) ans[u][j] = num;
      num++;
      cnt = 0;
    }
  }

  for (int i = 1; i < h; i--) {
    rep(j, 0, w) if (ans[i][j] == 0) ans[i][j] = ans[i - 1][j];
  }

  rep(i, 0, h) rep(j, 0, w) cout << ans[i][j] << " \n"[j == w - 1];

  return 0;
}


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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef vector<int> vi;
typedef vector<vi> vvi;

/*{
  }*/
int h, w, k;
string S[300];

int ans[301][301];
int s[301][301];

signed main() {
  cin >> h >> w >> k;
  rep(i, 0, h) cin >> S[i];

  rep(i, 0, h) rep(j, 0, w) {
    if (S[i][j] == '#') {
      s[i + 1][j + 1] = 1;
    }
  }

  rep(i, 0, h + 1) rep(j, 0, w) s[i][j + 1] += s[i][j];
  rep(i, 0, w + 1) rep(j, 0, h) s[j + 1][i] += s[j][i];

  int num = 1, cnt = 0;
  rep(i, 0, h) {
    int c = 0, next = 0;
    rep(j, 0, w) {
      if (S[i][j] == '#')
        c++;
      if (c == 2) {
        rep(u, i - cnt, i + 1) rep(k, next, j) ans[u][k] = num;
        c--;
        num++;
        next = j;
      }
    }

    if (c == 0)
      cnt++;
    else {
      rep(u, i - cnt, i + 1) rep(j, next, w) ans[u][j] = num;
      num++;
      cnt = 0;
    }
  }

  rep(i, 1, h) { rep(j, 0, w) if (ans[i][j] == 0) ans[i][j] = ans[i - 1][j]; }

  rep(i, 0, h) rep(j, 0, w) cout << ans[i][j] << " \n"[j == w - 1];

  return 0;
}
Problem p02856 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9 + 7;
ll c[100100], d[100100];

int main() {
  int m;
  cin >> m;
  rep(i, m) cin >> d[i] >> c[i];
  ll s = 0, len = 0;
  rep(i, m) {
    s += c[i] * d[i];
    len += c[i];
  }
  ll ans = (len - 1) + ((s - 1) / 9);
  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9 + 7;
ll c[200100], d[200100];

int main() {
  int m;
  cin >> m;
  rep(i, m) cin >> d[i] >> c[i];
  ll s = 0, len = 0;
  rep(i, m) {
    s += c[i] * d[i];
    len += c[i];
  }
  ll ans = (len - 1) + ((s - 1) / 9);
  cout << ans << endl;

  return 0;
}
Problem p02856 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int sum, tot;
int d[100001];
int c[100001];
int n;
signed main() {
  int n;
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &c[i], &d[i]);
    tot += d[i];
    sum += d[i] * c[i];
  }
  printf("%lld", (sum - 1) / 9 + tot - 1);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
int sum, tot;
int d[1000001];
int c[1000001];
int n;
signed main() {
  int n;
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &c[i], &d[i]);
    tot += d[i];
    sum += d[i] * c[i];
  }
  printf("%lld", (sum - 1) / 9 + tot - 1);
  return 0;
}
Problem p02856 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  long long ans = -1;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    long long d, c;
    scanf("%lld%lld", &d, &c);
    ans += c;
    sum += d * c;
  }
  while (sum >= 10) {
    ans += sum / 10;
    sum = sum / 10 + sum % 10;
  }
  printf("%lld\n", ans);
  return 0;
}
Problem p02856 (C++)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO                                                                 \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0);

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

const int N = (int)1e5 + 9;
ll d[N], c[N];

int main() {
  fastIO;
  int n;
  cin >> n;
  ll len = 0, sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> d[i] >> c[i];
    sum += d[i] * c[i];
    len += c[i];
  }
  ll ans = len - 1;
  if (sum >= 9)
    ans += (sum - 1) / 9;
  cout << ans << "\n";
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO                                                                 \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0);

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

const int N = (int)2e5 + 9;
ll d[N], c[N];

int main() {
  fastIO;
  int n;
  cin >> n;
  ll len = 0, sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> d[i] >> c[i];
    sum += d[i] * c[i];
    len += c[i];
  }
  ll ans = len - 1;
  if (sum >= 9)
    ans += (sum - 1) / 9;
  cout << ans << "\n";
  return 0;
}
Problem p02856 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i, a, b) for (ll i = (a); i < (b); ++i)
#define per(i, a, b) for (ll i = b - 1LL; i >= (a); --i)
#define clr(a, b) memset((a), (b), sizeof(a))
#define ctos(c) string(1, c)
#define print(x) cout << #x << " = " << x << endl;

#define MOD 10

int main() {
  ll m;
  cin >> m;
  ll a = 0;
  ll ans = 0;
  rep(i, 0, m) {
    ll d, c;
    cin >> d >> c;
    a += d * c;
    ans += c;
  }
  ans--;
  while (a > 9) {
    ll b = a / 10;
    ans += b;
    a += b;
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i, a, b) for (ll i = (a); i < (b); ++i)
#define per(i, a, b) for (ll i = b - 1LL; i >= (a); --i)
#define clr(a, b) memset((a), (b), sizeof(a))
#define ctos(c) string(1, c)
#define print(x) cout << #x << " = " << x << endl;

#define MOD 10

int main() {
  ll m;
  cin >> m;
  ll a = 0;
  ll ans = 0;
  rep(i, 0, m) {
    ll d, c;
    cin >> d >> c;
    a += d * c;
    ans += c;
  }
  ans--;
  while (a > 9) {
    ll b = a / 10;
    ans += b;
    a %= 10;
    a += b;
  }
  cout << ans << endl;
  return 0;
}
Problem p02856 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
int m, d;
long long len, sum, c;

int main() {
  scanf("%d", &m);
  len = sum = -1;
  for (int i = 0; i < m; ++i) {
    scanf("%d%lld", d, c);
    len += c;
    sum += c * d;
  }
  printf("%lld\n", len + sum / 9);
}


Fixed submission:
#include <cstdio>
int m, d;
long long len, sum, c;

int main() {
  scanf("%d", &m);
  len = sum = -1;
  for (int i = 0; i < m; ++i) {
    scanf("%d%lld", &d, &c);
    len += c;
    sum += c * d;
  }
  printf("%lld\n", len + sum / 9);
}
Problem p02858 (Python)

Buggy submission (status: Runtime Error):
from math import gcd

mod = 10**9 + 7
n, m, t = map(int, input().split())
a = gcd(n, t)
b = gcd(m, t)
n //= a
m //= b
ret = pow(2, n, mod) + pow(2, m, mod) + pow(2, gcd(n, m), mod) - 3
print(pow(ret, a * b, mod))


Fixed submission:
from fractions import gcd

mod = 10**9 + 7
n, m, t = map(int, input().split())
a = gcd(n, t)
b = gcd(m, t)
n //= a
m //= b
ret = pow(2, n, mod) + pow(2, m, mod) + pow(2, gcd(n, m), mod) - 3
print(pow(ret, a * b, mod))
Problem p02858 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

template <typename T> T gcd(T a, T b) {
  if (a < b)
    swap(a, b);
  while (b != 0) {
    T tmp = b;
    b = a % b;
    a = tmp;
  }
  return a;
}

template <typename T> T lcm(T a, T b) { return (a * b) / gcd<T>(a, b); }

template <typename T> T pow(T a, ll n) {
  T ans = 1;
  T tmp = a;
  for (int i = 0; i <= 60; i++) {
    ll m = (ll)1 << i;
    if (m & n) {
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(10) << fixed;
  ll H, W, T;
  cin >> H >> W >> T;
  ll h, w;
  h = lcm<ll>(H, T) / T;
  w = lcm<ll>(W, T) / T;
  ll ans = 0;
  if (gcd<ll>(h, w) != 1)
    return -1;
  ans += pow<ll>(2, h);
  ans %= MOD;
  ans += pow<ll>(2, w);
  ans--;
  ans %= MOD;
  ans = pow<ll>(ans, H * W / (h * w));
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

template <typename T> T gcd(T a, T b) {
  if (a < b)
    swap(a, b);
  while (b != 0) {
    T tmp = b;
    b = a % b;
    a = tmp;
  }
  return a;
}

template <typename T> T lcm(T a, T b) { return (a * b) / gcd<T>(a, b); }

template <typename T> T pow(T a, ll n) {
  T ans = 1;
  T tmp = a;
  for (int i = 0; i <= 60; i++) {
    ll m = (ll)1 << i;
    if (m & n) {
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(10) << fixed;
  ll H, W, T;
  cin >> H >> W >> T;
  ll h, w;
  h = lcm<ll>(H, T) / T;
  w = lcm<ll>(W, T) / T;
  ll ans = 0;
  if (gcd<ll>(h, w) != 1) {
    ll p = h * w / lcm<ll>(h, w);
    ans += (pow<ll>(2, p) - 2);
    ans %= MOD;
    // ans += (pow<ll>(2, p)-2);
    // ans %= MOD;
  }
  ans += pow<ll>(2, h);
  ans %= MOD;
  ans += pow<ll>(2, w);
  ans--;
  ans %= MOD;
  ans = pow<ll>(ans, H * W / (h * w));
  cout << ans << endl;
}
Problem p02859 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define mod 1000000007
int n, a, b, k, h, m, c;

int main() {
  scanf("%d", a);
  printf("%d", a * a);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define mod 1000000007
int n, a, b, k, h, m, c;

int main() {
  cin >> a;
  cout << a * a;
  return 0;
}
Problem p02859 (C++)

Buggy submission (status: Runtime Error):
// Nihal Mittal - nihal_47
// Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include <bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(), (v).end()
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(0);
#define pii pair<int, int>
#define maxn 100005
using namespace std;
signed main() {
  fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ll r;
  cin >> r;
  cout << r * r;
}

Fixed submission:
// Nihal Mittal - nihal_47
// Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include <bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(), (v).end()
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(0);
#define pii pair<int, int>
#define maxn 100005
using namespace std;
signed main() {
  fast;

  ll r;
  cin >> r;
  cout << r * r;
}
Problem p02859 (C++)

Buggy submission (status: Runtime Error):
// AUTHOR: *Akash Shrivastva*
// Birla Institute of Technology,Mesra,India
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define M 1000000007
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll vector<pair<ll, ll>>
#define F first
#define S second
#define PII pair<ll, ll>

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ll r;
  cin >> r;
  cout << r * r << endl;
}

Fixed submission:
// AUTHOR: *Akash Shrivastva*
// Birla Institute of Technology,Mesra,India
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define M 1000000007
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll vector<pair<ll, ll>>
#define F first
#define S second
#define PII pair<ll, ll>

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll r;
  cin >> r;
  cout << r * r << endl;
}
Problem p02859 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <type_traits>
#include <utility>
#include <vector>

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1.0);
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()

inline void finish() {
  cout << -1 << endl;
  exit(0);
}

template <typename T> inline void debug(vector<T> v) {
  cout << "[";
  for (ll i = 0; i < v.size() - 1; ++i) {
    cout << v[i] << ", ";
  }
  cout << v[v.size() - 1] << "]" << endl;
}

void Main();
inline void DebugMain() {
  while (true) {
    Main();
  }
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  bool debug = true;
  if (debug) {
    cout << "\x1b[41m"
         << "Debug Mode " << endl;
  }
  (debug) ? DebugMain() : Main();
  return 0;
}

inline void Main() {
  int r;

  cin >> r;

  cout << r * r;
}

Fixed submission:
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <type_traits>
#include <utility>
#include <vector>

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1.0);
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()

inline void finish() {
  cout << -1 << endl;
  exit(0);
}

template <typename T> inline void debug(vector<T> v) {
  cout << "[";
  for (ll i = 0; i < v.size() - 1; ++i) {
    cout << v[i] << ", ";
  }
  cout << v[v.size() - 1] << "]" << endl;
}

void Main();
inline void DebugMain() {
  while (true) {
    Main();
  }
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  bool debug = false;
  if (debug) {
    cout << "\x1b[41m"
         << "Debug Mode " << endl;
  }
  (debug) ? DebugMain() : Main();
  return 0;
}

inline void Main() {
  int r;

  cin >> r;

  cout << r * r;
}
Problem p02859 (C++)

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

using namespace std;

int main() {
  int r;
  cin >> r;
  while (1) {
  }
  cout << r;

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

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

  cout << r * r;

  return 0;
}
Problem p02859 (C++)

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

  return r * r;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int r;
  cin >> r;

  cout << r * r;
}
Problem p02859 (Python)

Buggy submission (status: Runtime Error):
r = input()
print(r**2)


Fixed submission:
r = int(input())
print(r**2)
Problem p02859 (Python)

Buggy submission (status: Runtime Error):
N = input()
print(N**2)


Fixed submission:
N = int(input())
print(N**2)
Problem p02859 (Python)

Buggy submission (status: Runtime Error):
r = int(input)

print(int(r**2))


Fixed submission:
r = int(input())

print(int(r**2))
Problem p02859 (Python)

Buggy submission (status: Runtime Error):
r = input()
ans = r * r
print(ans)


Fixed submission:
r = int(input())
ans = r * r
print(ans)
Problem p02859 (Python)

Buggy submission (status: Runtime Error):
r = int(input)
print(r**2)


Fixed submission:
r = int(input())
print(r**2)
Problem p02859 (Python)

Buggy submission (status: Runtime Error):
r = int(input().split())
print(r * r)


Fixed submission:
r = int(input().strip())
print(r * r)
Problem p02859 (Python)

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

r = stdin.readline().rstrip()

print(r**2)


Fixed submission:
from sys import stdin

r = int(stdin.readline().rstrip())

print(r**2)
Problem p02859 (Python)

Buggy submission (status: Runtime Error):
r = int(input)
x = r**2
print(x)


Fixed submission:
r = int(input())
x = r**2
print(x)
Problem p02859 (Python)

Buggy submission (status: Runtime Error):
print(int(input() ** 2))


Fixed submission:
print(int(input()) ** 2)
Problem p02859 (Python)

Buggy submission (status: Runtime Error):
import sys

r = sys.argv[1]
print(int(r) ** 2)


Fixed submission:
r = input()
print(int(r) ** 2)
Problem p02860 (C++)

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

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

  string s;

  if (n % 2 == 1) {
    cout << "No" << endl;
  } else {
    for (int i = 0; i < n / 2; i++) {
      if (s.at(i) != s.at(n / 2 + i)) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
}

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

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

  string s;
  cin >> s;

  if (n % 2 == 1) {
    cout << "No" << endl;
  } else {
    for (int i = 0; i < n / 2; i++) {
      if (s.at(i) != s.at(n / 2 + i)) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
}
Problem p02860 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string S;
  cin >> N >> S;
  int t = S.size();
  if (t % 2 != 0)
    cout << "No" << endl;
  else {
    vector<char> T(t);
    for (int i = 0; i < t / 2; i++) {
      T.at(i) = S.at(i);
      T.at(i + 3) = S.at(i);
    }
    int c = 0;
    for (int i = 0; i < t; i++) {
      if (T.at(i) != S.at(i))
        c = 1;
    }
    if (c == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string S;
  cin >> N >> S;
  int t = S.size();
  if (t % 2 != 0)
    cout << "No" << endl;
  else {
    vector<char> T(t);
    for (int i = 0; i < t / 2; i++) {
      T.at(i) = S.at(i);
      T.at(i + t / 2) = S.at(i);
    }
    int c = 0;
    for (int i = 0; i < t; i++) {
      if (T.at(i) != S.at(i))
        c = 1;
    }
    if (c == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
Problem p02860 (C++)

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

using namespace std;

int main() {
  long long n;
  string s;
  cin >> n >> s;
  if (n % 2 == 1) {
    cout << "No" << endl;
    return 1;
  }
  bool flag = true;
  for (long long i = 0; i < n / 2; i++) {
    if (s[i] != s[i + n / 2])
      flag = false;
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;

int main() {
  long long n;
  string s;
  cin >> n >> s;
  if (n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  bool flag = true;
  for (long long i = 0; i < n / 2; i++) {
    if (s[i] != s[i + n / 2])
      flag = false;
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02860 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
using namespace std;
struct all_init {
  all_init() { cout << fixed << setprecision(12); }
} All_init;

int main() {
  ll n;
  cin >> n;
  string s;
  if (n % 2 != 0) {
    cout << "No" << endl;
    exit(0);
  }
  string sa = s.substr(0, n / 2);
  string sb = s.substr(n / 2, n / 2);
  if (sa == sb) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
using namespace std;
struct all_init {
  all_init() { cout << fixed << setprecision(12); }
} All_init;

int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  if (n % 2 != 0) {
    cout << "No" << endl;
    exit(0);
  }
  string sa = s.substr(0, n / 2);
  string sb = s.substr(n / 2, n / 2);
  if (sa == sb) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02860 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
int main(void) {
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  string t0 = s.substr(0, 3), t1 = s.substr(3, 3);
  if (t0 == t1) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
int main(void) {
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  n >>= 1;
  string t0 = s.substr(0, n), t1 = s.substr(n, n);
  if (t0 == t1) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}
Problem p02860 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;

  if (n % 2 == 1) {
    cout << "No" << endl;
  } else {
    vector<char> hoge1(n / 2);
    vector<char> hoge2(n / 2);
    for (int i = 0; i < n; i++) {
      if (i <= n / 2 - 1)
        hoge1.at(i) = s.at(i);
      else
        hoge2.at(i - 3) = s.at(i);
    }

    if (hoge1 == hoge2)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;

  if (n % 2 == 1) {
    cout << "No" << endl;
  } else {
    vector<char> hoge1(n / 2);
    vector<char> hoge2(n / 2);
    for (int i = 0; i < n; i++) {
      if (i <= n / 2 - 1)
        hoge1.at(i) = s.at(i);
      else
        hoge2.at(i - n / 2) = s.at(i);
    }

    if (hoge1 == hoge2)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}
Problem p02860 (C++)

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

int main() {
  freopen("test.in", "r", stdin);
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 == 1) {
    cout << "No";
    return 0;
  }
  string a = "";
  for (int k = 0; k < n / 2; k++)
    a += s[k];
  a = a + a;
  if (a == s)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}


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

int main() {
  // freopen("test.in","r",stdin);
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 == 1) {
    cout << "No";
    return 0;
  }
  string a = "";
  for (int k = 0; k < n / 2; k++)
    a += s[k];
  a = a + a;
  if (a == s)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
Problem p02860 (C++)

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

int main() {

  int N;
  cin >> N;
  string S;
  cin >> S;
  bool flag = true;

  // Nが奇数のときは必ず'NO'
  if (N % 2 == 1)
    flag = false;
  else {
    for (int i = 0; i < S.size(); i++) {
      if (S.at(i) != S.at(i + N / 2)) {
        flag = false;
        break;
      }
    }
  }

  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {

  int N;
  cin >> N;
  string S;
  cin >> S;
  bool flag = true;

  // Nが奇数のときは必ず'NO'
  if (N % 2 == 1)
    flag = false;
  else {
    for (int i = 0; i < N / 2; i++) {
      if (S.at(i) != S.at(i + N / 2)) {
        flag = false;
        break;
      }
    }
  }

  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02860 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  int n;
  cin >> n;
  n = 6;
  string s;
  cin >> s;
  if (n % 2 == 0) {
    int t = n / 2;
    string k = s.substr(0, t);
    string l = s.substr(t, t);
    if (k == l)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  } else
    cout << "No" << endl;
}


Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  if (n % 2 == 0) {
    int t = n / 2;
    string k = s.substr(0, t);
    string l = s.substr(t, t);
    if (k == l)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  } else
    cout << "No" << endl;
}
Problem p02860 (C++)

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

int main() {
  int N;
  string s;
  cin >> N;
  cin >> s;

  int n;
  n = N / 2;

  int i = 0;

  if (N % 2 == 1) {
    cout << "No";
  } else {
    int b = 1;
    while (i < n) {
      if (s.at(i) != s.at(i + n)) {
        b = 0;
      }
    }
    if (b == 1) {
      cout << "Yes";
    } else {
      cout << "No";
    }
  }
}


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

int main() {
  int N;
  string s;
  cin >> N;
  cin >> s;

  int n;
  n = N / 2;

  int i = 0;

  if (N % 2 == 1) {
    cout << "No";
  } else {
    int b = 1;
    for (int i; i < n; i++) {
      if (s.at(i) != s.at(i + n)) {
        b = 0;
      }
    }
    if (b == 1) {
      cout << "Yes";
    } else {
      cout << "No";
    }
  }
}
Problem p02860 (C++)

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

using namespace std;

int main() {
  int n;
  cin >> n;
  if (n % 2 != 0) {
    cout << "No" << endl;
    return -1;
  }

  string s;
  cin >> s;

  const int m = n / 2;
  string p1 = s.substr(0, m);
  string p2 = s.substr(m, m);
  if (p1 == p2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  if (n % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  string s;
  cin >> s;

  const int m = n / 2;
  string p1 = s.substr(0, m);
  string p2 = s.substr(m, m);
  if (p1 == p2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}
Problem p02860 (C++)

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

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

  string S;
  cin >> S;

  if (N % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }

  string s1;
  s1 = S.substr(3);
  S = S.erase(3);

  if (s1 == S) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

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

  string S;
  cin >> S;

  if (N % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }

  string s1;
  s1 = S.substr(N / 2);
  S = S.erase(N / 2);

  if (s1 == S) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}
Problem p02860 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string S;
  cin >> N >> S;
  string ans = "Yes";
  if (S.size() % 2 != 0) {
    ans = "No";
  }
  for (int i = 0; i < N; i++) {
    if (S.at(i) != S.at(N / 2 + i)) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string S;
  cin >> N >> S;
  string ans = "Yes";
  if (S.size() % 2 != 0) {
    ans = "No";
  }
  for (int i = 0; i < N / 2; i++) {
    if (S.at(i) != S.at(N / 2 + i)) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}
Problem p02860 (C++)

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  string s;
  scanf("%d", &n);
  cin >> s;

  if (n % 2 != 0) {
    cout << "No"
         << "\n";
  } else {
    if (s.substr(0, n / 2) == s.substr(n / 2, string::npos))
      cout << "Yes\n";
    else
      cout << "No\n";
  }

  return 0;
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  string s;
  cin >> n >> s;

  if (n % 2 != 0) {
    cout << "No"
         << "\n";
  } else {
    if (s.substr(0, n / 2) == s.substr(n / 2, string::npos))
      cout << "Yes\n";
    else
      cout << "No\n";
  }

  return 0;
}
Problem p02860 (C++)

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::string S) {
  if (N % 2)
    cout << NO << '\n';
  else {
    string s1 = S.substr(0, N / 2);
    string s2 = S.substr(N / 2);
    if (s1 == s2)
      cout << YES << '\n';
    else
      cout << NO << '\n';
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  scanf("%lld", &N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::string S) {
  if (N % 2)
    cout << NO << '\n';
  else {
    string s1 = S.substr(0, N / 2);
    string s2 = S.substr(N / 2);
    if (s1 == s2)
      cout << YES << '\n';
    else
      cout << NO << '\n';
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}
Problem p02860 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int r;
  string s;
  cin >> r;
  cin >> s;
  if (r % 2 != 0) {
    printf("No");
  } else {
    if (s.substr(0, 3) == (s.substr(3, 6))) {
      printf("Yes");
    } else
      printf("No");
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int r;
  string s;
  cin >> r;
  cin >> s;
  if (r % 2 != 0) {
    printf("No");
  } else {
    if (s.substr(0, r / 2) == (s.substr(r / 2, r))) {
      printf("Yes");
    } else
      printf("No");
  }
}
Problem p02860 (C++)

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

using namespace std;

int main() {
  int n;
  string tmp;
  cin >> n >> tmp;
  vector<string> str(n);
  for (int i = 0; i < n; ++i)
    str.at(i) = tmp[i];

  sort(str.begin(), str.end());

  if (n < 2) {
    cout << "No";
    return 0;
  }

  for (int i = 0; i < n; i = i + 2) {
    if (str[i] != str[i + 1]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}


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

using namespace std;

int main() {
  int n;
  string tmp;
  cin >> n >> tmp;
  vector<string> str(n);
  for (int i = 0; i < n; ++i)
    str.at(i) = tmp[i];

  sort(str.begin(), str.end());

  if (n % 2 == 1) {
    cout << "No";
    return 0;
  }

  for (int i = 0; i < n; i = i + 2) {
    if (str[i] != str[i + 1]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}
Problem p02860 (Python)

Buggy submission (status: Runtime Error):
def solve(string):
    n, s = string.split()
    n = int(n)
    return "Yes" if s[: n // 2] == s[n // 2 :] else "No"


if __name__ == "__main__":
    print(solve(input()))


Fixed submission:
def solve(string):
    n, s = string.split()
    n = int(n)
    return "Yes" if s[: n // 2] == s[n // 2 :] else "No"


if __name__ == "__main__":
    print(solve("\n".join([input(), input()])))
Problem p02860 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
S = int(input())
if N % 2 != 0:
    print("No")
else:
    arr = list(S)
    s_len = len(arr) // 2
    if arr[s_len:] == arr[:s_len]:
        print("Yes")
    else:
        print("No")


Fixed submission:
N = int(input())
S = input()
if N % 2 != 0:
    print("No")
else:
    arr = list(S)
    s_len = len(arr) // 2
    if arr[s_len:] == arr[:s_len]:
        print("Yes")
    else:
        print("No")
Problem p02860 (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() {
  string s;
  int n;
  cin >> n, s;
  bool ans = true;
  if (n % 2 == 1)
    ans = false;
  else {
    rep(i, n / 2) {
      if (s.at(i) != s.at(i + n / 2))
        ans = false;
    }
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  string s;
  int n;
  cin >> n >> s;
  bool ans = true;
  if (n % 2 == 1)
    ans = false;
  else {
    rep(i, n / 2) {
      if (s.at(i) != s.at(i + n / 2))
        ans = false;
    }
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02860 (C++)

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

int main() {
  int N;
  string S;
  int i;

  cin >> N;
  cin >> S;
  int a;
  a = N / 2;
  if (N % 2 == 1) {
    cout << "No" << endl;
    return 0;
  } else {
    for (i == 0; i < N; i++) {
      if (S.at(i) == S.at(i + a)) {
      } else {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
}

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

int main() {
  int N;
  string S;
  int i;

  cin >> N;
  cin >> S;
  int a;
  a = N / 2;
  if (N % 2 == 1) {
    cout << "No" << endl;
    return 0;
  } else {
    for (i == 0; i < a; i++) {
      if (S.at(i) == S.at(i + a)) {
      } else {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
}
Problem p02860 (C++)

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

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

  // n = 10;
  // s = "aabbcaabbc";

  if (n % 2 == 1) {
    printf("No");
    return 0;
  }

  const char *ss = s.c_str();

  for (int i = 0; i < n / 2; i++) {
    if (ss[i] != ss[i + n / 2]) {
      printf("No");
      return 0;
    }
  }

  return printf("Yes");
}


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

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

  // n = 10;
  // s = "aabbcaabbc";

  if (n % 2 == 1) {
    printf("No");
    return 0;
  }

  const char *ss = s.c_str();

  for (int i = 0; i < n / 2; i++) {
    if (ss[i] != ss[i + n / 2]) {
      printf("No");
      return 0;
    }
  }

  printf("Yes");
  return 0;
}