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\nfrom functools import lru_cache\n\nMAX_N = 100000\n\n\nclass Solution:\n    def largestComponentSize(self, A: List[int]) -> int:\n        # compute factors\n        sieve = Sieve(MAX_N)\n        factors = defaultdict(list)\n        for x in A:\n            for factor in sieve.factorize(x):\n                factors[factor].append(x)\n        '''\n        f = Factors()\n        factors = defaultdict(list)\n        for x in A:\n            for factor in f.find_for(x):\n                factors[factor].append(x)\n        '''\n\n        '''\n        uf = UnionFind()\n        for values in factors.values():\n            for i in range(1, len(values)):\n                uf.connect(values[i-1], values[i])\n                \n        return max(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 list(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\nclass Factors:\n    def __init__(self):\n        self.primes = self.find_primes(100000+1)\n        self.factors = {p: [p] for p in self.primes}\n        self.factors[1] = []\n    \n    def find_primes(self, limit):\n        primes = []\n        nums = [True] * limit\n        nums[0] = nums[1] = False\n        for n in range(limit):\n            if nums[n]:\n                primes.append(n)\n                for j in range(n+n, limit, n):\n                    nums[j] = False\n        \n        return primes\n    \n    def find_for(self, n):\n        if n in self.factors:\n            return self.factors[n]\n        \n        self.factors[n] = factors = set()\n        for prime in self.primes:\n            if n % prime == 0:\n                factors.add(prime)\n                for f in self.find_for(n // prime):\n                    factors.add(f)\n                break\n        \n        return factors\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, max_n):\n        self.primes = self._compute_primes(max_n)\n        self.factors = {p: [p] for p in self.primes}\n        # self.factors = {}\n        \n    def _compute_primes(self, max_n):\n        primes = list()\n        sieve = [True] * (max_n+1)\n        for prime in range(2, max_n+1):\n            if not sieve[prime]:\n                continue\n            \n            primes.append(prime)\n            \n            for j in range(prime+prime, max_n+1, prime):\n                sieve[j] = False\n        \n        return primes\n    \n    def factorize(self, n):\n        if n in self.factors:\n            return self.factors[n]\n        \n        self.factors[n] = factors = set()\n        work = n\n        for prime in self.primes:\n            # does not improve runtime!\n            if work < prime:\n                break\n            \n            if work % prime == 0:\n                factors.add(prime)\n                work //= prime\n                \n                factors.update(self.factorize(work))\n                break\n\n        return factors\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: 1319208