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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

typedef pair<ll, ll> p_ll;
const int nm = 3 * pow(10,3);
vector<bool> isp(nm, true);
vector<ll> primes;

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=nm; i++) {
    if (isp[i]) for(int j=2; i*j<=nm; j++) isp[i*j] = false;
  }
  rep(i,nm) if (isp[i]) primes.push_back(i);
}

int main() {
  int N; cin >>N;
  ll s[N]; rep(i,N) cin >> s[i];
  sieve();
  map<p_ll, ll> num;
  ll result = 0;
  rep(i,N) {
    p_ll p = make_pair(1,1);
    for (auto prime: primes) {
      while (s[i]%(ll)pow(prime,3)==0) {s[i]/=(ll)pow(prime,3);}
      if (s[i]%prime!=0) continue;
      s[i]/=prime;
      if (s[i]%prime==0) { s[i]/=prime; p.first*=(ll)pow(prime,2); p.second*=prime; }
      else { p.first*=prime; p.second*=(ll)pow(prime,2); }
    }
    if (s[i]!=1) {
      double sq = sqrt(s[i]);
      if (floor(sq)==sq) { p_ll ppp = make_pair(s[i],sq); num[ppp]++; }
      else result++;
    }
    else num[p]++;
    // cout << p.first << " " << p.second << endl;
  }
  for (auto x: num) {
    if (x.first.first==1) { result++; continue; }
    p_ll ppp = make_pair(x.first.second, x.first.first);
    if (num[ppp]) {
      if (x.first.first>x.first.second) continue;
      result += max(x.second, num[ppp]);
    }
    else result += x.second;
    // cout << x.first.first << "&" << x.first.second << "->" << x.second << endl;
  }
  cout << result << endl;
  return 0;
}