Language: C++

/***
 ** "A lion doesn't concern himself with the opinion of sheep."
 **     -- David Hyner
***/

/**
  *  Author: dhruv_gheewala
  *  Date:   23.03.2020
  *  Time:   19:18:20
**/

#define DEBUG
#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;

    #define p(str) 7
    #define o(str) 42
    #define fundri 108
    #define d(...) 1729
#endif

typedef unsigned int ui;
typedef long long int ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;

const bool testcases = 0;
#define ff first
#define ss second
#define nl cout<<'\n'
#define pb push_back
#define pop pop_back
#define sz(cont) cont.size()
#define all(s) s.begin(),s.end()
#define lb(a,x) lower_bound(all(a),x)
#define ub(a,x) upper_bound(all(a),x)
#define test ll __T__=1;if(testcases)cin>>__T__;while(__T__--)
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define make_unique(vec) sort(all(vec));vec.erase(unique(all(vec)),vec.end())
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})

// copied macro - start
template<typename T>struct number_iterator : iterator<random_access_iterator_tag,T>
{T u;number_iterator(T v): u(v){}operator T&(){return u;}T operator *()const{return u;}};
template<typename T>struct number_range
{T l,r;number_range(T b,T e):l(b),r(e){}number_iterator<T> begin(){return l;}number_iterator<T> end(){return r;}};
template<typename T>number_range<T> range(T e){return number_range<T>(0,e);}
template<typename T>number_range<T> range(T b,T e){if(b>e)return number_range<T>(-b+1,-e+1);return number_range<T>(b,e);}
// copied macro - end

#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,l,r) for(ll i=l;i<r;i++)
#define rrep(i,n) for(ll i=n;~i;i--)
#define rloop(i,r,l) for(ll i=r;i>l;i--)

ll seed;auto random_address=[]{char *p=new char;delete p;return (ull64_t)p;};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()*(random_address()|1));
inline ll rnd(ll l=0,ll r=ll_MAX){return uniform_ll_distribution<ll>(l,r)(rng);}

template<typename T,typename U>inline bool exist(T cont,U val){return cont.find(val)!=cont.end();}
template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename TAIL>inline void inp(TAIL& T){cin>>T;}
template<typename HEAD,typename... TAIL>inline void inp(HEAD &H,TAIL&... T){cin>>H;inp(T...);}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}
template<typename T,typename U>inline istream& operator >>(istream& in,pair<T,U> &a){in>>a.ff>>a.ss;return in;}
template<typename T>inline istream& operator >>(istream& in,vector<T> &a){for(auto &x : a)in>>x;return in;}

map<ll, ll> mp;
int main()
{
    std::chrono::time_poll<std::chrono::high_resolution_clock> start_time, end_time;
    start_time = std::chrono::high_resolution_clock::now();

    #ifdef DHRUV_GHEEWALA
        freopen("INPUT.txt","r",stdin);
        freopen("OUTPUT.txt","w",stdout);
        freopen("DEBUG.txt","w",stderr);
    #endif
    
    fast;
    ll n;
    test{

    cin>>n;
    vi a(n);
    cin>>a;

    for(ll i : range(n))
        mp[a[i]]++;

    ll tot=0;
    for(pii x : mp)
        tot+=x.ss*(x.ss-1)/2;

    d(tot);
    d(mp);
    for(ll i : range(n))
        cout<<tot-mp[a[i]]*(mp[a[i]]-1)/2+(mp[a[i]]-1)*(mp[a[i]]-2)/2,nl;

    fundri;
    }

    end_time = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
    o("\n\n======\n");
    if(elapsed_time<10000)
        o("Elapsed Time: "<<elapsed_time<<" ms\n");
    else
        o("Elapsed Time: "<<elapsed_time/1000<<" s\n");

    return 0;
}

Compiler output:
a.cc:46:46: warning: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' is deprecated [-Wdeprecated-declarations]
   46 | template<typename T>struct number_iterator : iterator<random_access_iterator_tag,T>
      |                                              ^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:65,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:16:
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note: declared here
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~
a.cc: In lambda function:
a.cc:59:66: error: 'ull64_t' was not declared in this scope
   59 | ll seed;auto random_address=[]{char *p=new char;delete p;return (ull64_t)p;};
      |                                                                  ^~~~~~~
a.cc:59:74: error: expected ';' before 'p'
   59 | ll seed;auto random_address=[]{char *p=new char;delete p;return (ull64_t)p;};
      |                                                                          ^
      |                                                                          ;
a.cc: At global scope:
a.cc:61:27: error: 'll_MAX' was not declared in this scope
   61 | inline ll rnd(ll l=0,ll r=ll_MAX){return uniform_ll_distribution<ll>(l,r)(rng);}
      |                           ^~~~~~
a.cc: In function 'll rnd(ll, ll)':
a.cc:61:42: error: 'uniform_ll_distribution' was not declared in this scope
   61 | inline ll rnd(ll l=0,ll r=ll_MAX){return uniform_ll_distribution<ll>(l,r)(rng);}
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~
a.cc:61:68: error: expected primary-expression before '>' token
   61 | inline ll rnd(ll l=0,ll r=ll_MAX){return uniform_ll_distribution<ll>(l,r)(rng);}
      |                                                                    ^
a.cc:61:74: error: expression cannot be used as a function
   61 | inline ll rnd(ll l=0,ll r=ll_MAX){return uniform_ll_distribution<ll>(l,r)(rng);}
      |                                                                     ~~~~~^~~~~
a.cc: In function 'int main()':
a.cc:74:18: error: 'time_poll' is not a member of 'std::chrono'; did you mean 'time_point'?
   74 |     std::chrono::time_poll<std::chrono::high_resolution_clock> start_time, end_time;
      |                  ^~~~~~~~~
      |                  time_point
a.cc:74:62: error: expected primary-expression before '>' token
   74 |     std::chrono::time_poll<std::chrono::high_resolution_clock> start_time, end_time;
      |                                                              ^
a.cc:74:64: error: 'start_time' was not declared in this scope; did you mean 'strptime'?
   74 |     std::chrono::time_poll<std::chrono::high_resolution_clock> start_time, end_time;
      |                                                                ^~~~~~~~~~
      |                                                                strptime
a.cc:74:76: error: 'end_time' was not declared in this scope
   74 |     std::chrono::time_poll<std::chrono::high_resolution_clock> start_time, end_time;
      |                                                                            ^~~~~~~~