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


def solve(N: int, A: "List[int]"):
    nums = [0] * N
    for i in A:
        nums[int(i) - 1] += 1
    
    #print(nums)
    for k in range(0, N):
        nums[int(A[k]) - 1] -= 1
        #print("aaa" + str(k))
        #print(nums)
        sum = 0
        for num in nums:
            sum += num * ( num - 1 ) // 2
        print(sum)
        nums[int(A[k]) - 1] += 1
    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


def solve(N: int, A: "List[int]"):
    nums = [0] * N
    for i in A:
        nums[int(i) - 1] += 1
    
    sum = 0
    for num in nums:
        sum += num * ( num - 1 ) // 2

    for k in range(0, N):
        old = nums[int(A[k]) - 1]
        new = old - 1
        ans = sum - (old * (old - 1) // 2 - new * (new - 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()

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

def solve(N: int, A: "List[int]"):
    nums = [0] * N
    for i in A:
        nums[int(i) - 1] += 1
    
    #print(nums)
    for k in range(0, N):
        cp = copy.copy(nums)
        cp[int(A[k]) - 1] -= 1
        #print("aaa" + str(k))
        #print(nums)
        sum = 0
        for num in cp:
            sum += num * ( num - 1 ) // 2
        print(sum)
    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


def solve(N: int, A: "List[int]"):
    nums = [0] * N
    for i in A:
        nums[int(i) - 1] += 1
    
    sum = 0
    for num in nums:
        sum += num * ( num - 1 ) // 2

    for k in range(0, N):
        old = nums[int(A[k]) - 1]
        new = old - 1
        ans = sum - (old * (old - 1) // 2 - new * (new - 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()