Given a non-empty array of unique positive integers A, consider the following graph:

There are A.length nodes, labelled A[0] to A[A.length - 1];
There is an edge between A[i] and A[j] if and only if A[i] and A[j] share a common factor greater than 1.

Return the size of the largest connected component in the graph.
 



Example 1:
Input: [4,6,15,35]
Output: 4



Example 2:
Input: [20,50,9,63]
Output: 2



Example 3:
Input: [2,3,6,7,4,12,21,39]
Output: 8


Note:

1 <= A.length <= 20000
1 <= A[i] <= 100000

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

def _disabled_input(*args, **kwargs):
    raise RuntimeError("input() is disabled in callable mode")
builtins.input = _disabled_input

ns = {"__name__": "__judge__"}  # prevent if __name__ == "__main__" blocks
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "from collections import defaultdict, Counter\n\nMAX_N = 100000\n\n\nclass Solution:\n    def largestComponentSize(self, A: List[int]) -> int:\n        sieve = Sieve(MAX_N+1)\n        factors = defaultdict(list)\n        for x in A:\n            for factor in sieve.factorize(x):\n                factors[factor].append(x)\n\n        uf = UnionFind()\n        for values in list(factors.values()):\n            for i in range(1, len(values)):\n                uf.connect(values[i-1], values[i])\n                \n        return max(list(Counter(uf.root(x) for x in A).values()), default=0)\n        '''\n        \n        # build bipartite graph from factors and values\n        g = Graph()\n        for factor, values in factors.items():\n            g.add_factor(factor)\n            for value in values:\n                g.add_value(value)\n                g.connect(factor, value)\n        \n        return g.find_largest_connected_size()\n        '''\n\n    \nclass UnionFind:\n    def __init__(self):\n        self.parents = {}\n    \n    def connect(self, a, b):\n        if a not in self.parents:\n            self.parents[a] = a\n        \n        if b not in self.parents:\n            self.parents[b] = b\n            \n        root = self.root(b)\n        self.parents[self.root(a)] = root\n        return root\n    \n    def root(self, a):\n        if a not in self.parents:\n            self.parents[a] = a\n            return a\n\n        if a == self.parents[a]:\n            return a\n        \n        self.parents[a] = self.root(self.parents[a])\n        \n        return self.parents[a]\n\n\nclass Sieve:\n    def __init__(self, limit):\n        self.primes = self._compute_primes(limit)\n        # better runtime than simply empty dict!\n        self.factors = {p: {p} for p in self.primes}\n        self.factors[1] = set()\n        \n    def _compute_primes(self, limit):\n        primes = list()\n        sieve = [True] * limit\n        for prime in range(2, limit):\n            if not sieve[prime]:\n                continue\n            \n            primes.append(prime)\n            \n            # better runtime than a manual while loop!\n            for j in range(prime+prime, limit, prime):\n                sieve[j] = False\n        \n        return primes\n    \n    # this hurts the runtime!\n    #@lru_cache(maxsize=MAX_N)\n    def factorize(self, n):\n        if n in self.factors:\n            return self.factors[n]\n        \n        for prime in self.primes:\n            if n % prime == 0:\n                factors = self.factors[n] = self.factorize(n // prime).union({prime})\n                return factors\n\n        raise ValueError(f'Value larger than max known prime: {n}')\n        \n        \nclass Graph:\n    def __init__(self):\n        self.adj = {}\n        self.factors = set()\n        self.values = set()\n    \n    def add_vertex(self, p, label):\n        if p not in self.adj:\n            self.adj[p] = set()\n        if label == 'factor':\n            self.factors.add(p)\n        else:\n            self.values.add(p)\n    \n    def add_factor(self, factor):\n        self.add_vertex(factor, 'factor')\n        \n    def add_value(self, value):\n        self.add_vertex(value, 'value')\n        \n    def connect(self, p, q):\n        self.adj[p].add(q)\n        self.adj[q].add(p)\n\n    def find_largest_connected_size(self):\n        seen = set()\n        largest = 0\n        for p in list(self.adj.keys()):\n            count = self._dfs_from(p, seen)\n            largest = max(largest, count)\n            \n        return largest\n    \n    def _dfs_from(self, p, seen):\n        if p in seen:\n            return 0\n        \n        seen.add(p)\n        \n        count = 1 if p in self.values else 0\n        \n        return count + sum(self._dfs_from(q, seen) for q in self.adj[p])\n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

_target = None
_fn_name = 'largestComponentSize'
if _fn_name:
    if "Solution" in ns:
        try:
            _obj = ns["Solution"]()
            if hasattr(_obj, _fn_name):
                _target = getattr(_obj, _fn_name)
        except Exception:
            _target = None
    if _target is None and _fn_name in ns and callable(ns[_fn_name]):
        _target = ns[_fn_name]
# Fallback: if there's exactly one user-defined function, use it
if _target is None:
    _cands = [v for k, v in ns.items() if callable(v) and getattr(v, "__module__", "") in ("__judge__", "__main__")]
    _user_funcs = [c for c in _cands if getattr(c, "__name__", "").startswith("_") is False]
    if len(_user_funcs) == 1:
        _target = _user_funcs[0]
if _target is None:
    raise RuntimeError(f"Could not resolve callable '{_fn_name}'")

_raw = sys.stdin.read().strip()
if _raw:
    _parsed = json.loads(_raw)
    if isinstance(_parsed, dict):
        _kwargs = _parsed.get("kwargs", {})
        _args = _parsed.get("args", [])
    else:
        _args, _kwargs = _parsed, {}
else:
    _args, _kwargs = [], {}
if not isinstance(_args, (list, tuple)):
    _args = [_args]
_res = _target(*_args, **_kwargs)
try:
    sys.stdout.write(repr(_res) + "\n")
except Exception:
    pass

```

Measured memory_bytes: 2771836