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<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
using namespace std;
typedef long long ll;
const int N = 100000;

int n;
map<ll,ll> mp, cnt, nxt;
ll p[N];
ll isp[N + 10], pcnt = 0;
inline void prepare() {
  isp[0] = isp[1] = 1;
  for(ll i = 2;i <= N;i ++) {
    if(!isp[i]) p[++ pcnt] = i, mp[1LL * i * i] = i;
    for(ll j = 1;j <= pcnt && i * p[j] <= N;j ++) {
      isp[i * p[j]] = 1;
      if(i % p[j] == 0) break;
		}
	}
}

int main() {
	mp.clear(); cnt.clear(); nxt.clear();
	prepare();
	scanf("%d", &n);
	for(ll i = 1;i <= n;i ++) {
	  ll x, y; scanf("%lld", &x); y = x;
//	  cout << x << ' ';
	  ll now1 = 1LL, now2 = 1LL;
	  for(ll j = 1;j <= pcnt && 1LL * p[j] * p[j] * p[j] <= x;j ++) {
	    if(x % p[j] == 0) {
	    	ll tmp = 0;
	      while(x % p[j] == 0) {
	      	tmp ++;
	      	x /= p[j];
	      }
	      tmp %= 3;
	      for(int _ = 1; _ <= tmp; _ ++) now1 *= p[j];
	      for(int _ = 1; _ <= 3 - tmp; _ ++) now2 *= p[j];
			}
		}
		if(x != 1) {
		  now1 *= x;
		  if(mp.find(x) != mp.end()) now2 *= mp[x];
		  else now2 *= x * x;
		}
//		cout << now1 << ' ' << now2 << endl;
		cnt[now1] ++;
		nxt[now1] = now2;
		nxt[now2] = now1;
	}
	ll Ans = 0;
	if(cnt.find(1) != cnt.end()) {
	  Ans ++;
	  cnt.erase(cnt.find(1));
	}
	map<ll,ll>::iterator tmp;
	for(tmp = cnt.begin();tmp != cnt.end();tmp ++) {
//		cout << tmp->first << ' ' << nxt[tmp->first] << endl;
	  if(cnt.find(nxt[tmp->first]) == cnt.end()) {
	    Ans += tmp->second;
		}
		else {
			Ans += max(tmp->second,cnt[nxt[tmp->first]]);
			cnt[nxt[tmp->first]] = 0;
			tmp->second = 0;
		}
	}
	printf("%lld\n", Ans);
  return 0;
}