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: Runtime Error)

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 200020
#define MAXN 2655
using namespace std;
namespace IO{
	const LL BS=(1<<20)+5; LL Top=0; char Buffer[BS],*HD,*TL;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	LL read(){
		LL nm=0,fh=1; char cw=Getchar();
		for(;!isdigit(cw);cw=Getchar());
		for(;isdigit(cw);cw=Getchar()) nm=nm*10+(cw-'0');
		return nm*fh;
	}
}
using namespace IO;
LL n,m,q[M][24],cnt,sz[M],K[M],res,mp[5000000];
LL od[M],ans; LL p[M],pri[M];
bool isp[M];
bool cmp(LL x,LL y){
	int mn=min(sz[x],sz[y]);
	for(LL i=0;i<mn;i++) if(q[x][i]!=q[y][i]) return q[x][i]<q[y][i];
	return sz[x]<sz[y];
}
int main(){
	memset(isp,true,sizeof(isp));
	for(LL i=2;i<MAXN;i++){
		if(!isp[i]) continue; pri[++m]=i;
		for(LL j=i;j<MAXN;j+=i) isp[j]=false;
	} n=read();
	for(LL j,i=1;i<=n;i++){
		for(p[i]=read(),j=1;j<=m;j++){
			if(p[i]%pri[j]) continue;
			LL cnt=0; while(!(p[i]%pri[j])) p[i]/=pri[j],++cnt; cnt%=3;
			if(cnt) q[i][sz[i]]=j,K[i]|=((cnt&1)<<sz[i]),sz[i]++;
		} if(p[i]>1ll) res++,i--,n--;
	}
	for(LL i=1;i<=n;i++) od[i]=i; sort(od+1,od+n+1,cmp);
	for(LL l=1,r;l<=n;l=r+1){
		for(r=l;r<n&&!cmp(od[r],od[r+1]);r++);
		if(!sz[od[l]]){res++;continue;}
		LL maxn=(1<<sz[od[l]])-1;
//		for(LL i=l;i<=r;i++){
//			LL x=od[i];
//			printf("sz = %d   K = %d\n",sz[x],K[x]);
//			for(LL j=0;j<sz[x];j++) printf("%d\n",pri[q[x][j]]);
//		}
		for(LL i=l;i<=r;i++) mp[K[od[i]]]++;
		for(LL i=l;i<=r;i++){
			LL x=K[od[i]],ot=maxn^K[od[i]];
			if(mp[x]>=mp[ot]) ans+=mp[x],mp[x]=mp[ot]=0;
		}
		for(LL i=l;i<=r;i++) mp[K[od[i]]]=0;
//		printf("[ %d , %d ] res = %d   ans = %d  maxn = %d\n",l,r,res,ans,maxn);
	} printf("%lld\n",ans+res); return 0;
}