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

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

using namespace std;

int graph[100][100];
int near[100];
bool is_not_use[100];
int n, m;
int l;

void ini() {
  l = 0;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      graph[i][j] = 2147483647;
    }
  }
  for (int i = 0; i < 100; i++) {
    near[i] = 2147483647;
    is_not_use[i] = true;
  }
}

void prim() {
  int v = 0;
  int min_cost = 2147483647 - 1;
  for (int i = 0; i < n; i++) {
    if (min_cost > near[i] && is_not_use[i]) {
      min_cost = near[i];
      v = i;
    }
  }
  is_not_use[v] = false;
  l += min_cost;
  for (int i = 0; i < n; i++) {
    if (near[i] > graph[v][i]) {
      near[i] = graph[v][i];
    }
  }
  bool flag = false;
  for (int i = 0; i < n; i++) {
    if (is_not_use[i])
      flag = true;
  }
  if (flag)
    prim();
}

int main(void) {
  while (1) {
    ini();
    cin >> n;
    if (n == 0)
      break;
    cin >> m;
    for (int i = 0; i < m; i++) {
      int a, b, c;
      scanf("%d,%d,%d", &a, &b, &c);
      graph[a][b] = c;
      graph[b][a] = c;
    }
    is_not_use[0] = false;
    for (int i = 0; i < n; i++) {
      near[i] = graph[0][i];
    }
    prim();
    cout << l / 100 - n + 1 << endl;
  }
}

Error: TLE

Fixed submission:

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

using namespace std;

string bom[8];

class Graph {
public:
  int a;
  int b;
  int ab;
};

bool asc(const Graph &left, const Graph &right) { return left.ab < right.ab; }

int main(void) {
  Graph gr[1000];

  while (1) {
    int n, m;
    cin >> n;
    if (n == 0)
      break;
    cin >> m;
    for (int i = 0; i < m; i++) {
      scanf("%d,%d,%d", &gr[i].a, &gr[i].b, &gr[i].ab);
      if (gr[i].a > gr[i].b)
        swap(gr[i].a, gr[i].b);
      // cin>>gr[i].a>>gr[i].b>>gr[i].ab;
    }
    sort(gr, gr + m, asc);
    /*for(int i=0; i<m; i++){
        cout<<gr[i].a<<" "<<gr[i].b<<" "<<gr[i].ab<<endl;
    }*/
    int check[1000] = {0};
    int dist = 0;
    check[gr[0].a]++;
    check[gr[0].b]++;
    dist += gr[0].ab - 200;
    while (1) {
      int count = 0;
      for (int i = 0; i < m; i++)
        count += check[i];
      if (count == m)
        break;
      for (int i = 0; i < m; i++) {
        if (check[gr[i].a] == 1 && check[gr[i].b] == 0) {
          check[gr[i].b]++;
          dist += gr[i].ab;
          break;
        } else if (check[gr[i].b] == 1 && check[gr[i].a] == 0) {
          check[gr[i].a]++;
          dist += gr[i].ab - 100;
          break;
        }
      }
    }
    cout << dist / 100 << endl;
  }

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int par[10010], rk[10010];
void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rk[i] = 0;
  }
}

int find(int x) {
  if (par[x] == x)
    return x;
  else
    return par[x] = find(par[x]);
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y)
    return;

  if (rk[x] < rk[y])
    par[x] = y;
  else {
    par[y] = x;
    if (rk[x] == rk[y])
      rk[x]++;
  }
}

bool same(int x, int y) { return find(x) == find(y); }

struct edge {
  ll u, v, cost;
};

bool comp(const edge &e1, const edge &e2) { return e1.cost < e2.cost; }

edge es[10010];
int n, m;

ll kruskal() {
  sort(es, es + m, comp);
  init(n);
  ll res = 0;
  for (int i = 0; i < m; i++) {
    edge e = es[i];
    if (!same(e.u, e.v)) {
      unite(e.u, e.v);
      if (e.cost != 0)
        res += (e.cost) / 100 - 1;
    }
  }
  return res;
}

int main() {
  while (cin >> n, n) {
    cin >> m;
    for (int i = 0; i < m; i++) {
      ll a, b, d;
      scanf("%d,%d,%d", &a, &b, &d);
      es[i].u = a, es[i].v = b, es[i].cost = d;
    }
    cout << kruskal() << endl;
  }
  return 0;
}

Error: WA

Fixed submission:


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int par[110], rk[110];
void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rk[i] = 0;
  }
}

int find(int x) {
  if (par[x] == x)
    return x;
  else
    return par[x] = find(par[x]);
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y)
    return;

  if (rk[x] < rk[y])
    par[x] = y;
  else {
    par[y] = x;
    if (rk[x] == rk[y])
      rk[x]++;
  }
}

bool same(int x, int y) { return find(x) == find(y); }

struct edge {
  ll u, v, cost;
};

bool comp(const edge &e1, const edge &e2) { return e1.cost < e2.cost; }

edge es[110];
int n, m;

ll kruskal() {
  sort(es, es + m, comp);
  init(n);
  ll res = 0;
  for (int i = 0; i < m; i++) {
    edge e = es[i];
    if (!same(e.u, e.v)) {
      unite(e.u, e.v);
      res += (e.cost) / 100 - 1;
    }
  }
  return res;
}

int main() {
  while (cin >> n, n) {
    cin >> m;
    for (int i = 0; i < m; i++) {
      ll a, b, d;
      scanf("%d,%d,%d", &a, &b, &d);
      es[i].u = a, es[i].v = b, es[i].cost = d;
    }
    cout << kruskal() << endl;
  }
  return 0;
}
Problem p00072 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>

#define MAX_V 100
#define INF 9999

int prim(void);

int cost[MAX_V][MAX_V]; // cost[u][v]は辺e=(u,v)のコスト(存在しない場合はINF)
int mincost[MAX_V]; // 集合Xからの最小コスト
bool used[MAX_V];   // 頂点iがxに含まれているか
int V;              // 頂点数

using namespace std;

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

  while (1) {
    scanf("%d", &V);
    if (V == 0)
      break;
    scanf("%d", &n);
    for (j = 0; j < V; j++) {
      for (i = 0; i < V; ++i) {
        cost[j][i] = INF;
      }
    }
    for (i = 0; i < n; i++) {
      scanf("%d,%d,%d", &a, &b, &c);
      cost[a][b] = c / 100 - 1;
      cost[b][a] = c / 100 - 1;
    }
    printf("%d\\n", prim());
  }
  return 0;
}

int prim() {

  // 初期化
  for (int i = 0; i < V; ++i) {
    mincost[i] = INF;
    used[i] = false;
  }

  mincost[0] = 0;
  int res = 0;

  while (true) {
    int v = -1;
    // xに属さない頂点のうちxからの辺のコストが最小になる頂点を探す
    for (int u = 0; u < V; u++) {
      if (!used[u] && (v == -1 || mincost[u] < mincost[v]))
        v = u;
    }
    if (v == -1)
      break;

    used[v] = true;    // 頂点vをxに追加
    res += mincost[v]; // 辺のコストを比べる

    for (int u = 0; u < V; u++) {
      mincost[u] = min(mincost[u], cost[v][u]);
    }
  }
  return res;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>

#define MAX_V 100
#define INF 9999

int prim(void);

int cost[MAX_V][MAX_V]; // cost[u][v]は辺e=(u,v)のコスト(存在しない場合はINF)
int mincost[MAX_V]; // 集合Xからの最小コスト
bool used[MAX_V];   // 頂点iがxに含まれているか
int V;              // 頂点数

using namespace std;

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

  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    scanf("%d", &V);
    for (j = 0; j < V; j++) {
      for (i = 0; i < V; ++i) {
        cost[j][i] = INF;
      }
    }
    for (i = 0; i < V; i++) {
      scanf("%d,%d,%d", &a, &b, &c);
      cost[a][b] = c / 100 - 1;
      cost[b][a] = c / 100 - 1;
    }
    printf("%d\\n", prim());
  }
  return 0;
}

int prim() {

  // 初期化
  for (int i = 0; i < V; ++i) {
    mincost[i] = INF;
    used[i] = false;
  }

  mincost[0] = 0;
  int res = 0;

  while (true) {
    int v = -1;
    // xに属さない頂点のうちxからの辺のコストが最小になる頂点を探す
    for (int u = 0; u < V; u++) {
      if (!used[u] && (v == -1 || mincost[u] < mincost[v]))
        v = u;
    }
    if (v == -1)
      break;

    used[v] = true;    // 頂点vをxに追加
    res += mincost[v]; // 辺のコストを比べる

    for (int u = 0; u < V; u++) {
      mincost[u] = min(mincost[u], cost[v][u]);
    }
  }
  return res;
}
Problem p00072 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;
static const int INF = 99999999;
int cost[101][101];
int mincost[101];
bool used[101];
int n;

int prim() {
  for (int i = 0; i < n; ++i) {
    mincost[i] = INF;
    used[i] = false;
  }
  mincost[0] = 0;
  int res = 0;
  while (true) {
    int v = -1;
    for (int i = 0; i < n; ++i) {
      if (!used[i] && (v == -1 || mincost[i] < mincost[v])) {
        v = i;
      }
    }
    if (v == -1) {
      break;
    }
    used[v] = true;
    res += mincost[v];
    for (int i = 0; i < n; ++i) {
      mincost[i] = min(mincost[i], cost[v][i]);
    }
  }
  return (res);
}

void solve() {
  while (cin >> n, n) {
    for (int i = 0; i < 101; ++i) {
      for (int j = 0; j < 101; ++j) {
        cost[i][j] = INF;
      }
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
      int a, b, dist;
      char c;
      cin >> a >> c >> b >> c >> dist;
      cost[a][b] = dist / 100 - 1;
      cost[b][a] = dist / 100 - 1;
    }

    cout << prim() << endl;
  }
}

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

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;
static const int INF = 99999999;
int d[101][101];

void solve() {
  int n;
  while (cin >> n, n) {
    for (int i = 0; i < 101; ++i) {
      for (int j = 0; j < 101; ++j) {
        d[i][j] = INF;
      }
      d[i][i] = 0;
    }
    int m;
    cin >> m;
    for (int i = 0; i < n; ++i) {
      int a, b, dist;
      char c;
      cin >> a >> c >> b >> c >> dist;
      d[a][b] = dist;
      d[b][a] = dist;
    }
    for (int k = 0; k < n; ++k) {
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
    int min_sum_dist = INF;
    for (int i = 0; i < n; ++i) {
      int sum = 0;
      for (int j = 0; j < n; ++j) {
        if (d[i][j] != INF) {
          sum += d[i][j];
        }
      }
      if (min_sum_dist > sum) {
        min_sum_dist = sum;
      }
    }
    cout << min_sum_dist / 100 - 3 << endl;
  }
}

int main() {
  solve();
  return (0);
}
Problem p00072 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <functional>
#include <queue>
#include <vector>
using namespace std;

typedef pair<int, int> Pair;

struct Edge {
  int len;
  int to;
};

int n;
int m;
bool used[10000];
vector<Edge> es[10000];
priority_queue<Pair, vector<Pair>, greater<Pair>> q;

int CalcMSTCost() {
  int ret = 0;

  fill(used, used + n, false);
  q.push(Pair(0, 0));
  while (!q.empty()) {
    Pair p = q.top();
    q.pop();
    int d = p.first;
    int v = p.second;

    if (used[v])
      continue;
    used[v] = true;
    ret += d;
    for (int i = 0; i < es[v].size(); i++) {
      q.push(Pair(es[v][i].len, es[v][i].to));
    }
  }

  return ret;
}

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      return 0;

    for (int i = 0; i < n; i++) {
      es[i].clear();
    }

    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
      int a, b;
      struct Edge e;
      scanf("%d,%d,%d", &a, &b, &e.len);
      e.len -= 100;
      e.to = b;
      es[a].push_back(e);
      e.to = a;
      es[b].push_back(e);
    }

    printf("%d\\n", CalcMSTCost() / 100);
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <functional>
#include <queue>
#include <vector>
using namespace std;

typedef pair<int, int> Pair;

struct Edge {
  int len;
  int to;
};

int n;
int m;
bool used[10000];
vector<Edge> es[10000];
priority_queue<Pair, vector<Pair>, greater<Pair>> q;

int CalcMSTCost() {
  int ret = 0;

  fill(used, used + n, false);
  q.push(Pair(0, 0));
  while (!q.empty()) {
    Pair p = q.top();
    q.pop();
    int d = p.first;
    int v = p.second;

    if (used[v])
      continue;
    used[v] = true;
    ret += d;
    for (int i = 0; i < es[v].size(); i++) {
      q.push(Pair(es[v][i].len, es[v][i].to));
    }
  }

  return ret;
}

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      return 0;

    for (int i = 0; i < n; i++) {
      es[i].clear();
    }

    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
      int a, b;
      struct Edge e;
      scanf("%d,%d,%d", &a, &b, &e.len);
      --a;
      --b;
      e.len -= 100;
      e.to = b;
      es[a].push_back(e);
      e.to = a;
      es[b].push_back(e);
    }

    printf("%d\\n", CalcMSTCost() / 100);
  }
}
Problem p00072 (C++) — buggy submission, verdict: Runtime Error

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

const int MAX_N = 100, MAX_M = MAX_N * MAX_N;

int par[MAX_N];  // e
int rank[MAX_N]; // ØÌ[³

// nvfÅú»
void init_union_find(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rank[i] = 0;
  }
}

// ØÌªðßé
int find_union_find(int x) {
  if (par[x] == x)
    return x;
  else
    return par[x] = find_union_find(par[x]);
}

// xÆyÌ®·éWð¹
void unite_union_find(int x, int y) {
  x = find_union_find(x);
  y = find_union_find(y);
  if (x == y)
    return;

  if (rank[x] < rank[y])
    par[x] = y;
  else {
    par[y] = x;
    if (rank[x] == rank[y])
      rank[x]++;
  }
}

// xÆyª¯¶WÉ®·é©Û©
bool same_union_find(int x, int y) {
  return find_union_find(x) == find_union_find(y);
}

struct edge {
  int u, v, cost;
};

bool comp(const edge &e1, const edge &e2) { return e1.cost < e2.cost; }

// üÍ
int n, m;
edge es[MAX_M];

int kruskal() {
  std::sort(es, es + m, comp);
  init_union_find(n);
  int res = 0;
  for (int i = 0; i < m; i++) {
    edge e = es[i];
    if (!same_union_find(e.u, e.v)) {
      unite_union_find(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}

void solve() { printf("%d\\n", kruskal()); }

int main() {
  while (scanf("%d", &n) && n) {
    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
      int a, b, d;
      scanf("%d,%d,%d", &es[i].u, &es[i].v, &es[i].cost);
      es[i].cost = es[i].cost / 100 - 1;
    }

    solve();
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef struct {
  int cost, v, u, par;
} wa;
wa way[300];
int compare(const wa &a, const wa &b) { return a.cost < b.cost; }
int find(int t) {
  if (way[t].par == t)
    return t;
  else
    return find(way[t].par);
}
int same(int x, int y) { return find(x) == find(y); }
void unite(int x, int y) { way[x].par = find(way[y].par); }
int main() {
  int n, m, ans, x, y, c, num;
  while (cin >> n, n) {
    cin >> m;
    ans = 0;
    num = 0;
    for (int i = 0; i < m; i++) {
      scanf("%d,%d,%d", &x, &y, &c);
      way[i].v = x;
      way[i].u = y;
      way[i].cost = c;
    }
    sort(way, way + m, compare);
    for (int i = 0; i < m; i++)
      way[i].par = i;
    for (int i = 0; i < m; i++) {
      if (!same(way[i].v, way[i].u)) {
        unite(way[i].v, way[i].u);
        num++;
        ans += way[i].cost;
      }
    }

    cout << ans / 100 - num << endl;
  }
  return 0;
}
Problem p00073 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <math.h>
#include <stdio.h>
int main(void) {
  double x, h, c;
  while (1) {
    scanf("%lf %lf", &x, &h);
    if (x == 0.0 && h == 0.0)
      break;
    c = (x / 2.0) * (x / 2.0) + h * h;
    c = sqrt(c);
    c = x * x + x * c / 2.0 * 4.0;
    printf("%lf\\n", c);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <math.h>
#include <stdio.h>
int main(void) {
  double x, h, c;
  while (1) {
    scanf("%f %f", &x, &h);
    if (x == 0.0 && h == 0.0)
      break;
    c = (x / 2.0) * (x / 2.0) + h * h;
    c = sqrt(c);
    c = x * x + x * c / 2.0 * 4.0;
    printf("%f\\n", c);
  }
  return 0;
}
Problem p00073 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  double a, b;
  for (;;) {
    cin >> a >> b;
    if (!a && !b) {
      break;
    }
    printf("%.6lf\\n", a * a + 2 * a * sqrt((a / 2) * (a / 2) + b * b));
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
int main() {
  for (;;) {
    int n, m, sum = 0;
    cin >> n;
    if (!n) {
      break;
    }
    cin >> m;
    vector<pair<int, pair<int, int>>> edge;
    bool done[100] = {false};
    for (int i = 0; i < m; i++) {
      int a, b, cost;
      scanf("%d,%d,%d", &a, &b, &cost);
      edge.push_back(make_pair(cost, make_pair(a, b)));
    }
    sort(edge.begin(), edge.end());
    done[edge[0].second.first] = true;
    done[edge[0].second.second] = true;
    sum += edge[0].first / 100;
    if (!(edge[0].first % 100)) {
      sum--;
    }
    for (int i = 0; i < n - 1; i++) {
      for (int k = 0; k < m; k++) {
        if (done[edge[k].second.first] ^ done[edge[k].second.second]) {
          sum += edge[k].first / 100;
          if (!(edge[k].first % 100)) {
            sum--;
          }
          done[edge[k].second.first] = true;
          done[edge[k].second.second] = true;
          break;
        }
      }
    }
    cout << sum << endl;
  }
  return 0;
}
Problem p00074 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  while (1) {
    int h, m, s;
    cin >> h >> m >> s;
    if (h == -1 && m == -1 && s == -1)
      break;
    int rec = 120 * 60 - (60 * 60 * h + m * 60 + s);
    h = rec / (60 * 60), rec %= 60 * 60;
    m = rec / (60), rec %= 60;
    s = rec;
    printf("%02d:%02d:%02d\\n", h, m, s);
    rec = 3 * (60 * 60 * h + m * 60 + s);
    h = rec / (60 * 60), rec %= 60 * 60;
    m = rec / (60), rec %= 60;
    s = rec;
    printf("%02d:%02d:%02d\\n", h, m, s);
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int h, m, s;
  while (1) {
    cin >> h >> m >> s;
    if (h == -1 && m == -1 && s == -1)
      continue;
    int rec = 120 * 60 - (60 * 60 * h + m * 60 + s);
    h = rec / (60 * 60), rec %= 60 * 60;
    m = rec / (60), rec %= 60;
    s = rec;
    printf("%02d:%02d:%02d\\n", h, m, s);
    rec = 3 * (60 * 60 * h + m * 60 + s);
    h = rec / (60 * 60), rec %= 60 * 60;
    m = rec / (60), rec %= 60;
    s = rec;
    printf("%02d:%02d:%02d\\n", h, m, s);
  }
  return 0;
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {
  int a;
  double b, c;

  while (scanf("%d,%lf,%lf", &a, &b, &c) != EOF) {
    int d = 0;
    d = b / (c * c);
    if (d >= 25.00) {
      cout << a << endl;
    }
  }

  return (0);
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {
  int a;
  double b, c;

  while (scanf("%d,%lf,%lf", &a, &b, &c)) {
    int d = 0;
    d = b / (c * c);
    if (d >= 25.00) {
      cout << a << endl;
    }
  }

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

#include <cstdio>
#include <iostream>

using namespace std;

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

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {

  while (1) {
    int num;
    cin >> num;
    if (cin.eof()) {
      break;
    }

    double w, h;
    cin >> w >> h;

    if (w / h / h >= 25.0) {
      cout << num << endl;
    }
  }
  return 0;
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int s;
  double w, h;
  char t;

  while (cin >> s) {
    cin >> t >> w >> t >> h;

    if (w / (h * h) >= 25)
      cout << s << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int s;
  double w, h;
  char t;

  vector<int> v;
  while (cin >> s) {
    cin >> t >> w >> t >> h;

    if (w / (h * h) >= 25)
      v.push_back(s);
  }

  for (int var : v) {
    cout << var << endl;
  }
  return 0;
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main(void) {
  int ban;
  double tai, sin, BMI;
  while (scanf("%d,%lf,%lf", &ban, &tai, &sin) != EOF) {
    BMI = tai / (sin * sin);
    if (BMI >= 25.0) {
      printf("%d\\n", ban);
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main(void) {
  int ban;
  double tai, sin, BMI;
  while (scanf("%d %lf %lf", &ban, &tai, &sin) != EOF) {
    BMI = tai / (sin * sin);
    if (BMI >= 25.0) {
      printf("%d\\n", ban);
    }
  }
  return 0;
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int a = 0;
  double b, c;
  while (~scanf("%d,%lf,%lf", &a, &b, &c)) {
    if (b / (c * c) >= 25)
      cout << a << endl;
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int a = 0;
  double b, c;
  while (scanf("%d,%lf,%lf", &a, &b, &c)) {
    if (b / (c * c) >= 25)
      cout << a << endl;
  }
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define r(i, a, n) for (int i = a; i < n; i++)
using namespace std;
int main() {
  int a;
  double b, c;
  while (scanf("%d,%lf,%lf", &a, &b, &c) != EOF) {
    if (25 <= (b / (c * c)))
      cout << a << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define r(i, a, n) for (int i = a; i < n; i++)
using namespace std;
int main() {
  int a;
  double b, c;
  while (scanf("%d,%lf,%lf", &a, &b, &c)) {
    if (25 <= (b / (c * c)))
      cout << a << endl;
  }
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<int> ans;
  int a;
  float b, c;
  while (scanf("%d,%f,%f", &a, &b, &c) != EOF) {
    if ((b / (c * c)) >= 25) {
      ans.push_back(a);
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<int> ans;
  int a;
  double b, c;
  while (scanf("%d,%f,%f", &a, &b, &c)) {
    if ((int)(c / (b * b)) >= 25)
      ans.push_back(a);
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
Problem p00075 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

void solve() {
  int num;
  double weight, height;
  vector<int> Vec;
  while (scanf("%d,%lf,%lf", &num, &weight, &height) != EOF) {
    if (weight / height / height >= 25) {
      Vec.push_back(num);
    }
  }
  if (Vec.size()) {
    for (int i = 0; i < Vec.size(); ++i) {
      cout << Vec[i] << endl;
    }
  } else {
    cout << "該当なし" << endl;
  }
}

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

Error: TLE

Fixed submission:

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

using namespace std;

void solve() {
  int num;
  double weight, height;
  vector<int> Vec;
  while (scanf("%d,%lf,%lf", &num, &weight, &height)) {
    if (weight / height / height >= 25) {
      Vec.push_back(num);
    }
  }
  for (int i = 0; i < Vec.size(); ++i) {
    cout << Vec[i] << endl;
  }
}

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