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 C++ (judge verdict: WA: Presentation Error)

///======================================================= ALL METHOD / FUNTION/ VARIABLE/ TYPEDEF's =================================
///1.abs
///2.sq
///3.max
///min
///swap

/// ----------------------------------------------------- NUMBER   THEORY -----------------------------------------------------------------------------------------
///bigmod
///gcd
///lcm
///nCr
///fib
///catalan formula
///derangement formula
///arithmetic progression
///geometric progression
///bionomial
///sieve                      prime
///isPime()
///primeFactor()
///numPF()
///numDiv()
///sumDiv()
///EulerPhi()
///euclid  // linear diophantine equation
///fact

/// ------------------------------------------------ DYNAMIC PROGRAMMING -------------------------------------------------------------
///LIS
///MIN COST PATH
///COIN CHANGE
///MATRIX CHAIN MULTIPICATION
///BIONOMIAL CO EFFICIENT
///0 1 KNAPSACK
///CUTTING ROD
///LONGEST PALINDROMIC SUBSEQUENCE
///LONGEST SUBSEQUECE ARRAY SUM

///

///=================================================== STRING ALGORITHM ===========================================================
///KMPSearch
///RobinKarpsearch
///Edit Distance
///LCS
///longest common Prefix
/// longest repeated substring
//

/// ==================================================  SORTING ======================================================================
///q_sort
///
///


///==================================================JAVA BIGINTEGER ==================================================================
///Java BigInteger .... after the main() function ,,



///======================================================= FOR USING STANDARD LIBRARY==============================================================

using namespace std;
#include<bits/stdc++.h>
///=========================================FOR TAKING INPUT OF ANY TYPE , till 4 parameter====================================================

///inline void make(string &a) { string s ; if(scanf("%s",s)); a = s; }
inline void make(int &a)
{
    if(scanf("%d", &a));
}
inline void make(float &a)
{
    if(scanf("%f", &a));
}
inline void make(double &a)
{
    if(scanf("%lf", &a));
}
inline void make(char *a)
{
    if(scanf("%s", a));
}
inline void make(char &a)
{
    if(scanf(" %c", &a));
}
inline void makec(char &a)
{
    if(scanf("%c", &a));
}

template<typename A, typename B> inline void make(pair<A, B> & p)
{
    make(p.first);
    make(p.second);
}
template<typename A>
inline void maketab(A *tab, int size)
{
    for(int i = 0; i < size; i++) make(tab[i]);
}
template<typename A>
inline void maketab(vector<A> &v, int size)
{
    typedef typename vector<A>::iterator iter;
    v.resize(size);
    for(iter i = v.begin(); i != v.end(); i++) make(*i);
}

template<typename A, typename B>
inline void make(A &a, B &b)
{
    make(a);
    make(b);
}
template<typename A, typename B, typename C>
inline void make(A &a, B &b, C &c)
{
    make(a);
    make(b);
    make(c);
}
template<typename A, typename B, typename C, typename D>
inline void make(A &a, B &b, C &c, D &d)
{
    make(a);
    make(b);
    make(c);
    make(d);
}
template<typename A, typename B, typename C, typename D, typename E>
inline void make(A &a, B &b, C &c, D &d, E &e)
{
    make(a);
    make(b);
    make(c);
    make(d);
    make(e);
}





/// ==========================================================  FOR LESS WRITING OF ll, vector,pair, map , push,size,traverse objects===================
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef set<int> si;
typedef map<string, int> msi;

///size, push
#define sz(a) int((a).size())
#define pb push_back

///traverse all container
#define all(c) c.begin(),c.end()

///loop through all container
#define tr(c,it)\
            for(typeof(c.begin()) it=(c).begin();it!=(c).end();it++)

///=============================================================== FOR USING FOR LOOP, (FORALL,FOR) ============================================
#define FORALL(i,a,b) for(int i=(a);i<=(b);++i)
#define FOR(i,n) for(int i=0;i<(n);++i)
#define FORB(i,a,b) for(int i=(a);i>=(b);--i)


//abs of any numbers
#define abs(x) (((x) < 0) ? - (x) : (x))
#define sq(x) x*x
//value of pi
#define PI 2*acos (0.0)
//}
//typedef long long ll;
typedef unsigned long long llu;
#define mem(a,v) memset(a,v,sizeof(a)) //need to see in the internet
//#define all(a) a.begin(),a.end() //it is also unclear
/*
#define db double
#define pb push_back
#define pii pair<int ,int >
#define NL puts("")
*/

#define OC printf("Case %d:",i)


///===================================================================================================================================
///====================================================================================================================================
///===============================================================max of two numbers=====================================================
//--------------------
template <class T, class U> inline T max(T &a, U &b)
{
    return a > b ? a : b;
}





///================================================================min of two numbers=========================================================
//...................
template <class T, class U> inline T min(T &a, U &b)
{
    return a < b ? a : b;
}






///=================================================================swap two numbers===========================================================
//....................
template <class T, class U> inline T swap(T &a, U &b)
{
    T tmp = a;
    a = b;
    b = tmp;
}




///=============================================================function for calculating BIGMOD===================================================
//................................
template<class T>
T bigmod(T b, T p, T m)  // b^p % m type
{
    if (p == 0)return 1;
    else if (p % 2 == 0)return sq(bigmod(b, p / 2, m)) % m;
    else return ((b%m) % bigmod(b, p - 1, m)) % m;
}//....end of the code bigmod






///================================================================code for GCD==================================================================
//..................
template <class T>
T gcd(T a, T b)
{
    /*
    if (a%b)return b;
    else return (b, a%b);
    */
    while (b > 0)
    {
        a = a%b;
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return a;

}//...end of the code gcd






///========================================================     code for lcm     ==============================================================
//.....................
template<class T>
T lcm(T a, T b)
{
    return ((a*b) / gcd(a, b));
}







///=====================================================        code for nCr   ==================================================================
//....................
template <class T>
void Divbygcd(T& a, T& b)
{
    if (a > 0 && b > 0)
    {
        T g = gcd(a, b);
        if (g > 0)
        {
            a /= g;
            b /= g;
        }
    }
}
template<class T>
T nCr(T n, T k)
{
    T numerator = 1;
    T denominator = 1;
    T toMul;
    T toDiv;
    T i;
    if (k > n/2)k = n - k;
    for (i = k; i; i--)
    {
        toMul = n - k + i;
        toDiv = i;
        Divbygcd(toMul, toDiv);
        Divbygcd(numerator, toDiv);
        Divbygcd(toMul, denominator);
        numerator *= toMul;
        denominator *= toDiv;
    }
    return numerator / denominator;

} //... end of the code of nCr






///==================================================     n'th fibonacci number     ==========================================================
//....................
template<class T>
T fib(T n)
{
    T i, h, j, k , t;
    i = h = 1;
    j = k = 0;
    while (n > 0)
    {
        if (n % 2 == 1)   // if n is odd
        {
            t = j*h;
            j = i*h + j*k + t;
            i = i*k + t;
        }
        t = h*h;
        h = 2 * k*h + t;
        k = k*k + t;
        n = (int)n / 2;
    }
    return j;

} // ......... endl of fibonacci function ..


/// ====================================================== DERENGEMENT =========================================================================

///der(n) = (n-1) * (der(n-1) + der(n-2)) ;  der(0) = 1 ; der(1) = 0;




/// ===================================================   CATALAN  ============================================================================================
///Application: number of distinc binary trees , conting number of parenthesis, parenthesizing factors, polygon to triangled , monotonic path of n*n grid(206 s&h)

/// cat(n) = (2n C n)/(n+1) ;  or ,
/// cat(n) = ( (2*m*(2*m-1)) / ((m+1)*m) )  * cat(n-1) ;


/// ========================================================= Arithmetic Progression ===============================================================

/// S = (n/2) *(2*a + (n-1) *d) ;


/// ========================================================   Geometric Progression ==================================================================

/// S = a * ( (1-pow(r,n)) / (1-r) ) ;



/// ====================================================== BIONOMIAL CO-EFFCIENT ====================================================================

///C(n,0) = C(n,n) = 1;
/// C(n,k) = C(n-1,k-1) + C(n-1,k) ;




///======================================================   sieve PRIME GENERATORE   =============================================================
//...........................

void sieve(int L, int U)   //give prime between L & U
{
    int i, j, d;
    d = U - L + 1; /* from range L to U, we have d=U-L+1 numbers. */
    /* use flag[i] to mark whether (L+i) is a prime number or not. */
    bool *flag = new bool[d];
    for (i = 0; i<d; i++) flag[i] = true; /* default: mark all to be true */
    for (i = (L % 2 != 0); i<d; i += 2) flag[i] = false;
    /* sieve by prime factors staring from 3 till sqrt(U) */
    for (i = 3; i <= sqrt(U); i += 2)
    {
        if (i>L && !flag[i - L]) continue;
        /* choose the first number to be sieved -- >=L,
        divisible by i, and not i itself! */
        j = L / i*i;
        if (j<L) j += i;
        if (j == i) j += i; /* if j is a prime number, have to start form next
							one */
        j -= L; /* change j to the index representing j */
        for (; j<d; j += i) flag[j] = false;
    }
    if (L <= 1) flag[1 - L] = false;
    if (L <= 2) flag[2 - L] = true;
    for (i = 0; i<d; i++) if (flag[i]) cout << (L + i) << " ";
    cout << endl;
}//..........end of sieve prime generator ........

ll _sieve_size;
bitset<10000010> bs;
vi primes;

void sieve(ll upperbound)
{
    _sieve_size = upperbound+1;
    bs.set();
    bs[0] = bs[1] = 0;
    for(ll i =2; i<=_sieve_size; i++)if(bs[i])
        {
            for(ll j=i*i; j <=_sieve_size; j+=i)bs[j] = 0;
            primes.push_back((int)i);
        }

}

bool isPrime(ll N)
{
    if(N<=_sieve_size)return bs[N];
    FOR(i,(int)primes.size())
    {
        if(N%primes[i] == 0)return false;
    }
    return true;
}
vll primeFactor(ll N)
{
    vll factors;
    ll PF_idx = 0, PF = primes[PF_idx];
    while(PF*PF<=N)
    {
        while(N%PF == 0)
        {
            N/=PF;
            factors.push_back(PF);
        }
        PF = primes[++PF_idx];
    }
    if(N!=1)factors.push_back(N);
    return factors;
}
/// vi r = primeFactor(142391208960LL);

ll numPF(ll N)
{
    ll PF_idx = 0,PF = primes[PF_idx],ans = 0;
    while(PF*PF <=N)
    {
        while(N%PF == 0)
        {
            N/=PF;
            ans++;
        }
        PF = primes[++PF_idx];
    }
    if(N !=1)ans++;
    return ans;
}

//numDiffPF(N)
//sumPF(N)

///number of divisors of N
ll numDiv(ll N)
{
    ll PF_idx = 0,PF = primes[PF_idx],ans = 1;
    while(PF*PF <=N)
    {
        ll power = 0;
        while(N%PF == 0)
        {
            N/=PF;
            power++;
        }
        ans *= (power+1);
        PF = primes[++PF_idx];
    }
    if(N!=1)ans = 2;
    return ans ;
}
///sum of the divisors of N
ll sumDiv(ll N)
{
    ll PF_idx = 0,PF = primes[PF_idx],ans = 1;
    while(PF*PF <=N)
    {
        ll power = 0;
        while(N%PF == 0)
        {
            N/=PF;
            power++;
        }
        ans *=((ll)pow((double)PF,power+1.0)-1)/(PF-1)  ;
        PF = primes[++PF_idx];
    }
    if(N!=1)ans *=((ll)pow((double)N,2.0)-1)/(N-1)  ;
    return ans ;

}


///EulerPhi(N) returns relatively prime < N
ll EulerPhi(ll N)
{
    ll PF_idx = 0,PF = primes[PF_idx],ans = N;
    while(PF*PF<=N)
    {
        if(N%PF == 0)ans -=ans/PF;
        while(N%PF ==0)N/=PF;
        PF = primes[++PF_idx];
    }
    if(N!=1)ans -= ans/N;
    return ans;
}



/// ============================================================lINEAR DIOPHanTINE EQUATION ==========================================

//Store x, y, d is a global variable

int x_diophantine = 0,y_diophantine = 0;

int d_diophantine;// = gcd(a,b);

void euclid(int a,int b)
{
    if (b == 0)
    {
        x_diophantine =1;
        y_diophantine=0;
        d_diophantine=a;
        return;
    }
    euclid(b,a%b);
    int x1 = y_diophantine;
    int y1 = x_diophantine-(a/b)*y_diophantine;
    x_diophantine = x1;
    y_diophantine = y1;
}


/// ==================================================  code for factorial =====================================================================
//.......................
template <class T>
T fact(T n)
{
    T sum = 1 , i;
    for (i = 1; i <= n; i++)
    {
        sum = sum*i;
    }
    return sum;
}
 ///...............................end of NUMber Theory



int isvowel(char ch) { // make sure ch is in lowercase
  char vowel[12] = "aeiouAEIOU";
  for (int j = 0; vowel[j]; j++)
    if (vowel[j] == ch)
      return 1;
  return 0;
}




/// ----------------------------------------------------Dynamic Programming --------------------------------------

int _lis( int arr[], int n, int *max_ref)
{
    /* Base case */
    if(n == 1)
        return 1;

    int res, max_ending_here = 1; // length of LIS ending with arr[n-1]

    /* Recursively get all LIS ending with arr[0], arr[1] ... ar[n-2]. If
       arr[i-1] is smaller than arr[n-1], and max ending with arr[n-1] needs
       to be updated, then update it */
    for(int i = 1; i < n; i++)
    {
        res = _lis(arr, i, max_ref);
        if (arr[i-1] < arr[n-1] && res + 1 > max_ending_here)
            max_ending_here = res + 1;
    }

    // Compare max_ending_here with the overall max. And update the
    // overall max if needed
    if (*max_ref < max_ending_here)
       *max_ref = max_ending_here;

    // Return length of LIS ending with arr[n-1]
    return max_ending_here;
}






/// ============================================================ MAIN FUNCTION=================================================================
///============================================================================================================================================

int main(int argc, char const *argv[])
{

    /*
    FOR(i,5){
        cout << i << endl;
    }
    FORALL(i,0,4){
        cout << i << endl;
    }
    FORB(i,4,0)
    {
        cout << i << endl;
    }
    int i = 5;
    OC;

    */

    sieve(10000000);
    /*
    vll r = primeFactor(126);
    int i=0;
    for(int i=0;i < r.size();i++){
        cout << r[i] << " ";
    }
    */
    long long n;
    cin >> n;
    cout << n << ": ";
    vll r = primeFactor(n);
    for(int i=0;i<r.size();i++)
    {
        cout << r[i] << " ";
    }
    cout << endl;


    cout << endl;





    //sieve(10000000);
    return 0;

}











/// ============================================= STRING PROCESSING ===================================================================

///int isvowel(char ch)
///BUILT IN : strcpy(),strcat(),strlen(),strstr(),strtok(),strcmp(),isdigit(),isalpha(),tolower(),toupper(),

///void *memchr(const void *str, int c, size_t n) // return void pointer of the found char else NULL
///char *strchr(const char *str, int c)  //like memchr() ...
///char *strrchr(const char *str, int c) // return last occurnce pointer

///void *memcpy(void *dest, const void *src, size_t n)  // copy to dest till n bytes
///void *memmove(void *str1, const void *str2, size_t n)  // almost memcopy() but better for overlapping memory

///int memcmp(const void *str1, const void *str2, size_t n) // compare lexographically till n bytes
///int strcmp(const char *str1, const char *str2) // like memcmp()
///int strncmp(const char *str1, const char *str2, size_t n)

///void *memset(void *str, int c, size_t n) // set  value c till n'th byte

///char *strcat(char *dest, const char *src)
///char *strncat(char *dest, const char *src, size_t n)

///char *strcpy(char *dest, const char *src)
///char *strncpy(char *dest, const char *src, size_t n)

///size_t strcspn(const char *str1, const char *str2) // look for first occurence of str2 in str1

///char *strpbrk(const char *str1, const char *str2) // return first matching character

///char *strstr(const char *haystack, const char *needle)

///char *strtok(char *str, const char *delim)
/*
char str[] = "this, is the string - I want to parse";
char delim[] = " ,-";
char* token;

for (token = strtok(str, delim); token; token = strtok(NULL, delim))
{
    printf("token=%s\n", token);
}
*/
///size_t strxfrm(char *dest, const char *src, size_t n) //return length of formed string

/// String to Other Type Casting
/*
char sentence []="Rudolph is 12 years old";
  char str [20];
  int i;
  sscanf (sentence,"%s %*s %d",str,&i);
*/













///====================================================================================================================================
///========================================================================== JAVA BIGINTEGER ============================================================
///isProbablePrime(int certainty)  //certainty = 10 ( almost give correct anser -_- , try to avoid)
///gcd(BI)
///modPow(BI exponent , BI m)
///toString()

///for BaSE Convertion:      BigInteger p = new BigInteger(sc.next(),b) ; //convert the number to b base