Language: C++

use std::io::*;
use std::str::FromStr;
use std::clone::Clone;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>,  
    size: Vec<usize>
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        let mut vec = vec![0; n];
        for i in 0..n {
            vec[i] = i;
        }
        UnionFind {
            par: vec, 
            rank: vec![0; n], 
            size: vec![1; n]
        }
    }

    fn find(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let p = self.par[x];
            let pp = self.find(p);
            self.size[x] = self.size[pp];
            self.par[x] = pp;
            pp
        }
    }

    fn unite(&mut self, x: usize, y: usize) {
        let p_x = self.find(x);
        let p_y = self.find(y);
        if p_x != p_y {
            self.size[p_x] += self.size[p_y];
            self.size[p_y] = self.size[p_x];
            if self.rank[p_x] < self.rank[p_y] {
                self.par[p_x] = p_y;
            } else {
                self.par[p_y] = p_x;
                if self.rank[p_x] == self.rank[p_y] {
                    self.rank[p_x] += 1;
                }
            }
        }
    }

    fn are_same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }
}

#[derive(Clone)]
struct Edge {
    from: usize, 
    to: usize, 
    cost: u64
}

#[derive(Clone)]
struct Node {
    pos: u64, 
    idx: usize
}

fn main() {
    let N: usize = read();
    let mut edges: Vec<Edge> = vec![
        Edge{ from: 0, to: 0, cost: 0 }; N*2
    ];
    let mut x: Vec<Node> = vec![Node{ pos: 0, idx: 0}; N];
    let mut y: Vec<Node> = vec![Node{ pos: 0, idx: 0 }; N];

    for i in 0..N {
        x[i].pos = read();
        x[i].idx = i;
        y[i].pos = read();
        y[i].idx = i;
    }

    x.sort_by(
        |x1, x2| { x1.pos.cmp(&x2.pos) }
    );
    y.sort_by(
        |y1, y2| { y1.pos.cmp(&y2.pos) }
    );


    for i in 0..N-1 {
        edges[2*i].from = x[i].idx;
        edges[2*i].to = x[i+1].idx;
        edges[2*i].cost = x[i+1].pos - x[i].pos;
        edges[2*i+1].from = y[i].idx;
        edges[2*i+1].to = y[i+1].idx;
        edges[2*i+1].cost = y[i+1].pos - y[i].pos;
    }

    edges.sort_by(
        |e1, e2| { e1.cost.cmp(&e2.cost) }
    );

    let mut uf = UnionFind::new(N);
    let mut ans = 0;
    for edge in &edges {
        if !uf.are_same(edge.from, edge.to) {
            uf.unite(edge.from, edge.to);
            ans += edge.cost;
        }
    }

    println!("{}", ans);
}

Compiler output:
a.cc:26:18: error: too many decimal points in number
   26 |         for i in 0..n {
      |                  ^~~~
a.cc:70:2: error: invalid preprocessing directive #[
   70 | #[derive(Clone)]
      |  ^
a.cc:77:2: error: invalid preprocessing directive #[
   77 | #[derive(Clone)]
      |  ^
a.cc:91:14: error: too many decimal points in number
   91 |     for i in 0..N {
      |              ^~~~
a.cc:106:14: error: too many decimal points in number
  106 |     for i in 0..N-1 {
      |              ^~~~
a.cc:1:1: error: 'use' does not name a type
    1 | use std::io::*;
      | ^~~
a.cc:2:1: error: 'use' does not name a type
    2 | use std::str::FromStr;
      | ^~~
a.cc:3:1: error: 'use' does not name a type
    3 | use std::clone::Clone;
      | ^~~
a.cc:5:1: error: 'fn' does not name a type
    5 | fn read<T: FromStr>() -> T {
      | ^~
a.cc:18:5: error: 'par' does not name a type
   18 |     par: Vec<usize>,
      |     ^~~
a.cc:23:6: error: expected initializer before 'UnionFind'
   23 | impl UnionFind {
      |      ^~~~~~~~~
a.cc:72:5: error: 'from' does not name a type
   72 |     from: usize,
      |     ^~~~
a.cc:75:2: error: expected ';' after struct definition
   75 | }
      |  ^
      |  ;
a.cc:79:5: error: 'pos' does not name a type
   79 |     pos: u64,
      |     ^~~
a.cc:83:4: error: expected initializer before 'main'
   83 | fn main() {
      |    ^~~~