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

def main(N, lst_A):

    sum_comb = 0
    lst_cntA = []

    for i in range(1, N+1):
        cntA  = lst_A.count(i)
        combA = (cntA * (cntA-1)) // 2
        
        sum_comb += combA
        lst_cntA.append(cntA)

    for A in lst_A:
        print(sum_comb - (lst_cntA[A-1]-1))

    return 0

if __name__ == "__main__":

    main(N, lst_A)
    

Fixed submission:
from collections import Counter

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

def main(N, lst_A):

    dct_cntA = Counter(lst_A)
    sum_comb = 0

    for cntA in dct_cntA.values():
        comb = (cntA * (cntA - 1)) // 2
        sum_comb += comb

    for A in lst_A:
        print(sum_comb - (dct_cntA[A] - 1))

    return 0

if __name__ == "__main__":

    main(N, lst_A)

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

def calc_comb(lst_A):

    elem_A = list(set(lst_A))
    sum_comb = 0
    dct_A = {}

    for A in elem_A:
        numA  = lst_A.count(A)
        combA = (numA * (numA-1)) // 2
        dct_A[A] = numA
        sum_comb += combA

    return sum_comb, dct_A



def main(N, lst_A):

    sum_comb_all, dct_A = calc_comb(lst_A)

    for A in lst_A:
        numA = dct_A[A]
        prev_combA = (numA * (numA-1)) // 2
        new_combA  = ((numA-1) * (numA-2)) // 2

        sum_comb = sum_comb_all - prev_combA + new_combA
        print(sum_comb)

    return 0

if __name__ == "__main__":

    main(N, lst_A)
    

Fixed submission:
from collections import Counter

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

def main(N, lst_A):

    dct_cntA = Counter(lst_A)
    sum_comb = 0

    for cntA in dct_cntA.values():
        comb = (cntA * (cntA - 1)) // 2
        sum_comb += comb

    for A in lst_A:
        print(sum_comb - (dct_cntA[A] - 1))

    return 0

if __name__ == "__main__":

    main(N, lst_A)

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

def calc_comb(lst_A):

    elem_A = list(set(lst_A))
    sum_comb = 0
    dct_A = {}

    for A in elem_A:
        numA  = lst_A.count(A)
        combA = (numA * (numA-1)) // 2
        dct_A[A] = numA
        sum_comb += combA

    return sum_comb, dct_A



def main(N, lst_A):

    sum_comb_all, dct_A = calc_comb(lst_A)
    lst_sum_comb = []

    for A in lst_A:
        numA = dct_A[A]
        prev_combA = (numA * (numA-1)) // 2
        new_combA  = ((numA-1) * (numA-2)) // 2

        sum_comb = sum_comb_all - prev_combA + new_combA
        lst_sum_comb.append(sum_comb)

    return lst_sum_comb

if __name__ == "__main__":

    lst_answer = main(N, lst_A)
    for answer in lst_answer:
        print(answer)
    

Fixed submission:
from collections import Counter

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

def main(N, lst_A):

    dct_cntA = Counter(lst_A)
    sum_comb = 0

    for cntA in dct_cntA.values():
        comb = (cntA * (cntA - 1)) // 2
        sum_comb += comb

    for A in lst_A:
        print(sum_comb - (dct_cntA[A] - 1))

    return 0

if __name__ == "__main__":

    main(N, lst_A)

Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {

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

    vector<int> uniqueA = A;
    sort(uniqueA.begin(), uniqueA.end());
    uniqueA.erase(unique(uniqueA.begin(), uniqueA.end()), uniqueA.end());

    int sum_comb_all = 0;
    for (int i = 0; i < uniqueA.size(); i++) {
        int num_A = count(A.begin(), A.end(), uniqueA[i]);
        int comb  = (num_A * (num_A-1)) / 2;
        sum_comb_all += comb;
    }


    for (int i = 0; i < N; i++) {

        int num_A     = count(A.begin(), A.end(), A[i]);
        int prev_comb = (num_A * (num_A-1)) / 2;
        int new_comb  = ((num_A-1) * (num_A-2)) / 2;

        int sum_comb  = sum_comb_all - prev_comb + new_comb;
        cout << sum_comb << endl;

    }

}

Fixed submission:
from collections import Counter

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

def main(N, lst_A):

    dct_cntA = Counter(lst_A)
    sum_comb = 0

    for cntA in dct_cntA.values():
        comb = (cntA * (cntA - 1)) // 2
        sum_comb += comb

    for A in lst_A:
        print(sum_comb - (dct_cntA[A] - 1))

    return 0

if __name__ == "__main__":

    main(N, lst_A)

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

def calc_comb(lst_A):

    elem_A = list(set(lst_A))
    sum_comb = 0

    for A in elem_A:
        numA  = lst_A.count(A)
        combA = (numA * (numA-1)) // 2
        sum_comb += combA

    return sum_comb

def main(N, lst_A):

    sum_comb_all = calc_comb(lst_A)

    for A in lst_A:
        numA = lst_A.count(A)
        prev_combA = (numA * (numA-1)) // 2
        new_combA  = ((numA-1) * (numA-2)) // 2

        sum_comb = sum_comb_all - prev_combA + new_combA
        
        print(sum_comb)

if __name__ == "__main__":

    main(N, lst_A)
    

Fixed submission:
from collections import Counter

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

def main(N, lst_A):

    dct_cntA = Counter(lst_A)
    sum_comb = 0

    for cntA in dct_cntA.values():
        comb = (cntA * (cntA - 1)) // 2
        sum_comb += comb

    for A in lst_A:
        print(sum_comb - (dct_cntA[A] - 1))

    return 0

if __name__ == "__main__":

    main(N, lst_A)

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

def calc_comb(lst_A):

    elem_A = list(set(lst_A))
    sum_comb = 0

    for A in elem_A:
        numA  = lst_A.count(A)
        combA = (numA * (numA-1)) // 2
        sum_comb += combA

    return sum_comb



def main(N, lst_A):

    sum_comb_all = calc_comb(lst_A)
    lst_sum_comb = []

    for A in lst_A:
        numA = lst_A.count(A)
        prev_combA = (numA * (numA-1)) // 2
        new_combA  = ((numA-1) * (numA-2)) // 2

        sum_comb = sum_comb_all - prev_combA + new_combA
        lst_sum_comb.append(sum_comb)

    return lst_sum_comb

if __name__ == "__main__":

    lst_answer = main(N, lst_A)
    for answer in lst_answer:
        print(answer)
    

Fixed submission:
from collections import Counter

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

def main(N, lst_A):

    dct_cntA = Counter(lst_A)
    sum_comb = 0

    for cntA in dct_cntA.values():
        comb = (cntA * (cntA - 1)) // 2
        sum_comb += comb

    for A in lst_A:
        print(sum_comb - (dct_cntA[A] - 1))

    return 0

if __name__ == "__main__":

    main(N, lst_A)