fork download
  1. #include<bits/stdc++.h>
  2. #define el '\n'
  3. #define ll long long
  4. #define N 1000000
  5. using namespace std;
  6. ll n,a[N+3],x;
  7. int main()
  8. {
  9. ios_base::sync_with_stdio(false);
  10. cin.tie(NULL);cout.tie(NULL);
  11. cin>>n; ll ma=-1e10; ll mi=1e10;
  12. for(ll i=1;i<=n;i++)
  13. {
  14. cin>>x;
  15. a[x]++;
  16. ma=max(ma,x);
  17. mi=min(mi,x);
  18. }
  19. ll s=0;
  20. for(ll i=mi;i<=ma;i++)
  21. {
  22. if(a[i]!=0 && a[i]>0) {s=s+((a[i]*(a[i]-1))/2);}
  23. }
  24. cout << s << el;
  25. }
  26.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
0