Problem:
Score : 1100 points

Problem Statement

Snuke got positive integers s_1,...,s_N from his mother, as a birthday present. There may be duplicate elements.

He will circle some of these N integers. Since he dislikes cubic numbers, he wants to ensure that if both s_i and s_j (i ≠ j) are circled, the product s_is_j is not cubic. For example, when s_1=1,s_2=1,s_3=2,s_4=4, it is not possible to circle both s_1 and s_2 at the same time. It is not possible to circle both s_3 and s_4 at the same time, either.

Find the maximum number of integers that Snuke can circle.

Constraints

1 ≦ N ≦ 10^5

1 ≦ s_i ≦ 10^{10}

All input values are integers.

Input

The input is given from Standard Input in the following format:

N
s_1
:
s_N

Output

Print the maximum number of integers that Snuke can circle.

Sample Input 1

8
1
2
3
4
5
6
7
8

Sample Output 1

6

Snuke can circle 1,2,3,5,6,7.

Sample Input 2

6
2
4
8
16
32
64

Sample Output 2

3

Sample Input 3

10
1
10
100
1000000007
10000000000
1000000009
999999999
999
999
999

Sample Output 3

9

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const int MN = 100010;

vector<int> pr;
int pchk[MN];

void Sieve() {
    for(int i = 2; i < MN; i++) {
        if(!pchk[i]) {
            pr.push_back(i);
        }
        for(int j = 0; j < pr.size() && i * pr[j] < MN; j++) {
            pchk[ i * pr[j] ] = 1;
            if(i % pr[j] == 0) break;
        }
    }
}

int N;
ll S[100010];
pll C[100010];
map<pll, int> Cnt, Chk;

int main() {
    Sieve();

    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%lld", &S[i]);
    }

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < pr.size() && 1LL * pr[j] * pr[j] * pr[j] <= S[i]; j++) {
            while(S[i] % (1LL * pr[j] * pr[j] * pr[j]) == 0) {
                S[i] /= (1LL * pr[j] * pr[j] * pr[j]);
            }
        }

        if(1) {
            ll n = S[i];
            ll tmp = 1;
            for(int j = 0; j < pr.size() && pr[j] <= 2000; j++) {
                if(n % pr[j] == 0 && n % (1LL * pr[j] * pr[j])) {
                    n /= pr[j];
                    tmp *= pr[j];
                }
            }

            ll t = sqrt(n);
            if(t * t == n) {
                C[i] = pll(tmp, t);
                Cnt[ C[i] ]++;
                continue;
            }
        }
        if(2) {
            ll n = S[i];
            ll tmp = 1;
            for(int j = 0; j < pr.size() && 1LL * pr[j] * pr[j] <= 5000000; j++) {
                if(n % (1LL * pr[j] * pr[j]) == 0) {
                    n /= (1LL * pr[j] * pr[j]);
                    tmp *= 1LL * pr[j] * pr[j];
                }
            }
            C[i] = pll(n, tmp);
            Cnt[ C[i] ]++;
        }
    }

    int ans = Cnt[ pll(1, 1) ]? 1 : 0;
    Chk[ pll(1, 1) ] = 1;
    for(int i = 0; i < N; i++) {
        if(Chk[ C[i] ]) continue;

        ll t1 = C[i].first;
        ll t2 = C[i].second;

        ans += max(Cnt[ C[i] ], Cnt[ pll(t2, t1) ]);

        Chk[ C[i] ] = 1;
        Chk[ pll(t2, t1) ] = 1;
    }

    printf("%d", ans);
}