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

Solution (Python):
def factorization(n):
    i = 2
    L = []
    num = n
    while i**2 <= n:
        c = 0
        while num%i == 0:
           num //= i
           c += 1 
        
        if c > 0:
            L.append((i, c))
        i += 1

    if num > 1:
        L.append((n, 1))
    return L

N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()
facts = factorization(P)
ans = 1
for p, c in facts:
    a = c//N
    ans *= p**a
print(ans)

Solution (Python):

from collections import defaultdict
from math import sqrt,floor
num,product = map(int,input().split())
cnt = int(sqrt(product) + 2)
dd = defaultdict(int)

for i in range(2,cnt):
    if product % i == 0:
        a = 0
        while product % i == 0:
            a += 1
            product = product // i
        dd[i] = a
if product != 1:
    dd[product] =  1
ans = 1
for p,n in dd.items():
    ans *= pow(p,floor(n/num))
print(ans)

Solution (Python):
N,P = map(int,input().split())




def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i ==0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr

l = factorization(P)

ans = []
for i in range(len(l)):
    if l[i][1] >= N:
        ans.append(l[i][0]**(l[i][1]//N))
if ans:
    k = 1
    for i in ans:
        k *= i
    print(k)
else:
    print(1)

Solution (Python):
'''
Created on 2020/08/26

@author: harurun
'''
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

def main():
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  N,P=map(int,pin().split())
  l=factorize(P)
  d=list(set(l))
  ans=1
  for i in d:
    t=l.count(i)
    if t>=N:
      ans*=i**(int(t/N))
  print(ans)
  return

main()

Solution (Python):
import math
n,p=map(int,input().split())
p_sqrt=int(math.sqrt(p))
ans=1

for i in range(2,p_sqrt+1):
  cnt=0
  while p%i==0:
    p//=i
    cnt+=1
  ans*=i**(cnt//n)

ans*=p**(1//n)
print(ans)

Solution (Python):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N,K=map(int,input().split())
L=factorization(K)
ans=1
for i in L:
  ans*=i[0]**(i[1]//N)
print(ans)

Solution (Python):
import sys
import math
n,p=map(int,input().split())
if n==1:
  print(p)
  sys.exit()
soinsu=dict()
i=2
mx = math.ceil(p ** (1.0/n))+1
while i < mx:
  if p==1:
    break
  if p % i==0:
    p = p//i
    if i in soinsu:
      soinsu[i] += 1
    else:
      soinsu[i] = 1
  else:
    i += 1

ans=1
for k,v in soinsu.items():
  if v//n > 0:
    ans *= k ** (v//n)
    
print(ans)

Solution (Python):
from operator import itemgetter
from itertools import *
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction
import sys

sys.setrecursionlimit(10 ** 6)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

n,p=MI()
if n==1:
    print(p)
    exit()
ans=1
for a in range(2,p+1):
    if a**2>p:break
    cnt=0
    while p%a==0:
        cnt+=1
        p//=a
    ans*=a**(cnt//n)
print(ans)

Solution (Python):
def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

def main():
    N, P = map(int, input().split())
    if N == 1:
        print(P)
        exit()
    if P == 1:
        print(1)
        exit()
    A = fctr1(P)
    cnt = 1
    for i, j in A:
        if j >= N:
            cnt *= i ** (j // N)

    print(cnt)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict

n,p = map(int,input().split())
a = 1
d = defaultdict(int)
for i in range(2,10**6+1):
    if p == 1:
        break
    while p%i == 0:
        p //= i
        d[i] += 1
if p>1:
    d[p] += 1
for i,j in d.items():
    if j >= n:
        a *= i**(j//n)
print(a)

Solution (Python):
import heapq
from sys import stdin
input = stdin.readline




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








def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main():
    res = factorization(P)
    ans = 1
    for fac in res:
        p, index = fac[0],fac[1]
        ans *= (p)**(index//N)
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
def prime_factorize(n):
    a=[]
    while n%2 ==0:
        a.append(2)
        n //= 2
    f = 3
    while f*f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n!=1:
        a.append(n)
    return a
n,p = map(int,input().split())
keys_l = []
import collections
c=collections.Counter(prime_factorize(p))


ans = 1
a=1
a_l=[]
for key in c.keys():
    if c[key] >= n:
        
            
               
                
        
        ans *= key**(c[key]//n)
        

print(ans)

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

if n == 1:
    print(p)
else:
    l = 10**6 + 5
    A = [0] * l
    for i in range(2, l):
        while p%i == 0:
            p //= i
            A[i] += 1
        if p == 1:
            break

    

    if sum(A) == 0:
        print(1)
    else:
        ans = 1
        for i in range(l):
            ans *= i ** (A[i]//n)
        print(ans)

Solution (Python):
N,P=map(int,input().split())
l=[]
pf={}
m=P
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
keys=list(pf.keys())
val=list(pf.values())
ans=1
for i in range(len(keys)):
    l.append([keys[i],val[i]])

for i in range(len(l)):
    if l[i][1]>=N:
        ans=ans*pow(l[i][0],l[i][1]//N)
print(ans)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10


def solve():
    n, p = LI()
    def fact(x):
        res = 1
        for i in range(2, int(sqrt(x)) + 3):
            t = 0
            while x % i == 0:
                t += 1
                x //= i
            while t >= n:
                res *= i
                t -= n
        return res
    if n == 1:
        print(p)
        return
    print(fact(p))

    return



if __name__ == '__main__':
    solve()

Solution (Python):
def divisor(i):
    s = []
    for j in range(1, int(i ** (1 / 2)) + 1):
        if i % j == 0:
            s.append(i // j)
            s.append(j)
    return sorted(set(s))

n, p = map(int, input().split())
s = divisor(p)
s.reverse()
ans = 1
for i in s:
    c = i
    m = 0
    if not i * n > p and not i == 1:
        if i % p == 0:
            m = 1
        for _ in range(n - 1):
            if c > p:
                m = 0
                break
            else:
                m = 1
            c = c * i
    if p % c == 0 and m == 1:
        ans = i
        break
print(ans)

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

res = []
for i in range(2, int(pow(p, 0.5)) + 1):
    if p % i == 0:
        ex = 0
        while p % i == 0:
            ex += 1
            p //= i
        res.append([i, ex])
if p != 1:
    res.append([p, 1])

ans = 1
for p in res:
    k = p[1]
    while k:
        if k < n:
            k = 0
        else:
            ans *= p[0]
            k -= n
print(ans)

Solution (Python):
def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b==0:
            n = n//b
            e += 1
        if e > 0:
            fct.append((b,e))
        b,e = b+1,0
    if n > 1:
        fct.append((n,1))
    return fct

n,p = map(int,input().split())
ans = 1
for prime,power in factorize(p):
    ans *= pow(prime,(power//n))
print(ans)

Solution (Python):
def hoge(p):
    ret = {}
    pp = 2
    while pp * pp <= p:
        while p % pp == 0:
            ret[pp] = ret[pp]+1 if pp in ret else 1
            p //= pp
        pp += 1
    if p != 1: ret[p] = 1
    return ret

N,P=map(int,input().split())
if N==1:
    print(P)
elif P==1:
    print(1)
else:
    ans = 1
    ret = hoge(P)
    for p,e in ret.items():
        ans *= max(1, p**(e//N))
    print(ans)

Solution (Python):
N, P=map(int,input().split())
def factorization(n):
  primen = []
  degree = []
  primend = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      primen.append(i)
      degree.append(cnt)
      primend.append([i,cnt])
  if temp!=1:
    primen.append(temp)
    degree.append(1)
    primend.append([temp,1])
  if primen==[]:
    primen.append(n)
    degree.append(1)
    primend.append([n,1])
  return primend

ret = factorization(P)
ans = 1
for pn in ret:
  ans *= pn[0]**(pn[1]//N)
print(ans)

Solution (Python):

import sys


def solve(N: int, P: int):
        
    def divisor(n): 
        i = 1
        table = []
        while i * i <= n:
            if n%i == 0:
                table.append(i)
                table.append(n//i)
            i += 1
        table = sorted(list(set(table)))
        return table

    divisors = divisor(P)

    answer = 1
    if N > 40:
        print(answer)
        return 
    for div in divisors:
        if div**N > P:
            break

        if P%(div**N) == 0:
            answer = div

    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    P = int(next(tokens))  
    solve(N, P)

if __name__ == '__main__':
    main()

Solution (Python):
N, P = map(int, input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ans = 1
for sosuu, cnt in factorization(P):
  ans *= (sosuu ** (cnt//N))
  
print(ans)

Solution (Python):
def prime_factor(n):
    ret = {}
    p = 2
    while p*p <= n:
        while n % p == 0:
            ret[p] = ret.get(p, 0) + 1
            n //= p
        p += 1
    if n != 1: ret[n] = 1
    return ret

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

primes = prime_factor(p)
ans = 1

for p, e in primes.items():
    ans *= max(1, p**(e//n))

print(ans)

Solution (Python):
n,p=map(int,input().split())
if n==1:
    print(p)
    exit()
a=1
for i in range(2,int(p**0.5)+2):
  if p%i==0:
    c=0
    while p%i==0:
      p//=i
      c+=1
    a*=max(i**(c//n),1)
  if p==1:
    break
print(a)

Solution (Python):
def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append((i,c))
            c=0
    if n!=1:
        f.append((n,1))        
    f.sort(reverse=True,key=lambda x:x[1])
    return (f)

def main():

  n,p=map(int,input().split())
  li=fctr1(p)
  ans=1
  for i,j in li:
    ans*=(i**(j//n)) 

  print(ans)
  
main()

Solution (Python):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,p=map(int,input().split())
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        count=0
        while n % i==0:
            count+=1
            n = n//i
        if count!=0:
            ass.append((i,count))
    if n != 1:
        ass.append((n,1))
    return ass

ass=prime_factor(p)
for div,count in ass:
    pro*=div**(count//n)
print(pro)

Solution (Python):
N,P = map(int,input().split())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import collections
import math
c = collections.Counter(prime_factorize(P)) 


ans = 1
for n,k in c.items():
  ans *= n**(math.floor(k/N))
print(ans)

Solution (Python):
INFTY = 10**6
Q = [1 for _ in range(INFTY)]
Q[0]=0
Q[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        Q[j]=0
A = []
for i in range(INFTY):
    if Q[i]==1:
        A.append(i)
N,P = map(int,input().split())
C = {}
for a in A:
    if P%a==0:
        C[a] = 0
        while P%a==0:
            P = P//a
            C[a] += 1
if P>1:
    C[P] = 1
b = 1
for a in C:
    b *= a**(C[a]//N)
print(b)

Solution (Python):
import collections
N,P=map(int,input().split())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c=collections.Counter(prime_factorize(P))
c=list(c.items())
ans=1
for i in range(len(c)):
    ans*=c[i][0]**(c[i][1]//N)
print(ans)

Solution (Python):
from collections import  Counter

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

def fctr1(n):
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

tmp=fctr1(p)

ans=1
for i in range(len(tmp)):
    if tmp[i][1]>=n:
        ans*=(tmp[i][0]**(tmp[i][1]//n))


print(ans)

Solution (Python):
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n,p=map(int,input().split())
c=collections.Counter(prime_factorize(p))
a=list(c.keys())
b=list(c.values())
ans=1
if n==1:print(p)
else:
    for i in range(len(b)):
        c=0
        while b[i]>=n:
            c+=1
            b[i]-=n
        ans*=a[i]**c
    print(ans)

Solution (Python):
from collections import Counter
import sys
sys.setrecursionlimit(1000000)

def solve():
  n,p = (int(i) for i in input().split())
  ans = 1
  if n == 1:
    print(p)
    exit()
  p_dummy = p
  for i in range(2,int(p_dummy**0.5)+4):
    ct = 0
    while p_dummy%i == 0:
      ct += 1
      p_dummy //= i
      if ct >= n:
        ans *= i
        ct -= n
  

  print(ans)
  
solve()

Solution (Python):
N, P = map(int, input().split())
n = P
fs = []
f = 2
while n > 1:
  if f*f > n:
    fs.append(n)
    n = 1
  elif n%f == 0:
    fs.append(f)
    n = n//f
  else:
    f += 1

nfs = {}
for f in fs:
  if f not in nfs: nfs[f] = 0
  nfs[f] += 1
r = 1
for f in nfs:
  n = nfs[f]
  r *= f**(n//N)
print(r)

Solution (Python):
n,p=map(int,input().split());i=2;d={}
while i*i<=p:
 if p%i:i+=1
 else:d[i]=d.get(i,0)+1;p//=i
d[p]=d.get(p,0)+1;a=1
for k,v in d.items():a*=k**(v//n)
print(a)

Solution (Python):
def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
 
 
 
def main():
    n, p = map(int, input().split())
    l = factorize(p)
    ans = 1
    for ll in l:
        if ll[1] >= n:
            ans *= ll[0]**(ll[1]//n)
    print(ans)
 
 
if __name__ == '__main__':
    main()

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

ans = 1
x = int(p ** (1/n))

while x > 1:
    y = x ** n
    if p % y == 0:
        p //= y
        ans *= x
        if p == 1:
            break
    else:
        x -= 1

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

f = []
x = 2
while x*x <= P:
    if P%x == 0:
        f.append(x)
        P //= x
        continue
    x += 1

if P > 1:
    f.append(P)

from collections import Counter
counter = Counter(f)

answer = 1
for p,k in counter.items():
    answer *= p ** (k//N)
print(answer)

Solution (Python):
import math
import collections


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


def trial_division(n):
    
    factor = []
    
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    
    if not factor:
        return [n]
    else:
        factor.append(n)
        return factor


lst = trial_division(P)
c_lst = collections.Counter(lst)

ans = 1
for k, v in c_lst.items():
    while v >= N:
        ans *= k
        v -= N
print(ans)

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 998244353
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())



def hurui(N):
    koho = list(range(2,N))
    prime = []
    limit = math.sqrt(koho[-1])
    while True:
        p = koho[0]
        if limit <= p:
            prime = prime + koho
            break
        else:
            prime.append(p)
            koho = [e for e in koho if e%p != 0]

    return prime


def factorization(N):
    ans = defaultdict(int)
    L = len(primes)
    pind = 0
    while N > 1:
        p = primes[pind]
        while N%p == 0:
            N //= p
            ans[p] += 1
        pind += 1
        if pind >= L:
            ans[N] += 1
            break
    return ans

N,P = inpl()

primes = hurui(int(math.sqrt(P))+3)
facs = factorization(P)

ans = 1
for p,n in facs.items():
    if n >= N:
        ans *= p**(n//N)

print(ans)

Solution (Python):

def prime_factorization(x: int) -> int:
    """
    Prime factorization of a number (trial division)
    
    Args: x (int): a number to be resolved
    Return: ret (dict): {prime factor: power}
    
    e.g., n = 2^a * 3^b -> {2: a, 3: b}
    """
    max_prime = 0
    ret = {}

    
    cnt = 0
    while x % 2 == 0:
        x //= 2
        cnt += 1
    if cnt > 0:
        max_prime = 2
        ret[max_prime] = cnt

    
    cnt = 0
    for i in range(3, int(x ** 0.5) + 1, 2):
        cnt = 0
        while x % i == 0:
            x //= i
            max_prime = i
            cnt += 1
        if cnt > 0:
            ret[max_prime] = cnt

    
    if x > 2:
        max_prime = x
        ret[max_prime] = 1

    return ret


def main():
    
    n, p = list(map(int, input().rstrip().split()))
    ans = 1
    for f, p in prime_factorization(p).items():
        ans *= f ** (p // n)  
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n,p=map(int,input().split())
for i in range(round(p**(1/n)),0,-1):
  if p%(i**n)==0:print(i);exit()

Solution (Python):
import math
N,P=map(int,input().split())

dic_fact={}
for i in range(2,P+1):
  if i**2>P:
    break
  
  while(True):
    if P%i==0:
      P//=i
      if i not in dic_fact:
        dic_fact[i] = 1
      else:
        dic_fact[i] += 1
    else:
      break
      
if P!=1:
  dic_fact[P]=1


answer=1
for key in dic_fact:
  value=dic_fact[key]
  while(True):
    if value>=N:
      answer*=key
      value-=N
    else:
      break
      
print(answer)

Solution (Python):
N, P = map(int, input().split())
p = P
import math

MAX = 1000000   
prime = [True]*(MAX+1)
prime[0] = False
prime[1] = False

R = int(math.sqrt(MAX))

for i in range(2, R+1):
    if prime[i]:
        cnt = 2
        while i * cnt <= MAX:
            prime[i * cnt] = False
            cnt += 1

dp = [0]*(MAX+1)

for i in range(2, MAX+1):
    if prime[i]:
        while P % i == 0:
            dp[i] += 1
            P //= i

ans = 1
for i in range(2, MAX+1):
    if dp[i] >= N:
        ans *= i ** (dp[i] // N)

if N == 1:
    print(p)
else:
    print(ans)

Solution (Python):
from collections import Counter
n,p=map(int,input().split())
l=[]
while p%2==0:
    p=p//2
    l.append(2)
while 1:
    k=p
    for i in range(3,int(p**0.5)+1,2):
        if p%i==0:
            l.append(i)
            p=p//i
            break
    if k==p:
        l.append(p)
        break
    elif p==1:break
lc=Counter(l).most_common()
a=1
for i in lc:a*=i[0]**(i[1]//n)
print(a)

Solution (Python):
inpl = lambda: list(map(int,input().split()))
from math import sqrt
class Factorizer():
    def __init__(self):
        self.primes_ceil = 3
        self.primes = [2]

    def find_primes(self, primes_ceil):
        prev_primes_ceil, self.primes_ceil = self.primes_ceil, primes_ceil
        for i in range(prev_primes_ceil, self.primes_ceil):
            sieve = 1
            for p in self.primes:
                if p*p > i:
                    break
                elif i % p == 0:
                    sieve = 0
                    break
            if sieve == 0:
                continue
            else:
                self.primes.append(i)

    def __call__(self, n):
        if (self.primes_ceil-1)**2 < n:
            self.find_primes(int(sqrt(n))+1)
        factors = []
        powers = []
        for p in self.primes:
            if p * p > n:
                break
            elif n % p == 0:
                n //= p
                k = 1
                while n % p == 0:
                    n //= p
                    k += 1
                factors.append(p)
                powers.append(k)
        if n > 1:
            factors.append(n)
            powers.append(1)
        return factors, powers

N, P = inpl()
fct=Factorizer()
f, p = fct(P)
n = len(f)
ans = 1
for i in range(n):
    ans *= f[i]**(p[i]//N)
print(ans)

Solution (Python):
inpl = lambda: list(map(int,input().split()))
from math import sqrt
class Factorizer():
    def __init__(self):
        self.primes_ceil = 3
        self.primes = [2]

    def find_primes(self, primes_ceil):
        prev_primes_ceil, self.primes_ceil = self.primes_ceil, primes_ceil
        for i in range(prev_primes_ceil, self.primes_ceil):
            sieve = 1
            for p in self.primes:
                if p*p > i:
                    break
                elif i % p == 0:
                    sieve = 0
                    break
            if sieve == 0:
                continue
            else:
                self.primes.append(i)

    def __call__(self, n):
        if (self.primes_ceil-1)**2 < n:
            self.find_primes(int(sqrt(n))+1)
        factors = []
        powers = []
        for p in self.primes:
            if p * p > n:
                break
            elif n % p == 0:
                n //= p
                k = 1
                while n % p == 0:
                    n //= p
                    k += 1
                factors.append(p)
                powers.append(k)
        if n > 1:
            factors.append(n)
            powers.append(1)
        return factors, powers

N, P = inpl()
fct=Factorizer()
f, p = fct(P)
n = len(f)
ans = 1
for i in range(n):
    ans *= f[i]**(p[i]//N)
print(ans)

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

if n == 1:
    print(p)
else:
    m = int((p + 1) ** (1 / n))
    while m ** n > p:
        m -= 1
    for i in reversed(range(1, m + 1)):
        if p % (i ** n) == 0:
            print(i)
            break

Solution (Python):
import math


def main():
    N, P = map(int, input().split())
    rt = math.floor(math.sqrt(P))
    cnt = {}
    for i in range(2, rt+1):
        while P % i == 0:
            if i not in cnt:
                cnt[i] = 0
            cnt[i] += 1
            P //= i
    if P != 1:
        cnt[P] = 1
    ans = 1
    for c in cnt:
        ans *= c**(cnt[c]//N)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()
if int(P ** (1 / N)) < 2:
    print(1)
    exit()
for n in range(int(P ** (1 / N))+1, 0, -1):
    if P % (n ** N) == 0:
        print(n)
        break

Solution (Python):
import sys

np = input().split()
n = int(np[0])
p = int(np[1])
bound_p = int(p ** (1 / min(n, 4)))


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


ilist = list(range(2, bound_p + 1))
ilist.reverse()


for i in ilist:
    pp = p
    for j in range(n):
        if pp % i != 0:
            break
        pp = pp // i
    else:
        print(i)
        sys.exit(0)


print(1)

Solution (Python):
n,p=map(int,input().split())
ans=1
if(n==1):
    print(p)
    exit()
cnt=0    
s=int(pow(p,1/n))+1
for i in range(s,1,-1):
    q=p
    cnt=0
    while(q>0):
        if(q%i!=0):
            break
        cnt+=1
        q=int(q/i) 
        
    
    if(cnt>=n):
        ans=i
        break    
print(ans)

Solution (Python):
N,P = map(int, input().split())
gc = []
if N == 1:
    print(P)
    exit(0)

for i in range(2,int(1e7)+1):
    if P % i == 0:
        cnt = 0
        while P % i== 0 and P != 0:
            cnt += 1
            P //= i
        gc.append( (i, cnt) )
        if P == 0:
            break
ans = 1
for g,c in gc:
    if c >= N:
        ans *= g**(c//N)
print(ans)

Solution (Python):

N,P = list(map(int, input().split()))
import math

if N == 1:
    print(P)
    exit(0)

def get_prime(n):
    """ Returns  a list of primes < n """
    sieve = [True] * n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,n,2) if sieve[i]]

primax = int(1e7) + 9 * int(1e6)
primes = get_prime(primax)





def df(P, p):
    if P >= p:
        cnt = 0
        while P >= p and P % p == 0:
            P = int(P//p)
            cnt += 1
        return cnt
    else:
        raise "P , p error."

gc = []
for p in primes:
    if P % p == 0:
        cnt = df(P, p)
        P = int( P // int(p**cnt))
        gc.append([p, cnt])
ans = 1
for g,cnt in gc:
    if cnt >= N:
        ans *= g**(cnt//N)

debug = 1
for g,cnt in gc:
    debug *= g**cnt




if P > 1e9 and debug != P and  debug < P and N == 1:
    raise "errror"
print(ans)

Solution (Python):
n,p=map(int,input().split())
def factorize(n):
    f=[]
    p=2
    cnt=0
    while p**2<=n:
        while n%p==0:
            cnt+=1
            n=n//p
        if cnt!=0:
            f.append([p,cnt])
            cnt=0
        p+=1
    if n!=1:
        f.append([n,1])
    return f

A=factorize(p)
ans=1
for i in range(len(A)):
    ans*=A[i][0]**(A[i][1]//n)
print(ans)

Solution (Python):
import math
n, p = list(map(int, input().split()))
li = []
box = []
m = 1
k = 1
q = p
 
while True:
    for i in range(2,int(math.sqrt(q)) + 1):
        if p % i == 0:
            p = p // i
            li.append(i)
            k = i
            break
        else:
            continue
    else:
        break
 
for i in range(2,k+1):
    if i in li:
        box.append(i)
 
if n > len(li):
    print(m)
elif n==1:
  print(q)
else:
    for j in box:
        if li.count(j) // n > 0:
            m *= j ** (li.count(j) // n)
    print(m)

Solution (Python):
import math
n, p = list(map(int, input().split()))
li = []
box = []
m = 1
k = 1
q = p

while True:
    for i in range(2,int(math.sqrt(q)) + 1):
        if p % i == 0:
            p = p // i
            li.append(i)
            k = i
            break
        else:
            continue
    else:
        break

for i in range(2,k+1):
    if i in li:
        box.append(i)

if n > len(li):
    print(m)
elif n == 1:
    print(q)
else:
    for j in box:
        if li.count(j) // n > 0:
            m *= j ** (li.count(j) // n)
    print(m)

Solution (Python):
import math
n, p = list(map(int, input().split()))
li = []
box = []
m = 1
k = 1
q = p

while True:
    for i in range(2,int(math.sqrt(q)) + 1):
        if p % i == 0:
            p = p // i
            li.append(i)
            k = i
            break
        else:
            continue
    else:
        break

for i in range(2,k+1):
    if i in li:
        box.append(i)

box = sorted(box, reverse = True)

if n > len(li):
    print(m)
elif n == 1:
    print(q)
else:
    for j in box:
        if li.count(j) // n > 0:
            m *= j ** (li.count(j) // n)
    print(m)

Solution (Python):
def fctr(n):
    f = []
    c = 0
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            c+=1
            n = n//i
        if c!=0:
            f.append([i,c])
            c = 0

    if n!=1:
        f.append([n,1])

    return f


N,P = list(map(int,input().split()))
s = fctr(P)

ans = 1

for i in range(len(s)):
    ans *= s[i][0] ** (s[i][1]//N)
        

print(ans)

Solution (Python):
from collections import Counter
N, P = map(int, input().split())
pr = P
c = Counter()
i = 2
while i*i<=P:
  while pr%i == 0:
    c[i] += 1
    pr //= i
  i += 1
if pr>1:
  c[pr] += 1
r = 1
for p in c:
  while c[p]>=N:
    r *= p
    c[p] -= N
print(r)