stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



#define fRead(x)        freopen(x,"r",stdin)

#define fWrite(x)       freopen (x,"w",stdout)



#define LL              long long

#define ULL             unsigned long long

#define ff              first

#define ss              second

#define pb              push_back

#define INF             2e16

#define PI              acos(-1.0)

#define mk              make_pair

#define pii             pair<int,int>

#define pll             pair<LL,LL>





#define min3(a,b,c)     min(a,min(b,c))

#define max3(a,b,c)     max(a,max(b,c))

#define min4(a,b,c,d)   min(a,min(b,min(c,d)))

#define max4(a,b,c,d)   max(a,max(b,max(c,d)))

#define SQR(a)          ((a)*(a))

#define FOR(i,a,b)      for(int i=a;i<=b;i++)

#define ROF(i,a,b)      for(int i=a;i>=b;i--)

#define REP(i,b)        for(int i=0;i<b;i++)

#define MEM(a,x)        memset(a,x,sizeof(a))

#define ABS(x)          ((x)<0?-(x):(x))



#define SORT(v)         sort(v.begin(),v.end())

#define REV(v)          reverse(v.begin(),v.end())





#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);



const int N = 300005;

const LL MOD = 1e9 + 7;

LL n , ara[N];

int main()

{

    cin >> n;

    for(int i = 1;i <= n;i++){

        cin >> ara[i];

    }

    LL ans = 0;

    for(LL b = 0;b < 60;b++){

        LL zr = 0, one = 0;

        for(int i = 1;i <= n;i++){

            if(ara[i] & (1LL << b))one++;

            else zr++;

        }

        LL cnt = zr * one;

        cnt %= MOD;

        LL val = (1LL << b) % MOD;

        ans = (ans + val * cnt) % MOD;

    }

    cout << ans << "\n";

}






// Faster C++ solution for the same problem (measured speedup: 5.038754144464533x):
#include <cstdio>

//#include <iostream>

//#include <algorithm>

//#include <cstring>

//#include <queue> //priority_queue 优先队列

#include <map>

#include <set> //multiset  set<int,greater<int>>大到小

//#include <vector>// ::iterator it;

//#include <stack>

//#include <cmath> // auto &Name : STLName  Name.

//#include <utility>

//#include <sstream>

//#include <string>

#define mod 1000000007

#define mod9 998244353

typedef unsigned long long ull;

typedef long long ll;

typedef double db;

typedef long double ld;

const db eps=1e-10;

const int INF = 0x3f3f3f3f;

const ll inf=0x3f3f3f3f3f3f3f3f;

const int N=1e6+5;

using namespace std;





ll t,n,m,k,cnt=0;

ll a[65]={0};

ll sum=0;

ll ksm(ll a,ll b){

    ll c=mod;

    ll ans=1;

    a=a%c;

    while(b>0){

        if(b%2) ans=(ans*a)%c;

        b=b/2;

        a=(a*a)%c;

    }

    return ans;

}

int main(){

    scanf("%lld",&n);

    k=n;

    while(n--){

        scanf("%lld",&m);

        for(ll i=0;m;i++){

            ll x=m%2;

            m/=2;

            if(x) a[i]++;

        }

    }

    for(ll i=0;i<65;i++){

        sum=(sum+((a[i]*(k-a[i]))%mod)*ksm(2,i))%mod;

    }

    printf("%lld\n",sum);

    return 0;

}
// Slower C++ solution:
/*---------------Go Code GO---------------*/



#include<bits/stdc++.h>

using namespace std;



#define     PI              acos(-1.0)

#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)

#define     precision(a)    fixed<<setprecision(a)

#define     endl            '\n'

#define     Flush           cout<<flush

#define     LLMX            0x3fffffffffffffff

#define     PW2(a)          (long long)1<<a

#define     MOD             1000000007





bitset<64> num[300005];

int arr[300005][64];

int main()

{

    long long i,j,k,l,m,n,o,q,r,tst;

    unsigned long long ans=0, p;

    cin>>n;

    for(i=0; i<n; i++)

    {

        cin>>k;

        num[i]=bitset<64>(k);

    }

    for(i=n-1; i>=0; i--)

    {

        for(j=63; j>=0; j--)

        {

            if(num[i][j]) arr[i][j]=1;

            arr[i][j]+=arr[i+1][j];

        }

    }

    //cout<<"ekhane";

    ans=0;

    for(i=0; i<n; i++)

    {

        //cout<<num[i].to_string()<<endl;

        for(j=63; j>=0; j--)

        {

            if(num[i][j])

            {

                p=n-i-arr[i][j];

                ans+=(p*((1LL<<j)%MOD));

                ans=ans%MOD;

                //cout<<j<<'+'<<p<<' '<<num[i][j]<<endl;

            }

            else

            {

                p=arr[i][j];

                ans+=(p*((1LL<<j)%MOD));

                ans=ans%MOD;

                //cout<<j<<'-'<<p<<endl;

            }

        }

    }

    cout<<ans<<endl;





    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.065635900767855x):
#include <cstdio>

//#include <iostream>

//#include <algorithm>

//#include <cstring>

//#include <queue> //priority_queue 优先队列

#include <map>

#include <set> //multiset  set<int,greater<int>>大到小

//#include <vector>// ::iterator it;

//#include <stack>

//#include <cmath> // auto &Name : STLName  Name.

//#include <utility>

//#include <sstream>

//#include <string>

#define mod 1000000007

#define mod9 998244353

typedef unsigned long long ull;

typedef long long ll;

typedef double db;

typedef long double ld;

const db eps=1e-10;

const int INF = 0x3f3f3f3f;

const ll inf=0x3f3f3f3f3f3f3f3f;

const int N=1e6+5;

using namespace std;





ll t,n,m,k,cnt=0;

ll a[65]={0};

ll sum=0;

ll ksm(ll a,ll b){

    ll c=mod;

    ll ans=1;

    a=a%c;

    while(b>0){

        if(b%2) ans=(ans*a)%c;

        b=b/2;

        a=(a*a)%c;

    }

    return ans;

}

int main(){

    scanf("%lld",&n);

    k=n;

    while(n--){

        scanf("%lld",&m);

        for(ll i=0;m;i++){

            ll x=m%2;

            m/=2;

            if(x) a[i]++;

        }

    }

    for(ll i=0;i<65;i++){

        sum=(sum+((a[i]*(k-a[i]))%mod)*ksm(2,i))%mod;

    }

    printf("%lld\n",sum);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

typedef long long ll;



const ll MOD = 1e9 + 7;



int cnt[65][2];



int main(){

	memset(cnt,0,sizeof cnt);

	int n; cin >> n;

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

		ll x; cin >> x;

		for(int j=0; j<60; j++){

			if(x & ((ll)1 << j)) cnt[j][1]++;

			else cnt[j][0]++;

		}

	}

	ll ans = 0, pw = 1;

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

		pw %= MOD;

		ans += pw * (((ll)cnt[i][0] * cnt[i][1]) % MOD);

		ans %= MOD;

		pw *= (ll)2;

	}

	cout << ans << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.175024875182048x):
#include<stdio.h>

#define mod (long long)(1e9+7)

long long a[300010];

int main()

{

	int n,i,j;long long res=0,d=1;scanf("%d",&n);

	for(i=0;i<n;i++)

	    scanf("%lld",&a[i]);    

	for(j=0;j<60;j++)

	{

		long long c=0;

		for(i=0;i<n;i++)

		{

			if(a[i]&1)c++;

			a[i]>>=1;

		}

		res+=(((c*(n-c))%mod)*d)%mod;

		d*=2;

		d%=mod;

	}    

	printf("%lld\n",res%mod);

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

typedef long long ll;



const ll MOD = 1e9 + 7;



int cnt[65][2];



int main(){

	memset(cnt,0,sizeof cnt);

	int n; cin >> n;

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

		ll x; cin >> x;

		for(int j=0; j<60; j++){

			if(x & ((ll)1 << j)) cnt[j][1]++;

			else cnt[j][0]++;

		}

	}

	ll ans = 0, pw = 1;

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

		pw %= MOD;

		ans += pw * (((ll)cnt[i][0] * cnt[i][1]) % MOD);

		ans %= MOD;

		pw *= (ll)2;

	}

	cout << ans << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.194743629136682x):
#include<stdio.h>

long long int a[600000]={0};

#define mod 1000000007

int main()

{

	long long int n,i,j,s,ans,d;

	scanf("%lld",&n);

	for(i=1;i<=n;i++){

		scanf("%lld",&a[i]);

		

	} 

	d=1;ans=0;

	for(i=0;i<60;i++)

	{

		s=0;

		for(j=1;j<=n;j++)

		{



			if(a[j]&1)

			s++;

			a[j]>>=1;

		}



		ans+=((s*(n-s)%mod)*d)%mod;

		d*=2;

		d%=mod;

	}

	printf("%lld\n",ans%mod);

 }
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



const int MAXN=55;



bool  w[MAXN][MAXN],f[MAXN][MAXN][105];

int vis[MAXN];



int main()

{

    int n,m,len[3];

    scanf("%d%d",&n,&m);

    memset(w,0,sizeof(w));memset(f,0,sizeof(f));memset(vis,0,sizeof(vis));

    for (int i=0;i<3;i++) scanf("%d",&len[i]);

    for (int u,v;m--;)

    {

        scanf("%d%d",&u,&v);

        w[u][v]=true;

    }

    for (int i=1;i<=n;i++)

    {

        f[i][i][0]=true;

        for (int j=1;j<=100;j++)

            for (int k=1;k<=n;k++)

                for (int l=1;l<=n;l++)

                    if (w[l][k]&&f[i][l][j-1])

                        f[i][k][j]=true;

    }

    fill(vis+1,vis+n,INT_MAX);

    for (int now=1;now<=n;now++)

        for (int i=1;i<=n;i++)

            if (vis[i]>now)

            {

                bool flag;

                for (int j=0;j<3;j++)

                {

                    flag=false;

                    for (int k=1;k<=n;k++)

                        if (vis[k]<now&&f[i][k][len[j]])

                        {

                            flag=true;

                            break;

                        }

                    if (!flag) break;

                }

                if (flag)

                {

                    if (i==1)

                    {

                        printf("%d\n",now);

                        return 0;

                    }

                    vis[i]=now;

                }

            }

    puts("IMPOSSIBLE");

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3088051262008795x):
#include <queue>

#include <cstdio>

#include <cstring>

#include <iostream>

#include <algorithm>

#define N 55

#define M 2500

#define P 100

#define inf 0x3f3f3f3f

using namespace std;

struct Ahri

{

	int v,n;

}e[M];

int head[N],cnt;

inline void add(int u,int v)

{

	e[++cnt].v=v;

	e[cnt].n=head[u];

	head[u]=cnt;

}

bool f[P+5][N][N];

int dis[N],n,m,A,B,C;

int da[N],db[N],dc[N];

void getf()

{

	int i,j,k,l;

	for(i=1;i<=n;i++)f[0][i][i]=1;

	for(k=1;k<=P;k++)

		for(j=1;j<=n;j++)

			for(i=head[j];i;i=e[i].n)

				for(l=1;l<=n;l++)

					f[k][l][e[i].v]|=(f[k-1][l][j]);

}

queue<int>q;

void bfs()

{

	while(!q.empty())q.pop();

	memset(dis,-1,sizeof dis);

	memset(da,0,sizeof da);

	memset(db,0,sizeof db);

	memset(dc,0,sizeof dc);

	

	int i,u;

	q.push(n),dis[n]=0;

	

	while(!q.empty())

	{

		u=q.front(),q.pop();



		for(i=1;i<=n;i++)if(dis[i]==-1)

		{

			if(!da[i]&&f[A][i][u])da[i]=dis[u]+1;

			if(!db[i]&&f[B][i][u])db[i]=dis[u]+1;

			if(!dc[i]&&f[C][i][u])dc[i]=dis[u]+1;

			if(da[i]&&db[i]&&dc[i])

				dis[i]=max(da[i],max(db[i],dc[i])),q.push(i);

		}

	}

}



int main()

{

//	freopen("test.in","r",stdin);

	int i,j,k;

	scanf("%d%d%d%d%d",&n,&m,&A,&B,&C);

	while(m--)

	{

		scanf("%d%d",&i,&j);

		add(i,j);

	}

	getf();

	bfs();

	if(dis[1]==-1)puts("IMPOSSIBLE");

	else printf("%d\n",dis[1]);

	

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<sstream>

#include<algorithm>

#include<vector>

#include<iomanip>

#include<cmath>

#include<complex>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<bitset>

#include<functional>

#include<numeric>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )

#define rep(i,n) REP(i,0,n)

using ll = long long;

const int inf=1e9+7;

const ll longinf=1LL<<60 ;

const ll mod=1e9+7 ;

int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};





const int MAX = 510000;



// 二項係数計算

long long com(ll n){

    ll k = 2;

    if (n < k) return 0;

    if (n < 0 || k < 0) return 0;

    return n*(n-1)/2;

}



int main()

{



    ll N;

    cin >> N;

    vector<ll> A;

    ll same[200005] = {};

    ll done[200005] = {};



    for(ll i=0; i<N; ++i)

    {

        ll tmp;

        cin >> tmp;

        A.push_back(tmp);

        ++same[tmp];

    }



    ll all = 0;

    for(ll i=0; i<N; ++i)

    {

        if(done[A[i]]==1) continue;

        else

        {

            done[A[i]] = 1;

            all += com(same[A[i]]);

        }

    }



    for(ll i=0; i<N; ++i)

    {

        cout << all - com(same[A[i]]) + com(same[A[i]]-1) << endl;

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.2414063681593992x):
#include<iostream>

#include<string>

#include<sstream>

#include<algorithm>

#include<vector>

#include<iomanip>

#include<cmath>

#include<complex>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<bitset>

#include<functional>

#include<numeric>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )

#define rep(i,n) REP(i,0,n)

using ll = long long;

const int inf=1e9+7;

const ll longinf=1LL<<60 ;

const ll mod=1e9+7 ;

int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};



// 二項係数計算

long long com(ll n){

    ll k = 2;

    if (n < k) return 0;

    if (n < 0 || k < 0) return 0;

    return n*(n-1)/2;

}



int main()

{



    ll N;

    cin >> N;

    vector<ll> A;

    ll same[200005] = {};

    int done[200005] = {};



    for(ll i=0; i<N; ++i)

    {

        ll tmp;

        cin >> tmp;

        A.push_back(tmp);

        ++same[tmp];

    }



    ll all = 0;

    for(ll i=0; i<N; ++i)

    {

        if(done[A[i]]==1) continue;

        else

        {

            done[A[i]] = 1;

            all += com(same[A[i]]);

        }

    }



    for(ll i=0; i<N; ++i)

    {

        cout << all - com(same[A[i]]) + com(same[A[i]]-1) << endl;

    }



    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<sstream>

#include<algorithm>

#include<vector>

#include<iomanip>

#include<cmath>

#include<complex>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<bitset>

#include<functional>

#include<numeric>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )

#define rep(i,n) REP(i,0,n)

using ll = long long;

const int inf=1e9+7;

const ll longinf=1LL<<60 ;

const ll mod=1e9+7 ;

int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};





const int MAX = 510000;



// 二項係数計算

long long com(ll n){

    ll k = 2;

    if (n < k) return 0;

    if (n < 0 || k < 0) return 0;

    return n*(n-1)/2;

}



int main()

{



    ll N;

    cin >> N;

    vector<ll> A;

    ll same[200005] = {};

    ll done[200005] = {};



    for(ll i=0; i<N; ++i)

    {

        ll tmp;

        cin >> tmp;

        A.push_back(tmp);

        ++same[tmp];

    }



    ll all = 0;

    for(ll i=0; i<N; ++i)

    {

        if(done[A[i]]==1) continue;

        else

        {

            done[A[i]] = 1;

            all += com(same[A[i]]);

        }

    }



    for(ll i=0; i<N; ++i)

    {

        cout << all - com(same[A[i]]) + com(same[A[i]]-1) << endl;

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.6233849648111354x):
#include<iostream>

#include<string>

#include<sstream>

#include<algorithm>

#include<vector>

#include<iomanip>

#include<cmath>

#include<complex>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<bitset>

#include<functional>

#include<numeric>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )

#define rep(i,n) REP(i,0,n)

using ll = long long;

const int inf=1e9+7;

const ll longinf=1LL<<60 ;

const ll mod=1e9+7 ;

int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};



// 二項係数計算

long long com(ll n){

    ll k = 2;

    if (n < k) return 0;

    if (n < 0 || k < 0) return 0;

    return n*(n-1)/2;

}



int main()

{



    ll N;

    cin >> N;

    vector<ll> A;

    int same[200005] = {};

    int done[200005] = {};



    for(ll i=0; i<N; ++i)

    {

        ll tmp;

        cin >> tmp;

        A.push_back(tmp);

        ++same[tmp];

    }



    ll all = 0;

    for(ll i=0; i<N; ++i)

    {

        if(done[A[i]]==1) continue;

        else

        {

            done[A[i]] = 1;

            all += com(same[A[i]]);

        }

    }



    for(ll i=0; i<N; ++i)

    {

        cout << all - com(same[A[i]]) + com(same[A[i]]-1) << endl;

    }



    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<sstream>

#include<algorithm>

#include<vector>

#include<iomanip>

#include<cmath>

#include<complex>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<bitset>

#include<functional>

#include<numeric>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )

#define rep(i,n) REP(i,0,n)

using ll = long long;

const int inf=1e9+7;

const ll longinf=1LL<<60 ;

const ll mod=1e9+7 ;

int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};



// 二項係数計算

long long com(ll n){

    ll k = 2;

    if (n < k) return 0;

    if (n < 0 || k < 0) return 0;

    return n*(n-1)/2;

}



int main()

{



    ll N;

    cin >> N;

    vector<ll> A;

    ll same[200005] = {};

    int done[200005] = {};



    for(ll i=0; i<N; ++i)

    {

        ll tmp;

        cin >> tmp;

        A.push_back(tmp);

        ++same[tmp];

    }



    ll all = 0;

    for(ll i=0; i<N; ++i)

    {

        if(done[A[i]]==1) continue;

        else

        {

            done[A[i]] = 1;

            all += com(same[A[i]]);

        }

    }



    for(ll i=0; i<N; ++i)

    {

        cout << all - com(same[A[i]]) + com(same[A[i]]-1) << endl;

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.307698273868279x):
#include<iostream>

#include<string>

#include<sstream>

#include<algorithm>

#include<vector>

#include<iomanip>

#include<cmath>

#include<complex>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<bitset>

#include<functional>

#include<numeric>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )

#define rep(i,n) REP(i,0,n)

using ll = long long;

const int inf=1e9+7;

const ll longinf=1LL<<60 ;

const ll mod=1e9+7 ;

int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};



// 二項係数計算

long long com(ll n){

    ll k = 2;

    if (n < k) return 0;

    if (n < 0 || k < 0) return 0;

    return n*(n-1)/2;

}



int main()

{



    ll N;

    cin >> N;

    vector<ll> A;

    int same[200005] = {};

    int done[200005] = {};



    for(ll i=0; i<N; ++i)

    {

        ll tmp;

        cin >> tmp;

        A.push_back(tmp);

        ++same[tmp];

    }



    ll all = 0;

    for(ll i=0; i<N; ++i)

    {

        if(done[A[i]]==1) continue;

        else

        {

            done[A[i]] = 1;

            all += com(same[A[i]]);

        }

    }



    for(ll i=0; i<N; ++i)

    {

        cout << all - com(same[A[i]]) + com(same[A[i]]-1) << endl;

    }



    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<sstream>

#include<algorithm>

#include<vector>

#include<iomanip>

#include<cmath>

#include<complex>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<bitset>

#include<functional>

#include<numeric>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )

#define rep(i,n) REP(i,0,n)

using ll = long long;

const int inf=1e9+7;

const ll longinf=1LL<<60 ;

const ll mod=1e9+7 ;

int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};





const int MAX = 510000;



// 二項係数計算

long long com(ll n){

    ll k = 2;

    if (n < k) return 0;

    if (n < 0 || k < 0) return 0;

    return n*(n-1)/2;

}



int main()

{



    ll N;

    cin >> N;

    vector<ll> A;

    ll same[200005] = {};

    ll done[200005] = {};



    for(ll i=0; i<N; ++i)

    {

        ll tmp;

        cin >> tmp;

        A.push_back(tmp);

        ++same[tmp];

    }



    ll all = 0;

    for(ll i=0; i<N; ++i)

    {

        if(done[A[i]]==1) continue;

        else

        {

            done[A[i]] = 1;

            all += com(same[A[i]]);

        }

    }



    for(ll i=0; i<N; ++i)

    {

        cout << all - com(same[A[i]]) + com(same[A[i]]-1) << endl;

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.6210150834036128x):
#include<iostream>

#include<string>

#include<sstream>

#include<algorithm>

#include<vector>

#include<iomanip>

#include<cmath>

#include<complex>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<bitset>

#include<functional>

#include<numeric>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )

#define rep(i,n) REP(i,0,n)

using ll = long long;

const int inf=1e9+7;

const ll longinf=1LL<<60 ;

const ll mod=1e9+7 ;

int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};



// 二項係数計算

long long com(ll n){

    ll k = 2;

    if (n < k) return 0;

    if (n < 0 || k < 0) return 0;

    return n*(n-1)/2;

}



int main()

{



    int N;

    cin >> N;

    vector<int> A;

    int same[200005] = {};

    int done[200005] = {};



    for(ll i=0; i<N; ++i)

    {

        ll tmp;

        cin >> tmp;

        A.push_back(tmp);

        ++same[tmp];

    }



    ll all = 0;

    for(ll i=0; i<N; ++i)

    {

        if(done[A[i]]==1) continue;

        else

        {

            done[A[i]] = 1;

            all += com(same[A[i]]);

        }

    }



    for(ll i=0; i<N; ++i)

    {

        cout << all - com(same[A[i]]) + com(same[A[i]]-1) << endl;

    }



    return 0;

}