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: Wrong Answer)

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define MAX_P 3000

ll N;
vector<ll> primes;
map<ll,ll> prime2;


void getPrime(ll n){
    vector<bool> p(n+10,true);
    for(ll i=2;i<=n;i++){
        if(!p[i]) continue;
        if(p[i]) primes.push_back(i);
        for(ll j=2;i*j<=n;j++) p[i*j] = false;
    }
}

int main(){
    bool f=false;
    getPrime(MAX_P+10);
    for(ll p : primes) prime2[p*p]=p;

    cin>>N;
    vector<ll> S(N);
    for(int i=0;i<N;i++) cin>>S[i];

    // Norm[t] : Norm(t)
    // NN[t] : Norm(t) の個数
    // Pair[t] : Pair(t)
    map<ll,ll> Norm,NN,Pair;
    for(int i=0;i<N;i++){
        ll s = S[i];
        ll n = 1;       // norm(s)
        ll r = 1;       // pair(s)
        for(ll p : primes){
            if(p>s) break;
            ll cnt=0;
            ll x=0;
            while(s%p==0){
                x++;
                assert(x<100);
                cnt++;
                s/=p;
            }
            cnt%=3;

            if(cnt==1){
                n *= p;
                r *= p*p;
            }else if(cnt==2){
                n *= p*p;
                r *= p;
            }
        }

        if(s > 1){
            if(prime2.count(s)){
                //sは素数の2乗
                n *= s;
                r *= prime2[s];
            }else{
                n *= s;
                r *= s*s;
            }
        }

        NN[n]++;
        Norm[S[i]]=n;
        Pair[S[i]]=r;
        if(n==1){
            assert(n==r);
        }
        if(n==1) f=true;
    }

    ll ans = 0;
    if(f) ans++;


    map<ll,bool> used;
    for(int i=0;i<N;i++){
        ll n = Norm[S[i]];
        ll p = Pair[S[i]];

        if(used.count(n)==false) used[n]=false;
        if(used.count(p)==false) used[p]=false;

        if(n==1) continue;
        if(used[n]){
            if(used[p]) continue;
            ans += NN[p];
        }else if(used[p]){
            if(used[n]) continue;
            ans += NN[n];
        }else{
            if(NN[n] >= NN[p]){
                ans += NN[n];
            }else{
                ans += NN[p];
            }
        }
        used[n]=used[p]=true;
    }
    assert(ans>0);
    cout << ans << endl;
}