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: Accepted)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100005;
int n;
LL a[N],psqr[N];
int vis[N],prime[N],pcnt;
void Get_Prime(int n){
	pcnt=0;
	memset(vis,0,sizeof vis);
	for (int i=2;i<=n;i++){
		if (vis[i])
			continue;
		prime[++pcnt]=i;
		for (int j=i<<1;j<=n;j+=i)
			vis[j]=1;
	}
}
map <LL,int> cubic,sqr,cnt;
int check_cubic(){
	int f=0;
	int _n=0;
	for (int i=1;i<=n;i++)
		if (cubic[a[i]])
			f=1;
		else
			a[++_n]=a[i];
	n=_n;
	return f;
}
LL Get(LL x){
	LL res=1;
	for (int i=1;i<=pcnt;i++)
		if (x%prime[i]==0){
			LL cnt=1;
			x/=prime[i];
			if (x%prime[i]==0)
				x/=prime[i],cnt++;
			cnt=3-cnt;
			while (cnt>0){
				cnt--,res*=prime[i];
				if (res>1e11)
					return -1;
			}
		}
	if (x>1){
		LL t=x;
		if (sqr[x]>0)
			t=sqr[x];
		else {
			if (x>1e8)
				return -1;
			t=x*x;
		}
		if (t>1e11/res)
			return -1;
		res*=t;
	}
	return res>1e10?-1:res;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	cubic.clear(),sqr.clear();
	for (int i=1;i<=2500;i++)
		cubic[1LL*i*i*i]=i;
	for (int i=1;i<=100000;i++)
		sqr[1LL*i*i]=i;
	int ans=check_cubic();
	Get_Prime(2500);
	for (int i=1;i<=pcnt;i++)
		psqr[i]=1LL*prime[i]*prime[i]*prime[i];
	cnt.clear();
	for (int i=1;i<=n;i++){
		for (int j=1;j<=pcnt;j++)
			while (a[i]%psqr[j]==0)
				a[i]/=psqr[j];
		cnt[a[i]]++;
	}
	for (int i=1;i<=n;i++){
		if (!cnt[a[i]])
			continue;
		LL b=Get(a[i]);
		ans+=max(cnt[a[i]],cnt[b]);
		cnt[a[i]]=cnt[b]=0;
	}
	printf("%d",ans);
	return 0;
}