Language: C++

//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 2e5 + 20 ;
int n , X , x[N] , d[N] ;
ll part[N] ;

inline ll get (int k) {
	ll ans = 1ll * n * X + 1ll * k * X ;

	for (int i = 1 , p = n ; p > 0 ; i ++ , p -= k)
		ans += (part[p] - part[max(0ll , p - k)]) * d[i] , ans = min(1e18 , ans) ; 
	
	return ans ;
}

int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n >> X ;

	for (int i = 0 ; i < n ; i ++) cin >> x[i] ;

	sort(x , x + n) ;

	for (int i = 0 ; i < n ; i ++) part[i + 1] = part[i] + x[i] ;

	d[1] = 5 ;
	for (int i = 2 ; i <= n ; i ++) d[i] = 2 * i + 1 ;

	ll ans = get(1) ;
	for (int i = 2 ; i <= n ; i ++) ans = min(ans , get(i)) ; 

	cout << ans << '\n' ;
}

Compiler output:
a.cc: In function 'll get(int)':
a.cc:22:43: error: no matching function for call to 'max(long long int, int)'
   22 |                 ans += (part[p] - part[max(0ll , p - k)]) * d[i] , ans = min(1e18 , ans) ;
      |                                        ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:22:43: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   22 |                 ans += (part[p] - part[max(0ll , p - k)]) * d[i] , ans = min(1e18 , ans) ;
      |                                        ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:22:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   22 |                 ans += (part[p] - part[max(0ll , p - k)]) * d[i] , ans = min(1e18 , ans) ;
      |                                        ~~~^~~~~~~~~~~~~
a.cc:22:77: error: no matching function for call to 'min(double, ll&)'
   22 |                 ans += (part[p] - part[max(0ll , p - k)]) * d[i] , ans = min(1e18 , ans) ;
      |                                                                          ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:22:77: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'll' {aka 'long long int'})
   22 |                 ans += (part[p] - part[max(0ll , p - k)]) * d[i] , ans = min(1e18 , ans) ;
      |                                                                          ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:22:77: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   22 |                 ans += (part[p] - part[max(0ll , p - k)]) * d[i] , ans = min(1e18 , ans) ;
      |                                                                          ~~~^~~~~~~~~~~~