func_code_string: #include <bits/stdc++.h>   using namespace std;   bool deb = false;   int i, k, n;   const int N = 500011;   int a[N];   bool f1(long long int x) {     int i;     long long int inc = 0, dec = 0;     for (i = 0; i < n; ++i) {       if (a[i] > x)         dec += (a[i] - x);       else         inc += (x - a[i]);     }     if (dec <= inc && dec <= k) return 1;     return 0;   }   bool f2(long long int x) {     int i;     long long int inc = 0, dec = 0;     for (i = 0; i < n; ++i) {       if (a[i] > x)         dec += (a[i] - x);       else         inc += (x - a[i]);     }     if (dec >= inc && inc <= k) return 1;     return 0;   }   long long int min_max(long long int lo, long long int hi) {     while (lo < hi) {       long long int mid = lo + (hi - lo) / 2;       if (f1(mid)) {         hi = mid;       } else         lo = mid + 1;     }     return hi;   }   long long int max_min(long long int lo, long long int hi) {     while (lo < hi) {       long long int mid = lo + (hi - lo) / 2;       if (f2(mid)) {         lo = mid + 1;       } else         hi = mid;     }     return lo - 1;   }   int main() {     int i, j;     scanf( %d , &n), scanf( %d , &k);     for (i = 0; i < n; ++i) scanf( %d , &a[i]);     int mx = min_max(1, 1000000007);     int mn = max_min(1, 1000000007);     printf( %d n , mx - mn);     return 0;   }   