• + 12 comments

    Slightly more pythonic:

    res = sum((i+j)%k == 0 for x, i in enumerate(a) for j in a[x+1:])

    Since True == 1