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

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

#define INF -100000000

int main() {

  int dataSets;

  while (true) {
    vector<int> a;
    cin >> dataSets;
    if (dataSets == 0) {
      break;
    }
    for (int i = 0; i < dataSets; i++) {
      int tmpa;
      cin >> tmpa;
      a.push_back(tmpa);
    }

    int tmax = INF;
    // i?????§????????§?????????????????????
    vector<int> tmpMax(dataSets + 1, 0);
    tmpMax[0] = 0;
    for (int i = 1; i < dataSets + 1; i++) {
      tmpMax[i] += tmpMax[i - 1] + a[i - 1];
    }

    for (int i = 0; i < dataSets; i++) {
      for (int j = i + 1; j < dataSets + 1; j++) {
        tmax = max(tmax, tmpMax[j] - tmpMax[i]);
      }
    }

    // for(int i=0;i<dataSets+1;i++){
    // for(int j=i;j<dataSets;j++){
    // tmax = max(tmax, tmpMax[j+1] - tmpMax[i]);
    // }
    // }

    cout << tmax << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {

  int dataSets;

  while (true) {
    vector<int> a;
    cin >> dataSets;
    if (dataSets == 0) {
      break;
    }
    for (int i = 0; i < dataSets; i++) {
      int tmpa;
      cin >> tmpa;
      a.push_back(tmpa);
      // cout << "a[" << i << "]: " << a[i] << endl;
    }

    int max = 0;

    for (int i = 0; i < dataSets; i++) {
      // i+1?????£?¶?
      for (int j = 0; j < dataSets - i; j++) {
        int tmp = 0;
        for (int k = 0; k < i + 1; k++) {
          tmp += a[j + k];
          // cout << "(i,j,k): " << i << "," << j << "," << k << "  " << "a[" <<
          // j+k << "]   max:" << max << endl;
        }
        if (tmp > max) {
          max = tmp;
        }
      }
    }

    cout << max << endl;
  }

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

#include <stdio.h>
int main() {
  int n, a[5000];
  while (1) {
    int max = -100001;
    scanf("%d", &n);
    if (n == 0)
      break;
    for (int i = 0; i < n; i++)
      scanf("%d", &a[i]);
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = i; j < n; j++) {
        sum += a[j];
        if (max < sum)
          max = sum;
      }
    }
    printf("%d\\n", max);
  }
  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>
int main() {
  int n, a[5000];
  while (scanf("%d", &n) != EOF) {
    int max = -10001;
    scanf("%d", &n);
    if (n == 0)
      break;
    for (int i = 0; i < n; i++)
      scanf("%d", &a[i]);
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = i; j < n; j++) {
        sum += a[j];
        if (max < sum)
          max = sum;
      }
    }
    printf("%d\\n", max);
  }
  return 0;
}
Problem p00022 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>

int main() {
  int data_count = 0;
  while ((std::cin >> data_count) && (data_count > 0)) {
    std::vector<long> dataset;
    for (int i = 0; i < data_count; ++i) {
      int data = 0;
      std::cin >> data;
      dataset.push_back(data);
    }

    long max_sum = dataset[0];
    for (int i = 0; i < data_count; ++i) {
      long current_sum = 0;
      long max_current_sum = dataset[i];
      for (int j = i; j < data_count; ++j) {
        current_sum += dataset[j];
        if (max_current_sum < current_sum) {
          max_current_sum = current_sum;
        }
      }
      if (max_sum < max_current_sum) {
        max_sum = max_current_sum;
      }
    }
    std::cout << max_sum << std::endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

int main() {
  int data_count = 0;
  while ((std::cin >> data_count) && (data_count > 0)) {
    std::vector<long> dataset;
    for (int i = 0; i < data_count; ++i) {
      int data = 0;
      std::cin >> data;
      dataset.push_back(data);
    }

    long max_sum = dataset[0];
    for (int i = 0; i < data_count - 1; ++i) {
      for (int j = i + 1; j < data_count; ++j) {
        max_sum = std::max(max_sum, std::accumulate(dataset.begin() + i,
                                                    dataset.begin() + j, 0L));
      }
    }
    std::cout << max_sum << std::endl;
  }

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

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

int main() {
  int i, j, n, sum, result;
  int a[5000];
  while (cin >> n) {
    if (n == 0) {
      break;
    }
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    result = a[0];
    for (i = 0; i < n; i++) {
      sum = 0;
      for (j = i; j < n; j++) {
        sum += a[j];
        result = max(result, sum);
      }
    }
    cout << result << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int i, j, k, n, sum, result, head, head_before;
  int a[5000];
  while (cin >> n) {
    if (n == 0) {
      break;
    }
    result = 0;
    head = 0;
    head_before = 0;
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (i = 0; i < n; i++) {
      if (head > head_before) {
        head_before = head;
        head += a[i];
        continue;
      }
      for (j = 1; j <= n - i; j++) {
        sum = 0;
        for (k = 0; k < j; k++) {
          sum += a[i + k];
        }
        if (result < sum) {
          result = sum;
        }
      }
      head_before = head;
      head += a[i];
    }
    cout << result << endl;
  }
  return 0;
}
Problem p00022 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  long int n, a[5000], b[5000], i, j, max;

  while (0 <= scanf("%ld", &n)) {
    if (n == 0)
      break;
    max = -2147483647;
    for (i = 0; i < n; i++) {
      scanf("%ld", &a[i]);
      if (max < a[i])
        max = a[i];
    }
    b[0] = a[0];
    for (i = 1; i < n; i++) {
      b[i] = b[i - 1] + a[i];
      if (b[i] > max)
        max = b[i];
    }

    for (i = 1; i < n; i++) {
      for (j = i; j < n; j++) {
        if (max < b[j] - b[i - 1])
          max = b[j] - b[i - 1];
      }
    }

    printf("%ld\\n", max);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int n, a[5000], i, j, k, wa, max;

  while (0 <= scanf("%d", &n)) {
    if (n == 0)
      break;
    max = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }

    for (i = 0; i < n; i++) {
      for (j = i; j < n; j++) {
        wa = 0;
        for (k = i; k <= j; k++) {
          wa += a[k];
        }
        if (max < wa)
          max = wa;
      }
    }
    printf("%d\\n", max);
  }
  return 0;
}
Problem p00022 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n, i, j;
  cin >> n;
  while (n != 0) {
    long long sum[5001] = {};
    int b;
    long long o = 1 << 20;
    o *= -1;
    cin >> sum[1];
    for (i = 2; i <= n; i++) {
      cin >> b;
      sum[i] = sum[i - 1] + b;
      // cout << sum[i] << endl;
    }

    for (i = 0; i <= n; i++) {
      for (j = i + 1; j <= n; j++) {
        o = max(o, sum[j] - sum[i]);
      }
    }
    cout << o << endl;
    cin >> n;
  }
  return 0;
}

Error: MLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, i, j;
  cin >> n;
  while (n != 0) {
    long long sum[5001] = {};
    int b;
    vector<long long> v;
    cin >> sum[1];
    for (i = 2; i <= n; i++) {
      cin >> b;
      sum[i] = sum[i - 1] + b;
      // cout << sum[i] << endl;
    }

    for (i = 0; i <= n; i++) {
      for (j = i + 1; j <= n; j++) {
        v.push_back(sum[j] - sum[i]);
      }
    }
    sort(v.begin(), v.end());
    cout << v[v.size() - 1] << endl;
    cin >> n;
  }
  return 0;
}
Problem p00022 (C++) — buggy submission, verdict: Memory Limit Exceeded

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define EPS 1e-10
#define INF (-(1 << 21))
using namespace std;
typedef long long llong;
int main() {
  int n;
  while (1) {
    cin >> n;
    if (!n)
      break;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
      cin >> a[i];
    int tmp;
    int m = INF;
    for (int i = 0; i < n; i++) {
      tmp = 0;
      for (int j = i; j < n; j++) {
        tmp += a[j];
        m = max(m, tmp);
      }
    }
    cout << m << endl;
  }
  return 0;
}

Error: MLE

Fixed submission:

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define EPS 1e-10
#define INF (-(1 << 21))
using namespace std;
typedef long long llong;
int main() {
  int n;
  while (1) {
    cin >> n;
    if (!n)
      break;
    vector<vector<llong>> v(n, vector<llong>(n));
    vector<int> a(n);
    for (int i = 0; i < n; i++)
      cin >> a[i];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i == j)
          v[i][j] = a[i];
        else
          v[i][j] = INF;
      }
    }
    int max = INF;
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        if (i == j) {
          // cout << v[i][j] << " ";
          continue;
        }
        v[i][j] = v[i][j - 1] + a[j];
        if (max < v[i][j])
          max = v[i][j];
        // cout << v[i][j] << " ";
      }
      // cout << endl;
    }
    cout << max << endl;
  }
  return 0;
}
Problem p00022 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int a[5001], ans = -114514;
    for (int i = 0; i < n; i++)
      cin >> a[i];
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = i; j < n; j++) {
        cnt += a[j];
        if (ans < cnt)
          ans = cnt;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int a[5001], ans = -114514;
    for (int i = 0; i < n; i++)
      cin >> a[i];
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        int cnt = 0;
        for (int k = i; k <= j; k++)
          cnt += a[k];
        if (ans < cnt)
          ans = cnt;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00023 (C++) — buggy submission, verdict: 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;

struct circle {
  double r, x, y;
};

int main() {
  int n;
  scanf("%d", &n);
  for (int x = 0; x < n; ++x) {
    circle a, b;
    scanf("%lf %lf %lf %lf %lf %lf", &a.x, &a.y, &a.r, &b.x, &b.y, &b.r);
    double d = sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
    if (d > a.r + b.r) {
      cout << 0 << endl;
    } else if (a.r + d < b.r) {
      cout << -2 << endl;
    } else if (b.r + d < a.r) {
      cout << 2 << endl;
    } else {
      cout << 1 << endl;
    }
  }
  return 0;
}

Error: TLE

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;

struct circle {
  double r, x, y;
};

int main() {
  int n;
  while (scanf("%d", &n) == 1, n) {
    for (int x = 0; x < n; ++x) {
      circle a, b;
      scanf("%lf %lf %lf %lf %lf %lf", &a.x, &a.y, &a.r, &b.x, &b.y, &b.r);
      double d = sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
      if (d > a.r + b.r) {
        cout << 0 << endl;
      } else if (a.r + d < b.r) {
        cout << -2 << endl;
      } else if (b.r + d < a.r) {
        cout << 2 << endl;
      } else {
        cout << 1 << endl;
      }
    }
  }
  return 0;
}
Problem p00023 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <deque>
#include <iostream>

inline double distance(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main() {
  int dataSetNum;
  std::cin >> dataSetNum;

  std::deque<int> number;

  for (int i = 0; i < dataSetNum; ++i) {
    double xa, ya, ra, xb, yb, rb;
    std::cin >> xa >> ya >> ra >> xb >> yb >> rb;
    double dis = distance(xa, ya, xb, yb);
    //"0" if A and B do not overlap
    if (dis > ra + rb)
      number.push_back(0);
    //"2" if B is in A
    else if (dis + rb < ra)
      number.push_back(2);
    //"-2" if A is in B
    else if (dis + ra < rb)
      number.push_back(-2);
    //"1" if circumference of A and B intersect
    else
      number.push_back(1);
  }
  for (int i = 0; i < dataSetNum; ++i) {
    std::cout << number.front() << std::endl;
    number.pop_front();
  }
  return 0;
}

Error: -11

Fixed submission:

#include <array>
#include <cmath>
#include <iostream>
#include <vector>

inline double distance(std::array<double, 2> pa, std::array<double, 2> pb) {
  return sqrt((pa[0] - pb[0]) * (pa[0] - pb[0]) +
              (pa[1] - pb[1]) * (pa[1] - pb[1]));
}

int main() {
  int dataSetNum;
  std::cin >> dataSetNum;
  std::vector<int> number;
  for (int i = 0; i < dataSetNum; ++i) {
    std::array<double, 2> pa[i];
    std::array<double, 2> pb[i];
    double ra[i], rb[i];
    std::cin >> pa[i][0] >> pa[i][1] >> ra[i] >> pb[i][0] >> pb[i][1] >> rb[i];

    double dis = distance(pa[i], pb[i]);
    // if A and B do not overlap
    if (dis > ra[i] + rb[i])
      number[i] = 0;
    // if B is in A
    else if (ra[i] > rb[i] && dis + rb[i] <= ra[i])
      number[i] = 2;
    // if A is in B,
    else if (rb[i] > ra[i] && dis + ra[i] <= rb[i])
      number[i] = -2;
    // if circumference of A and B intersect
    else
      number[i] = 1;
  }
  for (int i = 0; i < dataSetNum; ++i)
    std::cout << number[i] << std::endl;
  return 0;
}
Problem p00023 (C++) — buggy submission, verdict: Runtime Error

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

int solve(long double d, long double ra, long double rb) {
  if (ra + rb < d) {
    return 0;
  } else if (ra + d < rb) {
    return -2;
  } else if (rb + d < ra) {
    return 2;
  } else {
    return 1;
  }
  assert(0);
  return -100;
}

int main() {
  long double xa, xb, ya, yb, ra, rb;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    cout << solve(sqrt(pow(ya - yb, 2) + pow(xa - xb, 2)), ra, rb) << endl;
  }
}

Error: 0

Fixed submission:

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

int solve(long double d, long double ra, long double rb) {
  if (ra + rb < d) {
    return 0;
  } else if (ra + rb == d) {
    return 1;
  } else if (ra + d < rb) {
    return -2;
  } else if (rb + d < ra) {
    return 2;
  } else {
    assert(0);
  }
  return -100;
}

int main() {
  long double xa, xb, ya, yb, ra, rb;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    cout << solve(sqrt(pow(ya - yb, 2) + pow(xa - xb, 2)), ra, rb) << endl;
  }
}
Problem p00023 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

#define reps(i, f, n) for (int i = f; i < int(n); i++)
#define rep(i, n) reps(i, 0, n)

#define X real()
#define Y imag()
typedef complex<double> P;

int main() {

  int n;
  cin >> n;
  rep(i, n) {
    double xa, ya, ra, xb, rb, yb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;

    P a = P(xa, ya);
    P b = P(xb, yb);

    double c = abs(a - b);

    if (abs(ra - rb) > c) {
      if (ra > rb)
        puts("2");
      else
        puts("-2");
      continue;
    }
    if (ra + rb < c) {
      puts("0");
      continue;
    }
    puts("1");
  }
}

Error: TLE

Fixed submission:

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

using namespace std;

#define reps(i, f, n) for (int i = f; i < int(n); i++)
#define rep(i, n) reps(i, 0, n)

#define X real()
#define Y imag()
typedef complex<double> P;

int main() {

  while (1) {
    int n;
    cin >> n;

    double xa, ya, ra, xb, rb, yb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;

    P a = P(xa, ya);
    P b = P(xb, yb);

    double c = abs(a - b);

    if (c <= ra && c <= rb) {
      if (ra > rb)
        puts("2");
      else
        puts("-2");
      continue;
    }
    if (ra + rb < c) {
      puts("0");
      continue;
    }
    puts("1");
  }
}
Problem p00024 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main(void) {
  int c, n;
  double v, y;
  while (cin >> v) {
    y = 4.9 * ((v * v) / (9.8 * 9.8));
    n = 1;
    while (1) {
      if (y < 5 * n - 5)
        break;
      n++;
    }
    cout << n << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  int c, n;
  double v, y;
  while (cin >> v, v != '\\0') {
    y = 4.9 * ((v * v) / (9.8 * 9.8));
    n = 1;
    while (1) {
      if (y < 5 * n - 5)
        break;
      n++;
    }
    cout << n << endl;
  }
}
Problem p00024 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  double v, y;
  int n;

  while (cin >> v) {
    y = (v * v) / 19.6;
    n = y / 5 + 2;
    cout << n << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  double v, y;
  int n;

  while (1) {
    cin >> v;
    y = (v * v) / 19.6;
    n = y / 5 + 2;
    cout << n;
  }

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

#include "bits/stdc++.h"
using namespace std;
int main() {
  double v;
  while (cin >> v) {
    int N = 0;
    double V = 0;
    do {
      N++;
      double h = 5 * N - 5;
      V = 9.8 * pow(h / 4.9, 0.5);
    } while (V < v);
    cout << N << endl;
  }
}

Error: TLE

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
int main() {
  double v;
  while (cin >> v, v) {
    int N = 0;
    double V = 0;
    do {
      N++;
      double h = 5 * N - 5;
      V = 9.8 * pow(h / 4.9, 0.5);
    } while (V < v);
    cout << N << endl;
  }
}
Problem p00024 (C++) — buggy submission, verdict: Time Limit Exceeded

// Physical Experiments

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

int main(void) {
  double v;
  int n;

  while (scanf("%lf", &v) != EOF) {
    //??°?????????????¨??????????
    n = (int)(v * v / 98.0 + 1.0) + 1;

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

  return 0;
}

Error: TLE

Fixed submission:

// Weight

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

bool g[65];

//?????????????????£??°??????????????°?????°??????
int count_bits(unsigned x) {
  int count = 0;
  while (x) {
    if (x & 1U)
      count++;
    x >>= 1;
  }
  return count;
}

// unsinged??????bit??°?????????
int int_bit(void) { return count_bits(~0U); }
//??£??°?????????????????§?????????????????????????????¨??????????°??????????????????????????´?????????????
void createArray(unsigned x) {
  int n = int_bit();
  for (int i = 0; i < n; i++) {
    if ((x >> i) & 1U)
      g[i] = true;
  }
}

int main(void) {

  int i = 9;
  unsigned int x;
  int dp[10][10]; // i?????????????????????????????????weight
  // Dp??§???

  while ((scanf("%d", &x)) != EOF) {
    for (int i = 0; i < 65; i++)
      g[i] = false;
    createArray(x);

    // flag????????£???????????????????°???????????????¨???????????????
    for (int i = 0, j = 0; i < 10; i++) {
      if (g[i]) {
        if (j)
          printf(" ");
        printf("%d", (int)pow(2.0, (double)i));
        j++;
      }
    }
    putchar('\\n');
  }

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

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  double v, y, t;
  int n;
  while (cin >> v) {
    t = (v / 9.8);
    y = 4.9 * (t * t);
    for (int i = 1; i <= 10000; i++) {
      n = 5 * i - 5;
      if ((int)y < n) {
        cout << i << endl;
        break;
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
  string str;
  int str_size;
  while (getline(cin, str)) {
    str_size = str.size();
    while (1) {
      for (int i = 0; i < str_size; i++) {
        if (str[i] == 'z')
          str[i] = 'a';
        else if (str[i] != '.' && str[i] != ' ')
          str[i]++;
      }
      if (str.find("the") != -1)
        break;
      if (str.find("that") != -1)
        break;
      if (str.find("this") != -1)
        break;
    }
    cout << str << endl;
  }
}
Problem p00024 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <list>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

int main() {
  int mod = 1000000007;
  int n;
  int ans;
  double v;
  while (scanf("%lf", &v) != EOF) {
    double t = v / 9.8;
    double y = t * t * 4.9;
    // int n=int(floor((y+5.0)/5.0));
    int tmp;
    for (int j = 0;; j++) {
      if ((j * 5 - 5) * 1.0 >= y) {
        tmp = j;
        break;
      }
    }
    printf("%d\\n", tmp);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <list>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

int main() {
  int mod = 1000000007;
  int n;
  int ans;
  double v;
  while (scanf("%lf", &v) != EOF) {
    for (int i = 0;; i++) {
      double t = v / 9.8;
      double y = t * t * 4.9;
      n = (int)floor((y + 5.0) / 5.0);
      int tmp;
      for (int j = 1;; j++) {
        if (j * 5 - 5 >= y) {
          tmp = j;
          break;
        }
      }
      printf("%d\\n", tmp);
    }
  }
  return 0;
}
Problem p00024 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  double v, t, h;
  int ans;
  while (cin >> v) {
    t = v / 9.8;
    h = 4.9 * t * t;
    for (int i = 1; i < 100000; i++) {
      if (h < 5 * i - 5) {
        ans = i;
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  while (1) {
    double v, t, h;
    int ans;
    cin >> v;
    t = v / 9.8;
    h = 4.9 * t * t;
    for (int i = 1; i < 100000; i++) {
      if (h < 5 * i - 5) {
        ans = i;
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00024 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main(void) {
  double N;
  double v;
  while (scanf("%lf", &v) != EOF) {
    N = v * v / (10.0 * 9.8) + 1.0;
    printf("%d\\n", (int)(N) + 1);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  double N;
  double v;
  while (scanf("%lf", &v)) {
    // 1/2*v^2=g*5(N-1)
    //??????????????§?????????????????¨?????????????????????
    N = v * v / (10.0 * 9.8) + 1.0;
    printf("%d\\n", (int)(N) + 1);
  }
  return 0;
}