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

#include <iostream>#include <vector>#include <queue>static const int MAX=100000;using namespace std;vector<int> follow[MAX];int color[MAX];  //-1 represent No Visitedvoid bfs(int i,int c){    queue<int> Q;    Q.push(i);color[i]=c;    while(!Q.empty())    {        int p=Q.front();Q.pop();        for(int j=0;j<follow[p].size();j++)        {            if(color[follow[p][j]]!=-1) continue;            //else            Q.push(follow[p][j]); color[follow[p][j]]=color[p];        }    }}int main(){   int n,m;   cin>>n>>m;   for(int i=0;i<n;i++) color[i]=-1;   for(int i=0;i<m;i++)   {       int a,b;       cin>>a>>b;       follow[a].push_back(b);       follow[b].push_back(a);   }   int c=0;   for(int i=0;i<n;i++)   {       if(color[i]==-1)       {           bfs(i, c);           c++;       }   }   int order_num;cin>>order_num;   for(int i=0;i< order_num;i++)   {       int a,b;       cin>>a>>b;       if(color[a]==color[b]) cout<<"yes"<<endl;       else cout<<"no"<<endl;   }}

Compiler output:
a.cc:1:20: warning: extra tokens at end of #include directive
    1 | #include <iostream>#include <vector>#include <queue>static const int MAX=100000;using namespace std;vector<int> follow[MAX];int color[MAX];  //-1 represent No Visitedvoid bfs(int i,int c){    queue<int> Q;    Q.push(i);color[i]=c;    while(!Q.empty())    {        int p=Q.front();Q.pop();        for(int j=0;j<follow[p].size();j++)        {            if(color[follow[p][j]]!=-1) continue;            //else            Q.push(follow[p][j]); color[follow[p][j]]=color[p];        }    }}int main(){   int n,m;   cin>>n>>m;   for(int i=0;i<n;i++) color[i]=-1;   for(int i=0;i<m;i++)   {       int a,b;       cin>>a>>b;       follow[a].push_back(b);       follow[b].push_back(a);   }   int c=0;   for(int i=0;i<n;i++)   {       if(color[i]==-1)       {           bfs(i, c);           c++;       }   }   int order_num;cin>>order_num;   for(int i=0;i< order_num;i++)   {       int a,b;       cin>>a>>b;       if(color[a]==color[b]) cout<<"yes"<<endl;       else cout<<"no"<<endl;   }}
      |                    ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<vector>
#include<stack>
 
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;
 
int n;
vector<int> G[MAX];
int color[MAX];
 
void dfs(int r, int c) {
   stack<int> S;
   S.push(r);
   color[r] = c;
   while ( !S.empty() ) {
      int u = S.top(); S.pop();
      for ( int i = 0; i < G[u].size(); i++ ) {
         int v = G[u][i]
         if ( color[v] == NIL ) {
            color[v] = c;
            S.push(v);
         }
      }
   }
}

void assignColor() {
   int id = 1;
   for ( int i = 0; i < n; i++ ) color[i] = NIL;

   for ( int u = 0; u < n; u++ ) {
      if ( color[u] == NIL ) dfs(u, id++ );
   }
}

int main() {
   int s, t, m, q;

   cin >> s >> m;

   for ( int i = 0; i < m; i++ ) {
      cin >> s >> t;
      G[s].push_back(t);
      G[t].push_back(s);
   }

   assignColor();
   
   cin >> q;

   for ( int i = 0; i < q; i++) {
      cin >> s >> t;
      if ( color[s] == color[t] ) {
         cout << "yes" << endl;
      } else {
      cout << "no" << endl;
      }
   }
 
   return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:21:10: error: expected ',' or ';' before 'if'
   21 |          if ( color[v] == NIL ) {
      |          ^~
Language: C++

#include<iostream>
#include<vector>
#include<stack>
 
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;
 
int n;
vector<int> G[MAX];
int color[MAX];
 
void dfs(int r, int c) {
   stack<int> S;
   S.push(r);
   color[r] = c;
   while ( !S.empty() ) {
      int u = S.top(); S.pop();
      for ( int i = 0; i < G[u].size(); i++ ) {
         int v = G[u][i]
         if ( color[v] == NIL ) {
            color[v] = c;
            S.push(v);
         }
      }
   }
}

void assignColor() {
   int id = 1;
   for ( int i = 0; i < n; i++ ) color[i] = NIL;

   for ( int u = 0; u < n; u++ ) {
      if ( color[u] == NIL ) dfs(u, id++ );
   }
}

int main() {
   int s, t, m, q;

   cin >> n >> m;

   for ( int i = 0; i < m; i++ ) {
      cin >> s >> t;
      G[s].push_back(t);
      G[t].push_back(s);
   }

   assignColor();
   
   cin >> q;

   for ( int i = 0; i < q; i++ ) {
      cin >> s >> t;
      if ( color[s] == color[t] ) {
         cout << "yes" << endl;
      } else {
      cout << "no" << endl;
      }
   }
 
   return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:21:10: error: expected ',' or ';' before 'if'
   21 |          if ( color[v] == NIL ) {
      |          ^~
Language: C++

#include <stdio.h>

int m[100000] = {0};

void init() {
	int i;
	for ( i = 0; i < 100000; ++i) {
		m[i] = i;
	}
}

int find(int n) {
	if ( n == m[n]) {
		return n;
	}
	return m[n] = find(m[n]);
}

int friend (int x, int y) {
	if ( find(x) == find(y)) {
		return 1;
	} else {
		return 0;
	}
}

void unit (int x, int y) {
	x = find(x);
	y = find(y);
	
	if ( x == y ) {
		return ;
	}
	m[y] = x;
}

int main() {
	int n, s, t, u, v, i;
	init();
	scanf("%d", &n);
	scanf("%d", &s);
	
	for ( i = 0; i < s; ++i) {
		scanf("%d", &u);
		scanf("%d", &v);
		unit( u, v);
	}
	
	scanf("%d", &t);
	
	for ( i = 0; i < s; i++) {
		scanf("%d", &u);
		scanf("%d", &v);
		if ( friend( u, v) == 1) {
			printf("yes\n");
		} else {
			printf("no\n");
		}
	}
	return 0;
}

Compiler output:
a.cc:19:5: error: 'friend' used outside of class
   19 | int friend (int x, int y) {
      |     ^~~~~~
      |     ------
a.cc:19:13: error: expected unqualified-id before 'int'
   19 | int friend (int x, int y) {
      |             ^~~
a.cc:19:13: error: expected ')' before 'int'
   19 | int friend (int x, int y) {
      |            ~^~~
      |             )
a.cc: In function 'int main()':
a.cc:54:22: error: 'friend' used outside of class
   54 |                 if ( friend( u, v) == 1) {
      |                      ^~~~~~
      |                      ------
'
a.cc:54: confused by earlier errors, bailing out
Language: C++

#include <stdio.h>

int m[100000] = {0};

void init() {
	int i;
	for ( i = 0; i < 100000; ++i) {
		m[i] = i;
	}
}

int find(int n) {
	if ( n == m[n]) {
		return n;
	}
	return m[n] = find(m[n]);
}

void friend (int x, int y) {
	if ( find(x) == find(y)) {
		return 1;
	} else {
		return 0;
	}
}

void unit (int x, int y) {
	x = find(x);
	y = find(y);
	
	if ( x == y ) {
		return ;
	}
	m[y] = x;
}

int main() {
	int n, s, t, u, v, i;
	init();
	scanf("%d", &n);
	scanf("%d", &s);
	
	for ( i = 0; i < s; ++i) {
		scanf("%d", &u);
		scanf("%d", &v);
		unit( u, v);
	}
	
	scanf("%d", &t);
	
	for ( i = 0; i < s; i++) {
		scanf("%d", &u);
		scanf("%d", &v);
		if ( friend( u, v) == 1) {
			printf("yes\n");
		} else {
			printf("no\n");
		}
	}
	return 0;
}

Compiler output:
a.cc:19:6: error: 'friend' used outside of class
   19 | void friend (int x, int y) {
      |      ^~~~~~
      |      ------
a.cc:19:14: error: expected unqualified-id before 'int'
   19 | void friend (int x, int y) {
      |              ^~~
a.cc:19:14: error: expected ')' before 'int'
   19 | void friend (int x, int y) {
      |             ~^~~
      |              )
a.cc: In function 'int main()':
a.cc:54:22: error: 'friend' used outside of class
   54 |                 if ( friend( u, v) == 1) {
      |                      ^~~~~~
      |                      ------
'
a.cc:54: confused by earlier errors, bailing out
Language: C++

#include <stdio.h>

int m[100000] = {0};

void init() {
	int i;
	for ( i = 0; i < 100000; ++i) {
		m[i] = i;
	}
}

int find(int a) {
	if ( a == m[a]) {
		return a;
	}
	return m[a] = find(m[a]);
}

int friend(int x, int y) {
	if ( find(x) == find(y)) {
		return 1;
	} else {
		return 0;
	}
}

void unit (int x, int y) {
	x = find(x);
	y = find(y);
	
	if ( x == y ) {
		return ;
	}
	m[y] = x;
}

int main() {
	int n, s, t, u, v, i;
	init();
	scanf("%d", &n);
	scanf("%d", &s);
	
	for ( i = 0; i < s; ++i) {
		scanf("%d", &u);
		scanf("%d", &v);
		unit( u, v);
	}
	
	scanf("%d", &t);
	
	for ( i = 0; i < s; i++) {
		scanf("%d", &u);
		scanf("%d", &v);
		if ( friend( u, v)) {
			printf("yes\n");
		} else {
			printf("no\n");
		}
	}
	return 0;
}

Compiler output:
a.cc:19:5: error: 'friend' used outside of class
   19 | int friend(int x, int y) {
      |     ^~~~~~
      |     ------
a.cc:19:12: error: expected unqualified-id before 'int'
   19 | int friend(int x, int y) {
      |            ^~~
a.cc:19:12: error: expected ')' before 'int'
   19 | int friend(int x, int y) {
      |           ~^~~
      |            )
a.cc: In function 'int main()':
a.cc:54:22: error: 'friend' used outside of class
   54 |                 if ( friend( u, v)) {
      |                      ^~~~~~
      |                      ------
'
a.cc:54: confused by earlier errors, bailing out
Language: C++

#include <stdio.h>

int m[100000] = {0};

void init() {
	int i;
	for ( i = 0; i < 100000; ++i) {
		m[i] = i;
	}
}

int find(int a) {
	if ( a == m[a]) {
		return a;
	}
	return m[a] = find(m[a]);
}

int friend(int x, int y) {
	if ( find(x) == find(y)) {
		return 1;
	} else {
		return 0;
	}
}

void unit (int x, int y) {
	x = find(x);
	y = find(y);
	
	if ( x == y ) {
		return ;
	}
	m[y] = x;
}

int main() {
	int n, s, t, u, v, i;
	init();
	scanf("%d", &n);
	scanf("%d", &s);
	
	for ( i = 0; i < s; i++) {
		scanf("%d %d", &u, &v);
		unit( u, v);
	}
	
	scanf("%d", &t);
	
	for ( i = 0; i < s; i++) {
		scanf("%d %d", &u, &v);
		if ( friend( u, v) == 1) {
			printf("yes\n");
		} else {
			printf("no\n");
		}
	}
	return 0;
}

Compiler output:
a.cc:19:5: error: 'friend' used outside of class
   19 | int friend(int x, int y) {
      |     ^~~~~~
      |     ------
a.cc:19:12: error: expected unqualified-id before 'int'
   19 | int friend(int x, int y) {
      |            ^~~
a.cc:19:12: error: expected ')' before 'int'
   19 | int friend(int x, int y) {
      |           ~^~~
      |            )
a.cc: In function 'int main()':
a.cc:52:22: error: 'friend' used outside of class
   52 |                 if ( friend( u, v) == 1) {
      |                      ^~~~~~
      |                      ------
'
a.cc:52: confused by earlier errors, bailing out
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N] = {{0}};
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/ccDqFYw9.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccDqFYw9.o
/tmp/ccDqFYw9.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccDqFYw9.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N] = {{0}};
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/ccrOIJyh.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrOIJyh.o
/tmp/ccrOIJyh.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrOIJyh.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N] = {{0}};
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/ccvXMh1W.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccvXMh1W.o
/tmp/ccvXMh1W.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccvXMh1W.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N] = {{0}};
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/ccxQNDNs.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccxQNDNs.o
/tmp/ccxQNDNs.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccxQNDNs.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N] = {{0}};
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/ccngm3Xt.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccngm3Xt.o
/tmp/ccngm3Xt.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccngm3Xt.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N] = {{0}};
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/cc2SisMj.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc2SisMj.o
/tmp/cc2SisMj.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc2SisMj.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N] = {{0}};
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/ccDu98AG.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccDu98AG.o
/tmp/ccDu98AG.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccDu98AG.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N] = {{0}};
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/cc2Auw0r.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc2Auw0r.o
/tmp/cc2Auw0r.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc2Auw0r.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream> using namespace std; const int N = 100000; int A[N][N] = {{0}}; int n; bool dfs(int s, int t) {     if (A[s][t] == 1) {         return true;     }     for (int i = 0; i < n; ++i) {         if (i != t && A[s][i] != 0) {             if (dfs(i, t)) {                 return true;             }         }     }     return false; } int main() {     int m;     cin >> n >> m;     for (int i = 0; i < m; ++i) {         int s, t;         cin >> s >> t;         A[s][t] = 1;     }     int q;     cin >> q;     for (int j = 0; j < q; ++j) {         int x, y;         cin >> x >> y;         if (dfs(x, y)) {             cout << "yes";         } else {             cout << "no";         }         cout << endl;     }     return 0; }

Compiler output:
a.cc:1:21: warning: extra tokens at end of #include directive
    1 | #include <iostream> using namespace std; const int N = 100000; int A[N][N] = {{0}}; int n; bool dfs(int s, int t) {     if (A[s][t] == 1) {         return true;     }     for (int i = 0; i < n; ++i) {         if (i != t && A[s][i] != 0) {             if (dfs(i, t)) {                 return true;             }         }     }     return false; } int main() {     int m;     cin >> n >> m;     for (int i = 0; i < m; ++i) {         int s, t;         cin >> s >> t;         A[s][t] = 1;     }     int q;     cin >> q;     for (int j = 0; j < q; ++j) {         int x, y;         cin >> x >> y;         if (dfs(x, y)) {             cout << "yes";         } else {             cout << "no";         }         cout << endl;     }     return 0; }
      |                     ^~~~~
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N] = {{0}};
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/ccPjlajO.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccPjlajO.o
/tmp/ccPjlajO.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccPjlajO.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N] = {{0}};
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/cc3qKsxI.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc3qKsxI.o
/tmp/cc3qKsxI.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc3qKsxI.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N] = {{0}};
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/ccOpIaUF.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOpIaUF.o
/tmp/ccOpIaUF.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOpIaUF.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N] = {{0}};
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/cc0lwjot.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc0lwjot.o
/tmp/cc0lwjot.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc0lwjot.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N] = {{0}};
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/ccDqbwks.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccDqbwks.o
/tmp/ccDqbwks.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccDqbwks.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

const int N = 100000;
int A[N][N];
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
/tmp/cc35K6Pk.o: in function `dfs(int, int)':
a.cc:(.text+0x9d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc35K6Pk.o
/tmp/cc35K6Pk.o: in function `main':
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc35K6Pk.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

using namespace std;

// int A[N][N];
vector<vector<int>> A;
int n;

bool dfs(int s, int t) {
    if (A[s][t] == 1) {
        return true;
    }
    for (int i = 0; i < n; ++i) {
        if (i != t && A[s][i] != 0) {
            if (dfs(i, t)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    A.resize(N);
    for (int i = 0; i < N; ++i)
        A[i].resize(N);

    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s][t] = 1;
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (dfs(x, y)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

Compiler output:
a.cc:6:1: error: 'vector' does not name a type
    6 | vector<vector<int>> A;
      | ^~~~~~
a.cc: In function 'bool dfs(int, int)':
a.cc:10:9: error: 'A' was not declared in this scope
   10 |     if (A[s][t] == 1) {
      |         ^
a.cc:14:23: error: 'A' was not declared in this scope
   14 |         if (i != t && A[s][i] != 0) {
      |                       ^
a.cc: In function 'int main()':
a.cc:24:5: error: 'A' was not declared in this scope
   24 |     A.resize(N);
      |     ^
a.cc:24:14: error: 'N' was not declared in this scope
   24 |     A.resize(N);
      |              ^
Language: C++

#include<iostream>
#include<vector>
#include<stack>
using namespace std;
int i, j, v, num, color[100000];
vector<int> list[100000];

void dfs(int r, int c){
 stack<int> S;
 S.push(r);
 color[r] = c;
 while( !S.empty() ){
   int u = S.top(); S.pop();
   for(i=0; i<list[u].size(); i++){
     v = list[u][i];
     if(color[v] == -1){
       color[v] = c;
       S.push(v);
     }
   }
 }
}
 
void assigncolor(){
 int id = 1;
 for(i=0; i<num; i++){
   color[i] = -1;
 }
 for(i=0; i<num; i++){
   if(color[i] == -1)
     dfs(i, id++);
 }
}
 
int main(){
 int a, b, trial, start, goal, kaisuu;
 scanf_s("%d %d", &num, &kaisuu);
 
 for(i=0; i<kaisuu; i++){
   scanf_s("%d %d", &a, &b);
   list[a].push_back(b);
   list[b].push_back(a);
 }

 assigncolor();

 scanf("%d", &trial);

 for(i=1; i<=trial; i++){
   scanf_s("%d %d", &start, &goal);
   if(color[start] == color[goal]){  
     cout << "yes" << endl;
   } else{
     cout << "no" << endl;
   }
 }
 
 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:2: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   37 |  scanf_s("%d %d", &num, &kaisuu);
      |  ^~~~~~~
      |  scanf
Language: C++

#include<iostream>
#include<vector>
#include<stack>
using namespace std;
int i, j, v, num, color[100000];
vector<int> list[100000];

void dfs(int r, int c){
 stack<int> S;
 S.push(r);
 color[r] = c;
 while( !S.empty() ){
   int u = S.top(); S.pop();
   for(i=0; i<list[u].size(); i++){
     v = list[u][i];
     if(color[v] == -1){
       color[v] = c;
       S.push(v);
     }
   }
 }
}
 
void assigncolor(){
 int id = 1;
 for(i=0; i<num; i++){
   color[i] = -1;
 }
 for(i=0; i<num; i++){
   if(color[i] == -1)
     dfs(i, id++);
 }
}
 
int main(){
 int a, b, trial, start, goal, kaisuu;
 cin >> num >>kaisuu;
 
 for(i=0; i<kaisuu; i++){
   scanf_s("%d %d", &a, &b);
   list[a].push_back(b);
   list[b].push_back(a);
 }

 assigncolor();

 cin >> trial;

 for(i=1; i<=trial; i++){
   scanf_s("%d %d", &start, &goal);
   if(color[start] == color[goal]){  
     cout << "yes" << endl;
   } else{
     cout << "no" << endl;
   }
 }
 
 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:4: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   40 |    scanf_s("%d %d", &a, &b);
      |    ^~~~~~~
      |    scanf
a.cc:50:4: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   50 |    scanf_s("%d %d", &start, &goal);
      |    ^~~~~~~
      |    scanf
Language: C++

#include<iostream>
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX =  100000;
int i, j, v, num, color[MAX];
vector<int> list[MAX];
 
void dfs(int r, int c){
 stack<int> S;
 S.push(r);
 color[r] = c;
 while( !S.empty() ){
   int u = S.top(); S.pop();
   for(i=0; i<list[u].size(); i++){
     v = list[u][i];
     if(color[v] == -1){
       color[v] = c;
       S.push(v);
     }
   }
 }
}
  
void assigncolor(){
 int id = 1;
 for(i=0; i<num; i++){
   color[i] = -1;
 }
 for(j=0; ij<num; j++){
   if(color[j] == -1)
     dfs(j, id++);
 }
}
  
int main(){
 int a, b, trial, start, goal, kaisuu;
 cin >> num >>kaisuu;
  
 for(i=0; i<kaisuu; i++){
   cin >> a >> b;
   list[a].push_back(b);
   list[b].push_back(a);
 }
 
 assigncolor();
 
 cin >> trial;
 
 for(i=1; i<=trial; i++){
   cin >> start >> goal;
   if(color[start] == color[goal]){  
     cout << "yes" << endl;
   } else{
     cout << "no" << endl;
   }
 }
  
 return 0;
}

Compiler output:
a.cc: In function 'void assigncolor()':
a.cc:31:11: error: 'ij' was not declared in this scope; did you mean 'id'?
   31 |  for(j=0; ij<num; j++){
      |           ^~
      |           id
Language: C++

#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs( int r, int c ){
    stack<int> S;
    S.push(r);
    color[r] = c;
    while ( !S.empty() ){
        int u = S.top(); S.pop();
        for ( int i = 0; i < G[u].size(); i ++ ){
            int v = G[u][i];
            if ( color[v] == NIL ){
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    for ( i = 0; i < n; i++ ) color[i] = NIL;
    for ( u = 0; u < n; u++ ){
        if ( color[u] == NIL ) dfs(u, id++);
    }
}

int main() {
    
    int s, t, m, q;
    
    cin >> n >> m;
    
    for ( i = 0; i < m; i++ ){
        con >> s >> t;
        G.push_back(t);
        G.push_back(s);
    }
    
    assignColor();
    
    cin >> q;
    
    for ( i = 0; i < q; i++ ){
        cin >> s >> t;
        if( color[s] == color[t] ){
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'void assignColor()':
a.cc:30:11: error: 'i' was not declared in this scope; did you mean 'id'?
   30 |     for ( i = 0; i < n; i++ ) color[i] = NIL;
      |           ^
      |           id
a.cc:31:11: error: 'u' was not declared in this scope
   31 |     for ( u = 0; u < n; u++ ){
      |           ^
a.cc: In function 'int main()':
a.cc:42:11: error: 'i' was not declared in this scope
   42 |     for ( i = 0; i < m; i++ ){
      |           ^
a.cc:43:9: error: 'con' was not declared in this scope
   43 |         con >> s >> t;
      |         ^~~
a.cc:44:11: error: request for member 'push_back' in 'G', which is of non-class type 'std::vector<int> [100000]'
   44 |         G.push_back(t);
      |           ^~~~~~~~~
a.cc:45:11: error: request for member 'push_back' in 'G', which is of non-class type 'std::vector<int> [100000]'
   45 |         G.push_back(s);
      |           ^~~~~~~~~
a.cc:52:11: error: 'i' was not declared in this scope
   52 |     for ( i = 0; i < q; i++ ){
      |           ^
Language: C++

#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n, i, u;
vector<int> G[MAX];
int color[MAX];

void dfs( int r, int c ){
    stack<int> S;
    S.push(r);
    color[r] = c;
    while ( !S.empty() ){
        int u = S.top(); S.pop();
        for ( int i = 0; i < G[u].size(); i ++ ){
            int v = G[u][i];
            if ( color[v] == NIL ){
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    for ( i = 0; i < n; i++ ) color[i] = NIL;
    for ( u = 0; u < n; u++ ){
        if ( color[u] == NIL ) dfs(u, id++);
    }
}

int main() {
    
    int s, t, m, q;
    
    cin >> n >> m;
    
    for ( i = 0; i < m; i++ ){
        cin >> s >> t;
        G.push_back(t);
        G.push_back(s);
    }
    
    assignColor();
    
    cin >> q;
    
    for ( i = 0; i < q; i++ ){
        cin >> s >> t;
        if( color[s] == color[t] ){
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:11: error: request for member 'push_back' in 'G', which is of non-class type 'std::vector<int> [100000]'
   44 |         G.push_back(t);
      |           ^~~~~~~~~
a.cc:45:11: error: request for member 'push_back' in 'G', which is of non-class type 'std::vector<int> [100000]'
   45 |         G.push_back(s);
      |           ^~~~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NTL = -1;

int n;
vector<int>G[max];
int color[MAX];

void dfs(int r,int c){
  stack<int> S;
  S.push(r);
  color[r]=c;
  while (!S.empty()) {
    int u = S.top(); S.pop();
    for (int i =0;i < G[u].size();i++){
      int v =G[u][i];
     if(color[v]==NTL){
      color[v]=c;
      S.push;
      }
    }
  }
}

void assigncolor() {
  int id=1;
  for(int i=0;i<n;i++) color[i]=NTL;
  for(int u =0;u<n;u++){
    if(color[u]==NTL)dfs(u,id++);
  }
}

int main() {
  int s, t, m, q;
  
  cin >> n >> m;

  for(int i = 0;i<m;i++){
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assigncolor();

  cin >> q;

  for(int i = 0; i<q;i++) {
    cin >> s >> t;
    if(color[s]==color[t]){
      cout << "yes"  <<  endl;
    } else {
      cout << "no" << endl;
    }
  }
  return 0;
}

Compiler output:
a.cc:9:17: error: cannot resolve overloaded function 'max' based on conversion to type 'long unsigned int'
    9 | vector<int>G[max];
      |                 ^
a.cc:9:12: error: size of array 'G' has non-integral type '<unresolved overloaded function type>'
    9 | vector<int>G[max];
      |            ^
a.cc: In function 'void dfs(int, int)':
a.cc:22:9: error: statement cannot resolve address of overloaded function
   22 |       S.push;
      |       ~~^~~~
Language: C++

#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c){
  stack<<int> S;
  S.push(r);
  color[r] = c;
  while( !S.empty()) {
   int u = S.top(); S.pop();
   for(int i = 0;i < G[u].size(); i++){
    int v = G[u][i];
   if(color[v] == NIL){
    color[v] = c;
    S.push(v);
    }
   }
  }
 }
  
void assignColor(){
  int id = 1;
  for ( int i = 0; i < n; i++) color[i] = NIL;
  for ( int u = 0; u < n; u++) {
    if ( color[u] == NIL) des(u,id++);
  }
 }
int main (){
  int s,t,q,m;

  cin >> n >> m;

  for(int i = 0;i < m;i++){
  cin >> s >> t;
  G[s].push_back(t);
  G[t].push_back(s);
  }

 assignColor();

 cin >> q;

  for(int i = 0; i < q; i++){
   cin >> s >> t;
    if(color[s] == color[t]){
   cout << "yes" << endl;
  }else{
   cout << "no" << endl;
  }
 }
  return 0;
}

  

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:13:8: error: expected unqualified-id before '<<' token
   13 |   stack<<int> S;
      |        ^~
a.cc:14:3: error: 'S' was not declared in this scope
   14 |   S.push(r);
      |   ^
a.cc: In function 'void assignColor()':
a.cc:32:27: error: 'des' was not declared in this scope; did you mean 'dfs'?
   32 |     if ( color[u] == NIL) des(u,id++);
      |                           ^~~
      |                           dfs
Language: C++

#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c){
  stack<int> S;
  S.push(r);
  color[r] = c;
  while( !S.empty()) {
   int u = S.top(); S.pop();
   for(int i = 0; i < G[u].size(); i++){
    int v = G[u][i];
   if(color[v] == NIL){
    color[v] = c;
    S.push(v);
    }
   }
  }
 }
  
void assignColor(){
  int id = 1;
  for ( int i = 0; i < n; i++) color[i] = NIL;
  for ( int u = 0; u < n; u++) {
    if ( color[u] == NIL) des(u,id++);
  }
 }
int main (){
  int s,t,q,m;

  cin >> n >> m;

  for(int i = 0;i < m;i++){
  cin >> s >> t;
  G[s].push_back(t);
  G[t].push_back(s);
  }

 assignColor();

 cin >> q;

  for(int i = 0; i < q; i++){
   cin >> s >> t;
    if(color[s] == color[t]){
   cout << "yes" << endl;
  }else{
   cout << "no" << endl;
  }
 }
  return 0;
}

  

Compiler output:
a.cc: In function 'void assignColor()':
a.cc:32:27: error: 'des' was not declared in this scope; did you mean 'dfs'?
   32 |     if ( color[u] == NIL) des(u,id++);
      |                           ^~~
      |                           dfs
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#define FOR(i,b,e) for(int i=b;i<e;i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;

const int N = 100000;
int n, m, q;
int M[N][N];
bool V[N];

int bfs(int u, int v) {
  int s;
  queue<int> q;
  REP(i, n) V[i] = false;

  s = u;
  q.push(s);
  V[s] = true;

  while (!q.empty() && !V[v]) {
    s = q.front(); q.pop();
    REP(i, n) {
      if (M[s][i] == 1 && !V[i]) {
        q.push(i);
        V[i] = true;
      }
    }
  }

  return V[v];
}

int main() {
	cin.tie(0);
 	ios::sync_with_stdio(false);

  REP(i, n) {
    REP(j, n) {
      M[i][j] = 0;
    }
  }

  cin >> n >> m;
  REP(i, m) {
    int u, v;
    cin >> u >> v;
    M[u][v] = M[v][u] = 1;
  }

  cin >> q;
  REP(i, q) {
    int u, v;
    string answer;
    cin >> u >> v;
    answer = bfs(u, v) ? "yes" : "no";
    cout << answer << endl;
  }
}


Compiler output:
/tmp/ccW6XEHn.o: in function `bfs(int, int)':
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccW6XEHn.o
a.cc:(.text+0x70): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccW6XEHn.o
a.cc:(.text+0xd7): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccW6XEHn.o
a.cc:(.text+0x101): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccW6XEHn.o
a.cc:(.text+0x13d): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccW6XEHn.o
a.cc:(.text+0x16b): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccW6XEHn.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#define FOR(i,b,e) for(int i=b;i<e;i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;

const int N = 100000;
int n, m, q;
int M[N][N];
bool V[N];

int bfs(int u, int v) {
  int s;
  queue<int> q;
  REP(i, n) V[i] = false;

  s = u;
  q.push(s);
  V[s] = true;

  while (!q.empty() && !V[v]) {
    s = q.front(); q.pop();
    REP(i, n) {
      if (M[s][i] == 1 && !V[i]) {
        q.push(i);
        V[i] = true;
      }
    }
  }

  return V[v];
}

int main() {
	cin.tie(0);
 	ios::sync_with_stdio(false);

  REP(i, n) {
    REP(j, n) {
      M[i][j] = 0;
    }
  }

  cin >> n >> m;
  REP(i, m) {
    int u, v;
    cin >> u >> v;
    M[u][v] = M[v][u] = 1;
  }

  cin >> q;
  REP(i, q) {
    int u, v;
    string answer;
    cin >> u >> v;
    answer = bfs(u, v) ? "yes" : "no";
    cout << answer << endl;
  }
}


Compiler output:
/tmp/cclWiENj.o: in function `bfs(int, int)':
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cclWiENj.o
a.cc:(.text+0x70): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cclWiENj.o
a.cc:(.text+0xd7): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cclWiENj.o
a.cc:(.text+0x101): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cclWiENj.o
a.cc:(.text+0x13d): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cclWiENj.o
a.cc:(.text+0x16b): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cclWiENj.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#define FOR(i,b,e) for(int i=b;i<e;i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;

const int N = 100000;
int n, m, q;
int M[N][N];
bool V[N];

int bfs(int u, int v) {
  int s;
  queue<int> q;
  REP(i, n) V[i] = false;

  s = u;
  q.push(s);
  V[s] = true;

  while (!q.empty() && !V[v]) {
    s = q.front(); q.pop();
    REP(i, n) {
      if (M[s][i] == 1 && !V[i]) {
        q.push(i);
        V[i] = true;
      }
    }
  }

  return V[v];
}

int main() {
	cin.tie(0);
 	ios::sync_with_stdio(false);

  REP(i, n) {
    REP(j, n) {
      M[i][j] = 0;
    }
  }

  cin >> n >> m;
  REP(i, m) {
    int u, v;
    cin >> u >> v;
    M[u][v] = M[v][u] = 1;
  }

  cin >> q;
  REP(i, q) {
    int u, v;
    string answer;
    cin >> u >> v;
    answer = bfs(u, v) ? "yes" : "no";
    cout << answer << endl;
  }
}


Compiler output:
/tmp/ccfR1VJm.o: in function `bfs(int, int)':
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccfR1VJm.o
a.cc:(.text+0x70): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccfR1VJm.o
a.cc:(.text+0xd7): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccfR1VJm.o
a.cc:(.text+0x101): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccfR1VJm.o
a.cc:(.text+0x13d): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccfR1VJm.o
a.cc:(.text+0x16b): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccfR1VJm.o
collect2: error: ld returned 1 exit status
Language: C++

#include <cstdio>
#include <algorithm>
#define rep(i, n) for(int i=0; i<(n); ++i)

int parent[100005];

int find(int x){
   if( parent[x] == x )return x;
   return parent[x] = find( parent[x] );
}

void unite(int x, int y)
{
   x = find(x);
   y = find(y);

   if(x == y)return;
   parent[x] = y;
}

int main()
{
   int N, M;
   int x, y, tmp;
   scanf("%d%d", &N, &M);
   std::iota(parent, parent + N, 0);

   rep(i, M){
      scanf("%d%d", &x, &y);
      unite(x, y);
   }

   int Q;
   scanf("%d", &Q);
   while(Q--){
      scanf("%d%d", &x, &y);
      puts( find(x) == find(y) ? "yes" : "no" );
   }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'iota' is not a member of 'std'
   26 |    std::iota(parent, parent + N, 0);
      |         ^~~~
Language: C++

#include<iostream>
#include<vector>
#include<stack>
#define pop onany
using namespace std;

static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int>G[max];
int color[MAX];

void dfs(int r, int c){
  stack<int>S;
  S.push(r);
  color[r] = c;
  while ( !S.empty() ) {
    int u = S.top();
    S.onany();
    for ( int i = 0; i < G[u].size() ; ++i) {
      int v = G[u][i];
      if ( color[v] == NIL ) {
	color[v] = c;
	S.push(v);
      }
    }
  }
}

int main(){
  int s, t, m, q;
  cin >> n >> m;
  
  for ( int i = 0; i < m ; ++i) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  int id = 1;
  
  for ( int i = 0; i < n; ++i) {
    color[i] = NIL; //preset
  }
  
  for ( int u = 0; u < n; ++u) {
    if ( color[u] == NIL ) {
      dfs(u,id);
      id++;
    }
  }
  
  scanf("%d", &q);
  for ( int i = 0; i < q; ++i) {
    scanf("%d %d", &s, &t);
    if ( color[s] == color[t] ) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return (0);
}



Compiler output:
a.cc:11:17: error: cannot resolve overloaded function 'max' based on conversion to type 'long unsigned int'
   11 | vector<int>G[max];
      |                 ^
a.cc:11:12: error: size of array 'G' has non-integral type '<unresolved overloaded function type>'
   11 | vector<int>G[max];
      |            ^
a.cc: In function 'void dfs(int, int)':
a.cc:20:7: error: 'class std::stack<int>' has no member named 'onany'
   20 |     S.onany();
      |       ^~~~~