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

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

bool rangeCheck(int y, int x, int h, int w) {
  if (y < 0 || x < 0 || y >= h || x >= w) {
    return false;
  } else {
    return true;
  }
}

void outputDone(int h, int w, vector<vector<int>> a) {
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      printf("%3d", a[i][j]);
    }
    cout << endl;
  }
  return;
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }

  int ans = 0;
  vector<vector<int>> done(h, vector<int>(w, -1));
  queue<pair<int, int>> st;
  int dirY[] = {1, 0, -1, 0};
  int dirX[] = {0, 1, 0, -1};
  int cnt = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '.' || done[i][j] != -1) {
        continue;
      }
      int blackCnt = 0, whiteCnt = 0;
      bool flag;
      pair<int, int> xy;
      xy.first = i;
      xy.second = j;
      st.push(xy);
      while (!st.empty()) {
        xy = st.top();
        st.pop();
        \\printf("y=%d x=%d\n",xy.first,xy.second);
        if (done[xy.first][xy.second] != -1) {
          continue;
        }
        if (s[xy.first][xy.second] == '#') {
          flag = false;
        } else {
          flag = true;
        }
        flag ? whiteCnt++ : blackCnt++;
        done[xy.first][xy.second] = cnt;
        for (int k = 0; k < 4; k++) {
          int ny = xy.first + dirY[k];
          int nx = xy.second + dirX[k];
          bool flag2;

          if (!rangeCheck(ny, nx, h, w)) {
            continue;
          }
          if (done[ny][nx] != -1) {
            continue;
          }
          if (s[ny][nx] == '#') {
            flag2 = false;
          } else {
            flag2 = true;
          }
          if (flag == flag2) {
            continue;
          }
          pair<int, int> temp;
          temp.first = ny;
          temp.second = nx;
          st.push(temp);
        }
      }
      cnt++;
      ans += blackCnt * whiteCnt;
    }
  }
  // outputDone(h,w,done);
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc:50:9: error: stray '\' in program
   50 |         \\printf("y=%d x=%d\n",xy.first,xy.second);
      |         ^
a.cc:50:10: error: stray '\' in program
   50 |         \\printf("y=%d x=%d\n",xy.first,xy.second);
      |          ^
a.cc: In function 'int main()':
a.cc:48:17: error: 'class std::queue<std::pair<int, int> >' has no member named 'top'; did you mean 'pop'?
   48 |         xy = st.top();
      |                 ^~~
      |                 pop
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,ll> P;
typedef tuple<int,int,int> TP;
constexpr int INF = 2e9;
struct UnionFind{
  vector<int> data;
  int __size;
  UnionFind(int sz) {
  data.assign(sz, -1);
  __size = sz;
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    __size--;
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  int union_count() {
    return (__size);
  }
};

int dx[] = {0,1};
int dy[] = {1,0};
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  map<int,ll> cnt;
  UnionFind uf(h * w);
  auto calc = [&](int i, int j){
    for (int k = 0; k < 2; k++) {
      int x = i + dx[k], y = j + dy[k];
      if (x >= h || y >= w) continue;
      if (uf.same(i * w + j. x * w + y)) continue;
      if (s[x][y] == s[i][j]) continue;
      uf.unite(i * w + j, x * w + y);
    }
  };
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      calc(i, j);
      if (s[i][j] == '#') cnt[uf.find(i * w + j)]++;
    }
  }
  ll res = 0;
  rep(i,h) rep(j,w) if (s[i][j] == '#') res += (uf.size(i * w + j) - cnt[uf.find(i * w + j)]);
  cout << res << endl;
  return 0;
} 

Compiler output:
a.cc: In lambda function:
a.cc:59:30: error: request for member 'x' in 'j', which is of non-class type 'int'
   59 |       if (uf.same(i * w + j. x * w + y)) continue;
      |                              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int black, white;
void dfs(vector<string> S, vector<vector<int>> &used, int sh, int sw, int H, int W){
    if(sh < H-1 && used[sh+1][sw] == 0 && S[sh+1][sw] == S[sh][sw]){
        if((sh + sw) % 2 == 1){
            black++;
        }
        else{
            white++;
        }
        used[sh+1][sw] = 1;
        dfs(S, used, sh+1, sw, H, W);
    }
    if(sh > 0 && used[sh-1][sw] == 0 && S[sh-1][sw] == S[sh][sw]){
        if((sh + sw) % 2 == 1){
            black++;
        }
        else{
            white++;
        }
        used[sh-1][sw] = 1;
        dfs(S, used, sh-1, sw, H, W);
    }   
    if(sw < W-1 && used[sh][sw+1] == 0 && S[sh][sw+1] == S[sh][sw]){
        if((sh + sw) % 2 == 1){
            black++;
        }
        else{
            white++;
        }
        used[sh][sw+1] = 1;
        dfs(S, used, sh, sw+1, H, W);
    }
    if(sw > 0 && used[sh][sw-1] == 0 && S[sh][sw-1] == S[sh][sw]){
        if((sh + sw) % 2 == 1){
            black++;
        }
        else{
            white++;
        }
        used[sh][sw-1] = 1;
        dfs(S, used, sh, sw-1, H, W);
    }
}

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> S(H, vector<char> (W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if((i+j) % 2 == 0){
                if(S[i][j] == '.'){
                    S[i][j] = '#';
                }
                else{
                    S[i][j] = '.';
                }
            }
        }
    }

    vector<vector<int>> used(H, vector<int> (W, 0));
    int sh, sw;
    sh = 0; sw = 0;
    bool check = true;
    ll ans = 0;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            used[i][j] = 1;
            black = 0;
            white = 0;
            if((i + j) % 2 == 1){
                white++;
            }
            else{
                black++;
            }  
            dfs(S, used, i, j, H, W);
            ans += black * white;
        }
    }

    printf("%lld\n", ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:96:17: error: could not convert 'S' from 'vector<std::vector<char>>' to 'vector<std::__cxx11::basic_string<char>>'
   96 |             dfs(S, used, i, j, H, W);
      |                 ^
      |                 |
      |                 vector<std::vector<char>>
Language: C++

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef pair<int,int> P;
const int INF = 100000000;

int W,H;
int sy, sx, gy, gx;

int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

bool movable(vector<vector<char>> &c, vector<vector<int>> &mat, int h, int w, int hb, int wb) {
  if ((h<0) || (h>=H) || (w<0) || (w>=W)) {
    return false;
  }
  else if (mat[h][w]!=INF || (c[h][w]==c[hb][wb])) {
    return false;
  }
  else {
    return true;
  }
}


ll bfs(vector<vector<char>> &c, vector<vector<int>> &mat, pair<int,int> &q) {
  ll k,s;
  s=0;
  k = 1;
  queue<P> que;
  que.push(q);
  
  if (mat[q.first][q.second] != INF) return 0;
  else (mat[q.first][q.second] = 0);

  while(que.size()) {
    P p = que.front();
    que.pop();

    rep(i,4){
      if (movable(c,mat,p.first+dy[i],p.second+dx[i],p.first,p.second)) {
        que.push(P(p.first+dy[i],p.second+dx[i]));
        mat[p.first+dy[i]][p.second+dx[i]]=mat[p.first][p.second]+1;
        if (c[p.first+dy[i]][p.second+dx[i]]=='.') s++;
        else k++;
      }
    }
  }
  return k*s;
}

int main() {
  cin >> H >> W;

  vector<vector<char>> c(H,vector<char> (W));
  vector<pair<int,int>> P;
  rep(h,H) {
      string s;
      cin >> s;
    rep(w,W) {
      c[h][w] = s[w];
      if (s[w]=='#') {
          P.push_back(make_pair(h,w));
      }
    }
  }
  vector<vector<int>> mat(H,vector<int> (W, INF));
  ll ans = 0;
  for (auto p: P) {
    int tmp = bfs(c,mat,p);
    ans += tmp;

  }
    cout << ans << endl;
}

Compiler output:
a.cc:27:1: error: 'll' does not name a type
   27 | ll bfs(vector<vector<char>> &c, vector<vector<int>> &mat, pair<int,int> &q) {
      | ^~
a.cc: In function 'int main()':
a.cc:69:3: error: 'll' was not declared in this scope
   69 |   ll ans = 0;
      |   ^~
a.cc:71:15: error: 'bfs' was not declared in this scope; did you mean 'ffs'?
   71 |     int tmp = bfs(c,mat,p);
      |               ^~~
      |               ffs
a.cc:72:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   72 |     ans += tmp;
      |     ^~~
      |     abs
a.cc:75:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   75 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

vint dx = {1,0,-1,0};
vint dy = {0,1,0,-1};

int h, w;
vector<string> field;
vector<vector<bool>> used;

ll dfs(int x, int y, char now, int &n_b, int &n_w) {
    used[y][x] = true;
    if (now == '.') n_w++;
    if (now == '#') n_b++;
    rep(i,4) {
        int n_x = x + dx[i], n_y = y + dy[i];
        if (n_x >= 0 && n_x < w && n_y >= 0 && n_y < h && !used[n_y][n_x]) {
            if (field[n_y][n_x] != now) {
                if (now == '.') dfs(n_x,n_y,'#',n_b,n_w);
                if (now == '#') dfs(n_x,n_y,'.',n_b,n_w);
            }
        }
    }
    return n_b * n_w;
}

int main() {
    cin >> h >> w;
    field.resize(h);
    rep(i,h) cin >> field[i];
    ll ans = 0;
    used.assign(h,vector<bool>(w,false));
    rep(i,h)rep(j,w) {
        if (field[i][j] == '#') {
            if (used[i][j]) continue;
            ll n_b = 0, n_w = 0;
            ans += dfs(j,i,'#',n_b,n_w);
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:32: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'll' {aka 'long long int'}
   53 |             ans += dfs(j,i,'#',n_b,n_w);
      |                                ^~~
a.cc:27:37: note:   initializing argument 4 of 'll dfs(int, int, char, int&, int&)'
   27 | ll dfs(int x, int y, char now, int &n_b, int &n_w) {
      |                                ~~~~~^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int dx[] = { 0,0,1,-1 };
const int dy[] = { 1,-1,0,0 };

int main() {
	int H, W; cin >> H >> W;
	vector<string> s(H);
	for (int i = 0; i < H; ++i) cin >> s[i];

	vector<pint> blacks;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (s[i][j] == '#')blacks.push_back({i, j});
		}
	}

	vector<vector<int>> used(H, vector<int>(W));
	 ans = 0;
	for (auto start : blacks) {
		if (used[start.first][start.second] != 0) continue;

		map<char, ll> mp;
		queue<pint> que;

		used[start.first][start.second] = 1;
		++mp[s[start.first][start.second]];
		que.push(start);
		while (!que.empty()) {
			pint p = que.front(); que.pop();
			int y = p.first;
			int x = p.second;
			for (int i = 0; i < 4; ++i) {
				int ny = y + dy[i];
				int nx = x + dx[i];
				if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
				if (s[ny][nx] == s[y][x]) continue;
				if (used[ny][nx] != 0) continue;
				used[ny][nx] = 1;
				++mp[s[ny][nx]];
				que.push({ ny,nx });
			}
		}
		ans += mp['#'] * mp['.'];
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |          ans = 0;
      |          ^~~
      |          abs
Language: C++

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int w,h;
    cin>>h>>w;
    vector<string> g(h);

    rep(i,h)cin>>g[i];

    vector<vector<bool>> vis(h,vector<bool>(w,false));

    rep(i,h)rep(j,w){

        if(g[i][j] == '#' && !vis[i][j] ){
            P now = P(i,j);

            stack<P> st;
            st.push(now);
            vis[i][j] = true;

            ll bl=0,wh=0;

            while(!st.empty()){
                P cur = st.top();st.pop();
                
                int ci = cur.fi;
                int cj = cur.se;

                if(g[ci][cj]=='#')bl++;
                else {wh++; //db2(ci,cj);ln;}

                rep(k,4){
                    int ni = ci+dy[k];
                    int nj = cj+dx[k];

                    if(!(0<=ni && ni<h && 0<=nj && nj<w))continue;

                    //db2(k,st.size());db2(ni,nj)ln;

                    if(g[ni][nj]!=g[ci][cj] && !vis[ni][nj]){
                        P nx = P(ni,nj);
                        st.push(nx);
                        vis[ni][nj] = true;
                    }
                }

                //cout<<ci<<" "<<cj;ln;
            }

            //db2(bl,wh);ln;
            ans += bl*wh;
            break;
        }
    }

    cout<<ans<<endl;
    //cout <<fixed<<setprecision(16)<< << endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:105:2: error: expected '}' at end of input
  105 | }
      |  ^
a.cc:42:11: note: to match this '{'
   42 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};

void dfs(pll a,vvb &q,vstr s,ll h,ll w,ll ans){
  if(s[a.F][a.S]=='.'){
    ans++;
  }
  q[a.F][a.S]=true;
  rep(i,4){
    ll nx=dx[i]+a.F;
    ll ny=dy[i]+a.S;
    if(nx>=0&&nx<h&&ny>=0&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&!q[nx][ny]){
      pll b=pll(nx,ny);
      dfs(b,q,s,h,w,ans);
    }
  }
}
int main(){
  cin>>h>>w;
  vstr s(h);
  vector<pll> p(0);
  rep(i,h) cin>>s[i];
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'){
        p.pb(mp(i,j));
      }
    }
  }
  rep(i,sz(p)){
    vvb q(h,vb(w,false));
    dfs(p[i],q,s,h,w,ans);
  }
  COUT(ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:8: error: 'h' was not declared in this scope
   58 |   cin>>h>>w;
      |        ^
a.cc:58:11: error: 'w' was not declared in this scope
   58 |   cin>>h>>w;
      |           ^
a.cc:71:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
   71 |     dfs(p[i],q,s,h,w,ans);
      |                      ^~~
      |                      abs
a.cc:73:8: error: 'ans' was not declared in this scope; did you mean 'abs'?
   73 |   COUT(ans);
      |        ^~~
a.cc:19:24: note: in definition of macro 'COUT'
   19 | #define COUT(x) cout<<(x)<<endl
      |                        ^
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll ans=0;
ll h,w;

void dfs(pll a,vvb &q,vstr s){
  if(s[a.F][a.S]=='.'){
    ans++;
  }
  q[a.F][a.S]=true;
  rep(i,4){
    ll nx=dx[i]+a.F;
    ll ny=dy[i]+a.S;
    if(nx>=0&&nx<h&&ny>=0&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&!q[nx][ny]){
      pll b=pll(nx,ny);
      dfs(b,q);
    }
  }
}
int main(){
  cin>>h>>w;
  vstr s(h);
  vector<pll> p(0);
  rep(i,h) cin>>s[i];
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'){
        p.pb(mp(i,j));
      }
    }
  }
  rep(i,sz(p)){
    vvb q(h,vb(w,false));
    dfs(p[i],q,s);
  }
  COUT(ans);
}


Compiler output:
a.cc: In function 'void dfs(pll, vvb&, vstr)':
a.cc:55:10: error: too few arguments to function 'void dfs(pll, vvb&, vstr)'
   55 |       dfs(b,q);
      |       ~~~^~~~~
a.cc:45:6: note: declared here
   45 | void dfs(pll a,vvb &q,vstr s){
      |      ^~~
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll ans=0; 
ll h,w;
vstr s(h);
vector<pll> p(0);
void dfs(pll a,vvb q){
  if(s[a.F][a.S]=='.'){
    ans++;
  }
  q[a.F][a.S]=true;
  rep(i,4){
    ll nx=dx[i]+a.F;
    ll ny=dy[i]+a.S;
    if(nx>=0&&nx<h&&ny>=0&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&!q[nx][ny]){
      pll b=mp(nx,ny);
      dfs(b);
    }
  }
}
int main(){
  cin>>h>>w;
  rep(i,h) cin>>s[i];
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'){
        p.pb(mp(i,j));
      }
    }
  }
  rep(i,sz(p)){
    vvb q(h,vb(w,false));
    dfs(p[i],q);
  }
  COUT(ans);
}


Compiler output:
a.cc: In function 'void dfs(pll, vvb)':
a.cc:56:10: error: too few arguments to function 'void dfs(pll, vvb)'
   56 |       dfs(b);
      |       ~~~^~~
a.cc:46:6: note: declared here
   46 | void dfs(pll a,vvb q){
      |      ^~~
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll ans=0; 
ll h,w;
vstr s(h);
vector<pll> p(0);
void dfs(pll a,vvb q){
  if(s[a.F][a.S]=='.'){
    ans++;
  }
  q[a.F][a.S]=trueiyc;
  rep(i,4){
    ll nx=dx[i]+a.F;
    ll ny=dy[i]+a.S;
    if(nx>=0&&nx<h&&ny>=0&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&!q[nx][ny]){
      pll b=mp(nx,ny);
      dfs(b);
    }
  }
}
int main(){
  cin>>h>>w;
  rep(i,h) cin>>s[i];
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'){
        p.pb(mp(i,j));
      }
    }
  }
  rep(i,sz(p)){
    vvb q(h,vb(w,false));
    dfs(p[i],q);
  }
  COUT(ans);
}


Compiler output:
a.cc: In function 'void dfs(pll, vvb)':
a.cc:50:15: error: 'trueiyc' was not declared in this scope; did you mean 'trunc'?
   50 |   q[a.F][a.S]=trueiyc;
      |               ^~~~~~~
      |               trunc
a.cc:56:10: error: too few arguments to function 'void dfs(pll, vvb)'
   56 |       dfs(b);
      |       ~~~^~~
a.cc:46:6: note: declared here
   46 | void dfs(pll a,vvb q){
      |      ^~~
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll ans=0; 
ll h,w;
vstr s(h);
vector<pll> p(0);
void dfs(pll a,vvb q){
  if(s[a.F][a.S]=='.'){
    ans++;
  }
  q[a.F][a.S]=trueiyc;
  rep(i,4){
    ll nx=dx[i]+a.F;
    ll ny=dy[i]+a.S;
    if(nx>=0&&nx<h&&ny>=0&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&!q[nx][ny]){
      pll b=mp(nx,ny);
      dfs(b);
    }
  }
}
int main(){
  cin>>h>>w;
  rep(i,h) cin>>s[i];
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'){
        p.pb(mp(i,j));
      }
    }
  }
  rep(i,sz(p)){
    vvb q(h,vb(w,false));
    dfs(p[i],q);
    t=tt;
  }
  COUT(ans);
}


Compiler output:
a.cc: In function 'void dfs(pll, vvb)':
a.cc:50:15: error: 'trueiyc' was not declared in this scope; did you mean 'trunc'?
   50 |   q[a.F][a.S]=trueiyc;
      |               ^~~~~~~
      |               trunc
a.cc:56:10: error: too few arguments to function 'void dfs(pll, vvb)'
   56 |       dfs(b);
      |       ~~~^~~
a.cc:46:6: note: declared here
   46 | void dfs(pll a,vvb q){
      |      ^~~
a.cc: In function 'int main()':
a.cc:73:5: error: 't' was not declared in this scope
   73 |     t=tt;
      |     ^
a.cc:73:7: error: 'tt' was not declared in this scope; did you mean 'tm'?
   73 |     t=tt;
      |       ^~
      |       tm
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll ans=0; 
ll h,w;
vstr s(h);
vvll t(h,vll(w,1));
vector<pll> p(0);
void dfs(pll a){
  if(s[a.F][a.S]=='.'){
    ans++;
  }
  t[a.F][a.S]=0;
  rep(i,4){
    ll nx=dx[i]+a.F;
    ll ny=dy[i]+a.S;
    if(nx>=0&&nx<h&&ny>=&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&t[nx][ny]){
      pll b=mp(nx,ny);
      dfs(b);
    }
  }
}

int main(){
  cin>>h>>w;
  rep(i,h) cin>>s[i];
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'){
        p.pb(mp(i,j));
      }
    }
  }
  vvll tt(h,vll(w,1));
  rep(i,sz(p)){
    dfs(p[i]);
    t=tt;
  }
  COUT(ans);
}


Compiler output:
a.cc: In function 'void dfs(pll)':
a.cc:55:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   55 |     if(nx>=0&&nx<h&&ny>=&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&t[nx][ny]){
      |                     ~~^~~~~~
a.cc:55:27: error: label 'ny' used but not defined
   55 |     if(nx>=0&&nx<h&&ny>=&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&t[nx][ny]){
      |                           ^~
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll ans=0; 
ll h,w;
vstr s(h);
vvll t(h,vll(w,1));
vector<pll> p(0);
void dfs(pll a){
  if(s[a.F][a.S]=='.'){
    ans++;
  }
  t[a.F][a.S]=0;
  rep(i,4){
    ll nx=dx+a.F;
    ll ny=dy+a.S;
    if(nx>=0&&nx<h&&ny>=&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&t[nx][ny]){
      pll b=mp(nx,ny);
      dfs(b);
    }
  }
}

int main(){
  cin>>h>>w;
  rep(i,h) cin>>s[i];
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'){
        p.pb(mp(i,j));
      }
    }
  }
  vvll tt(h,vll(w,1));
  rep(i,sz(p)){
    dfs(p[i]);
    t=tt;
  }
  COUT(ans);
}


Compiler output:
a.cc: In function 'void dfs(pll)':
a.cc:53:13: error: invalid conversion from 'long long int*' to 'long long int' [-fpermissive]
   53 |     ll nx=dx+a.F;
      |             ^
      |             |
      |             long long int*
a.cc:54:13: error: invalid conversion from 'long long int*' to 'long long int' [-fpermissive]
   54 |     ll ny=dy+a.S;
      |             ^
      |             |
      |             long long int*
a.cc:55:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   55 |     if(nx>=0&&nx<h&&ny>=&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&t[nx][ny]){
      |                     ~~^~~~~~
a.cc:55:27: error: label 'ny' used but not defined
   55 |     if(nx>=0&&nx<h&&ny>=&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&t[nx][ny]){
      |                           ^~
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll ans=0; 
ll h,w;
vstr s(h);
vvll t(h,vll(w,1));
vector<pll> p(0);
void dfs(pll a){
  if(s[a.F][a.S]=='.'){
    ans++;
  }
  t[nx][ny]=0;
  rep(i,4){
    ll nx=dx+a.F;
    ll ny=dy+a.S;
    if(nx>=0&&nx<h&&ny>=&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&t[nx][ny]){
      pll b=mp(nx,ny);
      dfs(b);
    }
  }
}

int main(){
  cin>>h>>w;
  rep(i,h) cin>>s[i];
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'){
        p.pb(mp(i,j));
      }
    }
  }
  vvll tt(h,vll(w,1));
  rep(i,sz(p)){
    dfs(p[i]);
    t=tt;
  }
  COUT(ans);
}

Compiler output:
a.cc: In function 'void dfs(pll)':
a.cc:51:5: error: 'nx' was not declared in this scope; did you mean 'dx'?
   51 |   t[nx][ny]=0;
      |     ^~
      |     dx
a.cc:51:9: error: 'ny' was not declared in this scope; did you mean 'yn'?
   51 |   t[nx][ny]=0;
      |         ^~
      |         yn
a.cc:53:13: error: invalid conversion from 'long long int*' to 'long long int' [-fpermissive]
   53 |     ll nx=dx+a.F;
      |             ^
      |             |
      |             long long int*
a.cc:54:13: error: invalid conversion from 'long long int*' to 'long long int' [-fpermissive]
   54 |     ll ny=dy+a.S;
      |             ^
      |             |
      |             long long int*
a.cc:55:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   55 |     if(nx>=0&&nx<h&&ny>=&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&t[nx][ny]){
      |                     ~~^~~~~~
a.cc:55:27: error: label 'ny' used but not defined
   55 |     if(nx>=0&&nx<h&&ny>=&&ny<w&&s[nx][ny]!=s[a.F][a.S]&&t[nx][ny]){
      |                           ^~
Language: C++

#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<int,int> P;
 #include <boost/multiprecision/cpp_int.hpp>

using bint = boost::multiprecision::cpp_int;
 
vector<vector<int>> hw(800,vector<int>(800));
vector<vector<int>> visited(800,vector<int>(800));

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int ans1 = 0;
int ans2 = 0;
void dfs(P v, P p, int h, int w){
    rep(i,4){
        int nx = v.first + dx[i];
        int ny = v.second + dy[i];
        if (nx == p.first && ny == p.second) continue;
        if (nx>=0 && nx < h && ny >= 0 && ny < w && visited[nx][ny] == 0){
            if (hw[nx][ny] != hw[v.first][v.second]){
                visited[nx][ny] = 1;
                if(hw[nx][ny] == 0) ans1++;
                else ans2++;
                dfs(mp(nx,ny),v,h,w);
            }
            
        }
    }
}

int main(){
    int h,w;
    cin >> h >> w;
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w){
            if (s[j] == '.') hw[i][j] = 0;
            else hw[i][j] = 1;
        }
    }
    


    bint res = 0;
    rep(i,h)rep(j,w){
        if(hw[i][j] == 1 && visited[i][j] == 0){
            ans1 = 0;
            ans2 = 1;
            visited[i][j] = 1;
            dfs(mp(i,j),mp(-1,-1),h,w);
            bint += (ll) ans1*ans2;
            
        }
    }
    cout << res;
}

Compiler output:
a.cc:33:11: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
   33 |  #include <boost/multiprecision/cpp_int.hpp>
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: Java

import java.util.*;

class UnionFind {
	int[] roots;
	int[] sameSetCnt;
	
	public UnionFind(int N) {
		roots = new int[N];
		sameSetCnt = new int[N];
		for(int i = 0; i < N; ++i) {
			roots[i] = i;
			sameSetCnt[i] = 1;
		}
	}
	
	int getRoot(int x) {
		if(roots[x] == x) return x;
		else return roots[x] = getRoot(roots[x]);
	}
	
	boolean isSameSet(int x, int y) {
		return getRoot(x) == getRoot(y);
	}
	
	void unite(int x, int y) {
		int rx = getRoot(x);
		int ry = getRoot(y);
		if(rx == ry) return;
		
		if(sameSetCnt[rx] < sameSetCnt[ry]) {
			int tmp = rx;
			rx = ry;
			ry = tmp;
		}
		sameSetCnt[rx] += sameSetCnt[ry];
		roots[ry] = rx;
	}
	
	int getSameSetNum(int i) {
		return sameSetCnt[getRoot(i)];
	}
}

public class C {
	static Scanner sc = new Scanner(System.in);
	static int h = 0;
	static int w = 0;
	static char[][] grids = null;
	static boolean[][] hasVisited = null;
	static int[][] bnum = null;
	static UnionFind uf = null;
	static int[] dy = {-1, 1, 0, 0};
	static int[] dx = {0, 0, -1, 1};
	
	public static void main(String[] args) {
		h = sc.nextInt();
		w = sc.nextInt();
		grids = new char[h][w];
		hasVisited = new boolean[h][w];
		for(int i = 0; i < h; ++i) grids[i] = sc.next().toCharArray();
		
		uf = new UnionFind(h * w);
		bnum = new int[h][w];
		// 黒と白が隣接する各箇所に辺を張る
		for(int y = 0; y < h; ++y) {
			for(int x = 0; x < w; ++x) {
				dfs(y, x);
			}
		}
		
		// 各連結成分について選ぶ組み合わせの数を足していく
		long ans = 0;
		for(int i = 0; i < h * w; ++i) {
			if(uf.getRoot(i) == i) {
				int bn = bnum[i / w][i - i / w * w];
				int wn = uf.getSameSetNum(i) - bn;
				ans += 1L * bn * wn;
			}
		}
		System.out.println(ans);
	}
	
	static boolean isOutside(int y, int x) {
		return y < 0 || h <= y || x < 0 || w <= x;
	}
	
	static void dfs(int sy, int sx) {
		// 訪問済みなら何もせず終了
		if(hasVisited[sy][sx]) return;
		
		// 自身のマスに訪問済みの印をつける
		hasVisited[sy][sx] = true;
		
		// 自身のマスの色
		char self = grids[sy][sx];
		
		// 黒マスならば連結成分の根のカウントを1増やす
		if(self == '#') {
			int ufRootIndex = uf.getRoot(w * sy + sx);
			++bnum[ufRootIndex / w][ufRootIndex - ufRootIndex / w * w];
		}
		
		// 上下左右のマスを見る
		for(int i = 0; i < 4; ++i) {
			int oy = sy + dy[i];
			int ox = sx + dx[i];
			
			// 範囲外ならばスキップ
			if(isOutside(oy, ox)) continue;
			
			// 相手のマスの色
			char other = grids[oy][ox];
			if(self != other) {
				// 自身と相手の色が異なれば辺を張る
				int selfIndex = w * sy + sx;
				int otherIndex = w * oy + ox;
				uf.unite(selfIndex, otherIndex);
				
				// 相手のマスに関してDFS
				dfs(oy, ox);
			}
		}
	}
}

Compiler output:
Main.java:44: error: class C is public, should be declared in a file named C.java
public class C {
       ^
1 error
Language: Java

import java.util.*;

class UnionFind {
	int[] roots;
	int[] sameSetCnt;
	
	public UnionFind(int N) {
		roots = new int[N];
		sameSetCnt = new int[N];
		for(int i = 0; i < N; ++i) {
			roots[i] = i;
			sameSetCnt[i] = 1;
		}
	}
	
	int getRoot(int x) {
		if(roots[x] == x) return x;
		else return roots[x] = getRoot(roots[x]);
	}
	
	boolean isSameSet(int x, int y) {
		return getRoot(x) == getRoot(y);
	}
	
	void unite(int x, int y) {
		int rx = getRoot(x);
		int ry = getRoot(y);
		if(rx == ry) return;
		
		if(sameSetCnt[rx] < sameSetCnt[ry]) {
			int tmp = rx;
			rx = ry;
			ry = tmp;
		}
		sameSetCnt[rx] += sameSetCnt[ry];
		roots[ry] = rx;
	}
	
	int getSameSetNum(int i) {
		return sameSetCnt[getRoot(i)];
	}
}

public class C {
	static Scanner sc = new Scanner(System.in);
	static int h = 0;
	static int w = 0;
	static char[][] grids = null;
	static boolean[][] hasVisited = null;
	static UnionFind uf = null;
	static int[] dy = {-1, 1, 0, 0};
	static int[] dx = {0, 0, -1, 1};
	
	public static void main(String[] args) {
		h = sc.nextInt();
		w = sc.nextInt();
		grids = new char[h][w];
		hasVisited = new boolean[h][w];
		for(int i = 0; i < h; ++i) grids[i] = sc.next().toCharArray();
		
		uf = new UnionFind(h * w);
		// 黒と白が隣接する各箇所に辺を張る
		for(int y = 0; y < h; ++y) {
			for(int x = 0; x < w; ++x) {
				dfs(y, x);
			}
		}
		
		int[][] bnum = new int[h][w];
		// 各連結成分について黒の数を数える
		for(int y = 0; y < h; ++y) {
			for(int x = 0; x < w; ++x) {
				if(grids[y][x] == '#') {
					int ufRootIndex = uf.getRoot(w * y + x);
					++bnum[ufRootIndex / w][ufRootIndex - ufRootIndex / w * w];
				}
			}
		}
		
		// 各連結成分について選ぶ組み合わせの数を足していく
		long ans = 0;
		for(int i = 0; i < h * w; ++i) {
			if(uf.getRoot(i) == i) {
				int bn = bnum[i / w][i - i / w * w];
				int wn = uf.getSameSetNum(i) - bn;
				ans += 1L * bn * wn;
			}
		}
		System.out.println(ans);
	}
	
	static boolean isOutside(int y, int x) {
		return y < 0 || h <= y || x < 0 || w <= x;
	}
	
	static void dfs(int sy, int sx) {
		// 訪問済みなら何もせず終了
		if(hasVisited[sy][sx]) return;
		
		// 自身のマスに訪問済みの印をつける
		hasVisited[sy][sx] = true;
		
		// 自身のマスの色
		char self = grids[sy][sx];
		
		// 上下左右のマスを見る
		for(int i = 0; i < 4; ++i) {
			int oy = sy + dy[i];
			int ox = sx + dx[i];
			
			// 範囲外ならばスキップ
			if(isOutside(oy, ox)) continue;
			
			// 相手のマスの色
			char other = grids[oy][ox];
			if(self != other) {
				// 自身と相手の色が異なれば辺を張る
				int selfIndex = w * sy + sx;
				int otherIndex = w * oy + ox;
				uf.unite(selfIndex, otherIndex);
				
				// 相手のマスに関してDFS
				dfs(oy, ox);
			}
		}
	}
}

Compiler output:
Main.java:44: error: class C is public, should be declared in a file named C.java
public class C {
       ^
1 error
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

int h, w;
vector<vector<char>> field;
vector<vector<bool>> used;
int cnt;

void dfs(int x, int y, char c) {
    used[x][y] = true;
    cnt ++;
    rep(i, 4) {
        int nx = x + dx[i], ny = y + dy[i];
        char d = (c == '#'? '.': '#');
        if(0 <= nx && nx < h && 0 <= ny && ny < w && field[nx][ny] == d && !used[i][j]) {
            dfs(nx, ny, d);
        }
    }
}

void solve() {
	cin >> h >> w;
    field.assign(h, vector<char>(w));
    used.assign(h, vector<bool>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> field[i][j];
            used[i][j] = false;
        }
    }
    int ans = 0;
    rep(i, h) {
        rep(j, w) {
            cnt = 0;
            if(!used[i][j]) {
                dfs(i, j, field[i][j]);
            }
            ans += cnt * (cnt - 1) / 2;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(long long int, long long int, char)':
a.cc:65:85: error: 'j' was not declared in this scope
   65 |         if(0 <= nx && nx < h && 0 <= ny && ny < w && field[nx][ny] == d && !used[i][j]) {
      |                                                                                     ^
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

int h, w;
vector<vector<char>> field;
vector<vector<bool>> used;
int cnt;

void dfs(int x, int y, char c) {
    used[x][y] = true;
    cnt ++;
    rep(i, 4) {
        int nx = x + dx[i], ny = y + dy[i];
        char d = (c == '#'? '.': '#');
        if(0 <= nx && nx < h && 0 <= ny && ny < w && field[nx][ny] == d) {
            dfs(nx, ny, d);
        }
    }
}

void solve() {
	cin >> h >> w;
    field.assign(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> field[i][j];
            used[i][j] = false;
        }
    }
    int ans = 0;
    rep(i, h) {
        rep(i, w) {
            cnt = 0;
            if(!used[i][j]) {
                dfs(i, j, field[i][j]);
            }
            ans += cnt * (cnt - 1) / 2;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:84:25: error: 'j' was not declared in this scope
   84 |             if(!used[i][j]) {
      |                         ^