Problem:


Score : 300 points

Problem Statement

There are N integers a_1, a_2, ..., a_N not less than 1.
The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P.

Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.

Constraints

1 \leq N \leq 10^{12}

1 \leq P \leq 10^{12}

Input

Input is given from Standard Input in the following format:

N P

Output

Print the answer.

Sample Input 1

3 24

Sample Output 1

2

The greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.

Sample Input 2

5 1

Sample Output 2

1

As a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.

Sample Input 3

1 111

Sample Output 3

111

Sample Input 4

4 972439611840

Sample Output 4

206



Sample input:
3 24


Sample output:
2

Submission status: Runtime Error

Solution code:
import math
import random
import collections

length, num = list(map(int, input().split()))

# def make_seed():
#     global length
#     seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
#     for i in range(len(seed_primes)):
#         seed_primes[i] = pow(seed_primes[i], length)
#     return seed_primes
#
#
# class Prime:
#     seed_primes = make_seed()
#     # print(seed_primes)
#
#     def is_prime(self, n):
#         """
#         prime test (hybrid)
#
#         see also: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369
#
#         :param n:
#         :return: boolean
#         """
#         is_prime_common = self.is_prime_common(n)
#         if is_prime_common is not None:
#             return is_prime_common
#
#         if n < 2000000:
#             return self.is_prime_brute_force(n)
#         else:
#             return self.is_prime_miller_rabin(n)
#
#     def is_prime_common(self, n):
#         if n == 1: return False
#         if n in Prime.seed_primes: return True
#         if any(map(lambda x: n % x == 0, self.seed_primes)): return False
#
#     def is_prime_brute_force(self, n):
#         """
#         brute force prime test
#         use with is_prime_common if you want to skip seed_primes
#
#         :param n:
#         :return: boolean
#         """
#         for k in range(2, int(math.sqrt(n)) + 1):
#             if n % k == 0:
#                 return False
#         return True
#
#     def is_prime_miller_rabin(self, n):
#         """
#         miller rabin prime test
#         use with is_prime_common if you want to skip seed_primes
#
#         see also
#             algorithm: https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
#             implementation: https://qiita.com/srtk86/items/609737d50c9ef5f5dc59
#             improvement: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369
#
#         :param n:
#         :return: boolean
#         """
#
#         d = n - 1
#         while d & 1 == 0:
#             d >>= 1
#
#         # use one of these lines / upper is more efficient.
#         witnesses = self.get_witnesses(n)
#         # witnesses = [random.randint(1, n - 1) for _ in range(100)]
#
#         for w in witnesses:
#             y = pow(w, d, n)
#
#             while d != n - 1 and y != 1 and y != n - 1:
#                 y = (y * y) % n
#                 d <<= 1
#
#             if y != n - 1 and d & 1 == 0:
#                 return False
#
#         return True
#
#     def get_witnesses(self, num):
#         def _get_range(num):
#             if num < 2047:
#                 return 1
#             if num < 1373653:
#                 return 2
#             if num < 25326001:
#                 return 3
#             if num < 3215031751:
#                 return 4
#             if num < 2152302898747:
#                 return 5
#             # if num < 3474749660383:
#             #     return 6
#             # if num < 341550071728321:
#             #     return 7
#             # if num < 3825123056546413051:
#             #     return 9
#             return 12
#         # print(self.seed_primes[:_get_range(num)])
#
#         return self.seed_primes[:_get_range(num)]
#
#     def gcd(self, a, b):
#         if a < b:
#             return self.gcd(b, a)
#         if b == 0:
#             return a
#         while b:
#             a, b = b, a % b
#         return a
#
#     @staticmethod
#     def f(x, n, seed):
#         """
#         pseudo prime generator
#         :param x:
#         :param n:
#         :param seed:
#         :return: pseudo prime
#         """
#         p = Prime.seed_primes[seed % len(Prime.seed_primes)]
#         return (p * x + seed) % n
#
#     def find_factor(self, n, seed=1):
#         global length
#         """
#         find one of factor of n
#         this function is based to Pollard's rho algorithm
#
#         see also
#             algorithm: https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm
#             implementation: https://qiita.com/gushwell/items/561afde2e00bf3380c98
#
#         :param n:
#         :param seed:
#         :return: factor
#         """
#         if self.is_prime(n):
#             return n
#
#         x, y, d = 2, 2, 1
#         count = 0
#         while d == 1:
#             count += 1
#             x = self.f(x, n, seed)
#             y = self.f(self.f(y, n, seed), n, seed)
#             d = self.gcd(abs(x - y), n)
#
#         d = pow(d, length)
#
#         if d == n:
#             return self.find_factor(n, seed+1)
#         return self.find_factor(d)
#
#     def find_factors(self, n):
#         primes = {}
#         if self.is_prime(n):
#             primes[n] = 1
#             return primes
#
#         while n > 1:
#             factor = self.find_factor(n)
#             print(factor)
#
#             primes.setdefault(factor, 0)
#             primes[factor] += 1
#
#             n //= factor
#
#         print(primes)
#
#         return primes

# def make_seed(num):
#     global seed_primes
#     for i in range(len(seed_primes)):
#         seed_primes[i] = pow(seed_primes[i], num)

#nの素因数分解(O(n**0.5)
def prime_factor(n):
    ass = collections.defaultdict(int)
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            # ass.append(i)
            ass[i] += 1
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

if __name__ == '__main__':

    # make_seed(num)
    # prime = Prime()
    # soinnsuu = prime.find_factors(num)
    soinnsuu = prime_factor(num)
    ans = 1
    # print(soinnsuu)
    for data in soinnsuu.keys():
        if soinnsuu[data] >= length:
           ans *= data
        # if soinnsuu[data] >= length:
        # ans *= data
    print(ans)

Submission status: Runtime Error

Solution code:
q = input().split()
n = int(q[0])
p = int(q[1])
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
pl = primes(p)
a = 1
for i in range(len(pl)):
    prime = int(pl[i])
    if prime**n > p:
        break
    if p % prime**n == 0:
        a *= prime
print(a)

Submission status: Runtime Error

Solution code:
import math
N, P = map(int, input().split())
ans=1
yakusu = []
for i in range(1,int(math.sqrt(P))+1):
    if P%i == 0:
        yakusu.append(i)
        yakusu.append(P/i)
yakusu.sort()
for j in yakusu:
    if P/(j**N) in yakusu:
        ans=int(j)
print(ans)

Submission status: Runtime Error

Solution code:
from fraction import gcd

n, p = list(map(int, input().split()))

def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

if p == 1:
    print(p)
    exit(1)
fact = prime_factors(p)
i = 0
while 1:
    if len(fact) == n:
        break
    if i >= len(fact):
        i = 0
    fact[i] = fact[i]*fact[-1]
    fact.pop()
    i += 1
print(min(fact))

Submission status: Runtime Error

Solution code:
from math import gcd

n, p = list(map(int, input().split()))

def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

if p == 1:
    print(p)
    exit(1)
fact = prime_factors(p)
i = 0
while 1:
    if len(fact) == n:
        break
    if i >= len(fact):
        i = 0
    fact[i] = fact[i]*fact[-1]
    fact.pop()
    i += 1
print(min(fact))

Submission status: Runtime Error

Solution code:
n, p = map(int, input().split())
def pf (x,p,a):
    if p * p > x:
        if n == 1:
            a = a*x
        return a
    c = 0
    while(x % p == 0):
        x = x//p
        c += 1
    if c != 0:
        a = a * (p**(c//n))
    return pf(x,p+1,a)
print(pf(p,2,1))

Submission status: Runtime Error

Solution code:
N, P = map(int, input().split())
Y = [i for i in range(1,int(P**(1/N))+1) if P % i == 0]
m = int(P**(1/N))
while True:
  if P % m == 0:
    x = m**N
    if P % x == 0:
      if P / x in Y:
        break
  m -= 1
print(m)

Submission status: Runtime Error

Solution code:
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
if p == 1:
    print(1)
    exit()
for i in range(2,int(p**(1/n)+2)):
    if p%(i**n)==0:
        ans = i
print(ans)

Submission status: Runtime Error

Solution code:
N, P = map(int, input().split())
Y = [i for i in range(1,int(P**(1/N))+1) if P % i == 0]
m = int(P**(1/N))
while True:
  if P % m == 0:
    x = m**N
    if P % x == 0 and P / x in Y:
      break
  m -= 1
print(m)

Submission status: Runtime Error

Solution code:
import math
import functools
import collections
N, P = map(int, input().split())


def factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors


li = factors(P)
li2 = []
if li:
    for i in range(N):
        li2.append(li[i] * li[-i-1])
    print(functools.reduce(math.gcd, li2))
else:
    print(1)

Submission status: Runtime Error

Solution code:
n,p = map(int,input().split())
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
a = primes(int(p**(1/n)))
res = 1
for j in range(len(a)):
 q = p
 if q%(a[j]**n) == 0:
  c = 0
  while q%(a[j]**n) == 0:
   q = q//(a[j]**n)
   c += 1
  res = res*(a[j]**c)
print(res)

Submission status: Runtime Error

Solution code:
n,p = map(int,input().split())
ans = 1
c = [0] * (p+1)
for i in range(2,p+1):
 while p % i == 0:
  p //= i
  c[i] += 1
for i in range(p+1)
 if c[i] % n == 0:
   ans *= i // n
print(ans)

Submission status: Runtime Error

Solution code:
import sympy
N, P = map(int, input().split())
A = sympy.factorint(P)
c = 1
for k, v in A.items():
    d = v // N
    if d >= 1:
        c = c * (k ** d)

print(c)

Submission status: Runtime Error

Solution code:
n, p = map(int, input().split())

import math

if p == 1:
    print(1)
    exit(0)

if n == 1:
    print(p)
    exit(0)


def factor(m):
    q = m
    r = []
    i = 2
    while i * i <= m:
        if q % i:
            i += 1
        else:
            r.append(i)
            q //= i
    if q != 1:
        r.append(q)

    return r



np = factor(p)


import collections

c = collections.Counter(np)
cc = []

ans = 0

for k, v in c.items():
    if v >= n:
        cc.append(k)


from functools import reduce
ans = reduce(lambda x, y:x*y, cc)

print(ans)

Submission status: Runtime Error

Solution code:
n,p = map(int,input().split())
ans = 1
c = [0] * p+1
for i in range(2,p+1):
 while p % i == 0:
  p //= i
  c[i] += 1
for i in range(p+1)
 if c[i] % n == 0:
   ans *= i // n
print(ans)

Submission status: Runtime Error

Solution code:
n,p = map(int,input().split())
ans = 1
c = [0] * n+1
for i in range(2,n+1):
 while p % i == 0:
  p //= i
  c[i] += 1
for i in range(n)
 if c[i] % n == 0:
   ans *= i // n
print(ans)

Submission status: Runtime Error

Solution code:
import math
N, P = map(int, input().split())
yakusu = []
for i in range(1,int(math.sqrt(P))+1):
    if P%i == 0:
        yakusu.append(i)
        yakusu.append(N/i)
for j in yakusu:
    if P/(j**N) in yakusu:
        ans=j
print(ans)

Submission status: Runtime Error

Solution code:
N,P = list(map(int,input().split()))
mylist = []
roop  = int((10**12)**(1/N))

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

Primelis = primes(roop)
if N ==1:
    print(P)
else:
    for i in Primelis:
        if P%(i**N)==0:
            mylist.append(i)
            P = P/(i**N)
    ans = 1
    L = len(mylist)
    for i in range(L):
        ans = ans*mylist[i]
    print(ans)

Submission status: Runtime Error

Solution code:
#encoding:utf-8

import math
import sympy

N,P = map(int,input().split())

facters = sympy.factorint(P)

ans = 1
for key in facters.keys():
    if facters[key]/N >= 1:
        ans *= key**(facters[key]//N)
print(ans)

Submission status: Runtime Error

Solution code:
n, p = map(int, input().split())
dic = {}

for i in [2] + list(range(3,p+1,2)):
    while p%i==0:
        if i not in dic.keys():
            dic[i] = 0
        p = p// i
        dic[i] += 1
        
    if p==1:
        break

out=1
for i in dic.keys():
    if dic[i] >=n:
        out *= i**(dic[i]//n)

print(out)

Submission status: Runtime Error

Solution code:
import math
n,p = list(map(int, input().split()))
m = int(math.sqrt(p))
if n == 1:
  print(p)
elif p == 1:
  print(p)
else:
  d = []
  k = 0
  for i in range(2, m+1):
    if not i in d:
      k = i
      while p % (k**n) == 0:
        d.append(k)
        k = k**2
  print(max(d))

Submission status: Runtime Error

Solution code:
n, p = map(int, input().split())

b = [False] * 1000001
prime = []
b[1] = True

for i in range(2, 1000001):
    if b[i]:
        continue
    k = i + i
    while k < 1000001:
        b[k] = True
        k += i

    prime.append(i)

prime_num = [0] * len(prime)

pp = []

for i in range(len(prime)):
    while p % prime[i] == 0:
        pp.append(prime[i])
        prime_num[i] += 1
        p //= prime[i]

if len(pp) == 0:
    print(1)
    exit()

idx = []
for i in range(len(prime) - 1, -1, -1):
    if prime_num[i] >= n:
        idx.append(i)
        break

for i in range(idx[0] - 1, -1, -1):
    if prime_num[i] >= prime_num[idx[0]]:
        idx.append(i)

ans = 1
for x in idx:
    ans *= prime[x]

print(ans)

Submission status: Runtime Error

Solution code:
n, p = map(int, input().split())
def pf (x,p,a):
    if p * p > x:
        a.append([x,1])
        return a
    c = 0
    while(x % p == 0):
        x = x//p
        c += 1
    if c != 0:
        a.append([p,c])
    return pf(x,p+1,a)
factors = pf(p,2,[])
ret = 1
for prime, exp in factors:
    ret = ret * (prime**(exp//n))
print(ret)

Submission status: Runtime Error

Solution code:
from sys import stdin
from functools import reduce
from itertools import combinations
from operator import mul
import platform
ver = platform.python_version_tuple()
if int(ver[1]) < 5:
    from fractions import gcd
else:
    from math import gcd

def primeFactors(n):
    factors = []
    apnd = factors.append
    while n >= 4:
        if n % 2:
            break
        else:
            n //= 2
            apnd(2)
    i = 3
    while n >= i * i:
        if n % i:
            i += 2
        else:
            n //= i
            apnd(i)
    apnd(n)
    return factors

def main():
    N, P = map(int, input().split())

    if N == 1:
        print(P)
        return

    an = primeFactors(P)
    if len(an) < N:
        an += [1] * (N - len(an))
    ans = 1
    for n in combinations(an, N - 1):
        x = P // reduce(mul, n)
        ans = max(ans, x)
    print(ans)

input = lambda: stdin.readline()
main()

Submission status: Runtime Error

Solution code:
def sieveOfEratosthenes(N, s): 
    prime = [False] * (N+1) 
    for i in range(2, N+1, 2):  
        s[i] = 2
    for i in range(3, N+1, 2): 
        if (prime[i] == False):  
            s[i] = i 
            for j in range(i, int(N / i) + 1, 2): 
                if (prime[i*j] == False): 
                    prime[i*j] = True
                    s[i * j] = i 
  
def generatePrimeFactors(N, n): 
    s = [0] * (N+1) 
    sieveOfEratosthenes(N, s) 
    curr = s[N] 
    cnt = 1 
    ans = 1
    while (N > 1): 
        N //= s[N] 
        if (curr == s[N]): 
            cnt += 1
            continue
        ans *= curr**(cnt //n)
        curr = s[N] 
        cnt = 1
    return ans

#print(generatePrimeFactors(28))
n, p = [int(i) for i in input().split()]
print(generatePrimeFactors(p,n))

Submission status: Runtime Error

Solution code:
N,P=[input().split()]
i=2
ans = 1
c=0
while P>1:
  if P%i==0:
    P//=i
    c+=1
    if c==N:
      ans*=i
      c=0
  else:
    c=0
    i+=1

print(ans)

Submission status: Runtime Error

Solution code:
N,P=map(int,input().split())
if N==1:
    print(P)
    exit()
else:
    ans=1
    for i in range(2,10**6):
        if P<i:
            print(ans)
            exit()
        while P%i==0:
            if P%(i**N)==0:
                ans*=i
                #print(P,i)
                P=P//(i**N)
            else:
                P=P//i
    print(ans)

Submission status: Runtime Error

Solution code:
N,P = map(int,input().split(" "))
def pow_r(x, n):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r(x ** 2, n // 2)
    else:  # standard case ② n is odd
        return x * pow_r(x ** 2, (n - 1) // 2)
ans = 1
for i in range(P):
    noli = pow_r(i,N)
    if P%noli == 0:
        ans = i+2
    elif noli > P:
        i+=P
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
a = [0]*N
for i in range(N):
    a[i] = int(input())

def isAllOdd (a):
    for i in a:
        if i % 2 == 0:
            return False
    return True

def isAllEven (a):
    for i in a:
        if i % 2 == 1:
            return False
    return True

ans = 'first'

if isAllOdd(a) or isAllEven(a):
    ans = 'second' 
    
print(ans)

Submission status: Runtime Error

Solution code:
n,P=map(int,input().split())
A=[]
for i in range(2,10**6+1):
  if P%(i**n)==0:
    A.append(i)
for i in range(2,10**3+1):
  if P%(i**(2*n))==0:
    A.append(i)
for i in range(2,101):
  if P%(i**(3*n))==0:
    A.append(i)
for i in range(2,33):
  if P%(i**(4*n))==0:
    A.append(i)
for i in range(2,30):
  if P%(i**(5*n))==0:
    A.append(i)




if P==10**12:
  A.append(10)
print(max(A))

Submission status: Runtime Error

Solution code:
#encoding:utf-8

import math
import sympy

N,P = map(int,input().split())

facters = sympy.factorint(P)

ans = 1
for key in facters.keys():
    if facters[key]/N >= 1:
        ans *= key**(facters[key]//N)

print(ans)

Submission status: Runtime Error

Solution code:
n, p = map(int, input().split())
import sympy
import math
fac = sympy.factorint(p)
result = 1
for i,j in fac.items():
  result *= i **math.floor(j/n)
print(result)

Submission status: Runtime Error

Solution code:
N, P = [int(x) for x in input().split()]

import types, math, operator
import numpy as np
from math import sqrt
from collections import Counter
from itertools import product
from functools import reduce
class PrimeUtils:
    @staticmethod
    def _has_numpy():
        g = globals()
        m = g.get('np')
        if m is not None and isinstance(m, types.ModuleType):
            return  m.__name__ == 'numpy'
        return False
    @staticmethod
    def _primes_sieve_pp(n):
        sieve = [True] * (n + 1)
        for i in range(2, int(sqrt(n)) + 1):
            if sieve[i]:
                for j in range(i * i, n + 1, i):
                    sieve[j] = False
        return [i for i, x in enumerate(sieve[2:], 2) if x]
    @staticmethod
    def _primes_sieve_np(n):
        sieve = np.ones(n + 1, np.bool)
        sieve[0] = sieve[1] = False
        for i, v in enumerate(sieve[2:int(sqrt(n)) + 1], 2):
            if v: sieve[i*i::i] = False
        return np.nonzero(sieve)[0]
    @staticmethod
    def _primes_sieve_np_fast(n):
        n += 1
        sieve = np.ones(n//3 + (n%6 == 2), dtype=np.bool)
        check_upper = int(sqrt(n)) // 3
        for i, v in enumerate(sieve[1:check_upper + 1], 1):
            if v:
                k = (3*i + 1) | 1
                sieve[k* k           //3::2*k] = False
                sieve[k*(k-2*(i&1)+4)//3::2*k] = False
        sieve[0] = False
        return np.r_[2,3,((3*np.nonzero(sieve)[0] + 1)|1)]
    @classmethod
    def primes_sieve(cls, n):
        if cls._has_numpy():
            return cls._primes_sieve_np_fast(n)
        else:
            return cls._primes_sieve_pp(n)
    # Prime Factor Decomposition
    @classmethod
    def pfd(cls, n):
        primes = cls.primes_sieve(math.floor(n ** (1/N)))

        factors = []
        cur = n
        for p in primes:
            while True:
                div, rem = divmod(cur, p)
                if rem == 0:
                    factors.append(p)
                    cur = div
                else:
                    break
        # assert(cur == 1)
        return factors
    # List up aliquots
    @classmethod
    def aliquots(cls, n):
        pf = cls.pfd(n)
        pfc = Counter(pf)
        ppv = [[pow(p, i) for i in range(n+1)] for p,n in pfc.items()]
        if not ppv:
            return (1,)
        else:
            return map(lambda x: reduce(operator.imul, x), product(*ppv))

from collections import Counter
c = Counter(PrimeUtils.pfd(P))
import functools, operator, itertools
print(functools.reduce(operator.imul, itertools.chain([1], map(lambda x: x[0] ** (x[1]//N), filter(lambda x: x[1] >= N, c.items())))))

Submission status: Runtime Error

Solution code:
n, p = map(int, input().split())

import math


def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    
    return factors

np = prime_factors(p)


import collections

c = collections.Counter(np)
cc = []

ans = 0

for k, v in c.items():
    if v >= n:
        cc.append(k)

map(int, cc)

from functools import reduce
ans = reduce(lambda x, y:x*y, cc)

print(ans)

Submission status: Runtime Error

Solution code:
def sieveOfEratosthenes(N, s): 
    prime = [False] * (N+1) 
    for i in range(2, N+1, 2):  
        s[i] = 2
    for i in range(3, N+1, 2): 
        if (prime[i] == False):  
            s[i] = i 
            for j in range(i, int(N / i) + 1, 2): 
                if (prime[i*j] == False): 
                    prime[i*j] = True
                    s[i * j] = i 
  
def generatePrimeFactors(N): 
    s = [0] * (N+1) 
  
    sieveOfEratosthenes(N, s) 
    curr = s[N] 
    cnt = 1 
    factordict = dict()
    while (N > 1): 
        N //= s[N] 
        if (curr == s[N]): 
            cnt += 1
            continue
        factordict[curr] = cnt
        curr = s[N] 
        cnt = 1
    return factordict

#print(generatePrimeFactors(28))
n, p = [int(i) for i in input().split()]
factordict = generatePrimeFactors(p)
ans = 1
for i in factordict:
    ans *= i **(factordict[i]//n)
print(ans)

Submission status: Runtime Error

Solution code:
ans = 1
P_tmp = P
for p in range(2, P):
    if P_tmp % (p ** N) > 0: continue
    else:
        for i_p in range(1, P):
            if P_tmp % (p ** (N * (i_p + 1))) > 0: break
        P_tmp = P_tmp // (p ** (N * i_p))
        ans = ans * (p ** i_p)
        if P_tmp < ((p + 1) ** N): break

print(ans)

Submission status: Runtime Error

Solution code:
n, p = map(int, input().split())

import math

if p == 1:
    print(1)
    exit(0)

if n == 1:
    print(p)
    exit(0)


def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    
    return factors

np = prime_factors(p)


import collections

c = collections.Counter(np)
cv = c.values

cc = []

ans = 0

for k, v in c.items():
    if v >= n:
        cc.append(k)

from functools import reduce
ans = reduce(lambda x, y:x*y, cc)

print(ans)

Submission status: Runtime Error

Solution code:
import sympy
a = sympy.factorint(2016)
print(a)

Submission status: Runtime Error

Solution code:
N = int(input())
s = sum(int(input()) for i in range(N))

if s & 1:
  print('first')
else:
  print('second')

Submission status: Runtime Error

Solution code:
n,p=map(int,input().split())
for i in range(2,1000001):
  if p%(i**n)==0:
    x=i
print(x)

Submission status: Runtime Error

Solution code:
n,p=map(int,input().split())
for i in range(1,100000):
  if p%(i**n)==0:
    x=i
print(x)​

Submission status: Runtime Error

Solution code:
import sympy

n, p = map(int, input().split())
a = sympy.factorint(p)
ans = 1
for i, j in a.items():
    if j >= n:
        ans *= i
print(ans)