Buggy python submission (verdict: Time Limit Exceeded):
import collections

N = int(input())
B = list(map(int, input().split()))

setB = list(set(B))
n = len(setB)
Num = [0]*n
total = 0
for j in range(n):
  Num[j] = B.count(setB[j])
  total += Num[j]*(Num[j]-1)/2
  
for i in range(N):
  print(int(total)-Num[setB.index(B[i])]+1)

Fixed submission:
N = int(input())
B = list(map(int, input().split()))
count = {}

for i in B:
  if i in count:
    count[i] += 1
  else:
    count[i] = 1
    
total = 0
for i in count:
  total += count[i]*(count[i]-1)/2
  
for i in range(N):
  k = count[B[i]]
  print(int(total-k+1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections

N = int(input())
B = list(map(int, input().split()))

setB = list(set(B))
n = len(setB)
Num = [0]*n
for j in range(n):
  Num[j] = B.count(setB[j])
  
for i in range(N):
  res = 0
  for j in range(n):
    if B[i] == setB[j]:
      res += (Num[j]-1)*(Num[j]-2)/2
    else:
      res += Num[j]*(Num[j]-1)/2
  print(int(res))

Fixed submission:
N = int(input())
B = list(map(int, input().split()))
count = {}

for i in B:
  if i in count:
    count[i] += 1
  else:
    count[i] = 1
    
total = 0
for i in count:
  total += count[i]*(count[i]-1)/2
  
for i in range(N):
  k = count[B[i]]
  print(int(total-k+1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import copy

N = int(input())
B = list(map(int, input().split()))
cp_B = copy.copy(B)
p = 0

setB = list(set(B))
num = len(setB)

for i in range(N):
  res = 0
  p = cp_B.pop(0)
  for j in range(num):
    if setB[j] == p:
      res += (B.count(setB[j])-1)*(B.count(setB[j])-2)/2
    else:
      res += B.count(setB[j])*(B.count(setB[j])-1)/2
  print(int(res))

Fixed submission:
N = int(input())
B = list(map(int, input().split()))
count = {}

for i in B:
  if i in count:
    count[i] += 1
  else:
    count[i] = 1
    
total = 0
for i in count:
  total += count[i]*(count[i]-1)/2
  
for i in range(N):
  k = count[B[i]]
  print(int(total-k+1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import copy

N = int(input())
B = list(map(int, input().split()))
temp = 0

setB = list(set(B))
num = len(setB)

for i in range(N):
  newB = copy.copy(B)
  newB[i] = 0
  res = 0
  for j in range(num):
    res += newB.count(setB[j])*(newB.count(setB[j])-1)/2
  print(int(res))

Fixed submission:
N = int(input())
B = list(map(int, input().split()))
count = {}

for i in B:
  if i in count:
    count[i] += 1
  else:
    count[i] = 1
    
total = 0
for i in count:
  total += count[i]*(count[i]-1)/2
  
for i in range(N):
  k = count[B[i]]
  print(int(total-k+1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections

N = int(input())
B = list(map(int, input().split()))
temp = 0

setB = list(set(B))
num = len(setB)

for i in range(N):
  if i > 0:
    B[i-1] = temp
  temp = B[i]
  B[i] = 0
  res = 0
  for j in range(num):
    res += B.count(setB[j])*(B.count(setB[j])-1)/2
  print(int(res))

Fixed submission:
N = int(input())
B = list(map(int, input().split()))
count = {}

for i in B:
  if i in count:
    count[i] += 1
  else:
    count[i] = 1
    
total = 0
for i in count:
  total += count[i]*(count[i]-1)/2
  
for i in range(N):
  k = count[B[i]]
  print(int(total-k+1))