criyle/codenet-compile-errors huggingface dataset:
Language: C

#include<stdio.h>
#define MAX 100000

int visit[MAX] = {0};
int graph[MAX][MAX] = {0};
int n, m, route;

void search(int lavel, int goal) {
  visit[lavel] = 1;
  if ( lavel == goal ) {
    route = 1;
  }
  else {
    int to;
    for ( to = 0; to < n; to++ ) {
      if ( !visit[to] && graph[lavel][to] ) {
        search(to, goal);
      }
    }
  }
}

int main(void) {
  int path[MAX][MAX];
  int a, b;
  int i, j, k, l;
  int ct;
  scanf("%d %d", &n, &m);
  for ( i = 0; i < m; i++ ) {
    scanf("%d %d", &a, &b);
    path[i][0] = a-1;
    path[i][1] = b-1;
    graph[a-1][b-1] = graph[b-1][a-1] = 1;
  }
  for ( i = 0; i < m; i++ ) {
    ct = 0;
    graph[path[i][0]][path[i][1]] = 0;
    graph[path[i][1]][path[i][0]] = 0;
    for ( j = n-1; j >= 0; j-- ) {
      for ( k = 0; k < j; k++ ) {
        for ( l = 0; l < n; l++ ) {
          visit[l] = 0;
        }
        route = 0;
        search(k, j);
        if ( !route ) {
          ct += 1;
        }
      }
    }
    printf("%d\n", ct);
  }
  
  return 0;
}

Compiler output:
/tmp/cc8sx1u7.o: in function `search':
main.c:(.text+0x33): relocation truncated to fit: R_X86_64_PC32 against symbol `route' defined in .bss section in /tmp/cc8sx1u7.o
main.c:(.text+0xa1): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8sx1u7.o
/tmp/cc8sx1u7.o: in function `main':
main.c:(.text+0xc1): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc8sx1u7.o
main.c:(.text+0xcb): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8sx1u7.o
main.c:(.text+0x244): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc8sx1u7.o
main.c:(.text+0x338): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8sx1u7.o
main.c:(.text+0x377): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8sx1u7.o
main.c:(.text+0x382): relocation truncated to fit: R_X86_64_PC32 against symbol `route' defined in .bss section in /tmp/cc8sx1u7.o
main.c:(.text+0x39b): relocation truncated to fit: R_X86_64_PC32 against symbol `route' defined in .bss section in /tmp/cc8sx1u7.o
main.c:(.text+0x3dc): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc8sx1u7.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long int
using namespace std;

ll N,M; 
 int flag[100009]; // 頂点に到達したかどうか
int edge[100009][100009] ; // 辺の情報
int a[100009];
int b[100009];
set <int> ga;
set <int> gb;



// 深さ優先探索
void dfs(int vertex,int ab){
    int i;
    
    // 既に到達済みの場合
    if(flag[vertex]) return;
    
    // 到達済みとして保存
    flag[vertex] = 1;
    if(ab==0) ga.insert(vertex);
    else gb.insert(vertex);
    
    // 頂点 vertex と辺がある頂点へ訪問
    for(i = 0; i <= N; ++i){
        if(edge[vertex][i]){ // 頂点 vertex から i へ辺がある
            dfs(i,ab); // 頂点 i へ移動
        }
    }
}



int main(){
  cin>>N>>M;

for(int i=0;i<N;i++){
  for(int j=0;j<N;j++){
    edge[i][j] = 0;
  }
}
 

for(int i=0;i<M;i++){
  cin>>a[i]>>b[i];
  edge[a[i]][b[i]] = 1;
  edge[b[i]][a[i]] = 1;
}

ll ans =0;

for(int i=0;i<M;i++){

   // 初期化
    for(int j = 0; j <= N; ++j){
        flag[j] = 0;
    }

    edge[a[i]][b[i]]=0;
    edge [b[i]][a[i]] = 0;



    dfs(a[i],0);
    dfs(b[i],1);

    if(ga != gb){
     // cout<<1<<endl;
      ans += ga.size() * gb.size();
    }

    ga.clear();
    gb.clear();
    
    cout<<ans<<endl;


}

return 0;

}
 

Compiler output:
/tmp/ccTF2Dhz.o: in function `dfs(int, int)':
a.cc:(.text+0x58): relocation truncated to fit: R_X86_64_PC32 against symbol `ga' defined in .bss section in /tmp/ccTF2Dhz.o
a.cc:(.text+0x70): relocation truncated to fit: R_X86_64_PC32 against symbol `gb' defined in .bss section in /tmp/ccTF2Dhz.o
/tmp/ccTF2Dhz.o: in function `main':
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccTF2Dhz.o
a.cc:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccTF2Dhz.o
a.cc:(.text+0x1e4): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccTF2Dhz.o
a.cc:(.text+0x1fb): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccTF2Dhz.o
a.cc:(.text+0x237): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccTF2Dhz.o
a.cc:(.text+0x24e): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccTF2Dhz.o
a.cc:(.text+0x2f2): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccTF2Dhz.o
a.cc:(.text+0x309): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccTF2Dhz.o
a.cc:(.text+0x345): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long int
using namespace std;

ll N,M; 
 int flag[1000090]; // 頂点に到達したかどうか
int edge[100009][100009] ; // 辺の情報
int a[100009];
int b[100009];
set <int> ga;
set <int> gb;



// 深さ優先探索
void dfs(int vertex,int ab){
    int i;
    
    // 既に到達済みの場合
    if(flag[vertex]) return;
    
    // 到達済みとして保存
    flag[vertex] = 1;
    if(ab==0) ga.insert(vertex);
    else gb.insert(vertex);
    
    // 頂点 vertex と辺がある頂点へ訪問
    for(i = 0; i <= N; ++i){
        if(edge[vertex][i]){ // 頂点 vertex から i へ辺がある
            dfs(i,ab); // 頂点 i へ移動
        }
    }
}



int main(){
  cin>>N>>M;

for(int i=0;i<N;i++){
  for(int j=0;j<N;j++){
    edge[i][j] = 0;
  }
}
 

for(int i=0;i<M;i++){
  cin>>a[i]>>b[i];
  edge[a[i]][b[i]] = 1;
  edge[b[i]][a[i]] = 1;
}

ll ans =0;

for(int i=0;i<M;i++){

   // 初期化
    for(int j = 0; j <= N; ++j){
        flag[j] = 0;
    }

    edge[a[i]][b[i]]=0;
    edge [b[i]][a[i]] = 0;



    dfs(a[i],0);
    dfs(b[i],1);

    if(ga != gb){
     // cout<<1<<endl;
      ans += ga.size() * gb.size();
    }

    ga.clear();
    gb.clear();
    
    cout<<ans<<endl;


}

return 0;

}
 

Compiler output:
/tmp/ccIJXWcd.o: in function `dfs(int, int)':
a.cc:(.text+0x58): relocation truncated to fit: R_X86_64_PC32 against symbol `ga' defined in .bss section in /tmp/ccIJXWcd.o
a.cc:(.text+0x70): relocation truncated to fit: R_X86_64_PC32 against symbol `gb' defined in .bss section in /tmp/ccIJXWcd.o
/tmp/ccIJXWcd.o: in function `main':
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccIJXWcd.o
a.cc:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccIJXWcd.o
a.cc:(.text+0x1e4): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccIJXWcd.o
a.cc:(.text+0x1fb): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccIJXWcd.o
a.cc:(.text+0x237): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccIJXWcd.o
a.cc:(.text+0x24e): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccIJXWcd.o
a.cc:(.text+0x2f2): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccIJXWcd.o
a.cc:(.text+0x309): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccIJXWcd.o
a.cc:(.text+0x345): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<string>
#include<sstream>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>
#include<map>

using namespace std;

int N,M;
int connect[100000][100000];
bool use[100000];
bool judge;

void hukasa(int y,int now)
{	
	use[now] = 1;
	if(now==y)
	{
		judge = 1;
		use[now] = 0;
		return ;
	}
	for(int i=0;i<N;i++)
	{
		if(connect[now][i]==1 && use[i]==0)
		{
			hukasa(y,i);
		}
	}
	use[now] = 0;
	return ;

}




int main()
{
	cin >> N >> M;
	int result[M];
	for(int i=0;i<M;i++)
	{
		
		int cnt = 0;
		int aa,bb;
		cin >> aa >> bb;
		connect[aa-1][bb-1] = 1;
		connect[bb-1][aa-1] = 1;
		for(int p=0;p<N;p++)
		{
			for(int q=p+1;q<N;q++)
			{
				judge = 0;
				hukasa(p,q);
				if(judge==0)
				{
					cnt = cnt + 1;
				}
			}
		}
		result[i] = cnt;
	}
	result[M-1] = result[M-2]+1;
	for(int i=0;i<M;i++)
	{
		
		cout << result[M-i-1] << endl;
	}

}

Compiler output:
/tmp/ccOz7fd1.o: in function `hukasa(int, int)':
a.cc:(.text+0x16): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccOz7fd1.o
a.cc:(.text+0x28): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccOz7fd1.o
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccOz7fd1.o
a.cc:(.text+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccOz7fd1.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccOz7fd1.o
/tmp/ccOz7fd1.o: in function `main':
a.cc:(.text+0x1fa): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccOz7fd1.o
a.cc:(.text+0x211): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccOz7fd1.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long int
using namespace std;

ll N,M; 
 int flag[1000090]; // 頂点に到達したかどうか
int edge[100009][100009] ; // 辺の情報
int a[100009];
int b[100009];
set <int> ga;
set <int> gb;



// 深さ優先探索
void dfs(int vertex,int ab){
    int i;
    
    // 既に到達済みの場合
    if(flag[vertex]) return;
    
    // 到達済みとして保存
    flag[vertex] = 1;
    if(ab==0) ga.insert(vertex);
    else gb.insert(vertex);
    
    // 頂点 vertex と辺がある頂点へ訪問
    for(i = 0; i <= N; ++i){
        if(edge[vertex][i]){ // 頂点 vertex から i へ辺がある
            dfs(i,ab); // 頂点 i へ移動
        }
    }
}



int main(){
  cin>>N>>M;

for(int i=0;i<N;i++){
  for(int j=0;j<N;j++){
    edge[i][j] = 0;
  }
}
 

for(int i=0;i<M;i++){
  cin>>a[i]>>b[i];
  edge[a[i]][b[i]] = 1;
  edge[b[i]][a[i]] = 1;
}

ll ans =0;

for(int i=0;i<M;i++){

   // 初期化
    for(int j = 0; j <= N; ++j){
        flag[j] = 0;
    }

    edge[a[i]][b[i]]=0;
    edge [b[i]][a[i]] = 0;



    dfs(a[i],0);
    dfs(b[i],1);

    if(ga != gb){
     // cout<<1<<endl;
      ans += ga.size() * gb.size();
    }

    ga.clear();
    gb.clear();
    
    cout<<ans<<endl;


}

return 0;

}
 

Compiler output:
/tmp/ccbiTLS8.o: in function `dfs(int, int)':
a.cc:(.text+0x58): relocation truncated to fit: R_X86_64_PC32 against symbol `ga' defined in .bss section in /tmp/ccbiTLS8.o
a.cc:(.text+0x70): relocation truncated to fit: R_X86_64_PC32 against symbol `gb' defined in .bss section in /tmp/ccbiTLS8.o
/tmp/ccbiTLS8.o: in function `main':
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccbiTLS8.o
a.cc:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccbiTLS8.o
a.cc:(.text+0x1e4): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccbiTLS8.o
a.cc:(.text+0x1fb): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccbiTLS8.o
a.cc:(.text+0x237): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccbiTLS8.o
a.cc:(.text+0x24e): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccbiTLS8.o
a.cc:(.text+0x2f2): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccbiTLS8.o
a.cc:(.text+0x309): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccbiTLS8.o
a.cc:(.text+0x345): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
using namespace std;
using ll = long long;

int p[100001];          // parent node
int a[100001];
ll count;

int f(int x) {          // find root
    if(p[x] == x )
        return p[x]; 
    else{
       return f(p[x]);
    }
}
 
void u(int x, int y) {  // unite
    ll a = num[f(x)] + num[f(y)];
    ll b = num[f(x)];
    ll c = num[f(x)];
    
    count +=(a-1)*1/2;
    count -= b*(b-1)/2;
    count -= c*(c-1)/2;
    num[f(x)] += num[f(y)];
    p[f(x)] = f(y);
}

int main()
{
    ll n,m;
    cin >> n >> m;
    ll comb = n*(n-1)/2;
    vector<ll> v;
    ll a[m] = {};
    ll b[m] = {};
    for(int i=0; i<n; i++){
        p[i] = i;
        num[i] = 1;
    }
    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];
    }
    for(int i=m-1; i>=0; i--){
        v.push_back(comb - count);
        u(a[i], b[i]);
    }

    for(int i=m-1; i>=0; i--){
        cout << v[i] << endl;
    }
        
    return 0;
}


Compiler output:
a.cc: In function 'void u(int, int)':
a.cc:18:12: error: 'num' was not declared in this scope; did you mean 'enum'?
   18 |     ll a = num[f(x)] + num[f(y)];
      |            ^~~
      |            enum
a.cc: In function 'int main()':
a.cc:34:5: error: 'vector' was not declared in this scope
   34 |     vector<ll> v;
      |     ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:34:14: error: expected primary-expression before '>' token
   34 |     vector<ll> v;
      |              ^
a.cc:34:16: error: 'v' was not declared in this scope
   34 |     vector<ll> v;
      |                ^
a.cc:39:9: error: 'num' was not declared in this scope; did you mean 'enum'?
   39 |         num[i] = 1;
      |         ^~~
      |         enum
Language: C++

#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <functional>
#include <string>
#include <sstream>

#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define rep(i,n) for (int i=0; i < int(n); i++)
// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int x[M], y[M];
    
    for (int i = 0; i < M; i++){
        cin >> x[i] >> y[i];
    }
        UnionFind tree(N);
        int num =0;
        ll ans[M] = 0;
    for (int i = M-1; i >= 0; i--){
        ll ans = 0;
        for(int j = M-1; j >=0; j--){
            if(i<j){
                tree.unite(x[j]-1, y[j]-1);
            }
        }
        for(int j = 0; j < N; j++){
            for(int k = j+1; k < N; k++){
                if(tree.same(j, k)){

                }else{
                    ans++;
                }
            }
        }
        ans[num] = ans;
        num++;
    }
    for(int i = 0; i < M; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:21: error: array must be initialized with a brace-enclosed initializer
   80 |         ll ans[M] = 0;
      |                     ^
a.cc:97:12: error: invalid types 'll {aka long long int}[int]' for array subscript
   97 |         ans[num] = ans;
      |            ^
Language: C++

#include<string>
#include<sstream>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>
#include<map>

using namespace std;

int N,M;
int connect[100000][100000];
bool use[100000];
bool judge;

void hukasa(int y,int now)
{	
	use[now] = 1;
	if(now==y)
	{
		judge = 1;
		use[now] = 0;
		return ;
	}
	for(int i=0;i<N;i++)
	{
		if(connect[now][i]==1 && use[i]==0)
		{
			hukasa(y,i);
		}
	}
	use[now] = 0;
	return ;

}




int main()
{
	cin >> N >> M;
	int result[M];
	for(int i=0;i<M;i++)
	{
		
		int cnt = 0;
		int aa,bb;
		cin >> aa >> bb;
		connect[aa-1][bb-1] = 1;
		connect[bb-1][aa-1] = 1;
		for(int p=0;p<N;p++)
		{
			for(int q=p+1;q<N;q++)
			{
				judge = 0;
				hukasa(p,q);
				if(judge==0)
				{
					cnt = cnt + 1;
				}
			}
		}
		result[i] = cnt;
	}
	result[M-1] = result[M-2]+1;
	for(int i=0;i<M;i++)
	{
		
		cout << result[M-i-1] << endl;
	}

}




Compiler output:
/tmp/ccXW3rgn.o: in function `hukasa(int, int)':
a.cc:(.text+0x16): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccXW3rgn.o
a.cc:(.text+0x28): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccXW3rgn.o
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccXW3rgn.o
a.cc:(.text+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccXW3rgn.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccXW3rgn.o
/tmp/ccXW3rgn.o: in function `main':
a.cc:(.text+0x1fa): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccXW3rgn.o
a.cc:(.text+0x211): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccXW3rgn.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long int
using namespace std;

ll N,M; 
 int flag[1000090]; // 頂点に到達したかどうか
int edge[100009][100009] ; // 辺の情報
int a[100009];
int b[100009];
set <int> ga;
set <int> gb;



// 深さ優先探索
void dfs(int vertex,int ab){
    int i;
    
    // 既に到達済みの場合
    if(flag[vertex]) return;
    
    // 到達済みとして保存
    flag[vertex] = 1;
    if(ab==0) ga.insert(vertex);
    else gb.insert(vertex);
    
    // 頂点 vertex と辺がある頂点へ訪問
    for(i = 0; i <= N; ++i){
        if(edge[vertex][i]){ // 頂点 vertex から i へ辺がある
            dfs(i,ab); // 頂点 i へ移動
        }
    }
}



int main(){
  cin>>N>>M;

for(int i=0;i<N;i++){
  for(int j=0;j<N;j++){
    edge[i][j] = 0;
  }
}
 

for(int i=0;i<M;i++){
  cin>>a[i]>>b[i];
  edge[a[i]][b[i]] = 1;
  edge[b[i]][a[i]] = 1;
}

ll ans =0;

for(int i=0;i<M;i++){

   // 初期化
    for(int j = 0; j <= N; ++j){
        flag[j] = 0;
    }

    edge[a[i]][b[i]]=0;
    edge [b[i]][a[i]] = 0;



    dfs(a[i],0);
    dfs(b[i],1);

    if(ga != gb){
     // cout<<1<<endl;
      ans += ga.size() * gb.size();
    }

    ga.clear();
    gb.clear();
    
    cout<<ans<<endl;


}

return 0;

}
 

Compiler output:
/tmp/ccpGOBYq.o: in function `dfs(int, int)':
a.cc:(.text+0x58): relocation truncated to fit: R_X86_64_PC32 against symbol `ga' defined in .bss section in /tmp/ccpGOBYq.o
a.cc:(.text+0x70): relocation truncated to fit: R_X86_64_PC32 against symbol `gb' defined in .bss section in /tmp/ccpGOBYq.o
/tmp/ccpGOBYq.o: in function `main':
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccpGOBYq.o
a.cc:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccpGOBYq.o
a.cc:(.text+0x1e4): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccpGOBYq.o
a.cc:(.text+0x1fb): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccpGOBYq.o
a.cc:(.text+0x237): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccpGOBYq.o
a.cc:(.text+0x24e): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccpGOBYq.o
a.cc:(.text+0x2f2): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccpGOBYq.o
a.cc:(.text+0x309): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccpGOBYq.o
a.cc:(.text+0x345): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<string>
#include<sstream>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>
#include<map>

using namespace std;

int N,M;
int connect[100000][100000];
bool use[100000];
bool judge;

void hukasa(int y,int now)
{	
	use[now] = 1;
	if(now==y)
	{
		judge = 1;
		use[now] = 0;
		return ;
	}
	for(int i=0;i<N;i++)
	{
		if(connect[now][i]==1 && use[i]==0)
		{
			hukasa(y,i);
		}
	}
	use[now] = 0;
	return ;

}




int main()
{
	cin >> N >> M;
	int result[M];
	for(int i=0;i<M;i++)
	{
		
		int cnt = 0;
		int aa,bb;
		cin >> aa >> bb;
		connect[aa-1][bb-1] = 1;
		connect[bb-1][aa-1] = 1;
		for(int p=0;p<N;p++)
		{
			for(int q=p+1;q<N;q++)
			{
				judge = 0;
				hukasa(p,q);
				if(judge==0)
				{
					cnt = cnt + 1;
				}
			}
		}
		result[i] = cnt;
	}
	result[M-1] = result[M-2]+1;
	for(int i=0;i<M;i++)
	{
		
		cout << result[M-i-1] << endl;
	}

}




Compiler output:
/tmp/ccrBh0Bx.o: in function `hukasa(int, int)':
a.cc:(.text+0x16): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccrBh0Bx.o
a.cc:(.text+0x28): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccrBh0Bx.o
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccrBh0Bx.o
a.cc:(.text+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccrBh0Bx.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccrBh0Bx.o
/tmp/ccrBh0Bx.o: in function `main':
a.cc:(.text+0x1fa): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccrBh0Bx.o
a.cc:(.text+0x211): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccrBh0Bx.o
collect2: error: ld returned 1 exit status
Language: C++

#include<string>
#include<sstream>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>
#include<map>

using namespace std;

int N,M;
int connect[100000][100000];
bool use[100000];
bool judge;

void hukasa(int y,int now)
{	
	use[now] = 1;
	if(now==y)
	{
		judge = 1;
		use[now] = 0;
		return ;
	}
	for(int i=0;i<N;i++)
	{
		if(connect[now][i]==1 && use[i]==0)
		{
			hukasa(y,i);
		}
	}
	use[now] = 0;
	return ;

}




int main()
{
	cin >> N >> M;
	int result[M];
	for(int i=0;i<M;i++)
	{
		
		int cnt = 0;
		int aa,bb;
		cin >> aa >> bb;
		connect[aa-1][bb-1] = 1;
		connect[bb-1][aa-1] = 1;
		for(int p=0;p<N;p++)
		{
			for(int q=p+1;q<N;q++)
			{
				judge = 0;
				hukasa(p,q);
				if(judge==0)
				{
					cnt = cnt + 1;
				}
			}
		}
		result[i] = cnt;
	}
	result[M-1] = result[M-2]+1;
	for(int i=0;i<M;i++)
	{
		
		cout << result[M-i-1] << endl;
	}

}




Compiler output:
/tmp/ccRsitLA.o: in function `hukasa(int, int)':
a.cc:(.text+0x16): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccRsitLA.o
a.cc:(.text+0x28): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccRsitLA.o
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccRsitLA.o
a.cc:(.text+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccRsitLA.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccRsitLA.o
/tmp/ccRsitLA.o: in function `main':
a.cc:(.text+0x1fa): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccRsitLA.o
a.cc:(.text+0x211): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccRsitLA.o
collect2: error: ld returned 1 exit status
Language: C++

#include<string>
#include<sstream>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>
#include<map>

using namespace std;

int N,M;
int connect[100000][100000];
bool use[100000];
bool judge;

void hukasa(int y,int now)
{	
	use[now] = 1;
	if(now==y)
	{
		judge = 1;
		use[now] = 0;
		return ;
	}
	for(int i=0;i<N;i++)
	{
		if(connect[now][i]==1 && use[i]==0)
		{
			hukasa(y,i);
		}
	}
	use[now] = 0;
	return ;

}




int main()
{
	cin >> N >> M;
	int result[M];
	for(int i=0;i<M;i++)
	{
		
		int cnt = 0;
		int aa,bb;
		cin >> aa >> bb;
		connect[aa-1][bb-1] = 1;
		connect[bb-1][aa-1] = 1;
		for(int p=0;p<N;p++)
		{
			for(int q=p+1;q<N;q++)
			{
				judge = 0;
				hukasa(p,q);
				if(judge==0)
				{
					cnt = cnt + 1;
				}
			}
		}
		result[i] = cnt;
	}
	result[M-1] = result[M-2]+1;
	for(int i=0;i<M;i++)
	{
		
		cout << result[M-i-1] << endl;
	}

}




Compiler output:
/tmp/ccLHV4ux.o: in function `hukasa(int, int)':
a.cc:(.text+0x16): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccLHV4ux.o
a.cc:(.text+0x28): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccLHV4ux.o
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccLHV4ux.o
a.cc:(.text+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccLHV4ux.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `use' defined in .bss section in /tmp/ccLHV4ux.o
/tmp/ccLHV4ux.o: in function `main':
a.cc:(.text+0x1fa): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccLHV4ux.o
a.cc:(.text+0x211): relocation truncated to fit: R_X86_64_PC32 against symbol `judge' defined in .bss section in /tmp/ccLHV4ux.o
collect2: error: ld returned 1 exit status
Language: C++

#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <functional>
#include <string>
#include <sstream>

#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define rep(i,n) for (int i=0; i < int(n); i++)
// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int x[M], y[M];
    
    for (int i = 0; i < M; i++){
        cin >> x[i] >> y[i];
    }
        UnionFind tree(N);
        int num =0;
    for (int i = M-1; i >= 0; i--){
        ll ans = 0;
        for(int j = M-1; j >=0; j--){
            if(i<j){
                tree.unite(x[j]-1, y[j]-1);
            }
        }
        for(int j = 0; j < N; j++){
            for(int k = j+1; k < N; k++){
                if(tree.same(j, k)){

                }else{
                    ans++;
                }
            }
        }
        ans[num] = ans;
        num++;
    }
    for(int i = 0; i < M; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:96:12: error: invalid types 'll {aka long long int}[int]' for array subscript
   96 |         ans[num] = ans;
      |            ^
a.cc:100:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
  100 |         cout << ans[i] << endl;
      |                 ^~~
      |                 abs
Language: C++

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

int main(){
  long N, M;
  cin >> N >> M;
  
  long all = M*(M-1)/2;
  
  vector<long> vec1(M);
  vector<long> vec2(M);
  vector<long> count(N);
  vector<long> count2(N);
  
  for(long i=0; i<M; i++){
    cin >> vec1.at(i) >> vec2.at(i);
  }
  
  for(long i=0; i<M; i++){
    if(N <= M-i){
      cout << 0 << endl;
    }
    else{
      for(long l=i; l<M; l++){
        for(long j=0; j<N; j++){
          if(vec1.at(l)==j+1){
            count.at(j)++;
          }
          if(vec2.at(l)==j+1){
            count.at(j)++;
          }
        }
      }
      long ans = 0;
      for(long l=i; l<M; l++){
        long a = vec1.at(l);
        long b = vec2.at(l);
        if(count.at(a-1)==1 && count.at(b-1)==1){
          ans++;
        }
        else{
          count2.at(a-1)++;
          count2.at(b-1)++;
          //やりたかったこと: i番目〜M番目までの橋の両端A,Bを調べてその重複度を配列countに入れる
          //両端とも重複していない(その橋以外が架かっていない)組み合わせの橋なら+1通り
          //それ以外は(橋でいける全範囲の)
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:2: error: expected '}' at end of input
   47 | }
      |  ^
a.cc:35:30: note: to match this '{'
   35 |       for(long l=i; l<M; l++){
      |                              ^
a.cc:47:2: error: expected '}' at end of input
   47 | }
      |  ^
a.cc:23:9: note: to match this '{'
   23 |     else{
      |         ^
a.cc:47:2: error: expected '}' at end of input
   47 | }
      |  ^
a.cc:19:26: note: to match this '{'
   19 |   for(long i=0; i<M; i++){
      |                          ^
a.cc:47:2: error: expected '}' at end of input
   47 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>
#include <set>
using namespace std;
using ll = long long;

int p[100001];          // parent node
int a[100001];
int num[100001];
ll count;

int f(int x) {          // find root
    if(p[x] == x )
        return p[x]; 
    else{
       return f(p[x]);
    }
}
 
void u(int x, int y) {  // unite
    ll a = num[f(x)] + num[f(y)];
    ll b = num[f(x)];
    ll c = num[f(x)];
    
    count +=(a-1)*1/2;
    count -= b*(b-1)/2;
    count -= c*(c-1)/2;
    num[f(x)] += num[f(y)];
    p[f(x)] = f(y);
}

int main()
{
    ll n,m;
    cin >> n >> m;
    ll comb = n*(n-1)/2;
    vector<ll> v;
    ll a[m] = {};
    ll b[m] = {};
    for(int i=0; i<n; i++){
        p[i] = i;
        num[i] = 1;
    }
    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];
    }
    
    vector<set<int>> vs;
    
    for(int i=m-1; i>=0; i--){
        v.push_back(comb - count);
        unite(a[i], b[i]);

    }

    for(int i=m-1; i>=0; i--){
        cout << v[i] << endl;
    }
        
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:9: error: 'unite' was not declared in this scope
   52 |         unite(a[i], b[i]);
      |         ^~~~~
Language: C++

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

int find(int x, vector<int> L) {
	if (L[x] == x) return x;
	else {
		L[x] = find(L[x], L);
		return L[x];
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> Bridge(M, vector<int>(2));
	vector<int> Par(N), Rank(N);
	for (int i = 0; i < M; ++i) {
		cin >> Bridge[i][0] >> Bridge[i][1];
	}
	for (int i = 0; i < N; ++i) {
		Rank[i] = 1;
		Par[i] = i;
	}

	int unite(int x, int y, long long Total) {
		int rx, ry;
		rx = find(x, Par);
		ry = find(y, Par);
		if (rx == ry) return Total;
		Total -= Rank[rx] * Rank[ry];
		Par[ry] = rx;
		Rank[ry] += Rank[rx];
		return Total;
	}

	long long T = N * (N - 1) / 2;
	vector<long long> Ans(M);
	Ans[M - 1] = T;
	for (int i = M - 2; i >= 0; --i) {
		int A, B;
		A = Bridge[i][0];
		B = Bridge[i][1];
		T = unite(A - 1, B - 1, T);
		Ans[i] = T;
	}
	for (int i = 0; i < M; ++i) {
		cout << Ans[i] << endl;
	}

}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:50: error: a function-definition is not allowed here before '{' token
   25 |         int unite(int x, int y, long long Total) {
      |                                                  ^
a.cc:43:21: error: 'unite' was not declared in this scope
   43 |                 T = unite(A - 1, B - 1, T);
      |                     ^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

int main(){
  int n,m;
  std::cin>>n,m;
  std::vector<std::vector<int>> data(m,std::vector<int>(2));
  for(int i = 0; i < m; i++){
    std::cin>>data[i][0]>>data[i][1];
  }

  std::vector<std::vector<bool>> gra(n+1,std::vector<bool>(n+1));

  std::vector<long long> ans(m);
  ans[m-1] = n(n-1)/2;
  for(int j = m-1; j > 0; j--){
    ans[j-1] = ans[j];
    int temp1 = data[j][0];
    int temp2 = data[j][1];
    if(gra[temp1][temp2] != 1){
      ans[j-1] --;
      gra[temp1][temp2] = 1;
      for(int i = 1; i < temp1; i++){
        if(gra[i][temp1] == 1){
          if(gra[i][temp2] != 1){
            ans[j-1] --;
            gra[i][temp2] = 1;
          }
        }
      }
      for(int i = temp1+1; i <= n; i++){
        if(gra[temp1][i] == 1){
          if(gra[std::min(i,temp2)][std::max(i,temp2)] != 1){
            ans[j-1] --;
            gra[std::min(i,temp2)][std::max(i,temp2)] = 1;
          }
        }
      }
      for(int i = 1; i < temp2; i++){
        if(gra[i][temp2] == 1){
          if(gra[std::min(i,temp1)][std::max(i,temp1)] != 1){
            ans[j-1] --;
            gra[std::min(i,temp1)][std::max(i,temp1)] = 1;
          }
        }
      }
      for(int i = temp2+1; i <= n; i++){
        if(gra[temp2][i] == 1){
          if(gra[temp1][i] != 1){
            ans[j-1] --;
            gra[temp1][i] = 1;
          }
        }
      }
    }
  }

  for(int i = 0; i < m; i++){
    std::cout<<ans[i]<<std::endl;

  }
  return 0;
  





}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:15: error: 'n' cannot be used as a function
   16 |   ans[m-1] = n(n-1)/2;
      |              ~^~~~~
Language: C++

#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

using std::cin;
using std::cout;
using std::string;
using hoge = std::vector<std::pair<int, int>>;
bool func(int start, int goal, const hoge& vec,int start_idx,std::vector<int> used)
{
  bool result = false;
  used.reserve(vec.size());
  for (size_t i = start_idx; i < vec.size(); ++i)
  {
    if (std::find(used.begin(), used.end(), i) != used.end())
    {
      continue;
    }
    if (vec[i].first == start)
    {
      if(vec[i].second == goal){return true;}
      used.push_back(i);
      result |= func(vec[i].second, goal, vec,start_idx, used);
    }
    else if (vec[i].second == start)
    {
      if(vec[i].first == goal){return true;}
      used.push_back(i);
      result |= func(vec[i].first, goal, vec,start_idx, used);
    }
    if(result == true) {break;}
  }

  return result;
}

int main()
{
  int n, m;
  cin >> n >> m;
  std::vector<std::pair<int, int>> nodes(m);
  for (int i = 0; i < m; ++i)
  {
    int a, b;
    cin >> a >> b;
    nodes[i] = std::make_pair(a, b);
  }

  std::vector<int> incs(m);
  std::vector<int> used;
  for (int fb = 1; fb <= m; ++fb)
  {
    // hoge sorted_nodes;
    // std::copy(nodes.begin() + fb, nodes.end(),
    //           std::back_inserter(sorted_nodes));
    // // std::sort(sorted_nodes.begin(), sorted_nodes.end());

    for (int i = 1; i <= n; ++i)
    {
      for (int j = i + 1; j <= n; ++j)
      {
        if (!func(i, j, sorted_nodes,fb, used))
          incs[fb - 1]++;
      }
    }
  }
  std::for_each(incs.begin(), incs.end(), [](int x) { cout << x << "\n";});
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:25: error: 'sorted_nodes' was not declared in this scope
   65 |         if (!func(i, j, sorted_nodes,fb, used))
      |                         ^~~~~~~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long int
using namespace std;

ll N,M; 
 int flag[1000090]; // 頂点に到達したかどうか
int edge[100009][100009] ; // 辺の情報
int a[100009];
int b[100009];
set <int> ga;
set <int> gb;



// 深さ優先探索
void dfs(int vertex,int ab){
    int i;
    
    // 既に到達済みの場合
    if(flag[vertex]) return;
    
    // 到達済みとして保存
    flag[vertex] = 1;
    if(ab==0) ga.insert(vertex);
    else gb.insert(vertex);
    
    // 頂点 vertex と辺がある頂点へ訪問
    for(i = 0; i <= N; ++i){
        if(edge[vertex][i]){ // 頂点 vertex から i へ辺がある
            dfs(i,ab); // 頂点 i へ移動
        }
    }
}



int main(){
  cin>>N>>M;

for(int i=0;i<N;i++){
  for(int j=0;j<N;j++){
    edge[i][j] = 0;
  }
}
 

for(int i=0;i<M;i++){
  cin>>a[i]>>b[i];
  edge[a[i]][b[i]] = 1;
  edge[b[i]][a[i]] = 1;
}

ll ans =0;

for(int i=0;i<M;i++){

   // 初期化
    for(int j = 0; j <= N; ++j){
        flag[j] = 0;
    }

    edge[a[i]][b[i]]=0;
    edge [b[i]][a[i]] = 0;



    dfs(a[i],0);
    dfs(b[i],1);

    if(ga != gb){
     // cout<<1<<endl;
      ans += ga.size() * gb.size();
    }

    ga.clear();
    gb.clear();
    
    cout<<ans<<endl;


}

return 0;

}
 

Compiler output:
/tmp/ccclynjn.o: in function `dfs(int, int)':
a.cc:(.text+0x58): relocation truncated to fit: R_X86_64_PC32 against symbol `ga' defined in .bss section in /tmp/ccclynjn.o
a.cc:(.text+0x70): relocation truncated to fit: R_X86_64_PC32 against symbol `gb' defined in .bss section in /tmp/ccclynjn.o
/tmp/ccclynjn.o: in function `main':
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccclynjn.o
a.cc:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccclynjn.o
a.cc:(.text+0x1e4): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccclynjn.o
a.cc:(.text+0x1fb): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccclynjn.o
a.cc:(.text+0x237): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccclynjn.o
a.cc:(.text+0x24e): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccclynjn.o
a.cc:(.text+0x2f2): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccclynjn.o
a.cc:(.text+0x309): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccclynjn.o
a.cc:(.text+0x345): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long int
using namespace std;

ll N,M; 
 int flag[1000090]; // 頂点に到達したかどうか
int edge[100009][100009] ; // 辺の情報
int a[100009];
int b[100009];
set <int> ga;
set <int> gb;



// 深さ優先探索
void dfs(int vertex,int ab){
    int i;
    
    // 既に到達済みの場合
    if(flag[vertex]) return;
    
    // 到達済みとして保存
    flag[vertex] = 1;
    if(ab==0) ga.insert(vertex);
    else gb.insert(vertex);
    
    // 頂点 vertex と辺がある頂点へ訪問
    for(i = 0; i <= N; ++i){
        if(edge[vertex][i]){ // 頂点 vertex から i へ辺がある
            dfs(i,ab); // 頂点 i へ移動
        }
    }
}



int main(){
  cin>>N>>M;

for(int i=0;i<N;i++){
  for(int j=0;j<N;j++){
    edge[i][j] = 0;
  }
}
 

for(int i=0;i<M;i++){
  cin>>a[i]>>b[i];
  edge[a[i]][b[i]] = 1;
  edge[b[i]][a[i]] = 1;
}

ll ans =0;

for(int i=0;i<M;i++){

   // 初期化
    for(int j = 0; j <= N; ++j){
        flag[j] = 0;
    }

    edge[a[i]][b[i]]=0;
    edge [b[i]][a[i]] = 0;



    dfs(a[i],0);
    dfs(b[i],1);

    if(ga != gb){
     // cout<<1<<endl;
      ans += ga.size() * gb.size();
    }

    ga.clear();
    gb.clear();
    
    cout<<ans<<endl;


}

return 0;

}
 

Compiler output:
/tmp/ccYDyQqt.o: in function `dfs(int, int)':
a.cc:(.text+0x58): relocation truncated to fit: R_X86_64_PC32 against symbol `ga' defined in .bss section in /tmp/ccYDyQqt.o
a.cc:(.text+0x70): relocation truncated to fit: R_X86_64_PC32 against symbol `gb' defined in .bss section in /tmp/ccYDyQqt.o
/tmp/ccYDyQqt.o: in function `main':
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccYDyQqt.o
a.cc:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccYDyQqt.o
a.cc:(.text+0x1e4): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccYDyQqt.o
a.cc:(.text+0x1fb): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccYDyQqt.o
a.cc:(.text+0x237): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccYDyQqt.o
a.cc:(.text+0x24e): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccYDyQqt.o
a.cc:(.text+0x2f2): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccYDyQqt.o
a.cc:(.text+0x309): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccYDyQqt.o
a.cc:(.text+0x345): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
struct UnionFind{
  vector<long long> par;
 
  UnionFind(int n){
    par.assign(n,-1);
  }
 
  void unite(long long x, long long y){
    x=root(x);y=root(y);
    if(x==y) return;
 
    if(par[x]>par[y]){
      swap(x,y);
    }
    par[x]+=par[y];
    par[y]=x;
  }
 
  long long root(long long x){
    if(par[x]<0){
      return x;
    }else{
      return par[x]=root(par[x]);
    }
  }
 
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
};

int main(){
  long long n,m;
  cin >> n >> m;
  UnionFind uf(n);
  long long a[m],b[m],ans[m]={};
  map<long long, int> mp;
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
  }
  for(int i=0;i<n;i++){
    mp[i]++;
  }
  reverse(a,a+m);
  reverse(b,b+m);
  ans[m-1]=n*(n-1)/2;
  for(int i=0;i<m-1;i++){
    if(!uf.same(a[i],b[i])){
      ans[m-i-2]=ans[m-i-1]-mp[uf.root(a[i])]*mp[uf.root(b[i])];
    }
    int tmp=mp[uf.root(a[i])], cmp=mp[uf.root(b[i])],x=mp[uf.root(a[i])], y=mp[uf.root(b[i])];
    uf.unite(a[i], b[i]);
    if(uf.root(a[i])==a){
      mp[uf.root(a[i])]+=cmp;
    }else{
      mp[uf.root(a[i])]+=tmp;
    }
  }
  for(int i=0;i<m;i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   57 |     if(uf.root(a[i])==a){
      |        ~~~~~~~~~~~~~^~~
Language: C++

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long int
using namespace std;

ll N,M; 
 int flag[1000090]; // 頂点に到達したかどうか
int edge[100009][100009] ; // 辺の情報
int a[100009];
int b[100009];
set <int> ga;
set <int> gb;



// 深さ優先探索
void dfs(int vertex,int ab){
    int i;
    
    // 既に到達済みの場合
    if(flag[vertex]) return;
    
    // 到達済みとして保存
    flag[vertex] = 1;
    if(ab==0) ga.insert(vertex);
    else gb.insert(vertex);
    
    // 頂点 vertex と辺がある頂点へ訪問
    for(i = 0; i <= N; ++i){
        if(edge[vertex][i]){ // 頂点 vertex から i へ辺がある
            dfs(i,ab); // 頂点 i へ移動
        }
    }
}



int main(){
  cin>>N>>M;

for(int i=0;i<N;i++){
  for(int j=0;j<N;j++){
    edge[i][j] = 0;
  }
}
 

for(int i=0;i<M;i++){
  cin>>a[i]>>b[i];
  edge[a[i]][b[i]] = 1;
  edge[b[i]][a[i]] = 1;
}

ll ans =0;

for(int i=0;i<M;i++){

   // 初期化
    for(int j = 0; j <= N; ++j){
        flag[j] = 0;
    }

    edge[a[i]][b[i]]=0;
    edge [b[i]][a[i]] = 0;



    dfs(a[i],0);
    dfs(b[i],1);

    if(ga != gb){
     // cout<<1<<endl;
      ans += ga.size() * gb.size();
    }

    ga.clear();
    gb.clear();
    
    cout<<ans<<endl;


}

return 0;

}
 

Compiler output:
/tmp/ccH4hEiv.o: in function `dfs(int, int)':
a.cc:(.text+0x58): relocation truncated to fit: R_X86_64_PC32 against symbol `ga' defined in .bss section in /tmp/ccH4hEiv.o
a.cc:(.text+0x70): relocation truncated to fit: R_X86_64_PC32 against symbol `gb' defined in .bss section in /tmp/ccH4hEiv.o
/tmp/ccH4hEiv.o: in function `main':
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccH4hEiv.o
a.cc:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccH4hEiv.o
a.cc:(.text+0x1e4): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccH4hEiv.o
a.cc:(.text+0x1fb): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccH4hEiv.o
a.cc:(.text+0x237): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccH4hEiv.o
a.cc:(.text+0x24e): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccH4hEiv.o
a.cc:(.text+0x2f2): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccH4hEiv.o
a.cc:(.text+0x309): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccH4hEiv.o
a.cc:(.text+0x345): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status