Language: C++

#g namespace std;
struct Union{
  vector<int> par;
  Union(int a){
  par=vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(int a,int b){
    return (find(a)==find(b));
  }
  int size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    int c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
int main(){
  int n,m,ans=0;
  cin >> n >> m;
  Union qwerty(n);
  vector<int> x(m),y(m),z(m);
  for(int i=0;i<m;i++){
    cin >> x[i] >> y[i] >> z[i];
    qwrety.unite(x[i],y[i]);
  }
  set<int> q;
  for(int i=0;i<n;i++){
    q=find(i);
  }
  cout << q.size;
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #g
    1 | #g namespace std;
      |  ^
a.cc:3:3: error: 'vector' does not name a type
    3 |   vector<int> par;
      |   ^~~~~~
a.cc: In constructor 'Union::Union(int)':
a.cc:5:3: error: 'par' was not declared in this scope
    5 |   par=vector<int>(a,-1);
      |   ^~~
a.cc:5:7: error: 'vector' was not declared in this scope
    5 |   par=vector<int>(a,-1);
      |       ^~~~~~
a.cc:5:14: error: expected primary-expression before 'int'
    5 |   par=vector<int>(a,-1);
      |              ^~~
a.cc: In member function 'int Union::find(int)':
a.cc:8:8: error: 'par' was not declared in this scope
    8 |     if(par[a]<0){
      |        ^~~
a.cc: In member function 'int Union::size(int)':
a.cc:19:13: error: 'par' was not declared in this scope
   19 |     return -par[find(a)];
      |             ^~~
a.cc: In member function 'void Union::unite(int, int)':
a.cc:26:7: error: 'swap' was not declared in this scope
   26 |       swap(c,d);
      |       ^~~~
a.cc:28:5: error: 'par' was not declared in this scope
   28 |     par[c]+=par[d];
      |     ^~~
a.cc: In function 'int main()':
a.cc:34:3: error: 'cin' was not declared in this scope
   34 |   cin >> n >> m;
      |   ^~~
a.cc:36:3: error: 'vector' was not declared in this scope
   36 |   vector<int> x(m),y(m),z(m);
      |   ^~~~~~
a.cc:36:10: error: expected primary-expression before 'int'
   36 |   vector<int> x(m),y(m),z(m);
      |          ^~~
a.cc:38:12: error: 'x' was not declared in this scope
   38 |     cin >> x[i] >> y[i] >> z[i];
      |            ^
a.cc:38:20: error: 'y' was not declared in this scope
   38 |     cin >> x[i] >> y[i] >> z[i];
      |                    ^
a.cc:38:28: error: 'z' was not declared in this scope
   38 |     cin >> x[i] >> y[i] >> z[i];
      |                            ^
a.cc:39:5: error: 'qwrety' was not declared in this scope; did you mean 'qwerty'?
   39 |     qwrety.unite(x[i],y[i]);
      |     ^~~~~~
      |     qwerty
a.cc:41:3: error: 'set' was not declared in this scope
   41 |   set<int> q;
      |   ^~~
a.cc:41:7: error: expected primary-expression before 'int'
   41 |   set<int> q;
      |       ^~~
a.cc:43:5: error: 'q' was not declared in this scope
   43 |     q=find(i);
      |     ^
a.cc:43:7: error: 'find' was not declared in this scope
   43 |     q=find(i);
      |       ^~~~
a.cc:45:3: error: 'cout' was not declared in this scope
   45 |   cout << q.size;
      |   ^~~~
a.cc:45:11: error: 'q' was not declared in this scope
   45 |   cout << q.size;
      |           ^