Language: C++

use std::collections::{
    HashMap, HashSet
};

#[derive(Debug)]
struct UnionFind {
    parent: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
}

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

    fn root(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            let p = self.parent[x];
            self.parent[x] = self.root(p);
            self.parent[x]
        }
    }

    fn unite(&mut self, a: usize, b:usize) {
        let ra = self.root(a);
        let rb = self.root(b);
        if self.rank[ra] > self.rank[rb] {
            self.parent[rb] = ra;
            self.size[ra] += self.size[rb];
        } else if self.rank[ra] < self.rank[rb] {
            self.parent[ra] = rb;
            self.size[rb] += self.size[ra];
        } else if ra != rb {
            self.parent[rb] = ra;
            self.size[ra] += self.size[rb];
            self.rank[ra] += 1;
        }
    }

    fn size (&mut self, x: usize) -> usize {
        let rx = self.root(x);
        self.size[rx]
    }

    fn same(&mut self, a: usize, b: usize) -> bool {
        self.root(a) == self.root(b)
    }

}


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|i| i.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<usize>();
    let n = input[0];
    let m = input[1];
    let k = input[2];

    let mut uf = UnionFind::new(n);
    let mut friends: HashMap<usize, HashSet<usize>> = HashMap::new();
    let mut blocks: HashMap<usize, HashSet<usize>> = HashMap::new();

    for i in 0..n {
        friends.insert(i, HashSet::new());
        blocks.insert(i, HashSet::new());
    }

    for _ in 0..m {
        let input = read_vec::<usize>();
        uf.unite(input[0]-1, input[1]-1);
        friends.get_mut(&(input[0]-1)).unwrap().insert(input[1]-1);
        friends.get_mut(&(input[1]-1)).unwrap().insert(input[0]-1);
        
    }

    for _ in 0..k {
        let input = read_vec::<usize>();
        blocks.get_mut(&(input[0]-1)).unwrap().insert(input[1]-1);
        blocks.get_mut(&(input[1]-1)).unwrap().insert(input[0]-1);
        

    }

    let mut ans: Vec<usize> = vec![];

    for i in 0..n {
        let s = uf.size(i);
        let f = &friends[&i];
        let b = &blocks[&i];
        let mut c = 0;
        for j in b {
            if uf.same(i, *j) {
                c += 1;
            }
        }
        ans.push(s-f.len()-c-1);
    }

    let s = ans.iter().map(|e| e.to_string()).collect::<Vec<_>>().join(" ");

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


Compiler output:
a.cc:5:2: error: invalid preprocessing directive #[
    5 | #[derive(Debug)]
      |  ^
a.cc:15:18: error: too many decimal points in number
   15 |         for i in 0..n {
      |                  ^~~~
a.cc:86:14: error: too many decimal points in number
   86 |     for i in 0..n {
      |              ^~~~
a.cc:91:14: error: too many decimal points in number
   91 |     for _ in 0..m {
      |              ^~~~
a.cc:99:14: error: too many decimal points in number
   99 |     for _ in 0..k {
      |              ^~~~
a.cc:109:14: error: too many decimal points in number
  109 |     for i in 0..n {
      |              ^~~~
a.cc:1:1: error: 'use' does not name a type
    1 | use std::collections::{
      | ^~~
a.cc:7:5: error: 'parent' does not name a type
    7 |     parent: Vec<usize>,
      |     ^~~~~~
a.cc:12:6: error: expected initializer before 'UnionFind'
   12 | impl UnionFind {
      |      ^~~~~~~~~
a.cc:63:1: error: 'fn' does not name a type
   63 | fn read<T: std::str::FromStr>() -> T {
      | ^~
a.cc:69:1: error: 'fn' does not name a type
   69 | fn read_vec<T: std::str::FromStr>() -> Vec<T> {
      | ^~
a.cc:76:1: error: 'fn' does not name a type
   76 | fn main() {
      | ^~