fork download
  1. #include <iostream>
  2. #include<queue>
  3. #include <algorithm>
  4. #include <map>
  5. #include<unordered_map>
  6. #include <set>
  7. #include <fstream>
  8. #include <vector>
  9. #include <math.h>
  10. #include <iomanip>
  11. #include <string>
  12. #include <cstring>
  13. using namespace std;
  14.  
  15. #define ll long long
  16.  
  17. ll mod = 1e9+7;
  18. const int MaxN = 1e5+5;
  19. int MOD = 998244353;
  20. int bit[200000];
  21. ll dem=0;
  22.  
  23. int main() {
  24. //freopen("CSBN.INP", "r", stdin);
  25. //freopen("CSBN.OUT", "w", stdout);
  26. ll n,x;
  27. cin >> n;
  28. unordered_map<int,int> mp;
  29. for(int i=1;i<=n;i++){
  30. cin >> x;
  31. mp[x]++;
  32. }
  33. for(auto &p : mp){
  34. dem += (p.second*(p.second-1))/2;
  35. }
  36. cout << dem;
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 5284KB
stdin
5
4 5 4 6 1
stdout
1