Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import collections
import copy


def solve(N: int, A: "List[int]"):
    C = collections.Counter(A)
    for k in range(len(A)):
        c = copy.copy(C)
        c[A[k]] -= 1
        values, counts = zip(*c.most_common())
        ans = 0
        for i in counts:
            ans += int(i * (i-1) / 2)
        print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import collections
import copy


def solve(N: int, A: "List[int]"):
    C = collections.Counter(A)
    S = sum([int(i * (i-1)) / 2 for i in C.values()])
    for k in range(len(A)):
        c = C[A[k]]
        print(int(S - (c * (c-1) / 2) + ((c-1) * (c-2) / 2)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import collections


def solve(N: int, A: "List[int]"):
    for k in range(len(A)):
        a = A[:]
        del a[k]
        c = collections.Counter(a)
        values, counts = zip(*c.most_common())
        ans = 0
        for i in counts:
            ans += int(i * (i-1) / 2)
        print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import collections
import copy


def solve(N: int, A: "List[int]"):
    C = collections.Counter(A)
    S = sum([int(i * (i-1)) / 2 for i in C.values()])
    for k in range(len(A)):
        c = C[A[k]]
        print(int(S - (c * (c-1) / 2) + ((c-1) * (c-2) / 2)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()