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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdio>
#include <vector>
#define file(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout)

inline int read() {
  int data = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9'))
    ch = getchar();
  if (ch == '-')
    w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    data = data * 10 + (ch ^ 48), ch = getchar();
  return data * w;
}

const int N(3010), Mod(1e9 + 7);
inline void Add(int &x, int y) { x = (x + y) % Mod; }
int n, m, f[N][N][2], ans;

int main() {
#ifndef ONLINE_JUDGE
  file(cpp);
#endif
  n = read(), m = read(), f[0][0][1] = 1;
  for (int i = 1; i <= n; i++)
    f[0][i][0] = 1;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= n; j++) {
      // RR
      if (j < n) {
        Add(f[i][j][1], f[i - 1][j + 1][1]);
        if (j == 0)
          Add(f[i][j][1], f[i - 1][j + 1][0]);
        else
          Add(f[i][j][0], f[i - 1][j + 1][0]);
      }
      // BB
      if (j) {
        Add(f[i][j][1], f[i - 1][j - 1][1]);
        Add(f[i][j][0], f[i - 1][j - 1][0]);
      }
      // RB
      if (j) {
        Add(f[i][j][1], f[i - 1][j][1]);
        if (j == 1)
          Add(f[i][j][1], f[i - 1][j][0]);
        else
          Add(f[i][j][0], f[i - 1][j][0]);
      }
      // BR
      if (j < n) {
        Add(f[i][j][1], f[i - 1][j][1]);
        Add(f[i][j][0], f[i - 1][j][0]);
      }
    }
  }
  for (int i = 0; i <= n; i++)
    Add(ans, f[m][i][1]);
  printf("%d\n", ans);
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <vector>
#define file(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout)

inline int read() {
  int data = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9'))
    ch = getchar();
  if (ch == '-')
    w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    data = data * 10 + (ch ^ 48), ch = getchar();
  return data * w;
}

const int N(3010), Mod(1e9 + 7);
inline void Add(int &x, int y) { x = (x + y) % Mod; }
int n, m, f[N][N][2], ans;

int main() {
  n = read(), m = read(), f[0][0][1] = 1;
  for (int i = 1; i <= n; i++)
    f[0][i][0] = 1;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= n; j++) {
      // RR
      if (j < n) {
        Add(f[i][j][1], f[i - 1][j + 1][1]);
        if (j == 0)
          Add(f[i][j][1], f[i - 1][j + 1][0]);
        else
          Add(f[i][j][0], f[i - 1][j + 1][0]);
      }
      // BB
      if (j) {
        Add(f[i][j][1], f[i - 1][j - 1][1]);
        Add(f[i][j][0], f[i - 1][j - 1][0]);
      }
      // RB
      if (j) {
        Add(f[i][j][1], f[i - 1][j][1]);
        if (j == 1)
          Add(f[i][j][1], f[i - 1][j][0]);
        else
          Add(f[i][j][0], f[i - 1][j][0]);
      }
      // BR
      if (j < n) {
        Add(f[i][j][1], f[i - 1][j][1]);
        Add(f[i][j][0], f[i - 1][j][0]);
      }
    }
  }
  for (int i = 0; i <= n; i++)
    Add(ans, f[m][i][1]);
  printf("%d\n", ans);
  return 0;
}
Problem p03749 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1000000007ll,
                Mul2[3][3] = {{1, 2, 1}, {0, 1, 1}, {0, 0, 1}};
long long MMul[39][3][3] = {{{1, 2, 1}, {0, 1, 1}, {1, 2, 2}}};
long long n, m, a[10090], mat[3] = {1, 0, 0};

int main() {
  for (int i = 0; i < 30; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++)
        for (int l = 0; l < 3; l++)
          MMul[i + 1][j][k] =
              (MMul[i + 1][j][k] + MMul[i][j][l] * MMul[i][l][k]) % Mod;
  cin >> n >> m;
  a[m + 1] = -1;
  do {
    if (m)
      cin >> a[m];
    else
      a[m] = n;
    long long k = a[m] - a[m + 1] - 1, _mat[3] = {0, 0, 0};
    for (int i = 0; i < 30; i++)
      if (k & (1 << i)) {
        for (int j = 0; j < 3; j++)
          for (int k = 0; k < 3; k++)
            _mat[j] = (_mat[j] + mat[k] * MMul[i][k][j]) % Mod;
        for (int j = 0; j < 3; j++)
          mat[j] = _mat[j], _mat[j] = 0;
      }
    if (m) {
      for (int j = 0; j < 3; j++)
        for (int k = 0; k < 3; k++)
          _mat[j] = (_mat[j] + mat[k] * Mul2[k][j]) % Mod;
      for (int j = 0; j < 3; j++)
        mat[j] = _mat[j];
    }
    //		printf("[%d %d %d]\n",mat[0],mat[1],mat[2]);
  } while (m--);
  cout << mat[2];
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1000000007ll,
                Mul2[3][3] = {{1, 2, 1}, {0, 1, 1}, {0, 0, 1}};
long long MMul[39][3][3] = {{{1, 2, 1}, {0, 1, 1}, {1, 2, 2}}};
long long n, m, a[100090], mat[3] = {1, 0, 0};

int main() {
  for (int i = 0; i < 30; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++)
        for (int l = 0; l < 3; l++)
          MMul[i + 1][j][k] =
              (MMul[i + 1][j][k] + MMul[i][j][l] * MMul[i][l][k]) % Mod;
  cin >> n >> m;
  a[m + 1] = -1;
  do {
    if (m)
      cin >> a[m];
    else
      a[m] = n;
    long long k = a[m] - a[m + 1] - 1, _mat[3] = {0, 0, 0};
    for (int i = 0; i < 30; i++)
      if (k & (1 << i)) {
        for (int j = 0; j < 3; j++)
          for (int k = 0; k < 3; k++)
            _mat[j] = (_mat[j] + mat[k] * MMul[i][k][j]) % Mod;
        for (int j = 0; j < 3; j++)
          mat[j] = _mat[j], _mat[j] = 0;
      }
    if (m) {
      for (int j = 0; j < 3; j++)
        for (int k = 0; k < 3; k++)
          _mat[j] = (_mat[j] + mat[k] * Mul2[k][j]) % Mod;
      for (int j = 0; j < 3; j++)
        mat[j] = _mat[j];
    }
    //		printf("[%d %d %d]\n",mat[0],mat[1],mat[2]);
  } while (m--);
  cout << mat[2];
}
Problem p03752 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = 1; i <= (n); i++)
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
using Pl = pair<ll, ll>;

int main() {
  ll n, k;
  cin >> n >> k;
  ll a[n];
  rep(i, n) cin >> a[i];
  ll ans = 1e18;
  rep(bit, 1 << n) {
    if (__builtin_popcount(bit) < k || bit % 2 == 0)
      continue;
    vector<ll> s;
    rep(i, n) {
      if (bit >> i & 1)
        s.push_back(i);
    }
    ll l = 0, total = 0;
    rep(j, s.size()) {
      l = max(l + 1, *max_element(a + s[j], a + s[j + 1]));
      total += l - a[s[j]];
    }
    ans = min(ans, total);
  }
  cout << ans << endl;
}


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

int main() {
  ll n, k;
  cin >> n >> k;
  ll a[n];
  rep(i, n) cin >> a[i];
  ll ans = 1e18;
  rep(bit, 1 << n) {
    if (__builtin_popcount(bit) < k || bit % 2 == 0)
      continue;
    vector<ll> s;
    rep(i, n) {
      if (bit >> i & 1)
        s.push_back(i);
    }
    ll l = 0, total = 0;
    s.push_back(n);
    rep(j, s.size() - 1) {
      l = max(l + 1, *max_element(a + s[j], a + s[j + 1]));
      total += l - a[s[j]];
    }
    ans = min(ans, total);
  }
  cout << ans << endl;
}
Problem p03753 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int gcd(Int x, Int y) {
  if (x < y)
    swap(x, y);
  if (y == 0)
    return x;
  return gcd(y, x % y);
}
Int lcm(Int x, Int y) { return x / gcd(x, y) * y; }
Int solve(Int N, Int M, const vector<int> A) {
  vector<char> B(N);
  for (int a : A) {
    for (int k = a; k < N; k += M) {
      B[k] = 1;
    }
  }
  auto dfs = [&](auto &&dfs, int n) {
    if (B[n] == 1)
      return;
    B[n] = 1;
    if (0 <= n - 7)
      dfs(dfs, n - 7);
    if ((n % 7) != 0)
      dfs(dfs, n - 1);
    if ((n % 7) != 6)
      dfs(dfs, n + 1);
    if (n + 7 < N)
      dfs(dfs, n + 7);
  };
  Int ans = 0;
  for (int i = 0; i < N; i++) {
    if (B[i] == 0) {
      ans++;
      dfs(dfs, i);
    }
  }
  return ans;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  Int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> A(Q);
  for (auto &a : A)
    cin >> a;
  Int x = lcm(M, lcm(7 * N / M, 7));
  Int k = 7 * N / x;
  if (k == 1) {
    Int cnt1 = solve(x, M, A);
    cout << cnt1 << endl;
  } else {
    Int cnt2 = solve(2 * x, M, A);
    Int cnt3 = solve(3 * x, M, A);
    cout << cnt2 + (cnt3 - cnt2) * (k - 2) << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int gcd(Int x, Int y) {
  if (x < y)
    swap(x, y);
  if (y == 0)
    return x;
  return gcd(y, x % y);
}
Int lcm(Int x, Int y) { return x / gcd(x, y) * y; }
Int solve(Int N, Int M, const vector<int> A) {
  vector<char> B(N);
  for (int a : A) {
    for (int k = a; k < N; k += M) {
      B[k] = 1;
    }
  }
  auto dfs = [&](auto &&dfs, int n) {
    if (B[n] == 1)
      return;
    B[n] = 1;
    if (0 <= n - 7)
      dfs(dfs, n - 7);
    if ((n % 7) != 0)
      dfs(dfs, n - 1);
    if ((n % 7) != 6)
      dfs(dfs, n + 1);
    if (n + 7 < N)
      dfs(dfs, n + 7);
  };
  Int ans = 0;
  for (int i = 0; i < N; i++) {
    if (B[i] == 0) {
      ans++;
      dfs(dfs, i);
    }
  }
  return ans;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  Int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> A(Q);
  for (auto &a : A)
    cin >> a;
  Int x = lcm(M, 7);
  Int k = 7 * N / x;
  if (k == 1) {
    Int cnt1 = solve(x, M, A);
    cout << cnt1 << endl;
  } else {
    Int cnt2 = solve(2 * x, M, A);
    Int cnt3 = solve(3 * x, M, A);
    cout << cnt2 + (cnt3 - cnt2) * (k - 2) << endl;
  }
  return 0;
}
Problem p03754 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb emplace_back
#define INF (1e9 + 1)
// #define INF (1LL<<59)
typedef pair<double, int> pdi;

vector<int> G[15000];
double val[150000];
double ans[150000];
int deg[150000];

pdi dfs(int cur, int prev) {
  double ret = 0;
  int c = 0;
  for (auto e : G[cur]) {
    if (e == prev)
      continue;
    c++;
  }
  if (c == 0)
    return pdi(val[cur] = 0, 0);

  int height = 0;
  for (auto e : G[cur]) {
    if (e == prev)
      continue;
    double res;
    int h;
    tie(res, h) = dfs(e, cur);
    ret += 1 + res;
    height = max(1 + h, height);
  }
  ret /= c;
  return pdi(val[cur] = ret, height);
}

double dfs2(int cur, int prev, double d_par) {
  vector<pdi> v;
  for (auto e : G[cur]) {
    if (e == prev)
      v.pb(pdi(d_par + 1, e));
    else
      v.pb(pdi(val[e] + 1, e));
  }

  double ave = 0;
  rep(i, v.size()) ave += v[i].first;
  ave /= deg[cur];

  for (auto e : G[cur]) {
    if (e == prev)
      continue;
    if (deg[cur] == 1)
      dfs2(e, cur, 0);
    else
      dfs2(e, cur, (ave * deg[cur] - (val[e] + 1)) / (deg[cur] - 1));
  }

  return ans[cur] = ave;
}

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

  rep(i, n - 1) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    deg[u]++;
    deg[v]++;
    G[u].pb(v);
    G[v].pb(u);
  }

  dfs(0, -1);

  dfs2(0, -1, 0);

  rep(i, n) { printf("%.20lf\n", ans[i]); }
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb emplace_back
#define INF (1e9 + 1)
// #define INF (1LL<<59)
typedef pair<double, int> pdi;

vector<int> G[150000];
double val[150000];
double ans[150000];
int deg[150000];

pdi dfs(int cur, int prev) {
  double ret = 0;
  int c = 0;
  for (auto e : G[cur]) {
    if (e == prev)
      continue;
    c++;
  }
  if (c == 0)
    return pdi(val[cur] = 0, 0);

  int height = 0;
  for (auto e : G[cur]) {
    if (e == prev)
      continue;
    double res;
    int h;
    tie(res, h) = dfs(e, cur);
    ret += 1 + res;
    height = max(1 + h, height);
  }
  ret /= c;
  return pdi(val[cur] = ret, height);
}

double dfs2(int cur, int prev, double d_par) {
  vector<pdi> v;
  for (auto e : G[cur]) {
    if (e == prev)
      v.pb(pdi(d_par + 1, e));
    else
      v.pb(pdi(val[e] + 1, e));
  }

  double ave = 0;
  rep(i, v.size()) ave += v[i].first;
  ave /= deg[cur];

  for (auto e : G[cur]) {
    if (e == prev)
      continue;
    if (deg[cur] == 1)
      dfs2(e, cur, 0);
    else
      dfs2(e, cur, (ave * deg[cur] - (val[e] + 1)) / (deg[cur] - 1));
  }

  return ans[cur] = ave;
}

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

  rep(i, n - 1) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    deg[u]++;
    deg[v]++;
    G[u].pb(v);
    G[v].pb(u);
  }

  dfs(0, -1);

  dfs2(0, -1, 0);

  rep(i, n) { printf("%.20lf\n", ans[i]); }
}
Problem p03754 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

VI e[15000];
double p1[15000], ans[15000];

double dfs(int now, int past) {
  double res = 0.0;
  double p = 1.0 / e[now].size();
  if (past != -1)
    p = 1.0 / (e[now].size() - 1);
  for (auto next : e[now]) {
    if (next == past)
      continue;
    double a = dfs(next, now);
    res += p * (1 + a);
    ans[now] += 1.0 / e[now].size() * (1 + a);
  }
  return p1[now] = res;
}

double dfs2(int now, int past, double pp) {
  int n = e[now].size();
  pp /= n;
  ans[now] += pp;
  if (n == 1) {
    if (e[now][0] != past)
      dfs2(e[now][0], now, 1.0);
    return 0;
  }
  for (auto next : e[now]) {
    if (next == past)
      continue;
    dfs2(next, now, (ans[now] - (p1[next] + 1) / n) * n / (n - 1.0) + 1);
  }
}

int main() {
  int n;
  cin >> n;
  REP(i, n - 1) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    e[u].push_back(v);
    e[v].push_back(u);
  }

  dfs(0, -1);
  dfs2(0, -1, 0.0);
  REP(i, n) { printf("%.10f\n", ans[i]); }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

VI e[150000];
double p1[150000], ans[150000];

double dfs(int now, int past) {
  double res = 0.0;
  double p = 1.0 / e[now].size();
  if (past != -1)
    p = 1.0 / (e[now].size() - 1);
  for (auto next : e[now]) {
    if (next == past)
      continue;
    double a = dfs(next, now);
    res += p * (1 + a);
    ans[now] += 1.0 / e[now].size() * (1 + a);
  }
  return p1[now] = res;
}

double dfs2(int now, int past, double pp) {
  int n = e[now].size();
  pp /= n;
  ans[now] += pp;
  if (n == 1) {
    if (e[now][0] != past)
      dfs2(e[now][0], now, 1.0);
    return 0;
  }
  for (auto next : e[now]) {
    if (next == past)
      continue;
    dfs2(next, now, (ans[now] - (p1[next] + 1) / n) * n / (n - 1.0) + 1);
  }
}

int main() {
  int n;
  cin >> n;
  REP(i, n - 1) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    e[u].push_back(v);
    e[v].push_back(u);
  }

  dfs(0, -1);
  dfs2(0, -1, 0.0);
  REP(i, n) { printf("%.10f\n", ans[i]); }

  return 0;
}
Problem p03754 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#define N 100010
using namespace std;
int head[N], k, sz[N];
double E[N], ans[N];
struct Edge {
  int v, next;
} edge[2 * N];
void add_edge(int u, int v) {
  edge[++k].v = v;
  edge[k].next = head[u];
  head[u] = k;
}
void dfs1(int u, int pre) {
  for (int kk = head[u]; ~kk; kk = edge[kk].next) {
    int v = edge[kk].v;
    if (v == pre)
      continue;
    dfs1(v, u);
    E[u] += 1.0 / sz[u] * (E[v] + 1);
  }
}
void dfs2(int u, int pre) {
  double t = 1.0 / sz[pre] * (E[u] + 1);
  t = ans[pre] - t;
  if (sz[pre] != 1)
    t = t * sz[pre] / (sz[pre] - 1);
  ans[u] = E[u] * (sz[u] - 1) / sz[u] + 1.0 / sz[u] * (t + 1);
  for (int kk = head[u]; ~kk; kk = edge[kk].next) {
    int v = edge[kk].v;
    if (v == pre)
      continue;
    dfs2(v, u);
  }
}
int main() {
  int n, u, v, i;
  scanf("%d", &n);
  memset(sz, -1, sizeof(sz));
  k = -1;
  memset(head, -1, sizeof(head));
  for (i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    add_edge(u, v);
    add_edge(v, u);
    sz[u]++;
    sz[v]++;
  }
  sz[1]++;
  dfs1(1, -1);
  for (i = 2; i <= n; ++i)
    sz[i]++;
  ans[1] = E[1];
  for (i = head[1]; ~i; i = edge[i].next) {
    int v = edge[i].v;
    dfs2(v, 1);
  }
  for (i = 1; i <= n; ++i) {
    printf("%.10lf\n", ans[i]);
  }
  return 0;
}
/*
3
1 2
1 3
*/


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#define N 200010
using namespace std;
int head[N], k, sz[N];
double E[N], ans[N];
struct Edge {
  int v, next;
} edge[2 * N];
void add_edge(int u, int v) {
  edge[++k].v = v;
  edge[k].next = head[u];
  head[u] = k;
}
void dfs1(int u, int pre) {
  for (int kk = head[u]; ~kk; kk = edge[kk].next) {
    int v = edge[kk].v;
    if (v == pre)
      continue;
    dfs1(v, u);
    E[u] += 1.0 / sz[u] * (E[v] + 1);
  }
}
void dfs2(int u, int pre) {
  double t = 1.0 / sz[pre] * (E[u] + 1);
  t = ans[pre] - t;
  if (sz[pre] != 1)
    t = t * sz[pre] / (sz[pre] - 1);
  ans[u] = E[u] * (sz[u] - 1) / sz[u] + 1.0 / sz[u] * (t + 1);
  for (int kk = head[u]; ~kk; kk = edge[kk].next) {
    int v = edge[kk].v;
    if (v == pre)
      continue;
    dfs2(v, u);
  }
}
int main() {
  int n, u, v, i;
  scanf("%d", &n);
  memset(sz, -1, sizeof(sz));
  k = -1;
  memset(head, -1, sizeof(head));
  for (i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    add_edge(u, v);
    add_edge(v, u);
    sz[u]++;
    sz[v]++;
  }
  sz[1]++;
  dfs1(1, -1);
  for (i = 2; i <= n; ++i)
    sz[i]++;
  ans[1] = E[1];
  for (i = head[1]; ~i; i = edge[i].next) {
    int v = edge[i].v;
    dfs2(v, 1);
  }
  for (i = 1; i <= n; ++i) {
    printf("%.10lf\n", ans[i]);
  }
  return 0;
}
/*
3
1 2
1 3
*/
Problem p03754 (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;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 *  */

const int inf = 1LL << 60;

int n;
V<int> es[101010];
double dp[101010];
double ans[101010];

void dfs(int v, int p) {
  double sum = 0;
  int k = 0;
  for (auto to : es[v]) {
    if (to == p)
      continue;
    dfs(to, v);
    sum += dp[to] + 1.0;
    k++;
  }

  if (k)
    dp[v] += sum / k;
}

double dfs2(int v, int p, double d_p) {
  double sum = 0;
  for (auto to : es[v]) {
    if (to == p) {
      sum += d_p + 1.0;
    } else {
      sum += dp[to] + 1.0;
    }
  }

  int k = sz(es[v]);
  ans[v] = sum / k;

  for (auto to : es[v]) {
    if (to == p)
      continue;
    dfs2(to, v, (sum - dp[to] - 1.0) / max(1LL, k - 1));
  }
}

signed main() {
  cin >> n;
  rep(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    es[a].emplace_back(b);
    es[b].emplace_back(a);
  }

  dfs(0, -1);
  dfs2(0, -1, 0);
  rep(i, 0, n) { printf("%.12f\n", ans[i]); }

  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;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 *  */

const int inf = 1LL << 60;

int n;
V<int> es[151010];
double dp[151010];
double ans[151010];

void dfs(int v, int p) {
  double sum = 0;
  int k = 0;
  for (auto to : es[v]) {
    if (to == p)
      continue;
    dfs(to, v);
    sum += dp[to] + 1.0;
    k++;
  }

  if (k)
    dp[v] += sum / k;
}

double dfs2(int v, int p, double d_p) {
  double sum = 0;
  for (auto to : es[v]) {
    if (to == p) {
      sum += d_p + 1.0;
    } else {
      sum += dp[to] + 1.0;
    }
  }

  int k = sz(es[v]);
  ans[v] = sum / k;

  for (auto to : es[v]) {
    if (to == p)
      continue;
    dfs2(to, v, (sum - dp[to] - 1.0) / max(1LL, k - 1));
  }
}

signed main() {
  cin >> n;
  rep(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    es[a].emplace_back(b);
    es[b].emplace_back(a);
  }

  dfs(0, -1);
  dfs2(0, -1, 0);
  rep(i, 0, n) { printf("%.12f\n", ans[i]); }

  return 0;
}
Problem p03759 (Python)

Buggy submission (status: Runtime Error):
a, b, c = list(input().split())
print("YES" if b - a == c - b else "NO")


Fixed submission:
a, b, c = list(map(int, input().split()))
print("YES" if b - a == c - b else "NO")
Problem p03759 (C++)

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

int main() {
  vector<int> v;
  for (int i = 0; i < 3; ++i)
    cin >> v[i];
  sort(v.begin(), v.end());
  int a = v[0], b = v[1], c = v[2];
  if (b - a == c - b) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
  return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (b - a == c - b) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
Problem p03759 (C++)

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

int main() {
  int a, b, c;
  while (scanf("%d%d%d", &a, &b, &c))
    cout << (b - a == c - b ? "YES" : "NO") << endl;
  return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (b - a == c - b ? "YES" : "NO") << endl;
  return 0;
}
Problem p03759 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define pi acos(-1)
using ll = long long;
using namespace std;
using namespace __gnu_pbds;
using vl = vector<ll>;
using pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

ll power(ll x, ll y) {
  ll res = 1;
  while (y) {
    if (y & 1)
      res = (res * x) % md;
    x = (x * x) % md;
    y = y / 2;
  }
  return res;
}

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + c == 2 * b)
    cout << "YES";
  else
    cout << "NO";
}

int main() {

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

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  // int n; cin>>n; for (int i = 0; i < n; ++i)
  solve();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define pi acos(-1)
using ll = long long;
using namespace std;
using namespace __gnu_pbds;
using vl = vector<ll>;
using pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

ll power(ll x, ll y) {
  ll res = 1;
  while (y) {
    if (y & 1)
      res = (res * x) % md;
    x = (x * x) % md;
    y = y / 2;
  }
  return res;
}

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + c == 2 * b)
    cout << "YES";
  else
    cout << "NO";
}

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  // int n; cin>>n; for (int i = 0; i < n; ++i)
  solve();
  return 0;
}
Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define str string
#define rep(x, y) for (int i = x; i < y; i++)
#define REP(x, y) for (int j = x; j < y; j++)
#define all(x) x.begin(), x.end()
int main() {
  int N, out = 0, safe = 0, stack = 0, A, B, C;
  str O, E;
  char d = 'A' - 'a';
  cin >> O >> E;
  rep(0, O.size()) { cout << O.at(i) << E.at(i); }
  cout << endl;
}

Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define str string
#define rep(x, y) for (int i = x; i < y; i++)
#define REP(x, y) for (int j = x; j < y; j++)
#define all(x) x.begin(), x.end()
int main() {
  int N, out = 0, safe = 0, stack = 0, A, B, C;
  str O, E;
  char d = 'A' - 'a';
  cin >> O >> E;
  for (int i = 0; i < E.size(); i++) {
    cout << O.at(i) << E.at(i);
    if (i == E.size() - 1 && abs(O.size() - E.size() == 1))
      cout << O.at(O.size() - 1);
  }
  cout << endl;
}
Problem p03760 (Python)

Buggy submission (status: Runtime Error):
O, E = [input() for _ in range(2)]
E += " "

length = max(len(O), len(E))

for i in range(length):
    print(O[i], end="")
    print(E[i], end="")


Fixed submission:
O, E = [input() for _ in range(2)]
E += " "

for i in range(len(O)):
    print(O[i], end="")
    print(E[i], end="")
Problem p03760 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
char s1[66], s2[66];
char cc[555];
int main() {
  int a, b, c;
  while (scanf("%s%s", s1, s2)) {
    int len = 0;
    int len1 = strlen(s1);
    int len2 = strlen(s2);
    int i1 = 0;
    int i2 = 0;
    for (int i = 0; i < len1 + len2; ++i) {
      if (i % 2 == 0 && i1 < len1)
        cc[i] = s1[i1++];
      else if (i2 < len2)
        cc[i] = s2[i2++];
    }
    cc[len1 + len2] = '\0';
    printf("%s\n", cc);
  }
  return 0;
}


Fixed submission:
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
char s1[66], s2[66];
char cc[555];
int main() {
  int a, b, c;
  while (scanf("%s%s", s1, s2) != EOF) {
    int len = 0;
    int len1 = strlen(s1);
    int len2 = strlen(s2);
    int i1 = 0;
    int i2 = 0;
    for (int i = 0; i < len1 + len2; ++i) {
      if (i % 2 == 0 && i1 < len1)
        cc[i] = s1[i1++];
      else if (i2 < len2)
        cc[i] = s2[i2++];
    }
    cc[len1 + len2] = '\0';
    printf("%s\n", cc);
  }
  return 0;
}
Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
string odd, even;
int main() {
  cin >> odd >> even;

  string ans = "";
  int len_odd = odd.length();
  int len_even = even.length();

  int cnt_even;
  for (int i = 0; i < len_odd; i++) {
    ans += odd[i];
    if (cnt_even < len_even)
      ans += even[cnt_even++];
  }

  cout << ans << endl;
}

Fixed submission:
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
string odd, even;
int main() {
  cin >> odd >> even;

  string ans = "";
  int len_odd = odd.length();
  int len_even = even.length();

  int cnt_even = 0;
  for (int i = 0; i < len_odd; i++) {
    ans += odd[i];
    if (cnt_even < len_even)
      ans += even[cnt_even++];
  }

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

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

int main() {
  string o, e;
  cin >> o >> e;
  if (o.size() % 2 == 1) {
    for (int i = 0; i < o.size(); i++) {
      cout << o.at(i) << e.at(i);
    }
    cout << endl;
  } else {
    for (int i = 0; i < e.size(); i++) {
      cout << o.at(i) << e.at(i);
    }
    cout << o.back() << endl;
  }
}


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

int main() {
  string o, e;
  cin >> o >> e;
  if (o.size() == e.size()) {
    for (int i = 0; i < o.size(); i++) {
      cout << o.at(i) << e.at(i);
    }
    cout << endl;
  } else {
    for (int i = 0; i < e.size(); i++) {
      cout << o.at(i) << e.at(i);
    }
    cout << o.back() << endl;
  }
}
Problem p03760 (C++)

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

int main() {
  string O, E;
  cin >> O >> E;

  for (int i = 0; i < O.size(); i++) {
    cout << O.at(i);
    if (i < E.at(i)) {
      cout << E.at(i);
    }
  }
}


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

int main() {
  string O, E;
  cin >> O >> E;

  for (int i = 0; i < O.size(); i++) {
    cout << O.at(i);
    if (i < E.size()) {
      cout << E.at(i);
    }
  }
}
Problem p03760 (C++)

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

int main() {
  string O, E;
  cin >> O >> E;

  if (O.size() == E.size()) {
    for (int i = 0; i < O.size(); i++) {
      cout << O.at(i) << E.at(i);
    }
  }

  else {
    for (int i = 0; i < E.size(); i++) {
      cout << O.at(i) << E.at(i);
    }
    cout << O.at(O.size());
  }
}


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

int main() {
  string O, E;
  cin >> O >> E;

  if (O.size() == E.size()) {
    for (int i = 0; i < O.size(); i++) {
      cout << O.at(i) << E.at(i);
    }
  }

  else {
    for (int i = 0; i < E.size(); i++) {
      cout << O.at(i) << E.at(i);
    }
    cout << O.at(O.size() - 1);
  }
}
Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

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

//-------------------ここから回答する-----------------------

void solve(void) {
  string o, e;
  cin >> o >> e;
  string ans = 0;
  rep(i, o.length()) {
    ans += o[i];
    if (i < e.length())
      ans += e[i];
  }
  cout << ans << endl;
}
int main(void) { solve(); }


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

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

//-------------------ここから回答する-----------------------

void solve(void) {
  string o, e;
  cin >> o >> e;
  string ans = "";
  rep(i, o.length()) {
    ans += o[i];
    if (i < e.length())
      ans += e[i];
  }
  cout << ans << endl;
}
int main(void) { solve(); }
Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string O, E;
  cin >> O >> E;
  int o = O.size(), e = E.size();
  for (int i = 0; i < o; i++)
    cout << O.at(i) << E.at(i);
  if (o > e)
    cout << O.at(o - 1) << endl;
  else
    cout << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string O, E;
  cin >> O >> E;
  int o = O.size(), e = E.size();
  for (int i = 0; i < e; i++)
    cout << O.at(i) << E.at(i);
  if (o > e)
    cout << O.at(o - 1) << endl;
  else
    cout << endl;
}
Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string o, e;
  cin >> o >> e;
  for (int i = 0; i < o.size(); i++)
    cout << o.at(i) << e.at(i);
  if (o.size() > e.size())
    cout << o.at(o.size() - 1);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string o, e;
  cin >> o >> e;
  for (int i = 0; i < e.size(); i++)
    cout << o.at(i) << e.at(i);
  if (o.size() > e.size())
    cout << o.at(o.size() - 1);
}
Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
  string o, e;
  cin >> o >> e;
  for (int i = 0; i < o.size(); i++) {
    cout << o.at(i) << e.at(i);
  }
  cout << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
  string o, e;
  cin >> o >> e;
  if (o.size() == e.size()) {
    for (int i = 0; i < o.size(); i++) {
      cout << o.at(i) << e.at(i);
    }
  } else {
    for (int i = 0; i < e.size(); i++) {
      cout << o.at(i) << e.at(i);
    }
    cout << o.at(o.size() - 1);
  }
  cout << endl;
  return 0;
}
Problem p03760 (C++)

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

int main() {

  std::string O, E;
  std::cin >> O >> E;

  for (int i = 0; i<O.size()> E.size() ? O.size() : E.size(); i++) {
    if (i < O.size())
      std::cout << O[i];
    if (i < E.size())
      std::cout << E[i];
  }

  return 0;
}

Fixed submission:
#include <iostream>

int main() {

  std::string O, E;
  std::cin >> O >> E;

  for (int i = 0; i < (O.size() > E.size() ? O.size() : E.size()); i++) {
    if (i < O.size())
      std::cout << O[i];
    if (i < E.size())
      std::cout << E[i];
  }

  return 0;
}
Problem p03760 (C++)

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

int main() {
  string o, e;
  cin >> o >> e;
  int n = 2 * o.size();

  if (o.size() == e.size()) {
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0) {
        cout << o.at(i / 2);
      } else {
        cout << e.at(i / 2);
      }
    }
    cout << endl;
  } else {
    for (int i = 0; i < n - 1; i++) {
      if (i % 2 == 0) {
        cout << o.at(i / 2);
      } else {
        cout << e.at(i / 2);
      }
    }
    cout << o.at(n / 2) << endl;
  }
  return 0;
}


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

int main() {
  string o, e;
  cin >> o >> e;
  int n = 2 * o.size();

  if (o.size() == e.size()) {
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0) {
        cout << o.at(i / 2);
      } else {
        cout << e.at(i / 2);
      }
    }
    cout << endl;
  } else {
    for (int i = 0; i < n - 1; i++) {
      if (i % 2 == 0) {
        cout << o.at(i / 2);
      } else {
        cout << e.at(i / 2);
      }
    }
  }
  return 0;
}
Problem p03760 (C++)

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

int main() {
  string o, e;
  cin >> o >> e;
  for (int i = 0; i < o.size(); i++) {
    cout << o.at(i) << e.at(i);
  }
  cout << endl;
}

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

int main() {
  string o, e;
  cin >> o >> e;
  if (o.size() > e.size()) {
    for (int i = 0; i < e.size(); i++) {
      cout << o.at(i) << e.at(i);
    }
    cout << o.at(o.size() - 1);
  } else {
    for (int i = 0; i < e.size(); i++) {
      cout << o.at(i) << e.at(i);
    }
  }
  cout << endl;
}
Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define r(i, n) for (int i = 0; i < n; i++)

int main(void) {
  string o, e;
  cin >> o >> e;
  int num;
  for (int j = 0; j < e.size(); j++) {
    cout << o.at(j) << e.at(j);
    num = j;
  }

  cout << o.at(num + 1) << endl;

  return 0;
}


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

int main(void) {
  string o, e;
  cin >> o >> e;
  int num;
  for (int j = 0; j < e.size(); j++) {
    cout << o.at(j) << e.at(j);
    num = j;
  }

  if ((o.size() + e.size()) % 2 == 0) {
    cout << endl;
  } else {
    cout << o.at(num + 1) << endl;
  }

  return 0;
}
Problem p03760 (C++)

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

int main() {
  string O, E;
  cin >> O >> E;
  for (int i = 0; i < O.size(); i++) {
    cout << O.at(i) << E.at(i);
  }
}


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

int main() {
  string O, E;
  cin >> O >> E;
  int o = O.size();

  if (O.size() == E.size()) {
    for (int i = 0; i < O.size(); i++) {
      cout << O.at(i) << E.at(i);
    }
  } else {
    for (int i = 0; i < E.size(); i++) {
      cout << O.at(i) << E.at(i);
    }
    cout << O.at(o - 1);
  }
}
Problem p03760 (C++)

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

int main() {
  string o, e;
  cin >> o >> e;
  int l = o.size();
  for (int i = 0; i < l; i++) {
    cout << o.at(i) << e.at(i);
  }
  if (l < o.size())
    cout << o.at(l);
  cout << endl;
  return 0;
}


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

int main() {
  string o, e;
  cin >> o >> e;
  int l = e.size();
  for (int i = 0; i < l; i++) {
    cout << o.at(i) << e.at(i);
  }
  if (l < o.size())
    cout << o.at(l);
  cout << endl;
  return 0;
}
Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < t.size(); i++) {
    cout << s.at(i) << t.at(i);
  }
  if (s.size() > t.size())
    cout << s.at(s.size()) << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < t.size(); i++) {
    cout << s.at(i) << t.at(i);
  }
  if (s.size() > t.size())
    cout << s.at(s.size() - 1) << endl;
}
Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;
int main() {
  string O, E, A, b, c;
  cin >> O;
  cin >> E;
  for (int i = 0; O.size() >= i; i++) {
    b = O.substr(i, 1);
    c = E.substr(i, 1);
    A += b + c;
  }
  cout << A << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  string O, E, A, b, c;
  cin >> O;
  cin >> E;
  for (int i = 0; O.size() >= i; i++) {
    b = O.substr(i, 1);
    if (i <= E.size()) {
      c = E.substr(i, 1);
    }
    A += b + c;
  }
  cout << A << endl;
  return 0;
}
Problem p03760 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(x) (x).begin(), (x).end()

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  string res;
  int id = 0;
  if (s.length() > t.length())
    t = t + " ";
  while (1) {
    res = res + s[id] + t[id];
    id++;
  }
  cout << res << endl;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(x) (x).begin(), (x).end()

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  string res;
  int id = 0;
  if (s.length() > t.length())
    t = t + " ";
  while (1) {
    res = res + s[id] + t[id];
    id++;
    if (id == s.length())
      break;
  }
  cout << res << endl;
}
Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  string O, E;
  cin >> O >> E;
  rep(i, O.size()) { cout << O.at(i) << E.at(i); }
  cout << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  string O, E;
  cin >> O >> E;
  rep(i, E.size()) { cout << O.at(i) << E.at(i); }
  if (O.size() - E.size() == 1)
    cout << O.at(O.size() - 1);
  cout << endl;
}
Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string O, E;
  cin >> O >> E;
  reverse(O.begin(), O.end());
  reverse(E.begin(), E.end());
  for (int i = 1; !O.empty() || E.empty(); i++) {
    if (i % 2) {
      cout << O.back();
      O.pop_back();
    } else {
      cout << E.back();
      E.pop_back();
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string O, E;
  cin >> O >> E;
  reverse(O.begin(), O.end());
  reverse(E.begin(), E.end());
  for (int i = 1; !O.empty() || !E.empty(); i++) {
    if (i % 2) {
      cout << O.back();
      O.pop_back();
    } else {
      cout << E.back();
      E.pop_back();
    }
  }
}
Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string O, E;
  cin >> O >> E;
  int M = O.size(), N = E.size();
  for (int i = 0; i < N; i++)
    cout << O.at(i) << E.at(i);
  if (M > N)
    cout << O.at(M);
  cout << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string O, E;
  cin >> O >> E;
  int M = O.size(), N = E.size();
  for (int i = 0; i < N; i++)
    cout << O.at(i) << E.at(i);
  if (M > N)
    cout << O.at(M - 1);
  cout << endl;
}
Problem p03760 (C++)

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

int main() {

  string O, E;

  cin >> O >> E;

  for (int i = 0; i < O.size(); i++) {

    cout << O.at(i);

    if (i < E.at(i)) {

      cout << E.at(i);
    }
  }
  return 0;
}


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

int main() {

  string O, E;

  cin >> O >> E;

  for (int i = 0; i < O.size(); i++) {

    cout << O.at(i);

    if (i < E.size()) {

      cout << E.at(i);
    }
  }
  return 0;
}
Problem p03760 (Python)

Buggy submission (status: Runtime Error):
from itertools import zip_longest

print("".join(sum(zip_longest(input(), input()), tuple())))


Fixed submission:
from itertools import zip_longest

print("".join(sum(zip_longest(input(), input(), fillvalue=""), tuple())))
Problem p03760 (Python)

Buggy submission (status: Runtime Error):
o = list(input())
e = list(input())
for i in range(len(o)):
    print(o[i] + e[i], end="")


Fixed submission:
o = list(input())
e = list(input()) + [""]
for i, j in zip(o, e):
    print(i + j, end="")
Problem p03760 (Python)

Buggy submission (status: Runtime Error):
import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    o = input()
    e = input()
    res = []
    for i in range(len(o)):
        res.append(o[i])
        res.append(e[i])
    print("".join(res))


if __name__ == "__main__":
    resolve()


Fixed submission:
import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    o = list(input())
    e = list(input())

    res = [""] * (len(o) + len(e))
    for i in range(len(o) + len(e)):
        if i % 2 != 0:
            s = e.pop(0)
            res[i] = s
        else:
            s = o.pop(0)
            res[i] = s

    print("".join(res))


if __name__ == "__main__":
    resolve()
Problem p03760 (Python)

Buggy submission (status: Runtime Error):
#!/usr/bin/env python3


def main():
    a = input()
    b = input() + [""]
    for i in range(len(a)):
        print(a[i], end="")
        print(b[i], end="")


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3


def main():
    a = list(input())
    b = list(input()) + [""]
    for i in range(len(a)):
        print(a[i], end="")
        print(b[i], end="")


if __name__ == "__main__":
    main()
Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int i = 1;
  int a = 0;
  int b = 0;
  while (i <= s1.size() + s2.size()) {
    if (i % 2)
      cout << s1[a], a++;
    else
      cout << s2[b], b++;
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int i = 1;
  int a = 0;
  int b = 0;
  while (i <= s1.size() + s2.size()) {
    if (i % 2)
      cout << s1[a], a++;
    else
      cout << s2[b], b++;
    i++;
  }
  return 0;
}
Problem p03760 (C++)

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

int main() {
  string s1, s2, res = "";
  cin >> s1;
  cin >> s2;
  int i = 0;
  while (i < s2.size()) {
    res += s1[i];
    res += s2[i];
  }
  if (i < s1.size()) {
    res += s1[i];
  }
  cout << res << "\n";
  return 0;
}

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

int main() {
  string s1, s2, res = "";
  cin >> s1;
  cin >> s2;
  int i = 0;
  while (i < s2.size()) {
    res += s1[i];
    res += s2[i];
    i++;
  }
  if (i < s1.size()) {
    res += s1[i];
  }
  cout << res << "\n";
  return 0;
}
Problem p03761 (C++)

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

using namespace std;

int main() {
  int n = 0;
  cin >> n;
  vector<string> moji(n);
  for (int i = 0; i < n; i++) {
    cin >> moji.at(i);
  }
  vector<int> count(26);
  for (char s = 'a'; s <= 'z'; s++) {
    int min = 100000;
    for (string str : moji) {
      int buf = 0;
      for (char c : str) {
        if (c == s)
          buf++;
      }
      if (buf < min)
        min = buf;
    }
    count.at(s - 'a') = min;
  }
  for (int i = 0; i < n; i++) {
    char put = 'a' + i;
    for (int j = 0; j < count.at(i); j++) {
      cout << put;
    }
  }
  cout << endl;
  return 0;
}


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

using namespace std;

int main() {
  int n = 0;
  cin >> n;
  vector<string> moji(n);
  for (int i = 0; i < n; i++) {
    cin >> moji.at(i);
  }
  vector<int> count(26);
  for (char s = 'a'; s <= 'z'; s++) {
    int min = 100000;
    for (string str : moji) {
      int buf = 0;
      for (char c : str) {
        if (c == s)
          buf++;
      }
      if (buf < min)
        min = buf;
    }
    count.at(s - 'a') = min;
  }
  for (int i = 0; i < 26; i++) {
    char put = 'a' + i;
    for (int j = 0; j < count.at(i); j++) {
      cout << put;
    }
  }
  cout << endl;
  return 0;
}