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:
def factorize(n):
    if n == 1:
        return [1]
    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())

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

f = factorize(p)
cnt = [0] * (max(f) + 1)

for _f in f:
    cnt[_f] += 1

ans = 1
# print(cnt)

for i in range(len(cnt)):
    if cnt[i] >= n:
        ans *= i

print(ans)

Submission status: Runtime Error

Solution code:
import collections
import math
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))
n=len(c.keys())
w=1
for i in c.keys():
  if c[i]>=N:
    k=math.ceil(c.values(i)/N)
    w=w*(i**k)
print(w)

Submission status: Runtime Error

Solution code:
import collections
import math
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))
n=len(c.keys())
w=1
for i in c.keys():
  if c.values(i)>=N:
    k=math.ceil(c.values(i)/N)
    w=w*(i**k)
print(w)

Submission status: Runtime Error

Solution code:
import math
N,P=map(int,input().split())
L=[]
for i in range(1,int(math.sqrt(P))+1):
	if math.pow(i,N)<=P:
		if P%i==0:
			if P%(math.pow(i,N))==0:
				L.append(i)
			j=(P//i)
			if P%(math.pow(j,N))==0:
				L.append(j)
	else:
		break
print(max(L))

Submission status: Runtime Error

Solution code:
import math
N,P=map(int,input().split())
L=[]
for i in range(1,int(math.sqrt(P))+1):
	if pow(i,N)<=P:
		if P%i==0:
			if P%(math.pow(i,N))==0:
				L.append(i)
			j=(P//i)
			if P%(math.pow(j,N))==0:
				L.append(j)
	else:
		break
print(max(L))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
n,p = map(int,input().split())
m = math.ceil(math.sqrt(p))
ans = 1
if n == 1:
    ans = p
else:
    for i in range(2,m):
        q = i**n
        if p%q == 0:
            ans = i
print(ans)

Submission status: Runtime Error

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

res = 1
i = 2

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

while True:
    if i > P ** (1 / N) + 1:
        break
    if P % pow(i, N) == 0:
        res = i

    i += 1

print(res)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,P;cin>>N>>P;
  long ans=1;
  long d=2,C=P;
  while(d*d<=C){
    long tmp=0;
    while(P%d==0){P/=d;tmp++;}
    if(tmp>=N)ans*=(tmp/N)*d;
    d++;
  }
  ans*=P;
  cout<<ans;
}

Submission status: Runtime Error

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

d={}
x=p
for i in range(2,p):
  while x%i==0:
    if i in d:
      d[i]+=1
    else:
      d[i]=1
    x//=i
  if i*i>=p:
    break

ans=1
for k,v in d:
  for i in range(v//n):
    ans*=k

print(ans)

Submission status: Runtime Error

Solution code:
def primes(n):
  ps = {}
  while n%2==0:
    n//=2
    if 2 not in ps:
      ps[2] = 1
    else:
      ps[2] += 1
  
  for i in range(3,int(n**.5)+1,2):
    while n%i==0:
      n//=i
      if i not in ps:
        ps[i] = 1
      else:
        ps[i] += 1
  
  if n!=1:
    if i not in ps:
      ps[i] = 1
    else:
      ps[i] += 1
  
  return ps
  
N,P = map(int,input().split())
ps = primes(P)
ans = 1
for p, num in ps.items():
  if num>=N:
    ans *= p**(num//N)
print(ans)

Submission status: Runtime Error

Solution code:
N,P=map(int,input().split())
for x in range(int(pow(P,1/N))+1,0,-1):
  if P%(x**N)==0:
    print(x)
    exit()

Submission status: Runtime Error

Solution code:
N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()

x = ans = 1
while True:
    y = x**N
    if y > P:
        break
    if P % y == 0:
        ans = x
    x += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline


def main():
    N, P = map(int, input().split())
    if N == 1:
        print(P)
        return
    x = ans = 1
    while True:
        y = x**N
        if y > P:
            break
        if P % y == 0:
            ans = x
        x += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
n, p = map(int, input().split())
cnt = [0] * math.ceil(math.sqrt(p))
ans = 1
for i in range(2, math.ceil(math.sqrt(p))):
    cnt = 0
    while p % i == 0 and p != 0:
        p //= i
        cnt[i] += 1
    ans *= i ** (cnt[i] // n)
ans *= p ** (1 // n)
print(ans)

Submission status: Runtime Error

Solution code:
import math


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, p = map(int, input().split())
a = factorization(p)
ans = 1
for i in range(len(a)):
    if a[i][1]>=n:
        b = a[i][1]//n
        ans = ans*a[i][0]*b
    else:
        continue
print(ans)import math


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, p = map(int, input().split())
a = factorization(p)
ans = 1
for i in range(len(a)):
    if a[i][1]>=n:
        b = a[i][1]//n
        ans = ans*a[i][0]*b
    else:
        continue
print(ans)

Submission status: Runtime Error

Solution code:
N, P = map(int, input().split())
P_prime = []
while P % 2 == 0:
    P_prime.append(2)
    P //= 2
odd = 3
while odd * odd <= P:
    if P % odd == 0:
        P_prime.append(odd)
        P //= odd
    else:
        odd += 2
if P != 1:
    P_prime.append(P)
edge = [0]
for i in range(len(P_prime) - 1):
    if P_prime[i] != P_prime[i + 1]:
        edge.append(i)
edge.append(len(P_prime) - 1)
ans = 1
for i in range(len(edge) - 1):
    ans *= pow(P_prime[edge[i + 1]], (edge[i + 1] - edge[i]) // N)
print(ans)

Submission status: Runtime Error

Solution code:
import sys


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

    i = 0
    while i**N <= P:
        i += 1

    i -= 1

    for j in range(i, 0, -1):
        if P % j**N == 0:
            print(j)
            sys.exit()


main()

Submission status: Runtime Error

Solution code:
import math
n, p = map(int ,input().split())
#引数　n, 返り値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]]
ff = primes(int(math.sqrt(p) + 1))
ans = 1
factorized = dict(zip(ff, [0 for i in range(len(ff))]))
div = 2
if n == 1:
    print(p)
    exit()
while p != 1:
    while p % div == 0:
        p /= div
        factorized[div] += 1
    div += 1
for i in factorized.keys():
    if factorized[i] >= n :
        ans *= i*(factorized[i] // n)
print(ans)

Submission status: Runtime Error

Solution code:
import math
n, p = map(int ,input().split())
#引数　n, 返り値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]]
ff = primes(int(math.sqrt(p) + 1))
ans = 1
factorized = dict(zip(ff, [0 for i in range(len(ff))]))
div = 2
if n == 1:
    print(1)
    exit()
while p != 1:
    while p % div == 0:
        p /= div
        factorized[div] += 1
    div += 1
for i in factorized.keys():
    if factorized[i] >= n :
        ans *= i*(factorized[i] // n)
print(ans)

Submission status: Runtime Error

Solution code:
n, p = map(int ,input().split())
#引数　n, 返り値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]]
ff = primes(p)
ans = 1
factorized = dict(zip(ff, [0 for i in range(len(ff))]))
div = 2
while p != 1:
    while p % div == 0:
        p /= div
        factorized[div] += 1
    div += 1
for i in factorized.keys():
    if factorized[i] >= n :
        ans *= i*(factorized[i] // n)
print(ans)

Submission status: Runtime Error

Solution code:
import math
N, P = map(int, input().split())
p = math.ceil(P**(1/N))
ans = 1
flag=False
if N==1:
  print(P)
  exit(0)


for i in reversed(range(1,p+1)):
    if P % (i ** N) == 0:
        ans = i
        break
print(ans)

Submission status: Runtime Error

Solution code:
import sys

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

if N == 1:
    print (P)
    sys.exit()

lis = []
dic = {}

i = 1
while i ** N < 10 ** 12:

    flag = True
    for j in lis:
        if i % j == 0:
            flag = False
            break
    
    if flag and i != 1:
        lis.append(i)
        dic[i] = 0

        while P % i == 0:
            P //= i
            dic[i] += 1

    i += 1


ans = 1
#print (dic)

for i in dic:

    if dic[i] != 0:
        ans *= i ** (dic[i]//N)

print (ans)

Submission status: Runtime Error

Solution code:
import sys

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

if N == 1:
    print (P)
    sys.exit()

lis = [2]

i = 2
while i ** N < 10 ** 12:

    flag = True
    for j in lis:
        if i % j == 0:
            flag = False
            break
    
    if flag:
        lis.append(i)

    i += 1

dic = {}

for i in lis:

    dic[i] = 0

    while P % i == 0:
        P //= i
        dic[i] += 1

ans = 1

for i in dic:

    if dic[i] != 0:
        ans *= i ** (dic[i]//N)

print (ans)

Submission status: Runtime Error

Solution code:
n = int(input())
f = True
for i in range(n):
	a = int(input())
	if a % 2 != 0:
		f = False
print('second' if f else 'first')

Submission status: Runtime Error

Solution code:
N,P=map(int,input().split())
Q=[0]*(10**6+1)

i=2

while 1:
  if P==1:
    break
  if P%i==0:
    P//=i
    Q[i]+=1
    i=2
  else:
    i+=1
#print(Q[:20])
#print(list(map(lambda x: x//N,Q)))
Q=list(map(lambda x: x//N,Q))

ans=1
for i,q in enumerate(Q):
  if q:
    ans*=i**q
print(ans)

Submission status: Runtime Error

Solution code:
N,P=map(int,input().split())
if N==1:
    print(P)
else:
    a=1
    for i in range(2,10**6+1):
        s=0
        while True:
            if P%i==0:
                P//=i
                s+=1
            else:
                if s>=N:
                    a*=i**(s//N)
                break
    print(a)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from random import randint

def brent(N):
   # brent returns a divisor not guaranteed to be prime, returns n if n prime
   if N%2==0: return 2
   y,c,m = randint(1, N-1),randint(1, N-1),randint(1, N-1)
   g,r,q = 1,1,1
   while g==1:             
       x = y
       for i in range(r):
          y = ((y*y)%N+c)%N
       k = 0
       while (k<r and g==1):
          ys = y
          for i in range(min(m,r-k)):
             y = ((y*y)%N+c)%N
             q = q*(abs(x-y))%N
          g = gcd(q,N)
          k = k + m
       r = r*2
   if g==N:
       while True:
          ys = ((ys*ys)%N+c)%N
          g = gcd(abs(x-ys),N)
          if g>1:  break
   return g

def factorize(n1):
    if n1<=0: return []
    if n1==1: return [1]
    n=n1
    t = {}
    p=0
    mx=1000000
    if n%2 == 0: 
        t[2]=0
    if n%3 == 0:
        t[3]=0
    while n % 2 ==0 :
        t[2] += 1
        n//=2
    
    while n % 3 ==0 : 
        t[3] += 1;n//=3
        
    
    i=5
    inc=2
    # print(n)
    #use trial division for factors below 1M
    while i <=mx:
       while n % i ==0 : 
           if i not in t.keys():
               t[i] = 0
           t[i] += 1
           n//=i
       i+=inc
       inc=6-inc
    #use brent for factors >1M  
    # print(t)
    while n>mx:
      p1=n
      #iterate until n=brent(n) => n is prime
      while p1!=p:
          p=p1
          p1=brent(p)
      # print(p1)
      if p1 not in t.keys():
          t[p1] = 0
      t[p1] += 1;n//=p1 
    # print(n)
    if n!=1:
        t[n] = 1
    return t


from functools import reduce
from sys import argv
def main():
    n, p = tuple(map(int, input().strip().split()))
    q = factorize(p)
    # print(q)
    ans = 1
    for a in q.keys():
        q[a] //= n
        ans = ans * (a**q[a])
    print(ans)     
    


if __name__ == "__main__":
   main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sympy
n,p = map(int,input().split())
cnt = sympy.factorint(p)
ans = 1

for i in cnt:
    while cnt[i] >= n:
        ans *= i
        cnt[i] -= n
print(ans)

Submission status: Runtime Error

Solution code:
import sympy

n, p = map(int, input().split())
ls = sympy.factorint(p)
maxNum = 0
ans = 1

for key, value in ls.items():
    if value >= n:
        ans *= key
print(ans)

Submission status: Runtime Error

Solution code:
import math
n, p = [int(i) for i in input().split()]
max_x = int(p**(1/n))
ans = 1
if n >= p:
    print(1)
else:
    for i in range(max_x+1, 1, -1):
        if p % int(math.pow(i,n)) == 0:
            ans = i
            break
    print(ans)

Submission status: Runtime Error

Solution code:
import math
n, p = [int(i) for i in input().split()]
max_x = int(p**(1/n))
ans = 1
if n >= p:
    print(1)
else:
    for i in range(max_x+1, 1, -1):
        if p % math.pow(i,n) == 0:
            ans = i
            break
    print(ans)

Submission status: Runtime Error

Solution code:
import math
n, p = [int(i) for i in input().split()]
max_x = int(p**(1/n))
ans = 1
for i in range(max_x+1, 1, -1):
    if p % math.pow(i,n) == 0:
        ans = i
        break
print(ans)

Submission status: Runtime Error

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

if N == 1:
    print(P)
else:
    prime = [0] * (10**6+1)
    index = 2
    tmp = 0
    while P > 1:
        if P % index == 0:
            tmp += 1
            P //= index
            if P == 1:
                prime[index] = tmp
        else:
            prime[index] = tmp
            tmp = 0
            if index == 2:
                index += 1
            else:
                index += 2
    
    
    if prime[2] >= N:
        ans = 2 ** (prime[2]//N)
    else:
        ans = 1
    for i in range(3, 10**6+1, 2):
        ans *= max(1, i ** (prime[i]//N))
    
    print(ans)

Submission status: Runtime Error

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

if N == 1:
    print(P)
else:
    prime = [0] * (10**6+1)
    index = 2
    tmp = 0
    while P > 1:
        if P % index == 0:
            tmp += 1
            P //= index
            if P == 1:
                prime[index] = tmp
        else:
            prime[index] = tmp
            tmp = 0
            if index == 2:
                index += 1
            else:
                index += 2
    
    
    if prime[2] >= N:
        ans = 2
    else:
        ans = 1
    for i in range(3, 10**6+1, 2):
        if prime[i] >= N:
            ans *= i
    
    print(ans)

Submission status: Runtime Error

Solution code:
def primeFactor(n):
    res = {}
    i = 2
    while i*i <= n:
        while n % i == 0:
            key = str(i)
            res.update({key : 1+int(res.get(key,0))})
            n=n/i
        i=i+1    
    if n!=1:
        key = str(n)
        res.update({key : 1+int(res.get(key,0))})
    return res

N, P = map(int, input().split())
max = 1
for divisor, count in primeFactor(P).items():
    while count >= N:
        max *= int(divisor)
        count -= N
print(max)

Submission status: Runtime Error

Solution code:
#CADDi2018 C
'''
問題
N個の自然数の積がPであるとき,それらの最大公約数としてありうるものの最大値を求めよ
ただしNとPはともに1以上10**12以下

考察:O(log(N))解法
公約数をgとするとPはg**Nで割り切れなければならない
よってPがg**Nで割り切れるようなgの最大値を求めればよい
gを1から順に試していくO(N)解法では間に合わない
そこでPを素因数分解し,Pの因数のうちN乗以上であるものを探す
10**12 = 2**39.8... なのでPの因数はたかだか39乗である
10**12 = 3**25.1...
10**12 = 4**19.9...
10**12 = 5**17.1...
10**12 = 6**15.4...
10**12 = 7**14.1...
10**12 = 8**13.2...
10**12 = 9**12.5...
N=1のときはg=P
N=2のときはg<=10**6
N=3のときはg<=10**4
N=4のときはg<=1000
N=5のときはg<=251
N=6のときはg<=100
N=7のときはg<=51
N=8のときはg<=31
N=9のときはg<=21
N=10のときはg<=15
N=11のときはg<=12
N>=12のときはg=1,2,3,4,5,6,7,8,9,10のいずれか
N>=13のときはg=1,2,3,4,5,6,7,8のいずれか
N>=14のときはg=1,2,3,4,5,6,7のいずれか
N>=15のときはg=1,2,3,4,5,6のいずれか
N>=16のときはg=1,2,3,4,5のいずれか
N>=18のときはg=1,2,3,4のいずれか
N>=20のときはg=1,2,3のいずれか
N>=26のときはg=1,2のいずれか
N>=40のときはg=1
'''
N,P=map(int,input().split())
if N==1:
	print(P)
elif N<=11:
	ans=[]
	magicnum=[10**6,10**4,1000,251,100,51,31,21,15,12][N-2]
	for g in range(1,magicnum):
		if g**N > P:
			break
		elif P%(g**N)==0:
			ans.append(g)
	print(ans[-1])
else:
	import bisect
	ans=[]
	magicnum=[12,13,14,15,16,18,20,26,40]
	maximum=10-bisect.bisect_right(magicnum,N)
	if maximum==9:
		maximum+=1
	for g in range(1,maximum):
		if P%(g**N)==0:
			ans.append(g)
	print(ans[-1])

Submission status: Runtime Error

Solution code:
#CADDi2018 C
'''
問題
N個の自然数の積がPであるとき,それらの最大公約数としてありうるものの最大値を求めよ
ただしNとPはともに1以上10**12以下

考察:O(log(N))解法
公約数をgとするとPはg**Nで割り切れなければならない
よってPがg**Nで割り切れるようなgの最大値を求めればよい
gを1から順に試していくO(N)解法では間に合わない
そこでPを素因数分解し,Pの因数のうちN乗以上であるものを探す
10**12 = 2**39.8... なのでPの因数はたかだか39乗である
10**12 = 3**25.1...
10**12 = 4**19.9...
10**12 = 5**17.1...
10**12 = 6**15.4...
10**12 = 7**14.1...
10**12 = 8**13.2...
10**12 = 9**12.5...
N=1のときはg=P
N=2のときはg<=10**6
N=3のときはg<=10**4
N=4のときはg<=1000
N=5のときはg<=251
N=6のときはg<=100
N=7のときはg<=51
N=8のときはg<=31
N=9のときはg<=21
N=10のときはg<=15
N=11のときはg<=12
N>=12のときはg=1,2,3,4,5,6,7,8,9,10のいずれか
N>=13のときはg=1,2,3,4,5,6,7,8,9のいずれか
N>=14のときはg=1,2,3,4,5,6,7,8のいずれか
N>=15のときはg=1,2,3,4,5,6,7のいずれか
N>=16のときはg=1,2,3,4,5,6のいずれか
N>=18のときはg=1,2,3,4,5のいずれか
N>=19のときはg=1,2,3,4のいずれか
N>=20のときはg=1,2,3のいずれか
N>=26のときはg=1,2のいずれか
N>=40のときはg=1
'''
N,P=map(int,input().split())
if N==1:
	print(P)
elif N<=11:
	ans=[]
	magicnum=[10**6,10**4,1000,251,100,51,31,21,15,12][N-2]
	for g in range(1,magicnum):
		if g**N > P:
			break
		elif P%(g**N)==0:
			ans.append(g)
	print(ans[-1])
else:
	import bisect
	ans=[]
	magicnum=[12,13,14,15,16,18,19,20,26,40]
	maximum=11-bisect.bisect_right(magicnum,N)
	for g in range(1,maximum):
		if P%(g**N)==0:
			ans.append(g)
	print(ans[-1])

Submission status: Runtime Error

Solution code:
from collections import defaultdict
N,P = map(int, input().split())
is_prime = [True]*(10**6+1)
is_prime[0] = is_prime[1] = False
def sieve(n:int):
    """Sieve of Eratoshenes
    return the number of prime number (0, n]"""
    global is_prime
    for i in range(2, n+1):
        if is_prime[i]:
            # 素数の倍数は合成数
            for j in range(i*2, n+1, i):
                is_prime[j] = False

sieve(10**6)
facts = defaultdict(lambda:0)
p = P
for i in range(P):
    if not is_prime[i]:
        continue
    if p == 1:
        break
    while p % i == 0:
        p //= i
        facts[i] += 1
ans = 1
for k,v in facts.items():
    ans *= pow(k, v//N)
print(ans)

Submission status: Runtime Error

Solution code:
from math import sqrt
from collections import defaultdict
N,P = map(int, input().split())
is_prime = [True]*(10**6+1)
is_prime[0] = is_prime[1] = False
def sieve(n:int):
    """Sieve of Eratoshenes
    return the number of prime number (0, n]"""
    global is_prime
    if n<2: return 0
    for i in range(2, n+1):
        if is_prime[i]:
            # 素数の倍数は合成数
            for j in range(i*2, n+1, i):
                is_prime[j] = False

sieve(10**6)
facts = defaultdict(lambda:0)
for i in range(P):
    if not is_prime[i]:
        continue
    if P == 1:
        break
    while P % i == 0:
        P //= i
        facts[i] += 1
ans = 1
for k,v in facts.items():
    ans *= pow(k, v//N)
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

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

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 array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

fac = factorize(p)
arr = array_count(fac)

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

print(ans)

Submission status: Runtime Error

Solution code:
from collections import defaultdict as dd
primes = dd(int)
n,p = int(input().split())
gcd = 1
for i in range(2,int(p**0.5)+1):
  while p%i == 0:
    p //= i
    primes[i] += 1
for fac in primes:
  gcd *= fac**(primes[fac]//n)
print(gcd)

Submission status: Runtime Error

Solution code:
a = int(input())
ar = []
for i in range(a):
    l = int(input())
    ar.append(l)
ar = sorted(ar,reverse=True)
if (ar[0]-ar[1]) % 2 == 0:
    print("second")
else:
    print("first")

Submission status: Runtime Error

Solution code:
from sympy import factorint as fi

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

di = fi(p)

li = []
vu = []

for i in di.keys():
    li.append(i)
    vu.append(di[i])

ans = 1
for j in range(len(li)):
    count = vu[j]//n
    if count != 0:
        ans *= count*li[j]

if n == 1:
    ans = p

print(ans)

Submission status: Runtime Error

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


def fst(x,y):
    ans = 1
    while y:
        if y&1:
            ans = ans * x
        x *= 2
        y //= 2
        if ans > m:
            return m+1
    return ans
    

if n == 1:
    print(m)
    exit(0)
else:
    for i in range(10**6 + 2):
        if m%fst(i,n) == 0:
            print(i)
            exit(0)

Submission status: Runtime Error

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

if n == 1:
    print(m)
    exit(0)
else:
    for i in range(10**6 + 2):
        if m%(i**n) == 0:
            print(i)
            exit(0)

Submission status: Runtime Error

Solution code:
N=input()
count=0
for i in range(N):
    count+=int(input())%2
if count>0:
    print("first")
else:
    print("second")

Submission status: Runtime Error

Solution code:
import math

N, P = [int(i) for i in input().split()]

max_num = 1
for i in range(1, P+1):
    nums = int(math.pow(i, N))
    if nums <= P:
        if P % nums == 0:
            max_num = i
    else:
        break

print(max_num)

Submission status: Runtime Error

Solution code:
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit


if True:
    N, = getIntList()
    #print(N)
    za = getIntList()
 

dprint('begin')

zleft = [0 for i in range(N+1)]
zright = [0 for i in range(N+1)]


def getwork(zr, za):
    zr[0] = 0
    st = []
    for i in range(N):
        if i%10000  ==0:
            dprint('---', i)
        nt = [[za[i],0], [za[i],0], 1]
        st.append(nt)
        nr = zr[i]
        #dprint(st)
        while len(st)>1:
            b_2 = st[-2][1][1]
            b_1 = st[-1][0][1]
            bb = min(b_1,b_2)
            b_1 -=bb
            b_2 -=bb
            b_1p = 4 ** b_1
            b_2p = 4 ** b_2
            t2 = st[-2][1][0] * b_2p
            t1 = st[-1][0][0] * b_1p
            if  t2 < t1:
                nr+= 2* st[-2][2]
                st[-2][0][1] +=1
                st[-2][1][1] +=1
            elif t2 < t1 * 4:
                ttt = [ st[-2][0], st[-1][1], st[-2][2] + st[-1][2] ]  
                st[-2] = ttt
                st.pop()
            else:
                break
        #dprint(st)
        zr[i+1] = nr
        #dprint(nr)
        #dprint(st)
        assert nr < 1000000000000000
    dprint(st)
getwork(zleft, za)
dprint('!!!!')
getwork(zright, za[::-1])
 
#dprint(zleft)
#dprint(zright)

r =  zright[N]
for i in range(N+1):
    tr =  i + zleft[i] + zright[N-i]
    r = min(r,tr)

print(r)

dprint('end')

Submission status: Runtime Error

Solution code:
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit


if True:
    N, = getIntList()
    #print(N)
    za = getIntList()
else:
    N = 100
    import random
    za = [random.randint(1, 1000000000) for i in range(N) ]

dprint('begin')

zleft = [0 for i in range(N+1)]
zright = [0 for i in range(N+1)]


def getwork(zr, za):
    zr[0] = 0
    st = []
    for i in range(N):
        if i%10000  ==0:
            dprint('---', i)
        nt = [[za[i],0], [za[i],0], 1]
        st.append(nt)
        nr = zr[i]
        #dprint(st)
        while len(st)>1:
            b_2 = st[-2][1][1]
            b_1 = st[-1][0][1]
            bb = min(b_1,b_2)
            b_1 -=bb
            b_2 -=bb
            b_1p = 4 ** b_1
            b_2p = 4 ** b_2
            t2 = st[-2][1][0] * b_2p
            t1 = st[-1][0][0] * b_1p
            if  t2 < t1:
                nr+= 2* st[-2][2]
                st[-2][0][1] +=1
                st[-2][1][1] +=1
            elif t2 < t1 * 4:
                ttt = [ st[-2][0], st[-1][1], st[-2][2] + st[-1][2] ]  
                st[-2] = ttt
                st.pop()
            else:
                break
        #dprint(st)
        zr[i+1] = nr
        #dprint(nr)
        #dprint(st)
        assert nr < 1000000000000000
    dprint(st)
getwork(zleft, za)
dprint('!!!!')
getwork(zright, za[::-1])
 
#dprint(zleft)
#dprint(zright)

r =  zright[N]
for i in range(N+1):
    tr =  i + zleft[i] + zright[N-i]
    r = min(r,tr)

print(r)

dprint('end')

Submission status: Runtime Error

Solution code:
def main():
    N, P = map(int, input().split())
    if N == 1:
        print(P)
        return
    primes = []
    i = 2
    while i**N <= P:
        isprime = True
        for p in primes:
            if i % p == 0:
                isprime = False
                break
        if isprime:
            primes.append(i)
        i += 1

    F = {}
    i = 0
    while P > 1 and i < len(primes):
        factor = primes[i]
        while P % factor == 0:
            if factor not in F:
                F[factor] = 0
            F[factor] += 1
            P //= factor
        i += 1
    retval = 1
    for p in F:
        if F[p] >= N:
            retval *= p
    print(retval)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
print("second" if all(int(input())%2 == 0 for i in range(int(input()))) else 'first')

Submission status: Runtime Error

Solution code:
import math

def primes(x):
    list = [2]
    check = 0
    for i in range(3,x+1):
        for j in list:
            if i%j==0:
                check = 1
                break
        if check==0:
            list.append(i)
        check = 0
    return list

def exDiv(x,y):
    count = 1
    a = pow(y,1/x)
    if math.floor(a)==a:
        return int(a)
    max = math.ceil(pow(y,1/(x+1)))
    if not max==2:
        prime_list = primes(max)
    else:
        prime_list=[2]
    while 1:
        i = prime_list.pop(0)
        if i>max:
            break
        i_x = i**x
        while y%i_x==0:
            y /= i_x
            count *= i
        while y%i==0:
            y /= i
        if y<i_x:
            break
        a = pow(y,1/x)
        if math.floor(a)==a:
            return int(a*count)
        max = math.ceil(pow(y,1/(x+1)))
    return count


x,y = map(int,input().split())
print(exDiv(x,y))

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]
odd = 0
for i in range(len(A)) :
    a = A[i]
    if a % 2 != 0 :
        odd += 1
        break
if odd == 1 :
    print("first")
else :
    print("second")

Submission status: Runtime Error

Solution code:
N = int(input())

p=0
q=0

for _ in range(N):
    a=int(input())
    if a>=p:
        q=p
        p=a

if p==1:
    print('first')
elif (p-q)%2==0:
    print('second')
else:
    print('first')

Submission status: Runtime Error

Solution code:
N = int(input())
a = [int(input()) for _ in range(N)]
 
if N == 2 and min(a) == 1:
    print("first")
else:
    if sum(a) % 2 == 1:
        print("first")
    else:
        print("second")

Submission status: Runtime Error

Solution code:
N = int(input())
a = [int(input()) for _ in range(N)]

if sum(a) % 2 == 1:
    print("first")
else:
    print("second")

Submission status: Runtime Error

Solution code:
N = int(input())
a = [int(input()) for _ in N]

if sum(a) % 2 == 1:
    print("first")
else:
    print("second")