def pairs(n):
    return n * (n - 1) / 2

def solution(lst):·
    counts = {}
    result = 0
    for e in lst:
        counts[e] = counts.get(e, 0) + 1
    for entry, count in counts.items():
        result += pairs(count)
    return result

assert(pairs(3) == 3)
assert(pairs(2) == 1)
assert(pairs(0) == 0)
assert(solution([5, 3, 1, 5, 5, 3]) == 4)
assert(solution([5, 5]) == 1)
assert(solution([5]) == 0)
assert(solution([]) == 0)
