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<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=100005,m=2154;
int n,ans,flg,p[m];bool vis[m+5];
struct ltl{
	long long x;bool y;
	bool operator <(ltl b)const{return x<b.x;}
}a[maxn];
inline char nc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline long long read(){
	long long ret=0;bool f=0;char ch=nc();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=nc();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc();
	return f?-ret:ret;
}
inline void make_p(){
	for (int i=2;i<=m;i++){
		if(!vis[i]) p[++p[0]]=i;
		for (int j=1;j<=p[0];j++){
			if(i*p[j]>m) break;
			vis[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}
}
int main(){
	make_p();
	for (int T=read();T--;){
		long long now=read(),x=1,y=1;
		for (int i=1;i<=p[0];i++){
			int cnt=0;
			while(now%p[i]==0) cnt++,now/=p[i];
			if(cnt%3==1) x*=p[i],y*=p[i]*p[i];
			if(cnt%3==2) x*=p[i]*p[i],y*=p[i];
			if(y>1e10) break;
		}
		if(y>1e10){ans++;continue;}
		if(now^1){
			int S=sqrt(now);
			if(S*S<now) S++;if(S*S>now) S--;
			if(S*S==now) x*=now,y*=S;else
			if(now<=sqrt(1e10/y)) x*=now,y*=now*now;
			else{ans++;continue;}
		}
		if(y>1e10){ans++;continue;}
		if(x==1) ans+=!flg,flg=1;else
		a[++n]=(ltl){min(x,y),x<=y};
	}
	sort(a+1,a+1+n);
	for (int i=1,j;i<=n;i=j){
		int cnt[2]={0,0};
		for (j=i;a[i].x==a[j].x&&j<=n;j++) cnt[a[j].y]++;
		ans+=max(cnt[0],cnt[1]);
	}
	printf("%d\n",ans);
	return 0;
}