Language: C++

#include<iostream>
#include<vector>

using namespace std;
typedef long long ll;

class DisjoitSet{
    public:
        vector<ll> rank, p,size;
        DisjoitSet(){}
        DisjoitSet(int n){
            rank.resize(n, 0);
            p.resize(n, 0);
            size.resize(n, 0);
            for (int i = 0; i < n; i++)
            {
                makeSet(i);
            }
        }
        void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
        size[x] = 1;
        }

        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }

        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }

        void link(int x, int y){
            if (rank[x] > rank[y]){
                p[y] = x;
                size[x] += size[y];
            }
            else
            {
                p[x] = y;
                size[y] += size[x];
                if (rank[x] == rank[y])
                {
                    rank[y]++;
                }
            }
        }
        int sized(int x)
        {
           int p = findSet(x);
           return size[p];
        }
        int findSet(int x){
            if (x != p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main(){
    int n, m;
    cin >> n >> m;
    DisjoitSet ds = DisjoitSet(n + 1);
    vector<pair<ll, ll>> v;
    for (int i = 1; i < m+1; i++)
    {
        int a, b;
        cin >> a >> b;
        v[i] = make_pair(a, b);
    }
    vector<ll> ans(m+1, 0);
    ans[m] = n * (n - 1) / 2;
    for (int i = m-1; i > -1 ; i--)
    {
        int a = v[i+1].first;
        int b = v[i+1].second;
        if(!ds.same(a,b))
        {
            ans[i] = ans[i + 1] - ds.sized(a) * ds.sized(b);
        }
        else
        {
            ans[i] = ans[i + 1];
        }
        ds.unite(a, b);
    }
    for (int i = 1; i < m+1; i++)
    {
        cout << ans[i] << endl;
    }

    return 0;
}#include<iostream>
#include<vector>

using namespace std;
typedef long long ll;

class DisjoitSet{
    public:
        vector<ll> rank, p,size;
        DisjoitSet(){}
        DisjoitSet(int n){
            rank.resize(n, 0);
            p.resize(n, 0);
            size.resize(n, 0);
            for (int i = 0; i < n; i++)
            {
                makeSet(i);
            }
        }
        void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
        size[x] = 1;
        }

        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }

        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }

        void link(int x, int y){
            if (rank[x] > rank[y]){
                p[y] = x;
                size[x] += size[y];
            }
            else
            {
                p[x] = y;
                size[y] += size[x];
                if (rank[x] == rank[y])
                {
                    rank[y]++;
                }
            }
        }
        int sized(int x)
        {
           int p = findSet(x);
           return size[p];
        }
        int findSet(int x){
            if (x != p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main(){
    int n, m;
    cin >> n >> m;
    DisjoitSet ds = DisjoitSet(n + 1);
    vector<pair<ll, ll>> v;
    for (int i = 1; i < m+1; i++)
    {
        int a, b;
        cin >> a >> b;
        v[i] = make_pair(a, b);
    }
    vector<ll> ans(m+1, 0);
    ans[m] = n * (n - 1) / 2;
    for (int i = m-1; i > -1 ; i--)
    {
        int a = v[i+1].first;
        int b = v[i+1].second;
        if(!ds.same(a,b))
        {
            ans[i] = ans[i + 1] - ds.sized(a) * ds.sized(b);
        }
        else
        {
            ans[i] = ans[i + 1];
        }
        ds.unite(a, b);
    }
    for (int i = 1; i < m+1; i++)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

Compiler output:
a.cc:95:2: error: stray '#' in program
   95 | }#include<iostream>
      |  ^
a.cc:95:3: error: 'include' does not name a type
   95 | }#include<iostream>
      |   ^~~~~~~
a.cc:101:7: error: redefinition of 'class DisjoitSet'
  101 | class DisjoitSet{
      |       ^~~~~~~~~~
a.cc:7:7: note: previous definition of 'class DisjoitSet'
    7 | class DisjoitSet{
      |       ^~~~~~~~~~
a.cc:156:5: error: redefinition of 'int main()'
  156 | int main(){
      |     ^~~~
a.cc:62:5: note: 'int main()' previously defined here
   62 | int main(){
      |     ^~~~