Language: C++

using namespace std;
 
int N, M, K;
 
/* UnionFind：素集合系管理の構造体(union by size)
    isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
    unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
    treeSize(x): x を含む集合の要素数。
*/
struct UnionFind {
    vector<int> size, parents;
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        size.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        size[x] = 1;
    }
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
    bool unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x) { return size[findRoot(x)]; }
};
 
int main() {
    cin >> N >> M >> K;
    UnionFind uf(N);              // Union-Find Tree で考える
    vector<int> edges_num(N, 0);  // 自身から出る辺の数
    vector<int> A(M), B(M);
    REP(i, M) {
        cin >> A.at(i) >> B.at(i);
        A[i]--, B[i]--;
        edges_num[A[i]]++;
        edges_num[B[i]]++;
        uf.unite(A[i], B[i]);
    }
    vector<int> C(K), D(K);
    REP(i, K) {
        cin >> C.at(i) >> D.at(i);
        C[i]--, D[i]--;
    }
 
    vector<int> ans(N);
    REP(i, N) { ans[i] = uf.treeSize(i) - 1 - edges_num[i]; }
    REP(i, K) {  // 同じ連結成分にあるブロック関係を引く
        if (uf.isSame(C[i], D[i])) {
            ans[C[i]]--;
            ans[D[i]]--;
        }
    }
 
    REP(i, (int)ans.size()) {
        cout << ans[i];
        if (i != (int)ans.size() - 1) cout << " ";
    }
    cout << endl;
 
    return 0;
}

Compiler output:
a.cc:11:5: error: 'vector' does not name a type
   11 |     vector<int> size, parents;
      |     ^~~~~~
a.cc: In constructor 'UnionFind::UnionFind(int)':
a.cc:14:9: error: 'size' was not declared in this scope
   14 |         size.resize(n, 0);
      |         ^~~~
a.cc:15:9: error: 'parents' was not declared in this scope
   15 |         parents.resize(n, 0);
      |         ^~~~~~~
a.cc: In member function 'void UnionFind::makeTree(int)':
a.cc:21:9: error: 'parents' was not declared in this scope
   21 |         parents[x] = x;  // the parent of x is x
      |         ^~~~~~~
a.cc:22:9: error: 'size' was not declared in this scope
   22 |         size[x] = 1;
      |         ^~~~
a.cc: In member function 'bool UnionFind::unite(int, int)':
a.cc:29:13: error: 'size' was not declared in this scope
   29 |         if (size[x] > size[y]) {
      |             ^~~~
a.cc:30:13: error: 'parents' was not declared in this scope
   30 |             parents[y] = x;
      |             ^~~~~~~
a.cc:33:13: error: 'parents' was not declared in this scope
   33 |             parents[x] = y;
      |             ^~~~~~~
a.cc: In member function 'int UnionFind::findRoot(int)':
a.cc:39:18: error: 'parents' was not declared in this scope
   39 |         if (x != parents[x]) {
      |                  ^~~~~~~
a.cc:42:16: error: 'parents' was not declared in this scope
   42 |         return parents[x];
      |                ^~~~~~~
a.cc: In member function 'int UnionFind::treeSize(int)':
a.cc:44:34: error: 'size' was not declared in this scope
   44 |     int treeSize(int x) { return size[findRoot(x)]; }
      |                                  ^~~~
a.cc: In function 'int main()':
a.cc:48:5: error: 'cin' was not declared in this scope
   48 |     cin >> N >> M >> K;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:50:5: error: 'vector' was not declared in this scope
   50 |     vector<int> edges_num(N, 0);  // 自身から出る辺の数
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:50:12: error: expected primary-expression before 'int'
   50 |     vector<int> edges_num(N, 0);  // 自身から出る辺の数
      |            ^~~
a.cc:51:12: error: expected primary-expression before 'int'
   51 |     vector<int> A(M), B(M);
      |            ^~~
a.cc:52:9: error: 'i' was not declared in this scope
   52 |     REP(i, M) {
      |         ^
a.cc:52:5: error: 'REP' was not declared in this scope
   52 |     REP(i, M) {
      |     ^~~
a.cc:59:12: error: expected primary-expression before 'int'
   59 |     vector<int> C(K), D(K);
      |            ^~~
a.cc:65:12: error: expected primary-expression before 'int'
   65 |     vector<int> ans(N);
      |            ^~~
a.cc:74:17: error: 'ans' was not declared in this scope
   74 |     REP(i, (int)ans.size()) {
      |                 ^~~
a.cc:78:5: error: 'cout' was not declared in this scope
   78 |     cout << endl;
      |     ^~~~
a.cc:78:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:78:13: error: 'endl' was not declared in this scope
   78 |     cout << endl;
      |             ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;