For this Question: Given an array Arr of N integers. Solve the following problem for X from 1 to N :-
Find the number of ways to select a pair (i, j) such that i < j and i != X and j != X and Arr[i] = Arr[j].First line of input contains a single integer, N.
Second line of input contains N space separated integers, denoting array Arr.

Constraints:
1 <= N <= 100000
1 <= Arr[i] <= NPrint N space separated integers where ith integer is the answer when X = i.Sample Input
5
4 4 1 1 1 

Sample Output
3 3 2 2 2 

Explanation:
For X=1 we have (3, 4) (3, 5) (4, 5)
For X=2 we have (3, 4) (3, 5) (4, 5)
For X=3 we have (1, 2) (4, 5)
For X=4 we have (1, 2) (3, 5)
For X=5 we have (1, 2) (3, 4), I have written this Solution Code: n=int(input())
arr=list(map(int,input().split()))
d=dict.fromkeys([i for i in arr],0)
for i in arr:
    d[i]+=1
ans=0
for value in d.values():
    if value>=2:
        ans+=((value*(value-1))//2)
for i in range(n):
    if arr[i] in d:
        f1=(d[arr[i]]*(d[arr[i]]-1))//2
        ans-=f1
        f2=((d[arr[i]]-1)*(d[arr[i]]-2))//2
        ans+=f2
        print(ans,end=" ")
        ans-=f2
        ans+=f1
    else:
        print(0,end=" "), In this Programming Language: Python, Now tell me if this Code is compilable or not?