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

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

typedef long long ll;
const int Maxn = 1e6;
const ll Mod = 1e9 + 7;

ll fac[Maxn + 5], inv_fac[Maxn + 5];
ll QuickPow(ll a, ll k) {
  ll ret = 1;
  while (k) {
    if (k & 1)
      ret = (ret * a) % Mod;
    a = (a * a) % Mod;
    k >>= 1;
  }
  return ret;
}
void init() {
  fac[0] = 1;
  for (int i = 1; i <= Maxn; i++)
    fac[i] = fac[i - 1] * i % Mod;
  inv_fac[0] = 1, inv_fac[Maxn] = QuickPow(fac[Maxn], Mod - 2);
  for (int i = Maxn - 1; i >= 1; i--)
    inv_fac[i] = inv_fac[i + 1] * (i + 1) % Mod;
}
ll C(int n, int m) { return fac[n] * inv_fac[m] % Mod * inv_fac[n - m] % Mod; }

ll calc(int n, int m, int num, int l, int r) {
  if (num - r * m < 0)
    return 0;
  else
    num -= (r * m);
  ll ret = 0;
  for (int i = 0, dir = 1; i <= n - m && num >= 0; i++, num -= l, dir *= -1)
    ret =
        (ret + 1LL * dir * C(num + n, n) % Mod * C(n - m, i) % Mod + Mod) % Mod;
  return ret * C(n, m) % Mod;
}
ll Solve(int n, int m, int num) {
  ll ret = C(n + num, n);
  for (int i = num; i >= 1; i--) {
    int del = (calc(n, m, num, i, i) - calc(n, m, num, i, i + 1) + Mod) % Mod;
    ret = (ret - del + Mod) % Mod;
  }
  return ret;
}

int main() {
#ifdef LOACL
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  int N, M, L, R;
  init();
  scanf("%d %d %d %d", &N, &M, &L, &R);
  printf("%lld\n", (Solve(N, M, R) - Solve(N, M, L - 1) + Mod) % Mod);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
using namespace std;

typedef long long ll;
const int Maxn = 1e6;
const ll Mod = 1e9 + 7;

ll fac[Maxn + 5], inv_fac[Maxn + 5];
ll QuickPow(ll a, ll k) {
  ll ret = 1;
  while (k) {
    if (k & 1)
      ret = (ret * a) % Mod;
    a = (a * a) % Mod;
    k >>= 1;
  }
  return ret;
}
void init() {
  fac[0] = 1;
  for (int i = 1; i <= Maxn; i++)
    fac[i] = fac[i - 1] * i % Mod;
  inv_fac[0] = 1, inv_fac[Maxn] = QuickPow(fac[Maxn], Mod - 2);
  for (int i = Maxn - 1; i >= 1; i--)
    inv_fac[i] = inv_fac[i + 1] * (i + 1) % Mod;
}
ll C(int n, int m) { return fac[n] * inv_fac[m] % Mod * inv_fac[n - m] % Mod; }

ll calc(int n, int m, int num, int l, int r) {
  if (num - 1LL * r * m < 0)
    return 0;
  else
    num -= (r * m);
  ll ret = 0;
  for (int i = 0, dir = 1; i <= n - m && num >= 0; i++, num -= l, dir *= -1)
    ret =
        (ret + 1LL * dir * C(num + n, n) % Mod * C(n - m, i) % Mod + Mod) % Mod;
  return ret * C(n, m) % Mod;
}
ll Solve(int n, int m, int num) {
  ll ret = C(n + num, n);
  for (int i = num; i >= 1; i--) {
    int del = (calc(n, m, num, i, i) - calc(n, m, num, i, i + 1) + Mod) % Mod;
    ret = (ret - del + Mod) % Mod;
  }
  return ret;
}

int main() {
#ifdef LOACL
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  int N, M, L, R;
  init();
  scanf("%d %d %d %d", &N, &M, &L, &R);
  printf("%lld\n", (Solve(N, M, R) - Solve(N, M, L - 1) + Mod) % Mod);
  return 0;
}
Problem p02932 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5, mod = 1e9 + 7;
typedef long long ll;
int n, m, l, r;
ll f[N], inv[N], invf[N];
ll C(int n, int m) { return f[n] * invf[n - m] % mod * invf[m] % mod; }
ll g(int x, int y, int k) {
  int s = k - x * m;
  ll res = 0;
  for (int i = 0, f = 1; i * y <= s && i <= n - m; i++, f *= -1)
    res = (res + f * C(n - m, i) % mod * C(s - i * y + n, n)) % mod;
  return res;
}
ll solve(int k) {
  ll ans = 0;
  for (int x = 1; x * m <= k; x++)
    ans = (ans + g(x, x, k) - g(x + 1, x, k)) % mod;
  return (C(k + n, n) - ans * C(n, m)) % mod;
}
int main() {
  f[0] = f[1] = invf[0] = invf[1] = inv[1] = 1;
  for (int i = 2; i < N; i++) {
    inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    f[i] = f[i - 1] * i % mod;
    invf[i] = invf[i - 1] * inv[i] % mod;
  }
  scanf("%d%d%d%d", &n, &m, &l, &r);
  printf("%lld\n", ((solve(r) - solve(l - 1)) % mod + mod) % mod);
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int N = 6e5 + 5, mod = 1e9 + 7;
typedef long long ll;
int n, m, l, r;
ll f[N], inv[N], invf[N];
ll C(int n, int m) { return f[n] * invf[n - m] % mod * invf[m] % mod; }
ll g(int x, int y, int k) {
  int s = k - x * m;
  ll res = 0;
  for (int i = 0, f = 1; i * y <= s && i <= n - m; i++, f *= -1)
    res = (res + f * C(n - m, i) % mod * C(s - i * y + n, n)) % mod;
  return res;
}
ll solve(int k) {
  ll ans = 0;
  for (int x = 1; x * m <= k; x++)
    ans = (ans + g(x, x, k) - g(x + 1, x, k)) % mod;
  return (C(k + n, n) - ans * C(n, m)) % mod;
}
int main() {
  f[0] = f[1] = invf[0] = invf[1] = inv[1] = 1;
  for (int i = 2; i < N; i++) {
    inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    f[i] = f[i - 1] * i % mod;
    invf[i] = invf[i - 1] * inv[i] % mod;
  }
  scanf("%d%d%d%d", &n, &m, &l, &r);
  printf("%lld\n", ((solve(r) - solve(l - 1)) % mod + mod) % mod);
}
Problem p02932 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <iostream>
using namespace std;
const int N = 600005;
const int MOD = 1000000007;
int n, m, L, R;
long long fac[N], inv[N];
long long ksm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1)
      res = res * a % MOD;
    a = a * a % MOD, b >>= 1;
  }
  return res;
}
void init(int n = 600000) {
  fac[0] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = fac[i - 1] * i % MOD;
  inv[n] = ksm(fac[n], MOD - 2);
  for (int i = n; i >= 1; i--)
    inv[i - 1] = inv[i] * i % MOD;
  return;
}
long long C(int n, int m) {
  if (m > n)
    return 0;
  else
    return fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
long long calc(int x, int p, int q) {
  x -= 1LL * m * p;
  if (x < 0)
    return 0;
  long long res = 0;
  for (int i = 0; i <= n - m && x - 1LL * i * q >= 0; i++)
    if (i & 1)
      res = (res - C(n - m, i) * C(x - 1LL * i * q + n, n) % MOD + MOD) % MOD;
    else
      res = (res + C(n - m, i) * C(x - 1LL * i * q + n, n) % MOD) % MOD;
  res *= C(n, m);
  return res;
}
long long solve(int x) {
  long long res = 0;
  for (int p = 1; p <= x; p++)
    res = (res + (calc(x, p, p) - calc(x, p, p - 1) + MOD) % MOD) % MOD;
  res = (C(x + n, n) - res + MOD) % MOD;
  return res;
}
int main() {
  init();
  scanf("%d%d%d%d", &n, &m, &L, &R);
  printf("%lld", (solve(R) - solve(L - 1) + MOD) % MOD);
  return 0;
}

Fixed submission:
#include <cstdio>
#include <iostream>
using namespace std;
const int N = 600005;
const int MOD = 1000000007;
int n, m, L, R;
long long fac[N], inv[N];
long long ksm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1)
      res = res * a % MOD;
    a = a * a % MOD, b >>= 1;
  }
  return res;
}
void init(int n = 600000) {
  fac[0] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = fac[i - 1] * i % MOD;
  inv[n] = ksm(fac[n], MOD - 2);
  for (int i = n; i >= 1; i--)
    inv[i - 1] = inv[i] * i % MOD;
  return;
}
long long C(int n, int m) {
  if (m > n)
    return 0;
  else
    return fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
long long calc(long long x, int p, int q) {
  x -= 1LL * m * p;
  if (x < 0)
    return 0;
  long long res = 0;
  for (int i = 0; i <= n - m && x - 1LL * i * q >= 0; i++)
    if (i & 1)
      res = (res - C(n - m, i) * C(x - 1LL * i * q + n, n) % MOD + MOD) % MOD;
    else
      res = (res + C(n - m, i) * C(x - 1LL * i * q + n, n) % MOD) % MOD;
  res *= C(n, m);
  return res;
}
long long solve(int x) {
  long long res = 0;
  for (int p = 1; p <= x; p++)
    res = (res + (calc(x, p, p) - calc(x, p, p - 1) + MOD) % MOD) % MOD;
  res = (C(x + n, n) - res + MOD) % MOD;
  return res;
}
int main() {
  init();
  scanf("%d%d%d%d", &n, &m, &L, &R);
  printf("%lld", (solve(R) - solve(L - 1) + MOD) % MOD);
  return 0;
}
Problem p02933 (C++)

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

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)                                                                   \
  int x;                                                                       \
  cin >> x;                                                                    \
  while (x--)
#define pw(b, p) pow(b, p) + 0.1
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

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

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

  if (n >= 3200)
    cout << s << '\n';
  else
    cout << "red\n";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)                                                                   \
  int x;                                                                       \
  cin >> x;                                                                    \
  while (x--)
#define pw(b, p) pow(b, p) + 0.1
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

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

  if (n >= 3200)
    cout << s << '\n';
  else
    cout << "red\n";
  return 0;
}
Problem p02933 (C++)

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

#define ll long long int
#define f(i, g, n) for (int i = g; i <= n; i++)

int main() {
  ios::sync_with_stdio(false);

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

  int a;
  string S;
  cin >> a >> S;
  a < 3200 ? cout << "red\n" : cout << S << "\n";

  return 0;
}

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

#define ll long long int
#define f(i, g, n) for (int i = g; i <= n; i++)

int main() {
  ios::sync_with_stdio(false);

  int a;
  string S;
  cin >> a >> S;
  a < 3200 ? cout << "red\n" : cout << S << "\n";

  return 0;
}
Problem p02933 (C++)

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

int main() {
  int a;
  char s[5];
  cin >> a;
  cin >> s;

  if (a >= 3200) {
    cout << s;
  } else {
    cout << "red";
  }

  return 0;
}

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

int main() {
  int a;
  char s[100];
  cin >> a;
  cin >> s;

  if (a >= 3200) {
    cout << s;
  } else {
    cout << "red";
  }

  return 0;
}
Problem p02933 (C++)

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

  int a;
  scanf("%d", &a);
  char *s;
  scanf("%s", s);
  if (a >= 3200) {
    printf("%s\n", s);
  } else {
    printf("red\n");
  }

  return 0;
}

Fixed submission:
#include <iostream>
int main() {

  int a;
  scanf("%d", &a);
  char s[10];
  scanf("%s", s);
  if (a >= 3200) {
    printf("%s\n", s);
  } else {
    printf("red\n");
  }

  return 0;
}
Problem p02933 (C++)

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

int main(int argc, char const *argv[]) {
  int a = atoi(argv[1]);
  string s = argv[2];
  if (a < 3200) {
    cout << "red" << endl;
  } else {
    cout << s << endl;
  }
  return 0;
}


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

int main(int argc, char const *argv[]) {
  // int a = atoi(argv[1]);
  // string s = argv[2];
  int a;
  string s;
  cin >> a;
  cin >> s;
  if (a < 3200) {
    cout << "red" << endl;
  } else {
    cout << s << endl;
  }
  return 0;
}
Problem p02933 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define vpll vector<pll>
#define all(x) x.begin(), x.end()
#define present(c, x) ((c).find(x) != (c).end())
#define dbg(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char *name, Arg1 &&arg1) {
  std::cerr << name << " = " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
#define sz(a) a.size()
#define vll vector<int>
#define pll pair<int, int>
#define ff first
#define ss second
#define br cout << "\n";
#define ld long double
#define int long long int
const int INF = 1e18 + 7;
const int MAX = 1234567;
const int MOD = 1000000007;

void solve() {
  int a;
  string s;
  cin >> a >> s;
  if (a < 3200)
    cout << "red";
  else
    cout << s;
}
int32_t main() {
  int t;
  t = 1;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  cin.sync_with_stdio(0), cin.tie(0);
  // cin>>t;
  while (t--) {
    solve();
    br;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define vpll vector<pll>
#define all(x) x.begin(), x.end()
#define present(c, x) ((c).find(x) != (c).end())
#define dbg(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char *name, Arg1 &&arg1) {
  std::cerr << name << " = " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
#define sz(a) a.size()
#define vll vector<int>
#define pll pair<int, int>
#define ff first
#define ss second
#define br cout << "\n";
#define ld long double
#define int long long int
const int INF = 1e18 + 7;
const int MAX = 1234567;
const int MOD = 1000000007;

void solve() {
  int a;
  string s;
  cin >> a >> s;
  if (a < 3200)
    cout << "red";
  else
    cout << s;
}
int32_t main() {
  int t;
  t = 1;
  cin.sync_with_stdio(0), cin.tie(0);
  // cin>>t;
  while (t--) {
    solve();
    br;
  }
  return 0;
}
Problem p02933 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
typedef vector<ll> vl;
#define PB push_back
#define ios()                                                                  \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);
#define scan(a, n)                                                             \
  for (ll i = 0; i < n; i++)                                                   \
    cin >> a[i];
#define print(a, n)                                                            \
  for (ll i = 0; i < n; i++)                                                   \
    cout << a[i] << "\n";
#define test()                                                                 \
  ll t;                                                                        \
  cin >> t;                                                                    \
  while (t--)
#define endl "\n"

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios() ll a;
  string s;
  cin >> a >> s;
  if (a < 3200)
    cout << "red\n";
  else
    cout << s << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
typedef vector<ll> vl;
#define PB push_back
#define ios()                                                                  \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);
#define scan(a, n)                                                             \
  for (ll i = 0; i < n; i++)                                                   \
    cin >> a[i];
#define print(a, n)                                                            \
  for (ll i = 0; i < n; i++)                                                   \
    cout << a[i] << "\n";
#define test()                                                                 \
  ll t;                                                                        \
  cin >> t;                                                                    \
  while (t--)
#define endl "\n"

int main() {
  ios() ll a;
  string s;
  cin >> a >> s;
  if (a < 3200)
    cout << "red\n";
  else
    cout << s << endl;
  return 0;
}
Problem p02933 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
const int maxn = 15;
using namespace std;

int a;
char s[maxn];

int main() {
  while (scanf("%d%s", &a, s)) {
    if (a < 3200)
      printf("red\n");
    else
      printf("%s\n", s);
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
const int maxn = 15;
using namespace std;

int a;
char s[maxn];

int main() {
  while (~scanf("%d%s", &a, s)) {
    if (a < 3200)
      printf("red\n");
    else
      printf("%s\n", s);
  }
  return 0;
}
Problem p02933 (C++)

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

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int, int>
#define pb push_back

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  //  code starts
  int n;
  cin >> n;
  string s;
  cin >> s;
  if (n < 3200) {
    cout << "red";
    return 0;
  }

  cout << s;

  return 0;
}

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

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int, int>
#define pb push_back

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  //  code starts
  int n;
  cin >> n;
  string s;
  cin >> s;
  if (n < 3200) {
    cout << "red";
    return 0;
  }

  cout << s;

  return 0;
}
Problem p02933 (C++)

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

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define MX 200005
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)                                                                   \
  int x;                                                                       \
  cin >> x;                                                                    \
  while (x--)
#define pw(b, p) pow(b, p) + 0.1
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

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

int32_t main() {
  c_p_c();
  int x;
  string s;
  cin >> x >> s;

  if (x < 3200)
    cout << "red\n";
  else
    cout << s << '\n';
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define MX 200005
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)                                                                   \
  int x;                                                                       \
  cin >> x;                                                                    \
  while (x--)
#define pw(b, p) pow(b, p) + 0.1
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

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

int32_t main() {
  // c_p_c();
  int x;
  string s;
  cin >> x >> s;

  if (x < 3200)
    cout << "red\n";
  else
    cout << s << '\n';
  return 0;
}
Problem p02933 (C++)

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

int main() {
  int a;
  char *s;
  cin >> a >> s;
  cout << (a >= 3200 ? s : "red") << endl;
  return 0;
}


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

int main() {
  int a;
  char s[11];
  cin >> a >> s;
  cout << (a >= 3200 ? s : "red") << endl;
  return 0;
}
Problem p02933 (C++)

Buggy submission (status: Runtime Error):
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define rep(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define anin(a) printf("%d\n", a);

int main(void) {
  int a, ans(0);
  char mozi(10);
  scanf("%d", &a);
  scanf("%s", mozi);
  if (a >= 3200)
    printf("%s\n", mozi);
  else
    printf("red\n");
  return 0;
}


Fixed submission:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define rep(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define anin(a) printf("%d\n", a);

int main(void) {
  int a, ans(0);
  char mozi[10];
  scanf("%d %s", &a, mozi);
  if (a >= 3200)
    printf("%s\n", mozi);
  else
    printf("red\n");
  return 0;
}
Problem p02933 (C++)

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

int main() {
  char s[5];
  int a;
  cin >> a;
  cin >> s;
  if (a >= 3200)
    cout << s << endl;
  if (a < 3200)
    cout << "red" << endl;
}

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

int main() {
  char s[15];
  int a;
  cin >> a;
  cin >> s;
  if (a >= 3200)
    cout << s << endl;
  if (a < 3200)
    cout << "red" << endl;
}
Problem p02933 (Python)

Buggy submission (status: Runtime Error):
import sys

input = sys.stdin.readline

# input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10**18
MOD = 10**9 + 7


def main():
    a = int(input())
    s = int(input())

    if a >= 3200:
        print(s)
    else:
        print("red")


if __name__ == "__main__":
    main()


Fixed submission:
import sys

input = sys.stdin.readline

# input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10**18
MOD = 10**9 + 7


def main():
    a = int(input())
    s = input()

    if a >= 3200:
        print(s)
    else:
        print("red")


if __name__ == "__main__":
    main()
Problem p02933 (Python)

Buggy submission (status: Runtime Error):
a = input()
s = input()
if a >= 3200:
    print(s)
else:
    print("red")


Fixed submission:
a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print("red")
Problem p02933 (Python)

Buggy submission (status: Runtime Error):
a = int(input())
s = int(input())
print(s if a < 3200 else "red")


Fixed submission:
a = int(input())
s = input()
print(s if a >= 3200 else "red")
Problem p02933 (C++)

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

using namespace std;

int main() {
  int a;
  string s;
  cin >> a;
  cin >> s;
  if (a < 3200)
    cout << "red" << endl;
  else
    cout << s << endl;
  return main();
}


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

using namespace std;

int main() {
  int a;
  string s;
  cin >> a;
  cin >> s;
  if (a < 3200)
    cout << "red" << endl;
  else
    cout << s << endl;
  return 0;
}
Problem p02934 (C++)

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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<string> vec(N);
  for (int i = 0; i < 3; ++i)
    cin >> vec[i];
  double res = 0;
  for (auto &&v : vec)
    res += 1.0 / stol(v);
  cout << setprecision(10) << (1.0 / res);
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<string> vec(N);
  for (int i = 0; i < N; ++i)
    cin >> vec[i];
  double res = 0;
  for (auto &&v : vec)
    res += 1.0 / stol(v);
  cout << setprecision(10) << (1.0 / res);
}
Problem p02934 (C++)

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

int main() {
  int n = 0, input = 0, sum = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> input;
    sum += 1 / input;
  }

  cout << 1 / sum << endl;

  return 0;
}

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

int main() {
  int n = 0;
  double input = 0.9, sum = 0.0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> input;
    sum += 1 / input;
  }

  cout << 1 / sum << endl;

  return 0;
}
Problem p02934 (C++)

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

int main() {
  int n, a[1000], suma = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = 1 / a[i];
    suma += a[i];
  }
  cout << 1 / suma;
  return 0;
}


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

int main() {
  double n, a[1005], suma = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = 1 / a[i];
    suma += a[i];
  }
  cout << 1 / suma;
  return 0;
}
Problem p02934 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
int main() {
  int n, s = 0;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    float a;
    std::cin >> a;
    s += 1 / a;
  }

  std::cout << 1 / s;
  return 0;
}

Fixed submission:
#include <iostream>
int main() {
  int n;
  float s = 0;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    float a;
    std::cin >> a;
    s += 1 / a;
  }

  std::cout << 1 / s;
  return 0;
}
Problem p02934 (C++)

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<double> A(N);
  double ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] = 1.0 / A[i];
  }
  ans = 1.0 / accumulate(A.begin(), A.end(), 0.0);
  cout << ans << endl;
  return true;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<double> A(N);
  double ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] = 1.0 / A[i];
  }
  ans = 1.0 / accumulate(A.begin(), A.end(), 0.0);
  cout << ans << endl;
  return 0;
}
Problem p02934 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0;
  cin >> n;
  double a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    sum = sum + (1 / a[i]);
  }
  cout << 1 / sum << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  double sum = 0.0;
  cin >> n;
  double a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    sum = sum + (1 / a[i]);
  }
  cout << 1 / sum << endl;
}
Problem p02934 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

  size_t N;
  std::cin >> N;
  assert(N <= 100);

  std::vector<double> A(N);
  for (auto &ai : A)
    std::cin >> ai;

  double res = 0;
  for (auto ai : A)
    res += 1.0 / ai;
  res = 1.0 / res;

  std::cout << std::fixed << std::setprecision(65252854) << res << std::endl;
}


Fixed submission:
#include <algorithm>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

  size_t N;
  std::cin >> N;
  assert(N <= 100);

  std::vector<double> A(N);
  for (auto &ai : A)
    std::cin >> ai;

  double res = 0;
  for (auto ai : A)
    res += 1.0 / ai;
  res = 1.0 / res;

  std::cout << std::fixed << std::setprecision(65200000) << res << std::endl;
}
Problem p02934 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n;
  double a[101], b[101];
  cin >> n;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = 1 / a[i];
    sum += b[i];
  }
  cout << 1 / sum << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n;
  double a[101], b[101];
  cin >> n;
  double sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = 1 / a[i];
    sum += b[i];
  }
  cout << 1 / sum << endl;
  return 0;
}
Problem p02934 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

  size_t N;
  std::cin >> N;
  assert(N <= 100);

  std::vector<double> A(N);
  for (auto &ai : A)
    std::cin >> ai;

  double res = 0;
  for (auto ai : A)
    res += 1.0 / ai;
  res = 1.0 / res;

  std::cout << std::fixed << std::setprecision(75000000) << res << std::endl;
}

Fixed submission:
#include <algorithm>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

  size_t N;
  std::cin >> N;
  assert(N <= 100);

  std::vector<double> A(N);
  for (auto &ai : A)
    std::cin >> ai;

  double res = 0;
  for (auto ai : A)
    res += 1.0 / ai;
  res = 1.0 / res;

  std::cout << std::fixed << std::setprecision(10000000) << res << std::endl;
}
Problem p02934 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX 10005
#define int long long
#define T                                                                      \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define f(i, a, b) for (int i = a; i < b; i++)
#define debug(x) cout << x = << x << n;
#define set_dp(dp) memset(dp, -1, sizeof(dp))
using namespace std;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int n;
  cin >> n;
  vector<int> v(n);
  f(i, 0, n) cin >> v[i];
  float ans = v[0];
  f(i, 1, n) { ans = (ans * v[i]) / (ans + v[i]); }
  cout << ans;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX 10005
#define int long long
#define T                                                                      \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define f(i, a, b) for (int i = a; i < b; i++)
#define debug(x) cout << x = << x << n;
#define set_dp(dp) memset(dp, -1, sizeof(dp))
using namespace std;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int n;
  cin >> n;
  vector<int> v(n);
  f(i, 0, n) cin >> v[i];
  float ans = v[0];
  f(i, 1, n) { ans = (ans * v[i]) / (ans + v[i]); }
  cout << ans;
  return 0;
}
Problem p02934 (C++)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int sum = 0;
  int n = 0;
  cin >> n;
  rep(i, n) {
    double A = 0;
    cin >> A;
    sum += 1 / A;
  }
  cout << 1 / sum << endl;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  double sum = 0;
  int n = 0;
  cin >> n;
  rep(i, n) {
    double A = 0;
    cin >> A;
    sum += 1 / A;
  }
  cout << 1 / sum << endl;
}
Problem p02934 (C++)

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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  double ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    ans += 1.0 / a;
  }
  ans = 1 / ans;
  cout << setprecision(12) << fixed << ans << endl;
}

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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  double ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    ans += 1.0 / a;
  }
  ans = 1 / ans;
  cout << setprecision(12) << fixed << ans << endl;
}
Problem p02934 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n = 1;
  cin >> n;
  vector<double> a(n);
  double s1 = 0, s2 = 1;
  for (int i = 0; i < n; i++) {
    cin >> a[n];
    s1 += 1 / a[n];
  }
  cout << 1 / s1 << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n = 1;
  cin >> n;
  // vector<double>a(n);
  double a[105];
  double s1 = 0, s2 = 1;
  for (int i = 0; i < n; i++) {
    cin >> a[n];
    s1 += 1 / a[n];
  }
  cout << 1 / s1 << endl;
  return 0;
}
Problem p02934 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  float ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    ans += (float)1 / A[i];
  }
  return (float)1 / ans;
}


Fixed submission:
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  float ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    ans += (float)1 / A[i];
  }
  cout << (float)1 / ans << endl;
  return 0;
}
Problem p02934 (C++)

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

#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const i64 MOD = 1000000007;
const int INF = 2000000000;

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

  int n;
  cin >> n;

  i64 mul = 0;

  REP(i, 0, n - 1) {
    double x;
    cin >> x;

    mul += 1 / x;
  }

  cout << 1 / mul << endl;

  return 0;
}

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

#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const i64 MOD = 1000000007;
const int INF = 2000000000;

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

  int n;
  cin >> n;

  double mul = 0;

  REP(i, 0, n - 1) {
    double x;
    cin >> x;

    mul += 1 / x;
  }

  cout << 1 / mul << endl;

  return 0;
}
Problem p02934 (C++)

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

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define MX 200005
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)                                                                   \
  int x;                                                                       \
  cin >> x;                                                                    \
  while (x--)
#define pw(b, p) pow(b, p) + 0.1
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

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

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

  double ans = 0.0;

  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;

    ans += 1.0 / x;
  }

  ans = 1.0 / ans;

  cout << ans << '\n';
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define MX 200005
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)                                                                   \
  int x;                                                                       \
  cin >> x;                                                                    \
  while (x--)
#define pw(b, p) pow(b, p) + 0.1
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

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

int32_t main() {
  // c_p_c();
  int n;
  cin >> n;

  double ans = 0.0;

  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;

    ans += 1.0 / x;
  }

  ans = 1.0 / ans;

  cout << ans << '\n';
  return 0;
}
Problem p02934 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

div = 0
for i in range(n):
    div += a / a[i]
print(1 / div)


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

div = 0
for i in range(n):
    div += 1 / a[i]
print(1 / div)
Problem p02934 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in n:
    ans += 1 / i
print(1 / ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in a:
    ans += 1 / i
print(1 / ans)
Problem p02934 (Python)

Buggy submission (status: Runtime Error):
import numpy as np

N = int(input())
A = [float(input()) for _ in range(N)]

nA = np.array(A)
print(np.reciprocal(np.sum(np.reciprocal(nA))))


Fixed submission:
import numpy as np

N = int(input())
A = [float(x) for x in input().split()]

nA = np.array(A)
print(np.reciprocal(np.sum(np.reciprocal(nA))))
Problem p02934 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int n;
  float gyaku[10], sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> gyaku[i];
    gyaku[i] = 1 / gyaku[i];
    sum += gyaku[i];
  }
  cout << 1 / sum;
}

Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int n;
  float gyaku[100], sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> gyaku[i];
    gyaku[i] = 1 / gyaku[i];
    sum += gyaku[i];
  }
  cout << 1 / sum;
}
Problem p02935 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++)
    cin >> v[i];
  sort(v.begin(), v.end());
  float res = (float)v[0];
  for (int i = 1; i < n; i++)
    res = (float)((res + v[i]) / 2);

  cout << res << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  sort(v.begin(), v.end());
  float res = (float)v[0];
  for (int i = 1; i < n; i++)
    res = (float)((res + v[i]) / 2);

  cout << res << endl;
  return 0;
}
Problem p02935 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <math.h>
#include <queue>
#include <vector>

using namespace std;

void solve() {
  int n;
  cin >> n;
  vector<int> gu(n);
  for (int i = 0; i < n; i++) {
    cin >> gu[i];
  }

  sort(gu.begin(), gu.end());
  double maxv = 0;
  do {
    double value = gu[0];
    for (int i = 1; i < gu.size(); i++) {
      value = (value + gu[i]) / 2;
    }
    maxv = max(maxv, value);
  } while (next_permutation(gu.begin(), gu.end()));

  cout << maxv;
}

int main() {
  solve();
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <math.h>
#include <queue>
#include <vector>

using namespace std;

void solve() {
  int n;
  cin >> n;
  vector<int> gu(n);
  for (int i = 0; i < n; i++) {
    cin >> gu[i];
  }

  sort(gu.begin(), gu.end());
  double maxv = 0;

  double value = gu[0];
  for (int i = 1; i < gu.size(); i++) {
    value = (value + gu[i]) / 2;
  }
  maxv = max(maxv, value);

  cout << maxv;
}

int main() {
  solve();
  return 0;
}
Problem p02935 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  priority_queue<double, vector<double>, greater<double>> q;
  for (int i = 1; i <= n; i++) {
    double v;
    cin >> v;
    q.push(v);
  }
  while (sz(q) >= 2) {
    auto u = q.top();
    q.pop();
    auto v = q.top();
    q.pop();
    q.push((u + v) / 2);
  }
  auto ans = q.top();
  cout << fixed << setprecision(12) << ans;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  priority_queue<double, vector<double>, greater<double>> q;
  for (int i = 1; i <= n; i++) {
    double v;
    cin >> v;
    q.push(v);
  }
  while (sz(q) >= 2) {
    auto u = q.top();
    q.pop();
    auto v = q.top();
    q.pop();
    q.push((u + v) / 2);
  }
  auto ans = q.top();
  cout << fixed << setprecision(12) << ans;
  return 0;
}
Problem p02935 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
double a[10000];
int n;
double ans = 0;
double cnt() {
  double las = a[1];
  for (int i = 2; i <= n; i++) {
    las = (a[i] + las) / 2;
  }
  return las;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  sort(a + 1, a + n + 1);
  do {
    ans = max(ans, cnt());
  } while (next_permutation(a + 1, a + n + 1));
  cout << ans;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
double a[10000];
int n;
double ans = 0;
double cnt() {
  double las = a[1];
  for (int i = 2; i <= n; i++) {
    las = (a[i] + las) / 2;
  }
  return las;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  sort(a + 1, a + n + 1);
  ans = cnt();
  cout << ans;
  return 0;
}
Problem p02935 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  priority_queue<float, vector<float>, greater<float>> q;
  for (int i = 0; i < n; i++) {
    float y;
    cin >> y;
    q.push(y);
  }
  while (q.size() != 1) {
    float x = q.top();
    q.pop();
    float y = q.top();
    q.pop();
    float z = (float)(x + y) / 2;
    q.push(z);
  }
  cout << q.top() << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  priority_queue<float, vector<float>, greater<float>> q;
  for (int i = 0; i < n; i++) {
    float y;
    cin >> y;
    q.push(y);
  }
  while (q.size() != 1) {
    float x = q.top();
    q.pop();
    float y = q.top();
    q.pop();
    float z = (float)(x + y) / 2;
    q.push(z);
  }
  cout << q.top() << endl;

  return 0;
}