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

# 数値Aの頻度
ndic = {}
for i in A:
    if i in ndic:
        ndic[i] += 1
    else:
        ndic[i] = 1

# 2つの同じ数値Aの選び方
cdic = {}
mem = {}
for j in ndic:
    if ndic[j] == 1:
        continue
    
    if ndic[j] in mem:
        cdic[j] = mem[ndic[j]]
    else:
        cdic[j] = int((ndic[j] * (ndic[j] -1)) / 2)
        mem[ndic[j]] = cdic[j]

buff = ""
for i in A:
    cmb = 0
    for j in cdic:
        if i == j and cdic[j] > 0:
            cmb += cdic[j] - (ndic[j] - 1)
        else:
            cmb += cdic[j]
    buff += str(cmb) + "\n"

print(buff)

Fixed submission:
import collections

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

# 数値Aの頻度
ndic = collections.Counter(A)

mem = {}
tcmb = 0
for j in ndic:
    if ndic[j] == 1:
        continue
    
    if ndic[j] in mem:
        tcmb += mem[ndic[j]]
    else:
        mem[ndic[j]] = int((ndic[j] * (ndic[j] -1)) / 2)
        tcmb += mem[ndic[j]]
        
for i in A:
    cmb  = tcmb - (ndic[i] - 1)
    print(cmb)

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

# 数値Aの頻度
ndic = {}
for i in A:
    if i in ndic:
        ndic[i] += 1
    else:
        ndic[i] = 1

# 2つの同じ数値Aの選び方
cdic = {}
mem = {}
for j in ndic:
    if ndic[j] == 1:
        continue
    
    if ndic[j] in mem:
        cdic[j] = mem[ndic[j]]
    else:
        cdic[j] = int((ndic[j] * (ndic[j] -1)) / 2)
        mem[ndic[j]] = cdic[j]

for i in A:
    cmb = 0
    for j in cdic:
        if i == j and cdic[j] > 0:
            cmb += cdic[j] - (ndic[j] - 1)
        else:
            cmb += cdic[j]
    print(cmb)

Fixed submission:
import collections

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

# 数値Aの頻度
ndic = collections.Counter(A)

mem = {}
tcmb = 0
for j in ndic:
    if ndic[j] == 1:
        continue
    
    if ndic[j] in mem:
        tcmb += mem[ndic[j]]
    else:
        mem[ndic[j]] = int((ndic[j] * (ndic[j] -1)) / 2)
        tcmb += mem[ndic[j]]
        
for i in A:
    cmb  = tcmb - (ndic[i] - 1)
    print(cmb)

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

# 数値Aの頻度
ndic = {}
for i in A:
    if i in ndic:
        ndic[i] += 1
    else:
        ndic[i] = 1

# 2つの同じ数値Aの選び方
cdic = {}
mem = {}
for j in ndic:
    if ndic[j] == 1:
        continue
    
    if j in mem:
        cdic[j] = mem[j]
    else:
        cdic[j] = int((ndic[j] * (ndic[j] -1)) / 2)
        mem[j] = cdic[j]

for i in A:
    cmb = 0
    for j in cdic:
        if i == j and cdic[j] > 0:
            cmb += cdic[j] - (ndic[j] - 1)
        else:
            cmb += cdic[j]
    print(cmb)

Fixed submission:
import collections

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

# 数値Aの頻度
ndic = collections.Counter(A)

mem = {}
tcmb = 0
for j in ndic:
    if ndic[j] == 1:
        continue
    
    if ndic[j] in mem:
        tcmb += mem[ndic[j]]
    else:
        mem[ndic[j]] = int((ndic[j] * (ndic[j] -1)) / 2)
        tcmb += mem[ndic[j]]
        
for i in A:
    cmb  = tcmb - (ndic[i] - 1)
    print(cmb)

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

# 数値Aの頻度
ndic = {}
for i in A:
    if i in ndic:
        ndic[i] += 1
    else:
        ndic[i] = 1

# 2つの同じ数値Aの選び方
cdic = {}
for j in ndic:
    cdic[j] = int((ndic[j] * (ndic[j] -1)) / 2)


for i in A:
    cmb = 0
    for j in cdic:
        if i == j and cdic[j] > 0:
            cmb += cdic[j] - (ndic[j] - 1)
        else:
            cmb += cdic[j]
    print(cmb)

Fixed submission:
import collections

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

# 数値Aの頻度
ndic = collections.Counter(A)

mem = {}
tcmb = 0
for j in ndic:
    if ndic[j] == 1:
        continue
    
    if ndic[j] in mem:
        tcmb += mem[ndic[j]]
    else:
        mem[ndic[j]] = int((ndic[j] * (ndic[j] -1)) / 2)
        tcmb += mem[ndic[j]]
        
for i in A:
    cmb  = tcmb - (ndic[i] - 1)
    print(cmb)

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

# 数値Aの頻度
ndic = {}
for i in A:
    if i in ndic:
        ndic[i] += 1
    else:
        ndic[i] = 1

# 2つの同じ数値Aの選び方
cdic = {}
for j in ndic:
    cdic[j] = int((ndic[j] * (ndic[j] -1)) / 2)


for i in A:
    cmb = 0
    for j in cdic:
        if i == j and cdic[j] > 0:
            cmb += cdic[j] - (ndic[j] - 1)
        else:
            cmb += cdic[j]
    print(cmb)

Fixed submission:
import collections

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

# 数値Aの頻度
ndic = collections.Counter(A)

mem = {}
tcmb = 0
for j in ndic:
    if ndic[j] == 1:
        continue
    
    if ndic[j] in mem:
        tcmb += mem[ndic[j]]
    else:
        mem[ndic[j]] = int((ndic[j] * (ndic[j] -1)) / 2)
        tcmb += mem[ndic[j]]
        
for i in A:
    cmb  = tcmb - (ndic[i] - 1)
    print(cmb)