#include #include #include typedef long long ll; ll a[100002]; int main(){ ll N,X; scanf("%lld",&N); scanf("%lld",&X); for(int i = 0; i < N; i++){ scanf("%lld",a+i+1); } std::sort(a+1,a+N+1); a[0] = a[N+1] = X+1; int cnt = 0; for(int left = 1; left < N+1; left++){ // X-a[left] <= a_right となる領域のうち左端を探索する int bl = 1, br = N+1; int b = bl; while(bl <= br){ b = (bl+br)/2; if( X-a[left] < a[b]){ br = b-1; }else if( X-a[left] > a[b]){ bl = b+1; }else{ /* X-a[left] == a[b] */ while(X-a[left] == a[b-1]) b--; break; } } if(X-a[left] == a[b]){ while(X-a[left] == a[b]){ //printf("(%d,%d)\n",a[left],a[b]); b++; cnt++; } } } printf("%d\n",cnt); }