#include #include #include using namespace std; long MyBinarySearch(vector vec, int target) { long 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()); long sum = 0; for (int i = 0; i < data.size(); i++) { int target = x - data[i]; sum += MyBinarySearch(data, target); } cout << sum; return 0; }