Language: C++

#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int Max = 100000
static const int NIL = 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] == NIL){
       color[v] = c;
       S.push(v);
     }
   }
 }
}
  
void assigncolor(){
 int id = 1;
 for(i=0; i<num; i++){
   color[i] = NIL;
 }
 for(j=0; j<num; j++){
   if(color[j] == NIL)
     dfs(i, 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:6:1: error: expected ',' or ';' before 'static'
    6 | static const int NIL = 100000
      | ^~~~~~
a.cc: In function 'void dfs(int, int)':
a.cc:13:2: error: 'color' was not declared in this scope; did you mean 'tolower'?
   13 |  color[r] = c;
      |  ^~~~~
      |  tolower
a.cc:16:8: error: 'i' was not declared in this scope
   16 |    for(i=0; i<list[u].size(); i++){
      |        ^
a.cc:17:6: error: 'v' was not declared in this scope
   17 |      v = list[u][i];
      |      ^
a.cc:18:21: error: 'NIL' was not declared in this scope
   18 |      if(color[v] == NIL){
      |                     ^~~
a.cc: In function 'void assigncolor()':
a.cc:28:6: error: 'i' was not declared in this scope; did you mean 'id'?
   28 |  for(i=0; i<num; i++){
      |      ^
      |      id
a.cc:28:13: error: 'num' was not declared in this scope; did you mean 'enum'?
   28 |  for(i=0; i<num; i++){
      |             ^~~
      |             enum
a.cc:29:4: error: 'color' was not declared in this scope; did you mean 'tolower'?
   29 |    color[i] = NIL;
      |    ^~~~~
      |    tolower
a.cc:29:15: error: 'NIL' was not declared in this scope
   29 |    color[i] = NIL;
      |               ^~~
a.cc:31:6: error: 'j' was not declared in this scope
   31 |  for(j=0; j<num; j++){
      |      ^
a.cc:31:13: error: 'num' was not declared in this scope; did you mean 'enum'?
   31 |  for(j=0; j<num; j++){
      |             ^~~
      |             enum
a.cc:32:7: error: 'color' was not declared in this scope; did you mean 'tolower'?
   32 |    if(color[j] == NIL)
      |       ^~~~~
      |       tolower
a.cc:32:19: error: 'NIL' was not declared in this scope
   32 |    if(color[j] == NIL)
      |                   ^~~
a.cc:33:10: error: 'i' was not declared in this scope; did you mean 'id'?
   33 |      dfs(i, id++);
      |          ^
      |          id
a.cc: In function 'int main()':
a.cc:39:9: error: 'num' was not declared in this scope; did you mean 'enum'?
   39 |  cin >> num >> kaisuu;
      |         ^~~
      |         enum
a.cc:41:6: error: 'i' was not declared in this scope
   41 |  for(i=0; i<kaisuu; i++){
      |      ^
a.cc:51:6: error: 'i' was not declared in this scope
   51 |  for(i=1; i<=trial; i++){
      |      ^
a.cc:53:7: error: 'color' was not declared in this scope; did you mean 'tolower'?
   53 |    if(color[start] == color[goal]){
      |       ^~~~~
      |       tolower