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 Rust (1.15.1) (judge verdict: Wrong Answer)

#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
use std::io::Write;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn generate_primes(upto: usize) -> Vec<i64> {
    let mut is_prime = vec![true; upto+1];
    is_prime[0] = false;
    is_prime[1] = false;
    for i in 2..upto+1 {
        if is_prime[i] {
            let mut ii = i * i;
            while ii <= upto {
                is_prime[ii] = false;
                ii += i;
            }
        }
    }

    let mut primes = vec![];
    for i in 0..upto+1 {
        if is_prime[i] {
            primes.push(i as i64);
        }
    }
    primes
}


fn main() {
    let n: usize = read();
    let a: Vec<i64> = readn(n);

    let primes = generate_primes(100010);
    let pn = primes.len();


    let mut anti_map = HashMap::new();
    let mut count_map: HashMap<i64, usize> = HashMap::new();

    let mut ans = 0;
    let mut has_cube = false;
    for i in 0..n {
        let mut aa = a[i];
        let mut normalized = 1;
        let mut anti = 1;
        let mut is_cube = true;
        for pi in 0..pn {
            let p = primes[pi];
            if aa < p {
                break
            }
            let mut cnt = 0;
            while aa % p == 0 {
                aa /= p;
                cnt += 1;
            }
            if cnt % 3 == 1 {
                normalized *= p;
                anti *= p;
                anti *= p;
                is_cube = false;
            } else if cnt % 3 == 2 {
                normalized *= p;
                normalized *= p;
                anti *= p;
                is_cube = false;
            }
        }
        if aa >= 2 {
            ans += 1;
        } else if !is_cube {
            anti_map.insert(normalized, anti);

            match count_map.get(&normalized) {
                Some(&n) => count_map.insert(normalized, n+1),
                _        => count_map.insert(normalized, 1),
            };
        }
        has_cube |= is_cube;
    }
    
    let mut processed = HashSet::new();
    for (num, &v0) in count_map.iter() {
        let anti = anti_map.get(&num).unwrap();
        if processed.contains(num) || processed.contains(anti) {
            continue
        }
        let zero = &0;
        let v1 = *count_map.get(&anti).unwrap_or(zero);
        ans += max(v0, v1);
        processed.insert(num);
        processed.insert(anti);
    }
    if has_cube {
        ans += 1;
    }
    println!("{}", ans);
}