func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2>   inline void chkmin(T1 &first, T2 second) {     if (first > second) first = second;   }   template <typename T1, typename T2>   inline void chkmax(T1 &first, T2 second) {     if (first < second) first = second;   }   const string FileName =  input ;   const int MAXN = 3e5 + 100;   int n, k, b, c;   vector<int> arr;   vector<int> event[5];   long long sum, mod, ans = 1e18;   multiset<long long> que;   long long f(long long s, long long t) {     return ((t - s) / 5) * b + ((t - s) % 5) * c;   }   int main(int argc, char const *argv[]) {     srand(time(0));     ios::sync_with_stdio(0);     cin >> n >> k >> b >> c;     arr.resize(n);     b = min(b, c * 5);     for (int i = 0; i < n; ++i) {       cin >> arr[i];     }     sort(arr.begin(), arr.end());     for (int i = 0; i < n; ++i) {       for (int j = 0; j < 5; ++j) {         event[(((arr[i] + j) % 5) + 5) % 5].push_back(arr[i] + j);       }     }     for (int j = 0; j < 5; ++j) {       int L = 0;       sum = 0, mod = 0;       que.clear();       for (int i = 0; i < n; ++i) {         while (L < n && arr[L] <= event[j][i]) {           que.insert(-f(arr[L], event[j][i]) - mod);           sum += f(arr[L], event[j][i]);           ++L;         }         while (que.size() > k) {           sum += *que.begin() + mod;           que.erase(que.begin());         }         if (que.size() == k) {           ans = min(ans, sum);         }         if (i != n - 1) {           assert(event[j][i] <= event[j][i + 1]);           mod -= f(event[j][i], event[j][i + 1]);           sum += f(event[j][i], event[j][i + 1]) * que.size();         }       }     }     cout << ans << endl;   }   