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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[2010][2010], n;
ll nthblueat[2010], nthredat[2010], numblue, numred;
char inp[2010];
int main() {
  scanf(" %s", inp);
  n = strlen(inp);
  for (int i = 0; i < n; i++) {
    if (inp[i] == '0') {
      nthredat[numred++] = i;
      nthredat[numred++] = i;
    } else if (inp[i] == '1') {
      nthredat[numred++] = i;
      nthblueat[numblue++] = i;
    } else {
      nthblueat[numblue++] = i;
      nthblueat[numblue++] = i;
    }
  }
  dp[0][0]++;
  for (int i = 0; i <= numblue; i++) {
    for (int j = 0; j <= numred; j++) {
      //	printf("%d %d - %lld\n", i, j, dp[i][j]);
      dp[i][j] %= 998244353;
      if (i < numblue && nthblueat[i] <= i + j) {
        dp[i + 1][j] += dp[i][j];
      }
      if (j < numred && nthredat[j] <= i + j) {
        dp[i][j + 1] += dp[i][j];
      }
    }
  }
  printf("%lld\n", dp[numblue][numred]);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[4010][4010], n;
ll nthblueat[4010], nthredat[4010], numblue, numred;
char inp[4010];
int main() {
  scanf(" %s", inp);
  n = strlen(inp);
  for (int i = 0; i < n; i++) {
    if (inp[i] == '0') {
      nthredat[numred++] = i;
      nthredat[numred++] = i;
    } else if (inp[i] == '1') {
      nthredat[numred++] = i;
      nthblueat[numblue++] = i;
    } else {
      nthblueat[numblue++] = i;
      nthblueat[numblue++] = i;
    }
  }
  dp[0][0]++;
  for (int i = 0; i <= numblue; i++) {
    for (int j = 0; j <= numred; j++) {
      //	printf("%d %d - %lld\n", i, j, dp[i][j]);
      dp[i][j] %= 998244353;
      if (i < numblue && nthblueat[i] <= i + j) {
        dp[i + 1][j] += dp[i][j];
      }
      if (j < numred && nthredat[j] <= i + j) {
        dp[i][j + 1] += dp[i][j];
      }
    }
  }
  printf("%lld\n", dp[numblue][numred]);
}
Problem p03134 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define N 2010
using namespace std;
string st;
int n, a[N], b[N], dp[N][N], mo = 998244353;
int main() {
  cin >> st;
  n = st.length();
  for (int i = 1; i <= n; i++)
    a[i] = st[i - 1] - '0' + a[i - 1], b[i] = b[i - 1] + '2' - st[i - 1];
  dp[0][0] = 1;
  for (int i = 0; i <= a[n]; i++)
    for (int j = 0; j <= b[n]; j++)
      if (i <= a[min(n, i + j)] && j <= b[min(n, i + j)])
        dp[i][j] =
            (dp[i][j] + (j ? dp[i][j - 1] : 0) + (i ? dp[i - 1][j] : 0)) % mo;
  cout << dp[a[n]][b[n]] << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define N 4010
using namespace std;
string st;
int n, a[N], b[N], dp[N][N], mo = 998244353;
int main() {
  cin >> st;
  n = st.length();
  for (int i = 1; i <= n; i++)
    a[i] = st[i - 1] - '0' + a[i - 1], b[i] = b[i - 1] + '2' - st[i - 1];
  dp[0][0] = 1;
  for (int i = 0; i <= a[n]; i++)
    for (int j = 0; j <= b[n]; j++)
      if (i <= a[min(n, i + j)] && j <= b[min(n, i + j)])
        dp[i][j] =
            (dp[i][j] + (j ? dp[i][j - 1] : 0) + (i ? dp[i - 1][j] : 0)) % mo;
  cout << dp[a[n]][b[n]] << endl;
  return 0;
}
Problem p03134 (C++)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 998244353;
#define REP(i, n) for (int i = 0; i < (int)n; ++i)

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

template <typename T> void vprint(T &v) {
  REP(i, v.size()) { cout << v[i] << " "; }
  cout << endl;
}

int main() {
  string S;
  cin >> S;
  ll N = S.size();
  vector<ll> red(N + 1, 0), blue(N + 1, 0);
  REP(i, N) {
    if (S[i] == '0') {
      red[i + 1] = red[i] + 2;
      blue[i + 1] = blue[i];
    } else if (S[i] == '1') {
      red[i + 1] = red[i] + 1;
      blue[i + 1] = blue[i] + 1;
    } else {
      red[i + 1] = red[i];
      blue[i + 1] = blue[i] + 2;
    }
  }
  ll ma = 200;
  ll dp[ma][ma];
  REP(i, ma) REP(j, ma) dp[i][j] = 0;
  dp[0][0] = 1;
  REP(i, 2 * N) {
    ll ikeru = min((ll)i, N - 1);
    ll ikered = red[ikeru + 1];
    ll ikeblue = blue[ikeru + 1];
    REP(j, 2 * N) {
      if (ikered > j) {
        dp[i + 1][j + 1] += dp[i][j];
        dp[i + 1][j + 1] %= mod;
      }
      if (ikeblue > i - j) {
        dp[i + 1][j] += dp[i][j];
        dp[i + 1][j] %= mod;
      }
    }
  }
  cout << dp[2 * N][red[N]] << endl;
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 998244353;
#define REP(i, n) for (int i = 0; i < (int)n; ++i)

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

template <typename T> void vprint(T &v) {
  REP(i, v.size()) { cout << v[i] << " "; }
  cout << endl;
}

int main() {
  string S;
  cin >> S;
  ll N = S.size();
  vector<ll> red(N + 1, 0), blue(N + 1, 0);
  REP(i, N) {
    if (S[i] == '0') {
      red[i + 1] = red[i] + 2;
      blue[i + 1] = blue[i];
    } else if (S[i] == '1') {
      red[i + 1] = red[i] + 1;
      blue[i + 1] = blue[i] + 1;
    } else {
      red[i + 1] = red[i];
      blue[i + 1] = blue[i] + 2;
    }
  }
  ll ma = 4040;
  ll dp[ma][ma];
  REP(i, ma) REP(j, ma) dp[i][j] = 0;
  dp[0][0] = 1;
  REP(i, 2 * N) {
    ll ikeru = min((ll)i, N - 1);
    ll ikered = red[ikeru + 1];
    ll ikeblue = blue[ikeru + 1];
    REP(j, 2 * N) {
      if (ikered > j) {
        dp[i + 1][j + 1] += dp[i][j];
        dp[i + 1][j + 1] %= mod;
      }
      if (ikeblue > i - j) {
        dp[i + 1][j] += dp[i][j];
        dp[i + 1][j] %= mod;
      }
    }
  }
  cout << dp[2 * N][red[N]] << endl;
  return 0;
}
Problem p03135 (C++)

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

int main() {
  int T, X;
  cin >> T, X;
  cout << T / X << endl;
}

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

int main() {
  double T = 0, X = 0;
  cin >> T >> X;
  cout << T / X << endl;
}
Problem p03135 (C++)

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

int main() {
  int a, b;
  float c;
  cin >> a, b;
  c = float(a / b);
  cout << c << endl;
}

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

int main() {
  int a, b;
  float c;
  cin >> a >> b;
  c = float(a) / b;
  cout << c << endl;
}
Problem p03135 (C++)

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

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

  ld t, x;
  cin >> t >> x;
  cout << setprecision(30) << (t / x) << endl;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

int main() {

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

  ld t, x;
  cin >> t >> x;
  cout << setprecision(30) << (t / x) << endl;
}
Problem p03135 (Python)

Buggy submission (status: Runtime Error):
num = int(input().split())
ans = num[0] / num[1]
print(ans)


Fixed submission:
num = list(map(int, input().split()))
ans = num[0] / num[1]
print(ans)
Problem p03135 (C++)

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

int main() {
  int T, X;
  scanf("%d %d", T, X);
  std::cout << T / X << std::endl;
}


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

int main() {
  float T, X;
  scanf("%f %f", &T, &X);
  std::cout << T / X << std::endl;
}
Problem p03135 (C++)

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

int main() {
  int N, sum = 0;
  cin >> N;

  vector<int> L(N);

  for (int i = 1; i <= N; i++) {
    cin >> L.at(i);
    sum += L.at(i);
  }

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

  if (2 * L.at(N) - sum < 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main() {
  double t, x;
  cin >> t >> x;
  cout << t / x << endl;
}
Problem p03135 (C++)

Buggy submission (status: Runtime Error):
/* Don't try to hack it :|

            _/﹋\_
            (҂`_´)
            <,︻╦╤─҉- - - - - - - - - - - - - - -
            _/﹋\_
*/
//@ROMENE7

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define ulli unsigned long long int
#define lli long long int
#define llv vector<ll>
#define llc vector<char>
#define lls vector<string>
#define llb vector<bool>
#define mp make_pair
#define endl "\n"
#define degb cout << "HI" << endl;
#define ins insert
#define foo(i, n) for (ll i = 0; i < n; i++)
#define foa(i, a) for (auto i = a.begin(); i != a.end(); i++)
#define foe(i, a, b) for (ll i = a; i <= b; i++)
#define INF 2147483647
#define siz size
#define len length
#define sp setprecision(16)

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  double m, n;
  cin >> m >> n;
  cout << sp << m / n * 1.0;

  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";

  return 0;
}

Fixed submission:
/* Don't try to hack it :|

            _/﹋\_
            (҂`_´)
            <,︻╦╤─҉- - - - - - - - - - - - - - -
            _/﹋\_
*/
//@ROMENE7

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define ulli unsigned long long int
#define lli long long int
#define llv vector<ll>
#define llc vector<char>
#define lls vector<string>
#define llb vector<bool>
#define mp make_pair
#define endl "\n"
#define degb cout << "HI" << endl;
#define ins insert
#define foo(i, n) for (ll i = 0; i < n; i++)
#define foa(i, a) for (auto i = a.begin(); i != a.end(); i++)
#define foe(i, a, b) for (ll i = a; i <= b; i++)
#define INF 2147483647
#define siz size
#define len length
#define sp setprecision(16)

int main() {
  /*  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  double m, n;
  cin >> m >> n;
  cout << sp << m / n * 1.0;

  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";

  return 0;
}
Problem p03135 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int, int>,                  // change type
             null_type, less<pair<int, int>>, // change type
             rb_tree_tag, tree_order_statistics_node_update>
    ordered_set;

typedef long long ll;
#define rep(i, start, end) for (int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-8);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
  int x, t;
  cin >> t >> x;
  cout << fixed << setprecision(6) << 1.0 * t / x;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int, int>,                  // change type
             null_type, less<pair<int, int>>, // change type
             rb_tree_tag, tree_order_statistics_node_update>
    ordered_set;

typedef long long ll;
#define rep(i, start, end) for (int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-8);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
  int x, t;
  cin >> t >> x;
  cout << fixed << setprecision(6) << 1.0 * t / x;
  return 0;
}
Problem p03135 (C++)

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

typedef long long ll;
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))

inline ll read() {
  char c = getchar();
  ll ret = 0;
  while (c < '0' || c > '9')
    c = getchar();
  while (c >= '0' && c <= '9')
    ret = ret * 10 + c - '0', c = getchar();
  return ret;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.in", "r", stdin);
  freopen("output.out", "w", stdout);
#endif
  ll T = read(), X = read();
  printf("%.8f\n", T / (double)X);
  return 0;
}

Fixed submission:
#include <cstdio>

typedef long long ll;
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))

inline ll read() {
  char c = getchar();
  ll ret = 0;
  while (c < '0' || c > '9')
    c = getchar();
  while (c >= '0' && c <= '9')
    ret = ret * 10 + c - '0', c = getchar();
  return ret;
}

int main() {
  ll T = read(), X = read();
  printf("%.8f\n", T / (double)X);
  return 0;
}
Problem p03135 (C++)

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

int main() {
  long long N, M;
  cin >> N >> M;
  long long X[M];
  for (int i = 0; i < M; i++) {
    cin >> X[i];
  }
  if (M == 1) {
    cout << 0 << endl;
    return 0;
  }
  sort(X, X + M);
  pair<long long, long long> kan[M];
  kan[0].first = 0;
  kan[0].second = 0;
  for (int i = 1; i < M; i++) {
    kan[i].first = X[i] - X[i - 1];
    kan[i].second = i;
  }
  sort(kan, kan + M);
  vector<long long> mp;
  mp.push_back(X[0]);
  for (int i = 1; i < N; i++) {
    long long a = X[kan[M - 1 - i + 1].second];
    mp.push_back(a);
  }
  pair<long long, long long> route[M];
  for (int i = 0; i < M; i++) {
    route[i].first = X[i];
    route[i].second = 0;
    auto itr = find(mp.begin(), mp.end(), X[i]);
    if (itr != mp.end())
      route[i].second = 1;
  }
  long long ans = 0;
  long long now = route[0].first;

  for (int i = 1; i < M; i++) {
    if (route[i].second != 0) {
      ans += route[i - 1].first - now;
      now = route[i].first;
    }
    if (i == M - 1) {
      if (now != X[M - 1])
        ans += X[M - 1] - now;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  double a, b;
  cin >> a >> b;
  cout << a / b << setprecision(6) << endl;
}
Problem p03135 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
// #include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
// using namespace __gnu_cxx;
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 200005, M = 100005, mod = 998244353, mxLog = 20;

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(6),
      cout << fixed;

  int t, x;
  cin >> t >> x;
  cout << 1.0 * t / x << '\n';

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
// #include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
// using namespace __gnu_cxx;
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 200005, M = 100005, mod = 998244353, mxLog = 20;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(6),
      cout << fixed;

  int t, x;
  cin >> t >> x;
  cout << 1.0 * t / x << '\n';

  return 0;
}
Problem p03135 (C++)

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

using namespace std;
using ll = long long;

#define endl "\n"
#define pb push_back

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

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

  double t, x;
  cin >> t >> x;
  cout << fixed << setprecision(3) << (t / x) << endl;
}


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

using namespace std;
using ll = long long;

#define endl "\n"
#define pb push_back

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

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

  double t, x;
  cin >> t >> x;
  cout << fixed << setprecision(3) << (t / x) << endl;
}
Problem p03135 (C++)

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

int main() {
  int t, x;
  cin >> t, x;
  double ans = t / x;
  cout << ans << endl;
  return 0;
}

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

int main() {
  int t, x;
  cin >> t >> x;
  double ans = double(t) / x;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}
Problem p03135 (C++)

Buggy submission (status: Runtime Error):
/**
 *	  Name: Ajay Subhash Jadhav
 *	  Institute: International Institute of Technology Hyderabad
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int, int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

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

int main() {

  fastio();
  inputread();
  double T, X;
  cin >> T >> X;
  printf("%.10f", (T / X));
  return 0;
}

Fixed submission:
/**
 *	  Name: Ajay Subhash Jadhav
 *	  Institute: International Institute of Technology Hyderabad
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int, int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

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

int main() {

  fastio();
  double T, X;
  cin >> T >> X;
  printf("%.10f", (T / X));
  return 0;
}
Problem p03135 (C++)

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

int main() {
  int T, X;
  cin >> T, X;

  cout << T / X << endl;
}


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

int main() {
  double T, X;
  cin >> T >> X;

  cout << T / X << endl;
}
Problem p03135 (C++)

Buggy submission (status: Runtime Error):
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(), v.end()
#define allr(s) s.rbegin(), s.rend()
#define RT(s) return cout << s, 0
#define watch(x) cout << (#x) << " = " << x << endl
#define sz(s) (int)(s.size())
#define PI acos(-1)
#define EPS 1e-3
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> row;
typedef vector<row> matrix;
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
void file() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
#else
  // freopen("street.in", "r", stdin);
  // freopen("out.txt", "w", stdout);
#endif
}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}

int main() {
  file();
  fast();
  int T, x;
  cin >> T >> x;
  cout << setprecision(10) << T / (double)x << endl;
  return 0;
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(), v.end()
#define allr(s) s.rbegin(), s.rend()
#define RT(s) return cout << s, 0
#define watch(x) cout << (#x) << " = " << x << endl
#define sz(s) (int)(s.size())
#define PI acos(-1)
#define EPS 1e-3
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> row;
typedef vector<row> matrix;
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
void file() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
#else
  // freopen("street.in", "r", stdin);
  // freopen("out.txt", "w", stdout);
#endif
}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}

int main() {
  // file();
  fast();
  int T, x;
  cin >> T >> x;
  cout << setprecision(10) << T / (double)x << endl;
  return 0;
}
Problem p03136 (C++)

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

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

using namespace std;

int main() {
  int N;
  cin >> N;
  ;
  int L[N];
  REP(i, N) { cin >> L[N]; }
  sort(L, L + sizeof(L));

  int alpha = 0;
  REP(i, N - 1) { alpha += L[i]; }

  if (L[N - 1] > alpha) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

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

using namespace std;

int main() {
  int N;
  cin >> N;
  int L[N + 10];
  REP(i, N) { cin >> L[i]; }
  sort(L, L + N);
  int tmp = 0;
  REP(i, N - 1) { tmp += L[i]; }
  if (L[N - 1] < tmp) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03136 (Python)

Buggy submission (status: Runtime Error):
def read():
    N = int(input().strip())
    L = map(int, input().strip().split())
    return N, L


def solve(N, L):
    L = sorted(L)
    return "Yes" if L[-1] < sum(L[:-1]) else "No"


if __name__ == "__main__":
    inputs = read()
    print("%f" % solve(*inputs))


Fixed submission:
def read():
    N = int(input().strip())
    L = map(int, input().strip().split())
    return N, L


def solve(N, L):
    L = sorted(L)
    return "Yes" if L[-1] < sum(L[:-1]) else "No"


if __name__ == "__main__":
    inputs = read()
    print("%s" % solve(*inputs))
Problem p03136 (C++)

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

using namespace std;

int main() {
  int N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  long ans = 0;
  for (int i = 0; i < N - 1; i++) {
    ans += L.at(i);
  }
  if (L.at(N - 1) < ans)
    cout << "Yes";
  else
    cout << "No";
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  long ans = 0;
  for (int i = 0; i < N - 1; i++) {
    ans += L.at(i);
  }
  if (L.at(N - 1) < ans)
    cout << "Yes";
  else
    cout << "No";
}
Problem p03136 (C++)

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

int main() {
  int N;
  vector<int> L(N);
  rep(i, N) cin >> L.at(i);
  sort(L.begin(), L.end());
  int sum = 0;
  rep(i, N - 1) sum += L.at(i);
  if (sum > L.at(N - 1))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L.at(i);
  sort(L.begin(), L.end());
  int sum = 0;
  rep(i, N - 1) sum += L.at(i);
  if (sum > L.at(N - 1))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03136 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <cmath>
#include <cstdlib>
using namespace std;
int main() {
  int N;
  vector<int> S;
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  int A = 0;
  for (int i = 0; i < N - 1; i++) {
    A += S.at(i);
  }
  if (A > S.at(N - 1))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#include <cmath>
#include <cstdlib>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  int A = 0;
  for (int i = 0; i < N - 1; i++) {
    A += S.at(i);
  }
  if (A > S.at(N - 1))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03136 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += vec.at(i);
  }

  sort(vec.begin(), vec.end());
  if (vec.at(N) * 2 < sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += vec.at(i);
  }

  sort(vec.begin(), vec.end());
  if (vec.at(N - 1) * 2 < sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03136 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  int sum = 0;
  for (int i = 0; i < N - 1; i++) {
    sum += A.at(i);
  }

  if (sum > A.at(N)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  int sum = 0;
  for (int i = 0; i < N - 1; i++) {
    sum += A.at(i);
  }

  if (sum > A.at(N - 1)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03136 (C++)

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

int main() {
  int N, sum(0);
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
    sum += L[i];
  }
  sort(L.begin(), L.end());
  if (sum - L[N - 1] > L[N - 1])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
  int N, sum(0);
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
    sum += L[i];
  }
  sort(L.begin(), L.end());
  if (sum - L[N - 1] > L[N - 1])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03136 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#pragma region Macros
#define int long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
#define LAST(x) x[x.size() - 1]
#define ALL(x) (x).begin(), (x).end()
#define swap(a, b) (a += b, b = a - b, a -= b)
#define CEIL(a, b) ((a + b - 1) / b)
int GCD(int a, int b) // assuming a,b >= 1
{
  if (a < b)
    swap(a, b);
  if (b == 0)
    return a;
  if (a % b == 0)
    return b;
  return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
  return a * b / GCD(a, b);
}
double LOG(int a, int b) { return log(b) / log(a); }
inline bool BETWEEN(int x, int min, int max) {
  if (min <= x && x <= max)
    return true;
  else
    return false;
}

using namespace std;
#pragma endregion
signed main() {
  int N, sum = 0;
  cin >> N;
  vector<int> L;
  rep(i, N) {
    cin >> L[i];
    sum += L[i];
  }
  sort(ALL(L));
  if (2 * LAST(L) < sum)
    cout << "Yes";
  else
    cout << "No";
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#pragma region Macros
#define int long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
#define LAST(x) x[x.size() - 1]
#define ALL(x) (x).begin(), (x).end()
#define swap(a, b) (a += b, b = a - b, a -= b)
#define CEIL(a, b) ((a + b - 1) / b)
int GCD(int a, int b) // assuming a,b >= 1
{
  if (a < b)
    swap(a, b);
  if (b == 0)
    return a;
  if (a % b == 0)
    return b;
  return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
  return a * b / GCD(a, b);
}
double LOG(int a, int b) { return log(b) / log(a); }
inline bool BETWEEN(int x, int min, int max) {
  if (min <= x && x <= max)
    return true;
  else
    return false;
}

using namespace std;
#pragma endregion
signed main() {
  int N, sum = 0;
  cin >> N;
  vector<int> L(N);
  rep(i, N) {
    cin >> L[i];
    sum += L[i];
  }
  sort(ALL(L));
  if (2 * LAST(L) < sum)
    cout << "Yes";
  else
    cout << "No";
}
Problem p03136 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int, int>,                  // change type
             null_type, less<pair<int, int>>, // change type
             rb_tree_tag, tree_order_statistics_node_update>
    ordered_set;

typedef long long ll;
#define rep(i, start, end) for (int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-8);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
  int n, mx = INT_MIN, sum = 0;
  cin >> n;
  rep(i, 0, n) {
    int x;
    cin >> x;
    sum += x;
    mx = max(mx, x);
  }
  if (mx < sum - mx)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int, int>,                  // change type
             null_type, less<pair<int, int>>, // change type
             rb_tree_tag, tree_order_statistics_node_update>
    ordered_set;

typedef long long ll;
#define rep(i, start, end) for (int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-8);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
  int n, mx = INT_MIN, sum = 0;
  cin >> n;
  rep(i, 0, n) {
    int x;
    cin >> x;
    sum += x;
    mx = max(mx, x);
  }
  if (mx < sum - mx)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
Problem p03136 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> v;
  int i, x;
  for (i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  int c = 0;
  sort(v.begin(), v.end());
  for (i = 0; i < n - 1; i++)
    c += v[i];
  if (v[n - 1] < c)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  int i, x;
  for (i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  int c = 0;
  sort(v.begin(), v.end());
  for (i = 0; i < n - 1; i++)
    c += v[i];
  if (v[n - 1] < c)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
Problem p03136 (C++)

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

int main() {

  int n;
  int i;
  int max = 0;
  int sum = 0;
  int a[n];

  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> a[i];

    if (a[i] > max)
      max = a[i];

    sum += a[i];
  }

  if (max >= (sum - max))
    cout << "No" << endl;

  else
    cout << "Yes" << endl;

  return 0;
}


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

int main() {

  int n;
  int i;
  int max = 0;
  int sum = 0;
  int a[10];

  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> a[i];

    if (a[i] > max)
      max = a[i];

    sum += a[i];
  }

  if (max >= (sum - max))
    cout << "No" << endl;

  else
    cout << "Yes" << endl;

  return 0;
}
Problem p03136 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i, N; i++)
    cin >> L.at(i);

  sort(L.begin(), L.end());
  int sum = 0;
  for (int i = 0; i < N - 1; i++)
    sum += L.at(i);
  if (L.at(N - 1) >= sum)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++)
    cin >> L.at(i);

  sort(L.begin(), L.end());
  int sum = 0;
  for (int i = 0; i < N - 1; i++)
    sum += L.at(i);
  if (L.at(N - 1) >= sum)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}
Problem p03136 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

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

  int result = 0;

  for (int i = 0; i < N - 1; i++) {
    result += vec.at(i);
  }
  if (result > vec.at(N)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

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

  int result = 0;

  for (int i = 0; i < N - 1; i++) {
    result += vec.at(i);
  }
  if (result > vec.at(N - 1)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03136 (C++)

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

int main() {
  int N, sum = 0;
  cin >> N;

  vector<int> L(N);
  for (int i = 1; i <= N; i++) {
    cin >> L.at(i);
    sum += L.at(i);
  }

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

  if (2 * L.at(N - 1) - sum < 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main() {
  int N, sum = 0;
  cin >> N;

  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
    sum += L.at(i);
  }

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

  if (2 * L.at(N - 1) - sum < 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03136 (C++)

Buggy submission (status: Runtime Error):
#pragma GCC optimize "-O3"
#pragma GCC target("avx")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; ++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int, int>
#define vp vector<pair<int, int>>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define inf (1ll << 60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
signed gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
signed lcm(int a, int b) { return a * b / gcd(a, b); }

using namespace std;

const int mod = 1e9 + 7;

void run();

void init() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(12);
}

signed main() {
  init();
  run();
  return 0;
}

void run() {
  int n;
  vi l(n);
  int sum = 0;
  rep(i, n) {
    cin >> l[i];
    sum += l[i];
  }
  RSORT(l);
  if (sum - l[0] > l[0])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Fixed submission:
#pragma GCC optimize "-O3"
#pragma GCC target("avx")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; ++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int, int>
#define vp vector<pair<int, int>>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define inf (1ll << 60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
signed gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
signed lcm(int a, int b) { return a * b / gcd(a, b); }

using namespace std;

const int mod = 1e9 + 7;

void run();

void init() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(12);
}

signed main() {
  init();
  run();
  return 0;
}

void run() {
  int n;
  cin >> n;
  vi l(n);
  int sum = 0;
  rep(i, n) {
    cin >> l[i];
    sum += l[i];
  }
  RSORT(l);
  if (sum - l[0] > l[0])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03136 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> MY(N);
  for (int i = 0; i < N; i++) {
    cin >> MY.at(i);
  }
  sort(MY.begin(), MY.end());
  int k = 0;
  for (int i = 0; i < N - 1; i++) {
    k += MY.at(i);
  }
  if (k > MY.at(N)) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> MY(N);
  for (int i = 0; i < N; i++) {
    cin >> MY.at(i);
  }
  sort(MY.begin(), MY.end());
  int k = 0;
  for (int i = 0; i < N - 1; i++) {
    k += MY.at(i);
  }
  if (k > MY.at(N - 1)) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
}
Problem p03136 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
L = map(int, input().split())

if max(L) < sum(L) - max(L):
    print("Yes")
else:
    print("No")


Fixed submission:
N = int(input())
L = list(map(int, input().split()))

if max(L) < sum(L) - max(L):
    print("Yes")
else:
    print("No")
Problem p03136 (C++)

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

int main() {

  int N;
  vector<int> vec(N);

  for (int i = 0; i < N; i++) {

    cin >> vec.at(i);
  }

  int max;
  max = *max_element(vec.begin(), vec.end());

  int total = 0;

  for (int i = 0; i < N; i++) {

    total += vec.at(i);
  }

  if (max < (total - max)) {

    cout << "Yes" << endl;

  } else {

    cout << "No" << endl;
  }

  return 0;
}


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

int main() {

  int N;
  cin >> N;

  vector<int> vec(N);

  for (int i = 0; i < N; i++) {

    cin >> vec.at(i);
  }

  int max;
  max = *max_element(vec.begin(), vec.end());

  int total = 0;

  for (int i = 0; i < N; i++) {

    total += vec.at(i);
  }

  if (max < (total - max)) {

    cout << "Yes" << endl;

  } else {

    cout << "No" << endl;
  }

  return 0;
}
Problem p03136 (Python)

Buggy submission (status: Runtime Error):
N = input()
L = map(int, input().split())
x = sorted(L)
Lmax = max(L)
y = x[0:-1]
ysum = sum(y)
print("Yes" if Lmax < ysum else "No")


Fixed submission:
N = int(input())
L = list(map(int, input().split()))
x = sorted(L)
Lmax = max(L)
y = x[0:-1]
ysum = sum(y)
print("Yes" if Lmax < ysum else "No")
Problem p03137 (C++)

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> x(m);
  for (ll i = 0; i < m; i++)
    cin >> x[i];
  sort(x.begin(), x.end());
  vector<ll> y(m - 1);
  for (ll i = 0; i < m - 1; i++)
    y[i] = x[i + 1] - x[i];
  sort(y.begin(), y.end());
  ll sum = 0;
  for (ll i = 0; i < y.size() - n + 1; i++)
    sum += y[i];
  cout << sum;
  return 0;
}

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> x(m);
  if (n > m) {
    cout << 0;
    return 0;
  }
  for (ll i = 0; i < m; i++)
    cin >> x[i];
  sort(x.begin(), x.end());
  vector<ll> y(m - 1);
  for (ll i = 0; i < m - 1; i++)
    y[i] = x[i + 1] - x[i];
  sort(y.begin(), y.end());
  ll sum = 0;
  for (ll i = 0; i < y.size() - n + 1; i++)
    sum += y[i];
  cout << sum;
  return 0;
}
Problem p03137 (C++)

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

using namespace std;

int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vector<int> x(m);
  vector<int> max(m - 1);

  for (int i = 0; i < m; i++) {
    cin >> x[i];
    if (i < m - 1)
      max[i] = 0;
  }

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

  for (int i = 0; i < m - 1; i++) {
    max[i] = x[i + 1] - x[i];
    ans += max[i];
  }

  if (n == 1) {
    cout << ans << endl;
  } else if (m == 1) {
    cout << "0" << endl;
  } else {
    sort(max.begin(), max.end());
    for (int i = m - 2; i >= m - n; i--) {
      ans -= max[i];
    }
    cout << ans << endl;
  }
}

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

using namespace std;

int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vector<int> x(m);
  vector<int> max(m - 1);

  for (int i = 0; i < m; i++) {
    cin >> x[i];
    if (i < m - 1)
      max[i] = 0;
  }

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

  for (int i = 0; i < m - 1; i++) {
    max[i] = x[i + 1] - x[i];
    ans += max[i];
  }

  if (n == 1) {
    cout << ans << endl;
  } else if (m <= n) {
    cout << "0" << endl;
  } else {
    sort(max.begin(), max.end());
    for (int i = m - 2; i >= m - n; i--) {
      ans -= max[i];
    }
    cout << ans << endl;
  }
}
Problem p03137 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repa(i, s, n) for (int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i, a, b) for (int i = a; i >= b; i--)

signed main() {
  int n, m;
  cin >> n >> m;
  vi x(m);
  vi diff(m - 1);
  rep(i, m) cin >> x[i];
  sort(x.begin(), x.end());

  if (m == 1) {
    cout << 0 << endl;
    return 0;
  }

  rep(i, m - 1) { diff[i] = x[i + 1] - x[i]; }
  sort(diff.begin(), diff.end(), greater<int>());

  int ans = *(x.end() - 1) - *x.begin();

  rep(i, n - 1) {
    /*  cout << "diff = " << diff[i] << " "; */
    ans -= diff[i];
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repa(i, s, n) for (int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i, a, b) for (int i = a; i >= b; i--)

signed main() {
  int n, m;
  cin >> n >> m;
  vi x(m);
  vi diff(m - 1);
  rep(i, m) cin >> x[i];
  sort(x.begin(), x.end());

  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }

  rep(i, m - 1) { diff[i] = x[i + 1] - x[i]; }
  sort(diff.begin(), diff.end(), greater<int>());

  int ans = *(x.end() - 1) - *x.begin();

  rep(i, n - 1) {
    /*  cout << "diff = " << diff[i] << " "; */
    ans -= diff[i];
  }
  cout << ans << endl;
}
Problem p03137 (C++)

Buggy submission (status: Runtime Error):
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,tune=native")

#include <bits/stdc++.h>
#include <x86intrin.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  if (N >= M) {
    cout << '0';
    exit(EXIT_SUCCESS);
  }
  int X[M], dist[M - 1], res = 0;
  cin >> X[0];
  for (int i = 1; i < M; i++)
    cin >> X[i];
  sort(X, X + M);
  for (int i = 0; i < M - 1; i++) {
    dist[i] = X[i + 1] - X[i];
    res += dist[i];
  }
  sort(dist, dist + M - 1, greater<int>());
  for (int i = 0; i < N - 1; i++)
    res -= dist[i];
  cout << res;
  return 0;
}

Fixed submission:
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,tune=native")

#include <bits/stdc++.h>
#include <x86intrin.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  if (N >= M) {
    cout << '0';
    exit(EXIT_SUCCESS);
  }
  int X[M], dist[M - 1], res = 0;
  cin >> X[0];
  for (int i = 1; i < M; i++)
    cin >> X[i];
  sort(X, X + M);
  for (int i = 0; i < M - 1; i++) {
    dist[i] = X[i + 1] - X[i];
    res += dist[i];
  }
  sort(dist, dist + M - 1, greater<int>());
  for (int i = 0; i < N - 1; i++)
    res -= dist[i];
  cout << res;
  return 0;
}