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 <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <stack>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <iterator>
#include <cstring>

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> point;
typedef pair<int, int> pointI;

#define PI 3.1415926535897932384626433832795

const ll mod=1000000007LL;
const ll top=10000000047;
vector<ll> primes;

ll stupid_pow(ll base, int e) {
	ll ans=1;
	while (e>0) ans*=base, e--;
	return ans;
}

ll compute_norm(ll n) {
	ll i=1, ans=n;
	while (stupid_pow(i, 3)<=n) {
		ll tmp=stupid_pow(i, 3);
		if (n%tmp==0) ans=n/tmp;
		i++;
	}
	return ans;
}

bool is_square(ll n) {
	for (int i=0; primes[i]*primes[i]<=n; i++)
		if (primes[i]*primes[i]==n) return true;
	return false;
}

ll compute_pair(ll n) {
	ll ans=1;
	for (int i=0; primes[i]<5047; i++) {
		int e=0;
		while (n%primes[i]==0) e=(3+e-1)%3, n/=primes[i];
		ans*=stupid_pow(primes[i], e);
	}
	if (is_square(n)) ans*=sqrt(n);
	else ans*=n*n;
}

int main() {
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<ll> input(n); for (int i=0; i<n; i++) cin>>input[i];
    primes.reserve(10000);

    for (ll i=2; i*i<top; i++) {
    	bool ins=true;
    	for (int j=0; (j<primes.size())&&(ins); j++) if (i%primes[j]==0) ins=false;
    	if (ins) primes.emplace_back(i);
    }

    bool inserted_one=false;
    map<point, int> mmap;
    int ans=0;

    for (int i=0; i<n; i++) {
    	ll pr=compute_pair(input[i]), nm=compute_norm(input[i]);
    	if (pr==1) {
    		if (inserted_one==false) ans++, inserted_one=true;
    	}
    	else mmap[point(pr, nm)]++;
    }

    while (!mmap.empty()) {
    	map<point, int>::iterator i1=mmap.begin();
    	map<point, int>::iterator i2=mmap.find(point(i1->first.second, i1->first.first));

    	if (i2==mmap.end()) {
    		ans+=i1->second;
    		mmap.erase(i1);
    	}
    	else {
    		ans+=max(i1->second, i2->second);
    		mmap.erase(i1);
    		if (i1!=i2) mmap.erase(i2);
    	}
    }

    cout<<ans<<endl;
    return 0;
}