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 <bits/stdc++.h>

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

#define LIM 1E10

using namespace std;

#define R 2200

int n, pr[2005], p, ans;
LL s[100005], pal[100005];

map<LL, int> M, M_pal;

bool isp(int x){
	FI(i, 1, p) if(x % pr[i] == 0) return false;
	return true;
}

int main(){
	FI(i, 2, R) if(isp(i)) pr[++p] = i;
	
	scanf("%d", &n);
	FI(i, 1, n){
		scanf("%lld", &s[i]);
		FI(j, 1, p){
			LL u = 1LL * pr[j] * pr[j] * pr[j];
			while(s[i] % u == 0) s[i] /= u;
		}
		//Now s[i] is p^3-free
		LL tmp = s[i];
		pal[i] = 1;
		FI(j, 1, p){
			if(tmp % pr[j] == 0 && pal[i] != -1){
				LL u = 1LL * pr[j] * pr[j] * pr[j];
				while(tmp % pr[j] == 0){
					tmp /= pr[j];
					u /= pr[j];
				}
				if(1.0 * pal[i] * u > LIM) pal[i] = -1;
				else pal[i] *= u;
			}
		}
		
		if(tmp > 1 && pal[i] != -1){
			LL rt = sqrt(tmp);
			if(rt * rt == tmp && 1.0 * pal[i] * rt <= LIM) pal[i] *= rt;
			else if(1.0 * pal[i] * tmp * tmp <= LIM) pal[i] *= tmp * tmp;
			else pal[i] = -1;
		}
	}
//	FI(i, 1, n) printf("%d: %lld %lld\n", i, s[i], pal[i]);
	FI(i, 1, n){
		if(!M.count(s[i])){
			M[s[i]] = 1;
			M_pal[s[i]] = pal[i];
		}
		else M[s[i]]++;
	}
	for(auto pi: M){
		LL u = pi.fi, cnt = pi.se;
		LL pa = M_pal[u];
		if(pa == -1) ans += cnt;
		else if(pa == u) ans++; //only if u == 1
		else{
			if(M.count(pa)){
				assert(M_pal[pa] == u);
				if(pa > u) ans += max(cnt, (LL)M[pa]);
			} else ans += cnt;
		}
	}
	printf("%d\n", ans);
	return 0;
}