qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N,P = map(int,input().split())
i = int(P**(1/N))
res = []
if N == 1:
  print(P)
elif P == 1:
  print(1)
else:
  for i in range(i,0,-1):
    print(i)
    if P%i**N==0:
      print(i)
      break

Fixed code:
N,P = map(int,input().split())
i = round(P**(1/N))
res = []
if N == 1:
  print(P)
elif P == 1:
  print(1)
else:
  for i in range(i,0,-1):
    if P%i**N==0:
      print(i)
      break
Buggy code:
def isprime(n):
    if(n==2 or n==3):
        return True
    if(n<=1):
        return False
    if(n%2==0 or n%3==0):
        return False
    x=5
    while(x*x<=n):
        if(n%x==0 or n%(x+2)==0):
            return False
        x+=6
    return True
n,p=map(int,input().split())
if(n==1):
    print(p)
else:
    ans=0
    for i in range(2,int(p**0.5)+1,1):
        num=p
        count=0
        while(num%i==0):
            num=num//i
            count+=1
        if(count>=n):
            ans=i
    print(ans)

Fixed code:
def isprime(n):
    if(n==2 or n==3):
        return True
    if(n<=1):
        return False
    if(n%2==0 or n%3==0):
        return False
    x=5
    while(x*x<=n):
        if(n%x==0 or n%(x+2)==0):
            return False
        x+=6
    return True
n,p=map(int,input().split())
if(n==1):
    print(p)
else:
    ans=1
    for i in range(2,int(p**0.5)+1,1):
        num=p
        count=0
        while(num%i==0):
            num=num//i
            count+=1
        if(count>=n):
            ans=i
    print(ans)
Buggy code:
N, P = map(int, input().split())
if N == 1:
  print(P)
  exit()
if N > 40:
  print(1)
  exit()
res = []
for i in range(P):
  x = i**N
  if i**N > P:
    break
  if P%x == 0:
    res.append(i)
print(max(res))
  

Fixed code:
N, P = map(int, input().split())
if N == 1:
  print(P)
  exit()
if N > 40:
  print(1)
  exit()
res = []
for i in range(1,P+1):
  x = i**N
  if i**N > P:
    break
  if P%x == 0:
    res.append(i)
print(max(res))
Buggy code:
n,p = map(int,input().split())
N = round(p**(1/n))
if n==1:
    print("p")
else:
    for i in range(N,0,-1):
        if p%(i**n)==0:
            print(i)
            exit()

Fixed code:
n,p = map(int,input().split())
N = round(p**(1/n))
for i in range(N,0,-1):
    if p%(i**n)==0:
        print(i)
        exit()
Buggy code:
n,p= map(int,input().split())
if n==1:
    print(p)
    exit()
else:
    for i in range(int(p**(1/n)),1,-1):
        if p%(i**n)==0:
            print(i)
            exit()


Fixed code:
n,p= map(int,input().split())
for i in range(round(p**(1/n)),0,-1):
    if p%(i**n)==0:
        print(i)
        exit()
Buggy code:
n,p = map(int,input().split())
a = []
i = 2
while (p>1) and (i < int(p**0.5) + 1):
    c = 0
    while p%i == 0:
        p = p/i
        c += 1
    a.append([i,c])
    i += 1

c = 1
for i in range(len(a)):
  if a[i][1] >= n:
  	c = c* a[i][0] * int(a[i][1]/n)
    
print(c)

Fixed code:
n,p = map(int,input().split())
a = []
i = 2
k = p

if n == 1:
  c = p
else:
  while (p>1) and (i < int(k**0.5) + 4):
      c = 0
      while p%i == 0:
          p = p/i
          c += 1
      a.append([i,c])
      i += 1
  if p>1:
      a.append([p,1])
  c = 1

  for i in range(len(a)):
    if a[i][1] >= n:
      k = a[i][0] ** int(a[i][1]/n)
      c = c* k

print(c)
Buggy code:
# -*- coding: utf-8 -*-

from sys import stdin

n,x = [int(i) for i in stdin.readline().split()]
limit = int(x ** (1.0/n)) + 1

def devide_counter(x, p):
    count = 1
    x /= p
    while x % p == 0:
        count += 1
        x /= p
    return x, count

def factorize(x):
    ans = 1

    p = 2
    if x % p == 0:
        x, count = devide_counter(x, p)
        if count >= n:
            ans = ans * (p ** (count // n))

    for p in range(3, limit, 2):
        if x % p == 0:
            x, count = devide_counter(x, p)
            print(x, count)
            if count >= n:
                ans = ans * (p ** (count // n))
        if x < p * p:
            break
    return ans

if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    ans = factorize(x)
    print(ans)

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

from sys import stdin

n,x = [int(i) for i in stdin.readline().split()]
limit = int(x ** (1.0/n)) + 1

def devide_counter(x, p):
    count = 1
    x /= p
    while x % p == 0:
        count += 1
        x /= p
    return x, count

def factorize(x):
    ans = 1

    p = 2
    if x % p == 0:
        x, count = devide_counter(x, p)
        if count >= n:
            ans = ans * (p ** (count // n))

    for p in range(3, limit, 2):
        if x % p == 0:
            x, count = devide_counter(x, p)
            if count >= n:
                ans = ans * (p ** (count // n))
        if x < p * p:
            break
    return ans

if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    ans = factorize(x)
    print(ans)
Buggy code:
n, p = map(int, input().split())

p2 = int(p ** (1 / n))

for i in range(p2 - 1, 0, -1):
    if p % (i ** n) == 0:
        print(i)
        break

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

p2 = round(p ** (1 / n))

for i in range(p2, 0, -1):
    if p % (i ** n) == 0:
        print(i)
        break
Buggy code:
N, P = [int(i) for i in input().strip().split()]
dic={}

for i in range(2,int(P**(1/2))+1):
    num = 0
    while P%i == 0:
        num = num +1
        P = P/i
    dic[i] = num
    
ans = 1
for i in dic:
    if dic[i] != 0:
        ans = ans*(i**((dic[i]//N)))
print(ans)

Fixed code:
N, P = [int(i) for i in input().strip().split()]
dic={}
ans = 1

if N == 1:
    print(P)
    quit()
elif P == 1:
    print(1)
    quit()
    
for i in range(2,int(P**(1/2))+1):
    num = 0
    while P%i == 0:
        num = num +1
        P = int(P/i)
    dic[i] = num//N
    ans = ans*(i**(dic[i]))

print(ans)
Buggy code:
N,P = map(int,input().split())
r = round(P**(1/N))
for i in range(r,0,-1):
    if P%i==0:
        print(i)
        exit()

Fixed code:
N,P = map(int,input().split())
r = round(P**(1/N))
for i in range(r,0,-1):
    if P%(i**N)==0:
        print(i)
        exit()
Buggy code:
import math
N,P = map(int,input().split())
Max = 1
if N==1:
    print(1)
else:
    for m in range(1,int(math.sqrt(P))+1):
        if P%m == 0:
            if m == int(m**(1/N))**N :
                if Max < int(m**(1/N)):
                    Max = int(m**(1/N))
                    if P//m == int((P//m)**(1/N))**N and Max < int((P//m)**(1/N)) :
                        Max = int((P//m)**(1/N))
            
    print(Max)

Fixed code:
import math
N,P = map(int,input().split())
Max = 1
if N==1:print(P)
else:
    for m in range(1,int(math.sqrt(P))+1):
        if P%m == 0:
            if m == int(m**(1/N)+0.1)**N and Max < int(m**(1/N)+0.1):
                    Max = int(m**(1/N)+0.1)
            if P//m == int((P//m)**(1/N)+(0.1)**1)**N and Max < int((P//m)**(1/N)+(0.1)**1) :
                Max = int((P//m)**(1/N)+(0.1)**1)
    print(Max)
Buggy code:
n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
i = int(p**(1/n))
print(i)
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 1
print(c)

Fixed code:
n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
i = int(p**(1/n))+1
if i%2 == 0:
    i -= 1
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 1
print(c)
Buggy code:
import math
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(round(math.pow(P,(1/N)))):
    tmp=math.pow(i,N-1)
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if (P/i)%tmp==0:
        ans=i
        break
print(ans)

Fixed code:
import math
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
po=math.pow(P,(1/N))
for i in reversed(range(int(round(po,0))+1)):
    tmp=math.pow(i,N)
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break
print(ans)
Buggy code:
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(int(pow(P,(1/N)))+1)):
    tmp=i**N
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break:
print(ans)

Fixed code:
import math
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(round(math.pow(P,(1/N)))+1)):
    tmp=math.pow(i,N)
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break
print(ans)
Buggy code:
N, P = list(map(int, input().split()))
if N == 1:
    print(P)
    exit()
elif P == 1:
    print("1")
    exit()

ans = 1
tmp = P

for i in range(2, int(pow(P, 1 / N))):
    po = pow(i, N)
    while tmp % po == 0:
        tmp = tmp // po
        ans = ans * i
        # print(i, tmp, ans)

    if tmp < po:
        break

print(ans)


Fixed code:
N, P = list(map(int, input().split()))
if N == 1:
    print(P)
    exit()
elif P == 1:
    print("1")
    exit()

ans = 1
tmp = P

for i in range(2, int(pow(P, 1 / N)) + 1):
    po = pow(i, N)
    while tmp % po == 0:
        tmp = tmp // po
        ans = ans * i
        # print(i, tmp, ans)

    if tmp < po:
        break

print(ans)
Buggy code:
import math

N, P = map(int, input().split())
max_value = math.floor(pow(P, 1/N))
ans = 1

if N == 1:
    ans = P
else:
    for i in range(1, max_value):
        mod = i ** N
        if P % mod == 0:
            ans = i

print(ans)


Fixed code:
import math

N, P = map(int, input().split())
max_value = round(pow(P, 1/N)) + 1 
ans = 1

if N == 1:
    ans = P
else:
    for i in range(1, max_value):
        mod = i ** N
        if P % mod == 0:
            ans = i

print(ans)
Buggy code:
N,P = map(int, input().split())

if P == 1 or N == 2:
    print(1)
elif N == 1:
    print(P)
else:
    import math

    sq_P = math.floor(math.sqrt(P))
    prim = []
    P_tmp=P

    for i in range(2,sq_P):
        r=0
        if P_tmp%i == 0:
            r+=1
            P_tmp=P/i
            while P_tmp%i==0:
                r+=1
                P_tmp=P_tmp/i
            prim.append([i,r])

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

    print(ans)

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

if P == 1 :
    print(1)
elif N == 1:
    print(P)
else:
    import math

    sq_P = math.floor(math.sqrt(P))
    prim = []
    P_tmp=P

    for i in range(2,sq_P):
        r=0
        if P_tmp%i == 0:
            r+=1
            P_tmp=P_tmp/i
            while P_tmp%i==0:
                r+=1
                P_tmp=P_tmp/i
            prim.append([i,r])

    ans = 1
    for i in range(len(prim)):
        if prim[i][1]>=N:
            ans = ans * prim[i][0]**math.floor(prim[i][1]/N)

    print(ans)
Buggy code:
import math

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

if N == 1:
    print(P)
else:
    for i in range(round(math.pow(P, 1 / N)) + 1, 0, -1):
        if P % (i ** N) == 0:
            now_max = i
    
    print(now_max)

Fixed code:
import math

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

if N == 1:
    print(P)
else:
    for i in range(1, round(math.pow(P, 1 / N)) + 1):
        if P % (i ** N) == 0:
            now_max = i
    
    print(now_max)
Buggy code:
from collections import Counter

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

def prime_factorization(n):
    factor = []
    f = 2
    while f ** 2 <= n:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    if n > 1:
        factor.append(n)
    return factor

p = prime_factorization(P)

c = Counter(p)

l = []
j = []
for k, v in c.items():
    if N <= v:
        l.append(k)
        j.append(v//N)
ans = 1

for i,v in zip(l,j):
    ans *= i**v

print(ans)

Fixed code:
from collections import Counter

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

def prime_factorization(n):
    factor = []
    f = 2
    while f ** 2 <= n:
        if n % f == 0:
            factor.append(f)
            n //= f
        else:
            f += 1
    if n > 1:
        factor.append(n)
    return factor

p = prime_factorization(P)
c = Counter(p)

l = []
j = []
for k, v in c.items():
    if N <= v:
        l.append(k)
        j.append(v//N)
ans = 1

for i,v in zip(l,j):
    ans *= i**v

print(ans)
Buggy code:
n,p=map(int, input().split())
ans=1
m=int(pow(p,1/n))+1
i=2
c=0
while(i<=p):
    if p % i == 0:
        p=p/i
        c=c+1
        if p % i != 0:
            #print('i**(c//n)=',i**(c//n))
            ans = ans * ( i**(c//n) )
            i=i+1
            c=0

print(ans)


Fixed code:
n,p=map(int, input().split())
ans=1
m=int(pow(p,1/n))+1
if n==1:
    print(p)
else:
    m=int(pow(p,1/n))+1
    i=2
    c=0
    while(i<=p and i<=m):
        #print('i,p=',i,p)
        if p % i == 0:
            p=p/i
            c=c+1
            if p % i != 0:
                #print('i**(c//n)=',i**(c//n))
                ans = ans * ( i**(c//n) )
                i=i+1
                c=0
        else:
            i=i+1
    print(ans)
Buggy code:
import itertools
import numpy as np
import math

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

table = [0] * (int(math.sqrt(p)) + 1)

pl = []
ans = 1

for i in range(2, int(math.sqrt(p)) + 1):
    if table[i] == 0:
        pl.append(i)
        for j in range(i + i, int(math.sqrt(p)) + 1, i):
            table[j] = 1

a = 0

for i in range(len(pl)):
    q = p
    while q % pl[i] == 0:
        a += 1
        q = q / pl[i]
    ans = ans * (pl[i] ** (int(a//n)))
    a = 0

print(ans)

Fixed code:
import itertools
import numpy as np
import math

n, p = map(int, input().split())
if n != 1:
    table = [0] * (int(math.sqrt(p)) + 1)

    pl = []
    ans = 1

    for i in range(2, int(math.sqrt(p)) + 1):
        if table[i] == 0:
            pl.append(i)
            for j in range(i + i, int(math.sqrt(p)) + 1, i):
                table[j] = 1

    a = 0

    for i in range(len(pl)):
        q = p
        while q % pl[i] == 0:
            a += 1
            q = q / pl[i]
        ans = ans * (pl[i] ** (int(a//n)))
        a = 0
else:
    ans = p

print(ans)
Buggy code:
import sys
import traceback

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

class PrimeFractorization:
    def __init__(self):
        self.a = 2

    def decomposit_prime(self, n):
        try:
            while n >= self.a * self.a:
                if n % self.a == 0:
                    p.append(self.a)
                    n //= self.a
                else:
                    self.a += 1
            p.append(n)
        except Exception as e:
            raise

obj = PrimeFractorization()
obj.decomposit_prime(P)

p2 = set(p)

print(p)

for a in p2:
    if p.count(a) >= N:
        ans *= pow(int(a),int(p.count(a)/N))

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


Fixed code:
import sys
import traceback

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

class PrimeFractorization:
    def __init__(self):
        self.a = 2

    def decomposit_prime(self, n):
        try:
            while n >= self.a * self.a:
                if n % self.a == 0:
                    p.append(self.a)
                    n //= self.a
                else:
                    self.a += 1
            p.append(n)
        except Exception as e:
            raise

obj = PrimeFractorization()
obj.decomposit_prime(P)

p2 = set(p)

for a in p2:
    if p.count(a) >= N:
        ans *= pow(int(a),int(p.count(a)/N))

if N == 1:
    print(P)
else:
    print(ans)
Buggy code:
n,p=map(int,input().split())
a=[i for i in range(p+1)]
a[1]=0
b=int(p**0.5)
for j in a:
    if j>b:
        break
    elif j==0:
        continue
    for k in range(2*j,p+1,j):
        a[k]=0
c=[l for l in a if l!=0]
for m in range(len(c)):
    d=0
    while p%c[m]==0:
        p//=c[m]
        d+=1
    c[m]=[c[m],d]
e=1
for v in c:
    e*=v[0]**(v[1]//n)
print(e)

Fixed code:
n,p=map(int,input().split())
if n==1:
    print(p)
    quit()
a=[i for i in range(int(p**(1/n))+1)]
a[1]=0
b=int(p**0.5)
for j in a:
    if j>b:
        break
    elif j==0:
        continue
    for k in range(2*j,len(a),j):
        a[k]=0
c=[l for l in a if l!=0]
for m in range(len(c)):
    d=0
    while p%c[m]==0:
        p//=c[m]
        d+=1
    c[m]=[c[m],d]
e=1
for v in c:
    e*=v[0]**(v[1]//n)
print(e)
Buggy code:
import sys

N,P=[int(i) for i in input().split()]
i=2
ans = 1
c=0
if N == 1:
  print(P)
  sys.exit()
while P>i*i:
  if P%i==0:
    P//=i
    c+=1
    if c==N:
      ans*=i
      c=0
  else:
    c=0
    i+=1
print(ans)


Fixed code:
import sys

N,P=[int(i) for i in input().split()]
i=2
ans = 1
c=0
if N == 1:
  print(P)
  sys.exit()
while P>i*i-4:
  if P%i==0:
    P//=i
    c+=1
    if c==N:
      ans*=i
      c=0
  else:
    c=0
    i+=1
if P==i and c+1 ==N:
  ans*=i
print(ans)
Buggy code:
#coding:utf-8
import math

def primeFact(P):
    s = math.floor(math.sqrt(P))
    result = {}

    for i in range(2, s):
        if P % i == 0:
            r = 0
            while P % i == 0:
                r += 1
                P = P / i
            result[i] = r

    if P > s:
        result[P] = 1
    return result

def gcd(N, fact):
    gcd = 1
    for key in fact.keys():
        if fact[key] >= N:
            gcd *= key * (int(fact[key] / N))
    return gcd

if __name__ == "__main__":
    N, P = map(int, input().split())
    fact = primeFact(P)
    print(gcd(N, fact))

Fixed code:
#coding:utf-8
import math

def primeFact(P):
    s = math.floor(math.sqrt(P))
    result = {}

    for i in range(2, s + 1):
        if P % i == 0:
            r = 0
            while P % i == 0:
                r += 1
                P = P // i
            result[i] = r

    if P > s:
        result[P] = 1
    return result

def gcd(N, fact):
    gcd = 1
    for key in fact.keys():
        if fact[key] >= N:
            gcd *= key ** (fact[key] // N)
    return int(gcd)

if __name__ == "__main__":
    N, P = map(int, input().split())
    fact = primeFact(P)
    print(gcd(N, fact))
Buggy code:
N,P = (int(i) for i  in input().split())

k = P
a = 2
ans = 1
counter = 0
while(k >= a*a):
    if (k%a==0):
        k = k // a
        counter += 1
    else:
        a += 1
        counter = 0
    if counter >= N:
        ans *= a
        counter = 0
if (k%a==0):
    k = k // a
    counter += 1
else:
    a += 1
    counter = 0
if counter >= N:
    ans *= a
    counter = 0
print(ans)

Fixed code:
N,P = (int(i) for i  in input().split())

k = P
a = 2
ans = 1
counter = 0
while(k >= a*a):
    if (k%a==0):
        k = k // a
        counter += 1
    else:
        a += 1
        counter = 0
    if counter >= N:
        ans *= a
        counter = 0
if (k%a==0):
    k = k // a
    counter += 1
else:
    a += 1
    counter = 0
if counter >= N:
    ans *= a
    counter = 0
if N == 1:
    ans = P
print(ans)
Buggy code:

import collections

def get_lim(n):
    for i in range(n):
        if i * i > n:
            return i + 1

def prime_factor(n, length):
    ass = collections.defaultdict(int)
    # break_num = pow()
    # for i in range(2,int(n**0.5)+1):
    lim = get_lim(n)
    for i in range(2, lim):
        # print(pow(i, length),  n)
        # if pow(i, length) > n:
        #     break
        if i > n or n == 1:
            break
        # i = pow(i, num)
        while n % i==0:
            ass[i] += 1
            n = n//i

    if n != 1:
        ass[n] += 1
    return ass

if __name__ == '__main__':
    length, num = list(map(int, input().split()))

    if length == 1:
        print(num)
    else:

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

Fixed code:

import collections

# def get_lim(n):
#     # for i in range(n):
#     #     if i * i > n:
#     #         return i + 1
#     return pow(10, int((len(str(n)) / 2)))

def prime_factor(n, length):
    ass = collections.defaultdict(int)
    # break_num = pow()
    # for i in range(2,int(n**0.5)+1):
    # lim = get_lim(n)
    for i in range(2, n):
        # print(pow(i, length),  n)
        # if pow(i, length) > n:
        #     break
        if i * i > n:
            break
        # print(n, i)
        # i = pow(i, num)
        while n % i==0:
            ass[i] += 1
            n = n//i

    if n != 1:
        ass[n] += 1
    return ass

if __name__ == '__main__':
    length, num = list(map(int, input().split()))

    if length == 1:
        print(num)
    else:

        soinnsuu = prime_factor(num, length)
        ans = 1
        # print(soinnsuu)
        for data in soinnsuu.keys():
            if soinnsuu[data] >= length:
               ans *= pow(data, int(soinnsuu[data] / length))
        print(ans)
Buggy code:
import math
N,P = map(int,input().split(" "))
i = 2
plimes = []

if N == 1:
    print(P)
else:
    while(i <= math.sqrt(P)):
        if P % i == 0:
            P = P // i
            plimes.append(i)
        else:
            i += 2

    resalt = 1
    j = 0

    while(len(plimes) > j):
        k =plimes.count(plimes[j])
        if k // N >= 1:
            resalt *= plimes[0]
        j = j + k
    print(resalt)

Fixed code:
import math
N,P = map(int,input().split(" "))

i = 2
plimes = []

if N == 1:
    print(P)
else:
    while(i <= math.sqrt(P)):
        if P % i == 0:
            P = P // i
            plimes.append(i)
        elif i == 2:
            i += 1
        else:
            i += 2
    plimes.append(P)


    resalt = 1
    j = 0

    while(len(plimes) > j):
        k =plimes.count(plimes[j])
        if k // N >= 1:
            resalt = resalt * plimes[j] **(k//N)
        j = j + k
    print(resalt)
Buggy code:
import math
import copy

n,p=map(int,input().split())
a=math.floor(p**(1/n))
#print(a)
ans=1
for i in range(a,1,-1):
    p_s=copy.deepcopy(p)
    cnt=0
    while p_s%i==0:
        cnt+=1
        p_s//=i
        if cnt>=n:
            print(i)
            exit()

Fixed code:
import math
import copy
 
n,p=map(int,input().split())
a=math.floor(p**(1/n)+1)
#print(a)
for i in range(a,0,-1):
    if i==1:
        print(i)
        break
    p_s=copy.deepcopy(p)
    cnt=0
    while p_s%i==0:
        cnt+=1
        p_s//=i
        if cnt>=n:
            print(i)
            exit()