Problem:
Prime Factorization Factorize a given integer n . Input  n  An integer n is given in a line. Output Print the given integer n and : . Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before each prime factor. Constraints  2 ≤ n ≤ 10 9   Sample Input 1 12 Sample Output 1 12: 2 2 3 Sample Input 2 126 Sample Output 2 126: 2 3 3 7

Solution (Python):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors

n = int(input())
n_ = n
div = make_divisors(n)
ans = []
for d in div[1:]:
    while n_ % d == 0 and n_ > 0:
        n_ //= d
        ans.append(d)
print("{}:".format(n), *ans)

Solution (Python):
n = int(input())

def soinsu(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 [str(_) for _ in a]
ans = str(n) + ': ' + ' '.join(soinsu(n))
print(ans)

Solution (Python):
n = int(input())

tn = n
t = []
for i in range(2, int(n ** 0.5) + 1):
    while n % i == 0:
        n //= i
        t.append(i)

if n != 1:
    t.append(n)

print("{}: {}".format(tn, " ".join(map(str, t))))

Solution (Python):
import math

n = int(input())
x = n
print(f'{x}:', end='')
cnt = 0
for i in range(2, n+1):
    if x==1:
        break
    
    if i>math.sqrt(n) and cnt==0:
        print(f' {n}', end='')
        break
    

    while x%i==0:
        cnt += 1
        x=x//i
        print(f' {i}', end='')
        
print()

Solution (Python):
def prime_factorization(n):  
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                cnt += 1
                n //= i
            res.append((i, cnt))
    if n > 1:
        res.append((n, 1))
    return res


if __name__ == "__main__":
    N = int(input())
    pf = prime_factorization(N)
    ans = "{}:".format(N)
    for k, v in pf:
        ans += (" {}".format(k)) * v
    print(ans)

Solution (Python):
from math import sqrt
N = int(input())
i = 2
lis = []
n = N
while True:
    if i>sqrt(n):
        if n==1:
            break
        else:
            lis.append(str(n))
            break
    if n%i==0:
        lis.append(str(i))
        n //= i
    else:
        i += 1
print('{}: '.format(N)+' '.join(lis))

Solution (Python):
def main():
    from math import sqrt
    n = int(input())
    N = n
    i = 2
    ans = []
    while i<=sqrt(n):
        if n%i==0:
            n //= i
            ans.append(str(i))
        else:
            i += 1
    if n != 1:
        ans.append(str(n))
    print(str(N)+':', ' '.join(ans))

main()

Solution (Python):
def PrimeFactorize(n):
    l = []
    for i in range(2, int(n ** 0.5) + 1):
        if i > n:
            break
        while n % i == 0:
            n //= i
            l.append(str(i))
    if n != 1:
        l.append(str(n))
    return l


n = int(input())
print(str(n) + ": " + " ".join(PrimeFactorize(n)))

Solution (Python):
n=int(input())
num=int(n**0.5)
str_n=str(n)
l=[]
for i in range(2,num+1):
    while n%i==0:
        n=n//i
        l.append(i)
if n!=1:l.append(n)
print(str_n+':',*l)

Solution (Python):

import math
import copy
n = int(input())
m = copy.copy(n)
A = []

for i in range(2,int(math.sqrt(m))+2):
    if n == 1:
        break
    if n % i == 0:
        while n % i == 0:
            A.append(str(i))
            n //= i
if n > 1:
    A.append(str(n))
print(str(m) + ': ' + ' '.join(A))

Solution (Python):
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

n=int(input())
ans="{}:".format(n)
if is_prime(n)==True:
    ans+=' '
    ans+=str(n)
    print(ans)
    exit()
lis=[]
flag=True
import math
while flag:
    flag=False
    for i in range(2,n+1):
        if n%i==0:
            lis.append(i)
            n//=i
            flag=True
            break
for i in lis:
    ans+=" "
    ans+=str(i)
print(ans)

Solution (Python):
n = int(input())
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
print(f"{n}:", " ".join(list(map(str, prime_factorize(n)))))

Solution (Python):
n = int(input())
N = n
ans = []
for i in range(2, int(n**0.5)+1):
    while n % i == 0:
        ans.append(i)
        n //= i
if n != 1: ans.append(n)
print('{}:'.format(N), *ans)

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

n = int(input())
ans = str(n) + ":"
for i,v in factorize(n):
    ans += (" "+str(i))*v
print(ans)

Solution (Python):
def resolve():
    n=int(input())
    
    def prime_factorization(m):
        pf = {}  

        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

        return pf
    print('{}:'.format(n),end='')
    ans=[]
    for k, v in prime_factorization(n).items():
        for i in range(v):
            print(' {}'.format(k), end='')
    print()

resolve()

Solution (Python):
n = int(input())
_n = n

prime = []
for i in range(2, int(n**0.5)+1):
    while n%i == 0:
        prime.append(i)
        n /= i

if len(prime) == 0 or n != 1:
    prime.append(int(n))

print(str(_n) + ":", *prime)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def factorize(n):
        if n < 4:
            return [n]
        res = []
        i = 2
        while i**2 <= n:
            while n%i == 0:
                res.append(i)
                n //= i
            i += 1
        if n != 1:
            res.append(n)
        res.sort()
        return res
    n = I()
    f = factorize(n)
    print(n,end =": ")
    print(*f)
    return


if __name__ == "__main__":
    solve()

Solution (Python):
N = int(input())
A = []
def is_prime(n):
    if n<2:return False
    for i in range(2,n):
        if i*i>n:break
        if n%i==0:return False
    return True
n = N
if is_prime(n):
    A.append(n)
    n=1
for i in range(2,N):
    if n%i==0:
        while n>1:
            A.append(i)
            n//=i
            if n%i!=0:break
    if n==1:break
print(str(N)+":",*A)

Solution (Python):
from math import sqrt

n = int(input())

def prime_factors(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


factors = prime_factors(n)
print("{}:".format(n), *factors)

Solution (Python):
N = int(input())
n = N

limit = int(N ** 0.5)
A = []
for i in range(2, limit + 1):
    while n % i == 0:
        A.append(i)
        n //= i

if not n == 1:
    A.append(n)

A.sort()
print(f'{N}: {" ".join(map(str, A))}')

Solution (Python):
import math
n = int(input())

def dev(n,x):
    while n % x == 0:
        print ('',x,end='')
        n //= x
    return n

print ('{}:'.format(n),end='')
n = dev(n,2)
for x in range(3,int(math.sqrt(n))+1,2):
    if n == 1: break
    n = dev(n,x)
if n > 1:
    print ('',n)
else:
    print ('')

Solution (Python):
import math
n = int(input())

def eratosthenes(num):
	out = []
	d = math.floor(num**(1/2))
	is_prime = [True] * (d+1)
	is_prime[0] = False
	is_prime[1] = True

	for i in range(2,d+1):
		if is_prime[i]:
			out.append(i)
			for j in range(2*i, d+1, i):
				is_prime[j] = False

	return out

tmp = n
primes = eratosthenes(10**9)
ans = []
for p in primes:
	while True:
		div, mod = divmod(tmp, p)
		if mod == 0:
			ans.append(p)
			tmp = div
		else:
			break

if len(ans) == 0:
	print('{}: {}'.format(n,n))
else:
	print('{}: {}'.format(n, ' '.join(list(map(str, ans)))))

Solution (Python):
n = int(input())
n1 = n
p = 2
primes = []

while n1 != 1:
    if n1%p == 0:
        n1 /= p
        primes.append(p)
    elif n1 == 999993031:
        primes = [999993031]
        break
    else:
        p += 1
print((str(n)+":"),*primes,sep = " ")

Solution (Python):
n = int(input())
n_hype = n
ans = []
for i in range(2,int(n**0.5)+2):
    while True:
        if n_hype%i==0:
            ans.append(i)
            n_hype /=i
        else:
            break
if n_hype!=1:
    ans.append(int(n_hype))
    
print('{}:'.format(n),end = '')
for a in ans:
    print('',a,end = '')
print()

Solution (Python):
import math

n = int(input())

def Prime(n):
    List = [1 for _ in range(n+1)]
    List[0],List[1] = 0,0
    P_List_tmp = [2]
    for i in range(3,n+1):
        flag = 0
        for j in range(len(P_List_tmp)):
            if i % P_List_tmp[j] == 0:
                flag = 1
                List[i] = 0
        if List[i] == 1:
            P_List_tmp.append(i)
    P_List = []
    for i in range(n+1):
        if List[i] == 1:
            P_List.append(i)
    return P_List

def fact(n):
    P_List = Prime(int(math.sqrt(n)))
    Ans = []
    for i in range(len(P_List)):
        if n % P_List[i] == 0:
            while n % P_List[i] == 0:
                n //= P_List[i]
                Ans.append(P_List[i])
    if n != 1:
        Ans.append(n)
    return Ans

print(str(n)+":",end="")
Ans = fact(n)
for i in range(len(Ans)):
    print(" "+str(Ans[i]),end="")
print()

Solution (Python):
def prime_factorization(n):
    arr = []
    tmp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if tmp % i == 0:
            while tmp % i == 0:
                arr.append(i)
                tmp //= i
    if(tmp != 1):
        arr.append(tmp)
    if not arr:
        arr.append(n)
    return arr 

n = int(input())

ans = str(n) + ": " + " ".join(map(str, prime_factorization(n)))
print(ans)

Solution (Python):
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

n = int(input())
ans = ["{0}".format(n) + ":"]
for i in range(2, int(math.sqrt(n) // 1) + 3):
    if n == 1:
        break
    elif n % i == 0:
        while n % i == 0:
            ans.append("{0}".format(i))
            n //= i
if n != 1:
    ans.append("{0}".format(n))
print(" ".join(ans))

Solution (Python):
n = int(input())


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


print('{}:'.format(n), *prime_factorize(n))

Solution (Python):
n = int(input())
nf = n
ans = []
while n > 1:
    tmp = n
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            ans.append(i)
            n = n // i
            break
    if tmp == n:
        ans.append(n)
        n = n // n

print(str(nf) + ': ', end='')
print(*ans)

Solution (Python):
import math


ordinal_n = int(input())
n = ordinal_n
sosuu_candidate = []
answer_list = []
for i in range(2, int(math.sqrt(n)+1)):
    sosuu_candidate.append(i)

for p in sosuu_candidate:
    while True:
        if n % p == 0:
            answer_list.append(str(p))
            n = int(n / p)
        else:
            break
if n == 1:
    print(str(ordinal_n) + ":" + ' ' + ' '.join(answer_list))
else:
    answer_list.append(str(n))
    print(str(ordinal_n) + ":" + ' ' + ' '.join(answer_list))

Solution (Python):


import math

def get_input():
    return int(input())

def eratosthenes(n):
    table = [i for i in range(2, int(math.sqrt(n))+1)]
    prime = []
    while table[0] <= int(math.sqrt(n)):
        prime.append(table[0])
        head = table[0]
        table = [i for i in table if i%head != 0]
        if not table: break
    return prime

if __name__ == '__main__':
    n = get_input()
    
    if n <= 3:
        print("{}: {}".format(n, n))
    else:
        lis = []
        temp = n
        primes = eratosthenes(n) + [n]
        for d in primes:
            if temp <= 0:
                break
            while (temp%d == 0):
                lis.append(str(int(d)))
                temp = temp // d
        
        if temp > 1:
            lis.append(str(temp))

        print("{}: {}".format(n, " ".join(lis)))

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
import math

def prime_table(n):
    all_table = [True for _ in range(n+1)]
    all_table[0] = False
    all_table[1] = False    

    for i in range(2, n+1):
        if all_table[i]:
            j = 2 * i
            while j <= n:
                all_table[j] = False
                j += i
    table = [i for i in range(1, n+1) if all_table[i]]
    return table

n_orig = int(input())
n = n_orig

prime_lis = []

for i in prime_table(int(math.sqrt(n))):
    while n % i == 0:
        n /= i
        prime_lis.append(str(i))

if n != 1:
    prime_lis.append(str(int(n)))

print("{}: {}".format(n_orig, " ".join(prime_lis)))

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

N = int(input())

ans = [str(N)+':']

for x,y in factorization(N):
    ans.extend([x]*y)

print(' '.join(map(str,ans)))

Solution (Python):
def isPrime(x):
    if x < 2:
        return False
    elif x == 2:
        return True;
    if x % 2 == 0:
        return False
    
    for i in range(3,int(x),2):
        if i * i > x :
            break;
        if x % i == 0:
            return False
        
    return True
    

while 1:
    try:
        num = (int)(input())
    except EOFError:
        break
print(str(num) + ":",end="")
factor = 2
factors = []
while num != 1:
    
    if isPrime(num) :
        factors.append(int(num))
        break
    if(num % factor == 0):
        num = num / factor
        factors.append(factor)
    else:
        factor = factor + 1


for i in factors:
    print(" " + str(i),end="")
print()

Solution (Python):
n = int(input())
print("{}:".format(n), end="")
q = 2
while n>1 and q*q <= n:
	if n % q == 0:
		print(" {}".format(q), end="")
		n //= q
	else:
		q += 1
if n>1:
	print(" {}".format(n), end="")
print("")

Solution (Python):
def factoring(n):
    """
    This program factorize any number.
    This returns the dictionary of prime factors of the number.(if n=18=2*3**2, this returns {2:1,3:2})
        """
    if n == 0:
        return {0: 1}
    if n == 1:
        return {1: 1}

    
    
    

    nOrigin = n
    n = n**0.5
    
    
    
    numlist = [0 for i in range(int(n) + 1)]
    numlist[0] = -1
    numlist[1] = -1

    
    t = 2
    while t < (n**0.5):
        if numlist[t] == 0:
            numlist[t] = t
            k = 2
            while t * k <= n:
                numlist[t * k] = -1
                k += 1
        t += 1

    
    while t <= n:
        if numlist[t] == 0:
            numlist[t] = t
        t += 1

    
    result = {}
    for i in numlist:
        if i == -1:
            continue
        j = 0
        while nOrigin % i == 0:
            j += 1
            nOrigin = nOrigin / i
        if j == 0:
            continue
        else:
            result[i] = j

    if int(nOrigin) != 1:
        result[int(nOrigin)] = 1
    return result

n=int(input())

print("{0}: ".format(n),end="")
factors=[]
for i in sorted(factoring(n).items()):
    for j in range(i[1]):
        factors.append(str(i[0]))

print(" ".join(factors))

Solution (Python):
import math
mod = 10 ** 9 + 7

def f(num):

    i = 2
    d = dict()

    while i * i <= num:
        if num % i == 0:
            num //= i
            d[i] = d.get(i, 0) + 1
        else:
            i += 1
    
    
    d[num] = d.get(num, 0) + 1

    return d

n = int(input())

ans = []
for k, v in f(n).items():
    for _ in range(v):
        ans.append(k)

print(str(n)+":", *ans)

Solution (Python):
def is_prime(n):
    if n==2:
        return True
    if n%2==0 or n==1:
        return False
    for i in range(3,int(n**0.5)+1,2):
        if n%i==0:
            return False
    return True
        
n = int(input())
print(str(n)+": ", end='')
if is_prime(n):
    print(n)
else:
    ans = []
    while n % 2 == 0:
        n //= 2
        ans.append(2)
    d = 3
    while d <= n ** 0.5:
        if is_prime(d):
            while n % d == 0:
                n //= d
                ans.append(d)
        d += 2
    if is_prime(n):
        ans.append(n)
    print(*ans)

Solution (Python):
n=int(input())
i=2
ans=str(n)+":"
while n!=0 and i<=n**0.5:
	while n%i==0:
		n//=i
		ans+=" "+str(i)
	i+=1
if n==1:
	print(ans)
	exit()
print(ans+" "+str(n))

Solution (Python):
n = int(input())
k = n
L = []
for i in range(2,100000):
    while n%i == 0:
        L.append(i)
        n = n//i
if n != 1:
    L.append(n)
s = str(k)+':'
for i in range(len(L)):
  s += ' '+str(L[i])
print(s)

Solution (Python):
def prime_factor(n):
    ret, p = [], 2

    while p*p <= n:
        if n % p != 0:
            p += 1
            continue

        exp_v = 0
        while n%p == 0:
            exp_v += 1
            n //= p
        ret.append( [p, exp_v] )

        p += 1

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

    return ret

n = int(input())
L = prime_factor(n)

print(str(n) + ":", end = "")
print( "".join([ (" " + str(k)) * v for (k, v) in L]) )

Solution (Python):

def 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

Q = int(input())
alist = factorize( Q )
print(str(Q)+':',end='')
for a in alist:
    print( ' '+str(a), end = '')
print('')

Solution (Python):
n = int(input())
ans = [str(n) + ":"]
i = 2
while i * i <= n:
    while n % i == 0:
        n //= i
        ans.append(i)
    i += 1
if n != 1:
    ans.append(n)
print(*ans)

Solution (Python):
n = int(input())
ans = [str(n) + ":"]
i = 2
while i * i <= n:
    while n % i == 0:
        n //= i
        ans.append(i)
    i += 1
if n != 1:
    ans.append(n)
print(*ans)

Solution (Python):

import math
N = int(input())
n2 = math.ceil(math.sqrt(N))
M = math.ceil(math.sqrt(10**9))
prime = []
for i in range(M):
    I = i+1
    m = math.ceil(math.sqrt(I))
    flag = 0
    for j in range(m):
        J = j+1
        if J == 1 or J == I:
            pass
        else:
            if I%J == 0:
                flag = 1
                break
    if flag == 0 and I != 1:
        prime.append(I)
prime.append(999993031)
fact = []
for p in prime:
    if p > N:
        break
    else:
        if N%p == 0:
            count = 0
            n3 = N
            while True:
                if n3%p == 0:
                    n3 = n3//p
                    count+=1
                else:
                    break
            fact.append([p,count])
print(str(N)+":",end="")
for f in fact:
    p,c = f
    while c > 0:
        c-=1
        print("",p,end="")
print()

Solution (Python):
def main():
    N = int(input())
    ans = [str(N) + ':']
    
    while not N % 2:
        N //= 2
        ans.append(2)
        
    i = 3
    while i ** 2 <= N:
        while not N % i:
            N //= i
            ans.append(i)
            
        i += 2
        
    if N != 1: ans.append(N)
    
    print(' '.join(map(str, ans)))

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
m = n
output = []
for i in range(2, int(n**0.5)+1):
    while True:
        if n % i != 0:
            break
        else:
            output.append(i)
            n //= i
if n != 1:
    output.append(n)
print(str(m) + ": " + ' '.join(map(str, output)))

Solution (Python):
n = int(input())
print(str(n) + ':', end='')
while n > 1:
    for p in range(2, n+1):
        if n % p == 0:
            n //= p
            print(' ' + str(p), end='')
            break
        elif p * p > n:
            print(' ' + str(n), end='')
            n = 1
            break
print()

Solution (Python):

def prime_factorization(x: int) -> dict:
    """
    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, ret = 0, {}
    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 = int(input())
    facts = prime_factorization(N)
    ans = f"{N}: "
    for prime, cnt in facts.items():
        ans += f"{prime} " * cnt
    print(ans[:-1])


if __name__ == "__main__":
    main()

Solution (Python):
arr = []
n= int(input())
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])

k=[]
for a,s in arr:
    k+=[a]*s
print(str(n)+":",*k,sep=" ")

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

def factorization(num):
    import math
    
    
    MAX_PRIME = int(math.sqrt(num)) + 1
    primes = []
    is_prime = [True] * (MAX_PRIME+1)
    for i in range(2, MAX_PRIME+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(2*i, MAX_PRIME+1, i):
                is_prime[j] = False
    insu = []
    tmp = num
    max_count = 0
    for i in range(len(primes)):
        count = 0
        while tmp%primes[i] == 0:
            tmp //= primes[i]
            count += 1
        if count > 0:
            insu.append((primes[i], count))
            max_count = max(max_count, count)
        if tmp == 1:
            break
    if tmp != 1:
        insu.append((tmp, 1))
    return insu

def main():
    N = int(input())
    insu = factorization(N)

    print("{}:".format(N), end="")
    for prime, count in insu:
        for i in range(count):
            print(" {}".format(prime), end="")
    print()

if __name__ == "__main__":
    main()

Solution (Python):
import math
n = int(input())
k = n
l = []
for i in range(2, int(math.sqrt(n))+1):
    while k % i ==0:
        l.append(i)
        k = k // i
        if k == 1:
            break

if k != 1:
    l.append(k)
print("{}: ".format(n),end="")
print(*l)

Solution (Python):
def f(n) -> list:
	if n==1:
		return [1]
	ret = []
	i = 2
	while i*i<=n:
		while n%i==0:
			n //= i
			ret.append(i)
		i += 1
	if n!=1:
		ret.append(n)
	return ret
n=int(input())
print("{}:".format(n),*f(n))

Solution (Python):
n = int(input())
m = n
A = ""
i = 2
while True:
    if n%i == 0:
        A = A + " " + str(i)
        if i == n:
            break
        n = n//i
        i = 2
    else:
        if i*i >= n:
            A = A + " " + str(n)
            break
        else:
            i += 1

print("{}:{}".format(m,A))

Solution (Python):
import math


def compute_prime_factor(n: int) -> None:
    global prime_factors
    sqrt_n = int(math.sqrt(n)) + 1
    for i in range(2, sqrt_n + 1):
        if 0 == (n % i):
            prime_factors.append(i)
            compute_prime_factor(n // i)
            return
    if 1 != n:
        prime_factors.append(n)
        return


if __name__ == "__main__":
    n = int(input())
    prime_factors = []  
    compute_prime_factor(n)

    print(f"{n}: " + " ".join([str(elem) for elem in prime_factors]))

Solution (Python):
import sys
import math
i=int(input())
  
k=[]
num=i
j=2
while j*j<=num:
  if i%j==0:
    i//=j
    k.append(j)
  else:
    j+=1
if i!=1:
  k.append(i)

print(str(num)+": "+(' '.join(map(str, k))))

Solution (Python):


import sys
from collections import Counter
from math import sqrt

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def factorize(num: int) -> dict:
    """ 素因数分解 """
    d = Counter()
    
    for i in range(2, int(sqrt(num))+1):
        cnt = 0
        
        while num % i == 0:
            num //= i
            d[i] += 1
        
        if num == 1:
            break
    
    if num != 1:
        d[num] += 1
    return d

N = INT()

print('{0}: '.format(N), end='')
ans = []
for k, v in sorted(factorize(N).items()):
    for i in range(v):
        ans.append(k)
print(*ans)

Solution (Python):
n=int(input())
x=n
ans=[]
for i in range(2,int(x**0.5)+1):
    if n%i==0:
        while n%i==0:
            ans.append(i)
            n//=i
if ans==[]:
    ans.append(x)
elif n!=1:
    ans.append(n)
print(str(x)+": "+" ".join(map(str,ans)))