func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 7;   const int MOD = 1e9 + 7;   const int dx[4] = {0, 0, -1, 1};   const int dy[4] = {-1, 1, 0, 0};   const int N = 1e5 + 1;   int n;   long long a[N], s[N], p[N], k;   int ans = INF;   bool Check(int val) {     long long ans = k + 1;     for (int l = 1, r = 1; l <= n; l++) {       while (r <= n && a[r] - a[l] <= val) r++;       r--;       long long x = (a[l] * l - p[l]) + (s[r + 1] - (a[l] + val) * (n - r));       ans = min(ans, x);     }     for (int r = n, l = n; r > 0; r--) {       while (l > 0 && a[r] - a[l] <= val) l--;       l++;       long long x =           (s[r] - a[r] * (n - r + 1)) + ((a[r] - val) * (l - 1) - p[l - 1]);       ans = min(ans, x);     }     return (ans <= k);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + 1 + n);     for (int i = 1; i <= n; i++) p[i] = ((i == 1) ? a[i] : p[i - 1] + a[i]);     for (int i = n; i > 0; i--) s[i] = ((i == n) ? a[i] : s[i + 1] + a[i]);     int l = 0;     int r = INF;     while (l <= r) {       int m = (l + r) / 2;       if (Check(m)) {         ans = m;         r = m - 1;       } else         l = m + 1;     }     cout << ans;     return 0;   }   