func_code_string: #include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   template <typename T, typename U>   inline void amin(T &x, U y) {     if (y < x) x = y;   }   template <typename T, typename U>   inline void amax(T &x, U y) {     if (x < y) x = y;   }   template <typename T>   inline void write(T x) {     int i = 20;     char buf[21];     buf[20] =   n ;     do {       buf[--i] = x % 10 +  0 ;       x /= 10;     } while (x);     do putchar(buf[i]);     while (buf[i++] !=   n );   }   template <typename T>   inline T readInt() {     T n = 0, s = 1;     char p = getchar();     if (p ==  - ) s = -1;     while ((p <  0  || p >  9 ) && p != EOF && p !=  - ) p = getchar();     if (p ==  - ) s = -1, p = getchar();     while (p >=  0  && p <=  9 ) {       n = (n << 3) + (n << 1) + (p -  0 );       p = getchar();     }     return n * s;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n, k, *h, smin, c;     n = readInt<long long int>();     h = (long long int *)malloc(n * sizeof(long long int));     k = readInt<long long int>();     for (int i = 0; i < n; i += 1) h[i] = readInt<long long int>();     sort(h, h + n);     reverse(h, h + n);     if (h[0] == h[n - 1]) {       write(0);       return 0;     }     smin = 1;     c = 0;     for (int i = 0; i < n - 1; i += 1) {       for (int j = h[i]; j >= h[i + 1] + 1; j -= 1) {         if (c + i + 1 > k) {           smin++;           c = i + 1;         } else           c += i + 1;       }     }     write(smin);     return 0;   }   