Assign Elements to Groups with Constraints
Record each element value's first index, then sieve over multiples so every group size knows the smallest index of an element that divides it.
Record each element value's first index, then sieve over multiples so every group size knows the smallest index of an element that divides it.