Problem p02660 (python)

Fixed submission:
P = [1 for _ in range(10**6)]
P[0]=0
P[1]=0
for i in range(2,10**3):
    for j in range(i*i,10**6,i):
        P[j] = 0
Q = []
for i in range(2,10**6):
    if P[i]==1:
        Q.append(i)
N = int(input())
C = {}
for q in Q:
    if N%q==0:
        C[q] = 0
        while N%q==0:
            N = N//q
            C[q] += 1
if N>1:
    C[N] = 1
cnt = 0
for q in C:
    k = C[q]
    n = 1
    while k>(n*(n+1))//2:
        n += 1
    if k==(n*(n+1))//2:
        cnt += n
    else:
        cnt += n-1
print(cnt)

Buggy submission (verdict: Runtime Error):
N=int(input())

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
A=[i for i in range(N + 1) if is_prime[i]]

a=[]
for i in A:
    if N%i==0:
        a.append(i)
print(a)
ans=0
for i in a:
    e=0
    while N%i==0:
            N = N//i
            e+= 1
    x=0
    for j in range(1,100):
        x+=j
        if e>=x:
            ans+=1
        else:
            break

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N=int(input())

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
A=[i for i in range(N + 1) if is_prime[i]]


a=[]
for i in A:
    if N%i==0:
        a.append(i)

ans=0
for i in a:
    e=int(math.log(N,i))
    x=0
    for j in range(1,100):
        x+=j
        if e>=x:
            ans+=1
        else:
            break

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N=int(input())

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
A=[i for i in range(N + 1) if is_prime[i]]


a=[]
for i in A:
    if N%i==0:
        a.append(i)

ans=0
for i in a:
    e=int(math.log(N,i))
    x=0
    for j in range(1,100):
        x+=j
        if e>=x:
            ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N=int(input())
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]]

def factorization(n,A):
    a=[]
    for i in A:
        if n%i==0:
            a.append(i)
    return a

A=primes(N)
a=factorization(N,A)

ans=0
for i in a:
    e=int(math.log(N,i))
    x=0
    for j in range(1,100):
        x+=j
        if e>=x:
            ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N=int(input())
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]]

def factorization(n,A):
    a=[]
    for i in A:
        if n%i==0:
            a.append(i)
    return a

A=primes(N)
print(1)
a=factorization(N,A)
print(2)

ans=0
for i in a:
    e=int(math.log(N,i))
    x=0
    for j in range(1,100):
        x+=j
        if e>=x:
            ans+=1

print(ans)