func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   bool chmax(T& a, const T& b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   template <class T>   bool chmin(T& a, const T& b) {     if (b < a) {       a = b;       return 1;     }     return 0;   }   long long int gcd(long long int a, long long int b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   long long int ceil(long long int a, long long int b) { return (a + b - 1) / b; }   long long int digit(long long int a) { return (long long int)log10(a); }   const long long int MOD = 1e9 + 7, INF = 1e18;   long long int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1},                 dy[8] = {0, 1, 0, -1, -1, -1, 1, 1};   void YN(bool flag) { cout << (flag ?  YES  :  NO ) <<   n ; }   struct point {     long long int r;     long long int x, y;   };   long long int N, K;   int main() {     cin >> N >> K;     vector<long long int> arr(N);     for (long long int i = (0), i_end_ = (N); i < i_end_; i++) {       cin >> arr[i];     }     sort((arr).begin(), (arr).end());     vector<pair<long long int, long long int> > vec;     long long int curr = arr[0], cnt = 1;     for (long long int i = (0), i_end_ = (N - 1); i < i_end_; i++) {       if (arr[i + 1] != curr) {         vec.push_back({curr, cnt});         curr = arr[i + 1];         cnt = 1;       } else {         cnt++;       }     }     vec.push_back({curr, cnt});     N = ((long long int)(vec).size());     vector<long long int> sums_l(N);     vector<long long int> sums_r(N);     vector<long long int> sumn_l(N);     vector<long long int> sumn_r(N);     long long int sum = 0;     for (long long int i = (0), i_end_ = (N - 1); i < i_end_; i++) {       sum += vec[i].second;       sums_l[i + 1] = sums_l[i] + (vec[i + 1].first - vec[i].first) * sum;       sumn_l[i + 1] = sum;     }     sum = 0;     for (long long int i = (0), i_end_ = (N - 1); i < i_end_; i++) {       sum += vec[N - i - 1].second;       sums_r[i + 1] =           sums_r[i] + (vec[N - i - 1].first - vec[N - i - 2].first) * sum;       sumn_r[i + 1] = sum;     }     long long int minv = INF;     for (long long int i = (0), i_end_ = (((long long int)(vec).size()));          i < i_end_; i++) {       long long int rest = K - sums_l[i];       if (rest < 0) continue;       long long int idx =           upper_bound((sums_r).begin(), (sums_r).end(), rest) - sums_r.begin();       idx--;       rest -= sums_r[idx];       long long int score = vec[N - idx - 1].first - vec[i].first;       score -= rest / sumn_r[idx + 1];       chmin(minv, score);     }     for (long long int i = (0), i_end_ = (((long long int)(vec).size()));          i < i_end_; i++) {       long long int rest = K - sums_r[i];       if (rest < 0) continue;       long long int idx =           upper_bound((sums_l).begin(), (sums_l).end(), rest) - sums_l.begin();       idx--;       rest -= sums_l[idx];       long long int score = vec[N - i - 1].first - vec[idx].first;       score -= rest / sumn_l[idx + 1];       chmin(minv, score);     }     cout << max(0ll, minv) <<   n ;   }   