For this Question: Given an array A of size N, find the maximum subarray size such that the difference between the maximum and minimum elements of the subarray is <= K.First line of the input contains two integers N and K.
The second line of the input contains N space seperated integers.

Constraints:
1 <= N <= 10<sup>5</sup>
1 <= K <= 10<sup>9</sup>
1 <= A<sub>i</sub> <= 10<sup>9</sup>Print the maximum subarray size such that the difference between the maximum and minimum elements of the subarray is <= K.Sample Input:
5 3
3 5 2 7 1

Sample Input:
3

Explanation:
We can take subarray [3, 5, 2]. No subarray of size 4 or larger will satisfy the condition., I have written this Solution Code: #include<bits/stdc++.h>
using namespace std;
 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
// #define int long long
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using T = pair<int, int>;
typedef long double ld;
 
const int mod = 1e9 + 7;
const int INF = 2e9;
 
void solve(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(auto &i : a) cin >> i;
    int l = 1, r = n, ans = 1;
    while(l <= r){
        int mid = (l + r)/2;
        multiset<int> s;
        int res = INF;
        for(int i = 0; i < mid; i++){
            s.insert(a[i]);
        }
        res = min(res, *s.rbegin() - *s.begin());
        for(int i = mid; i < n; i++){
            s.insert(a[i]);
            s.erase(s.find(a[i - mid]));
            res = min(res, *s.rbegin() - *s.begin());
        }
        if(res <= k){
            ans = mid;
            l = mid + 1;
        }
        else r = mid - 1;
    }
    cout << ans;
}
 
signed main(){
    fast
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
        if(i != t) cout << endl;
    }
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?