fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const int N=1e6+4;
  4. long long n,k;
  5. map<long long,long long>mp;
  6. int main()
  7. {
  8. long long dem=0;
  9. cin>>n>>k;
  10. for(int i=1;i<=n;i++)
  11. {
  12. long long x;
  13. cin>>x;
  14. dem+=mp[k-x];
  15. mp[x]++;
  16. }
  17. cout<<dem;
  18. }
  19.  
Success #stdin #stdout 0.01s 5476KB
stdin
Standard input is empty
stdout
Standard output is empty