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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
#define all(n) n.begin(), n.end()
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define insert(a, b, c, d) PP(P(a, b), P(c, d))
#define F first
#define S second
#define pb push_back
#define INF (1 << 27)
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;

typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

int main() {

  int a, b;
  while (cin >> a >> b) {
    int c = a + b;
    stringstream ss;
    ss << c;
    string ret;
    ss >> ret;
    cout << ret.size() << endl;
  }

  ofstream ofs("out2.txt");
  for (int i = 0; i <= 10000; i++) {
    ofs << string(200000, '?') << endl;
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
#define all(n) n.begin(), n.end()
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define insert(a, b, c, d) PP(P(a, b), P(c, d))
#define F first
#define S second
#define pb push_back
#define INF (1 << 27)
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;

typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

int main() {

  int a, b;
  while (cin >> a >> b) {
    int c = a + b;
    stringstream ss;
    ss << c;
    string ret;
    ss >> ret;
    cout << ret.size() << endl;
  }

  for (int j = 0; j <= 1000; j++) {
    string name = "out";
    stringstream ss;
    ss << j;
    string index;
    ss >> index;
    name += index + ".txt";
    ofstream ofs(name.c_str());
    ofs << string(100000, '?') << endl;
  }

  return 0;
}
Problem p00002 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
#define all(n) n.begin(), n.end()
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define insert(a, b, c, d) PP(P(a, b), P(c, d))
#define F first
#define S second
#define pb push_back
#define INF (1 << 27)
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

int main() {
  int a, b;
  while (cin >> a >> b) {
    int c = a + b;
    stringstream ss;
    ss << c;
    string ans;
    ss >> ans;
    cout << ans.length() << endl;
  }

  /*
  ofstream ofs("tes");
  ofs << "script -k test.log" << endl;
  system("chmod 755 tes");
  system("at -m -f tes 2:35");



  system("at exit 2:40");
  system("at cat test.log 2:41");
  */

  ofstream ofs("test.t");
  ofs << "testetete" << endl;
  cerr << system("rm test.t") << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
#define all(n) n.begin(), n.end()
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define insert(a, b, c, d) PP(P(a, b), P(c, d))
#define F first
#define S second
#define pb push_back
#define INF (1 << 27)
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

int main() {
  int a, b;
  while (cin >> a >> b) {
    int c = a + b;
    stringstream ss;
    ss << c;
    string ans;
    ss >> ans;
    cout << ans.length() << endl;
  }

  /*
  ofstream ofs("tes");
  ofs << "script -k test.log" << endl;
  system("chmod 755 tes");
  system("at -m -f tes 2:35");



  system("at exit 2:40");
  system("at cat test.log 2:41");
  */

  // ofstream ofs("test.t");
  // ofs << "testetete" << endl;
  // cerr << system("rm test.t") << endl;

  return 0;
}
Problem p00002 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int size(int n) {
  int ret = 0;
  while (n > 0) {
    ++ret;
    n /= 10;
  }
  return ret;
}

int main() {
  int i, j;
  while (scanf("%d %d", &i, &j)) {
    printf("%d\n", size(i + j));
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int size(int n) {
  int ret = 0;
  while (n > 0) {
    ++ret;
    n /= 10;
  }
  return ret;
}

int main() {
  int i, j;
  while (scanf("%d %d", &i, &j) == 2) {
    printf("%d\n", size(i + j));
  }
  return 0;
}
Problem p00002 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;

int main() {

  while (true) {
    int a, b;
    cin >> a >> b;
    a = a + b;
    cout << (int)log10(a) + 1 << endl;
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;

int main() {
  int a, b;
  while (cin >> a >> b) {
    a = a + b;
    cout << (int)log10(a) + 1 << endl;
  }

  return 0;
}
Problem p00002 (C++)

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

using namespace std;

int main(void) {

  int a, b;
  int ans;

  while (1) {
    cin >> a >> b;

    if (a == 0 && b == 0)
      break;

    ans = log10(a + b) + 1;
    cout << ans << endl;
  }
}


Fixed submission:
#include <cmath>
#include <iostream>

using namespace std;

int main(void) {

  int a, b;
  int ans;

  while (cin >> a >> b) {
    ans = log10(a + b) + 1;
    cout << ans << endl;
  }
}
Problem p00002 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int digit(int x) {
  int res = 0;
  while (x != 0) {
    res++;
    x /= 10;
  }
  return res;
}

int main(void) {
  int a, b;
  while (true) {
    cin >> a >> b;
    cout << digit(a + b) << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int digit(int x) {
  int res = 0;
  while (x != 0) {
    res++;
    x /= 10;
  }
  return res;
}

int main(void) {
  int a, b;
  while (cin >> a >> b) {
    cout << digit(a + b) << endl;
  }
}
Problem p00002 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>

using namespace std;

int main() {
  int a, b, i;
  while (a != -1 && b != -1) {
    scanf("%d%d", &a, &b);
    a += b;
    for (i = 0; i < 201; i++) {
      if (a / 10 == 0) {
        printf("%d\n", i + 1);
        break;
      } else {
        a = a / 10;
      }
    }
  }

  return 0;
}

Fixed submission:
#include <stdio.h>

using namespace std;

int main() {
  int a, b, i;
  while (scanf("%d%d", &a, &b) != EOF) {
    a += b;
    for (i = 0; i < 201; i++) {
      if (a / 10 == 0) {
        printf("%d\n", i + 1);
        break;
      } else {
        a = a / 10;
      }
    }
  }

  return 0;
}
Problem p00002 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  long long int a, b, c;
  int x;
  bool flg = true;

  while (1) {
    cin >> a;
    if (a == 0)
      break;
    cin >> b;

    c = a + b;

    x = 1;
    flg = true;
    while (flg) {
      if ((c = c / 10) > 0)
        x++;
      else
        flg = false;
    }
    cout << x << endl;
  }
  return 0;
}

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

int main() {
  long long int a, b, c;
  int x;
  bool flg = true;

  while (1) {
    cin >> a;
    if (cin.eof())
      break;
    cin >> b;

    c = a + b;

    x = 1;
    flg = true;
    while (flg) {
      if ((c = c / 10) > 0)
        x++;
      else
        flg = false;
    }
    cout << x << endl;
  }
  return 0;
}
Problem p00002 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int stringers_number(int a) { return int(log10(a) + 1); }

int extract_the_number(char *n1, char *n2) {
  int data_size1 = 0;
  int data_size2 = 0;
  for (data_size1 = 0; !(*(n1 + data_size1) == '\0'); data_size1++) {
  }
  for (data_size2 = 0; !(*(n2 + data_size2) == '\0'); data_size2++) {
  }
  /*int data_size1 = sizeof(n1) / sizeof(n1[0]);
  int data_size2 = sizeof(n2) / sizeof(n2[0]);*/
  /*for (i=0;i<=data_size-1;i++)
          if (a[i] == ' ')
                  break; */
  int a1 = 0;
  int j = 0;
  for (j = 0; j <= data_size1 - 1; j++) {
    int j_keta = int(*(n1 + (sizeof n1[0]) * j)) - 48;
    a1 = a1 + (pow(10, (data_size1 - j - 1))) * j_keta;
  }
  int a2 = 0;
  int k = 0;
  for (k = 0; k <= data_size2 - 1; k++) {
    int k_keta = int(*(n2 + (sizeof n2[0]) * k)) - 48;
    a2 = a2 + (pow(10, (data_size2 - k - 1))) * k_keta;
  }
  return a1 + a2;
}

int main() {
  char n1[100];
  char n2[100];
  while (1) {
    cin >> n1;
    cin >> n2;
    cout << stringers_number(extract_the_number(n1, n2)) << endl;
  }
  return 0;
}

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

int stringers_number(int a) { return int(log10(a) + 1); }

int extract_the_number(char *n1, char *n2) {
  int data_size1 = 0;
  int data_size2 = 0;
  for (data_size1 = 0; !(*(n1 + data_size1) == '\0'); data_size1++) {
  }
  for (data_size2 = 0; !(*(n2 + data_size2) == '\0'); data_size2++) {
  }
  /*int data_size1 = sizeof(n1) / sizeof(n1[0]);
  int data_size2 = sizeof(n2) / sizeof(n2[0]);*/
  /*for (i=0;i<=data_size-1;i++)
          if (a[i] == ' ')
                  break; */
  int a1 = 0;
  int j = 0;
  for (j = 0; j <= data_size1 - 1; j++) {
    int j_keta = int(*(n1 + (sizeof n1[0]) * j)) - 48;
    a1 = a1 + (pow(10, (data_size1 - j - 1))) * j_keta;
  }
  int a2 = 0;
  int k = 0;
  for (k = 0; k <= data_size2 - 1; k++) {
    int k_keta = int(*(n2 + (sizeof n2[0]) * k)) - 48;
    a2 = a2 + (pow(10, (data_size2 - k - 1))) * k_keta;
  }
  return a1 + a2;
}

int main() {
  char n1[100];
  char n2[100];
  while (cin >> n1 && cin >> n2) {
    /*cin >> n1;
    cin >> n2;*/
    cout << stringers_number(extract_the_number(n1, n2)) << endl;
  }
  return 0;
}
Problem p00002 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int count = 0;
  int digit_num;
  int a[200], b[200];
  int sum;
  while (1) {
    cin >> a[count] >> b[count];
    if (a[count] >= 0 && a[count] <= 1000000)
      if (b[count] >= 0 && b[count] <= 1000000) {
        sum = a[count] + b[count];
        digit_num = 1;
        while ((sum / 10) != 0) {
          digit_num++;
          sum = sum / 10;
        }
        cout << digit_num << endl;
        count++;
        if (count > 200)
          break;
      }
  }
  return 0;
}

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

int main() {
  int count = 0;
  int digit_num;
  int a[200], b[200];
  int sum;
  while (cin >> a[count] >> b[count]) {
    if (a[count] >= 0 && a[count] <= 1000000)
      if (b[count] >= 0 && b[count] <= 1000000) {
        sum = a[count] + b[count];
        digit_num = 1;
        while ((sum / 10) != 0) {
          digit_num++;
          sum = sum / 10;
        }
        cout << digit_num << endl;
        count++;
        if (count > 200)
          break;
      }
  }
  return 0;
}
Problem p00002 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
using namespace std;
int a, b;
int cnt, ans;
int count(int s) {
  if (s / 10 == 0)
    return cnt;
  else {
    cnt++;
    count(s / 10);
  }
}
int main() {
  while (scanf("%d %d", &a, &b)) {
    cnt = 1;
    ans = count(a + b);
    printf("%d\n", ans);
  }
  return 0;
}

Fixed submission:
#include <cstdio>
using namespace std;
int a, b;
int cnt, ans;
int count(int s) {
  if (s / 10 == 0)
    return cnt;
  else {
    cnt++;
    count(s / 10);
  }
}
int main() {
  while (scanf("%d %d", &a, &b) != EOF) {
    cnt = 1;
    ans = count(a + b);
    printf("%d\n", ans);
  }
  return 0;
}
Problem p00002 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;

int main() {
  while (true) {
    long int a, b;
    cin >> a >> b;
    long int c = a + b;
    double r = log10(c) + 1;
    long int s = r;
    cout << s << endl;
  }
  return 0;
}

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

int main() {
  long int a, b, c, s;
  double r;
  while (cin >> a >> b) {
    c = a + b;
    r = log10(c) + 1;
    s = r;
    cout << s << endl;
  }
  return 0;
}
Problem p00002 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>

int main() {
  int a;
  int b;
  while (scanf("%d %d", &a, &b)) {
    int result = a + b;
    int digit = 0;
    while (result != 0) {
      digit++;
      result /= 10;
    }

    printf("%d\n", digit);
  }
}

Fixed submission:
#include <stdio.h>

int main() {
  int a;
  int b;
  while (scanf("%d %d", &a, &b) != EOF) {
    int result = a + b;
    int digit = 0;
    while (result != 0) {
      digit++;
      result /= 10;
    }

    printf("%d\n", digit);
  }
}
Problem p00003 (C++)

Buggy submission (status: 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++) {
      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;
}

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 < 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;
}
Problem p00003 (C++)

Buggy submission (status: 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;
  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(); }

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;
  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(); }
Problem p00003 (C++)

Buggy submission (status: 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[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;
}

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[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;
}
Problem p00003 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
int main() {
  int a, b, c, n, i;
  std::cin >> n;
  for (i = 0; i = n; i++) {
    std::cin >> a >> b >> c;
    if (a * a == b * b + c * c)
      std::cout << "YES" << std::endl;
    else if (b * b == a * a + c * c)
      std::cout << "YES" << std::endl;
    else if (c * c == a * a + b * b)
      std::cout << "YES" << std::endl;
    else
      std::cout << "NO" << std::endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
int main() {
  int a, b, c, n, i;
  std::cin >> n;
  for (i = 0; i < n; i++) {
    std::cin >> a >> b >> c;
    if (a * a == b * b + c * c)
      std::cout << "YES" << std::endl;
    else if (b * b == a * a + c * c)
      std::cout << "YES" << std::endl;
    else if (c * c == a * a + b * b)
      std::cout << "YES" << std::endl;
    else
      std::cout << "NO" << std::endl;
  }
  return 0;
}
Problem p00003 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int a[100], b[100], c[100], n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i] *= a[i];
    b[i] *= b[i];
    c[i] *= c[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] + b[i] == c[i] || a[i] + c[i] == b[i] || b[i] + c[i] == a[i]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return (0);
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int a[10000], b[10000], c[10000], n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i] *= a[i];
    b[i] *= b[i];
    c[i] *= c[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] + b[i] == c[i] || a[i] + c[i] == b[i] || b[i] + c[i] == a[i]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return (0);
}
Problem p00003 (C++)

Buggy submission (status: 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 < 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;
}

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);
      readAll(arr, 3);
      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 (status: Runtime Error):
#include <iostream>
#include <queue>
using namespace std;

int ary[3][1010];
int main() {
  priority_queue<int> que;
  int N;
  cin >> N;
  int a;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= 2; j++) {
      cin >> a;
      que.push(a);
    }
    for (int j = 0; j <= 2; j++) {
      ary[i][j] = que.top();
      que.pop();
    }
  }
  for (int i = 1; i <= N; i++) {
    if (ary[i][0] * ary[i][0] ==
        ary[i][1] * ary[i][1] + ary[i][2] * ary[i][2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

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

int ary[1010][3];
int main() {
  priority_queue<int> que;
  int N;
  cin >> N;
  int a;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= 2; j++) {
      cin >> a;
      que.push(a);
    }
    for (int j = 0; j <= 2; j++) {
      ary[i][j] = que.top();
      que.pop();
    }
  }
  for (int i = 1; i <= N; i++) {
    if (ary[i][0] * ary[i][0] ==
        ary[i][1] * ary[i][1] + ary[i][2] * ary[i][2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
Problem p00003 (C++)

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

int main() {

  int N = 0, a = 0, b = 0, c = 0, i;

  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d %d %d", a, b, c);
    if (a * a + b * b == c * c) {
      printf("YES\n");
    } else if (a * a + c * c == b * b) {
      printf("YES\n");
    } else if (b * b + c * c == a * a) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}

Fixed submission:
#include <stdio.h>

int main() {

  int N = 0, a = 0, b = 0, c = 0, i;

  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d %d %d", &a, &b, &c);

    if (a * a + b * b == c * c) {
      printf("YES\n");
    } else if (a * a + c * c == b * b) {
      printf("YES\n");
    } else if (b * b + c * c == a * a) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}
Problem p00003 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c;
  cin >> n;
  long long tmp[3];
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    tmp[0] = a;
    tmp[1] = b;
    tmp[2] = c;
    sort(tmp, tmp + n);
    if (tmp[0] * tmp[0] + tmp[1] * tmp[1] == tmp[2] * tmp[2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c;
  cin >> n;
  long long tmp[3];
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    tmp[0] = a;
    tmp[1] = b;
    tmp[2] = c;
    sort(tmp, tmp + 3);
    if (tmp[0] * tmp[0] + tmp[1] * tmp[1] == tmp[2] * tmp[2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
Problem p00003 (C++)

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

using namespace std;

int main() {
  int n[200][3];
  int len = 0, m;
  cin >> m;
  while (cin >> n[len][0] >> n[len][1] >> n[len][2]) {
    n[len][0] *= n[len][0];
    n[len][1] *= n[len][1];
    n[len][2] *= n[len][2];
    len++;
  }
  for (int i = 0; i < len; i++) {
    if (n[i][0] == (n[i][1] + n[i][2]))
      cout << "YES" << endl;
    else if (n[i][1] == (n[i][2] + n[i][0]))
      cout << "YES" << endl;
    else if (n[i][2] == (n[i][0] + n[i][1]))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  int n[1000][3];
  int len = 0, m;
  cin >> m;
  while (cin >> n[len][0] >> n[len][1] >> n[len][2]) {
    n[len][0] *= n[len][0];
    n[len][1] *= n[len][1];
    n[len][2] *= n[len][2];
    len++;
  }
  for (int i = 0; i < len; i++) {
    if (n[i][0] == (n[i][1] + n[i][2]))
      cout << "YES" << endl;
    else if (n[i][1] == (n[i][2] + n[i][0]))
      cout << "YES" << endl;
    else if (n[i][2] == (n[i][0] + n[i][1]))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
Problem p00003 (Python)

Buggy submission (status: Runtime Error):
import sys

input()
for e in sys.stdin:
    a, b, c = sorted(int(e.split()))
    if a**2 + b**2 == c**2:
        print("YES")
    else:
        print("NO")


Fixed submission:
import sys

input()
for e in sys.stdin:
    a, b, c = sorted(map(int, e.split()))
    if a**2 + b**2 == c**2:
        print("YES")
    else:
        print("NO")
Problem p00003 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <stdio.h>
using namespace std;

int triangle(int a, int b, int c) {
  a = a * a;
  b = b * b;
  c = c * c;

  if (a == (b + c))
    return 0;
  else if (b == (a + c))
    return 0;
  else if (c == (a + b))
    return 0;
  else
    return 1;
}

int main() {
  int n;
  int a, b, c;
  int i = 0;

  scanf("%d", &n);

  while (i < n) {
    scanf("%d %d %d", &a, &b, &c);

    if (triangle(a, b, c) == 0) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}

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

int triangle(int a, int b, int c) {
  a = a * a;
  b = b * b;
  c = c * c;

  if (a == (b + c))
    return 0;
  else if (b == (a + c))
    return 0;
  else if (c == (a + b))
    return 0;
  else
    return 1;
}

int main() {
  int n;
  int a, b, c;
  int i = 0;

  scanf("%d", &n);

  while (i < n) {
    scanf("%d %d %d", &a, &b, &c);

    if (triangle(a, b, c) == 0) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
    i++;
  }
  return 0;
}
Problem p00003 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    vector<string> ans;
    for (int i = 0; i < n; ++i) {
      int x, y, z;
      cin >> x >> y >> z;
      if (x < y + z && y < z + x && z < x + y) {
        if (x * x == y * y + z * z || y * y == z * z + x * x ||
            z * z == x * x + y * y) {
          ans.push_back("YES");
        }
      } else {
        ans.push_back("NO");
      }
    }
    for (int i = 0; i < n; ++i) {
      cout << ans[i] << endl;
    }
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    vector<string> ans;
    for (int i = 0; i < n; ++i) {
      int x, y, z;
      cin >> x >> y >> z;
      if (x * x == y * y + z * z || y * y == z * z + x * x ||
          z * z == x * x + y * y) {
        ans.push_back("YES");
      } else {
        ans.push_back("NO");
      }
    }
    for (int i = 0; i < n; ++i) {
      cout << ans[i] << endl;
    }
  }
  return 0;
}
Problem p00003 (Python)

Buggy submission (status: Runtime Error):
while True:
    try:
        input_line = input()
        if input_line == "":
            break
        else:
            nums = list(map(int, input_line.split()))
            max_num = max(nums)
            nums.remove(max_num)
            if max_num**2 == nums[0] ** 2 + nums[1] ** 2:
                print("YES")
            else:
                print("NO")
    except EOFError:
        break


Fixed submission:
n = int(input())
for i in range(0, n):
    nums = list(map(int, input().split()))
    max_num = max(nums)
    nums.remove(max_num)
    if max_num**2 == nums[0] ** 2 + nums[1] ** 2:
        print("YES")
    else:
        print("NO")
Problem p00003 (C++)

Buggy submission (status: 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) {
    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;
  }
}


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) {
    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;
  }
}
Problem p00004 (C++)

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

const double EPS = 1e-8;
typedef vector<double> Vec;
typedef vector<Vec> Mat;

void show(const Mat &m) {
  puts("====");
  for (int i = 0; i < m.size(); i++) {
    for (int j = 0; j < m[i].size(); j++) {
      printf("%f ", m[i][j]);
    }
    puts("");
  }
  puts("====");
}

Vec gauss_jordan(const Mat &A, const Vec &b) {
  int n = A.size();
  Mat B(n, Vec(n + 1));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      B[i][j] = A[i][j];
    }
    B[i][n] = b[i];
  }

  for (int i = 0; i < n; i++) {
    int pivot = i;
    for (int j = i; j < n; j++) {
      if (abs(B[j][i]) > abs(B[pivot][i])) {
        pivot = j;
      }
    }
    swap(B[i], B[pivot]);

    if (abs(B[i][i]) < EPS)
      return Vec();

    for (int j = i + 1; j <= n; j++) {
      B[i][j] /= B[i][i];
    }
    for (int j = 0; j < n; j++) {
      if (i != j) {
        for (int k = i + 1; k <= n; k++) {
          B[j][k] -= B[j][i] * B[i][k];
        }
      }
    }

    // show(B);
  }

  Vec x(n);
  for (int i = 0; i < n; i++) {
    x[i] = B[i][n];
  }

  return x;
}

int main() {
  while (true) {
    Mat A(2, Vec(2));
    Vec b(2);

    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        scanf("%lf", &A[i][j]);
      }
      scanf("%lf", &b[i]);
    }

    Vec res = gauss_jordan(A, b);
    printf("%.3f %.3f\n", res[0], res[1]);
  }

  return 0;
}

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

const double EPS = 1e-8;
typedef vector<double> Vec;
typedef vector<Vec> Mat;

void show(const Mat &m) {
  puts("====");
  for (int i = 0; i < m.size(); i++) {
    for (int j = 0; j < m[i].size(); j++) {
      printf("%f ", m[i][j]);
    }
    puts("");
  }
  puts("====");
}

Vec gauss_jordan(const Mat &A, const Vec &b) {
  int n = A.size();
  Mat B(n, Vec(n + 1));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      B[i][j] = A[i][j];
    }
    B[i][n] = b[i];
  }

  for (int i = 0; i < n; i++) {
    int pivot = i;
    for (int j = i; j < n; j++) {
      if (abs(B[j][i]) > abs(B[pivot][i])) {
        pivot = j;
      }
    }
    swap(B[i], B[pivot]);

    if (abs(B[i][i]) < EPS)
      return Vec();

    for (int j = i + 1; j <= n; j++) {
      B[i][j] /= B[i][i];
    }
    for (int j = 0; j < n; j++) {
      if (i != j) {
        for (int k = i + 1; k <= n; k++) {
          B[j][k] -= B[j][i] * B[i][k];
        }
      }
    }

    // show(B);
  }

  Vec x(n);
  for (int i = 0; i < n; i++) {
    x[i] = B[i][n];
  }

  return x;
}

int main() {
  while (true) {
    Mat A(2, Vec(2));
    Vec b(2);

    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        if (scanf("%lf", &A[i][j]) == EOF)
          return 0;
      }
      scanf("%lf", &b[i]);
    }

    Vec res = gauss_jordan(A, b);
    printf("%.3f %.3f\n", res[0], res[1]);
  }

  return 0;
}
Problem p00004 (C++)

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

using namespace std;

int main() {
  double a, b, c, d, e, f;
  while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f)) {
    printf("%.3f %.3f\n", (c * e - b * f) / (a * e - b * d),
           (c * d - a * f) / (b * d - a * e));
  }

  return 0;
}

Fixed submission:
#include <cstdio>

using namespace std;

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

  return 0;
}
Problem p00004 (C++)

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

int main(void) {
  while (scanf("") != EOF) {
    float equ[2][3];
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 3; j++)
        cin >> equ[i][j];
    float delta = -equ[0][0] * equ[1][1] + equ[0][1]

                                               * equ[1][0];
    float y = (-equ[0][0] * equ[1][2] + equ[0][2] * equ

                                                        [1][0]) /
              delta;
    float x = (equ[0][2] - equ[0][1] * y) / equ[0][0];
    printf("%.3f %.3f\n", x, y);
  }
}

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

int main(void) {
  float a, b, c, d, e, f;
  while (cin >> a >> b >> c >> d >> e >> f) {
    float delta = -a * e + b * d;
    float y = (-a * f + c * d) / delta;
    float x = (c - b * y) / a;
    printf("%.3f %.3f\n", x, y);
  }
}
Problem p00004 (C++)

Buggy submission (status: Time Limit Exceeded):
/*************************************************************************
        > File Name: 23.cpp
        > Author: ralph
        > Mail: 1694487365@qq.com
        > Created Time: 2018年12月21日 星期五 21时32分48秒
 ************************************************************************/

#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b, c, d, e, f;
  while (scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f)) {
    printf("%.3f %.3f\n",
           (c * e - b * f) / (a * e - b * d) == 0
               ? 0.000
               : (c * e - b * f) / (a * e - b * d),
           (a * f - c * d) / (a * e - b * d) == 0
               ? 0.000
               : (a * f - c * d) / (a * e - b * d));
  }
}


Fixed submission:
/*************************************************************************
        > File Name: 23.cpp
        > Author: ralph
        > Mail: 1694487365@qq.com
        > Created Time: 2018年12月21日 星期五 21时32分48秒
 ************************************************************************/

#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b, c, d, e, f;
  while (scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != EOF) {
    double ans1 = (c * e - b * f) / (a * e - b * d),
           ans2 = (a * f - c * d) / (a * e - b * d);
    printf("%.3f %.3f\n", ans1 == 0 ? 0 : ans1, ans2 == 0 ? 0 : ans2);
  }
}
Problem p00004 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p00004 (C++)

Buggy submission (status: 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)) {
    y = (c * d - f * a) / (b * d - a * e);
    x = (c - b * y) / a;
    printf("%.3f %.3f\n", x, y);
  }
  return 0;
}

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) != EOF) {
    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 (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <stdio.h>

using namespace std;

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

int main() {
  while (1) {
    cin >> a >> b >> c >> d >> e >> f;
    y = (c - f * a / d) / (b - e * a / d);
    x = -b / a * y + c / a;
    printf("%.3lf %.3lf\n", x, y);
  }
}

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

using namespace std;

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

int main() {
  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);
  }
}
Problem p00004 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
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)) {
    x = ((c * e - f * b) / (a * e - d * b));
    y = ((c - a * x) / b);
    if (x > 0)
      x += 0.0005;
    else
      x -= 0.0005;
    if (y > 0)
      x += 0.0005;
    else
      y = -0.0005;
    printf("%.3ld %.3ld", x, y);
  }
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  double a, b, c, d, e, f;
  while (scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != -1) {
    printf("%.3lf %.3lf\n",
           (c * e - f * b) == 0 ? 0 : (c * e - f * b) / (a * e - d * b),
           (c * d - a * f) == 0 ? 0 : (c * d - a * f) / (b * d - a * e));
  }
  return 0;
}
Problem p00004 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
int main() {
  for (float a, b, c, d, e, f, x, y, g, h;
       std::cin.eof() || (std::cin >> a >> b >> c >> d >> e >> f, 1);
       printf("%.3f %.3f\n", x, y))
    g = b * d - a * e, h = c * d - a * f,
    d * g ? (x = f / d - e * h / g / d,
             y = b ? c / b - a * x / b : f / e - d * x / e)
          : (y = h / g, x = a ? c / a - b * y / a : f / d - e * y / d);
}

Fixed submission:
#include <iostream>
int main() {
  for (float a, b, c, d, e, f, x, y, g, h;; printf("%.3f %.3f\n", x, y)) {
    std::cin >> a >> b >> c >> d >> e >> f;
    if (std::cin.eof())
      break;
    g = b * d - a * e;
    h = c * d - a * f;
    d *g ? (x = f / d - e * h / g / d,
            y = b ? c / b - a * x / b : f / e - d * x / e)
         : (y = h / g, x = a ? c / a - b * y / a : f / d - e * y / d);
  }
}
Problem p00004 (C++)

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

double halfadjust(double x) {
  int tmp = (x * 10000);
  tmp = tmp % 10;
  double ans = static_cast<double>(static_cast<int>(x * 1000));
  ans = ans / 1000;
  if (tmp >= 5)
    ans += 0.001;
  if (tmp <= -5)
    ans -= 0.001;
  return ans;
}

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

void solve() {
  using namespace std;
  double x = (c * e - b * f) / (a * e - b * d);
  double y = (c * d - a * f) / (b * d - a * e);
  cout << setprecision(3) << fixed << halfadjust(x) << ' ';
  cout << halfadjust(y) << endl;
  cout << setprecision(6);
}

int main() {
  while (true) {
    std::cin >> a >> b >> c >> d >> e >> f;
    if (!a && !b && !c && !d && !e && !f)
      break;
    solve();
  }
  return 0;
}

Fixed submission:
#include <iomanip>
#include <iostream>

double halfadjust(double x) {
  int tmp = (x * 10000);
  tmp = tmp % 10;
  double ans = static_cast<double>(static_cast<int>(x * 1000));
  ans = ans / 1000;
  if (tmp >= 5)
    ans += 0.001;
  if (tmp <= -5)
    ans -= 0.001;
  return ans;
}

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

void solve() {
  using namespace std;
  double x = (c * e - b * f) / (a * e - b * d);
  double y = (c * d - a * f) / (b * d - a * e);
  cout << setprecision(3) << fixed << halfadjust(x) << ' ';
  cout << halfadjust(y) << endl;
  cout << setprecision(6);
}

int main() {
  using std::cin;
  while (cin >> a && cin >> b && cin >> c && cin >> d && cin >> e && cin >> f) {
    solve();
  }
  return 0;
}
Problem p00005 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main(void) {
  while (1) {
    ll a, b, A, B;
    cin >> a >> b;
    A = a;
    B = b;
    if (a < b)
      swap(a, b);
    ll r = b;
    while (r) {
      r = a % b;
      a = b;
      b = r;
    }
    cout << a << " " << (A / a) * B << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main(void) {
  ll a, b, A, B;
  while (cin >> a >> b) {
    A = a;
    B = b;
    if (a < b)
      swap(a, b);
    ll r = b;
    while (r) {
      r = a % b;
      a = b;
      b = r;
    }
    cout << a << " " << (A / a) * B << endl;
  }
  return 0;
}
Problem p00005 (C++)

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

long long int GCD(long long int a, long long int b) {
  return (b % a == b) ? a : GCD(b % a, a);
}

long long int LCM(long long int a, long long int b) {
  return (a / GCD(a, b)) * b;
}

int main() {
  long long int a, b;
  while (cin >> a >> b) {
    cout << GCD(a, b) << " " << LCM(a, b) << endl;
  }
  return 0;
}


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

long long int GCD(long long int a, long long int b) {
  return (b % a == 0) ? a : GCD(b % a, a);
}

long long int LCM(long long int a, long long int b) {
  return (a / GCD(a, b)) * b;
}

int main() {
  long long int a, b;
  while (cin >> a >> b) {
    cout << GCD(a, b) << " " << LCM(a, b) << endl;
  }
  return 0;
}
Problem p00005 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  long long int a, b, x, y, z;

  while (cin >> a >> b, a, b) {
    x = max(a, b);
    y = min(a, b);
    while (1) {
      if (y == 0)
        break;
      z = x % y;
      x = y;
      y = z;
    }

    cout << x << ' ' << a * b / x << endl;
  }

  return 0;
}

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

int main() {
  long long int a, b, x, y, z;

  while (cin >> a >> b) {
    x = max(a, b);
    y = min(a, b);
    while (1) {
      if (y == 0)
        break;
      z = x % y;
      x = y;
      y = z;
    }

    cout << x << ' ' << a * b / x << endl;
  }

  return 0;
}
Problem p00005 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  long long int a, b, t, aa, bb;

  while (1) {
    cin >> a;
    if (a == 0)
      break;
    cin >> b;

    aa = a;
    bb = b;

    while (1) {
      if (b == 0)
        break;

      t = b;
      b = a % b;
      a = t;
    }
    cout << a << " " << aa * bb / a << endl;
  }
  return 0;
}

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

int main() {
  long long int a, b, t, aa, bb;

  while (1) {
    cin >> a;
    if (cin.eof())
      break;
    cin >> b;

    aa = a;
    bb = b;

    while (1) {
      if (b == 0)
        break;

      t = b;
      b = a % b;
      a = t;
    }
    cout << a << " " << aa * bb / a << endl;
  }
  return 0;
}