Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

# 0 0
# 1 0
# 2 1
# 3 3
# 4 6

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

C = [0]*(2*10**5+1)

for i in A:
    l[i] += 1

ans = sum(i*(i-1)//2 for i in l)

for i in A:
    print(ans-l[i]+1)

Fixed submission:
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]


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

C = [0]*(2*10**5+1)

for i in A:
    C[i] += 1

ans = sum(i*(i-1)//2 for i in C)

for i in A:
    print(ans-C[i]+1)

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

# 0 0
# 1 0
# 2 1
# 3 3
# 4 6

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

data = collections.Counter(A)
dict = {}

for i in range(N):
    if dict.get(A[i]) == None :
        ans = 0
        tmp = copy.copy(data)
        tmp[A[i]] = data[A[i]] - 1
        C = list(tmp.values())
        for j in range(len(C)):
            if C[j] >= 2:
                ans += comb(C[j],2)
        dict[A[i]] = ans
    else:
        ans = dict.get(A[i])
    print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]


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

C = [0]*(2*10**5+1)

for i in A:
    C[i] += 1

ans = sum(i*(i-1)//2 for i in C)

for i in A:
    print(ans-C[i]+1)

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

# 0 0
# 1 0
# 2 1
# 3 3
# 4 6

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

data = collections.Counter(A)

for i in range(N):
    #print(data)
    ans = 0
    tmp = copy.copy(data)
    tmp[A[i]] = data[A[i]] - 1
    C = list(tmp.values())
    #print(C)
    for j in range(len(C)):
        if C[j] >= 2:
            ans += comb(C[j],2)
    print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]


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

C = [0]*(2*10**5+1)

for i in A:
    C[i] += 1

ans = sum(i*(i-1)//2 for i in C)

for i in A:
    print(ans-C[i]+1)