Buggy python submission (verdict: Runtime Error):
import collections
n=int(input())
a=list(map(int,input().split()))
d=collections.Counter(a)
total=sum([(v-1)*v//2, for v in d.values()])
for x in a:
    print(total-d[x]+1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(v-1)*v//2
for x in a:
    print(total-d[x]+1)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(y-1)*y//2
for x in a:
    print(total-d[x]+1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(v-1)*v//2
for x in a:
    print(total-d[x]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
d={}
ua=list(set(a))
total=0
for x in ua:
    y=a.count(x)
    d[x]=y
    total+=(y-1)*y//2
for x in a:
    print(total-d[x]+1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(v-1)*v//2
for x in a:
    print(total-d[x]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ua=list(set(a))
d={}
total=0
for x in ua:
    c=a.count(x)
    d[x]=c
    total+=sum(range(c))
for x in a:
    print(total-d[x]+1)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(v-1)*v//2
for x in a:
    print(total-d[x]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ua=list(set(a))
d={}
total=0
for x in ua:
    c=a.count(x)
    d[x]=c
    total+=sum(range(c))
for x in a:
    print(total-d[x]+1)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(v-1)*v//2
for x in a:
    print(total-d[x]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ua=list(set(a))
total=sum([sum(range(a.count(x))) for x in ua])
d={}
total=0
for x in ua:
    c=a.count(x)
    d[x]=c
    total+=sum(range(c))
for x in a:
    print(total-d[x]+1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(v-1)*v//2
for x in a:
    print(total-d[x]+1)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ua=list(set(a))
total=sum([sum(range(a.count(x))) for x in ua])
d={}
total=0
for x in ua:
    c=a.count(x)
    d[x]=c
    total+=sum(range(c))
for i in range(n):
    print(total-d[i]+1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(v-1)*v//2
for x in a:
    print(total-d[x]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ua=list(set(a))
total=sum([sum(range(a.count(x))) for x in ua])
for i in range(n):
    print(total-a.count(a[i])+1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(v-1)*v//2
for x in a:
    print(total-d[x]+1)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ua=list(set(a))
d={}
total=0
for i in range(n):
    y=a[i]
    if y in d:
        print(d[y])
        continue
    if ua:
        for x in ua:
            c = a.count(x)
            if c==1:
                ua.remove(c)
            total+=sum(range(c - (1 if x==y else 0)))
        print(total)
        d[y]=total
        total=0
    else:
        print(0)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(v-1)*v//2
for x in a:
    print(total-d[x]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
sorted_a=list(set(sorted(a)))
d={}
for i in range(n):
    y=a[i]
    if y in d:
        print(d[y])
        continue
    total=sum([sum(range(a.count(x) - (1 if x==y else 0))) for x in sorted_a])
    print(total)
    d[y]=total


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(v-1)*v//2
for x in a:
    print(total-d[x]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
sorted_a=list(set(sorted(a)))
for i in range(n):
    y=a[i]
    print(sum([sum(range(a.count(x) - (1 if x==y else 0))) for x in sorted_a]))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(v-1)*v//2
for x in a:
    print(total-d[x]+1)