#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define lint long long int /* vectoral(26); al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; vectorAL(26); AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}; */ int main() { lint n, X; cin >> n >> X; vectorA(n); for (int i = 0; i < n; i++) { cin >> A[i]; } sort(A.begin(), A.end()); vectors(100000); for (int i = 0; i < n; i++) { s[A[i]]++; } lint serch; lint left; lint right; lint ans = 0; for (int i = 0; i < n; i++) { serch = X - A[i]; left = 0; right = n - 1; while (right - left >= 0){ lint mid = (left + right) / 2; if (serch == A[mid]) { ans+=s[A[mid]]; break; } else if (serch < A[mid]) { right = mid-1; } else if (serch > A[mid]) { left = mid+1; } } } cout << ans << endl; }