Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1


d_c = {}
for i in d:
    d_c[i] = d[i] * (d[i] - 1) // 2


d_3 ={}

for i in range(n):
    b = a[i]
    count = 0
    if b not in d_3:
        for j in d:
            if j != b:
                count += d_c[j]
            else:
                count += d_c[j]*(d[j]-2)//d[j]
        d_3[b] = count
        print(count)
    else:
        print(d_3[b])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

count = 0
for i in d:
    count += d[i] * (d[i] - 1) // 2


for i in range(n):
    b = d[a[i]]
    print(count-b+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1


d_c = {}
for i in d:
    d_c[i] = d[i] * (d[i] - 1) // 2


d_3 ={}

for i in range(n):
    b = a[i]
    count = 0
    if b not in d_3:
        for j in d:
            if j != b:
                count += d_c[j]
            else:
                count += d_c[j]*(d[j]-2)//d[j]
        d_3[b] = count
        print(count)
    else:
        print(d_3[b])
       

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

count = 0
for i in d:
    count += d[i] * (d[i] - 1) // 2


for i in range(n):
    b = d[a[i]]
    print(count-b+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1


d_c = {}
d_2_c = {}
for i in d:
    d_c[i] = d[i] * (d[i] - 1) // 2
    d_2_c[i] = (d[i] - 1) * (d[i] - 2) // 2


d_3 ={}

for i in range(n):
    b = a[i]
    count = 0
    if b not in d_3:
        for j in d:
            if j != b:
                count += d_c[j]
            else:
                count += d_2_c[j]
        d_3[b] = count
        print(count)
    else:
        print(d_3[b])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

count = 0
for i in d:
    count += d[i] * (d[i] - 1) // 2


for i in range(n):
    b = d[a[i]]
    print(count-b+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1


d_c = {}
d_2_c = {}
for i in d:
    d_c[i] = d[i] * (d[i] - 1) // 2
    d_2_c[i] = (d[i] - 1) * (d[i] - 2) // 2


for i in range(n):
    b = a[i]
    count = 0
    for j in d:
        if j != b:
            count += d_c[j]
        else:
            count += d_2_c[j]
    print(count)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

count = 0
for i in d:
    count += d[i] * (d[i] - 1) // 2


for i in range(n):
    b = d[a[i]]
    print(count-b+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

for i in range(n):
    b = a[i]
    d[b] = d[b]-1
    count = 0
    for j in d:
        temp_count = d[j]*(d[j]-1)//2
        count += temp_count
    d[b] = d[b] + 1
    print(count)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

count = 0
for i in d:
    count += d[i] * (d[i] - 1) // 2


for i in range(n):
    b = d[a[i]]
    print(count-b+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

for i in range(n):
    b = a[i]
    d[b] = d[b]-1
    count = 0
    for j in d:
        temp_count = d[j]*(d[j]-1)//2
        count += temp_count
    d[b] = d[b] + 1
    print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

count = 0
for i in d:
    count += d[i] * (d[i] - 1) // 2


for i in range(n):
    b = d[a[i]]
    print(count-b+1)