/* -*- coding: utf-8 -*- * * 723.cc: No.723 2つの数の和 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100000; /* typedef */ typedef long long ll; typedef vector vi; typedef queue qi; typedef pair pii; /* global variables */ int as[MAX_N], bs[MAX_N], cs[MAX_N]; /* subroutines */ /* main */ int main() { int n, x; scanf("%d%d", &n, &x); for (int i = 0; i < n; i++) scanf("%d", &as[i]); sort(as, as + n); int m = 0, pa = -1; for (int i = 0; i < n; pa = as[i++]) { if (pa != as[i]) bs[m] = as[i], cs[m] = 1, m++; else cs[m - 1]++; } //for (int i = 0; i < m; i++) printf("(%d,%d)", bs[i], cs[i]); putchar('\n'); ll cnt = 0; int maxb = bs[m - 1]; for (int i = 0; i < m; i++) { int d = x - bs[i]; if (d >= 0 && d <= maxb) { int j = lower_bound(bs, bs + m, d) - bs; if (j < m && d == bs[j]) cnt += (ll)cs[i] * cs[j]; } } printf("%lld\n", cnt); return 0; }