For this Question: Actually, a pair of chopsticks need not have two sticks that are the same length. You can eat with a pair of sticks as long as the length difference is no greater than D. Samar is appointed as a head chef of a restaurant. He is provided with N sticks, the i<sup>th</sup>stick of which is L[i] units long. More than one set of chopsticks cannot share the same stick. Assist him in matching the sticks to create as many functional pairs of chopsticks as possible.The first line contains two space-separated integers N and D. The next N lines contain one integer each, the i<sup>th</sup>line giving the value of L[i].

<b>Constraints</b>
1 &le; N &le; 10,000 (10<sup>5</sup>)
0 &le; D &le; 1,000,000,000 (10<sup>9</sup>)
1 &le; L[i] &le; 1,000,000,000 (10<sup>9</sup>) for all integers i from 1 to NOutput a single line containing the maximum number of pairs of chopsticks Samar can form.Sample Input :
5 2
1
3
3
9
4
Sample Output :
2
Explanation :
The 5 sticks have lengths 1, 3, 3, 9, and 4 respectively. The maximum allowed difference in the lengths of two sticks forming a pair is at most 2. It is clear that the 4th stick (length 9) cannot be used with any other stick. The remaining 4 sticks can be paired as (1st and 3rd) and (2nd and 5th) to form 2 pairs of usable chopsticks., I have written this Solution Code: #include <bits/stdc++.h>
using namespace std;

int main() {
    long int n, d;
    cin >> n >> d;
    long int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    int cnt = 0;
    for (int i = 1; i < n; i++) {
        if (arr[i] - arr[i - 1] <= d) {
            cnt++;
            i++;
        }
    }
    cout << cnt << endl;
    return 0;
}
, In this Programming Language: C++, Now tell me if this Code is compilable or not?