Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = tuple(map(int, input().split()))
ans = 0
lim = max(a)
amount = [0]*lim
for i in range(lim):
    amount[i] = a.count(i+1)
    ans += amount[i]*(amount[i]-1)//2
for j in range(n):
    print(ans - amount[a[j]-1] + 1)

Fixed submission:
import numpy as np
def main():
    from collections import Counter
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    c = Counter(a)
    for i in range(n):
        ans += c[i+1]*(c[i+1]-1)//2
    for j in range(n):
        print(ans - c[a[j]] + 1)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    lim = max(a)
    amount = [0]*lim
    for i in range(lim):
        amount[i] = a.count(i+1)
        ans += amount[i]*(amount[i]-1)//2
    #print(ans)
    for j in range(n):
        ansout = ans
        #print(amount[a[j]-1])
        ansout -= amount[a[j]-1] -1
        print(ansout)
if __name__ == '__main__':
    main()

Fixed submission:
import numpy as np
def main():
    from collections import Counter
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    c = Counter(a)
    for i in range(n):
        ans += c[i+1]*(c[i+1]-1)//2
    for j in range(n):
        print(ans - c[a[j]] + 1)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
lim = max(a)
amount = [0]*lim
for i in range(lim):
    amount[i] = a.count(i+1)
    ans += amount[i]*(amount[i]-1)//2
for j in range(n):
    ansout = ans
    ansout -= amount[a[j]-1] -1
    print(ansout)

Fixed submission:
import numpy as np
def main():
    from collections import Counter
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    c = Counter(a)
    for i in range(n):
        ans += c[i+1]*(c[i+1]-1)//2
    for j in range(n):
        print(ans - c[a[j]] + 1)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
lim = max(a)
amount = [0]*lim
for i in range(lim):
    amount[i] = a.count(i+1)
    ans += amount[i]*(amount[i]-1)//2
for j in range(n):
    ansout = ans
    ansout -= amount[a[j]-1] -1
    print(ansout)

Fixed submission:
import numpy as np
def main():
    from collections import Counter
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    c = Counter(a)
    for i in range(n):
        ans += c[i+1]*(c[i+1]-1)//2
    for j in range(n):
        print(ans - c[a[j]] + 1)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += a.count(i+1)*(a.count(i+1)-1)//2
for j in range(n):
    ansout = ans
    ansout -= a.count(a[j]) -1
    print(ansout)

Fixed submission:
import numpy as np
def main():
    from collections import Counter
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    c = Counter(a)
    for i in range(n):
        ans += c[i+1]*(c[i+1]-1)//2
    for j in range(n):
        print(ans - c[a[j]] + 1)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
amount = [0]*n
preans = [0]*n

for i in range(n):
    amount[i] = a.count(i+1)
    preans[i] = amount[i]*(amount[i]-1)//2

ans = sum(preans)
#print(ans)
for j in range(n):
    ansout = ans
    #print(amount[a[j]-1])
    ansout -= amount[a[j]-1] -1
    print(ansout)

Fixed submission:
import numpy as np
def main():
    from collections import Counter
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    c = Counter(a)
    for i in range(n):
        ans += c[i+1]*(c[i+1]-1)//2
    for j in range(n):
        print(ans - c[a[j]] + 1)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
amount = [0]*n

for i in range(n):
    amount[i] = a.count(i+1)

for j in range(n):
    ans = 0
    for k in range(max(a)):
        ans += amount[k]*(amount[k]-1)//2
    ans -= amount[a[j]-1] -1
    print(ans)

Fixed submission:
import numpy as np
def main():
    from collections import Counter
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    c = Counter(a)
    for i in range(n):
        ans += c[i+1]*(c[i+1]-1)//2
    for j in range(n):
        print(ans - c[a[j]] + 1)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
amount = [0]*n

for i in range(n):
    amount[i] = a.count(i+1)

for j in range(n):
    ans = 0
    for k in range(n):
        ans += amount[k]*(amount[k]-1)//2
    ans -= amount[a[j]-1] -1
    print(ans)

Fixed submission:
import numpy as np
def main():
    from collections import Counter
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    c = Counter(a)
    for i in range(n):
        ans += c[i+1]*(c[i+1]-1)//2
    for j in range(n):
        print(ans - c[a[j]] + 1)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
amount = [0]*n

for i in range(n):
    amount[i] = a.count(i+1)

for j in range(n):
    ans = 0
    for k in range(n):
        if a[j] == k+1:
            ans += (amount[k]-1)*(amount[k]-2)//2
        else:
            ans += amount[k]*(amount[k]-1)//2
    print(ans)

Fixed submission:
import numpy as np
def main():
    from collections import Counter
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    c = Counter(a)
    for i in range(n):
        ans += c[i+1]*(c[i+1]-1)//2
    for j in range(n):
        print(ans - c[a[j]] + 1)
if __name__ == '__main__':
    main()