Language: C++

/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
#include<tr1/unordered_map>
using namespace std;

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}

inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong

#define ll long long
#define int long long

const int maxn = 2e6 + 30;
const int maxm = 4e6 + 30;
const int asd = 2e8 + 30;
int n;
ll a[maxn], tmp[maxn], point[maxn];
unordered_map<ll, int> mmp;
int head[maxn], cnt, to[asd], du[maxn], net[asd];
inline void add(int x, int y) {
	net[++cnt] = head[x]; head[x] = cnt; to[cnt] = y;
}
int tong[maxn], t[maxn];
int dp[maxn][2];
void dfs(int x, int fa) {
	dp[x][0] = point[x];
	for (int i = head[x]; i; i = net[i]) {
		int v = to[i];
		if (v == fa) continue;
		dfs(v, x);
		dp[x][1] += dp[v][0];
		dp[x][0] += max(dp[v][0], dp[v][1]);
	}
}
signed main() {
	n = ri();
	for (int i = 1; i <= n; i++) {
		a[i] = rl();
	}
	sort(a + 1, a + 1 + n);
	int tot = 0;
	for (int i = 1; i <= n; i++) {
		if (i == 1 || a[i] != a[i - 1]) {
			tmp[++tot] = a[i]; point[tot] = 1;
		}
		else point[tot] ++;
	}
	n = tot;
	ll Maxx = 0;
	tot = 0;
	for (int i = 1; i <= n; i++) {
		a[i] = tmp[i];
		t[i] = a[i];
		Maxx = max(Maxx, a[i]);
	}
	for (int i = 1; i <= n; i++) {
		mmp[a[i]] = i;
		for (ll j = 1; j * j * j <= Maxx; j++) {
			ll pp = j * j * j;	
			if (pp % a[i] != 0) continue;
			if (mmp[pp / a[i]] == 0) continue;
			if (mmp[pp / a[i]] == i) point[i] = 1;
			else {
				add(a[i], pp / a[i]);	du[i]++;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (du[i] == 0) {
			dfs(i, 0);
			ans += max(dp[i][0], dp[i][1]);
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int readint()':
a.cc:15:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   15 |     register int x = 0, flag = 1;
      |                  ^
a.cc:15:25: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   15 |     register int x = 0, flag = 1;
      |                         ^~~~
a.cc:16:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   16 |     register char ch;
      |                   ^~
a.cc: In function 'long long int readlong()':
a.cc:23:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   23 |         register long long x = 0, flag = 1;
      |                            ^
a.cc:23:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   23 |         register long long x = 0, flag = 1;
      |                                   ^~~~
a.cc:24:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |         register char ch;
      |                       ^~
/tmp/ccHvK6NJ.o: in function `dfs(long long, long long)':
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0xa7): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0xbd): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0xd7): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0xee): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0x103): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0x126): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0x140): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
/tmp/ccHvK6NJ.o: in function `main':
a.cc:(.text+0x35a): relocation truncated to fit: R_X86_64_PC32 against symbol `t' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0x5e3): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0x5f8): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status