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

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

using namespace std;

#define ALL(co) co.begin(), co.end()

typedef long long LL;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> Array;
typedef vector<int> LArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

int itiv;
inline int getInt() { return (cin >> itiv, itiv); }
void readAll(Array &vec, int n) {
  for (int i = 0; i < n; i++)
    cin >> vec[i];
}
inline bool between(int first, int last, int n) {
  return first <= n && n <= last;
}
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int m, n;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
int dr[] = {0, -1, 0, 1}, dc[] = {-1, 0, 1, 0};

int main(void) {
  while (cin >> n && n) {
    for (int i = 0; i < n; i++) {
      vector<int> arr(3);
      readAll(arr, 3);
      sort(ALL(arr));
      cout << (arr[2] * arr[2] == arr[0] * arr[0] + arr[1] * arr[1] ? "YES"
                                                                    : "NO")
           << endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

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

using namespace std;

#define ALL(co) co.begin(), co.end()

typedef long long LL;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> Array;
typedef vector<int> LArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

int itiv;
inline int getInt() { return (cin >> itiv, itiv); }
void readAll(Array &vec, int n) {
  for (int i = 0; i < n; i++)
    cin >> vec[i];
}
inline bool between(int first, int last, int n) {
  return first <= n && n <= last;
}
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int m, n;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
int dr[] = {0, -1, 0, 1}, dc[] = {-1, 0, 1, 0};

int main(void) {
  while (cin >> n && n) {
    for (int i = 0; i < n; i++) {
      vector<int> arr(3);
      for (int i = 0; i < n; i++)
        cin >> arr[i];
      sort(ALL(arr));
      cout << (arr[2] * arr[2] == arr[0] * arr[0] + arr[1] * arr[1] ? "YES"
                                                                    : "NO")
           << endl;
    }
  }
  return 0;
}
Problem p00003 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

#define ALL(co) co.begin(), co.end()

typedef long long LL;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> Array;
typedef vector<int> LArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

int itiv;
inline int getInt() { return (cin >> itiv, itiv); }
void readAll(Array &vec, int n) {
  for (int i = 0; i < n; i++)
    cin >> vec[i];
}
inline bool between(int first, int last, int n) {
  return first <= n && n <= last;
}
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int m, n;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
int dr[] = {0, -1, 0, 1}, dc[] = {-1, 0, 1, 0};

int main(void) {
  while (cin >> n && n) {
    for (int i = 0; i < n; i++) {
      vector<int> arr(3);
      for (int i = 0; i < 3; i++) {
        cin >> arr[i];
      }
      sort(ALL(arr));
      cout << (arr[2] * arr[2] == arr[0] * arr[0] + arr[1] * arr[1] ? "YES"
                                                                    : "NO")
           << endl;
    }
  }
  return 0;
}

Error: WA

Fixed submission:

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

using namespace std;

#define ALL(co) co.begin(), co.end()

typedef long long LL;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> Array;
typedef vector<int> LArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

int itiv;
inline int getInt() { return (cin >> itiv, itiv); }
void readAll(Array &vec, int n) {
  for (int i = 0; i < n; i++)
    cin >> vec[i];
}
inline bool between(int first, int last, int n) {
  return first <= n && n <= last;
}
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int m, n;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
int dr[] = {0, -1, 0, 1}, dc[] = {-1, 0, 1, 0};

int main(void) {
  while (cin >> n && n) {
    for (int i = 0; i < n; i++) {
      Array arr(3);
      readAll(arr, n);
      cout << "YES" << endl;
      // sort(ALL(arr));
      // cout << (arr[2] * arr[2] == arr[0] * arr[0] + arr[1] * arr[1] ? "YES" :
      // "NO") << endl;
    }
  }
  return 0;
}
Problem p00003 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a, b, c, d, c2, irekae, i, n;
  a = 0;
  b = 0;
  c = 0;
  d = 0;
  c2 = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b >> c;
    if (a > c) {
      irekae = a;
      a = c;
      c = irekae;
    }
    if (b > c) {
      irekae = b;
      b = c;
      c = irekae;
    }
    d = (a * a) + (b * b);
    c2 = (c * c);
    if (d == c2) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int a, b, c, d, c2;
  a = 0;
  b = 0;
  c = 0;
  d = 0;
  c2 = 0;
  while (scanf("%d %d %d", &a, &b, &c)) {
    d = a * a + b * b;
    c2 = c * c;
    if (d == c2) {
      printf("YES");
    } else {
      printf("NO");
    }
  }
}
Problem p00003 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int n;
  int deta[3];
  int square;

  cin >> n;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> deta[j];
    }

    sort(deta, deta + 3);

    square = (deta[0] * deta[0]) + (deta[1] * deta[1]);

    if (square == deta[2] * deta[2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int n;
  int deta[3];
  int square;

  cin >> n;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> deta[j];
    }
    square = (deta[0] * deta[0]) + (deta[1] * deta[1]);

    if (square == deta[2] * deta[2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

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

#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int maxnum(int f, int s, int t) {

  if (f >= s && f >= t) {

    return 0;

  } else if (s >= f && s >= t) {

    return 1;

  } else {

    return 2;
  }
}

bool solve() {

  int n;
  int set[1000][3];
  bool f;

  cin >> n;

  for (long i = 0; i < n; i++) {

    for (long j = 0; j < 3; j++) {

      cin >> set[i][j];
    }
  }

  for (long i = 0; i < n; i++) {

    f = (pow(set[i][0], 2) == (pow(set[i][1], 2) + pow(set[i][2], 2)) ||
         pow(set[i][1], 2) == (pow(set[i][0], 2) + pow(set[i][2], 2)) ||
         pow(set[i][2], 2) == (pow(set[i][0], 2) + pow(set[i][1], 2)));
    f ? cout << "YES\\n" : cout << "NO\\n";
  }

  return 0;
}

int main() { return solve(); }

Error: -11

Fixed submission:

#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int maxnum(int f, int s, int t) {

  if (f >= s && f >= t) {

    return 0;

  } else if (s >= f && s >= t) {

    return 1;

  } else {

    return 2;
  }
}

bool solve() {

  int n;
  vector<int[3]> set;
  bool f;

  cin >> n;

  for (long i = 0; i < n; i++) {

    for (long j = 0; j < 3; j++) {

      cin >> set[i][j];
    }
  }

  for (long i = 0; i < n; i++) {

    f = (pow(set[i][0], 2) == (pow(set[i][1], 2) + pow(set[i][2], 2)) ||
         pow(set[i][1], 2) == (pow(set[i][0], 2) + pow(set[i][2], 2)) ||
         pow(set[i][2], 2) == (pow(set[i][0], 2) + pow(set[i][1], 2)));
    f ? cout << "YES\\n" : cout << "NO\\n";
  }

  return 0;
}

int main() { return solve(); }
Problem p00003 (C++) — buggy submission, verdict: Memory Limit Exceeded

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

int main() {

  int n;
  cin >> n;

  vector<int> array(3, 0);

  while (n > 0) {

    cin >> array[0] >> array[1] >> array[2];

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

    if (array[0] * array[0] + array[1] * array[1] == array[2] * array[2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
    n--;
  }

  return 0;
}

Error: MLE

Fixed submission:

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

int main() {

  int n;
  cin >> n;

  vector<int> array(n * n * n, 0);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> array[j];
    }
    sort(array.begin(), array.end());

    if (array[0] * array[0] + array[1] * array[1] == array[2] * array[2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

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

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

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int len[3];
    for (int j = 0; j < 3; j++) {
      cin >> len[j];
    }
    sort(len, len + 3);

    if (len[2] * len[2] == len[0] * len[0] + len[1] * len[1])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

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

int main() {
  int n;
  while (cin >> n) {
    int len[3];
    for (int i = 0; i < n; i++) {
      cin >> len[i];
    }
    sort(len, len + 3);

    if (len[2] * len[2] == len[0] * len[0] + len[1] * len[1])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
Problem p00003 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>

int main() {
  using namespace std;
  int i;
  scanf("%d", &i);

  for (; i > 0; i--) {
    int l[3];
    scanf("%d %d %d", &l[0], &l[1], &l[2]);

    sort(l, l + 3);
    if (l[2] * l[2] == l[0] * l[0] + l[1] * l[1])
      printf("YES\\n");
    else
      printf("NO\\n");
  }

  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
int main() {

  int i;
  scanf("%d", &i);

  int tri[8][3];

  int cnt, k;

  for (cnt = 0; cnt < i; cnt++) {
    scanf("%d %d %d", &tri[cnt][0], &tri[cnt][1], &tri[cnt][2]);
    for (k = 0; k < 3; k++) {
      tri[cnt][k] = tri[cnt][k] * tri[cnt][k];
    }
    if (tri[cnt][0] == (tri[cnt][1] + tri[cnt][2]) ||
        tri[cnt][1] == (tri[cnt][2] + tri[cnt][0]) ||
        tri[cnt][2] == (tri[cnt][0] + tri[cnt][1]))
      printf("YES\\n");
    else
      printf("NO\\n");
  }

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

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

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

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

  REP(i, n) {
    vector<int> v(3);
    REP(j, 3) { cin >> v[j]; }
    sort(ALL(v));
    if (pow(v[0], 2) + pow(v[1], 2) == pow(v[2], 2))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

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

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

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

  REP(i, n) {
    vector<int> v(3);
    REP(j, 3) { cin >> v[i]; }
    sort(ALL(v));
    if (pow(v[0], 2) + pow(v[1], 2) == pow(v[2], 2))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
Problem p00003 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  int n;

  cin >> n;

  vector<int> v(3);

  for (int i = 0; i < n; ++i) {
    cin >> v[0] >> v[1] >> v[2];

    sort(v.begin(), v.end());
    if (v[0] * v[0] + v[1] * v[1] == v[2] * v[2])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}


Error: TLE

Fixed submission:

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

int main() {

  int n;

  cin >> n;

  vector<int> v(3);

  for (int i = 0; i < n; ++i) {
    for (int j = 0; i < 3; ++j) {
      cin >> v[j];
    }
    sort(v.begin(), v.end());
    if (v[0] * v[0] + v[1] * v[1] == v[2] * v[2])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
Problem p00004 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
class SimultaneousEquation {
public:
  void solve(int a, int b, int c, int d, int e, int f) {
    double x, y;
    x = double(c * e - b * f) / (a * e - b * d);
    y = double(c * d - a * f) / (b * d - a * e);
    if (x == 0)
      x = 0;
    if (y == 0)
      y = 0;
    printf("%.3lf %.3lf\\n", x, y);
  }
};
int main() {
  int a, b, c, d, e, f;
  SimultaneousEquation inst;
  while (cin >> a >> b >> c >> d >> e >> f) {
    inst.solve(a, b, c, d, e, f);
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
class SimultaneousEquation {
public:
  void solve(int a, int b, int c, int d, int e, int f) {
    double x, y;
    x = double(a * e - b * d) / (c * e - b * f);
    y = double(c * d - a * f) / (b * d - a * e);
    printf("%.3lf %.3lf\\n", x, y);
  }
};
int main() {
  int a, b, c, d, e, f;
  SimultaneousEquation inst;
  while (scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f)) {
    inst.solve(a, b, c, d, e, f);
  }
}
Problem p00004 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <stdio.h>
using namespace std;
int main() {
  double a, b, c, d, e, f, x, y;
  while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
    y = (c * d - f * a) / (b * d - a * e);
    x = (c - b * y) / a;
    printf("%.3f %.3f\\n", x, y);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <stdio.h>
using namespace std;
int main() {
  double a, b, c, d, e, f, x, y;
  while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f)) {
    y = (c * d - f * a) / (b * d - a * e);
    x = (c - b * y) / a;
    printf("%.3f %.3f\\n", x, y);
  }
  return 0;
}
Problem p00004 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {

  double a, b, c, d, e, f;
  double x, y;

  while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
    y = (c * d - a * f) / (b * d - a * e);
    x = (c * e - b * f) / (a * e - b * d);
    if (x == -0)
      x = 0;
    if (y == -0)
      y = 0;
    printf("%.3lf %.3lf\\n", x, y);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int X, Y;
  double a, b, c, d, e, f, x, y;
  double p[2][3] = {0};
  y = 0;
  x = 0;
  while (1) {
    scanf("%lf", &a);
    scanf("%lf", &b);
    scanf("%lf", &c);
    scanf("%lf", &d);
    scanf("%lf", &e);
    scanf("%lf", &f);
    if (a == EOF && b == EOF && c == EOF && d == EOF && e == EOF && f == EOF)
      break;
    y = (d * c - a * f) / (b * d - a * e);
    x = (e * c - b * f) / (e * a - b * d);
    X = x * 10000;
    Y = y * 10000;
    if ((X) % 10 >= 5)
      x += 0.0005;
    else if ((X) % 10 <= -5)
      x -= 0.0005;
    if ((Y) % 10 >= 5)
      y += 0.0005;
    else if ((Y) % 10 <= -5)
      y -= 0.0005;

    printf("%.3f %.3f\\n", x, y);
  }
  return 0;
}
Problem p00004 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  double a, b, c, d, e, f;
  double x, y;
  while (cin >> a >> b >> c >> d >> e >> f) {
    double det = a * e - b * d;
    x = (c * e - b * f) / det;
    y = (a * f - c * d) / det;
    if (x == -0) {
      x = 0;
    }
    if (y == -0) {
      y = 0;
    }
    printf("%.3f %.3f\\n", x, y);
  }
  return 0;
}

Error: WA

Fixed submission:


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

int main() {
  int a, b, c, d, e, f;
  double x, y;
  for (int i = 0; i < 2; i++) {
    cin >> a >> b >> c >> d >> e >> f;
    double l, m, n;
    l = a / d;
    m = b - e * l;
    n = c - f * l;
    y = n / m;
    x = (c - b * y) / a;
    printf("%.3f %.3f\\n", x, y);
  }
  return 0;
}
Problem p00004 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#define N 1000000
struct {
  int a[6];
} data[N];

int main() {
  int i, j, L;
  double a, b, c, d, e, f;
  double x, y;
  for (i = 0; i < N; i++) {
    for (j = 0; j < 6; j++)
      if (scanf("%d", &data[i].a[j]) == EOF)
        break;
    if (j == 0)
      break;
  }
  L = i;
  for (i = 0; i < L; i++) {
    a = data[i].a[0];
    b = data[i].a[1];
    c = data[i].a[2];
    d = data[i].a[3];
    e = data[i].a[4];
    f = data[i].a[5];
    x = (1 / (a * e - b * d)) * (e * c - b * f);
    y = (1 / (a * e - b * d)) * (a * f - d * c);
    if (x == -0)
      x = 0;
    if (y == -0)
      y = 0;
    printf("%4.3f %4.3f\\n", x, y);
  }
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
#define N 1000000
struct {
  double a, b, c, d, e, f;
} data[N];

int main() {
  int i, L;
  double a, b, c, d, e, f;
  double x, y;
  for (i = 0; i < N && scanf("%d %d %d %d %d %d", data[i].a, data[i].b,
                             data[i].c, data[i].d, data[i].e, data[i].f) != EOF;
       i++)
    ;
  L = i;
  for (i = 0; i < L; i++) {
    a = data[i].a;
    b = data[i].b;
    c = data[i].c;
    d = data[i].d;
    e = data[i].e;
    f = data[i].f;
    x = (1 / (a * e - b * d)) * (e * c - b * f);
    y = (1 / (a * e - b * d)) * (a * f - d * c);
    printf("%.3f %.3f", x, y);
  }
  return 0;
}
Problem p00004 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#pragma warning(disable : 4996)
long double a, b, c, d, e, f, x, y;
int main() {
  while (~scanf("%Lf%Lf%Lf%Lf%Lf%Lf", &a, &b, &c, &d, &e, &f)) {
    x = (c * e - b * f) / (a * e - b * d);
    y = (a * f - c * d) / (a * e - b * d);
    if (-0.0005 < x && x < 0.0005)
      x = 0.0;
    if (-0.0005 < y && y < 0.0005)
      y = 0.0;
    printf("%.3Lf %.3Lf\\n", x, y);
  }
  return 0;
}

Error: TLE

Fixed submission:

/*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <algorithm> // max??¢??°??????
#include <cmath>     // ??°??????
#include <fstream>   // ??????????????\\??????
#include <iomanip>   // stream???????????¢???
#include <iostream>  // ?¨??????\\??????
#include <string>    // ???????????¢???
#include <vector>    // ???????????????

using std::cin;
using std::cout;
using std::endl;
using std::fixed; // ???????????????????¨???????????????????????????????
using std::
    setprecision; // ?????°????°???°?????\\???????????°????????????????????¨????????\\???
using std::string;
using std::vector; // ????´???°????????????????????????

int main() {
  double a, b, p, c, d, q;
  double x, y;

  while (true) {
    cin >> a >> b >> p >> c >> d >> q;

    x = (p * d - b * q) / (a * d - b * c);
    y = (a * q - p * c) / (a * d - b * c);

    cout << fixed << setprecision(4) << x << " " << y << endl;
  }
  return 0;
}
Problem p00004 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
  double a, b, c, d, e, f;
  double x, y;
  while (cin >> a >> b >> c >> d >> e >> f) {
    if (a != 0 && d != 0) {
      y = (c / a - f / d) / (b / a - e / d);
      x = (c - b * y) / a;
    } else if (a == 0 && d != 0) {
      y = b / c;
      x = (f - e * y) / d;
    } else if (a != 0 && d == 0) {
      y = f / e;
      x = (c - b * y) / a;
    }
    printf("%4.3f %4.3f\\n", x, y);
  }
}

Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int a, b, c, d, e, f;
  double x, y;
  while (cin >> a >> b >> c >> d >> e >> f) {
    y = (c / a - f / d) / (b / a - e / d);
    x = (c - b * y) / a;
    cout << x << " " << y << endl;
  }
}
Problem p00004 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  float a, b, c, d, e, f, x, y;

  while (scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) != EOF) {
    y = (c * d - f * a) / (b * d - e * a);
    x = (c - b * y) / a;
    printf("%.3f %.3f\\n", x, y);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  while (1) {
    float a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, x = 0, y = 0;
    scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f);
    y = (c * d - f * a) / (b * d - e * a);
    x = (c - b * y) / a;
    printf("%.3f %.3f\\n", x, y);
  }
  return 0;
}
Problem p00004 (C++) — buggy submission, verdict: Runtime Error

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

int fff(double x) {
  if (x == (int)x) {
    return 3;
  } else if (x * 10 == (int)(x * 10)) {
    return 2;
  } else if (x * 100 == (int)(x * 100)) {
    return 1;
  } else if (x * 1000 == (int)(x * 1000)) {
    return 0;
  }
}

int main() {
  double k[60000] = {0};
  int i = 0;
  while (cin >> k[i++])
    ;
  int n = i - 1;
  for (int j = 0; j < n; j += 6) {
    double x = 0, y = 0, a = k[j], b = k[j + 1], c = k[j + 2], d = k[j + 3],
           e = k[j + 4], f = k[j + 5];
    x = (c * e - b * f) / (-b * d + a * e);
    y = (c * d - a * f) / (b * d - a * e);
    if (x == 0)
      x = abs(x);
    if (y == 0)
      y = abs(y);
    x *= 1000, x = round(x), x /= 1000;
    y *= 1000, y = round(y), y /= 1000;
    cout << x;
    int fx = fff(x);
    if (fx == 3) {
      cout << ".000 ";
    }
    if (fx == 2) {
      cout << "00 ";
    }
    if (fx == 1) {
      cout << "0 ";
    }
    if (fx == 0) {
      cout << " ";
    }
    cout << y;
    int fy = fff(y);
    if (fy == 3) {
      cout << ".000";
    }
    if (fy == 2) {
      cout << "00";
    }
    if (fy == 1) {
      cout << "0";
    }
    cout << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  double a[60000000] = {0};
  int i = 0;
  while (cin >> a[i++])
    ;
  int n = i - 1;
  for (int j = 0; j < n; j += 6) {
    double k = a[j] / a[j + 3], x = 0, y = 0;
    a[j + 3] *= k, a[j + 4] *= k, a[j + 5] *= k;
    y = (a[j + 2] - a[j + 5]) / (a[j + 1] - a[j + 4]);
    x = (a[j + 2] - a[j + 1] * y) / a[j];
    cout << x << " " << y << endl;
  }
  return 0;
}