• + 0 comments
    import collections
    def nonDivisibleSubset(k, s):
        counts = collections.Counter((i % k for i in s))
        return sum((max(counts[r], counts[k - r]) for r in range(k//2 + 1))) \
        + (1 - counts[0])*(0 in counts) \
        + (1 - counts[k // 2])*(k % 2 == 0)*(k // 2 in counts)