prithivMLmods/Coder-Stat huggingface dataset:
Problem p03352 (Python)

Buggy submission (status: Runtime Error):
def main():
    n = int(input())

    # for i in range(1, n + 1):
    #     if

    # i = 1
    # while i * i <= n:
    #     i += 1
    #
    # print((i - 1) ** 2)

    ans = [1]
    for i in range(2, n + 1):
        j = 2
        while i**j <= n:
            ans.append(i**j)
            j += 1

    print(max[ans])


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())

    # for i in range(1, n + 1):
    #     if

    # i = 1
    # while i * i <= n:
    #     i += 1
    #
    # print((i - 1) ** 2)

    ans = [1]
    for i in range(2, n + 1):
        j = 2
        while i**j <= n:
            ans.append(i**j)
            j += 1

    print(max(ans))


if __name__ == "__main__":
    main()
Problem p03352 (Python)

Buggy submission (status: Time Limit Exceeded):
x = int(input())
ans = 1
for i in range(2, 1000):
    j = 2
    while i**j <= x:
        ans = max(ans, i**j)
    j += 1
    if i > x:
        break
print(ans)


Fixed submission:
x = int(input())
ans = 1
for i in range(2, 1000):
    j = 2
    while i**j <= x:
        ans = max(ans, i**j)
        j += 1
print(ans)
Problem p03352 (Python)

Buggy submission (status: Time Limit Exceeded):
X = int(input())

ans = []
for i in range(1000):
    for j in range(1000):
        if i**j > X:
            continue
        ans.append(i**j)
print(max(ans))


Fixed submission:
X = int(input())

ans = []
for i in range(1, 1000):
    for j in range(2, 11):
        if i**j > X:
            continue
        ans.append(i**j)
print(max(ans))
Problem p03352 (Python)

Buggy submission (status: Time Limit Exceeded):
X = int(input())

for i in range(X, 0, -1):
    tmp = i
    if X % tmp:
        continue
    while tmp <= X:
        tmp *= tmp
    if tmp == X:
        print(i)


Fixed submission:
X = int(input())

ans = 1
for i in range(1, X):
    for j in range(2, X):
        tmp = i**j
        if tmp > X:
            break
        ans = max(tmp, ans)
print(ans)
Problem p03352 (C++)

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

int a;
int main() {
  cin >> a;

  int mx = 0;
  for (int i = 1; i * i <= a; ++i) {
    int base = i * i;
    while (base <= a) {
      mx = max(mx, base);
      base *= i;
    }
  }
  cout << mx << endl;
}

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

int a;
int main() {
  cin >> a;

  int mx = 1;
  for (int i = 2; i * i <= a; ++i) {
    int base = i * i;
    while (base <= a) {
      mx = max(mx, base);
      base *= i;
    }
  }
  cout << mx << endl;
}
Problem p03352 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;

int main() {
  int X;
  cin >> X;
  int j = 2;

  while (true) {
    if (X == 1) {
      cout << 1 << endl;
    }
    for (int i = 2; i * i <= X; i++) {
      while (pow(i, j) <= X) {
        if (pow(i, j) == X) {
          cout << X << endl;
          return 0;
        }
        j++;
      }
      j = 2;
    }
    X--;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;

int main() {
  int X;
  cin >> X;
  int j = 2;

  while (true) {
    if (X == 1) {
      cout << 1 << endl;
      return 0;
    }
    for (int i = 2; i * i <= X; i++) {
      while (pow(i, j) <= X) {
        if (pow(i, j) == X) {
          cout << X << endl;
          return 0;
        }
        j++;
      }
      j = 2;
    }
    X--;
  }
}
Problem p03352 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  vector<int> a(0);
  for (int i = 2; i <= 1000; i++) {
    for (int j = 2; (int)pow(i, j) <= x; j++) {
      a.push_back((int)pow(i, j));
    }
  }
  sort(a.begin(), a.end());
  cout << a.at(a.size() - 1) << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  if (x == 1) {
    cout << 1 << endl;
    return 0;
  }
  vector<int> a(0);
  for (int i = 2; i <= 1000; i++) {
    for (int j = 2; (int)pow(i, j) <= x; j++) {
      a.push_back((int)pow(i, j));
    }
  }
  sort(a.begin(), a.end());
  cout << a.at(a.size() - 1) << endl;
}
Problem p03352 (C++)

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

int main() {
  int X;
  scanf("%d", &X);
  if (X <= 3) {
    printf("1");
    return 0;
  }
  for (int l = X; l > 0; l--) {
    for (int i = 1; i * i <= X; i++) {
      if (l % i == 0) {
        int k = l;
        while (k != 1) {
          if (k % i == 0)
            k /= i;
          else
            break;
        }
        if (k == 1 && l != i) {
          printf("%d", l);
          return 0;
        }
      }
    }
  }
}


Fixed submission:
#include <stdio.h>

int main() {
  int X;
  scanf("%d", &X);
  if (X <= 3) {
    printf("1");
    return 0;
  }
  for (int l = X; l > 0; l--) {
    for (int i = 2; i * i <= X; i++) {
      if (l % i == 0) {
        int k = l;
        while (k != 1) {
          if (k % i == 0)
            k /= i;
          else
            break;
        }
        if (k == 1 && l != i) {
          printf("%d", l);
          return 0;
        }
      }
    }
  }
}
Problem p03352 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define FOR(i, begin, end) for (int i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readline(int N, vector<int> &a) {
  string s;
  for (int i = 0; i < N - 1; i++) {
    getline(cin, s, ' ');
    a[i] = atoi(s.c_str());
  }
  getline(cin, s, '\n');
  a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a) {
  string s;
  for (int i = 0; i < N - 1; i++) {
    getline(cin, s, ' ');
    a[i] = atof(s.c_str());
  }
  getline(cin, s, '\n');
  a[N - 1] = atof(s.c_str());
}

signed main() {

  int X;
  cin >> X;
  vector<int> p(0);

  FOR(i, 2, 100) {
    int tmp = i * i;
    while (tmp <= X) {
      p.push_back(tmp);
      tmp *= i;
    }
  }

  sort(p.begin(), p.end());

  cout << p[p.size() - 1];

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define FOR(i, begin, end) for (int i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readline(int N, vector<int> &a) {
  string s;
  for (int i = 0; i < N - 1; i++) {
    getline(cin, s, ' ');
    a[i] = atoi(s.c_str());
  }
  getline(cin, s, '\n');
  a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a) {
  string s;
  for (int i = 0; i < N - 1; i++) {
    getline(cin, s, ' ');
    a[i] = atof(s.c_str());
  }
  getline(cin, s, '\n');
  a[N - 1] = atof(s.c_str());
}

signed main() {

  int X;
  cin >> X;
  vector<int> p(1);
  p[0] = 1;

  FOR(i, 2, 100) {
    int tmp = i * i;
    while (tmp <= X) {
      p.push_back(tmp);
      tmp *= i;
    }
  }

  sort(p.begin(), p.end());

  cout << p[p.size() - 1];

  return 0;
}
Problem p03352 (C++)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for (_loop_int i = 0; i < (_loop_int)(n); ++i)
#define FOR(i, a, b) for (_loop_int i = (_loop_int)(a); i < (_loop_int)(b); ++i)
#define FORR(i, a, b)                                                          \
  for (_loop_int i = (_loop_int)(b)-1; i >= (_loop_int)(a); --i)

#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG_VEC(v)                                                           \
  cout << #v << ":";                                                           \
  REP(i, v.size()) cout << " " << v[i];                                        \
  cout << endl
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a) % MOD + MOD) % MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(a, b) (abs(a - b) < EPS)
typedef complex<Real> P;

int main() {
  int x;
  cin >> x;
  int ans = 1;
  FOR(b, 1, x + 1) {
    int cur = b * b;
    while (cur <= x) {
      CHMAX(ans, cur);
      cur *= b;
    }
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for (_loop_int i = 0; i < (_loop_int)(n); ++i)
#define FOR(i, a, b) for (_loop_int i = (_loop_int)(a); i < (_loop_int)(b); ++i)
#define FORR(i, a, b)                                                          \
  for (_loop_int i = (_loop_int)(b)-1; i >= (_loop_int)(a); --i)

#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG_VEC(v)                                                           \
  cout << #v << ":";                                                           \
  REP(i, v.size()) cout << " " << v[i];                                        \
  cout << endl
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a) % MOD + MOD) % MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(a, b) (abs(a - b) < EPS)
typedef complex<Real> P;

int main() {
  int x;
  cin >> x;
  int ans = 1;
  FOR(b, 2, x + 1) {
    int cur = b * b;
    while (cur <= x) {
      CHMAX(ans, cur);
      cur *= b;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03352 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, ans = 1;
  cin >> x;
  for (int i = 1; i <= x; i++)
    for (int j = i * i; j <= x; j *= i)
      ans = max(ans, j);
  cout << ans;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, ans = 1;
  cin >> x;
  for (int i = 2; i <= x; i++)
    for (int j = i * i; j <= x; j *= i)
      ans = max(ans, j);
  cout << ans;
}
Problem p03352 (C++)

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

using namespace std;
typedef long long ll;

int solve(int x) {
  if (x == 1) {
    return 1;
  }
  int res = 0;
  for (int i = 2;; i++) {
    for (int j = 2; pow(i, j) <= 1000; j++) {
      res = max(res, (int)pow(i, j));
    }
  }
  return res;
}

int main() {
  int x;
  cin >> x;
  cout << solve(x);
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int solve(int x) {
  if (x == 1) {
    return 1;
  }
  int res = 0;
  for (int i = 2; pow(i, 2) <= x; i++) {
    for (int j = 2; pow(i, j) <= x; j++) {
      res = max(res, (int)pow(i, j));
    }
  }
  return res;
}

int main() {
  int x;
  cin >> x;
  cout << solve(x);
}
Problem p03352 (C++)

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

int main() {
  int X;
  cin >> X;
  bool f[1000 + 1] = {};
  f[1] = true;
  for (int i = 2; i < 32; i++) {
    int idx = i * i;
    while (idx <= 1000) {
      f[idx] = true;
      idx *= i;
    }
  }
  while (X > 0) {
    if (f[X]) {
      cout << X << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}


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

int main() {
  int X;
  cin >> X;
  bool f[1000 + 1] = {};
  f[1] = true;
  for (int i = 2; i < 32; i++) {
    int idx = i * i;
    while (idx <= 1000) {
      f[idx] = true;
      idx *= i;
    }
  }
  while (X > 0) {
    if (f[X]) {
      cout << X << endl;
      return 0;
    }
    X--;
  }
  cout << 1 << endl;
  return 0;
}
Problem p03352 (C++)

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template <class T, class U> using P = pair<T, U>;
template <class T> using Heap = priority_queue<T>;
template <class T> using heaP = priority_queue<T, vector<T>, greater<T>>;
template <class T, class U> using umap = unordered_map<T, U>;
template <class T> using uset = unordered_set<T>;

template <class T> bool ChangeMax(T &a, const T &b) {
  if (a >= b)
    return false;
  a = b;
  return true;
}

template <class T> bool ChangeMin(T &a, const T &b) {
  if (a <= b)
    return false;
  a = b;
  return true;
}

template <class T, size_t N, class U> void Fill(T (&a)[N], const U &v) {
  fill((U *)a, (U *)(a + N), v);
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
  for (auto &e : v)
    is >> e;
  return is;
}

int main() {
  int x;
  cin >> x;
  int ans = 0;
  for (int i = 1; i <= x; ++i) {
    int y = i;
    while (y <= x) {
      ChangeMax(ans, y);
      y *= i;
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template <class T, class U> using P = pair<T, U>;
template <class T> using Heap = priority_queue<T>;
template <class T> using heaP = priority_queue<T, vector<T>, greater<T>>;
template <class T, class U> using umap = unordered_map<T, U>;
template <class T> using uset = unordered_set<T>;

template <class T> bool ChangeMax(T &a, const T &b) {
  if (a >= b)
    return false;
  a = b;
  return true;
}

template <class T> bool ChangeMin(T &a, const T &b) {
  if (a <= b)
    return false;
  a = b;
  return true;
}

template <class T, size_t N, class U> void Fill(T (&a)[N], const U &v) {
  fill((U *)a, (U *)(a + N), v);
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
  for (auto &e : v)
    is >> e;
  return is;
}

int main() {
  int x;
  cin >> x;
  int ans = 1;
  for (int i = 2; i <= x; ++i) {
    int y = i * i;
    while (y <= x) {
      ChangeMax(ans, y);
      y *= i;
    }
  }
  cout << ans << endl;
}
Problem p03352 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;

int main() {
  int x;
  cin >> x;
  priority_queue<int> p;
  p.push(1);
  rep(i, pow(x, 0.5)) {
    int a = i * i;
    while (a <= x) {
      p.push(a);
      a *= i;
    }
  }
  cout << p.top() << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;

int main() {
  int x;
  cin >> x;
  priority_queue<int> p;
  p.push(1);
  rep(i, pow(x, 0.5)) {
    if (i > 1) {
      int a = i * i;
      while (a <= x) {
        p.push(a);
        a *= i;
      }
    }
  }
  cout << p.top() << endl;
  return 0;
}
Problem p03352 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int X, i = 0;
  vector<int> a = {1,   4,   8,   9,   16,  25,  27,  32,  36,  49,  64,
                   81,  100, 121, 125, 128, 144, 169, 196, 216, 225, 243,
                   256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576,
                   625, 676, 729, 784, 841, 900, 961, 1000};
  cin >> X;
  while (a.at(i + 1) <= X)
    i++;
  cout << a.at(i) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int X, i = 0;
  vector<int> a = {1,   4,   8,   9,   16,  25,  27,  32,   36,  49,  64,
                   81,  100, 121, 125, 128, 144, 169, 196,  216, 225, 243,
                   256, 289, 324, 343, 361, 400, 441, 484,  512, 529, 576,
                   625, 676, 729, 784, 841, 900, 961, 1000, 1001};
  cin >> X;
  while (a.at(i + 1) <= X)
    i++;
  cout << a.at(i) << endl;
}
Problem p03352 (C++)

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

int main() {
  int x;
  cin >> x;
  int b = 1;
  int p = 2;
  set<int> ans;
  for (int i = b; i < x; i++) {
    for (int j = p; j < x; j++) {
      if (pow(i, j) > x)
        break;
      else
        ans.insert(pow(i, j));
    }
  }
  cout << *(--ans.end());
}

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

int main() {
  int x;
  cin >> x;
  int b = 1;
  int p = 2;
  set<int> ans;
  if (x == 1)
    return cout << 1, 0;
  for (int i = b; i < x; i++) {
    for (int j = p; j < x; j++) {
      if (pow(i, j) > x)
        break;
      else
        ans.insert(pow(i, j));
    }
  }
  cout << *(--ans.end());
}
Problem p03352 (C++)

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

int main() {
  int x, i;
  cin >> x;
  vector<bool> v(x, 0);
  for (int b = 0; b <= sqrt(x); b++) {
    for (int p = 2; pow(b, p) <= x; p++)
      v[pow(b, p)] = 1;
  }
  for (i = x;; i--)
    if (v[i] == 1)
      break;
  cout << i << endl;
  return 0;
}

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

int main() {
  int x, i;
  cin >> x;
  vector<bool> v(x + 1, 0);
  v[1] = 1;
  for (int b = 2; b <= sqrt(x); b++) {
    for (int p = 2; pow(b, p) <= x; p++)
      v[pow(b, p)] = 1;
  }
  for (i = x;; i--)
    if (v[i] == 1)
      break;
  cout << i << endl;
  return 0;
}
Problem p03352 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int x;
  cin >> x;
  while (true) {
    int q = sqrt(x);
    for (int i = q; i > 1; --i) {
      int t = x;
      while (t > 1) {
        if (t % i == 0)
          t /= i;
        else
          break;

        if (t == 1) {
          cout << x << endl;
          return 0;
        }
      }
    }
    --x;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int x;
  cin >> x;
  if (x == 1) {
    cout << 1 << endl;
    return 0;
  }

  while (true) {
    int q = sqrt(x);
    for (int i = q; i > 1; --i) {
      int t = x;
      while (t > 1) {
        if (t % i == 0)
          t /= i;
        else
          break;

        if (t == 1) {
          cout << x << endl;
          return 0;
        }
      }
    }
    --x;
  }
  return 0;
}
Problem p03352 (C++)

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

int main() {
  int x, a = 1, b = 1;
  cin >> x;
  for (int i = 1; i < 35; i++) {
    for (int j = i * i; j <= 10; j = j * i) {
      if (j > a) {
        a = j;
      }
    }
  }
  cout << a << endl;
  return 0;
}

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

int main() {
  int x, a = 1, b = 1;
  cin >> x;
  if (x == 1) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 2; i < 35; i++) {
    for (int j = i * i; j <= x; j = j * i) {
      if (j > a) {
        a = j;
      }
    }
  }
  cout << a << endl;
  return 0;
}
Problem p03352 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int X;
  cin >> X;
  int ans = 0;
  for (int i = X; i >= 1; i--) {
    for (int j = 1; j < 1000; j++) {
      for (int k = 2; k < 1000; k++) {
        if (pow(j, k) == i) {
          cout << i << endl;
          return 0;
        }
      }
    }
  }
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int X;
  cin >> X;
  int ans = 0;
  for (int i = X; i >= 1; i--) {
    for (int j = 1; j <= 1000; j++) {
      for (int k = 2; k <= 10; k++) {
        if (pow(j, k) == i) {
          cout << i << endl;
          return 0;
        }
      }
    }
  }
}
Problem p03352 (C++)

Buggy submission (status: Runtime Error):

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;

using Graph = vector<vector<int>>;

vector<int> seen;

int main() {
  int N;

  cin >> N;

  if (N == 1) {
    cout << 1;
    return 1;
  }

  int v;
  int max_v = 0;
  for (int ni = 2; ni < 34; ni++) {
    v = ni * ni;
    while (v <= N) {
      max_v = max(max_v, v);
      v *= ni;
    }
  }

  int ans = max_v;
  // printf("%.9f", ans);
  std::cout << ans;

  return 0;
}


Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;

using Graph = vector<vector<int>>;

vector<int> seen;

int main() {
  int N;

  cin >> N;

  if (N == 1) {
    cout << 1;
    return 0;
  }

  int v;
  int max_v = 0;
  for (int ni = 2; ni < 34; ni++) {
    v = ni * ni;
    while (v <= N) {
      max_v = max(max_v, v);
      v *= ni;
    }
  }

  int ans = max_v;
  // printf("%.9f", ans);
  std::cout << ans;

  return 0;
}
Problem p03352 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int x;
  cin >> x;
  vector<long long> bp;
  int i, j;
  for (i = 1; i < x; i++) {
    for (j = 2; j < x; j++) {
      int product = pow(i, j);
      if (product <= x) {
        bp.push_back(product);
      } else {
        break;
      }
    }
  }
  sort(bp.begin(), bp.end());
  cout << bp[bp.size() - 1] << endl;
  return 0;
}


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

int main() {
  int x;
  cin >> x;
  vector<long long> bp;
  bp.push_back(1);
  int i, j;
  for (i = 1; i < x; i++) {
    for (j = 2; j < x; j++) {
      int product = pow(i, j);
      if (product <= x) {
        bp.push_back(product);
      } else {
        break;
      }
    }
  }
  sort(bp.begin(), bp.end());
  cout << bp[bp.size() - 1] << endl;
  return 0;
}
Problem p03352 (C++)

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

int main() {
  int X;
  cin >> X;
  int ans = 1;
  for (int i = 2; i < X; i++) {
    for (int j = i * i; j <= X; i *= i) {
      ans = max(ans, j);
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
  int X;
  cin >> X;
  int ans = 1;
  for (int i = 2; i < X; i++) {
    for (int j = i * i; j <= X; j *= i) {
      ans = max(ans, j);
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03352 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int X;
  int x;
  for (int i = 0; i * i <= X; i++)
    x = i;
  vector<int> M(x + 1);
  M.at(0) = 0;
  M.at(1) = 1;
  for (int i = 2; i <= x; i++) {
    int sum = 1;
    for (int j = 0; sum <= X; j++) {
      sum *= i;
      if (X < sum) {
        sum /= i;
        break;
      }
    }
    M.at(i) = sum;
  }
  sort(M.begin(), M.end());
  cout << M.at(x) << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int X;
  cin >> X;
  int x;
  for (int i = 0; i * i <= X; i++)
    x = i;
  vector<int> M(x + 1);
  M.at(0) = 0;
  M.at(1) = 1;
  for (int i = 2; i <= x; i++) {
    int sum = 1;
    for (int j = 0; sum <= X; j++) {
      sum *= i;
      if (X < sum) {
        sum /= i;
        break;
      }
    }
    M.at(i) = sum;
  }
  sort(M.begin(), M.end());
  cout << M.at(x) << endl;

  return 0;
}
Problem p03352 (C++)

Buggy submission (status: Runtime Error):
/**
 *      ABC 97 B
 *      author  : kyomukyomupurin
 *      created : 2018/08/23
 **/

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

int main() {
  int X;
  cin >> X;
  vector<int> v;
  v.push_back(1);
  for (int i = 2; i < 10; ++i) {
    v.push_back(pow(2, i));
  }
  for (int i = 2; i < 7; ++i) {
    v.push_back(pow(3, i));
  }
  for (int i = 2; i < 5; ++i) {
    v.push_back(pow(5, i));
  }
  for (int i = 6; i < 9; ++i) {
    for (int j = 2; j < 4; ++j) {
      v.push_back(pow(i, j));
    }
  }
  for (int i = 2; i < 4; ++i) {
    v.push_back(pow(10, i));
  }
  for (int i = 11; i < 32; ++i) {
    v.push_back(pow(i, 2));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); ++i) {
    if (X >= v.at(i) && X < v.at(i + 1)) {
      cout << v.at(i);
      break;
    }
  }

  return 0;
}


Fixed submission:
/**
 *      ABC 97 B
 *      author  : kyomukyomupurin
 *      created : 2018/08/23
 **/

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

int main() {
  int X;
  cin >> X;
  vector<int> v;
  v.push_back(1);
  for (int i = 2; i < 10; ++i) {
    v.push_back(pow(2, i));
  }
  for (int i = 2; i < 7; ++i) {
    v.push_back(pow(3, i));
  }
  for (int i = 2; i < 5; ++i) {
    v.push_back(pow(5, i));
  }
  for (int i = 6; i < 9; ++i) {
    for (int j = 2; j < 4; ++j) {
      v.push_back(pow(i, j));
    }
  }
  for (int i = 2; i < 4; ++i) {
    v.push_back(pow(10, i));
  }
  for (int i = 11; i < 32; ++i) {
    v.push_back(pow(i, 2));
  }
  sort(v.begin(), v.end());

  if (X == 1)
    cout << 1 << endl;
  else if (X == 1000)
    cout << 1000 << endl;
  else {
    for (int i = 0; i < v.size(); ++i) {
      if (X >= v.at(i) && X < v.at(i + 1)) {
        cout << v.at(i);
        break;
      }
    }
  }

  return 0;
}
Problem p03352 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool f(int a) {
  for (int i = 1; i <= a; i++) {
    for (int j = 2; j <= 1000; j++) {
      if (pow(i, j) == a) {
        return true;
      }
    }
  }
  return false;
}

int main() {
  int x;
  cin >> x;
  while (1) {
    if (f(x)) {
      cout << x << endl;
      return 0;
    }
    x--;
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool f(int a) {
  for (int i = 1; i <= a; i++) {
    for (int j = 2; j <= 10; j++) {
      if (pow(i, j) == a) {
        return true;
      }
    }
  }
  return false;
}

int main() {
  int x;
  cin >> x;
  while (1) {
    if (f(x)) {
      cout << x << endl;
      return 0;
    }
    x--;
  }
}
Problem p03352 (C++)

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

using namespace std;

int main() {
  int x;
  cin >> x;
  vector<bool> expo(x + 1);

  for (int b = 2; b <= x; b++) {
    int v = b * b;
    while (v <= x) {
      expo[v] = 1;
      v *= b;
    }
  }
  for (int i = x; x >= 1; i--) {
    if (expo[i] == 1) {
      cout << i << endl;
      return 0;
    }
  }
}


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

using namespace std;

int main() {
  int x;
  cin >> x;
  vector<bool> expo(x + 1);
  expo[1] = 1;
  for (int b = 2; b <= x; b++) {
    int v = b * b;
    while (v <= x) {
      expo[v] = 1;
      v *= b;
    }
  }
  for (int i = x; x >= 1; i--) {
    if (expo[i] == 1) {
      cout << i << endl;
      return 0;
    }
  }
}
Problem p03352 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
ll INF = 300000;

int main() {
  ll N;
  cin >> N;
  ll NN = pow(N, 0.5);
  vector<bool> Low(1010, false);
  for (ll i = 1; i <= NN; i++) {
    ll T = i;
    T *= i;
    while (T <= N) {
      Low[T] = true;
      T *= i;
    }
  }
  for (int i = N; i >= 1; i--) {
    if (Low[i]) {
      cout << i << endl;
      return 0;
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
ll INF = 300000;

int main() {
  ll N;
  cin >> N;
  ll NN = pow(N, 0.5);
  vector<bool> Low(1010, false);
  for (ll i = 1; i <= NN; i++) {
    ll T = i;
    T *= i;
    while (T <= N) {
      Low[T] = true;
      T *= i;
      if (i == 1) {
        T = N + 1;
      }
    }
  }
  for (int i = N; i >= 1; i--) {
    if (Low[i]) {
      cout << i << endl;
      return 0;
    }
  }
}
Problem p03352 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
typedef long long ll;

typedef vector<int> vi;
;
typedef vector<ll> vll;

#define l() length()
#define sz() size()

#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()

#define pb(i) push_back(i)
#define PB() pop_back()

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mp make_pair
#define Fi first
#define Se second

const int maxx = 1e6 + 9;

// Happy Coding!

void sieve(int n, vector<bool> &expo) {
  for (int i = 2; i <= n; i++) {
    for (int j = i * i; j <= n; j *= i) {
      expo[j] = 1;
    }
  }
}
int _find(int n, vector<bool> &expo) {
  for (int i = n; i >= 1; i--) {
    if (expo[i]) {
      return i;
    }
  }
}
void solve() {
  int n;
  cin >> n;
  vector<bool> expo(n + 1, false);
  sieve(n, expo);
  cout << _find(n, expo);
}

int main() {
  faster;
  int t = 1;
  // cin>>t;
  while (t-- > 0) {
    solve();
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
typedef long long ll;

typedef vector<int> vi;
;
typedef vector<ll> vll;

#define l() length()
#define sz() size()

#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()

#define pb(i) push_back(i)
#define PB() pop_back()

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mp make_pair
#define Fi first
#define Se second

const int maxx = 1e6 + 9;

// Happy Coding!

void sieve(int n, vector<bool> &expo) {
  for (int i = 2; i <= n; i++) {
    for (int j = i * i; j <= n; j *= i) {
      expo[j] = 1;
    }
  }
}
int _find(int n, vector<bool> &expo) {
  for (int i = n; i >= 1; i--) {
    if (expo[i]) {
      return i;
    }
  }
  return 1;
}
void solve() {
  int n;
  cin >> n;
  vector<bool> expo(n + 1, false);
  sieve(n, expo);
  cout << _find(n, expo);
}

int main() {
  faster;
  int t = 1;
  // cin>>t;
  while (t-- > 0) {
    solve();
  }
  return 0;
}
Problem p03352 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
bool good(int x) {
  for (int i = 1; i < x; i++) {
    if (x % i == 0) {
      int cx = x;
      while (cx % i == 0 && cx != 1)
        cx /= i;
      if (cx == 1)
        return true;
    }
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  while (!good(n))
    n--;
  cout << n << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
bool good(int x) {
  if (x == 1)
    return true;
  for (int i = 2; i < x; i++) {
    if (x % i == 0) {
      int cx = x;
      while (cx % i == 0 && cx != 1)
        cx /= i;
      if (cx == 1)
        return true;
    }
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  while (!good(n))
    n--;
  cout << n << endl;
  return 0;
}
Problem p03352 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main() {
  int x;
  cin >> x;
  int ans = 0;
  for (int i = 0; i < 50; i++) {
    int temp = i;
    while (temp <= x) {
      ans = max(ans, temp);
      temp *= i;
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main() {
  int x;
  cin >> x;
  int ans = 1;
  for (int i = 2; i < 50; i++) {
    int temp = i * i;
    while (temp <= x) {
      ans = max(ans, temp);
      temp *= i;
    }
  }
  cout << ans << endl;
}
Problem p03352 (C++)

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

int main() {
  int x;
  cin >> x;

  int v = 0, j = 2;
  for (int i = 1; pow(i, 2) <= x; i++) {
    for (j = 2; pow(i, j) <= x; j++) {
      if (pow(i, j) > v)
        v = pow(i, j);
    }
  }

  cout << v << endl;

  return 0;
}


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

int main() {
  int x;
  cin >> x;

  int v = 0, j = 2;
  if (x < 4)
    v = 1;
  else {
    for (int i = 2; pow(i, 2) <= x; i++) {
      for (j = 2; pow(i, j) <= x; j++) {
        if (pow(i, j) > v)
          v = pow(i, j);
      }
    }
  }

  cout << v << endl;

  return 0;
}
Problem p03352 (C++)

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL << 60);
const int INF = (1LL << 30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a <= x && x < b; }
template <typename T> T ceil(T a, T b) { return a / b + !!(a % b); }
template <class S, class T>
ostream &operator<<(ostream &out, const pair<S, T> &a) {
  out << '(' << a.first << ',' << a.second << ')';
  return out;
}
template <class T> ostream &operator<<(ostream &out, const vector<T> &a) {
  out << '[';
  REP(i, a.size()) {
    out << a[i];
    if (i != a.size() - 1)
      out << ',';
  }
  out << ']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int x;
  cin >> x;

  int ans = 0;
  FOR(i, 1, x + 1) {
    int ret = 1;
    int y = x;
    while (y % i == 0)
      y /= i, ret *= i;
    chmax(ans, ret);
  }
  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL << 60);
const int INF = (1LL << 30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a <= x && x < b; }
template <typename T> T ceil(T a, T b) { return a / b + !!(a % b); }
template <class S, class T>
ostream &operator<<(ostream &out, const pair<S, T> &a) {
  out << '(' << a.first << ',' << a.second << ')';
  return out;
}
template <class T> ostream &operator<<(ostream &out, const vector<T> &a) {
  out << '[';
  REP(i, a.size()) {
    out << a[i];
    if (i != a.size() - 1)
      out << ',';
  }
  out << ']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int x;
  cin >> x;

  int ans = 1;
  for (int i = 2; i * i <= x + 1; ++i) {
    int y = 1;
    while (y * i <= x)
      y *= i;
    chmax(ans, y);
  }
  cout << ans << endl;

  return 0;
}
Problem p03352 (C++)

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

int main() {
  int X;
  cin >> X;

  int max = 1;
  for (int i = 1; pow(i, 2) <= X; i++) {
    for (int j = 2; pow(i, j) <= X; j++) {
      if (pow(i, j) > max) {
        max = pow(i, j);
      }
    }
  }
  cout << max << endl;

  return 0;
}

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

int main() {
  int X;
  cin >> X;

  if (1 <= X && X <= 3) {
    cout << 1 << endl;
    return 0;
  }

  int max = 4;
  for (int i = 2; pow(i, 2) <= X; i++) {
    for (int j = 2; pow(i, j) <= X; j++) {
      if (pow(i, j) > max) {
        max = pow(i, j);
      }
    }
  }
  cout << max << endl;

  return 0;
}
Problem p03352 (C++)

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

using namespace std;

int main() {
  int X;
  cin >> X;
  int ans = 1;
  for (int b = 1; b <= sqrt(X); b++) {
    int B = b;
    for (; B < X;) {
      B *= b;
    }
    if (ans < B) {
      ans = B;
    }
  }
  cout << ans;
  return 0;
}

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

using namespace std;

int main() {
  int X;
  cin >> X;
  int ans = 1;
  for (int b = 1; b <= sqrt(X); b++) {
    int B = b;
    for (; 1 < B && B <= X / b;) {
      B *= b;
    }
    if (ans < B) {
      ans = B;
    }
  }
  cout << ans;
  return 0;
}
Problem p03353 (C++)

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

typedef long long ll;
typedef pair<int, int> P;

#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)

const long double PI = acos(-1);

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  string s;
  cin >> s;
  ll k;
  cin >> k;

  set<string> t;
  for (ll i = 1; i <= s.size(); i++) {
    for (ll j = 0; j < s.size() - i + 1; j++) {
      string b = s.substr(j, i);
      t.insert(b);
    }
  }

  ll cnt = 1;
  for (auto x : t) {
    if (cnt == k)
      cout << x << endl;
    cnt++;
  }
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)

const long double PI = acos(-1);

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  string s;
  cin >> s;
  ll k;
  cin >> k;

  set<string> t;
  for (ll i = 1; i <= k; i++) {
    for (ll j = 0; j < s.size() - i + 1; j++) {
      string b = s.substr(j, i);
      t.insert(b);
    }
  }

  ll cnt = 1;
  for (auto x : t) {
    if (cnt == k)
      cout << x << endl;
    cnt++;
  }
  return 0;
}
Problem p03353 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {

  string s;
  cin >> s;

  int k;
  cin >> k;

  vector<string> v;
  set<string> t;

  for (int i = 0; i < s.length(); i++) {
    for (int j = 1; j <= s.length() - i; j++) {
      string l = s.substr(i, j);
      if (!t.count(l)) {
        v.push_back(s.substr(i, j));
        t.insert(l);
      }
    }
  }

  sort(v.begin(), v.end());

  cout << v[k - 1];

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {

  string s;
  cin >> s;

  int k;
  cin >> k;

  vector<string> v;
  set<string> t;

  for (int i = 0; i < s.length(); i++) {
    for (int j = 1; j <= k; j++) {
      string l = s.substr(i, j);
      if (!t.count(l)) {
        v.push_back(s.substr(i, j));
        t.insert(l);
      }
    }
  }

  sort(v.begin(), v.end());

  cout << v[k - 1];

  return 0;
}
Problem p03353 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int k;
  cin >> k;
  k--;
  map<string, bool> mp;
  vector<string> v;
  rep(i, s.size()) {
    rep(j, 1, s.size() - i + 1) {
      string t = s.substr(i, j);
      if (mp[t] == true) {
        continue;
      }
      mp[t] = true;
      v.push_back(t);
    }
  }
  sort(ALL(v));
  cout << v[k] << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int k;
  cin >> k;
  k--;
  map<string, bool> mp;
  vector<string> v;
  rep(i, s.size()) {
    rep(j, 1, k + 1 + 1) {
      if (i + j > s.size())
        break;

      string t = s.substr(i, j);
      if (mp[t] == true) {
        continue;
      }
      mp[t] = true;
      v.push_back(t);
    }
  }
  sort(ALL(v));
  cout << v[k] << endl;
  return 0;
}
Problem p03353 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  set<string> se;
  rep(i, s.size()) {
    repi(j, i, s.size()) {
      if (i - j >= k) {
        continue;
      }
      string t = s.substr(i, j - i + 1);
      se.insert(t);
    }
  }
  auto ite = se.begin();
  rep(i, k - 1) { ite++; }
  cout << *ite << endl;
  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  set<string> se;
  rep(i, s.size()) {
    repi(j, i, s.size()) {
      if (j - i >= k) {
        break;
      }
      string t = s.substr(i, j - i + 1);
      se.insert(t);
    }
  }
  auto ite = se.begin();
  rep(i, k - 1) { ite++; }
  cout << *ite << endl;
  return 0;
}
Problem p03353 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#define INF 1000000009
#define LINF 1000000000000000009
#define EPS 1e-10
#define double long double
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
ll gcd(ll n, ll m) { return (m ? gcd(m, n % m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

int main() {
  string s;
  int k;
  cin >> s >> k;
  set<string> st;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - i; j++) {
      string t = "";
      for (int k = 0; k <= j; k++) {
        t += s[i + k];
      }
      st.insert(t);
    }
  }
  for (int i = 0; i < k - 1; i++) {
    st.erase(*st.begin());
  }
  cout << *st.begin() << endl;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#define INF 1000000009
#define LINF 1000000000000000009
#define EPS 1e-10
#define double long double
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
ll gcd(ll n, ll m) { return (m ? gcd(m, n % m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

int main() {
  string s;
  int k;
  cin >> s >> k;
  set<string> st;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < min(k, n - i); j++) {
      string t = "";
      for (int k = 0; k <= j; k++) {
        t += s[i + k];
      }
      st.insert(t);
    }
  }
  for (int i = 0; i < k - 1; i++) {
    st.erase(*st.begin());
  }
  cout << *st.begin() << endl;
}
Problem p03353 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  string str;
  set<string> s;
  int n;
  cin >> str >> n;
  for (int i = 0; i < str.size(); i++) {
    for (int j = 1; i + j < str.size() + 1; j++) {
      string t = str.substr(i, j);
      s.insert(t);
    }
  }
  set<string>::iterator it;
  it = s.begin();

  for (int i = 0; i < n - 1; i++)
    it++;
  cout << *it << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  string str;
  set<string> s;
  int n;
  cin >> str >> n;
  for (int i = 0; i < str.size(); i++) {
    for (int j = 1; j <= 6; j++) {
      if (i + j > str.size())
        break;
      string t = str.substr(i, j);
      s.insert(t);
    }
  }
  set<string>::iterator it;
  it = s.begin();

  for (int i = 0; i < n - 1; i++)
    it++;
  cout << *it << endl;
}
Problem p03353 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>

using namespace std;

int main(void) {
  string s;
  int x;
  cin >> s >> x;

  set<string> vec_sub;

  for (int i = 0; i < s.size(); i++) {
    int max_index = min(int(s.size() - i), 5);
    for (int j = 1; j <= s.size() - i; j++) {
      vec_sub.insert(s.substr(i, j));
    }
  }

  set<string>::iterator iter = vec_sub.begin();
  advance(iter, x - 1);
  cout << *iter;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>

using namespace std;

int main(void) {
  string s;
  int x;
  cin >> s >> x;

  set<string> vec_sub;

  for (int i = 0; i < s.size(); i++) {
    int max_index = min(int(s.size() - i), 5);
    for (int j = 1; j <= max_index; j++) {
      vec_sub.insert(s.substr(i, j));
    }
  }

  set<string>::iterator iter = vec_sub.begin();
  advance(iter, x - 1);
  cout << *iter;
}
Problem p03353 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)), t.end())
typedef long long ll;
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  vector<string> t;
  int n = s.length();
  int k;
  cin >> k;
  for (int i = 0; i < n; i++) {
    int maki = min(5, n - i);
    for (int j = i; j < maki; j++) {
      t.pb(s.substr(i, j + 1));
    }
  }
  sort(be(t));
  era(t);
  cout << t[k - 1] << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)), t.end())
typedef long long ll;
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  vector<string> t;
  int n = s.length();
  int k;
  cin >> k;
  for (int i = 0; i < n; i++) {
    int maki = min(k, n - i);
    for (int j = 0; j < maki; j++) {
      t.pb(s.substr(i, j + 1));
    }
  }
  sort(be(t));
  era(t);
  cout << t[k - 1] << endl;
  return 0;
}