func_code_string: #include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }   long long bigmod(long long a, long long b) {     long long ret = 1;     while (b) {       if (b & 1) ret = (ret * a) % 1000000007;       b >>= 1;       a = (a * a) % 1000000007;     }     return ret;   }   long long inverse(long long n) { return bigmod(n, 1000000007 - 2); }   long long add(long long a, long long b) {     long long ret = a + b;     if (ret >= 1000000007) ret %= 1000000007;     return ret;   }   long long subtract(long long a, long long b) {     long long ret = a - b;     if (ret < 0) ret += 1000000007;     return ret;   }   long long mult(long long a, long long b) {     long long ret = a * b;     if (ret >= 1000000007) ret %= 1000000007;     return ret;   }   bool checkBit(int n, int i) { return (n & (1 << i)); }   int setBit(int n, int i) { return (n | (1 << i)); }   int resetBit(int n, int i) { return (n & (~(1 << i))); }   long long a[500010], p[500010];   int main() {     int n, k;     scanf( %d%d , &n, &k);     long long sum = 0;     for (int i = 0; i < n; ++i) {       scanf( %lld , &a[i]);       sum += a[i];     }     sort(a, a + n);     long long avg = sum / n, rem = sum % n;     for (int i = 0; i < n; ++i) p[i] = avg;     for (int i = n - 1; rem; --i) {       --rem;       ++p[i];     }     long long up = 0, down = n - 1, days = 0;     for (int i = 0; i < n; ++i) {       if (a[i] <= p[i]) {         up = i;         days += p[i] - a[i];       } else         break;     }     for (int i = n - 1; i >= 0; --i) {       if (a[i] >= p[i])         down = i;       else         break;     };     ;     ;     if (k >= days) {       printf( %lld n , p[n - 1] - p[0]);       return 0;     }     long long mn = -1, mx = -1;     sum = 0, days = 0;     for (int i = 0; i < up + 1; ++i) {       ++sum;       long long x = a[i], y = min(a[i + 1], p[i + 1]);       days += sum * (y - x);       ;       if (days == k) {         mn = y;         break;       } else if (days > k) {         days -= sum * (y - x);         rem = k - days;         ;         mn = a[i] + rem / sum;         break;       }     };     sum = 0, days = 0;     for (int i = n - 1; i >= down; --i) {       ++sum;       long long x = a[i], y = max(a[i - 1], p[i - 1]);       days += sum * (x - y);       ;       if (days == k) {         mx = y;         break;       } else if (days > k) {         days -= sum * (x - y);         rem = k - days;         ;         mx = a[i] - rem / sum;         break;       }     };     cout << mx - mn << endl;     return 0;   }   