prithivMLmods/Coder-Stat huggingface dataset:
Problem p03196 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

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

  ll n, p;
  cin >> n >> p;

  map<ll, int> mp = prime_factor(p);
  std::map<ll, int>::reverse_iterator i = mp.rbegin();
  vector<ll> v(n, 1);
  int j = 0;
  for (; i != mp.rend(); ++i) {
    rep(k, 0, i->second) {
      v[j] *= i->first;
      j++;
      if (j == n)
        j = 0;
    }
  }

  ll ans = v[0];
  rep(i, 1, n) { ans = __gcd(ans, v[i]); }

  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

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

  ll n, p;
  cin >> n >> p;

  map<ll, int> mp = prime_factor(p);

  int c = 0;
  for (auto m : mp)
    c += m.second;
  if (c < n) {
    cout << 1 << endl;
    return 0;
  }

  std::map<ll, int>::reverse_iterator i = mp.rbegin();
  vector<ll> v(n, 1);
  int j = 0;
  for (; i != mp.rend(); ++i) {
    rep(k, 0, i->second) {
      v[j] *= i->first;
      j++;
      if (j == n)
        j = 0;
    }
  }

  ll ans = v[0];
  rep(i, 1, n) { ans = __gcd(ans, v[i]); }

  cout << ans << endl;
}
Problem p03196 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int cot = 0;
ll n, p, a[10000005];
bool judge(ll m) {
  ll ans = 1;
  ll t = n;
  while (t) {
    if (m > p)
      return false;
    if (t & 1)
      ans *= m;
    if (ans > p || p % ans)
      return false;
    if (m > 1e10 && (t >> 1))
      return false;
    m *= m;
    t >>= 1;
  }
  if (p % ans)
    return false;
  return true;
}
int main() {
  a[cot++] = 1;
  scanf("%lld%lld", &n, &p);
  ll k = sqrt(p);
  for (int i = 1; i <= k; i++)
    if (p % i == 0) {
      a[cot++] = i;
      a[cot++] = p / i;
    }
  sort(a, a + cot);
  ll ans = 1;
  for (int i = cot - 1; i >= 0; i--)
    if (judge(a[i])) {
      ans = a[i];
      break;
    }
  printf("%lld\n", ans);
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int cot = 0;
ll n, p, a[10000005];
bool judge(ll m) {
  ll ans = 1;
  ll t = n;
  while (t) {
    if (m > p)
      return false;
    if (t & 1)
      ans *= m;
    if (ans > p || p % ans)
      return false;
    if (m > 1e8 && (t >> 1))
      return false;
    m *= m;
    t >>= 1;
  }
  if (p % ans)
    return false;
  return true;
}
int main() {
  a[cot++] = 1;
  scanf("%lld%lld", &n, &p);
  ll k = sqrt(p);
  for (int i = 1; i <= k; i++)
    if (p % i == 0) {
      a[cot++] = i;
      a[cot++] = p / i;
    }
  sort(a, a + cot);
  ll ans = 1;
  for (int i = cot - 1; i >= 0; i--)
    if (judge(a[i])) {
      ans = a[i];
      break;
    }
  printf("%lld\n", ans);
}
Problem p03196 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
ll i, j, k, n, m, p, ans = 1;
ll Pow(ll n, ll m) {
  ll ans = 1;
  while (m > 1) {
    if (m % 2 == 0) {
      m /= 2;
      n = n * n;
    } else {
      ans = ans * n;
      m /= 2;
      n = n * n;
    }
  }
  return n * ans;
}
int main() {
  cin >> p >> n;
  if (p == 1) {
    cout << n << endl;
    return 0;
  }
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = (ll)pow((double)n, (double)(1.0 / p));
  for (i = ans + 1; i >= 2; i--) {
    ll k = Pow(i, p);
    if (n % k == 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}
/*
2 999999999999
3
*/

Fixed submission:
#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
ll i, j, k, n, m, p, ans = 1;
ll Pow(ll n, ll m) {
  ll ans = 1;
  while (m > 1) {
    if (m % 2 == 0) {
      m /= 2;
      n = n * n;
    } else {
      ans = ans * n;
      m /= 2;
      n = n * n;
    }
  }
  return n * ans;
}
int main() {
  cin >> p >> n;
  if (p == 1) {
    cout << n << endl;
    return 0;
  }
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = (ll)pow((double)n, (double)(1.0 / p));
  for (i = ans + 1; i >= 2; i--) {
    ll k = Pow(i, p);
    if (k > 0 && n % k == 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}
/*
2 999999999999
3
*/
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

int in() {
  int x;
  scanf("%d", &x);
  return x;
}
ll lin() {
  ll x;
  scanf("%lld", &x);
  return x;
}

int main() {
  ll n, p;
  cin >> n >> p;
  if (n == 1) {
    cout << p << endl;
  } else {
    ll ans = 1;
    for (ll x = 2; x <= 1000001; x++) {
      ll y = p;
      bool ok = true;
      REP(i, n) {
        if (y % x == 0) {
          y /= x;
        } else {
          ok = false;
        }
      }
      if (ok)
        ans = x;
    }
    cout << ans << endl;
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

int in() {
  int x;
  scanf("%d", &x);
  return x;
}
ll lin() {
  ll x;
  scanf("%lld", &x);
  return x;
}

int main() {
  ll n, p;
  cin >> n >> p;
  if (n == 1) {
    cout << p << endl;
  } else {
    ll ans = 1;
    for (ll x = 2; x <= 1000001; x++) {
      ll y = p;
      bool ok = true;
      REP(i, n) {
        if (y % x == 0) {
          y /= x;
        } else {
          ok = false;
          break;
        }
      }
      if (ok)
        ans = x;
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

ll powll(ll x, ll n) {
  if (n == 0)
    return 1;
  ll xx = powll(x, n / 2);
  if (n % 2 == 0)
    return xx * xx;
  else
    return xx * xx * x;
}

int main() {
  ll N, P;
  cin >> N >> P;
  ll ans = 1;
  for (ll k = 2; true; k++) {
    ll now = powll(k, N);
    if (now > P || N >= 45)
      break;
    while (P % now == 0) {
      P /= now;
      ans *= k;
    }
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

ll powll(ll x, ll n) {
  if (n == 0)
    return 1;
  ll xx = powll(x, n / 2);
  if (n % 2 == 0)
    return xx * xx;
  else
    return xx * xx * x;
}

int main() {
  ll N, P;
  cin >> N >> P;
  ll ans = 1;
  if (N == 1) {
    cout << P << endl;
    return 0;
  }
  for (ll k = 2; true; k++) {
    ll now = powll(k, N);
    if (now > P || N >= 45)
      break;
    while (P % now == 0) {
      P /= now;
      ans *= k;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
/**
 *    author:  souzai32
 *    created: 12.08.2020 12:16:11
 **/

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

int main() {

  long long n, p;
  cin >> n >> p;
  long long gcd = 1, num, i = 2;
  int count = 0;

  if (n == 1)
    gcd = p;
  else {
    while (1) {
      num = pow(i, n);
      if (p % num)
        i++;
      else {
        gcd *= i;
        p /= num;
      }
      if (num > p)
        break;
      // cout << num << endl;
    }
  }

  cout << gcd << endl;

  return 0;
}

Fixed submission:
/**
 *    author:  souzai32
 *    created: 12.08.2020 12:16:11
 **/

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

int main() {

  long long n, p;
  cin >> n >> p;
  long long gcd = 1, num, i = 2;
  int count = 0;

  if (n == 1)
    gcd = p;
  else if (n >= 40)
    gcd = 1;
  else {
    while (1) {
      num = pow(i, n);
      if (p % num)
        i++;
      else {
        gcd *= i;
        p /= num;
      }
      if (num > p)
        break;
      // cout << num << endl;
    }
  }

  cout << gcd << endl;

  return 0;
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):


#include <bits/stdc++.h>
// macros
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repll(i, a, b) for (ll i = (a); i < (b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(), (a).end()
const long long int mod = 1e9 + 7;

int main() {
  ll N, P;
  ll res = 1;
  map<ll, ll> list;
  cin >> N >> P;
  repll(i, 2, P) {
    while (P % i == 0) {
      list[i]++;
      P /= i;
    }
  }
  if (P != 1)
    list[P]++;
  for (auto i : list) {
    ll common = i.second / N;
    res *= pow(i.first, common);
  }
  COUT(res);
}

Fixed submission:


#include <bits/stdc++.h>
// macros
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repll(i, a, b) for (ll i = (a); i < (b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(), (a).end()
const long long int mod = 1e9 + 7;

int main() {
  ll N, P;
  ll res = 1;
  map<ll, ll> list;
  cin >> N >> P;
  for (ll i = 2; i * i <= P; i++) {
    while (P % i == 0) {
      list[i]++;
      P /= i;
    }
  }
  if (P != 1)
    list[P]++;
  for (auto i : list) {
    ll common = i.second / N;
    res *= pow(i.first, common);
  }
  COUT(res);
}
Problem p03196 (C++)

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

int main() {
  long long n, p, ans = 1;
  scanf("%lld%lld", &n, &p);
  if (n == 1)
    printf("%lld\n", p);
  else {
    for (int i = 2; i * i <= p; i += 2) {
      int j = 0;
      for (; p % i == 0; p /= i, j++)
        ;
      for (int k = 0; k < (j / n); k++)
        ans *= i;
      if (i == 2)
        i--;
    }
    printf("%lld\n", ans);
  }
}


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

int main() {
  long long n, p, ans = 1;
  scanf("%lld%lld", &n, &p);
  if (n == 1)
    printf("%lld\n", p);
  else {
    for (long long i = 2; i * i <= p; i += 2) {
      int j = 0;
      for (; p % i == 0; p /= i, j++)
        ;
      for (int k = 0; k < (j / n); k++)
        ans *= i;
      if (i == 2)
        i--;
    }
    printf("%lld\n", ans);
  }
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u> bool chmax(t &a, u b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class t, class u> bool chmin(t &a, u b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

ll mod = 1000000007;

ll mypow(ll a, ll b) {
  if (b == 1) {
    return a;
  } else {
    return a * mypow(a, b - 1);
  }
}

signed main() {
  ll n, p;
  cin >> n >> p;
  map<ll, ll> m;
  for (int i = 2; i * i <= p; i++) {
    while (p % i == 0) {
      m[i]++;
      p /= i;
    }
  }
  if (p != 1) {
    m[p]++;
  }
  ll ans = 1;
  for (auto &i : m) {
    if (i.second >= n) {
      ans *= mypow(i.first, i.second / n);
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u> bool chmax(t &a, u b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class t, class u> bool chmin(t &a, u b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

ll mod = 1000000007;

ll mypow(ll a, ll b) {
  if (b == 1) {
    return a;
  } else {
    return a * mypow(a, b - 1);
  }
}

signed main() {
  ll n, p;
  cin >> n >> p;
  map<ll, ll> m;
  for (ll i = 2; i * i <= p; i++) {
    while (p % i == 0) {
      m[i]++;
      p /= i;
    }
  }
  if (p != 1) {
    m[p]++;
  }
  ll ans = 1;
  for (auto &i : m) {
    if (i.second >= n) {
      ans *= mypow(i.first, i.second / n);
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
long long n, p, ans;
int main() {
  scanf("%lld%lld", &n, &p);
  long long ans = 1;
  for (int i = 2; i * i <= p; i++) {
    int tot = 0;
    while (p % i == 0) {
      tot++;
      if (tot == n)
        tot = 0, ans *= i;
      p /= i;
    }
  }
  if (n == 1)
    ans *= p;
  printf("%lld\n", ans);
}

Fixed submission:
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
long long n, p, ans;
int main() {
  scanf("%lld%lld", &n, &p);
  long long ans = 1;
  for (long long i = 2; i * i <= p; i++) {
    int tot = 0;
    while (p % i == 0) {
      tot++;
      if (tot == n)
        tot = 0, ans *= i;
      p /= i;
    }
  }
  if (n == 1)
    ans *= p;
  printf("%lld\n", ans);
}
Problem p03196 (C++)

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

int main() {
  ll n, p;
  cin >> n >> p;
  vector<ll> num(1001000, 0);
  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  if (p == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = 1;
  if (p % 2 == 0) {
    while (p % 2 == 0) {
      p /= 2;
      num[2]++;
    }
    if (num[2] / n > 0)
      ans *= pow(2, num[2] / n);
  }
  for (int i = 3; i * i <= p; i += 2) {
    ll x = ll(i);
    while (p % x == 0) {
      p /= x;
      num[i]++;
    }
    if (num[i] / n > 0)
      ans *= pow(x, num[i] / n);
  }
  cout << ans << endl;
}

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

int main() {
  ll n, p;
  cin >> n >> p;
  vector<ll> num(1001000, 0);
  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  if (p == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = 1;
  if (p % 2 == 0) {
    while (p % 2 == 0) {
      p /= 2;
      num[2]++;
    }
    if (num[2] / n > 0)
      ans *= pow(2, num[2] / n);
  }
  for (ll x = 3; x * x <= p; x += 2) {
    int i = int(x);
    while (p % x == 0) {
      p /= x;
      num[i]++;
    }
    if (num[i] / n > 0)
      ans *= pow(x, num[i] / n);
  }
  cout << ans << endl;
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

inline char gc() {
  //	static char buf[100000],*p1,*p2;
  //	return
  //p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin)),p1==p2)?EOF:*p1++;
  return getchar();
}

template <class T> int read(T &ans) {
  ans = 0;
  T f = 1;
  char ch = gc();
  while (!isdigit(ch)) {
    if (ch == '-')
      f = -1;
    if (ch == EOF)
      return EOF;
    ch = gc();
  }
  while (isdigit(ch))
    ans = ans * 10 + ch - '0', ch = gc();
  ans *= f;
  return 1;
}

typedef long long ll;

int main() {
  //	freopen("test.in","r",stdin);
  ll n, p, ans = 1;
  read(n);
  read(p);
  for (int i = 2; i * i <= p; i++) {
    ll temp = 0;
    while (p % i == 0)
      p /= i, temp++;
    temp /= n;
    while (temp--)
      ans *= i;
  }
  if (n == 1)
    ans *= p;
  printf("%lld\n", ans);
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

inline char gc() {
  //	static char buf[100000],*p1,*p2;
  //	return
  //p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin)),p1==p2)?EOF:*p1++;
  return getchar();
}

template <class T> int read(T &ans) {
  ans = 0;
  T f = 1;
  char ch = gc();
  while (!isdigit(ch)) {
    if (ch == '-')
      f = -1;
    if (ch == EOF)
      return EOF;
    ch = gc();
  }
  while (isdigit(ch))
    ans = ans * 10 + ch - '0', ch = gc();
  ans *= f;
  return 1;
}

typedef long long ll;

int main() {
  //	freopen("test.in","r",stdin);
  ll n, p, ans = 1;
  read(n);
  read(p);
  for (ll i = 2; i * i <= p; i++) {
    ll temp = 0;
    while (p % i == 0)
      p /= i, temp++;
    temp /= n;
    while (temp--)
      ans *= i;
  }
  if (n == 1)
    ans *= p;
  printf("%lld\n", ans);
  return 0;
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(i) i.begin(), i.end()
template <class T, class U> bool cmax(T &a, U b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T, class U> bool cmin(T &a, U b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}

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

  ll n, p;
  cin >> n >> p;

  ll ans = 1;
  for (int i = 2; i * i <= p; i++) {
    int cnt = 0;
    while (p % i == 0) {
      p /= i;
      cnt++;
    }
    // ans *= pow(i, cnt/n);
    rep(j, cnt / n) { ans *= i; }
  }
  ans *= pow(p, 1 / n);
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(i) i.begin(), i.end()
template <class T, class U> bool cmax(T &a, U b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T, class U> bool cmin(T &a, U b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}

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

  ll n, p;
  cin >> n >> p;

  ll ans = 1;
  for (ll i = 2; i * i <= p; i++) {
    int cnt = 0;
    while (p % i == 0) {
      p /= i;
      cnt++;
    }
    // ans *= pow(i, cnt/n);
    rep(j, cnt / n) { ans *= i; }
  }
  ans *= pow(p, 1 / n);
  cout << ans << endl;
}
Problem p03196 (C++)

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

#define int long long

map<int, int> prime_factor(int n) {
  map<int, int> ret;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, p;
  cin >> n >> p;

  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  for (int i = sqrt(p); i >= 1; i--) {
    if (p % i)
      continue;
    bool f = true;
    int q = 1;
    for (int j = 0; j < n; j++) {
      q *= i;
      if (q > p) {
        f = false;
        break;
      }
    }
    if (f && p % q == 0) {
      cout << i << endl;
      return 0;
    }
  }

  cout << 1 << endl;

  return 0;
}


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

#define int long long

map<int, int> prime_factor(int n) {
  map<int, int> ret;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, p;
  cin >> n >> p;

  if (n == 1) {
    cout << p << endl;
    return 0;
  }

  for (int i = sqrt(p); i >= 2; i--) {
    if (p % i)
      continue;
    bool f = true;
    int q = 1;
    for (int j = 0; j < n; j++) {
      q *= i;
      if (q > p) {
        f = false;
        break;
      }
    }
    if (f && p % q == 0) {
      cout << i << endl;
      return 0;
    }
  }

  cout << 1 << endl;

  return 0;
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, P;
  cin >> N >> P;
  long long ans = 1;
  for (int i = 2; i * i <= P; i++) {
    if (P % i == 0) {
      int cnt = 0;
      while (P % i == 0) {
        P /= i;
        cnt++;
      }
      for (int j = 0; j < cnt / N; j++) {
        ans *= i;
      }
    }
  }
  if (N == 1) {
    ans *= P;
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, P;
  cin >> N >> P;
  long long ans = 1;
  for (long long i = 2; i * i <= P; i++) {
    if (P % i == 0) {
      int cnt = 0;
      while (P % i == 0) {
        P /= i;
        cnt++;
      }
      for (int j = 0; j < cnt / N; j++) {
        ans *= i;
      }
    }
  }
  if (N == 1) {
    ans *= P;
  }
  cout << ans << endl;
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
ll Mod = 1000000007;

vector<p> pri(ll n) {
  vector<p> Pr;
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    if (cnt != 0) {
      Pr.push_back(make_pair(i, cnt));
    }
  }
  if (n != 1)
    Pr.push_back(make_pair(n, 1LL));
  return Pr;
}

int main() {
  ll N, P;
  cin >> N >> P;
  vector<p> S = pri(P);
  ll ans = 1;
  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < S[i].second / N; j++) {
      ans *= S[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
ll Mod = 1000000007;

vector<p> pri(ll n) {
  vector<p> Pr;
  for (ll i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    if (cnt != 0) {
      Pr.push_back(make_pair(i, cnt));
    }
  }
  if (n != 1)
    Pr.push_back(make_pair(n, 1LL));
  return Pr;
}

int main() {
  ll N, P;
  cin >> N >> P;
  vector<p> S = pri(P);
  ll ans = 1;
  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < S[i].second / N; j++) {
      ans *= S[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N, P;
  cin >> N >> P;
  map<int64_t, int64_t> M;
  int64_t X = P;
  for (int i = 2; i * i <= P && i <= X; i++) {
    if (X % i == 0) {
      int64_t a = 0;
      while (X % i == 0) {
        X /= i;
        a++;
      }
      a /= N;
      M[i] = a;
    }
  }
  if (X != 1)
    M[X] = (1 / N);
  int64_t ans = 1;
  for (auto p : M) {
    auto k = p.first;
    auto v = p.second;
    ans *= powl(k, v);
  }
  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N, P;
  cin >> N >> P;
  map<int64_t, int64_t> M;
  int64_t X = P;
  for (int64_t i = 2; i * i <= P && i <= X; i++) {
    if (X % i == 0) {
      int64_t a = 0;
      while (X % i == 0) {
        X /= i;
        a++;
      }
      a /= N;
      M[i] = a;
    }
  }
  if (X != 1)
    M[X] = (1 / N);
  int64_t ans = 1;
  for (auto p : M) {
    auto k = p.first;
    auto v = p.second;
    ans *= powl(k, v);
  }
  cout << ans << endl;

  return 0;
}
Problem p03196 (C++)

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

int main(void) {
  ll n, p;
  cin >> n >> p;

  ll ans = 1;

  if (n == 1) {
    cout << p << endl;
    return 0;
  }

  for (int i = 2; i * i <= p; i++) {

    ll cnt = 0;
    while (p % i == 0) {

      cnt++;
      p /= i;
    }
    if (cnt >= n) {
      ans *= (ll)pow(i, cnt / n);
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main(void) {
  ll n, p;
  cin >> n >> p;

  ll ans = 1;

  if (n == 1) {
    cout << p << endl;
    return 0;
  }

  for (ll i = 2; i * i <= p; i++) {

    ll cnt = 0;
    while (p % i == 0) {

      cnt++;
      p /= i;
    }
    if (cnt >= n) {
      ans *= (ll)pow(i, cnt / n);
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p03196 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <stack>
using namespace std;
long long mpow(long long a, long long b) {
  long long cur = a;
  long long ans = 1;
  for (;;) {
    if (b == 0)
      return ans;
    if (b & 1) {
      ans = ans * cur;
    }
    b = b >> 1;
    cur = cur * cur;
  }
}

int main() {
  long long n, p;
  cin >> n >> p;
  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  long long ans = 1;
  long long arr[1000000];
  int ind = 0;
  long long cnt = 1;
  for (long long a = 2; mpow(a, n) <= p; a = a + 1) {
    cnt = a;
  }
  //   cout<<cnt<<endl;
  for (long long a = cnt; a >= 1; a--) {
    if (p % mpow(a, n) == 0) {
      cout << a << endl;
      return 0;
    }
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <stack>
using namespace std;
long long mpow(long long a, long long b) {
  long long cur = a;
  long long ans = 1;
  for (;;) {
    if (b == 0)
      return ans;
    if (b & 1) {
      ans = ans * cur;
    }
    b = b >> 1;
    cur = cur * cur;
  }
}

int main() {
  long long n, p;
  cin >> n >> p;
  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  if (n >= 40) {
    cout << '1' << endl;
    return 0;
  }
  long long ans = 1;
  long long arr[1000000];
  int ind = 0;
  long long cnt = 1;
  for (long long a = 2; mpow(a, n) <= p; a = a + 1) {
    cnt = a;
  }
  //   cout<<cnt<<endl;
  for (long long a = cnt; a >= 1; a--) {
    if (p % mpow(a, n) == 0) {
      cout << a << endl;
      return 0;
    }
  }

  return 0;
}
Problem p03196 (C++)

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

typedef long long ll;

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = 1;
  if (n == 1) {
    cout << m << endl;
  } else {
    for (int i = 2; i * i <= m; i++) {
      int count = 0;
      ll k = m;
      while (k % i == 0 && count < n) {
        k /= i;
        count++;
      }
      if (count == n) {
        ans = i;
      }
    }
    cout << ans << endl;
  }
}


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

typedef long long ll;

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = 1;
  if (n == 1) {
    cout << m << endl;
  } else {
    for (ll i = 2; i * i <= m; i++) {
      int count = 0;
      ll k = m;
      while (k % i == 0 && count < n) {
        k /= i;
        count++;
      }
      if (count == n) {
        ans = i;
      }
    }
    cout << ans << endl;
  }
}
Problem p03196 (C++)

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

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

long long MOD = 1000000000 + 7;

template <typename T> map<T, ll> prime_factorize(T x) {
  map<T, ll> res;
  for (int i = 2; i * i <= x; i++) {
    while (x % i == 0) {
      x /= i;
      res[i]++;
    }
  }
  if (x != 1)
    res[x]++;
  return res;
}

map<ll, ll> merge(map<ll, ll> m1, map<ll, ll> m2) {
  map<ll, ll> m;
  for (auto x : m1) {
    if (m2.count(x.first) != 0) {
      m[x.first] = min(m1[x.first], m2[x.first]);
    }
  }
  return m;
}

ll mpow(ll x, ll n) {
  if (n == 0)
    return 1;

  if (n % 2 == 0)
    return mpow(x * x, n / 2);
  else
    return x * mpow(x, n - 1);
}

int main() {
  cout << setprecision(10);
  ll N, P;
  cin >> N >> P;

  map<ll, ll> m = prime_factorize(P);

  ll ans = 1;
  for (auto x : m) {
    if (x.second >= N) {
      ll pow_num = x.second / N;
      ans *= mpow(x.first, pow_num);
    }
  }
  cout << ans << endl;
}


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

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

long long MOD = 1000000000 + 7;

template <typename T> map<T, ll> prime_factorize(T x) {
  map<T, ll> res;

  while (x % 2 == 0) {
    x /= 2;
    res[2]++;
  }

  for (ll i = 3; i * i <= x; i += 2) {
    while (x % i == 0) {
      x /= i;
      res[i]++;
    }
  }
  if (x != 1)
    res[x]++;
  return res;
}

map<ll, ll> merge(map<ll, ll> m1, map<ll, ll> m2) {
  map<ll, ll> m;
  for (auto x : m1) {
    if (m2.count(x.first) != 0) {
      m[x.first] = min(m1[x.first], m2[x.first]);
    }
  }
  return m;
}

ll mpow(ll x, ll n) {
  if (n == 0)
    return 1;

  if (n % 2 == 0)
    return mpow(x * x, n / 2);
  else
    return x * mpow(x, n - 1);
}

int main() {
  cout << setprecision(10);
  ll N, P;
  cin >> N >> P;

  map<ll, ll> m = prime_factorize(P);

  ll ans = 1;
  for (auto x : m) {
    if (x.second >= N) {
      ll pow_num = x.second / N;
      ans *= mpow(x.first, pow_num);
    }
  }
  cout << ans << endl;
}
Problem p03196 (C++)

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

#define SZ(a) (int)(a).size()
using ll = long long;

int main() {
  cin.sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  if (n == 1) {
    printf("%lld\n", m);
    return 0;
  }
  int ans = 1;
  for (int i = 2; i * i <= m; i++) {
    int cnt = 0;
    while (m % i == 0) {
      m /= i;
      cnt++;
      if (cnt % n == 0) {
        ans *= i;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

#define SZ(a) (int)(a).size()
using ll = long long;

int main() {
  cin.sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  if (n == 1) {
    printf("%lld\n", m);
    return 0;
  }
  int ans = 1;
  for (ll i = 2; i * i <= m; i++) {
    int cnt = 0;
    while (m % i == 0) {
      m /= i;
      cnt++;
      if (cnt % n == 0) {
        ans *= i;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
Problem p03196 (C++)

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

using ll = long long;
using Pi = pair<int, int>;

constexpr int INF = (1 << 30) - 1;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};

template <typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template <typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }

int main() {
  ll N, P;
  ll ans = 1;
  cin >> N >> P;

  for (int i = 2; i * i <= P; i++) {
    int cnt = 0;
    while (P % i == 0) {
      P /= i;
      cnt++;
    }
    cnt /= N;
    for (int j = 0; j < cnt; j++) {
      ans *= i;
    }
  }

  if (N == 1) {
    ans *= P;
  }

  cout << ans << endl;

  return (0);
}


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

using ll = long long;
using Pi = pair<int, int>;

constexpr int INF = (1 << 30) - 1;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};

template <typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template <typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }

int main() {
  ll N, P;
  ll ans = 1;
  cin >> N >> P;

  for (ll i = 2; i * i <= P; i++) {
    int cnt = 0;
    while (P % i == 0) {
      P /= i;
      cnt++;
    }
    cnt /= N;
    for (int j = 0; j < cnt; j++) {
      ans *= i;
    }
  }

  if (N == 1) {
    ans *= P;
  }

  cout << ans << endl;

  return (0);
}
Problem p03196 (C++)

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

typedef long long ll;

int main() {
  ll N, K, ans = 1;
  cin >> N >> K;
  if (N == 1) {
    cout << K << endl;
    return 0;
  }

  for (int i = 2; i * i <= K; i++) {
    int cnt = 0;
    ll tmp = i;
    while (K % tmp == 0) {
      cnt++;
      K /= tmp;
    }
    cnt /= N;
    for (int j = 0; j < cnt; j++) {
      ans *= tmp;
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;

int main() {
  ll N, K, ans = 1;
  cin >> N >> K;
  if (N == 1) {
    cout << K << endl;
    return 0;
  }

  for (int i = 2; i <= sqrt(K); i++) {
    int cnt = 0;
    ll tmp = i;
    while (K % tmp == 0) {
      cnt++;
      K /= tmp;
    }
    cnt /= N;
    for (int j = 0; j < cnt; j++) {
      ans *= tmp;
    }
  }
  cout << ans << endl;
}
Problem p03196 (C++)

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

int main() {
  long long n, p, ans{1};
  scanf("%lld%lld", &n, &p);
  for (int i = 2; i * i <= p; i++) {
    if (p % i)
      continue;
    int tmp{};
    while (!(p % i)) {
      p /= i;
      tmp++;
    }
    tmp /= n;
    for (int j = 0; j < tmp; j++)
      ans *= i;
  }
  if (n == 1)
    ans *= p;
  printf("%lld\n", ans);

  return 0;
}

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

int main() {
  long long n, p, ans{1};
  scanf("%lld%lld", &n, &p);
  for (long long i = 2; i * i <= p; i++) {
    if (p % i)
      continue;
    int tmp{};
    while (!(p % i)) {
      p /= i;
      tmp++;
    }
    tmp /= n;
    for (int j = 0; j < tmp; j++)
      ans *= i;
  }
  if (n == 1)
    ans *= p;
  printf("%lld\n", ans);

  return 0;
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007

int main() {
  ll n, p;
  cin >> n >> p;
  if (n == 1) {
    cout << p;
    return 0;
  }
  ll ans = 1;
  for (int i = 2; i * i <= p; i += 2) {
    ll cnt = 0;
    while (p % i == 0) {
      cnt++;
      p /= i;
    }
    if (cnt != 0) {
      cnt /= n;
      ans *= pow(i, cnt);
    }
    if (i == 2) {
      i = 1;
    }
  }
  cout << ans;
  // your code goes here
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007

int main() {
  ll n, p;
  cin >> n >> p;
  if (n == 1) {
    cout << p;
    return 0;
  }
  ll ans = 1;
  for (ll i = 2; i * i <= p; i += 2) {
    ll cnt = 0;
    while (p % i == 0) {
      cnt++;
      p /= i;
    }
    if (cnt != 0) {
      cnt /= n;
      ans *= pow(i, cnt);
    }
    if (i == 2) {
      i = 1;
    }
  }
  cout << ans;
  // your code goes here
  return 0;
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define int long long
signed main() {
  int n, p;
  cin >> n >> p;
  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  int ans = 1;
  for (int i = 2;; i++) {
    int w = 1;
    for (int j = 0; j < n; j++)
      w *= i;
    if (p < w)
      break;
    if (!(p % w))
      ans = i;
  }
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define int long long
signed main() {
  int n, p;
  cin >> n >> p;
  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  if (n > 50) {
    cout << 1 << endl;
    return 0;
  }
  int ans = 1;
  for (int i = 2;; i++) {
    int w = 1;
    for (int j = 0; j < n; j++)
      w *= i;
    if (p < w)
      break;
    if (!(p % w))
      ans = i;
  }
  cout << ans << endl;
}
Problem p03196 (C++)

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

int main() {
  ll n, p;
  std::cin >> n >> p;
  unordered_map<ll, ll> in;

  ll rem = p;
  for (int i = 2; i <= sqrt(p); i++) {
    while (rem % i == 0) {
      rem /= i;
      in[i]++;
    }
  }
  for (int i = 2; i <= rem; i++) {
    while (rem % i == 0) {
      rem /= i;
      in[i]++;
    }
  }
  ll result = 1;
  for (auto i : in) {
    result *= (ll)pow(i.first, (ll)(i.second / n));
  }
  std::cout << result << std::endl;
}


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

int main() {
  ll n, p;
  std::cin >> n >> p;
  unordered_map<ll, ll> in;

  ll rem = p;
  for (int i = 2; i <= sqrt(p); i++) {
    while (rem % i == 0) {
      rem /= i;
      in[i]++;
    }
  }
  in[rem]++;

  ll result = 1;
  for (auto i : in) {
    result *= (ll)pow(i.first, (ll)(i.second / n));
  }
  std::cout << result << std::endl;
}
Problem p03196 (C++)

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

using namespace std;

typedef long long lint;

lint n, p;

lint rez;

int main() {
  rez = 1;
  cin >> n >> p;

  if (n == 1) {
    cout << p << "\n";

    return 0;
  }

  for (int i = 2; i * i <= p; i++) {
    int x = 0;
    while (p % i == 0)
      x++, p /= i;

    rez = rez * pow(i, x / n);
  }

  cout << rez << "\n";

  return 0;
}


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

using namespace std;

typedef long long lint;

lint n, p;

lint rez;

int main() {
  rez = 1;
  cin >> n >> p;

  if (n == 1) {
    cout << p << "\n";

    return 0;
  }

  for (int i = 2; 1LL * i * i <= p; i++) {
    int x = 0;
    while (p % i == 0)
      x++, p /= i;

    rez = rez * pow(i, x / n);
  }

  cout << rez << "\n";

  return 0;
}
Problem p03196 (C++)

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

typedef long long ll;

ll solve(ll N, ll P) {
  if (N == 1)
    return P;

  double x = powl(P, 1.0 / N);
  if (x < 2.0)
    return 1;

  // x >= 2
  int d = (int)ceil(x);
  for (ll n = d; n >= 1; --n) {
    int cnt = 0;
    ll y = P;
    while (y % n == 0) {
      ++cnt;
      y /= n;
    }
    if (cnt >= N)
      return n;
  }
  return 1;
}

int main() {
  ll N, P;
  cin >> N >> P;
  cout << solve(N, P) << endl;
  return 0;
}


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

typedef long long ll;

ll solve(ll N, ll P) {
  if (N == 1)
    return P;

  double x = powl(P, 1.0 / N);
  if (x < 2.0)
    return 1;

  // x >= 2
  int d = (int)ceil(x);
  for (ll n = d; n >= 2; --n) {
    int cnt = 0;
    ll y = P;
    while (y % n == 0) {
      ++cnt;
      y /= n;
    }
    if (cnt >= N)
      return n;
  }
  return 1;
}

int main() {
  ll N, P;
  cin >> N >> P;
  cout << solve(N, P) << endl;
  return 0;
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 1;
  if (n == 1) {
    cout << k;
    return 0;
  }
  for (int i = 2; i * i <= k; i += 2) {
    ll cnt = 0;
    while (k % i == 0) {
      cnt++;
      k /= i;
    }
    if (cnt != 0) {
      cnt = cnt / n;
      ans *= pow(i, cnt);
    }
    if (i == 2) {
      i--;
    }
  }
  cout << ans;
  // your code goes here
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 1;
  if (n == 1) {
    cout << k;
    return 0;
  }
  for (ll i = 2; i * i <= k; i += 2) {
    ll cnt = 0;
    while (k % i == 0) {
      cnt++;
      k /= i;
    }
    if (cnt != 0) {
      cnt = cnt / n;
      ans *= pow(i, cnt);
    }
    if (i == 2) {
      i--;
    }
  }
  cout << ans;
  // your code goes here
  return 0;
}
Problem p03196 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define PI acos(-1)
#define fast_io                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
ll mod = 1e9 + 7;

int main() {
  fast_io

      ll n,
      p;
  cin >> n >> p;
  ll ans = 1;

  for (int i = 2; i * i <= p; i++) {
    int num = 0;
    while (p % i == 0) {
      num++;
      p /= i;
    }
    int cnt = num / n;
    for (int j = 0; j < cnt; j++)
      ans *= i;
  }
  if (n == 1)
    ans *= p;
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define PI acos(-1)
#define fast_io                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
ll mod = 1e9 + 7;

int main() {
  fast_io

      ll n,
      p;
  cin >> n >> p;
  ll ans = 1;

  for (ll i = 2; i * i <= p; i++) {
    int num = 0;
    while (p % i == 0) {
      num++;
      p /= i;
    }
    int cnt = num / n;
    for (int j = 0; j < cnt; j++)
      ans *= i;
  }
  if (n == 1)
    ans *= p;
  cout << ans << endl;
  return 0;
}
Problem p03196 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
map<long long, long long> mp;
int main() {
  long long n, p;
  cin >> n >> p;
  set<long long> s;
  long long P = p;
  vector<int> v;
  for (long long i = 2; i * i <= P; i++) {
    if (P % i == 0) {
      while (p && p % i == 0) {
        p /= i;
        s.insert(i);
        mp[i]++;
      }
      v.push_back(P / i);
    }
  }
  for (int i = 0; i < v.size(); i++) {
    while (p && p % v[i] == 0) {
      p /= v[i];
      s.insert(v[i]);
      mp[v[i]]++;
    }
  }
  if (s.size() == 0) {
    s.insert(P);
    mp[P]++;
  }
  long long cnt = 1;
  for (set<long long>::iterator it = s.begin(); it != s.end(); it++) {
    if (mp[*it] >= n) {
      for (int j = 0; j < mp[*it] / n; j++)
        cnt *= *it;
    }
  }
  cout << cnt << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
map<long long, long long> mp;
int main() {
  long long n, p;
  cin >> n >> p;
  set<long long> s;
  long long P = p;
  vector<long long> v;
  for (long long i = 2; i * i <= P; i++) {
    if (P % i == 0) {
      while (p && p % i == 0) {
        p /= i;
        s.insert(i);
        mp[i]++;
      }
      v.push_back(P / i);
    }
  }
  for (int i = 0; i < v.size(); i++) {
    while (p && p % v[i] == 0) {
      p /= v[i];
      s.insert(v[i]);
      mp[v[i]]++;
    }
  }
  if (s.size() == 0) {
    s.insert(P);
    mp[P]++;
  }
  long long cnt = 1;
  for (set<long long>::iterator it = s.begin(); it != s.end(); it++) {
    if (mp[*it] >= n) {
      for (int j = 0; j < mp[*it] / n; j++)
        cnt *= *it;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p03196 (C++)

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task ""

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 5;

map<ll, int> ma;
ll N, P;

signed main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("A.INP", "r")) {
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  }
  if (fopen(Task ".INP", "r")) {
    freopen(Task ".INP", "r", stdin);
    freopen(Task ".OUT", "w", stdout);
  }
  cin >> N >> P;
  for (int i = 2; i * i <= P; ++i) {
    while (P % i == 0) {
      ma[i]++;
      P /= i;
    }
  }
  if (P != 1)
    ma[P]++;
  ll res = 1;
  for (auto it : ma) {
    int cnt = it.se / N;
    while (cnt--) {
      res *= it.fi;
    }
  }
  cout << res << '\n';
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task ""

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 5;

map<ll, int> ma;
ll N, P;

signed main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("A.INP", "r")) {
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  }
  if (fopen(Task ".INP", "r")) {
    freopen(Task ".INP", "r", stdin);
    freopen(Task ".OUT", "w", stdout);
  }
  cin >> N >> P;
  for (int i = 2; 1ll * i * i <= P; ++i) {
    while (P % i == 0) {
      ma[i]++;
      P /= i;
    }
  }
  if (P != 1)
    ma[P]++;
  ll res = 1;
  for (auto it : ma) {
    int cnt = it.se / N;
    while (cnt--) {
      res *= it.fi;
    }
  }
  cout << res << '\n';
}