Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# import time


def main():
    # from scipy.special import comb
    from math import factorial

    N = int(input())
    A = [int(x) for x in input().split()]

    num_lst = [0] * (N + 1)
    for a in A:
        num_lst[a] += 1

    ans = 0
    for num in num_lst:
        # ans += comb(num, 2, exact=True)
        if num >= 2:
            ans += int(factorial(num) / 2 / factorial(num - 2))
        else:
            ans += 0

    # start = time.time()
    for a in A:
        print(ans - (num_lst[a] - 1))
    # end = time.time() - start
    # print(f'{end:6f}', '[sec]')


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    import time

    N = int(input())
    A = [int(x) for x in input().split()]

    num_lst = [0] * (N + 1)
    for a in A:
        num_lst[a] += 1

    ans = 0
    for num in num_lst:
        # ans += comb(num, 2, exact=True)
        ans += num * (num - 1) // 2

    start = time.time()
    for a in A:
        print(ans - (num_lst[a] - 1))
    end = time.time() - start
    # print(f'{end:6f}', 's')


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import time


def main():
    # from scipy.special import comb
    from math import factorial

    N = int(input())
    A = [int(x) for x in input().split()]

    num_lst = [0] * (N + 1)
    for a in A:
        num_lst[a] += 1

    ans = 0
    for num in num_lst:
        # ans += comb(num, 2, exact=True)
        if num >= 2:
            ans += int(factorial(num) / 2 / factorial(num - 2))
        else:
            ans += 0

    start = time.time()
    for a in A:
        print(ans - (num_lst[a] - 1))
    end = time.time() - start
    # print(f'{end:6f}', '[sec]')


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    import time

    N = int(input())
    A = [int(x) for x in input().split()]

    num_lst = [0] * (N + 1)
    for a in A:
        num_lst[a] += 1

    ans = 0
    for num in num_lst:
        # ans += comb(num, 2, exact=True)
        ans += num * (num - 1) // 2

    start = time.time()
    for a in A:
        print(ans - (num_lst[a] - 1))
    end = time.time() - start
    # print(f'{end:6f}', 's')


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import time


def main():
    # from scipy.special import comb
    from math import factorial

    N = int(input())
    A = [int(x) for x in input().split()]

    num_lst = [0] * (N + 1)
    for a in A:
        num_lst[a] += 1

    ans = 0
    for num in num_lst:
        # ans += comb(num, 2, exact=True)
        if num >= 2:
            ans += factorial(num) / 2 / factorial(num - 2)
        else:
            ans += 0

    start = time.time()
    for a in A:
        print(ans - (num_lst[a] - 1))
    end = time.time() - start
    print(f'{end:6f}', '[sec]')


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    import time

    N = int(input())
    A = [int(x) for x in input().split()]

    num_lst = [0] * (N + 1)
    for a in A:
        num_lst[a] += 1

    ans = 0
    for num in num_lst:
        # ans += comb(num, 2, exact=True)
        ans += num * (num - 1) // 2

    start = time.time()
    for a in A:
        print(ans - (num_lst[a] - 1))
    end = time.time() - start
    # print(f'{end:6f}', 's')


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import time


def main():
    from scipy.special import comb

    N = int(input())
    A = [int(x) for x in input().split()]
    # N = 10 ** 4
    # A = [int(x) for x in range(N)]

    num_lst = [0] * (N + 1)
    for a in A:
        num_lst[a] += 1

    cnt_lst = []
    for num in num_lst:
        cnt_lst.append(comb(num, 2, exact=True))

    for i in range(N):
        now = A[i]
        res = num_lst[now] - 1
        print(sum(cnt_lst[:now])
              + sum(cnt_lst[now + 1:])
              + (comb(res, 2, exact=True) if res >= 2 else 0))
    # print(num_lst)
    # print(cnt_lst)


if __name__ == '__main__':
    start = time.time()
    main()
    elapsed_time = time.time() - start
    # print(f'{elapsed_time:6f}', '[sec]')


Fixed submission:
#!/usr/bin/env python3
def main():
    import time

    N = int(input())
    A = [int(x) for x in input().split()]

    num_lst = [0] * (N + 1)
    for a in A:
        num_lst[a] += 1

    ans = 0
    for num in num_lst:
        # ans += comb(num, 2, exact=True)
        ans += num * (num - 1) // 2

    start = time.time()
    for a in A:
        print(ans - (num_lst[a] - 1))
    end = time.time() - start
    # print(f'{end:6f}', 's')


if __name__ == '__main__':
    main()