Buggy python submission (verdict: Runtime Error):
import math
from collections import Counter

def cmb(n,r):
    if n < r:
        return 0
    else:
        math.factorial(n,r)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([cmb(i,2) for i in count.values()])

    for i in range(len(A)):
        remain = A[:i] + A[i+1:]
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([v*(v-1)/2 for v in count.values()])

    for i in range(len(A)):
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import math
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([math.factorial(i,2) for i in count.values()])

    for i in range(len(A)):
        remain = A[:i] + A[i+1:]
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([v*(v-1)/2 for v in count.values()])

    for i in range(len(A)):
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter()
    count.update(A)
    sum_ = 0
    for i in count.values():
        sum_ += i*(i-1)/2

    for i in range(len(A)):
        remain = A[:i] + A[i+1:]
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([v*(v-1)/2 for v in count.values()])

    for i in range(len(A)):
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter()
    count.update(A)
    sum_ = sum([i*(i-1)/2 for i in count.values()])

    for i in range(len(A)):
        remain = A[:i] + A[i+1:]
        took = A[i]
        took_count = count[took]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([v*(v-1)/2 for v in count.values()])

    for i in range(len(A)):
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([i*(i-1)/2 for i in count.values()])

    for i in range(len(A)):
        remain = A[:i] + A[i+1:]
        took = A[i]
        took_count = count[took]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([v*(v-1)/2 for v in count.values()])

    for i in range(len(A)):
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()