#include #include #include using namespace std; int MyBinarySearch(vector vec, int target) { int sum=0; auto low=lower_bound(vec.begin(),vec.end(),target); auto upper=upper_bound(vec.begin(),vec.end(),target); sum=upper-low; return sum; } int main() { int n; long x; vector data; cin >> n >> x; for (int i = 0; i < n; i++) { int buff; cin >> buff; data.push_back(buff); } sort(data.begin(), data.end()); int sum = 0; for (int i = 0; i < data.size(); i++) { int target = x - data[i]; sum += MyBinarySearch(data, target); } cout << sum; return 0; }