Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

Number = [A.count(i+1) for i in range(N)]
Total = sum([Number[i]*(Number[i]-1)/2 for i in range(N)])

for Ak in A:
    print(int(Total - Number[Ak-1]+1))



Fixed submission:

import collections

# 入力 : N
# 入力 : A1 A2 ... AN
N = int(input())
A = list(map(int, input().split()))

C = collections.Counter(A)

Total = sum([i*(i-1)/2 for i in C.values()])

for Ak in A:
    print(int(Total - C[Ak]+1))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

# 入力 : N
# 入力 : A1 A2 ... AN
N = int(input())
A = list(map(int, input().split()))

Number = []
Total = 0

Number = [A.count(i+1) for i in range(N)]
Total = sum([Number[i]*(Number[i]-1)/2 for i in range(N)])

for Ak in A:
    print(int(Total - Number[Ak-1]+1))

    

Fixed submission:

import collections

# 入力 : N
# 入力 : A1 A2 ... AN
N = int(input())
A = list(map(int, input().split()))

C = collections.Counter(A)

Total = sum([i*(i-1)/2 for i in C.values()])

for Ak in A:
    print(int(Total - C[Ak]+1))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

# 入力 : N
# 入力 : A1 A2 ... AN
N = int(input())
A = list(map(int, input().split()))

Number = []
Total = 0

for i in range(N):
    Number.append(A.count(i+1))
    Total += Number[i]*(Number[i]-1)/2

for Ak in A:
    print(int(Total - Number[Ak-1]+1))


Fixed submission:

import collections

# 入力 : N
# 入力 : A1 A2 ... AN
N = int(input())
A = list(map(int, input().split()))

C = collections.Counter(A)

Total = sum([i*(i-1)/2 for i in C.values()])

for Ak in A:
    print(int(Total - C[Ak]+1))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

# 入力 : N
# 入力 : A1 A2 ... AN
N = int(input())
A = list(map(int, input().split()))

Number = []
PosNum = []
NegNum = []

for i in range(N):
    Number.append(A.count(i+1))
    PosNum.append(Number[i]*(Number[i]-1)/2)
    NegNum.append(- Number[A[i]-1]*(Number[A[i]-1]-1)/2 + (Number[A[i]-1]-1)*(Number[A[i]-1]-2)/2)

Total = sum(PosNum)

for k in range(N):
    print(int(Total + NegNum[k]))


Fixed submission:

import collections

# 入力 : N
# 入力 : A1 A2 ... AN
N = int(input())
A = list(map(int, input().split()))

C = collections.Counter(A)

Total = sum([i*(i-1)/2 for i in C.values()])

for Ak in A:
    print(int(Total - C[Ak]+1))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

# 入力 : N
# 入力 : A1 A2 ... AN
N = int(input())
A = list(map(int, input().split()))

Number = []

for i in range(N):
    Number.append(A.count(i+1))

Total = 0

for i in range(N):
    Total = Total + Number[i]*(Number[i]-1)/2

for k in range(N):
    print(int(Total - Number[A[k]-1]*(Number[A[k]-1]-1)/2 + (Number[A[k]-1]-1)*(Number[A[k]-1]-2)/2))


Fixed submission:

import collections

# 入力 : N
# 入力 : A1 A2 ... AN
N = int(input())
A = list(map(int, input().split()))

C = collections.Counter(A)

Total = sum([i*(i-1)/2 for i in C.values()])

for Ak in A:
    print(int(Total - C[Ak]+1))