Python Count Non Divisible
def count_non_divisible(a: list[int]) -> list[int]:
    size = len(a)
    occurrences = [0] * (max(a) + 1)
    for v in a:
        occurrences[v] += 1

    nondivisor = [0] * size
    for k, v in enumerate(a):
        count = 0
        i = 1
        while i * i <= v:
            if v % i == 0:
                count += occurrences[i]
                if v // i != i:
                    count += occurrences[v // i]
            i += 1
        nondivisor[k] = size - count

    return nondivisor

This counts how often each value appears, then subtracts the divisor matches so you get the non-divisible count for each item.