Language: C++

#include <bits/stdc++.h>
using namespace std;

class UnionFind {
private:
  vector<int> par;  // 隕ェ
  vector<int> rank; // 譛ィ縺ョ豺ア縺?
public:
  // n隕∫エ?〒蛻晄悄蛹?  UnionFind(int n) {
    par.resize(n);
    rank.resize(n);
    for(int i = 0; i < n; ++i) {
      par[i] = i;
      rank[i] = 0;
    }
  }
  
  // 譛ィ縺ョ譬ケ繧呈アゅａ繧?  int find(int x) {
    if(par[x] == x) {
      return x;
    } else  {
      return par[x] = find(par[x]);
    }
  }

  // x縺ィy縺悟酔縺倬寔蜷医↓螻槭☆繧九°蜷ヲ縺?  bool same(int x, int y) {
    return find(x) == find(y);
  }
  
  // x縺ィy縺ョ螻槭☆繧矩寔蜷医ｒ菴オ蜷?  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    
    if(rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x] == rank[y]) ++rank[x];
    }
  }
};

struct Edge {
  int a, b, c;
  bool operator < (const Edge &e) const {
    return c < e.c;
  }
};

int main() {
  for(int n, m; cin >> n >> m && (n|m);) {
    vector<Edge> es;
    while(m--) {
      int a, b, c;
      cin >> a >> b >> c;
      --a; --b;
      es.push_back((Edge){a,b,c});
    }
    sort(es.begin(), es.end());
    UnionFind uf(n);
    int cnt = 0;
    for(int i = 0; i < es.size(); ++i) {
      if(uf.same(es[i].a, es[i].b)) continue;
      uf.unite(es[i].a, es[i].b);
      if(++cnt == n / 2) {
        cout << es[i].c << endl;
        break;
      }
    }
  }
  return 0;
}

Compiler output:
a.cc:10:5: error: 'par' does not name a type
   10 |     par.resize(n);
      |     ^~~
a.cc:11:5: error: 'rank' does not name a type
   11 |     rank.resize(n);
      |     ^~~~
a.cc:12:5: error: expected unqualified-id before 'for'
   12 |     for(int i = 0; i < n; ++i) {
      |     ^~~
a.cc:12:20: error: 'i' does not name a type
   12 |     for(int i = 0; i < n; ++i) {
      |                    ^
a.cc:12:27: error: expected unqualified-id before '++' token
   12 |     for(int i = 0; i < n; ++i) {
      |                           ^~
a.cc:16:4: error: expected ';' after class definition
   16 |   }
      |    ^
      |    ;
a.cc:19:5: error: expected unqualified-id before 'if'
   19 |     if(par[x] == x) {
      |     ^~
a.cc:21:7: error: expected unqualified-id before 'else'
   21 |     } else  {
      |       ^~~~
a.cc:24:3: error: expected declaration before '}' token
   24 |   }
      |   ^
a.cc:27:5: error: expected unqualified-id before 'return'
   27 |     return find(x) == find(y);
      |     ^~~~~~
a.cc:28:3: error: expected declaration before '}' token
   28 |   }
      |   ^
a.cc:31:5: error: 'x' does not name a type
   31 |     x = find(x);
      |     ^
a.cc:32:5: error: 'y' does not name a type
   32 |     y = find(y);
      |     ^
a.cc:33:5: error: expected unqualified-id before 'if'
   33 |     if(x == y) return;
      |     ^~
a.cc:35:5: error: expected unqualified-id before 'if'
   35 |     if(rank[x] < rank[y]) {
      |     ^~
a.cc:37:7: error: expected unqualified-id before 'else'
   37 |     } else {
      |       ^~~~
a.cc:41:3: error: expected declaration before '}' token
   41 |   }
      |   ^
a.cc:42:1: error: expected declaration before '}' token
   42 | };
      | ^
a.cc: In function 'int main()':
a.cc:61:19: error: no matching function for call to 'UnionFind::UnionFind(int&)'
   61 |     UnionFind uf(n);
      |                   ^
a.cc:4:7: note: candidate: 'UnionFind::UnionFind()'
    4 | class UnionFind {
      |       ^~~~~~~~~
a.cc:4:7: note:   candidate expects 0 arguments, 1 provided
a.cc:4:7: note: candidate: 'UnionFind::UnionFind(const UnionFind&)'
a.cc:4:7: note:   no known conversion for argument 1 from 'int' to 'const UnionFind&'
a.cc:4:7: note: candidate: 'UnionFind::UnionFind(UnionFind&&)'
a.cc:4:7: note:   no known conversion for argument 1 from 'int' to 'UnionFind&&'
a.cc:64:13: error: 'class UnionFind' has no member named 'same'
   64 |       if(uf.same(es[i].a, es[i].b)) continue;
      |             ^~~~
a.cc:65:10: error: 'class UnionFind' has no member named 'unite'
   65 |       uf.unite(es[i].a, es[i].b);
      |          ^~~~~