Language: C++

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

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define all(a) (a).begin(),(a).end()
usind ll = long long;
using vi  = vector<int>;
using pii = pair<int,int>;

class UnionFind{
public:
  vi data;

  UnionFind(int size){
    data.resize(size,-1);
    //rep(i, size) data[i] = -1;
  }

  bool unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x != y){
      if(data[y] < data[x]) swap(x,y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }

  bool find(int x, int y){
    return root(x) == root(y);
  }

  int root(int x){ // どの集合か
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }

  int size(int x){
    return -data[root(x)];
  }
};

signed main(){
  int n, m; cin >> n >> m;
  vector<pii> q(m);
  rep(i,m){
    cin >> q[i].first >> q[i].second;
    q[i].first--;
    q[i].second--;
  }
  reverse(all(q));

  vi ans = {n*(n-1)/2};
  int c = 0;
  UnionFind uf(n);
  rep(i,m){
    if(not uf.find(q[i].first,q[i].second)){
      int tmpa = uf.size(q[i].first);
      int tmpb = uf.size(q[i].second);
      uf.unite(q[i].first,q[i].second);
      //c += tmpc*(tmpc-1)/2 - tmpa*(tmpa-1)/2 - tmpb*(tmpb-1)/2;
      c += tmpa * tmpb;
    }
    ans.push_back(ans[0] - c);
  }
  reverse(all(ans));
  FOR(i,1,m+1) cout << ans[i] << endl;
}


Compiler output:
a.cc:8:1: error: 'usind' does not name a type
    8 | usind ll = long long;
      | ^~~~~
a.cc:4:13: error: 'll' was not declared in this scope; did you mean 'all'?
    4 | #define int ll
      |             ^~
a.cc:9:20: note: in expansion of macro 'int'
    9 | using vi  = vector<int>;
      |                    ^~~
a.cc:9:23: error: template argument 1 is invalid
    9 | using vi  = vector<int>;
      |                       ^
a.cc:9:23: error: template argument 2 is invalid
a.cc:4:13: error: 'll' was not declared in this scope; did you mean 'all'?
    4 | #define int ll
      |             ^~
a.cc:10:18: note: in expansion of macro 'int'
   10 | using pii = pair<int,int>;
      |                  ^~~
a.cc:4:13: error: 'll' was not declared in this scope; did you mean 'all'?
    4 | #define int ll
      |             ^~
a.cc:10:22: note: in expansion of macro 'int'
   10 | using pii = pair<int,int>;
      |                      ^~~
a.cc:10:25: error: template argument 1 is invalid
   10 | using pii = pair<int,int>;
      |                         ^
a.cc:10:25: error: template argument 2 is invalid
a.cc:14:3: error: 'vi' does not name a type; did you mean 'void'?
   14 |   vi data;
      |   ^~
      |   void
a.cc:16:17: error: expected ')' before 'size'
   16 |   UnionFind(int size){
      |            ~    ^~~~
a.cc:4:13: error: 'll' has not been declared
    4 | #define int ll
      |             ^~
a.cc:21:14: note: in expansion of macro 'int'
   21 |   bool unite(int x,int y){
      |              ^~~
a.cc:4:13: error: 'll' has not been declared
    4 | #define int ll
      |             ^~
a.cc:21:20: note: in expansion of macro 'int'
   21 |   bool unite(int x,int y){
      |                    ^~~
a.cc:4:13: error: 'll' has not been declared
    4 | #define int ll
      |             ^~
a.cc:32:13: note: in expansion of macro 'int'
   32 |   bool find(int x, int y){
      |             ^~~
a.cc:4:13: error: 'll' has not been declared
    4 | #define int ll
      |             ^~
a.cc:32:20: note: in expansion of macro 'int'
   32 |   bool find(int x, int y){
      |                    ^~~
a.cc:4:13: error: 'll' does not name a type; did you mean 'all'?
    4 | #define int ll
      |             ^~
a.cc:36:3: note: in expansion of macro 'int'
   36 |   int root(int x){ // どの集合か
      |   ^~~
a.cc:4:13: error: 'll' does not name a type; did you mean 'all'?
    4 | #define int ll
      |             ^~
a.cc:40:3: note: in expansion of macro 'int'
   40 |   int size(int x){
      |   ^~~
a.cc: In member function 'bool UnionFind::unite(int, int)':
a.cc:22:9: error: 'root' was not declared in this scope
   22 |     x = root(x);
      |         ^~~~
a.cc:25:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   25 |       if(data[y] < data[x]) swap(x,y);
      |              ^
a.cc:25:24: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   25 |       if(data[y] < data[x]) swap(x,y);
      |                        ^
a.cc:26:11: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   26 |       data[x] += data[y];
      |           ^
a.cc:26:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   26 |       data[x] += data[y];
      |                      ^
a.cc:27:11: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   27 |       data[y] = x;
      |           ^
a.cc: In member function 'bool UnionFind::find(int, int)':
a.cc:33:12: error: 'root' was not declared in this scope
   33 |     return root(x) == root(y);
      |            ^~~~
a.cc: In function 'int main()':
a.cc:4:13: error: 'll' was not declared in this scope; did you mean 'all'?
    4 | #define int ll
      |             ^~
a.cc:46:3: note: in expansion of macro 'int'
   46 |   int n, m; cin >> n >> m;
      |   ^~~
a.cc:46:20: error: 'n' was not declared in this scope; did you mean 'yn'?
   46 |   int n, m; cin >> n >> m;
      |                    ^
      |                    yn
a.cc:46:25: error: 'm' was not declared in this scope; did you mean 'tm'?
   46 |   int n, m; cin >> n >> m;
      |                         ^
      |                         tm
a.cc:47:10: error: 'pii' was not declared in this scope
   47 |   vector<pii> q(m);
      |          ^~~
a.cc:47:13: error: template argument 1 is invalid
   47 |   vector<pii> q(m);
      |             ^
a.cc:47:13: error: template argument 2 is invalid
a.cc:48:7: error: expected ';' before 'i'
   48 |   rep(i,m){
      |       ^
a.cc:5:26: note: in definition of macro 'rep'
    5 | #define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
      |                          ^
a.cc:48:7: error: 'i' was not declared in this scope
   48 |   rep(i,m){
      |       ^
a.cc:5:43: note: in definition of macro 'rep'
    5 | #define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
      |                                           ^
a.cc:48:7: error: 'i_cond' was not declared in this scope
   48 |   rep(i,m){
      |       ^
a.cc:5:45: note: in definition of macro 'rep'
    5 | #define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
      |                                             ^
a.cc:7:20: error: request for member 'begin' in 'q', which is of non-class type 'int'
    7 | #define all(a) (a).begin(),(a).end()
      |                    ^~~~~
a.cc:53:11: note: in expansion of macro 'all'
   53 |   reverse(all(q));
      |           ^~~
a.cc:7:32: error: request for member 'end' in 'q', which is of non-class type 'int'
    7 | #define all(a) (a).begin(),(a).end()
      |                                ^~~
a.cc:53:11: note: in expansion of macro 'all'
   53 |   reverse(all(q));
      |           ^~~
a.cc:55:3: error: 'vi' was not declared in this scope
   55 |   vi ans = {n*(n-1)/2};
      |   ^~
a.cc:56:7: error: expected ';' before 'c'
   56 |   int c = 0;
      |       ^
a.cc:58:7: error: expected ';' before 'i'
   58 |   rep(i,m){
      |       ^
a.cc:5:26: note: in definition of macro 'rep'
    5 | #define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
      |                          ^
a.cc:58:7: error: 'i' was not declared in this scope
   58 |   rep(i,m){
      |       ^
a.cc:5:43: note: in definition of macro 'rep'
    5 | #define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
      |                                           ^
a.cc:58:7: error: 'i_cond' was not declared in this scope
   58 |   rep(i,m){
      |       ^
a.cc:5:45: note: in definition of macro 'rep'
    5 | #define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
      |                                             ^
a.cc:60:11: error: expected ';' before 'tmpa'
   60 |       int tmpa = uf.size(q[i].first);
      |           ^~~~
a.cc:61:11: error: expected ';' before 'tmpb'
   61 |       int tmpb = uf.size(q[i].second);
      |           ^~~~
a.cc:64:7: error: 'c' was not declared in this scope
   64 |       c += tmpa * tmpb;
      |       ^
a.cc:64:12: error: 'tmpa' was not declared in this scope; did you mean 'tmpnam'?
   64 |       c += tmpa * tmpb;
      |            ^~~~
      |            tmpnam
a.cc:64:19: error: 'tmpb' was not declared in this scope; did you mean 'tm'?
   64 |       c += tmpa * tmpb;
      |                   ^~~~
      |                   tm
a.cc:66:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   66 |     ans.push_back(ans[0] - c);
      |     ^~~
      |     abs
a.cc:66:28: error: 'c' was not declared in this scope
   66 |     ans.push_back(ans[0] - c);
      |                            ^
a.cc:68:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   68 |   reverse(all(ans));
      |               ^~~
a.cc:7:17: note: in definition of macro 'all'
    7 | #define all(a) (a).begin(),(a).end()
      |                 ^
a.cc:69:7: error: expected ';' before 'i'
   69 |   FOR(i,1,m+1) cout << ans[i] << endl;
      |       ^
a.cc:6:28: note: in definition of macro 'FOR'
    6 | #define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
      |                            ^
a.cc:69:7: error: 'i' was not declared in this scope
   69 |   FOR(i,1,m+1) cout << ans[i] << endl;
      |       ^
a.cc:6:47: note: in definition of macro 'FOR'
    6 | #define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
      |                                               ^
a.cc:69:7: error: 'i_cond' was not declared in this scope
   69 |   FOR(i,1,m+1) cout << ans[i] << endl;
      |       ^
a.cc:6:49: note: in definition of macro 'FOR'
    6 | #define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
      |                                                 ^