Language: C++

#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i++)

#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include <cassert>
#include<stack>
#include<deque>
#include<list>
#include<sstream>
#include<unordered_map>
#include<time.h>
#pragma comment(linker, "/STACK:8809999999")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef pair<ld, ld> pld;
typedef pair<pll, ll> ppll;
typedef pair<pll, pll> ppp;
typedef vector <vector <pair <ll, ll>>> gosh; // cost, end of edge
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const ll settled = 400007;

vl a;
gosh ed;
ll co = 0;
void DnC(ll d, ll le = 0, ll ri = a.size())
{
	co++;
	if (le >= ri-1)
		return;
	DnC(d, le, (ri + le) / 2);
	DnC(d, (ri + le) / 2, ri);
	ll lem = 0, rim = (ri + le) / 2;
	
	forn(i, le, (ri + le) / 2)
	{
		ll cost1, cost2;
		cost1 = a[lem] - d*lem;
		cost2 = a[i] - d*i;
		if (cost2 < cost1)
			lem = i;
	}

	forn(i, (ri + le) / 2, ri)
	{
		ll cost1, cost2;
		cost1 = a[rim] + d*rim;
		cost2 = a[i] + d*i;
		if (cost2 < cost1)
			rim = i;
	}
	
	forn(i, le, (ri + le) / 2)
	{
		ll cle, cri;
		cle = a[i] - d*i;
		cri = a[rim] + d*rim;
		ll cost = cle + cri;
		ed[i].push_back(make_pair(cost, rim));
		if(i != lem)
			ed[rim].push_back(make_pair(cost, i));
	}

	forn(i, (ri + le) / 2, ri)
	{
		ll cle, cri;
		cle = a[lem] - d*lem;
		cri = a[i] + d*i;
		ll cost = cle + cri;
		ed[i].push_back(make_pair(cost, lem));
		if (i != rim)
			ed[lem].push_back(make_pair(cost, i));
	}
}

template <class T> struct greater
{
	bool operator() (const T& x, const T& y)const
	{
		return x > y;
	}
};

ll MSTcost()
{
	priority_queue<pll, vector<pll>, greater<pll> > pile;
	vl used(ed.size(), 0);
	ll cost = 0;
	pile.push(make_pair(0, 0));
	while (pile.size())
	{
		pair<ll, ll> cur;
		cur = pile.top();
		pile.pop();
		if (used[cur.second])
			continue;
		used[cur.second] = 1;
		cost += cur.first;
		for (pair<ll, ll> edge : ed[cur.second])
		{
			if (used[edge.second])
				continue;
			pile.push(edge);
		}
	}
	cost;
	return cost;
}

int main()
{
	ios_base::sync_with_stdio(false); cout.tie(NULL);
#ifndef overlord
	//freopen("sufpref.in", "r", stdin);
	//freopen("sufpref.out", "w", stdout);
#else
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
	ll n, d;
	cin >> n >> d;
	a.resize(n, 0); ed.resize(n);
	forn(i, 0, ed.size())
		ed[i].reserve(20);
	forn(i, 0, n)
		cin >> a[i];
	DnC(d);
	ll val = MSTcost();
	cout << val;

	return 0;
}

Compiler output:
a.cc: In function 'll MSTcost()':
a.cc:98:55: error: template argument 3 is invalid
   98 |         priority_queue<pll, vector<pll>, greater<pll> > pile;
      |                                                       ^
a.cc:101:14: error: request for member 'push' in 'pile', which is of non-class type 'int'
  101 |         pile.push(make_pair(0, 0));
      |              ^~~~
a.cc:102:21: error: request for member 'size' in 'pile', which is of non-class type 'int'
  102 |         while (pile.size())
      |                     ^~~~
a.cc:105:28: error: request for member 'top' in 'pile', which is of non-class type 'int'
  105 |                 cur = pile.top();
      |                            ^~~
a.cc:106:22: error: request for member 'pop' in 'pile', which is of non-class type 'int'
  106 |                 pile.pop();
      |                      ^~~
a.cc:115:30: error: request for member 'push' in 'pile', which is of non-class type 'int'
  115 |                         pile.push(edge);
      |                              ^~~~