Language: C++

#include <queue>
#include <vector>
#include <iostream>
using namespace std;
// ------ Class ------ //
class Graph2 {
public:
	// ------ Variables ------ //
	static const long double INF = 1000000000000000000;
	int V, E; vector<vector<pair<int, long double> > > G;

	// ------ Constructors ------ //
	Graph2() : V(0), E(0), G(vector<vector<pair<int, long double> > >()) {}
	Graph2(int v) : V(v), E(0), G(vector<vector<pair<int, long double> > >(v)) {}
	Graph2(vector<vector<pair<int, long double> > > g) : V(g.size()), G(g) { for (int i = 0; i < g.size(); i++) E += g[i].size(); }

	// ------ Basic Functions ------ //
	int size() { return V; }
	void add1(int v1, int v2, long double w) { G[v1].push_back(make_pair(v2, w)); E++; }
	void add2(int v1, int v2, long double w) { add1(v1, v2, w); add1(v2, v1, w); }

	// ------ Operators ------ //
	bool operator==(const Graph2& g) const { return G == g.G; }
	bool operator!=(const Graph2& g) const { return G != g.G; }
	vector<pair<int, long double> > operator[](int x) { return G[x]; }

	// ------ Algorithms ------ //
	long double minspan() {
		vector<long double> d(V, INF);
		vector<bool> used(V, false);
		priority_queue<pair<long doubleg, int> > que;
		for (int i = 0; i < V; i++) d[i] = INF;
		d[0] = 0; que.push(make_pair(0, 0));
		while (!que.empty()) {
			pair<long double, int> pa = que.top(); que.pop();
			int u = pa.second; used[u] = true;
			for (int i = 0; i < G[u].size(); i++) {
				int v = G[u][i].first;
				if (d[v] > G[u][i].second && !used[v]) {
					d[v] = G[u][i].second; que.push(make_pair(-d[v], v));
				}
			}
		}
		long double sum = 0;
		for (int i = 0; i < V; i++) sum += d[i];
		return sum;
	}
};
// ------ Main ------ //
int n; long double x[111], y[111], x[111], r[111];
int main() {
	while(cin >> n, n) {
		for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i] >> r[i];
		Graph2 G(n);
		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				long double dist = sqrtl((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) + (z[i] - z[j]) * (z[i] - z[j]));
				G.add2(i, j, (dist > r[i] + r[j]) ? (dist - r[i] - r[j]) : 0)
			}
		}
		cout << G.minspan() << endl;
	}
}

Compiler output:
a.cc:9:34: error: 'constexpr' needed for in-class initialization of static data member 'const long double Graph2::INF' of non-integral type [-fpermissive]
    9 |         static const long double INF = 1000000000000000000;
      |                                  ^~~
a.cc: In member function 'long double Graph2::minspan()':
a.cc:31:54: error: wrong number of template arguments (1, should be 2)
   31 |                 priority_queue<pair<long doubleg, int> > que;
      |                                                      ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/deque:62,
                 from /usr/include/c++/14/queue:62,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
   89 |     struct pair;
      |            ^~~~
a.cc:31:56: error: template argument 1 is invalid
   31 |                 priority_queue<pair<long doubleg, int> > que;
      |                                                        ^
a.cc:31:56: error: template argument 2 is invalid
a.cc:31:56: error: template argument 3 is invalid
a.cc:33:31: error: request for member 'push' in 'que', which is of non-class type 'int'
   33 |                 d[0] = 0; que.push(make_pair(0, 0));
      |                               ^~~~
a.cc:34:29: error: request for member 'empty' in 'que', which is of non-class type 'int'
   34 |                 while (!que.empty()) {
      |                             ^~~~~
a.cc:35:57: error: request for member 'top' in 'que', which is of non-class type 'int'
   35 |                         pair<long double, int> pa = que.top(); que.pop();
      |                                                         ^~~
a.cc:35:68: error: request for member 'pop' in 'que', which is of non-class type 'int'
   35 |                         pair<long double, int> pa = que.top(); que.pop();
      |                                                                    ^~~
a.cc:40:68: error: request for member 'push' in 'que', which is of non-class type 'int'
   40 |                                         d[v] = G[u][i].second; que.push(make_pair(-d[v], v));
      |                                                                    ^~~~
a.cc: At global scope:
a.cc:50:36: error: redefinition of 'long double x [111]'
   50 | int n; long double x[111], y[111], x[111], r[111];
      |                                    ^
a.cc:50:20: note: 'long double x [111]' previously declared here
   50 | int n; long double x[111], y[111], x[111], r[111];
      |                    ^
a.cc: In function 'int main()':
a.cc:53:67: error: 'z' was not declared in this scope
   53 |                 for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i] >> r[i];
      |                                                                   ^
a.cc:57:123: error: 'z' was not declared in this scope
   57 |                                 long double dist = sqrtl((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) + (z[i] - z[j]) * (z[i] - z[j]));
      |                                                                                                                           ^
a.cc:57:52: error: 'sqrtl' was not declared in this scope; did you mean 'strtol'?
   57 |                                 long double dist = sqrtl((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) + (z[i] - z[j]) * (z[i] - z[j]));
      |                                                    ^~~~~
      |                                                    strtol
a.cc:58:94: error: expected ';' before '}' token
   58 |                                 G.add2(i, j, (dist > r[i] + r[j]) ? (dist - r[i] - r[j]) : 0)
      |                                                                                              ^
      |                                                                                              ;
   59 |                         }
      |                         ~