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;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pi;

const int maxn = 1e5 + 5;
ll s[maxn], t[maxn];
int n;

vector<ll> prime;

void init_prime(int N){
    vector<int> vis(N, 0);
    prime.clear();
    vis[1] = 1;
    for(int i = 2;i < N;i++){
        if(!vis[i]){
            prime.push_back(i);
            for(int j = i * 2;j < N; j += i){
                vis[j] = 1;
            }
        }
    }
}

ll qpow(ll a, ll n){
    ll ret = 1;
    while(n > 0){
        if(n & 1){
            ret = ret * a;
        }
        a = a * a;
        n >>= 1;
    }
    return ret;
}

vector<pair<ll, int> > decom(ll v){
    vector<pair<ll, int> > ans;
    for(int i = 0;i < prime.size();i++){
        if(prime[i] > v)
            break;
        if(v % prime[i] == 0){
            int cnt = 0;
            while(v % prime[i] == 0){
                v /= prime[i];
                cnt++;
            }
            cnt %= 3;
            ans.eb(prime[i], cnt);
        }
    }
    if(v > 1){
        ll rt = (ll)(sqrt(v) + 0.5);
        if(rt * rt == v){
            ans.eb(rt, 2);
        }else{
            ans.eb(v, 1);
        }
    }
    return ans;
}

int Inv[3] = {0, 2, 1};

ll cal(vector<pair<ll, int> > rep, bool inv){
    ll ret = 1;
    for(auto p : rep){
        int cnt = p.se;
        if(inv)
            cnt = Inv[cnt];
        ret = ret * qpow(p.fi, cnt);
    }
    return ret;
}

map<ll, int> Count;
map<ll, bool> visited;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    init_prime(2500);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> s[i];
        vector<pair<ll, int> > rep = decom(s[i]);
        ll v1 = cal(rep, false);
        ll v2 = cal(rep, true);
        Count[v1]++;
    }
    ll ans = 0;
    for(auto v : Count){
        ll val = v.first;
        if(visited.count(val))
            continue;
        int cnt = v.second;
        if(val == 1){
            ans++;
            visited[val] = true;
            continue;
        }
        vector<pair<ll, int> > rep = decom(val);
        ll val1 = cal(rep, true);
        if(Count.count(val1)){
            ans += max(cnt, Count[val1]);
            visited[val] = true;
            visited[val1] = true;
        }else{
            ans += cnt;
            visited[val] = true;
        }
    }
    cout << ans << endl;
    return 0;
}