Language: C++

#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
typedef long long ll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

class UnionFind{
    vector<int> par; vector<int> rank;
    public:
        UnionFind(int N) : par(N),rank(N){
            for(int i=0; i<N; ++i){ par[i] = i; rank[i] = 0; }
        }

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

        //xとyとが所属する集合を併呑する
        void unite(int x,int y){
            int rx = find(x); int ry = find(y);
            if(rx == ry) return;
            if(rank[x]<rank[y]){
                par[rx] = ry;
            }else{
                par[ry] = rx;
                if(rank[rx] == rank[ry])rank[rx]++;
            }
        }

        bool same(int x, int y){
            int ry = find(x); int rx = find(y);
            return rx == ry;
        }
};

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

    int n,k,l; cin>>n>>k>>l; int p,q;
    UnionFind road(n); rep(i,k){ cin>>p>>q; road.unite(--p,--q); }/
    UnionFind rail(n); rep(i,l){ cin>>p>>q; rail.unite(--p,--q); }/

    rep(i,n){
        int ans = 1;
        rep(j,n){
            if(i!=j){
                if(road.same(i,j) && rail.same(i,j))++ans;
            }
        }
        cout<< ans <<' ';
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:33: error: expected primary-expression before '/' token
   54 |     ios::sync_with_stdio(false);/
      |                                 ^
a.cc:56:5: error: expected primary-expression before 'int'
   56 |     int n,k,l; cin>>n>>k>>l; int p,q;
      |     ^~~
a.cc:56:21: error: 'n' was not declared in this scope; did you mean 'yn'?
   56 |     int n,k,l; cin>>n>>k>>l; int p,q;
      |                     ^
      |                     yn
a.cc:56:24: error: 'k' was not declared in this scope
   56 |     int n,k,l; cin>>n>>k>>l; int p,q;
      |                        ^
a.cc:56:27: error: 'l' was not declared in this scope; did you mean 'll'?
   56 |     int n,k,l; cin>>n>>k>>l; int p,q;
      |                           ^
      |                           ll
a.cc:57:67: error: expected primary-expression before '/' token
   57 |     UnionFind road(n); rep(i,k){ cin>>p>>q; road.unite(--p,--q); }/
      |                                                                   ^
a.cc:58:15: error: expected primary-expression before 'rail'
   58 |     UnionFind rail(n); rep(i,l){ cin>>p>>q; rail.unite(--p,--q); }/
      |               ^~~~
a.cc:58:45: error: 'rail' was not declared in this scope
   58 |     UnionFind rail(n); rep(i,l){ cin>>p>>q; rail.unite(--p,--q); }/
      |                                             ^~~~
a.cc:58:67: error: expected primary-expression before '/' token
   58 |     UnionFind rail(n); rep(i,l){ cin>>p>>q; rail.unite(--p,--q); }/
      |                                                                   ^
a.cc:15:18: error: expected primary-expression before 'for'
   15 | #define rep(i,n) for(int i = 0; i<n; ++i)
      |                  ^~~
a.cc:60:5: note: in expansion of macro 'rep'
   60 |     rep(i,n){
      |     ^~~
a.cc:60:9: error: 'i' was not declared in this scope
   60 |     rep(i,n){
      |         ^
a.cc:15:33: note: in definition of macro 'rep'
   15 | #define rep(i,n) for(int i = 0; i<n; ++i)
      |                                 ^