Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

long long facto(long long n)
{
long long i,ans;
ans=1;
for(i=1;i<=n;i++) {
ans=ans*i;
}
return ans;
}


long long com(int n , int r){
    return ( facto(n) / ( facto(n-r) * facto(r) ) );
}

void comb(vector<vector <long long int> > &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

int main(){
    long long N;
    cin >> N;
    int A[N];
    for(int i = 0 ; i< N ; i++){
        cin >> A[i];
    }

    long long data[N+1];
    for(int i = 0 ; i<N+1 ;i++){
        data[i] = 0;
    }

    for(int i = 0;i<N;i++){
        data[A[i]] += 1;
    }

    long long total = 0;

    for(int i =0;i<N;i++){
        if( data[i] >=2 ){
            total += com(data[i],2 );
        }
    }

    
    for(int i=0 ; i<N;i++){
        if(data[A[i]]-1>0){
            cout << total - com(data[A[i]]-1,1) << endl;
        }else{
            cout << total << endl;
        }
    
    }

    return 0;
}

Fixed submission:
import math
 
def permutations_count(n, r):
    if r == 2:
        return int( (n*(n-1) ) / r )
    if r == 1:
        return n
 
 
N = int(input())
A = list(map(int,input().split()))
 
data = [0] * (N+1)
 
for i in range(N):
    data[A[i]] += 1
 
total = 0
 
for i in range(N+1):
    if data[i] >= 2:
        total += permutations_count(data[i],2)
 
 
 
for i in range(N):
    if data[A[i]] - 1 > 0 :
        print( total - permutations_count(data[A[i]]-1,1) )
    else:
        print(total)

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

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


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

data = [0] * (N+1)

for i in range(N):
    data[A[i]] += 1

total = 0

for i in range(N+1):
    if data[i] >= 2:
        total += permutations_count(data[i],2)



for i in range(N):
    t = total
    if data[A[i]] - 1 > 0 :
        print( total-permutations_count(data[A[i]]-1,1) )
    else:
        print(total)

Fixed submission:
import math
 
def permutations_count(n, r):
    if r == 2:
        return int( (n*(n-1) ) / r )
    if r == 1:
        return n
 
 
N = int(input())
A = list(map(int,input().split()))
 
data = [0] * (N+1)
 
for i in range(N):
    data[A[i]] += 1
 
total = 0
 
for i in range(N+1):
    if data[i] >= 2:
        total += permutations_count(data[i],2)
 
 
 
for i in range(N):
    if data[A[i]] - 1 > 0 :
        print( total - permutations_count(data[A[i]]-1,1) )
    else:
        print(total)

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

total = 0
for i in range(N):
    for j in range(i+1,N):
        if A[i] == A[j]:
            total += 1


for i in range(N):
    tmp = 0
    to = total
    for j in range(N):
        if i != j and A[i] == A[j]:
            tmp += 1
    
    print(to-tmp)


Fixed submission:
import math
 
def permutations_count(n, r):
    if r == 2:
        return int( (n*(n-1) ) / r )
    if r == 1:
        return n
 
 
N = int(input())
A = list(map(int,input().split()))
 
data = [0] * (N+1)
 
for i in range(N):
    data[A[i]] += 1
 
total = 0
 
for i in range(N+1):
    if data[i] >= 2:
        total += permutations_count(data[i],2)
 
 
 
for i in range(N):
    if data[A[i]] - 1 > 0 :
        print( total - permutations_count(data[A[i]]-1,1) )
    else:
        print(total)