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 ≤ 109

Sample Input 1

12

Sample Output 1

12: 2 2 3

Sample Input 2

126

Sample Output 2

126: 2 3 3 7

Solution in Python3 (judge verdict: Time Limit Exceeded)

def generate_prime(max_number):
    
    prime_list = []
    num = 0
#   count up to max number
    for i in range(max_number):
        num += 1

#       judge: 1
        if num == 1:
            continue

#       judge: 2
        if num == 2:
            #yield 2
            prime_list.append(num)
            continue

        k = 1
        ok = ''
        while k < num:
            k += 1
            if num % k == 0:
                break
            else:
                ok = 'X'

        if ok == 'X':
            #yield num
            prime_list.append(num)
                
    return prime_list

def main():
    n_bk= n = int(input())

    count_d = {}
    factor_list = generate_prime(n)

    for factor in factor_list:#generate_prime(n)::

        while True:

            if n == factor:
                if str(factor) in count_d:
                    count_d[str(factor)] = count_d[str(factor)] + 1
                else:
                    count_d[str(factor)] = 1

                break

            if n % factor == 0:
                n = int(n / factor)
                if str(factor) in count_d:
                    count_d[str(factor)] = count_d[str(factor)] + 1
                else:
                    count_d[str(factor)] = 1

            else:
                break


    print(str(n_bk)+':',end='')

    for factor in factor_list:

        if str(factor) in count_d:
            for count in range(int(count_d[str(factor)])):
                print('',factor,end='')
    print()

if __name__ == '__main__':
    main()