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

#include <stdio.h>

int main() {
  int l, i = 0;
  double m, n;
  while (scanf("%d,%lf,%lf", &l, &m, &n) != EOF) {
    if (25.0 <= m / (n * n)) {
      printf("%d\\n", l);
      i++;
    }
  }
  if (i == 0)
    printf("????????????\\n");
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int l, i = 0;
  double m, n;
  while (scanf("%d,%lf,%lf", &l, &m, &n) != NULL) {
    if (25.0 <= m / (n * n)) {
      printf("%d\\n", l);
      i++;
    }
  }
  if (i == 0)
    printf("????????????\\n");
  return 0;
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

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

struct data {
  int number;
  double weight;
  double tall;
};

int main() {
  data dt;
  while (scanf("%d,%lf,%lf", &dt.number, &dt.weight, &dt.tall) != EOF) {
    if (dt.weight / pow(dt.tall, 2) >= 25)
      cout << dt.number << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

struct data {
  int number;
  double weight;
  double tall;
};

int main() {
  data dt;
  while (1) {
    scanf("%d,%lf,%lf", &dt.number, &dt.weight, &dt.tall);
    if (!dt.number)
      break;
    if (dt.weight / pow(dt.tall, 2) >= 25)
      cout << dt.number << endl;
  }
  return 0;
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (long long int i = (a); i < (b); i++)
#define REP(i, n) for (long long int i = 0; i < (n); i++)
#define ALL(s) (s).begin(), (s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main() {
  int n, c = 0;
  double l, m;
  vector<ll> vi;
  while (scanf("%d,%lf,%lf", &n, &l, &m) != EOF) {
    if (l / powl(m, 2) >= 25) {
      vi.push_back(n);
      c++;
    }
  }
  if (c == 0) {
    cout << "????????????\\n";
  } else {
    REP(i, c) { cout << vi[i] << "\\n"; }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (long long int i = (a); i < (b); i++)
#define REP(i, n) for (long long int i = 0; i < (n); i++)
#define ALL(s) (s).begin(), (s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main() {
  int n, c = 0;
  double l, m;
  vector<ll> vi;
  while (scanf("%d,%lf,%lf", &n, &l, &m)) {
    if (l / powl(m, 2) >= 25) {
      vi.push_back(n);
    }
  }
  if (c == 0) {
    cout << "????????????\\n";
  } else {
    REP(i, c) { cout << vi[i] << "\\n"; }
  }
  return 0;
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

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

    double w, h;
    scanf(",%lf,%lf", &w, &h);
    // cin>>n>>w>>h;
    double bmi = w / (h * h);
    if (bmi >= 25.0)
      cout << n << endl;
  }
}

Error: TLE

Fixed submission:

#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int main(void) {
  while (1) {
    int n;
    double w, h;
    scanf("%d,%lf,%lf", &n, &w, &h);
    // cin>>n>>w>>h;
    double bmi = w / (h * h);
    if (bmi >= 25.0)
      cout << n << endl;
  }
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int id;
  double w, h;
  while (scanf("%d,%lf,%lf", &id, &w, &h) != EOF) {
    double bmi = w / (h * h);
    if (bmi >= 25.0) {
      cout << id << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int id;
  double w, h;
  while (scanf("%d,%lf,%lf", &id, &w, &h), id) {
    double bmi = w / (h * h);
    if (bmi >= 25.0) {
      cout << id << endl;
    }
  }
  return 0;
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <stdio.h>
using namespace std;
double BMI(double Kg, double m) {
  double bmi;
  bmi = Kg / (m * m);
  return bmi;
}

int main() {
  double Kg, m;
  int student;
  while (scanf("%d,%lf,%lf", &student, &Kg, &m) != EOF) {
    if (BMI(Kg, m) >= 25) {
      cout << student << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;
double BMI(double Kg, double m) {
  double bmi;
  bmi = Kg / (m * m);
  return bmi;
}

int main() {
  double Kg, m;
  int student;
  while (scanf("%d,%lf,%lf", &student, &Kg, &m)) {
    if (BMI(Kg, m) >= 25) {
      cout << student << endl;
    }
  }
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  double kg, m;

  while (scanf("%d, %lf,%lf", &n, &kg, &m) != EOF) {
    if (kg / (m * m) >= 25) {
      cout << n << endl;
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  double kg, m;

  while (scanf("%d, %lf,%lf", &n, &kg, &m)) {
    if (kg / (m * m) >= 25) {
      cout << n << endl;
    }
  }
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int id;
  double h, w;
  while (scanf("%d,%lf,%lf", &id, &w, &h) != EOF) {
    double b = (double)w / (h * h);
    if (b >= 25.0)
      cout << id << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int id;
  double h, w;
  while (scanf("%d,%lf,%lf", &id, &w, &h)) {
    double b = (double)w / (h * h);
    if (b >= 25.0)
      cout << id << endl;
  }

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

#include <cstdio>
using namespace std;

int main() {
  int n;
  double wei, hei;
  while (scanf("%d,%lf,%lf", &n, &wei, &hei) == 3) {
    double bmi = wei / (hei * hei);
    if (bmi >= 25.0) {
      printf("%d\\n", n);
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;

int main() {
  int n;
  double wei, hei;
  while (scanf("%d,%lf,%lf", &n, &wei, &hei)) {
    double bmi = wei / (hei * hei);
    printf("bmi:%f\\n", bmi);
    if (bmi >= 25.0) {
      printf("%d\\n", n);
    }
  }
  return 0;
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int num;
  double tai, sint;
  char d;
  while (scanf("%d,%lf,%lf", &num, &tai, &sint) != EOF) {
    // cout<<tai/sint*sint<<endl;
    if (tai / (sint * sint) >= 25)
      cout << num << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int num;
  double tai, sint;
  char d;
  while (scanf("%d,%lf,%lf", &num, &tai, &sint) != '\\0') {
    // cout<<tai/sint*sint<<endl;
    if (tai / (sint * sint) >= 25)
      cout << num << endl;
  }
}
Problem p00075 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>

using namespace std;
int num, i = 0;
double m, kg;
int main(void) {
  while (~scanf("%d,%lf,%lf", &num, &kg, &m)) {
    if (kg / (pow(m, 2)) >= 25)
      printf("%d\\n", num);
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>

using namespace std;
int num[100000], i = 0;
double m[100000], kg[100000];
int main(void) {
  while (~scanf("%d,%f,%f", num[i], kg[i], m[i])) {
    i++;
  }
  for (int a = 0; a < i; a++) {
    if (kg[i] / pow(m[i], 2) >= 25)
      printf("%d\\n", num[i]);
  }
  return 0;
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, s, n) for (int i = s; i < n; i++)
#define ALL(x) x.begin(), x.end()
#define pb push_back
#define foreach(it, con) for (auto it = con.begin(); it != con.end(); it++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
  int id;
  float m, h;
  while (scanf("%d,%f,%f", &id, &m, &h) + 1) {
    if (m / (h * h) >= 25.0) {
      cout << id << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, s, n) for (int i = s; i < n; i++)
#define ALL(x) x.begin(), x.end()
#define pb push_back
#define foreach(it, con) for (auto it = con.begin(); it != con.end(); it++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

struct Person {
  Person(int _id, int _m, int _h) : h(_h), m(_m), id(_id) {}
  int id;
  float m;
  float h;
  float bmi() { return m / h * h; }
};

int main() {
  int n;
  while (cin >> n, n) {
    rep(i, n) {
      int id;
      float m, h;
      cin >> id >> m >> h;
      Person p(id, m, h);
      if (p.bmi() >= 25.0) {
        cout << id << endl;
      }
    }
  }
  return 0;
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

void solve() {
  int Num = 0;
  double mass = 0;
  double height = 0;
  while (~scanf("%d,%lf,%lf/n", &Num, &mass, &height)) {
    if (mass / (height * height) >= 25.0) {
      cout << Num << endl;
    }
  }
}

int main() {
  solve();
  return (0);
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

void solve() {
  int Num = 0;
  double mass = 0;
  double height = 0;
  bool flag = false;
  while (scanf("%d,%lf,%lf", &Num, &mass, &height)) {
    if (mass / height / height >= 25) {
      cout << Num << endl;
      flag = true;
    }
  }
  if (!flag) {
    cout << "ツ該ツ督鳴づ按つオ" << endl;
  }
}

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

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

using namespace std;

double angle(int n);
double X(int n);
double Y(int n);

double angle(int n) {
  if (n == 1)
    return 0;
  else
    return (angle(n - 1) + atan(1 / sqrt((double)(n - 1))));
}

double X(int n) { return (sqrt((double)n) * cos(angle(n))); }

double Y(int n) { return (sqrt((double)n) * sin(angle(n))); }

int main() {
  int n;
  while (cin >> n, n != -1) {
    printf("%.2f\\n%.2f\\n", X(n), Y(n));
  }
  return 0;
}

Error: TLE

Fixed submission:

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

double R(int n);
double X(int n);
double Y(int n);

double R(int n) { return sqrt(X(n) * X(n) + Y(n) * Y(n)); }

double X(int n) {
  if (n == 2)
    return 1.0;
  else
    return (X(n - 1) - Y(n - 1) / R(n - 1));
}

double Y(int n) {
  if (n == 2)
    return 1.0;
  else
    return (Y(n - 1) + X(n - 1) / R(n - 1));
}

int main() {
  int n;
  while (cin >> n, n != -1) {
    printf("%.2f\\n%.2f\\n", X(n), Y(n));
  }
  return 0;
}
Problem p00076 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iomanip>
#include <iostream>

int main() {
  int n;
  while (std::cin >> n, n != -1) {
    double x = 1.0, y = 0.0;

    for (int i = 0; i != n - 1; ++i) {
      double t = sqrt(x * x + y * y);
      double vx = -y / t, vy = x / t;
      x += vx;
      y += vy;
    }

    std::cout << std::fixed << std::setprecision(2);
    std::cout << x << std::endl;
    std::cout << y << std::endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iomanip>
#include <iostream>

int main() {
  int n;
  while (std::cin >> n) {
    double x = 1.0, y = 0.0;

    for (int i = 0; i != n - 1; ++i) {
      double t = sqrt(x * x + y * y);
      double vx = -y / t, vy = x / t;
      x += vx;
      y += vy;
    }

    std::cout << std::fixed << std::setprecision(2);
    std::cout << x << std::endl;
    std::cout << y << std::endl;
  }

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

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

int main() {
  char a;
  while (scanf("%c", &a) != EOF) {
    if (a == '@') {
      int s;
      cin >> a;
      s = a - '0';
      cin >> a;
      for (int i = 0; i < s; i++) {
        cout << a;
      }
    } else if (a == '\\n')
      cout << endl;
    else
      cout << a;
  }
}

Error: TLE

Fixed submission:

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

int main() {
  char a;
  while (scanf("%c", &a)) {
    if (a == '@') {
      int s;
      cin >> a;
      s = a - '0';
      cin >> a;
      for (int i = 0; i < s; i++) {
        cout << a;
      }
    } else if (a == '\\n')
      cout << endl;
    else
      cout << a;
  }
}
Problem p00077 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  while (cin >> s) {
    while (s.find("@") != -1) {
      int x = s.find("@");
      string buf;
      for (int i = 0; i < s[x + 1] - '0'; i++)
        buf += s[x + 2];
      s.replace(x, 3, buf);
    }
    cout << s << endl;
  }
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::replace: __pos (which is 18446744073709551615) > this->size() (which is 18)


Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  while (cin >> s) {
    while (s.find("@") != 0) {
      int x = s.find("@");
      string buf;
      for (int i = 0; i < s[x + 1] - '0'; i++)
        buf += s[x + 2];
      s.replace(x, 3, buf);
    }
    cout << s << endl;
  }
}
Problem p00077 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main() {
  string s;
  while (cin >> s) {
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '@') {
        for (int j = 0; j < (s[i + 1] - '0'); j++) {
          cout << s[i + 2];
        }
        i += 2;
      } else {
        cout << s[i];
      }
    }
    cout << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main() {
  string s;
  while (1) {
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '@') {
        for (int j = 0; j < (s[i + 1] - '0'); j++) {
          cout << s[i + 2];
        }
        i += 2;
      } else {
        cout << s[i];
      }
    }
    cout << endl;
  }
  return 0;
}
Problem p00077 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main() {
  std::ios_base::sync_with_stdio(false);

  string inp, mozi;
  int kai;

  while (cin >> inp) {
    for (int i = 0; i < inp.length(); i++) {
      if (inp[i] == '@') {
        kai = inp[i + 1] - '0';
        mozi = inp[i + 2];
        for (int j = 0; j < kai; j++) {
          cout << mozi;
        }
        i += 2;
      } else
        cout << inp[i];
    }
    cout << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main() {
  std::ios_base::sync_with_stdio(false);

  string inp, mozi;
  int kai;

  while (1) {
    cin >> inp;
    for (int i = 0; i < inp.length(); i++) {
      if (inp[i] == '@') {
        kai = inp[i + 1] - '0';
        mozi = inp[i + 2];
        for (int j = 0; j < kai; j++) {
          cout << mozi;
        }
        i += 2;
      } else
        cout << inp[i];
    }
    cout << endl;
  }

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

#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {
  int i, j, k, l;
  int n;
  char n_tmp;
  char moji;
  char t[1000];

  while (true) {
    if ((moji = cin.get()) == EOF)
      break;
    if (moji == '\\n') {
      cout << '\\n';
      continue;
    }
    if (moji == '@') {
      n_tmp = cin.get();
      n = (int)n_tmp - '0';
      moji = cin.get();
      for (i = 0; i < n; i++) {
        cout << moji;
      }
      continue;
    }
    cout << moji;
  }
  return (0);
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {
  int i, j, k, l;
  int n;
  char n_tmp;
  char moji;
  char t[1000];

  while (true) {
    moji = cin.get();
    if (moji == '@') {
      n_tmp = cin.get();
      n = (int)n_tmp - '0';
      moji = cin.get();
      for (i = 0; i < n; i++) {
        cout << moji;
      }
      continue;
    }
    cout << moji;
  }
  return (0);
}
Problem p00078 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
int cnt, s[16][16], n;
void func(int y, int x) {
  if (cnt == n * n + 1)
    ;
  else if (s[y][x] == 0) {
    s[y++][x++] = cnt++;
    if (y > n)
      y -= n;
    if (x > n)
      x -= n;
    func(y, x);
  } else {
    y++;
    x--;
    if (y > n)
      y -= n;
    if (x < 1)
      x += n;
    func(y, x);
  }
}
int main() {
  while (1) {
    std::cin >> n;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        s[i][j] = 0;
    if (n == 0)
      break;
    cnt = 1;
    func(n / 2 + 2, n / 2 + 1);
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++)
        std::printf("%4d", s[i][j]);
      std::cout << std::endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int cnt, s[20][20], n;
void func(int y, int x) {
  if (cnt == n * n + 1)
    ;
  else if (s[y][x] == 0) {
    s[y++][x++] = cnt++;
    if (y > n)
      y -= n;
    if (x > n)
      x -= n;
    func(y, x);
  } else {
    y++;
    x--;
    if (y > n)
      y -= n;
    if (x < 1)
      x += n;
    func(y, x);
  }
}
int main() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      s[i][j] = 0;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    cnt = 1;
    func(n / 2 + 2, n / 2 + 1);
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++)
        printf("%4d", s[i][j]);
      cout << endl;
    }
  }
  return 0;
}
Problem p00079 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define X first
#define Y second
typedef pair<double, double> Point;

double sq(double a) { return a * a; }

double gD(Point p1, Point p2) {
  return sqrt(sq(p1.X - p2.X) + sq(p1.Y - p2.Y));
}

int main() {
  Point p[123456];
  char ch;
  int n = 0;
  for (int i = 0; cin >> p[i].X >> ch >> p[i].Y; i++)
    n++;
  double S = 0;
  for (int i = 1; i < n - 1; i++) {
    double a = gD(p[0], p[i]), b = gD(p[i], p[i + 1]), c = gD(p[i + 1], p[0]);
    double z = (a + b + c) / 2;
    S += sqrt(z * (z - a) * (z - b) * (z - c));
  }
  printf("%.8f\\n", S);

  return 0;
}

Error: TLE

Fixed submission:

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

#define X first
#define Y second
typedef pair<double, double> Point;

double sq(int a) { return a * a; }

double gD(Point p1, Point p2) {
  return sqrt(sq(p1.X - p2.X) + sq(p1.Y - p2.Y));
}

int main() {
  Point p[123456];
  char ch;
  int n = 0;
  for (int i = 0;; i++) {
    if (cin >> p[i].X >> p[i].Y)
      break;
    n++;
  }
  double S = 0;
  for (int i = 1; i < n - 1; i++) {
    double a = gD(p[0], p[i]), b = gD(p[i], p[i + 1]), c = gD(p[i + 1], p[0]);
    double z = (a + b + c) / 2;
    S += sqrt(z * (z - a) * (z - b) * (z - c));
  }
  printf("%.7f\\n", S);

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


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

int main() {
  int n = 0;
  double x, y;
  complex<double> v[20];
  while (scanf("%lf,%lf", &x, &y) > 0) {
    v[n] = complex<double>(x, y);
    n++;
  }

  double s = 0.0;
  for (int i = 1; (i + 1) < n; i++) {
    s += abs((conj(v[i] - v[0]) * (v[i + 1] - v[0])).imag()) / 2.0;
  }

  cout << s << endl;

  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  int n = 0;
  double x, y;
  complex<double> v[20];
  while (scanf("%lf,%lf", x, y)) {
    v[n] = complex<double>(x, y);
    n++;
  }

  double s = 0.0;
  for (int i = 1; (i + 1) < n; i++) {
    s += abs((conj(v[i] - v[0]) * (v[i + 1] - v[0])).imag()) / 2.0;
  }

  cout << s << endl;

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

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

int main() {

  int n = 0;
  double x[20], y[20], s = 0;

  while (scanf("%lf,%lf", &x[n], &y[n]) + 1)
    ++n;

  for (int i = 0; i < n; ++i) {
    s += x[i] * y[(i + 1) % n] - y[i] * x[(i + 1) % n];
  }
  s /= 2;

  cout << setprecision(20) << (s > 0 ? s : -s) << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  double x[20], y[20], s = 0;
  int i = 0;
  while (scanf("%d,%d", x + i, y + i) + 1) {
    ++i;
  }

  for (int j = 0; j < i - 1; ++j)
    s += x[j] * y[j + 1] - x[j + 1] * y[j];

  s /= 2;
  cout << setprecision(15) << s << endl;
  return 0;
}
Problem p00079 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

typedef complex<double> xy_t;
xy_t P[110];
char c;
double x, y;
int N = 0;
double s = 0.0;

int main() {
  // ??\\???
  while (cin >> x >> c >> y) {
    P[N] = xy_t(x, y);
    N++;
  }
  //?¨????
  for (int i = 0; i + 2 < N; ++i) {
    xy_t a = P[i + 1] - P[0];
    xy_t b = P[i + 2] - P[0];
    s = s + (conj(a) * b).imag() / 2;
  }
  printf("%.6f\\n", abs(s));
}

Error: TLE

Fixed submission:

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

using namespace std;

typedef complex<double> xy_t;
xy_t P[110];
double x, y;
int N = 0;
double s = 0.0;

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