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 <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

using VP = vector<P>;

VI primes = {2};
unordered_map<long, long> cubes;

void addPrimes() {
    for (int i = 3; i <= 100000; i += 2) {
        bool fl = true;
        for (long j: primes) {
            if (i % j == 0) {
                fl = false;
                break;
            }
        }
        if (fl) primes.push_back(i);
    }
}

void addCubes() {
    for (long i = 1; i * i * i <= 10000000000l; i++) {
        cubes[i * i * i]++;
    }
}

long getminp(long p, long start) {
    REPI(i, start, primes.size()) if (p % primes[i] == 0) return primes[i];
    return p;
}

VP fctr(long s) {
    VP v;
    long p = 2;
    while (s != 1) {
        p = getminp(s, p);
        long cn = 0;
        while (s % p == 0) {
            s /= p;
            cn++;
        }
        if (cn % 3) {
            v.push_back(P(p, cn % 3));
        }
    }
    return v;
}

long cnt = 0;
map<VP, long> m;

void hoge(VP f) {
    if (m[f] == 0) return;
    VP v;
    for (P a: f) {
        v.push_back(P(a.first, (3 - a.second) % 3));
    }
    cnt += max(m[f], m[v]);
    m[f] = 0;
    m[v] = 0;
}

int main() {
    addPrimes();
    addCubes();
    long n;
    cin >> n;
    bool hasCube;
    long s;
    REP(i,n) {
        cin >> s;
        if (cubes[s]) {
            hasCube = true;
        } else {
            VP f = fctr(s);
            m[f]++;
        }
    }
    
    for (auto itr = m.begin(); itr != m.end(); itr++) {
        hoge(itr->first);
    }
    cout << cnt + hasCube << endl;
}