alexjercan/bugnet huggingface dataset:
Problem p00079 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>

using namespace std;

typedef complex<double> xy_t;
xy_t P[110];

int main() {
  int N = 0;
  double x, y;
  while (~scanf("%lf,%lf", &x, &y)) {
    P[N++] = xy_t(x, y);
  }
  double sum = 0.0;
  for (int i = 0; i < N - 2; i++) {
    xy_t a = P[0], b = P[(i + 1) % N], c = P[(i + 2) % N];
    sum += ((b.real() - a.real()) * (c.imag() - a.imag()) -
            (b.imag() - a.imag()) * (c.real() - a.real()));
  }
  printf("%.6f\\n", abs(sum) / 2);
}

Error: -11

Fixed submission:

#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>

using namespace std;

typedef complex<double> xy_t;
xy_t P[110];

int main() {
  int N = 0;
  double x, y;
  while (scanf("%lf,%lf", &x, &y)) {
    P[N++] = xy_t(x, y);
  }
  double sum = 0.0;
  for (int i = 0; i < N - 2; i++) {
    xy_t a = P[0], b = P[(i + 1) % N], c = P[(i + 2) % N];
    sum += (1 / 2) * ((b.real() - a.real()) * (c.imag() - a.imag()) -
                      (b.imag() - a.imag()) * (c.real() - a.real()));
  }
  printf("%.6f\\n", abs(sum) / 2);
}
Problem p00079 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
using namespace std;

double s(double a, double b, double c) {
  double S, z;
  z = (a + b + c) / 2.0;
  S = z * (z - a) * (z - b) * (z - c);
  return sqrt(S);
}

int main(void) {
  int n = 0;
  double x[21], y[21], sum = 0;
  double xx, yy, tt;
  for (int i = 1; scanf("%lf,%lf", &x[i], &y[i]) != EOF; i++) {
    n = i;
  }
  for (int i = 2; i <= n; i++) {
    xx = sqrt((x[i] - x[i - 1]) * (x[i] - x[i - 1]) +
              (y[i] - y[i - 1]) * (y[i] - y[i - 1]));
    yy = sqrt(x[i] * x[i] + y[i] * y[i]);
    tt = sqrt(x[i - 1] * x[i - 1] + y[i - 1] * y[i - 1]);
    sum += s(xx, yy, tt);
  }

  xx = sqrt((x[n] - x[1]) * (x[n] - x[1]) + (y[n] - y[1]) * (y[n] - y[1]));
  yy = sqrt(x[n] * x[n] + y[n] * y[n]);
  tt = sqrt(x[1] * x[1] + y[1] * y[1]);
  sum += s(xx, yy, tt);
  cout << fixed;
  cout << setprecision(7) << sum << endl;
  return 0;
}


Error: WA

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
using namespace std;

double s(double a, double b, double c) {
  double S, z;
  z = (a + b + c) / 2.0;
  S = z * (z - a) * (z - b) * (z - c);
  return sqrt(S);
}

int main(void) {
  int n;
  double x[21], y[21], sum = 0;
  double a, b, xx, yy, tt;
  for (int i = 1; scanf("%lf,%lf", &x[n], &y[n]) != EOF; i++) {
    x[i] = a;
    y[i] = b;
    n = i;
  }
  for (int i = 2; i < n; i++) {
    xx = sqrt((x[i] - x[i - 1]) * (x[i] - x[i - 1]) +
              (y[i] - y[i - 1]) * (y[i] - y[i - 1]));
    yy = sqrt(x[i] * x[i] + y[i] * y[i]);
    tt = sqrt(x[i - 1] * x[i - 1] + y[i - 1] * y[i - 1]);
    sum += s(xx, yy, tt);
  }
  cout << fixed;
  cout << setprecision(7) << sum << endl;
  return 0;
}
Problem p00079 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

#define X real()
#define Y imag()
typedef complex<double> P;

double cross(P a, P b) { return a.X * b.Y - a.Y * b.X; }
int main() {

  double a, b;
  vector<P> p;
  while (scanf("%lf,%lf", &a, &b) != EOF) {
    p.push_back(P(a, b));
  }

  double sum = 0;
  reps(i, 1, p.size() - 1) { sum += cross(p[i] - p[0], p[i + 1] - p[0]) / 2; }

  printf("%.9lf\\n", fabs(sum));
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

#define X real()
#define Y imag()
typedef complex<double> P;

double cross(P a, P b) { return a.X * b.Y - a.Y * b.X; }
int main() {

  double a, b;
  vector<P> p;
  while (scanf("%lf,%lf", &a, &b)) {
    p.push_back(P(a, b));
  }

  double sum = 0;
  reps(i, 1, p.size() - 1) { sum += cross(p[i] - p[0], p[i + 1] - p[0]) / 2; }

  printf("%.9lf\\n", fabs(sum));
}
Problem p00079 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main() {
  double num[21][2];
  int r = 1;
  while (scanf("%lf,%lf", &num[r][0], &num[r][1]) != EOF) {
    r++;
  }
  double ans = 0.0;
  for (int i = 2; i < r - 1; i++) {
    double a, b, c;
    a = sqrt((num[i][0] - num[1][0]) * (num[i][0] - num[1][0]) +
             (num[i][1] - num[1][1]) * (num[i][1] - num[1][1]));
    b = sqrt((num[i + 1][0] - num[1][0]) * (num[i + 1][0] - num[1][0]) +
             (num[i + 1][1] - num[1][1]) * (num[i + 1][1] - num[1][1]));
    c = sqrt((num[i][0] - num[i + 1][0]) * (num[i][0] - num[i + 1][0]) +
             (num[i][1] - num[i + 1][1]) * (num[i][1] - num[i + 1][1]));
    double y = (a + b + c) / 2.0;
    ans += sqrt(y * (y - a) * (y - b) * (y - c));
  }
  printf("%f\\n", ans);
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main() {
  double num[21][2];
  int r = 1;
  while (scanf("%lf %lf", &num[r][0], &num[r][1]) != EOF) {
    r++;
  }
  double ans = 0.0;
  for (int i = 2; i < r - 1; i++) {
    double a, b, c;
    a = sqrt((num[i][0] - num[1][0]) * (num[i][0] - num[1][0]) +
             (num[i][1] - num[1][1]) * (num[i][1] - num[1][1]));
    b = sqrt((num[i + 1][0] - num[1][0]) * (num[i + 1][0] - num[1][0]) +
             (num[i + 1][1] - num[1][1]) * (num[i + 1][1] - num[1][1]));
    c = sqrt((num[i][0] - num[i + 1][0]) * (num[i][0] - num[i + 1][0]) +
             (num[i][1] - num[i + 1][1]) * (num[i][1] - num[i + 1][1]));
    double y = (a + b + c) / 2.0;
    ans += sqrt(y * (y - a) * (y - b) * (y - c));
  }
  printf("%f\\n", ans);
}
Problem p00079 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  typedef complex<double> xy;
  xy p[20];
  int n = 0;
  double x, y, s;
  while (~scanf("%lf, %lf", &x, &y)) {
    p[n++] = xy(x, y);
  }
  for (int i = 1; i < n - 1; i++) {
    s += (conj(p[i] - p[0]) * (p[i + 1] - p[0])).imag() / 2;
  }
  printf("%.6f\\n", abs(s));
}

Error: TLE

Fixed submission:

#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  typedef complex<double> xy;
  double x1, y1, x2, y2, s;
  xy z1, z2;
  s = 0.0;
  scanf("%lf, %lf", &x1, &y1);
  while (scanf("%lf, %lf", &x2, &y2)) {
    z1 = xy(x1, y1);
    z2 = xy(x2, y2);
    s += (conj(z1) * z2).real() / 2;
    x1 = x2;
    y1 = y2;
  }
  printf("%.6f?\\n", abs(s));
}
Problem p00079 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
using namespace std;
#pragma warning(disable : 4996)
struct Point {
  long double px, py;
};
struct Segment {
  Point p1, p2;
};
Point X[200000];
Point Minus(Point a, Point b) {
  Point G;
  G.px = a.px - b.px;
  G.py = a.py - b.py;
  return G;
}
long double Abs(Point a) { return sqrt(a.px * a.px + a.py * a.py); }
long double dot(const Point &a, const Point &b) {
  return a.px * b.px + a.py * b.py;
}
long double crs(const Point &a, const Point &b) {
  return a.px * b.py - a.py * b.px;
}
long double dst(const Segment &a, const Point &b) {
  return abs(crs(Minus(a.p2, a.p1), Minus(b, a.p1)) / Abs(Minus(a.p2, a.p1)));
}
int main() {
  int N = 0;
  while (scanf("%Lf,%Lf", &X[N].px, &X[N].py) != EOF) {
    N++;
  }
  long double SUM = 0.0l;
  for (int i = 1; i < N - 1; i++) {
    Segment A;
    A.p1 = X[i];
    A.p2 = X[i + 1];
    long double DST = dst(A, X[0]);
    Point H;
    H.px = X[i].px - X[i + 1].px;
    H.py = X[i].py - X[i + 1].py;
    long double LEN = Abs(H);
    SUM += DST * LEN / 2;
  }
  cout << fixed << setprecision(1919) << SUM << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
using namespace std;
#pragma warning(disable : 4996)
struct Point {
  long double px, py;
};
struct Segment {
  Point p1, p2;
};
Point X[200000];
Point Minus(Point a, Point b) {
  Point G;
  G.px = a.px - b.px;
  G.py = a.py - b.py;
  return G;
}
long double Abs(Point a) { return sqrt(a.px * a.px + a.py * a.py); }
long double dot(const Point &a, const Point &b) {
  return a.px * b.px + a.py * b.py;
}
long double crs(const Point &a, const Point &b) {
  return a.px * b.py - a.py * b.px;
}
long double dst(const Segment &a, const Point &b) {
  return abs(crs(Minus(a.p2, a.p1), Minus(b, a.p1)) / Abs(Minus(a.p2, a.p1)));
}
int main() {
  int N = 0;
  while (scanf("%Lf,%Lf", &X[N].px, &X[N].py)) {
    N++;
  }
  long double SUM = 0.0l;
  for (int i = 1; i < N - 1; i++) {
    Segment A;
    A.p1 = X[i];
    A.p2 = X[i + 1];
    long double DST = dst(A, X[0]);
    Point H;
    H.px = X[i].px - X[i + 1].px;
    H.py = X[i].py - X[i + 1].py;
    long double LEN = Abs(H);
    SUM += DST * LEN / 2;
  }
  cout << fixed << setprecision(1919) << SUM << endl;
  return 0;
}
Problem p00079 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <complex>
#include <iostream>
#include <stdio.h>

using namespace std;
typedef complex<double> xy_t;
xy_t P[110];

int main() {
  int N = 0;
  double x, y;

  while (~scanf("%lf,%lf", &x, &y)) {
    P[N++] = xy_t(x, y);
  }
  double sum = 0.0;
  for (int i = 0; i + 2 < N; ++i) {
    xy_t a = P[0], b = P[i + 1], c = P[i + 2];
    sum += (abs((b.real() - a.real()) * (c.imag() - a.imag())) -
            abs((c.real() - a.real()) * (b.imag() - a.imag()))) /
           2.0;
  }
  printf("%.6f\\n", abs(sum));
  // return 0;
}

Error: -11

Fixed submission:

#include <cmath>
#include <complex>
#include <iostream>
#include <stdio.h>

using namespace std;
typedef complex<double> xy_t;
xy_t P[110];

int main() {
  int N = 0;
  double x, y;
  while (scanf("%lf,%lf", &x, &y)) {
    P[N++] = xy_t(x, y);
  }
  double sum = 0.0;
  for (int i = 0; i + 2 < N; ++i) {
    xy_t a = P[0], b = P[i + 1], c = P[i + 2];
    sum += (abs((b.real() - a.real()) * (c.imag() - a.imag())) +
            abs((c.real() - a.real()) * (b.imag() - a.imag()))) /
           2.0;
  }
  printf("%.6f\\n", abs(sum));
  // return 0;
}
Problem p00079 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
using namespace std;
typedef complex<double> xy_t;
int main() {
  xy_t P[110];
  int N = 0;
  double x, y;
  while (~scanf("%lf,%lf", &x, &y)) {
    P[N++] = xy_t(x, y);
  }
  double sum = 0.0;
  for (int i = 0; i + 2 < N; ++i) {
    xy_t a = P[0], b = P[i + 1], c = P[i + 2];
    sum += (conj(b - a) * (c - a)).imag();
  }
  sum /= 2;
  printf("%.6f\\n", abs(sum));
  return 0;
}

Error: -11

Fixed submission:

#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
using namespace std;
typedef complex<double> xy_t;
int main() {
  xy_t P[110];
  int N = 0;
  double x, y;
  while (scanf("%lf,%lf", &x, &y)) {
    P[N++] = xy_t(x, y);
  }
  double sum = 0.0;
  for (int i = 0; i + 2 < N; ++i) {
    xy_t a = P[0], b = P[i + 1], c = P[i + 2];
    sum += (conj(b - a) * (c - a)).imag();
  }
  sum /= 2;
  printf("%.6f\\n", abs(sum));
  return 0;
}
Problem p00079 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  double x[22], y[22], ans = 0;
  int n = 0;
  int l;
  while (scanf("%lf,%lf", &x[n], &y[n]) != -1) {
    n++;
  }
  double s;
  for (int i = 1; i < n; i++) {
    s = (x[i] - x[0]) * (y[(i + 1) % n] - y[0]) -
        (x[(i + 1) % n] - x[0]) * (y[i] - y[0]);
    if (s < 0)
      s = -s;
    ans += s;
  }
  printf("%.8lf", ans / 2.0);
}


Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  double x[22], y[22], ans = 0;
  int n = 0;
  while (scanf("%lf,%lf", &x[n], &y[n])) {
    n++;
  }
  double s;
  for (int i = 1; i < n; i++) {
    s = (x[i] - x[0]) * (y[i + 1] - y[0]) - (x[i + 1] - x[0]) * (y[i] - y[0]);
    if (s < 0)
      s = -s;
    ans += s;
  }
  printf("%.8lf", ans / 2.0);
}
Problem p00079 (C++) — buggy submission, verdict: Time Limit Exceeded

// 32
#include <cmath>
#include <complex>
#include <cstdio>

using namespace std;

int main() {
  double x, y, px, py;
  scanf("%lf,%lf%lf,%lf", &x, &y, &px, &py);
  double s = 0;
  complex<double> p(x, y), pp(px, py);
  for (double cx, cy; scanf("%lf,%lf", &cx, &cy) != EOF;) {
    complex<double> cp(cx, cy);
    double a = abs(pp - p), b = abs(cp - p), c = abs(cp - pp);
    double z = (a + b + c) / 2;
    s += sqrt(z * (z - a) * (z - b) * (z - c));
    pp = cp;
  }
  printf("%.6f\\n", s);
  return 0;
}

Error: TLE

Fixed submission:

// 32
#include <cmath>
#include <complex>
#include <cstdio>

using namespace std;

int main() {
  double x, y, px, py;
  scanf("%lf,%lf,%lf,%lf", &x, &y, &px, &py);
  double s = 0;
  complex<double> p(x, y), pp(px, py);
  for (double cx, cy; scanf("%lf,%lf", &cx, &cy);) {
    complex<double> cp(cx, cy);
    double a = abs(pp - p), b = abs(cp - p), c = abs(cp - pp);
    double z = (a + b + c) / 2;
    s += sqrt(z * (z - a) * (z - b) * (z - c));
    pp = cp;
  }
  printf("%.6f\\n", s);
  return 0;
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
typedef unsigned long long ull;
#define rep(i, a) for (int i = 0; i < a; i++)
#define loop(i, a, b) for (int i = a; i < b; i++)
using namespace std;
const double eps = 0.00001;
const double pi = acos(-1);
const double inf = (int)1e5;

int main(void) {
  double N;
  while (cin >> N, N != -1) {
    double q = 1.0 * N / 2;
    int i = 0;
    while (abs(pow(q, 3) - N) > eps * N && i < 10000) {
      i++;
      // printf("%.10f\\n",q);
      q = q - (pow(q, 3) - N) / (3 * pow(q, 2));
    }
    printf("%.6f\\n", q);
  }
}

Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
typedef unsigned long long ull;
#define rep(i, a) for (int i = 0; i < a; i++)
#define loop(i, a, b) for (int i = a; i < b; i++)
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1);
const double inf = (int)1e5;

int main(void) {
  double N;
  while (cin >> N, N != -1) {
    double q = 1.0 * N / 2;
    int i = 0;
    while (abs(pow(q, 3) - N) > eps) {
      i++;
      // printf("%.10f\\n",q);
      q = q - (pow(q, 3) - N) / (3 * pow(q, 2));
    }
    printf("%.6f\\n", q);
  }
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, b, n) for (int i = b; i < n; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1 << 29;

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

int main() {

  double q;
  while (cin >> q) {
    if (q == -1)
      break;
    double x = q / 2;
    while (1) {
      x = x - (x * x * x - q) / (3 * x * x);
      if (abs(x * x * x - q) < 0.00001 * q)
        break;
    }
    printf("%.6f\\n", x);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, b, n) for (int i = b; i < n; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1 << 29;

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

int main() {
  int q;
  while (1) {
    cin >> q;
    if (q == -1 || cin.eof())
      break;
    double x = q / 2;
    while (true) {
      if (fabs(x * x * x - q) < 0.00001 * q)
        break;
      x = x - (x * x * x - q) / (3 * x * x);
    }
    printf("%,6f\\n", x);
  }

  return 0;
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

typedef long long int ll;

using namespace std;

int q;
double x;

double f() { return x * x * x - q; }
double df() { return 3 * x * x; }

double calc() {
  x = q / 2.0;
  while (1) {
    if ((fabs(f()) > -0.00001 * q && fabs(f()) < 0.00001 * q)) {
      break;
    }
    x = (x * df() - f()) / df();
  }
  return x;
}

int main() {
  while (1) {
    cin >> q;
    if (q == -1)
      break;
    printf("%.15lf\\n", calc());
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

typedef long long int ll;

using namespace std;

int q;
double x;

double f() { return x * x * x - q; }
double df() { return 2 * x * x; }

double calc() {
  x = q / 2;
  while (1) {
    if ((fabs(f()) > -0.00001 * q && fabs(f()) < 0.00001 * q)) {
      break;
    }
    x = (x * df() - f()) / df();
  }
  return x;
}

int main() {
  while (1) {
    cin >> q;
    if (q == -1)
      break;
    printf("%.15lf\\n", calc());
  }
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <list>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

int main() {
  double tmp[20][2];
  int cnt = 0;
  int n;
  for (;;) {
    scanf("%d", &n);
    if (n == -1)
      break;
    double ans = 1.0 * n / 2.0;
    while (abs(ans * ans * ans - n) >= 0.00001 * n)
      ans -= (ans * ans * ans - n) / (3 * ans * ans);
    printf("%.8lf\\n", ans);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <list>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

int main() {
  double tmp[20][2];
  int cnt = 0;
  int n;
  for (;;) {
    scanf("%d", &n);
    if (n == -1)
      break;
    double ans = 1.0 * n / 2.0;
    while (abs(ans * ans * ans - n) >= 1e-10)
      ans -= (ans * ans * ans - n) / (3 * ans * ans);
    printf("%.8lf\\n", ans);
  }
  return 0;
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
int main() {
  int q;
  float x;
  for (; scanf("%d", &q), ~q; printf("%f\\n", x))
    for (x = q / 2.; fabs(x * x * x - q) > 1e-5 * q;
         x -= (x * x * x - q) / (3 * x * x))
      ;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
int main() {
  int q;
  float x;
  for (; scanf("%d", &q), ~q; printf("%f\\n", x))
    for (x = q / 2.; fabs(x * x * x - q) > 1e-5 * q; x -= x / 3 - q / 3 / x / x)
      ;
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  int n;
  double res;
  while (cin >> n) {
    if (n == -1)
      break;
    res = n / 2.0;

    while (1) {
      res -= (res * res * res - n) / (3 * res * res);
      if (fabs(res * res * res - n) < 0.00001 * n)
        break;
    }
    printf("%.6lf\\n", res);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;

int main() {
  int n;
  double res;
  while (cin >> n) {
    if (n == -1)
      break;
    res = n / 2.0;

    while (1) {
      res = res - ((res * res * res - n) / (3 * res * res * res));
      if (fabs(res * res * res - n) < 0.000001 * n)
        break;
    }
    cout << res << endl;
  }
  return 0;
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <iostream>
int main() {
  int q;
  while (std::cin >> q, q != -1) {
    double x = q / 2.0, a;
    while (1) {
      a = x * x * x - q;
      if (fabs(a) < 1e-5 * q)
        break;
      x -= a / 3 / x / x;
    }
    printf("%.6f\\n", x);
  }
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
int main() {
  int q;
  while (1) {
    std::cin >> q;
    if (q == -1)
      break;
    double x = q / 2, a;
    while (1) {
      a = x * x * x - q;
      if (fabs(a) < 1e-5 * q)
        break;
      x -= a / 3 / x / x;
    }
    std::cout << x << "\\n";
  }
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

int main() {
  while (1) {
    double q;
    cin >> q;
    if (q == -1)
      break;
    double x = q / 2;
    while (fabs(pow(x, 3) - q) >= 0.00001 * q) {
      x = x - (pow(x, 3) - q) / (3 * pow(x, 2));
    }
    cout << fixed << setprecision(6) << x << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

int main() {
  double q;
  while (cin >> q && q != -1) {
    double x = q / 2;
    while (1) {
      double n = fabs(pow(x, 3) - q);
      if (n < 0.00001)
        break;
      x = x - (n / (3 * pow(x, 2)));
    }
    cout << fixed << setprecision(6) << x << endl;
  }
  return 0;
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
  long long int q;
  double x;
  while (1) {
    cin >> q;
    if (q == -1)
      break;
    double x = (double)q / 2.0;
    while (fabs(x * x * x - q) > 0.00001 * (double)q) {
      x = x - (x * x * x - q) / (3 * x * x);
    }
    printf("%.6f\\n", x);
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  long long int q;
  double ans;
  while (1) {
    cin >> q;
    if (q == -1)
      break;
    double s = (double)q / 2;
    while (1) {
      ans = s - (s * s * s - q) / (3 * s * s);
      if (ans < 0.00001 * q)
        break;
      s = ans;
    }
    printf("%.6f\\n", ans);
  }
  return 0;
}