Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, node1, node2, ans, leaf, sett;
vector<ll> adjlist[10005];
ll c[10005];
bool visited1[10005];
bool visited2[10005];
ll sets[10005];
void dfs(ll x){
	if (visited1[x]) return;
	visited1[x] = 1;
	if (adjlist[x].size() == 1 && x != 1){
		leaf = x;
		}
	for (auto i:adjlist[x]){
		if (visited1[i])continue;
		//if (adjlist[i].size() == 1 && i != 1){
		//	leaf = i;
		//	cout << leaf << '\n';
		//	}
			dfs(i);
		}
	
	}
void dfs2(ll x){
	if (visited2[x])return;
	visited2[x] = 1;
	sets[x] = c[sett];
	sett -= 1;
	for (auto i:adjlist[x]){
		if (visited2[i])continue;
		//sets[i] = c[sett];
		//sett -= 1;
		dfs2(i);
		}
	
	}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for (ll i = 0; i < n-1; i++){
		cin >> node1 >> node2;
		adjlist[node1].push_back(node2);
		adjlist[node2].push_back(node1);
		}
	for (ll i = 1; i <= n; i++){
		cin >> c[i];
		}
		sort(c+1, c+n+1);
		for (ll i = 1; i <= n-1; i++){
			ans += c[i];
			}
			cout << ans << '\n';
		dfs(1); //dfs parts buggy
		//cout << leaf << '\n';
		sett = n;
		dfs2(leaf);
		for (ll i = 1; i <= n; i++){
			//if (sets[i] == c[n])continue;
			cout << sets[i] << ' ';
			}
}#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, node1, node2, ans, leaf, sett;
vector<ll> adjlist[10005];
ll c[10005];
bool visited1[10005];
bool visited2[10005];
ll sets[10005];
void dfs(ll x){
	if (visited1[x]) return;
	visited1[x] = 1;
	if (adjlist[x].size() == 1 && x != 1){
		leaf = x;
		}
	for (auto i:adjlist[x]){
		if (visited1[i])continue;
		//if (adjlist[i].size() == 1 && i != 1){
		//	leaf = i;
		//	cout << leaf << '\n';
		//	}
			dfs(i);
		}
	
	}
void dfs2(ll x){
	if (visited2[x])return;
	visited2[x] = 1;
	sets[x] = c[sett];
	sett -= 1;
	for (auto i:adjlist[x]){
		if (visited2[i])continue;
		//sets[i] = c[sett];
		//sett -= 1;
		dfs2(i);
		}
	
	}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for (ll i = 0; i < n-1; i++){
		cin >> node1 >> node2;
		adjlist[node1].push_back(node2);
		adjlist[node2].push_back(node1);
		}
	for (ll i = 1; i <= n; i++){
		cin >> c[i];
		}
		sort(c+1, c+n+1);
		for (ll i = 1; i <= n-1; i++){
			ans += c[i];
			}
			cout << ans << '\n';
		dfs(1); //dfs parts buggy
		//cout << leaf << '\n';
		sett = n;
		dfs2(leaf);
		for (ll i = 1; i <= n; i++){
			//if (sets[i] == c[n])continue;
			cout << sets[i] << ' ';
			}
}

Compiler output:
a.cc:63:2: error: stray '#' in program
   63 | }#include <bits/stdc++.h>
      |  ^
a.cc:63:3: error: 'include' does not name a type
   63 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:66:4: error: redefinition of 'll n'
   66 | ll n, node1, node2, ans, leaf, sett;
      |    ^
a.cc:4:4: note: 'll n' previously declared here
    4 | ll n, node1, node2, ans, leaf, sett;
      |    ^
a.cc:66:7: error: redefinition of 'll node1'
   66 | ll n, node1, node2, ans, leaf, sett;
      |       ^~~~~
a.cc:4:7: note: 'll node1' previously declared here
    4 | ll n, node1, node2, ans, leaf, sett;
      |       ^~~~~
a.cc:66:14: error: redefinition of 'll node2'
   66 | ll n, node1, node2, ans, leaf, sett;
      |              ^~~~~
a.cc:4:14: note: 'll node2' previously declared here
    4 | ll n, node1, node2, ans, leaf, sett;
      |              ^~~~~
a.cc:66:21: error: redefinition of 'll ans'
   66 | ll n, node1, node2, ans, leaf, sett;
      |                     ^~~
a.cc:4:21: note: 'll ans' previously declared here
    4 | ll n, node1, node2, ans, leaf, sett;
      |                     ^~~
a.cc:66:26: error: redefinition of 'll leaf'
   66 | ll n, node1, node2, ans, leaf, sett;
      |                          ^~~~
a.cc:4:26: note: 'll leaf' previously declared here
    4 | ll n, node1, node2, ans, leaf, sett;
      |                          ^~~~
a.cc:66:32: error: redefinition of 'll sett'
   66 | ll n, node1, node2, ans, leaf, sett;
      |                                ^~~~
a.cc:4:32: note: 'll sett' previously declared here
    4 | ll n, node1, node2, ans, leaf, sett;
      |                                ^~~~
a.cc:67:12: error: redefinition of 'std::vector<long long int> adjlist [10005]'
   67 | vector<ll> adjlist[10005];
      |            ^~~~~~~
a.cc:5:12: note: 'std::vector<long long int> adjlist [10005]' previously declared here
    5 | vector<ll> adjlist[10005];
      |            ^~~~~~~
a.cc:68:4: error: redefinition of 'll c [10005]'
   68 | ll c[10005];
      |    ^
a.cc:6:4: note: 'll c [10005]' previously declared here
    6 | ll c[10005];
      |    ^
a.cc:69:6: error: redefinition of 'bool visited1 [10005]'
   69 | bool visited1[10005];
      |      ^~~~~~~~
a.cc:7:6: note: 'bool visited1 [10005]' previously declared here
    7 | bool visited1[10005];
      |      ^~~~~~~~
a.cc:70:6: error: redefinition of 'bool visited2 [10005]'
   70 | bool visited2[10005];
      |      ^~~~~~~~
a.cc:8:6: note: 'bool visited2 [10005]' previously declared here
    8 | bool visited2[10005];
      |      ^~~~~~~~
a.cc:71:4: error: redefinition of 'll sets [10005]'
   71 | ll sets[10005];
      |    ^~~~
a.cc:9:4: note: 'll sets [10005]' previously declared here
    9 | ll sets[10005];
      |    ^~~~
a.cc:72:6: error: redefinition of 'void dfs(ll)'
   72 | void dfs(ll x){
      |      ^~~
a.cc:10:6: note: 'void dfs(ll)' previously defined here
   10 | void dfs(ll x){
      |      ^~~
a.cc:88:6: error: redefinition of 'void dfs2(ll)'
   88 | void dfs2(ll x){
      |      ^~~~
a.cc:26:6: note: 'void dfs2(ll)' previously defined here
   26 | void dfs2(ll x){
      |      ^~~~
a.cc:101:5: error: redefinition of 'int main()'
  101 | int main(){
      |     ^~~~
a.cc:39:5: note: 'int main()' previously defined here
   39 | int main(){
      |     ^~~~