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 <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,ii ) for( typeof(gg.begin()) ii=gg.begin();ii!=gg.end();ii++)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define sz(a) int((a).size())
#define N 100010
#define MAX 2156
#define mod 1000000007
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define all(a) a.begin(),a.end()
const ll INF = 1e18+1;

ll a[N],cube[MAX];
int primes[N];
map <ll, ll> conjugate;
map <ll, int> vis,cnt;

void make()
{
	int i,j,k,cnt;
	FILL(primes,0);
	primes[0]=1;
	primes[1]=1;
	for(i=2;i<N;i++)
	{
		if (primes[i]) continue;
		for(j=2*i;j<N;j+=i) primes[j]=1;
	}
}

int main()
{
	ll n,ans=0,x,y,z,flag,a1,b=1ll*(N-10)*(N-10);
	make();
	scanf("%lld",&n);
	REP(i,MAX) cube[i]=1ll*i*i*i;
	REP(i,n)
	{
		scanf("%lld",&a[i]);
		if (vis[a[i]]) continue;
		vis[a[i]]=1;
		//printf("%d %d\n",i,n);
		REPP(j,2,MAX)
		{
			if (primes[j]) continue;
			while (a[i]%cube[j]==0) a[i]/=cube[j];
		}
		cnt[a[i]]++;
		x=a[i];
		z=1;
		flag=0;
		REPP(j,2,MAX)
		{
			if (primes[j]) continue;
			a1=j*j;
			y=__gcd(x,a1);
			if (y==a1) z*=j;
			else if (y==j) z*=a1;
			x/=y;
			if (z>b&&x!=1) {flag=1; break;}
			if (x==1) break;
		}
		if (flag) conjugate[a[i]]=-1;
		else
		{
			if (x>1)
			{
				if (x<(N-10)&&!primes[x])
				{
					z*=x;
					if (z>b)
						conjugate[a[i]]=-1;
					else
					{
						z*=x;
						if (z>b)
							conjugate[a[i]]=-1;
						else conjugate[a[i]]=z;
					}
				}
				else
				{
					y=sqrt(x);
					if (y*y!=x) conjugate[a[i]]=-1;
					else
					{
						z*=y;
						if (z>b)
							conjugate[a[i]]=-1;
						else conjugate[a[i]]=z;
					}
				}
			}
			else
				conjugate[a[i]]=z;
		}
	}
	//REP(i,n) printf("%lld %lld\n",a[i],conjugate[a[i]]);
	REP(i,n) vis[a[i]]=0;
	REP(i,n)
	{
		if (vis[a[i]]) continue;
		vis[a[i]]=1;
		if (conjugate[a[i]]==-1) ans+=cnt[a[i]];
		else
		{
			vis[conjugate[a[i]]]=1;
			ans+=max(cnt[conjugate[a[i]]],cnt[a[i]]);
		}
	}
	if (cnt[1]) ans-=(cnt[1]-1);
	printf("%lld\n",ans);
return 0;
}