alexjercan/bugnet huggingface dataset:
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
  double q;
  while (cin >> q && q != -1) {
    double x = q / 2;
    while (true) {
      if (fabs(x * x * x - q) < 0.00001 * q)
        break;
      x -= (x * x * x - q) / (x * x * 3);
    }
    cout << fixed << setprecision(7) << x << endl;
  }
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
  double q;
  while (cin >> q && q != -1) {
    double x = q / 2;
    while (true) {
      if (fabs(x * x * x * q) < 0.00001 * q)
        break;
      x -= (x * x * x - q) / (x * x * 3);
    }
    cout << fixed << setprecision(7) << x << endl;
  }
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits //stdc++.h>
using namespace std;
int main() {
  int a;
  while (cin >> a && a != -1) {
    long double x1 = a / 2, x2;
    int i = 1;
    if (a == 1) {
      cout << "1.00000000000000" << endl;
    } else {
      while (true) {
        x2 = x1 - (x1 * x1 * x1 - a) / (3 * x1 * x1);
        if (abs(x2 * x2 * x2 - a) < 0.00001 * a) {
          printf("%.15Lf\\n", x2);
          break;
        }
        x1 = x2 - (x2 * x2 * x2 - a) / (3 * x2 * x2);
        if (abs(x1 * x1 * x1 - a) < 0.00001 * a) {
          printf("%.15Lf\\n", x1);
          break;
        }
        i++;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits //stdc++.h>
using namespace std;
int main() {
  int a;
  while (cin >> a && a != -1) {
    double x1 = a / 2, x2;
    int i = 1;
    while (true) {
      x2 = x1 - (x1 * x1 * x1 - a) / (3 * x1 * x1);
      if (abs(x2 * x2 * x2 - a) < 0.00001 * a) {
        cout << x2 << endl;
        break;
      }
      x1 = x2 - (x2 * x2 * x2 - a) / (3 * x2 * x2);
      if (abs(x1 * x1 * x1 - a) < 0.00001 * a) {
        cout << x1 << endl;
        break;
      }
      i++;
    }
  }
  return 0;
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <math.h>
#include <stdio.h>
int main(void) {
  double q;
  while (scanf("%lf", &q) != EOF && q != -1) {
    double x, a;
    x = q / 2;
    while (1) {
      if (fabs(x * x * x - q) < 0.00001 * q)
        break;
      x = x - ((x * x * x - q) / (3 * x * x));
      x = x;
    }
    printf("%.7f\\n", x);
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <math.h>
#include <stdio.h>
int main(void) {
  int q;
  while (scanf("%d", &q) != EOF) {
    double x;
    x = q / 2;
    if (q == -1)
      break;
    double xx;
    while (1) {
      xx = x - ((x * x * x - q) / (3 * x * x));

      if (fabs(x * x * x - q) < (0.00001 * q))
        break;
      x = xx;
    }
    printf("%.7f\\n", x);
  }

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

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

#define ABS(a) ((a) < 0 ? (-(a)) : (a))

int main() {
  while (1) {
    double q;
    cin >> q;
    if (q == -1)
      return 0;
    double a = q / 2;
    while (true) {
      a = a - (a * a * a - q) / (3 * a * a);
      if (ABS(a * a * a - q) < q * 0.00001)
        break;
    }
    printf("%.9lf\\n", a);
  }
}

Error: TLE

Fixed submission:

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

int main() {
  while (1) {
    double q;
    cin >> q;
    if (q == -1)
      return 0;
    double a = q / 2;
    for (int i = 0; i < 50000000; i++) {
      a = a - (a * a * a - q) / (3 * a * a);
    }
    printf("%.9lf\\n", a);
    cout << a * a * a << endl;
  }
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <string.h>
#include <utility>
#include <vector>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i, n) for (i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main() {
  int q;

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

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <string.h>
#include <utility>
#include <vector>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i, n) for (i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main() {
  int x;

  while (1) {
    cin >> x;
    if (x < 0)
      break;
    double a, b;
    b = x / 2;

    while (2) {
      a = b - (b * b * b - x) / (3 * b * b);
      if (abs(a * a * a - x) < 0.00001 * x)
        break;
      b = a;
    }
    cout << a << endl;
  }
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int in;
  double q, x;
  while (cin >> in && in != -1) {
    q = in;
    x = q / 2;
    while (fabs(x * x * x - q) >= q * 1e-5) {
      x = x - (x * x * x - q) / (3 * x * x);
    }
    printf("%.5f\\n", x);
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int in;
  double q, x;
  while (cin >> in && in) {
    q = in;
    x = q / 2;
    while (fabs(x * x * x - q) >= q * 1e-5) {
      x = x - (x * x * x - q) / (3 * x * x);
    }
    printf("%.5f\\n", x);
  }
  return 0;
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define REPR(i, n) for (ll i = 1; i < n; ++i)
#define FOR(i, a, b) for (ll i = a; i < b; ++i)

#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG_VEC(v)                                                           \\
  cout << #v << ":";                                                           \\
  REP(i, v.size()) cout << " " << v[i];                                        \\
  cout << endl
#define ALL(a) (a).begin(), (a).end()

#define MOD (ll)(1e9 + 7)
#define ADD(a, b) a = ((a) + (b)) % MOD
#define FIX(a) ((a) % MOD + MOD) % MOD

#define INF 1000000000

typedef double Real;
#define EPS 1e-11
#define EQ(x) (-EPS < x && x < EPS)
typedef complex<Real> P;
Real dot(P a, P b) { return real(conj(a) * b); }
Real cross(P a, P b) { return imag(conj(a) * b); }

int main() {
  cout.precision(12);
  while (true) {
    Real x;
    cin >> x;
    if (x == -1)
      break;
    Real a = x / 2.0;
    while (abs(a * a * a - x) >= 0.00001 * x) {
      a = a - (a * a * a - x) / (3.0 * a * a);
    }
    cout << fixed << a << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define REPR(i, n) for (ll i = 1; i < n; ++i)
#define FOR(i, a, b) for (ll i = a; i < b; ++i)

#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG_VEC(v)                                                           \\
  cout << #v << ":";                                                           \\
  REP(i, v.size()) cout << " " << v[i];                                        \\
  cout << endl
#define ALL(a) (a).begin(), (a).end()

#define MOD (ll)(1e9 + 7)
#define ADD(a, b) a = ((a) + (b)) % MOD
#define FIX(a) ((a) % MOD + MOD) % MOD

#define INF 1000000000

typedef double Real;
#define EPS 1e-11
#define EQ(x) (-EPS < x && x < EPS)
typedef complex<Real> P;
Real dot(P a, P b) { return real(conj(a) * b); }
Real cross(P a, P b) { return imag(conj(a) * b); }

int main() {
  cout.precision(12);
  while (true) {
    Real x;
    cin >> x;
    if (x == -1)
      break;
    Real a = x / 2;
    while (abs(a * a * a - x) > 1e-7) {
      a = a - (a * a * a - x) / (3 * a * a);
    }
    cout << fixed << a << endl;
  }
  return 0;
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>

#define abs(x) (x > 0.000000 ? x : -x)

double third_root(double x, double q) {
  double x2 = (2.0 * x + q / (x * x)) / 3.0;
  if (abs(x2 * x2 * x2 - q) < 0.000010 * q)
    return x2;
  return third_root(x2, q);
}

int main() {
  int n;
  while (1) {
    std::cin >> n;
    if (n == -1)
      break;
    std::printf("%.6f\\n", third_root((double)n / 2.0, (double)n));
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

#define abs(x) (x > 0.000000 ? x : -x)

double third_root(double x, double q) {
  double x2 = x - (x * x * x - q) / (3 * x * x);
  if (abs(x2 * x2 * x2 - q) < 0.00001 * q)
    return x2;
  return third_root(x2, q);
}

int main() {
  int n;
  while (std::cin >> n) {
    std::cout << third_root((double)n / 2.0, (double)n) << std::endl;
  }
  return 0;
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define EPS 1e-5

int main() {

  double q;
  while (cin >> q, q >= 0) {
    double x = q / 2;
    while (fabs(x * x * x - q) >= EPS * q) {
      x = x - (x * x * x - q) / (3 * x * x);
    }
    printf("%f\\n", x);
  }

  return 0;
}

Error: TLE

Fixed submission:

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

#define EPS 1e-5

int main() {

  double q;
  while (cin >> q, q >= 0) {
    double x = q / 2;
    while (fabs(x * x * x) > EPS * q) {
      x = x - (x * x * x - q) / (3 * x * x);
    }
    printf("%f\\n", x);
  }

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

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

using namespace std;

int main(void) {

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

Error: TLE

Fixed submission:

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

using namespace std;

int main(void) {

  int q;
  while (cin >> q) {
    if (q == -1)
      break;

    double x = q / 2;
    while (1) {
      if (abs(x * x * x - q) < 0.00001 * q)
        break;
      x = x - (x * x * x - q) / (3 * x * x);
    }
    printf("%.6f", x);
    cout << endl;
  }
  return 0;
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(), vec.end()
typedef long long int ll;
const ll MOD = 1000000007;
const ll INF = 1000000010;
const ll LINF = 4000000000000000010LL;
const int MAX = 310;
const double EPS = 1e-8;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {-1, 1, 0, 0};
int main() {
  double q;
  while (cin >> q, q != -1) {
    double b = q / 2;
    while (abs(pow(b, 3) - q) >= 0.00001 * q) {
      b = b - (pow(b, 3) - q) / (3 * pow(b, 2));
    }
    printf("%.6lf\\n", b);
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(), vec.end()
typedef long long int ll;
const ll MOD = 1000000007;
const ll INF = 1000000010;
const ll LINF = 4000000000000000010LL;
const int MAX = 310;
const double EPS = 1e-8;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {-1, 1, 0, 0};
int main() {
  double q;
  while (cin >> q, q != -1) {
    int id = 0;
    double dp[100010];
    dp[0] = q / 2;
    while (abs(pow(dp[id], 3) - q) > EPS) {
      dp[id + 1] = dp[id] - (pow(dp[id], 3) - q) / (3 * pow(dp[id], 2));
      id++;
    }
    printf("%.8lf\\n", dp[id]);
  }
}
Problem p00080 (C++) — buggy submission, verdict: Time Limit Exceeded

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

bool eq(double x, double y) {
  if (abs(x - y) < 0.00001 * y)
    return true;
  else
    return false;
}

int main(void) {
  long long q;
  double x[100], x1;
  while (cin >> q) {
    if (q == -1)
      break;
    x[1] = q / 2.0;
    for (int i = 2;; i++) {
      x[i] = x[i - 1] - (x[i - 1] * x[i - 1] * x[i - 1] - (double)q) /
                            (3 * x[i - 1] * x[i - 1]);
      if (eq(x[i] * x[i] * x[i], (double)q)) {
        x1 = x[i];
        break;
      }
    }
    cout << fixed;
    cout << setprecision(7) << x1 << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main(void) {
  long long q;
  double x[100], x1;
  while (cin >> q) {
    if (q == -1)
      break;
    x[1] = q / 2;
    for (int i = 2;; i++) {
      x[i] = x[i - 1] -
             (x[i - 1] * x[i - 1] * x[i - 1] - q) / (3 * x[i - 1] * x[i - 1]);
      if (abs(x[i] * x[i] * x[i] - q) < 0.00001 * q) {
        x1 = x[i];
        break;
      }
    }
    cout << fixed;
    cout << setprecision(7) << x1 << endl;
  }
  return 0;
}
Problem p00081 (C++) — buggy submission, verdict: Time Limit Exceeded


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

using namespace std;
typedef complex<double> xy_t;
double x[3], y[3];
char c;

double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); }
xy_t projection(xy_t p, xy_t b) { return b * dot_product(p, b) / norm(b); }

int main(void) {
  while (cin >> x[0] >> c >> y[0] >> c >> x[1] >> c >> y[1] >> c >> x[2] >> c >>
         y[2]) {
    xy_t P1(x[0], y[0]), P2(x[1], y[1]), Q(x[2], y[2]);
    xy_t S = projection(Q - P1, P2 - P1) + P1;
    xy_t T = S + S - Q;
    printf("%.6f %.6f\\n", real(T), imag(T));
  }

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;
typedef complex<double> xy_t;
double x[3], y[3];

double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); }
xy_t projection(xy_t p, xy_t b) { return b * dot_product(p, b) / norm(b); }

int main(void) {
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x[0], &y[0], &x[1], &y[1], &x[2],
               &y[2])) {
    xy_t P1(x[0], y[0]), P2(x[1], y[1]), Q(x[2], y[2]);
    xy_t S = projection(Q - P1, P2 - P1) + P1;
    xy_t T = S + S - Q;
    printf("%.6f %.6f\\n", real(T), imag(T));
  }

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

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

using namespace std;

int main() {
  double _x[6];
  while (cin >> _x[0]) {
    for (int i = 1; i < 6; i++) {
      char c;
      cin >> c;
      cin >> _x[i];
    }
    complex<double> x0(_x[0], _x[1]);
    complex<double> x1(_x[2], _x[3]);
    complex<double> q(_x[4], _x[5]);
    complex<double> r = polar(abs(q - x0), 2 * arg(x1 - x0) - arg(q - x0)) + x0;
    printf("%.6f %.6f\\n", real(r), imag(r));
  }
}

Error: TLE

Fixed submission:

#include <complex>
#include <cstdio>

using namespace std;

int main() {
  double _x[6];
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf", _x, _x + 1, _x + 2, _x + 3, _x + 4,
               _x + 5)) {
    complex<double> x0(_x[0], _x[1]);
    complex<double> x1(_x[2], _x[3]);
    complex<double> q(_x[4], _x[5]);
    complex<double> r = polar(abs(q - x0), 2 * arg(x1 - x0) - arg(q - x0)) + x0;
    printf("%.6f %.6f\\n", real(r), imag(r));
  }
}
Problem p00081 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, l, n) for (lint i = l; i < n; i++)
#define rer(i, l, n) for (lint i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define pb(a) push_back(a)
#define mk(a, b) make_pair(a, b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

double dist(double x1, double y1, double x2, double y2) {
  return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
}

double dot_product(double x1, double y1, double x2, double y2) {
  return x1 * x2 + y1 * y2;
}

int main() {
  double x1, y1, x2, y2, xq, yq;
  while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq)) {
    double xr, yr, k, xs, ys;
    k = dot_product(x2 - x1, y2 - y1, xq - x1, yq - y1) / dist(x2, y2, x1, y1);
    xs = x1 + k * (x2 - x1);
    ys = y1 + k * (y2 - y1);
    // o(" "<<xs<<" "<<ys);
    xr = 2 * xs - xq;
    yr = 2 * ys - yq;
    // xr=x1+(2*k-1)*(xq-x1);
    // yr=y1+(2*k-1)*(yq-y1);
    printf("%.6lf %.6lf\\n", xr, yr);
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, l, n) for (lint i = l; i < n; i++)
#define rer(i, l, n) for (lint i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define pb(a) push_back(a)
#define mk(a, b) make_pair(a, b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

double dist(double x1, double y1, double x2, double y2) {
  return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
}

double dot_product(double x1, double y1, double x2, double y2) {
  return x1 * x2 + y1 * y2;
}

int main() {
  double x1, y1, x2, y2, xq, yq;
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) !=
         'EOF') {
    double xr, yr, k, xs, ys;
    k = dot_product(x2 - x1, y2 - y1, xq - x1, yq - y1) / dist(x2, y2, x1, y1);
    xs = x1 + k * (x2 - x1);
    ys = y1 + k * (y2 - y1);
    // o(" "<<xs<<" "<<ys);
    xr = 2 * xs - xq;
    yr = 2 * ys - yq;
    // xr=x1+(2*k-1)*(xq-x1);
    // yr=y1+(2*k-1)*(yq-y1);
    printf("%.6lf %.6lf", xr, yr);
  }
}
Problem p00081 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  double x1, y1, x2, y2, xq, yq, a1, b1, a2, b2, cx, cy;

  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) !=
         EOF) {
    if ((y2 - y1) == 0) {
      a1 = xq;
      a2 = yq - y1;
      b1 = yq - 2 * a2;
    } else if ((x2 - x1) == 0) {
      b1 = yq;
      a2 = xq - x1;
      a1 = xq - 2 * a2;
    } else {
      a1 = (y2 - y1) / (x2 - x1);
      a2 = -1 / a1;
      b1 = y1 - a1 * x1;
      b2 = yq - a2 * xq;
      cx = a1 * (b2 - b1) / (a1 * a1 + 1);
      cy = a1 * cx + b1;
      a1 = 2 * cx - xq;
      b1 = 2 * cy - yq;
    }
    printf("%.6f %.6f\\n", a1, b1);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main(int argc, char **argv) {
  float x1, y1, x2, y2, xq, yq, a1, b1, a2, b2, s, t;

  while (scanf("%f,%f,%f,%f,%f,%f", &x1, &y1, &x2, &y2, &xq, &yq) != EOF) {
    if (x2 - x1 != 0 && y2 - y1 != 0) {
      a1 = (y2 - y1) / (x2 - x1);
      b1 = y1 - x1 * a1;
      a2 = -1 / a1;
      b2 = yq - xq * a2;

      for (int i = (int)((x1 < x2) ? x1 : x2);; i++) {
        s = (float)i * 0.001;
        if (a1 * s + b1 == a2 * s + b2) {
          break;
        }
      }
    } else if (x2 - x1 == 0) {
      s = x1;
      a2 = 0;
      b2 = yq;
    } else if (y2 - y1 == 0) {
      t = y1 + y1 - yq;
      printf("%.6f %.6f\\n", xq, t);
      continue;
    } else {
      t = 0;
      a2 = 0;
      b2 = 0;
    }

    t = s + s - xq;

    printf("%.6f %.6f\\n", t, a2 * t + b2);
  }

  return 0;
}
Problem p00081 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  double x1, y1, x2, y2, xq, yq;
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) > 0) {
    complex<double> p[2], q;
    p[0] = complex<double>(x1, y1);
    p[1] = complex<double>(x2, y2);
    q = complex<double>(xq, yq);

    complex<double> r;
    r = conj((q - p[0]) * conj(p[1] - p[0])) / conj(p[1] - p[0]) + p[0];
    cout << r.real() << ' ' << r.imag() << endl;
  }

  return 0;
}

Error: -11

Fixed submission:


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

int main() {
  double x1, y1, x2, y2, xq, yq;
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf", x1, y1, x2, y2, xq, yq) > 0) {
    complex<double> p[2], q;
    p[0] = complex<double>(x1, y1);
    p[1] = complex<double>(x2, y2);
    q = complex<double>(xq, yq);

    complex<double> r;
    r = conj(q * conj(p[1] - p[0])) / conj(p[1] - p[0]);
    cout << r.real() << ' ' << r.imag() << endl;
  }

  return 0;
}