func_code_string: #include <bits/stdc++.h>   template <class C, class E>   inline bool contains(const C &container, const E &element) {     return container.find(element) != container.end();   }   template <class T>   inline void checkmin(T &a, T b) {     if (b < a) a = b;   }   template <class T>   inline void checkmax(T &a, T b) {     if (b > a) a = b;   }   using namespace std;   class UnionFind {    public:     UnionFind(int elements) : _subsets(elements), _setCount(elements) {       for (int i = 0; i < elements; ++i) {         _subsets[i].parent = i;         _subsets[i].rank = 0;       }     }     int Find(int i) {       if (_subsets[i].parent != i) _subsets[i].parent = Find(_subsets[i].parent);       return _subsets[i].parent;     }     void Union(int x, int y) {       int xroot = Find(x);       int yroot = Find(y);       if (xroot == yroot) return;       --_setCount;       if (_subsets[xroot].rank < _subsets[yroot].rank)         _subsets[xroot].parent = yroot;       else if (_subsets[xroot].rank > _subsets[yroot].rank)         _subsets[yroot].parent = xroot;       else {         _subsets[yroot].parent = xroot;         _subsets[xroot].rank++;       }     }     struct subset {       int parent;       int rank;     };     void Trace() {       for (int i = (0), _b = ((_subsets.size()) - 1); i <= _b; i++)         cout << i <<  :  << Find(i) <<   | ;       cout << endl;     }     vector<subset> _subsets;     int _setCount;   };   vector<int> res;   struct Node {     Node(int v) {       l = r = NULL;       val = v;     }     Node(Node *_l, Node *_r) {       l = _l;       r = _r;     }     Node *l, *r;     int val;     void Solve() {       if (l == NULL) {         cout << val <<    ;       } else {         l->Solve();         r->Solve();       }     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cout << std::setprecision(15);     cout << std::fixed;     int n;     cin >> n;     res.reserve(n);     UnionFind uf(n + 1);     vector<Node *> d(n + 1);     for (int i = (1), _b = (n); i <= _b; i++) {       d[i] = new Node(i);     }     for (int i = (0), _b = ((n - 1) - 1); i <= _b; i++) {       int a, b;       cin >> a >> b;       int ra = uf.Find(a);       int rb = uf.Find(b);       Node *na = d[ra];       Node *nb = d[rb];       assert(na != NULL);       assert(nb != NULL);       d[ra] = NULL;       d[rb] = NULL;       uf.Union(ra, rb);       int nr = uf.Find(ra);       Node *nn = new Node(na, nb);       d[nr] = nn;     }     int rootR = uf.Find(1);     d[rootR]->Solve();     return 0;   }   