Problem p03194 (python)

Fixed submission:
# -*- 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 submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from sys import stdin
import math
from functools import reduce

n,x = [int(x) for x in stdin.readline().split()]
limit = int(math.pow(x, (1.0/n)))

def factorize(x):
    g = []

    p = 2
    if x % p == 0:
        count = 0
        while x % p == 0:
            count += 1
            x /= p
        else:
            if count >= n:
                g.append(p * (count // n))

    for p in range(3, limit, 2):
        if x % p == 0:
            count = 0
            while x % p == 0:
                count += 1
                x /= p
            else:
                if count >= n:
                    g.append(p * (count // n))
    return g

if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    g = factorize(x)
    ans = reduce(lambda a,b: a*b, g)
    print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from sys import stdin, setrecursionlimit
import math
from functools import reduce

setrecursionlimit(10000)

n,x = [int(x) for x in stdin.readline().split()]
limit = int(math.pow(x, (1.0/n)))

def factorize(x, g):

    p = 2
    if x % p == 0:
        p_n = math.pow(p, n)
        if x % p_n == 0:
            g = factorize(x / p_n, g)
            g.append(p)
            return g

    for p in range(3, limit, 2):
        if x % p == 0:
            p_n = math.pow(p, n)
            if x % p_n == 0:
                g = factorize(x / p_n, g)
                g.append(p)
                return g
    return g

if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    g = factorize(x, [])
    ans = reduce(lambda a,b: a*b, g)
    print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from sys import stdin, setrecursionlimit
import math
from functools import reduce

setrecursionlimit(10000)

n,x = [int(x) for x in stdin.readline().split()]
limit = int(math.pow(x, (1.0/n)))

def factorize(x, g):

    for 
    p = 2
    if x % p == 0:
        p_n = math.pow(p, n)
        if x % p_n == 0:
            g = factorize(x / p_n, g)
            g.append(p)
            return g

    for p in range(3, limit, 2):
        if x % p == 0:
            p_n = math.pow(p, n)
            if x % p_n == 0:
                g = factorize(x / p_n, g)
                g.append(p)
                return g
    return g

if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    g = factorize(x, [])
    ans = reduce(lambda a,b: a*b, g)
    print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from sys import stdin
import math
from functools import reduce

n,x = [int(x) for x in stdin.readline().split()]
limit = int(math.pow(x, (1.0/n)))

def factorize(x, g):
    p = 2
    if x % p == 0:
        p_n = math.pow(p, n)
        if x % p_n == 0:
            g = factorize(x / p_n, g)
            g.append(p)
            return g

    for p in range(3, limit, 2):
        if x % p == 0:
            p_n = math.pow(p, n)
            if x % p_n == 0:
                g = factorize(x / p_n, g)
                g.append(p)
                return g
    return g

if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    g = factorize(x, [])
    ans = reduce(lambda a,b: a*b, g)
    print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from sys import stdin
import math
from functools import reduce

n,x = [int(x) for x in stdin.readline().split()]
limit = int(math.pow(x, (1.0/n)))

def factorize(x, g):
    for p in range(2, limit):
        if x % p == 0:
            p_n = math.pow(p, n)
            if x % p_n == 0:
                g = factorize(x / p_n, g)
                g.append(p)
                return g
    return g

if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    g = factorize(x, [])
    ans = reduce(lambda a,b: a*b, g)
    print(ans)