# include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
long long n;
cin>>n;
vector<long long> arr(n+1, 0);
for(long long i=0; i<n; i++){
long long freq;
cin>>freq;
arr[freq]++;
}
long long fact = 0 ;
long long prev=0;
for(long long i=0; i<=n; i++){
if(arr[i]>=3){
long long mid = (arr[i]*(arr[i]-1));
mid*=(arr[i]-2);
mid/=6;
fact+=mid;
}
if(arr[i]>=2){
long long mid = (arr[i]*(arr[i]-1));
mid/=2;
fact+=(mid*prev);
}
prev+=arr[i];
}
cout<<fact<<"\n";
}
return 0;
}
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |
Divisible | Three primes |
Coprimes | Cost of balloons |
One String No Trouble | Help Jarvis! |
Lift queries | Goki and his breakup |
Ali and Helping innocent people | Book of Potion making |
Duration | Birthday Party |
e-maze-in | Bricks Game |