Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = 0
ans = 0
dic = {}
for i in set(a):
    b = a.count(i)
    dic.setdefault(i, b)
    if b > 1:
        ans += b*(b-1)//2
for i in a:
    print(ans - (dic[i] - 1))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = 0
ans = 0
dic = {}
for i in a:
    if i not in dic.keys():
        dic[i] = 1
    else:
        dic[i] += 1
for i in dic.values():
    ans += i*(i-1)//2
for i in a:
    print(ans - (dic[i] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = 0
ans = 0
dic = {}
for i in set(a):
    b = a.count(i)
    dic.setdefault(i, a.count(i))
    if b > 1:
        ans += b*(b-1)//2
for i in a:
    print(ans - (dic[i] - 1))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = 0
ans = 0
dic = {}
for i in a:
    if i not in dic.keys():
        dic[i] = 1
    else:
        dic[i] += 1
for i in dic.values():
    ans += i*(i-1)//2
for i in a:
    print(ans - (dic[i] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = 0
ans = 0
for i in set(a):
    b = a.count(i)
    if b > 1:
        ans += b*(b-1)//2
for i in a:
    print(ans - (a.count(i) - 1))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = 0
ans = 0
dic = {}
for i in a:
    if i not in dic.keys():
        dic[i] = 1
    else:
        dic[i] += 1
for i in dic.values():
    ans += i*(i-1)//2
for i in a:
    print(ans - (dic[i] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
dic = {}
for i in set(a):
    dic.setdefault(i, a.count(i))
ans = 0
for i in dic.values():
    if i > 1:
        ans += i*(i-1)//2
for i in a:
    print(ans - (dic[i] - 1))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = 0
ans = 0
dic = {}
for i in a:
    if i not in dic.keys():
        dic[i] = 1
    else:
        dic[i] += 1
for i in dic.values():
    ans += i*(i-1)//2
for i in a:
    print(ans - (dic[i] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
dic = {}
for i in set(a):
    dic.setdefault(i, a.count(i))
ans = 0
for i in dic.values():
    if i > 1:
        ans += i*(i-1)//2
for i in a:
    print(ans - (dic[i] - 1))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = 0
ans = 0
dic = {}
for i in a:
    if i not in dic.keys():
        dic[i] = 1
    else:
        dic[i] += 1
for i in dic.values():
    ans += i*(i-1)//2
for i in a:
    print(ans - (dic[i] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
dic = {}
for i in range(len(a)):
    dic.setdefault(a[i], a.count(a[i]))
ans = 0
for i in dic.values():
    if i > 1:
        ans += i*(i-1)//2
for i in a:
    print(ans - (dic[i] - 1))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = 0
ans = 0
dic = {}
for i in a:
    if i not in dic.keys():
        dic[i] = 1
    else:
        dic[i] += 1
for i in dic.values():
    ans += i*(i-1)//2
for i in a:
    print(ans - (dic[i] - 1))