Buggy python submission (verdict: Time Limit Exceeded):
import collections
a=int(input())
ai = list(map(int, input().split()))
c = collections.Counter(ai)
val=0
for i in c.values():
    val+=i*(i-1)//2
for i in ai:
    b=ai.count(i)
    print(val-b+1)

Fixed submission:
import collections
a=int(input())
ai = list(map(int, input().split()))
c = collections.Counter(ai)
val=0
for i in c.values():
    val+=i*(i-1)//2
for i in range(len(ai)):
    b=c[ai[i]]
    print(val-b+1)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
a=int(input())
ai=[int(i) for i in input().split()]
c = collections.Counter(ai)
val=0
for i in c.values():
    val+=i*(i-1)//2
for i in ai:
    b=ai.count(i)
    print(val-b+1)

Fixed submission:
import collections
a=int(input())
ai = list(map(int, input().split()))
c = collections.Counter(ai)
val=0
for i in c.values():
    val+=i*(i-1)//2
for i in range(len(ai)):
    b=c[ai[i]]
    print(val-b+1)

Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
ai=[int(i) for i in input().split()]

c=[ai.count(x) for x in set(ai) if ai.count(x)>1]
val=sum([x*(x-1)//2 for x in c])
for i in ai:
    b=ai.count(i)
    print(val-b+1)

Fixed submission:
import collections
a=int(input())
ai = list(map(int, input().split()))
c = collections.Counter(ai)
val=0
for i in c.values():
    val+=i*(i-1)//2
for i in range(len(ai)):
    b=c[ai[i]]
    print(val-b+1)

Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
ai=[int(i) for i in input().split()]

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
c=[ai.count(x) for x in set(ai) if ai.count(x)>1]
val=sum([cmb(x,2) for x in c])
for i in range(len(ai)):
    b=ai.count(ai[i])
    print(val-b+1)

Fixed submission:
import collections
a=int(input())
ai = list(map(int, input().split()))
c = collections.Counter(ai)
val=0
for i in c.values():
    val+=i*(i-1)//2
for i in range(len(ai)):
    b=c[ai[i]]
    print(val-b+1)

Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
ai=[int(i) for i in input().split()]

from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

for i in range(len(ai)):
    print(sum([cmb(x,2) for x in [sorted(ai[:i]+ai[i+1:]).count(x) for x in set(sorted(ai[:i]+ai[i+1:])) if sorted(ai[:i]+ai[i+1:]).count(x)>1]]))

Fixed submission:
import collections
a=int(input())
ai = list(map(int, input().split()))
c = collections.Counter(ai)
val=0
for i in c.values():
    val+=i*(i-1)//2
for i in range(len(ai)):
    b=c[ai[i]]
    print(val-b+1)

Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
ai=[int(i) for i in input().split()]

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result

for i in range(len(ai)):
    b=sorted(ai[:i]+ai[i+1:])
    c=[b.count(x) for x in set(b) if b.count(x) > 1]
    ans=[cmb(x,2) for x in c]
    print(sum(ans))

Fixed submission:
import collections
a=int(input())
ai = list(map(int, input().split()))
c = collections.Counter(ai)
val=0
for i in c.values():
    val+=i*(i-1)//2
for i in range(len(ai)):
    b=c[ai[i]]
    print(val-b+1)

Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
ai=[int(i) for i in input().split()]

from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

for i in range(len(ai)):
    b=sorted(ai[:i]+ai[i+1:])
    c=[b.count(x) for x in set(b) if b.count(x) > 1]
    ans=[cmb(x,2) for x in c]
    print(sum(ans))

Fixed submission:
import collections
a=int(input())
ai = list(map(int, input().split()))
c = collections.Counter(ai)
val=0
for i in c.values():
    val+=i*(i-1)//2
for i in range(len(ai)):
    b=c[ai[i]]
    print(val-b+1)