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

#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, c)                                                              \\
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()

typedef complex<double> P;
const double EPS = 1e-8;

int main() {
  int n;
  while (cin >> n, n) {
    vector<P> v;
    REP(i, n) {
      double x, y;
      cin >> x >> y;
      v.push_back(P(x, y));
    }
    int ans = 1;
    REP(i, n - 1) {
      for (int j = i + 1; j < n; j++) {
        P m = (v[i] + v[j]) * P(0.5, 0);
        // cout << "m "<< m << endl;
        P a = v[i] - v[j];
        double dis = abs(a);
        if (1 - dis * dis / 4 < 0)
          continue;
        double d = sqrt(1 - dis * dis / 4);
        int hoge[] = {1, -1};
        REP(k, 2) {
          P un = (a * P(0, hoge[k])) / dis;
          P o1 = m + un * d;
          // cout << o1 << endl;
          int sum = 0;
          REP(l, n) {
            if (norm(v[l] - o1) < 1 + EPS)
              sum++;
          }
          ans = max(ans, sum);
        }
      }
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, c)                                                              \\
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()

typedef complex<double> P;
const double EPS = 1e-8;

int main() {
  int n;
  while (cin >> n, n) {
    vector<P> v;
    REP(i, n) {
      double x, y;
      cin >> x >> y;
      v.push_back(P(x, y));
    }
    int ans = 0;
    REP(i, n - 1) {
      for (int j = i + 1; j < n; j++) {
        P m = (v[i] + v[2]) * P(0.5, 0);
        P a = v[i] - v[j];
        double dis = abs(a);
        double d = sqrt(1 - dis * dis / 4);
        int hoge[] = {1, -1};
        REP(k, 2) {
          P un = (a * P(0, hoge[k])) / dis;
          P o1 = m + un * d;
          int sum = 0;
          REP(l, n) {
            if (norm(v[l] - o1) < 1 + EPS)
              sum++;
          }
          ans = max(ans, sum);
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p00713 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef complex<double> C;

int solve(int N, vector<double> &x, vector<double> &y) {
  vector<C> point(N);

  for (int j = 0; j < N; ++j) {
    point[j] = C(x[j], y[j]);
  }

  int ret = 1;

  for (int j = 0; j < N; ++j) {
    for (int k = j + 1; k < N; ++k) {
      C mid = (point[j] + point[k]) * 0.5;

      C normal = (point[j] - point[k]) * C(0, 1);
      normal /= abs(point[j] - point[k]);

      double a = sqrt(1 - norm(mid - point[j]));

      C centre1 = mid + a * normal;
      int count = 0;
      for (int l = 0; l < N; ++l) {
        if (abs(centre1 - point[l]) < 1.0 + 1e-9) {
          ++count;
        }
      }
      ret = max(ret, count);

      C centre2 = mid - a * normal;
      count = 0;
      for (int l = 0; l < N; ++l) {
        if (abs(centre2 - point[l]) < 1.0 + 1e-9) {
          ++count;
        }
      }
      ret = max(ret, count);
    }
  }

  return ret;
}

int main() {
  int N;
  vector<double> x, y;

  while (true) {
    cin >> N;
    if (N == 0)
      break;

    x.resize(N);
    y.resize(N);

    for (int j = 0; j < N; ++j) {
      cin >> x[j] >> y[j];
    }

    cout << solve(N, x, y) << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

typedef complex<double> C;

int solve(int N, vector<double> &x, vector<double> &y) {
  vector<C> point(N);

  for (int j = 0; j < N; ++j) {
    point[j] = C(x[j], y[j]);
  }

  int ret = 0;

  for (int j = 0; j < N; ++j) {
    for (int k = 0; k < N; ++k) {
      C mid = (point[j] + point[k]) * 0.5;

      C normal = (point[j] - point[k]) * C(0, 1);
      normal /= abs(point[j] - point[k]);

      double a = 1 - norm(mid - point[j]);

      C centre1 = mid + a * normal;
      int count = 0;
      for (int l = 0; l < N; ++l) {
        if (abs(centre1 - point[l]) < 1) {
          ++count;
        }
      }
      ret = max(ret, count);

      C centre2 = mid - a * normal;
      count = 0;
      for (int l = 0; l < N; ++l) {
        if (abs(centre2 - point[l]) < 1.0001) {
          ++count;
        }
      }
      ret = max(ret, count);
    }
  }

  return ret;
}

int main() {
  int N;
  vector<double> x, y;

  while (true) {
    cin >> N;
    if (N == 0)
      break;

    x.resize(N);
    y.resize(N);

    for (int j = 0; j < N; ++j) {
      cin >> x[j] >> y[j];
    }

    cout << solve(N, x, y) << endl;
  }

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

#include <complex>
#include <iostream>
using namespace std;
typedef complex<double> P;

int n;
double x[300], y[300];

int main() {
  while (cin >> n && n) {
    for (int i = 0; i < n; ++i) {
      cin >> x[i] >> y[i];
    }
    int ret = 1;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == j)
          continue;
        P a = P(x[i], y[i]);
        P b = P(x[j], y[j]);
        P m = (a + b) / 2.0;
        double h = sqrt(1.0 - norm(a - m));
        P u = (a - b) / abs(a - b);
        u = P(-u.imag(), u.real());
        P c = (a + b) / 2.0 + u * h;
        int cnt = 0;
        for (int k = 0; k < n; ++k) {
          P t(x[k], y[k]);
          if (norm(c - t) < 1.0 + 1e-8) {
            cnt++;
          }
        }
        ret = max(ret, cnt);
      }
    }
    cout << ret << endl;
  }
  return 0;
}

Error: MLE

Fixed submission:

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  double x, y;
  while (cin >> n && n) {
    vector<double> xs, ys;
    for (int i = 0; i < n; ++i) {
      cin >> x >> y;
      xs.push_back(x);
      ys.push_back(y);
    }
    vector<double> cxs, cys;
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        cxs.push_back((xs[i] + xs[j]) / 2.0);
        cys.push_back((ys[i] + ys[j]) / 2.0);
        for (int k = j + 1; k < n; ++k) {
          cxs.push_back((xs[i] + xs[j] + xs[k]) / 3.0);
          cys.push_back((ys[i] + ys[j] + ys[k]) / 3.0);
        }
      }
    }
    int ret = 1;
    for (int i = 0; i < (int)cxs.size(); ++i) {
      double cx = cxs[i], cy = cys[i];
      int cnt = 0;
      for (int j = 0; j < n; ++j) {
        if ((xs[j] - cx) * (xs[j] - cx) + (ys[j] - cy) * (ys[j] - cy) <
            1.0 + 1e-8) {
          cnt++;
        }
      }
      ret = max(ret, cnt);
    }
    cout << ret << endl;
  }
  return 0;
}
Problem p00713 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef complex<double> p;
const double eps = 1e-9;

int n;
p ps[300];

int main() {
  while (cin >> n, n != 0) {
    for (int i = 0; i < n; i++) {
      double x, y;
      cin >> x >> y;
      ps[i] = p(x, y);
    }

    int ans = 1;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (!(norm(ps[i] - ps[j]) < 4.0))
          continue;
        p v = ps[i] - ps[j], ve = v / abs(v);
        double l = sqrt(1 - norm(v) * 0.25);
        p vn1 = ve * p(0, 1) * l, vn2 = ve * p(0, -1) * l;
        p c1 = ps[j] + v * 0.5 + vn1, c2 = ps[j] + v * 0.5 + vn2;
        int count1 = 2, count2 = 2;
        for (int k = 0; k < n; k++) {
          if (k == i || k == j)
            continue;
          if (norm(c1 - ps[k]) < 1.0 + eps)
            count1++;
          if (norm(c2 - ps[k]) < 1.0 + eps)
            count2++;
        }
        ans = max(ans, count1);
        ans = max(ans, count2);
      }
    }

    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

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

typedef complex<double> p;

int n;
p ps[300];

int main() {
  while (cin >> n, n != 0) {
    for (int i = 0; i < n; i++) {
      double x, y;
      cin >> x >> y;
      ps[i] = p(x, y);
    }

    if (n == 1) {
      cout << 1 << endl;
      continue;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        p v = ps[i] - ps[j], ve = v / abs(v);
        double l = sqrt(1 - norm(v) * 0.25);
        p vn1 = ve * p(0, 1) * l, vn2 = ve * p(0, -1) * l;
        p c1 = ps[j] + v * 0.5 + vn1, c2 = ps[j] + v * 0.5 + vn2;
        int count1 = 2, count2 = 2;
        for (int k = 0; k < n; k++) {
          if (k == i || k == j)
            continue;
          if (norm(c1 - ps[k]) <= 1.0)
            count1++;
          if (norm(c2 - ps[k]) <= 1.0)
            count2++;
        }
        ans = max(ans, count1);
        ans = max(ans, count2);
      }
    }

    cout << ans << endl;
  }
}
Problem p00713 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, n) for ((i) = 0; (i) < (int)(n); (i)++)
#define foreach(c, itr)                                                        \\
  for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)

struct point {
  double x, y;
};

int N;
point P[310];

double dist(point A, point B) {
  double dx = A.x - B.x, dy = A.y - B.y;
  return sqrt(dx * dx + dy * dy);
}

int func(void) {
  int i, j, k, ans = 1;

  REP(i, N) REP(j, N) if (i != j && dist(P[i], P[j]) < 2.0) {
    double dx = (P[j].x - P[i].x) / 2.0, dy = (P[j].y - P[i].y) / 2.0;
    double d = sqrt(dx * dx + dy * dy);
    double t = sqrt(1.0 - d * d) / d;
    point O = {P[i].x + dx - t * dy, P[i].y + dy + t * dx};

    int tmp = 0;
    REP(k, N) if (dist(O, P[k]) < 1.00001) tmp++;
    ans = max(ans, tmp);
  }

  return ans;
}

int main(void) {
  int i;

  while (1) {
    cin >> N;
    if (N == 0)
      break;
    REP(i, N) cin >> P[i].x >> P[i].y;
    int ans = func();
    cout << ans << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define FOR(i, k, n) for (int i = (k); i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define FORIT(i, c)                                                            \\
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const double EPS = 1e-8;
typedef pair<double, double> P;

inline double dist(P p, P q) {
  return ((p.first - q.first) * (p.first - q.first) +
          (p.second - q.second) * (p.second - q.second));
}

int main() {
  int N;
  double sign[2] = {+1, -1};
  P p[301];
  while (scanf("%d", &N) != EOF) {
    if (N == 0)
      break;
    REP(i, N) scanf("%lf %lf", &p[i].first, &p[i].second);
    int ans = 1;
    REP(i, N) {
      FOR(j, i + 1, N) {
        double dst = dist(p[i], p[j]);
        if (dst > 4.0)
          continue;
        P v((p[j].first - p[i].first) / dst, (p[j].second - p[i].second) / dst);
        P m((p[j].first + p[i].first) / 2.0, (p[j].second + p[i].second) / 2.0);
        double lth = sqrt(1.0 - dst * dst / 4.0);
        REP(k, 2) {
          double cx = m.first + sign[k] * v.first * lth;
          double cy = m.second - sign[k] * v.second * lth;
          P center(cx, cy);
          int count = 0;
          REP(l, N) {
            if (l == i || l == j || dist(center, p[l]) < 1) {
              count++;
            }
            if (N - l - 1 + count < ans)
              break;
          }
          if (ans < count)
            ans = count;
        }
      }
    }
    printf("%d\\n", ans);
  }
  return 0;
}
Problem p00713 (C++) — buggy submission, verdict: Time Limit Exceeded

//???????????????????????????,
//?????????????????????????????°????????????????????????????????????????????????2???????????¨???????????£?????\\????????¨?????§????????????
//?????£???,
//2??????????????????1?????????????????????????????????????????°??????????????????????£????,
//O(N^2)????????????????????????, ??¨?????§O(N^3)????????§?§£?????????
#include <complex>
#include <iostream>
#include <vector>
using namespace std;
typedef complex<double> Point;

int n;
double x[300], y[300];
vector<Point> points; //????£???????

int main() {
  while (cin >> n) {
    if (n == 0)
      break;
    for (int i = 0; i < n; i++)
      cin >> x[i] >> y[i];

    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        Point p1 = Point(x[i], y[i]);
        Point p2 = Point(x[j], y[j]);
        if (norm(p1 - p2) < 4) {
          double h = sqrt(1.0 - norm(p1 - p2) / 4.0);
          Point t = p2 - p1;
          t /= abs(t);
          Point u = t * Point(0, 1);
          points.push_back(p1 + t * abs(p1 - p2) / 2.0 + u * h);
          points.push_back(p1 + t * abs(p1 - p2) / 2.0 - u * h);
        }
      }
    }

    double eps = 1e-10;
    int ans = 1;
    for (int i = 0; i < points.size(); i++) {
      double px = points[i].real();
      double py = points[i].imag();
      int cnt = 0;
      for (int j = 0; j < n; j++) {
        if ((x[j] - px) * (x[j] - px) + (y[j] - py) * (y[j] - py) < 1 + eps) {
          cnt++;
        }
      }
      if (ans < cnt)
        ans = cnt;
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

//???????????????????????????,
//?????????????????????????????°????????????????????????????????????????????????2???????????¨???????????£?????\\????????¨?????§????????????
//?????£???,
//2??????????????????1?????????????????????????????????????????°??????????????????????£????,
//O(N^2)????????????????????????, ??¨?????§O(N^3)????????§?§£?????????
#include <complex>
#include <iostream>
#include <vector>
using namespace std;
typedef complex<double> Point;

int n;
double x[300], y[300];
vector<Point> points; //????£???????

int main() {
  while (cin >> n || n) {
    for (int i = 0; i < n; i++)
      cin >> x[i] >> y[i];
    if (n == 1) {
      cout << 1 << endl;
      continue;
    }

    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        Point p1 = Point(x[i], y[i]);
        Point p2 = Point(x[j], y[j]);
        if (norm(p1 - p2) < 4) {
          double h = sqrt(1.0 - norm(p1 - p2) / 4.0);
          Point t = p2 - p1;
          t /= abs(t);
          Point u = t * Point(0, 1);
          points.push_back(p1 + t * abs(p1 - p2) / 2.0 + u * h);
          points.push_back(p1 + t * abs(p1 - p2) / 2.0 - u * h);
        }
      }
    }

    double eps = 1e-7;
    int ans = 0;
    for (int i = 0; i < points.size(); i++) {
      int cnt = 0;
      for (int j = 0; j < n; j++) {
        Point p = Point(x[j], y[j]);
        if (norm(points[i] - p) < 1 + eps) {
          cnt++;
        }
      }
      if (ans < cnt)
        ans = cnt;
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00713 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define loop(n, i) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

using namespace std;
typedef pair<double, double> P;
const double EPS = 1e-4;

#include <bits/stdc++.h>

#define loop(n, i) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

using namespace std;

vector<P> center(P a, P b) {
  auto t = atan2(b.second - a.second, b.first - a.first);
  auto x = hypot(a.first - b.first, a.second - b.second) / 2;
  auto y = sqrt(1.0 - x * x);
  auto cs = cos(t), sn = sin(t);
  return {{cs * x - sn * y + a.first, sn * x + cs * y + a.second},
          {cs * x + sn * y + a.first, sn * x - cs * y + a.second}};
}

int main() {
  while (1) {
    int n;
    cin >> n;
    if (!n)
      break;
    vector<P> pnt;
    loop(n, i) {
      double x, y;
      cin >> x >> y;
      pnt.emplace_back(x, y);
    }
    int ans = 1;
    loop(n, i) loop(n, j) {
      auto ps = center(pnt[i], pnt[j]);
      for (auto o : ps) {
        int cnt = 0;
        loop(n, l) {
          auto x = o.first - pnt[l].first;
          auto y = o.second - pnt[l].second;
          if (x * x + y * y < 1 + EPS)
            cnt++;
        }
        ans = max(ans, cnt);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define loop(n, i) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

using namespace std;
typedef pair<double, double> P;
const double EPS = 1e-5;

#include <bits/stdc++.h>

#define loop(n, i) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

using namespace std;

double dist(P a, P b) { return hypot(a.first - b.first, a.second - b.second); }

vector<P> center(P a, P b) {
  auto t = atan2(b.first - a.first, b.second - a.second);
  auto x = dist(a, b) / 2;
  auto y = sqrt(1.0 - x * x);
  auto cs = cos(t), sn = sin(t);
  return {{cs * x - sn * y + a.first, sn * x + cs * y + a.second},
          {cs * x + sn * y + a.first, sn * x - cs * y + a.second}};
}

int main() {
  while (1) {
    int n;
    cin >> n;
    if (!n)
      break;
    vector<P> pnt;
    loop(n, i) {
      double x, y;
      cin >> x >> y;
      pnt.emplace_back(x, y);
    }
    int ans = 1;
    loop(n, i) loop(n, j) {
      auto ps = center(pnt[i], pnt[j]);
      for (auto o : ps) {
        int cnt = 0;
        loop(n, l) {
          if (dist(o, pnt[l]) < 1 + EPS)
            cnt++;
        }
        ans = max(ans, cnt);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00716 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
using namespace std;
int maxn, n, m, y, money, money2, a, c;
double b;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> money;
    money2 = money;
    cin >> y >> m;
    maxn = 0;
    for (int j = 0; j < m; j++) {
      cin >> a >> b >> c;
      money = money2;
      if (a == 1) {
        for (int k = 0; k < y; k++) {
          money = (double)money * (1 + b);
          money -= c;
        }
      } else {
        for (int k = 0; k < y; k++) {
          money += (double)(money2 - k * c) * b;
        }
        money -= y * c;
      }
      maxn = max(maxn, money);
    }
    cout << maxn << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int maxn, n, m, y, money, money2, a, c;
double b;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> money;
    money2 = money;
    cin >> y >> m;
    maxn = 0;
    for (int j = 0; j < m; j++) {
      cin >> a >> b >> c;
      money = money2;
      if (a == 1) {
        for (int k = 0; k < y; k++) {
          money = (double)money * b;
          money -= c;
        }
      } else {
        for (int k = 1; i <= y; k++) {
          money += (double)(money - k * c) * b;
        }
        money -= y * b;
      }
      maxn = max(maxn, money);
    }
    cout << maxn << endl;
  }
}
Problem p00716 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int i, j, k;
  int a, m, n, o, p, q, s, t, u;
  double r;
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> p >> n >> o;
    a = 0;
    for (j = 0; j < o; j++) {
      cin >> q >> r >> s;
      t = p;
      if (q) {
        for (k = 0; k < n; k++) {
          t += (int)(t * r);
          t -= s;
        }
        a = max(a, t);
      } else {
        u = 0;
        for (k = 0; k < n; k++) {
          u += (int)(t * r);
          t -= s;
        }
        a = max(a, t + u);
      }
    }
    cout << a << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int i, j, k;
  int a[100], m, n, o, p, q, s, t, u;
  double r;
  memset(a, 0, sizeof(a));
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> p >> n >> o;
    for (j = 0; j < o; j++) {
      cin >> q >> r >> s;
      t = p;
      if (q) {
        for (k = 0; k < n; k++) {
          t += (int)(t * r);
          t -= s;
        }
        a[i] = max(a[i], t);
      } else {
        u = 0;
        for (k = 0; k < n; k++) {
          u += (int)(t * r);
          t -= s;
        }
        a[i] = max(a[i], t + u);
      }
    }
    cout << a[i] << endl;
  }
  return 0;
}
Problem p00716 (C++) — buggy submission, verdict: Memory Limit Exceeded

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

bool t_h;
long long int year, var, tesuryo;
double riritu, hukuiri;

long long int T(long long int shikin) {
  int rishi = 0;
  for (int i = 0; i < year; i++) {
    rishi += riritu * shikin;
    shikin -= tesuryo;
  }
  return rishi + shikin;
}

long long int H(long long int shikin) {
  // cout<<"H"<<endl;
  for (int i = 0; i < year; i++) {
    shikin = shikin * riritu + shikin - tesuryo;
    // cout<<"shikin "<<shikin<<endl;
  }
  // cout<<"end"<<endl;
  return shikin;
}

int main() {
  int n;
  long long int shikin;
  vector<long long int> ans;
  cin >> n;
  for (int i = 0; i < n; i++) {
    // cout<<"i is "<<i<<endl;
    ans.clear();
    cin >> shikin >> year >> var;
    for (int j = 0; j < var; j++) {
      // cout<<"j is "<<j<<endl;
      cin >> t_h >> riritu >> tesuryo;
      // cout<<t_h<<endl;
      if (t_h == 1)
        ans.push_back(H(shikin));
      else
        ans.push_back(T(shikin));
      // cout<<"LKJL"<<endl;
    }
    sort(ans.begin(), ans.end());
    // cout<<"sort"<<endl;
    cout << ans.back() << endl;
  }
  return 0;
}

Error: MLE

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<pii> L;

ll dist(pii p1, pii p2) {
  return (ll)(p1.first - p2.first) * (ll)(p1.first - p2.first) +
         (ll)(p1.second - p2.second) * (ll)(p1.second - p2.second);
}

void RotateL(L &ls) {
  int len = (int)ls.size();
  for (int i = 0; i < len; i++) {
    pii p = ls[i];
    ls[i] = make_pair(p.second, -p.first);
  }
}

bool isSame(L l1, L l2) {
  for (int rep = 0; rep < 4; rep++) {
    RotateL(l2);
    int len = (int)l2.size();
    if (len != (int)l1.size())
      return false;

    ll dist1 = dist(l1[0], l2[0]);
    ll dist2 = dist(l1[len - 1], l2[0]);

    bool same1 = true, same2 = true;
    for (int i = 0; i < len; i++) {
      if (dist(l1[i], l2[i]) != dist1)
        same1 = false;
      if (dist(l1[len - 1 - i], l2[i]) != dist2)
        same2 = false;
    }

    if (same1 || same2)
      return true;
  }
  return false;
}

int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;

    L l0;
    int len;
    cin >> len;
    for (int i = 0; i < len; i++) {
      int ix, iy;
      cin >> ix >> iy;
      l0.push_back(make_pair(ix, iy));
    }

    for (int i = 0; i < n; i++) {
      L li;
      cin >> len;
      for (int j = 0; j < len; j++) {
        int ix, iy;
        cin >> ix >> iy;
        li.push_back(make_pair(ix, iy));
      }
      if (isSame(l0, li))
        cout << i + 1 << endl;
    }
    cout << "+++++" << endl;
  }
  return 0;
}