Language: C++

#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair< int, int> pii;
typedef pair< ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template< typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
class Graph {
public:
	int vn;
	int sumcost = 0;
	vector< vector< pii> > g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
	void scan(int edcount, bool oindexed, bool w) {
		REP(i, edcount) {
			int a, b, c = 1;
			scanf(" %d %d", &a, &b);
			if (w)scanf(" %d", &c);
			con(a - oindexed, b - oindexed, c);
		}
	}
};
class BiDGraph : public Graph {//無向
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b, w });
		g[b].push_back({ a, w });
		sumcost++;
	}
};
struct UnionFind {
	vector< int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) { //ｘの入ってる集合と yの入ってる集合を併合
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { //xとyが同じ集合に入っているかどうかを判定
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	bool isroot(int x) {
		return data[x] < 0;
	}
	int size(int x) {
		return -data[root(x)];
	}
};
BiDGraph Kruskal(BiDGraph g) {//最小全域　森
	UnionFind uf(g.vn);
	priority_queue< pair< int, pii>, vector< pair< int, pii> >, greater< pair< int, pii> > > que;
	REP(i, g.g.size()) {
		for (auto itr : g.g[i]) {
			int f = i, t = itr.first;
			if (f < t)
				swap(f, t);
			que.push({ itr.second, { f, t } });
		}
	}
	BiDGraph MST(g.vn);
	int alcou = 0;
	while (alcou < g.vn) {
		pair< int, pii> cur = que.top();
		que.pop();
		if (uf.findSet(cur.second.first, cur.second.second))
			continue;

		if (uf.data[cur.second.first] == -1)
			alcou++;
		if (uf.data[cur.second.second] == -1)
			alcou++;
		uf.unionSet(cur.second.first, cur.second.second);
		MST.con(cur.second.first, cur.second.second);
	}
	return MST;
}

template <typename T>
class SkewHeap {

	SkewHeap l, r;
	T val;

	static meld(SkewHeap* a, SkewHeap* b){
		if (!a) return b;
		if (!b) return a;
		i(a)
	}
};

signed main() {
	int n, m;
	scanf(" %d %d", &n, &m);
	BiDGraph g(n);
	vector< pii> ed(m);
	REP(i, m) {
		int a, b, w;
		scanf(" %d %d %d", &a, &b, &w);
		ed[i] = { a, b };
		g.con(a - 1, b - 1, w);
	}

	BiDGraph mst = Kruskal(g);
	int sum = 0;
	for (auto itr : mst.g) {
		for (auto itr2 : itr) {
			sum += itr2.second;
		}
	}
	sum /= 2;
	vector< pii> eu(n);
	int euc = 0;
	function< void(int, int)> tour = [&](int c, int p) {
		eu[c].first = euc;
		euc++;
		for (auto itr : mst.g[c]) {
			if (itr.first != p) {
				tour(itr.first, c);
			}
		}
		eu[c].second = euc;
		euc++;
	};
	tour(0, -1);

	map< pii, int> ans;
	function< SkewHeap(int, int, int)> dfs = [&](int c, int p, int w) {
		SkewHeap heap;
		for (auto itr : mst.g[c]) {
			if (itr.first != p) {
				heap.meld(dfs(itr.first, c, itr.second));
			}
		}
		for (auto itr : mst.g[c]) {
			heap.push(itr.second, itr.first);
		}
		if (p > 0) {
			while (1) {
				pii cur = heap.top();
				if (eu[c].first < eu[cur.second].first & & eu[cur.second].second < eu[c].second) {
					heap.pop();
				}
				else {
					ans[{p, c}] = sum - w + cur.first;
					break;
				}
			}
		}
	};

	dfs(0, -1, 0);
	return 0;
}

Compiler output:
a.cc:8:20: warning: extra tokens at end of #include directive
    8 | #include <stdlib.h>>
      |                    ^
a.cc:149:18: error: field 'l' has incomplete type 'SkewHeap<T>'
  149 |         SkewHeap l, r;
      |                  ^
a.cc:147:7: note: definition of 'class SkewHeap<T>' is not complete until the closing brace
  147 | class SkewHeap {
      |       ^~~~~~~~
a.cc:149:21: error: field 'r' has incomplete type 'SkewHeap<T>'
  149 |         SkewHeap l, r;
      |                     ^
a.cc:147:7: note: definition of 'class SkewHeap<T>' is not complete until the closing brace
  147 | class SkewHeap {
      |       ^~~~~~~~
a.cc:152:16: error: ISO C++ forbids declaration of 'meld' with no type [-fpermissive]
  152 |         static meld(SkewHeap* a, SkewHeap* b){
      |                ^~~~
a.cc: In static member function 'static int SkewHeap<T>::meld(SkewHeap<T>*, SkewHeap<T>*)':
a.cc:156:9: error: expected ';' before '}' token
  156 |         }
      |         ^
a.cc: In function 'int main()':
a.cc:195:42: error: template argument 1 is invalid
  195 |         function< SkewHeap(int, int, int)> dfs = [&](int c, int p, int w) {
      |                                          ^
a.cc: In lambda function:
a.cc:196:26: error: class template argument deduction failed:
  196 |                 SkewHeap heap;
      |                          ^~~~
a.cc:196:26: error: no matching function for call to 'SkewHeap()'
a.cc:147:7: note: candidate: 'template<class T> SkewHeap()-> SkewHeap<T>'
  147 | class SkewHeap {
      |       ^~~~~~~~
a.cc:147:7: note:   template argument deduction/substitution failed:
a.cc:196:26: note:   couldn't deduce template parameter 'T'
  196 |                 SkewHeap heap;
      |                          ^~~~
a.cc:147:7: note: candidate: 'template<class T> SkewHeap(SkewHeap<T>)-> SkewHeap<T>'
  147 | class SkewHeap {
      |       ^~~~~~~~
a.cc:147:7: note:   candidate expects 1 argument, 0 provided
a.cc:199:46: error: expression cannot be used as a function
  199 |                                 heap.meld(dfs(itr.first, c, itr.second));
      |                                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:208:98: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  208 |                                 if (eu[c].first < eu[cur.second].first & & eu[cur.second].second < eu[c].second) {
      |                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:195:50: error: cannot convert 'main()::<lambda(int, int, int)>' to 'int' in initialization
  195 |         function< SkewHeap(int, int, int)> dfs = [&](int c, int p, int w) {
      |                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                  |
      |                                                  main()::<lambda(int, int, int)>
  196 |                 SkewHeap heap;
      |                 ~~~~~~~~~~~~~~                    
  197 |                 for (auto itr : mst.g[c]) {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~       
  198 |                         if (itr.first != p) {
      |                         ~~~~~~~~~~~~~~~~~~~~~     
  199 |                                 heap.meld(dfs(itr.first, c, itr.second));
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  200 |                         }
      |                         ~                         
  201 |                 }
      |                 ~                                 
  202 |                 for (auto itr : mst.g[c]) {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~       
  203 |                         heap.push(itr.second, itr.first);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  204 |                 }
      |                 ~                                 
  205 |                 if (p > 0) {
      |                 ~~~~~~~~~~~~                      
  206 |                         while (1) {
      |                         ~~~~~~~~~~~               
  207 |                                 pii cur = heap.top();
      |                                 ~~~~~~~~~~~~~~~~~~~~~
  208 |                                 if (eu[c].first < eu[cur.second].first & & eu[cur.second].second < eu[c].second) {
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  209 |                                         heap.pop();
      |                                         ~~~~~~~~~~~
  210 |                                 }
      |                                 ~                 
  211 |                                 else {
      |                                 ~~~~~~            
  212 |                                         ans[{p, c}] = sum - w + cur.first;
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  213 |                                         break;
      |                                         ~~~~~~    
  214 |                                 }
      |                                 ~                 
  215 |                         }
      |                         ~                         
  216 |                 }
      |                 ~                                 
  217 |         };
      |         ~                                         
a.cc:219:12: error: 'dfs' cannot be used as a function
  219 |         dfs(0, -1, 0);
      |         ~~~^~~~~~~~~~