#include #include using namespace std; using LL = long long; using ULL = unsigned long long; int main() { int N, X; cin >> N >> X; int a[N]; for (int i = 0; i < N; i++) cin >> a[i]; sort(a, a + N); LL ans = 0; for (int i = 0; i < N; i++) { int *p = lower_bound(a, a + N, X - a[i]); int *q = upper_bound(a, a + N, X - a[i]); if (a[i] + *p == X) ans += q - p; } cout << ans << endl; }