optimal hypercube share: prefer more balanced allocation.
fix a bug of using UnionFind, need to groupBy root rather parent