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<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
//<< setprecision(5)
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
vector<llint>prime;
void init(void){
	//2200まででよい
	for(llint i=2;i<2200;i++){
		bool ok=true;
		for(auto j:prime){
			if(j*j<=i){break;}
			if(i%j==0){ok=false;break;}
		}
		if(ok){prime.pub(i);}
	}
}
pair<llint,pair<llint,llint>> han(llint in){//3乗を除いたもの,1乗部分,2乗部分の平方根
	pair<llint,llint> ans;
	ans=mp(1LL,1LL);
	int gen;
	for(auto i:prime){
		gen=0;
		while(in%i==0){in/=i;gen++;}
		if(gen%3==1){ans.fir*=i;}
		if(gen%3==2){ans.sec*=i;}
	}
	ans.fir*=in;
	return mp(ans.fir*ans.sec*ans.sec,ans);
}
int main(void){
	init();
	llint ans=0;
	int i,n;cin>>n;
	map<llint,pair<llint,pair<llint,llint>>> a;//惨状を除く,回数,1部,2部
	llint q;
	for(i=0;i<n;i++){
		cin>>q;
		auto ret=han(q);
		auto dai=mp(a[ret.fir].fir+1,ret.sec);
		a[ret.fir]=dai;
	}
	for(auto it:a){
		if(it.fir==1){ans++;continue;}
		if(it.sec.sec.fir>100000){ans+=it.sec.fir;continue;}
		llint th=it.sec.sec.fir*it.sec.sec.fir*it.sec.sec.sec;
		if(a.count(th)!=0){if(it.fir>th){continue;}ans+=max(a[th].fir,it.sec.fir);}
		else{ans+=it.sec.fir;}
	}
	cout<<ans<<endl;
	return 0;
}