#define _CRT_SECURE_NO_WARNINGS #define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING #include using namespace std; const int N = 2e5 + 50; int a[N]; int main() { int n, z; scanf("%d%d", &n, &z); for (int i = 0; i < n; i++) scanf("%d", a + i); //sort(a, a + n); multiset S(a, a + n); int cnt = 0; while (S.size() > 1) { auto ft = S.begin(); auto lb = S.lower_bound(*ft + z); if (lb != S.end()) { printf("** %d %d\n", *ft, *lb); cnt++; S.erase(lb); S.erase(ft); } else break; } printf("%d", cnt); return 0; }