Language: C++

#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define int long long;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

class union_find {
private:
    vector<int> par;
    vector<int> ran;
    vector<ll> size;
public:
    union_find(int n);
    int find(int x);
    void unite(int x, int y);
    bool same(int x, int y);
    ll show_size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    ran.resize(n);
    size.resize(n);
    REP(i,n) par[i] = i;
    REP(i,n) ran[i] = 0;
    REP(i,n) size[i] = 1;
};

int union_find::find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    ll t = show_size(x)+show_size(y);
    size[x] = size[y] = t;
    if (ran[x] < ran[y]) {
        par[x] = y;
        //size[y] += size[x];
    } else {
        par[y] = x;
        //ize[x] += size[y];
        if (ran[x]==ran[y]) ran[x]++;
    }
};

ll union_find::show_size(int x) {
    if (par[x] == x) return size[x];
    return show_size(par[x] = find(par[x]));
}

bool union_find::same(int x, int y) {
    return (find(x) == find(y));
};

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> b(m);
    REP(i,m) {
        int A, B;
        cin >> A >> B;
        a[i] = --A; b[i] = --B;
    }
    vector<ll> ans(m);
    union_find uf(n);
    ll fai = n*(n-1)/2;
    ans[m-1] = 0;
    for (int i = m-2; i >= 0; --i) {
        if(!uf.same(a[i+1], b[i+1])) {
            ans[i] = ans[i+1]+(uf.show_size(a[i+1])*uf.show_size(b[i+1]));
            uf.unite(a[i+1], b[i+1]);
        }
        else ans[i] = ans[i+1];
    }
    REP(i,m) cout << fai-ans[i] << endl;
    return 0;
}

Compiler output:
a.cc:5:18: error: template argument 1 is invalid
    5 | #define int long long;
      |                  ^~~~
a.cc:16:12: note: in expansion of macro 'int'
   16 |     vector<int> par;
      |            ^~~
a.cc:5:18: error: template argument 2 is invalid
    5 | #define int long long;
      |                  ^~~~
a.cc:16:12: note: in expansion of macro 'int'
   16 |     vector<int> par;
      |            ^~~
a.cc:16:15: error: expected unqualified-id before '>' token
   16 |     vector<int> par;
      |               ^
a.cc:5:18: error: template argument 1 is invalid
    5 | #define int long long;
      |                  ^~~~
a.cc:17:12: note: in expansion of macro 'int'
   17 |     vector<int> ran;
      |            ^~~
a.cc:5:18: error: template argument 2 is invalid
    5 | #define int long long;
      |                  ^~~~
a.cc:17:12: note: in expansion of macro 'int'
   17 |     vector<int> ran;
      |            ^~~
a.cc:17:15: error: expected unqualified-id before '>' token
   17 |     vector<int> ran;
      |               ^
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:20:16: note: in expansion of macro 'int'
   20 |     union_find(int n);
      |                ^~~
a.cc:20:15: note: to match this '('
   20 |     union_find(int n);
      |               ^
a.cc:20:20: error: 'n' does not name a type
   20 |     union_find(int n);
      |                    ^
a.cc:5:18: error: declaration does not declare anything [-fpermissive]
    5 | #define int long long;
      |                  ^~~~
a.cc:21:5: note: in expansion of macro 'int'
   21 |     int find(int x);
      |     ^~~
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:21:14: note: in expansion of macro 'int'
   21 |     int find(int x);
      |              ^~~
a.cc:21:13: note: to match this '('
   21 |     int find(int x);
      |             ^
a.cc:21:9: error: ISO C++ forbids declaration of 'find' with no type [-fpermissive]
   21 |     int find(int x);
      |         ^~~~
a.cc:21:18: error: 'x' does not name a type
   21 |     int find(int x);
      |                  ^
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:22:16: note: in expansion of macro 'int'
   22 |     void unite(int x, int y);
      |                ^~~
a.cc:22:15: note: to match this '('
   22 |     void unite(int x, int y);
      |               ^
a.cc:22:20: error: 'x' does not name a type
   22 |     void unite(int x, int y);
      |                    ^
a.cc:22:27: error: 'y' does not name a type
   22 |     void unite(int x, int y);
      |                           ^
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:23:15: note: in expansion of macro 'int'
   23 |     bool same(int x, int y);
      |               ^~~
a.cc:23:14: note: to match this '('
   23 |     bool same(int x, int y);
      |              ^
a.cc:23:19: error: 'x' does not name a type
   23 |     bool same(int x, int y);
      |                   ^
a.cc:23:26: error: 'y' does not name a type
   23 |     bool same(int x, int y);
      |                          ^
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:24:18: note: in expansion of macro 'int'
   24 |     ll show_size(int x);
      |                  ^~~
a.cc:24:17: note: to match this '('
   24 |     ll show_size(int x);
      |                 ^
a.cc:24:22: error: 'x' does not name a type
   24 |     ll show_size(int x);
      |                      ^
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:27:24: note: in expansion of macro 'int'
   27 | union_find::union_find(int n){
      |                        ^~~
a.cc:27:23: note: to match this '('
   27 | union_find::union_find(int n){
      |                       ^
a.cc:27:1: error: declaration of 'union_find::union_find(long long int)' outside of class is not definition [-fpermissive]
   27 | union_find::union_find(int n){
      | ^~~~~~~~~~
a.cc:27:28: error: 'n' does not name a type
   27 | union_find::union_find(int n){
      |                            ^
a.cc:5:18: error: declaration does not declare anything [-fpermissive]
    5 | #define int long long;
      |                  ^~~~
a.cc:36:1: note: in expansion of macro 'int'
   36 | int union_find::find(int x) {
      | ^~~
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:36:22: note: in expansion of macro 'int'
   36 | int union_find::find(int x) {
      |                      ^~~
a.cc:36:21: note: to match this '('
   36 | int union_find::find(int x) {
      |                     ^
a.cc:5:22: error: expected constructor, destructor, or type conversion before ';' token
    5 | #define int long long;
      |                      ^
a.cc:36:22: note: in expansion of macro 'int'
   36 | int union_find::find(int x) {
      |                      ^~~
a.cc:36:26: error: 'x' does not name a type
   36 | int union_find::find(int x) {
      |                          ^
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:41:24: note: in expansion of macro 'int'
   41 | void union_find::unite(int x, int y) {
      |                        ^~~
a.cc:41:23: note: to match this '('
   41 | void union_find::unite(int x, int y) {
      |                       ^
a.cc:41:6: error: declaration of 'void union_find::unite(long long int)' outside of class is not definition [-fpermissive]
   41 | void union_find::unite(int x, int y) {
      |      ^~~~~~~~~~
a.cc:41:28: error: 'x' does not name a type
   41 | void union_find::unite(int x, int y) {
      |                            ^
a.cc:41:35: error: 'y' does not name a type
   41 | void union_find::unite(int x, int y) {
      |                                   ^
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:57:26: note: in expansion of macro 'int'
   57 | ll union_find::show_size(int x) {
      |                          ^~~
a.cc:57:25: note: to match this '('
   57 | ll union_find::show_size(int x) {
      |                         ^
a.cc:57:4: error: declaration of 'll union_find::show_size(long long int)' outside of class is not definition [-fpermissive]
   57 | ll union_find::show_size(int x) {
      |    ^~~~~~~~~~
a.cc:57:30: error: 'x' does not name a type
   57 | ll union_find::show_size(int x) {
      |                              ^
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:62:23: note: in expansion of macro 'int'
   62 | bool union_find::same(int x, int y) {
      |                       ^~~
a.cc:62:22: note: to match this '('
   62 | bool union_find::same(int x, int y) {
      |                      ^
a.cc:62:6: error: declaration of 'bool union_find::same(long long int)' outside of class is not definition [-fpermissive]
   62 | bool union_find::same(int x, int y) {
      |      ^~~~~~~~~~
a.cc:62:27: error: 'x' does not name a type
   62 | bool union_find::same(int x, int y) {
      |                           ^
a.cc:62:34: error: 'y' does not name a type
   62 | bool union_find::same(int x, int y) {
      |                                  ^
a.cc:5:18: error: declaration does not declare anything [-fpermissive]
    5 | #define int long long;
      |                  ^~~~
a.cc:66:1: note: in expansion of macro 'int'
   66 | int main(int argc, char const *argv[]) {
      | ^~~
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:66:10: note: in expansion of macro 'int'
   66 | int main(int argc, char const *argv[]) {
      |          ^~~
a.cc:66:9: note: to match this '('
   66 | int main(int argc, char const *argv[]) {
      |         ^
a.cc:5:22: error: expected constructor, destructor, or type conversion before ';' token
    5 | #define int long long;
      |                      ^
a.cc:66:10: note: in expansion of macro 'int'
   66 | int main(int argc, char const *argv[]) {
      |          ^~~
a.cc:66:14: error: 'argc' does not name a type
   66 | int main(int argc, char const *argv[]) {
      |              ^~~~