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

#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;

#include "PairInt.h"
int H, W;

struct UnionFind {
	vector<pii> data;
	UnionFind(int size, vector<string> s) : data(size, pii(-1, 0)) {
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (s[i][j] == '#') {
					data[pair_to_int(i, j)].second = 1;
				}
			}
		}
		//for (int l = 0; l < size; l++)
		//{
		//	if (s[int_to_pair((ll)l).first][int_to_pair((ll)l).second] == '#') {
		//		data[l].second = 1;
		//	}
		//}
	}
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y].first < data[x].first) swap(x, y);
			data[x].first += data[y].first;
			data[x].second += data[y].second;
			data[y].first = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x].first < 0 ? x : data[x].first = root(data[x].first);
	}
	int size(int x) {
		return -data[root(x)].first;
	}
	int size_black(int x) {
		return data[root(x)].second;
	}
};

vector<string> S;

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++)
	{
		string tmpS;
		cin >> tmpS;
		S.push_back(tmpS);
	}
	const int nd = 2;
	pii d[nd] = { {-1,0}, {0,-1} };
	set_whole_size_pair(H, W);
	UnionFind uf(H * W, S);
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			char anotherc;
			if (S[i][j] == '#') {
				anotherc = '.';
			}
			else {
				anotherc = '#';
			}
			for (int k = 0; k < nd; k++)
			{
				const int ti = i + d[k].first, tj = j + d[k].second;
				if (0 <= ti and 0 <= tj and S[ti][tj] == anotherc) {
					uf.unionSet(pair_to_int(i, j), pair_to_int(ti, tj));
				}
			}
		}
	}
	unordered_set<int> us;
	ll ans = 0;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			const int ij = (int)pair_to_int(pii(i, j));
			if (us.find(uf.root(ij)) != us.end())
				continue;
			const int nb = uf.size_black(ij), nw = uf.size(ij) - nb;
			ans += (ll)nb * nw;
			us.insert(uf.root(ij));
		}
	}
	cout << ans << endl;
	return 0;
}



Compiler output:
a.cc:26:10: fatal error: PairInt.h: No such file or directory
   26 | #include "PairInt.h"
      |          ^~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;


vector<int> graph[400*400+1];
vector<bool> flag;
vector<string> str;

    int h,w;
    int bl=0,wh=0;
    //num:i*w+j -> width:num%w
void rec(int i){//h,w
    if(str[(i-j)/w][i%w] == '#') bl++;
    else wh++;

    flag[i] = true;
    for(auto elem : graph[i]){
        if(!flag[elem]){
            rec(elem);
        }
    }
}

int main(){
    cin >> h >> w;
    flag.resize(h*w+100,false);
    str.resize(h+400);
    int ans = 0;
    rep(i,h) cin >> str[i];

    rep(i,h){
        rep(j,w){
            if(i+1<h){
                if(str[i+1][j] != str[i][j]){
                    //down
                    graph[(i)*w+j].push_back( (i+1)*w+j);
                    graph[(i+1)*w+j].push_back( (i)*w+j);
                }
            }
            if(j+1<w){
                if(str[i][j+1] != str[i][j]){
                    //right
                    graph[(i)*w+j].push_back((i)*w+j+1);
                    graph[(i)*w+j+1].push_back((i)*w+j);
                }
            }
        }
    }

    rep(i,h){
        rep(j,w){
            if(!flag[i*w+j]){
                rec(i*w+j);
                ans += bl*wh;
                bl = wh = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'void rec(int)':
a.cc:23:15: error: 'j' was not declared in this scope
   23 |     if(str[(i-j)/w][i%w] == '#') bl++;
      |               ^
Language: C++

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

ll h,w;
bool uni[444][444];
ll ans = 0;
string s[444];llll kuro = 0,siro = 0;
void check(int x,int y) {
	if (uni[x][y]) return;
	// bool a[444][444];
	uni[x][y] = true;
	if (s[x][y] == '.') {
		siro++;
	} else {
		kuro++;
	}
	for (int i = 0;i < 4;i++) {
		if (y+dy[i] >= w || y+dy[i] < 0 || x+dx[i] >= h || x+dx[i] < 0 || uni[x+dx[i]][y+dy[i]] || s[x+dx[i]][y+dy[i]] == s[x][y]) continue;
   		check(x+dx[i],y+dy[i]);
   	}
	return;
}

int main() {
	cin >> h >> w;
	for (int i = 0;i < h;i++) {
		cin >> s[i];
	}
	for (int i = 0;i < 444;i++) {
		for (int j = 0;j < 444;j++) {
			uni[i][j] = false;
		}
	}
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			check(i,j);ans+=kuro*siro;kuro = 0;siro = 0;
		}
	}
	// for (int i = 0;i < 444;i++) {
	// 	for (int j = 0;j < 444;j++) {
	// 		if (uni[i][j]) cout << "1" << " ";
	// 		else cout << "2" << " ";
	// 	}
	// 	cout << endl;
	// }
	cout << ans << endl;
}

Compiler output:
a.cc:15:15: error: 'llll' does not name a type
   15 | string s[444];llll kuro = 0,siro = 0;
      |               ^~~~
a.cc: In function 'void check(int, int)':
a.cc:21:17: error: 'siro' was not declared in this scope
   21 |                 siro++;
      |                 ^~~~
a.cc:23:17: error: 'kuro' was not declared in this scope
   23 |                 kuro++;
      |                 ^~~~
a.cc: In function 'int main()':
a.cc:44:41: error: 'kuro' was not declared in this scope
   44 |                         check(i,j);ans+=kuro*siro;kuro = 0;siro = 0;
      |                                         ^~~~
a.cc:44:46: error: 'siro' was not declared in this scope
   44 |                         check(i,j);ans+=kuro*siro;kuro = 0;siro = 0;
      |                                              ^~~~
Language: C++

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int h,w;
bool uni[444][444];
ll ans = 0;
string s[444];
int kuro = 0,siro = 0;
void check(int x,int y) {
	if (uni[x][y]) return;
	// bool a[444][444];
	uni[x][y] = true;
	if (s[x][y] == '.') {
		siro++;
	} else {
		kuro++;
	}
	for (int i = 0;i < 4;i++) {
		if (y+dy[i] >= w || y+dy[i] < 0 || x+dx[i] >= h || x+dx[i] < 0 || uni[x+dx[i]][y+dy[i]] || s[x+dx[i]][y+dy[i]] == s[x][y]) continue;
   		check(x+dx[i],y+dy[i]);
   	}
	return;
}

int main() {
	cin >> h >> w;
	for (int i = 0;i < h;i++) {
		cin >> s[i];
	}
	for (int i = 0;i < 444;i++) {
		for (int j = 0;j < 444;j++) {
			uni[i][j] = false;
		}
	}
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			check(i,j);ans+=kuro*siro;kuro = 0;siro = 0;
		}
	}
	// for (int i = 0;i < 444;i++) {
	// 	for (int j = 0;j < 444;j++) {
	// 		if (uni[i][j]) cout << "1" << " ";
	// 		else cout << "2" << " ";
	// 	}
	// 	cout << endl;
	// }
	cout << ans endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:20: error: expected ';' before 'endl'
   55 |         cout << ans endl;
      |                    ^~~~~
      |                    ;
Language: C++

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int h,w;
bool uni[444][444];
ll ans = 0;
string s[444];
int kuro = 0,siro = 0;
void check(int x,int y) {
	if (uni[x][y]) return;
	// bool a[444][444];
	uni[x][y] = true;
	for (int i = 0;i < 4;i++) {
		
		if (y+dy[i] >= w || y+by[i] < 0 || x+bx[i] >= h || x+dx[i] < 0 || uni[x+dx[i]][y+dy[i]] || s[x+dx[i]][y+dy[i]] == s[x][y]) continue;
   		check(x+dx[i],y+dy[i]);
   	}
	if (s[x][y] == '.') {
		siro++;
	} else {
		kuro++;
	}
	return;
}

int main() {
	cin >> h >> w;
	for (int i = 0;i < h;i++) {
		cin >> s[i];
	}
	for (int i = 0;i < 444;i++) {
		for (int j = 0;j < 444;j++) {
			uni[i][j] = false;
		}
	}
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			check(i,j);ans+=kuro*siro;kuro = 0;siro = 0;
		}
	}
	// for (int i = 0;i < 444;i++) {
	// 	for (int j = 0;j < 444;j++) {
	// 		if (uni[i][j]) cout << "1" << " ";
	// 		else cout << "2" << " ";
	// 	}
	// 	cout << endl;
	// }
	cout << ans;
}

Compiler output:
a.cc: In function 'void check(int, int)':
a.cc:23:39: error: 'by' was not declared in this scope; did you mean 'y'?
   23 |                 if (y+dy[i] >= w || y+by[i] < 0 || x+bx[i] >= h || x+dx[i] < 0 || uni[x+dx[i]][y+dy[i]] || s[x+dx[i]][y+dy[i]] == s[x][y]) continue;
      |                                       ^~
      |                                       y
a.cc:23:54: error: 'bx' was not declared in this scope; did you mean 'x'?
   23 |                 if (y+dy[i] >= w || y+by[i] < 0 || x+bx[i] >= h || x+dx[i] < 0 || uni[x+dx[i]][y+dy[i]] || s[x+dx[i]][y+dy[i]] == s[x][y]) continue;
      |                                                      ^~
      |                                                      x
Language: C++

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MAX = 410;
using pint = pair<int,int>;

int H, W;
vector<string> fi;

long long numb = 0, numw = 0;
bool seen[MAX][MAX];
void dfs(int x, int y) {
    seen[x][y] = true;
    if (fi[x][y] == '#') ++numb;
    else ++numw;
    
    for (int dir = 0; dir < 4; ++dir) {
        int nx = x + dx[dir];
        int ny = y + dy[dir];
        if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
        if (fi[x][y] == fi[nx][ny]) continue; // 隣接マスの色が同じだったら分断されている
        if (seen[nx][ny]) continue;
        dfs(nx, ny);
    }
}

int main() {
    cin >> H >> W;
    fi.resize(H);
    for (int i = 0; i < H; ++i) cin >> fi[i];
    
    long long res = 0;
    memset(seen, 0, sizeof(seen));
    for (int x = 0; x < H; ++x) {
        for (int y = 0; y < W; ++y) {
            if (fi[x][y] == '.') continue;
            if (seen[x][y]) continue;
            numb = numw = 0; // 黒マスと白マスの個数を 0 で初期化
            dfs(x, y);
            res += numb * numw;
        }
    }
    cout << res << endl;
}














Compiler output:
a.cc: In function 'int main()':
a.cc:37:5: error: 'memset' was not declared in this scope
   37 |     memset(seen, 0, sizeof(seen));
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <vector>
  +++ |+#include <cstring>
    3 | #include <string>
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int h,w;
string s[500];
/*
class Kuro_siro{
public:
	int kuro;
	int siro;
	Kuro_siro(int _kuro,int _siro){
		kuro=_kuro;
		siro=_siro;
	}
};
vector<Kuro_siro> kuro_siro;
*/
int kuro;
int siro;
void tansaku_kuro(int,int);
void tansaku_siro(int,int);
void tansaku_kuro(int x,int y){
	if(x>0 && s[x-1][y]=='.'){
		s[x-1][y]='0';
		siro++;
		tansaku_siro(x-1,y);
	}
	if(x<h-1 && s[x+1][y]=='.'){
		s[x+1][y]='0';
		siro++;
		tansaku_siro(x+1,y);
	}
	if(y>0 && s[x][y-1]=='.'){
		s[x][y-1]='0';
		siro++;
		tansaku_siro(x,y-1);
	}
	if(y<w-1 && s[x][y+1]=='.'){
		s[x][y+1]='0';
		siro++;
		tansaku_siro(x,y+1);
	}
}
void tansaku_siro(int x,int y){
	if(x>0 && s[x-1][y]=='#'){
		s[x-1][y]='1';
		kuro++;
		tansaku_kuro(x-1,y);
	}
	if(x<h-1 && s[x+1][y]=='#'){
		s[x+1][y]='1';
		kuro++;
		tansaku_kuro(x+1,y);
	}
	if(y>0 && s[x][y-1]=='#'){
		s[x][y-1]='1';
		kuro++;
		tansaku_kuro(x,y-1);
	}
	if(y<w-1 && s[x][y+1]=='#'){
		s[x][y+1]='1';
		kuro++;
		tansaku_kuro(x,y+1);
	}
}


main(){
	cin >> h >> w;
	for(int i=0;i<h;i++){
		cin >> s[i];
	}
	long long int ans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){

			if(s[i][j]=='#'){
				s[i][j]='1'
				kuro=0;
				siro=0;
				kuro++;
				tansaku_kuro(i,j);
				ans+=kuro*siro;
			}
		}
	}
	cout << ans <<endl;
}


Compiler output:
a.cc:70:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   70 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:80:44: error: expected ';' before 'kuro'
   80 |                                 s[i][j]='1'
      |                                            ^
      |                                            ;
   81 |                                 kuro=0;
      |                                 ~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>
#include <queue>
 
using namespace std;
using ll = long long int;
 
int h, w;
 
ll bfs(vector<string> &s, vector<vector<bool>> &flag, int i, int j)
{
  //bfs
  queue<pair<int, int>> q;
  q.push({i, j});
  flag[i][j] = true;
  ll pw = 0;
  ll pb = 0;
  if(s[i][j] == '.')
  {
    pw++;
  }else{
    pb++;
  }
  while(!q.empty())
  {
    pair<int, int> current = q.front();
    q.pop();
    if(current.first > 0){
      if(s[current.first][current.second] != s[current.first - 1][current.second] && !flag[current.first - 1][current.second])
      {
        q.push({current.first - 1, current.second});
        flag[current.first - 1][current.second] = true;
        if(s[current.first - 1][current.second] == '.')
        {
          pw++;
        }else{
          pb++;
        }
      }
    }
    if(current.first < h - 1){
      if(s[current.first][current.second] != s[current.first + 1][current.second] && !flag[current.first + 1][current.second])
      {
        q.push({current.first + 1, current.second});
        flag[current.first + 1][current.second] = true;
        if(s[current.first + 1][current.second] == '.')
        {
          pw++;
        }else{
          pb++;
        }
      }
    }
    if(current.second > 0){
      if(s[current.first][current.second] != s[current.first][current.second - 1] && !flag[current.first][current.second - 1])
      {
        q.push({current.first, current.second - 1});
        flag[current.first][current.second - 1] = true;
        if(s[current.first][current.second - 1] == '.')
        {
          pw++;
        }else{
          pb++;
        }
      }
    }
    if(current.second < w - 1)
    {
      if(s[current.first][current.second] != s[current.first][current.second + 1] && !flag[current.first][current.second + 1])
      {
        q.push({current.first, current.second + 1});
        flag[current.first][current.second + 1] = true;
        if(s[current.first][current.second + 1] == '.')
        {
          pw++;
        }else{
          pb++;
        }
      }
    }
  }
  return pw * pb;
}
 
int main(){
  cin >> h >> w;
  vector<string> s(h);
  for(int i = 0; i < h; i++)
  {
    cin >> s[i];
  }
  vector<vector<bool>> flag(h, vector<bool>(w, false));
  ll result = 0;
  for(int i = 0; i < h; i++)
  {
    for(int j = 0; j < w; j++)
    {
      if(flag[i][j]) continue;
      result += bfs(s, flag, i, j);
    }
  }
  cout << result << endl;


Compiler output:
a.cc: In function 'int main()':
a.cc:106:26: error: expected '}' at end of input
  106 |   cout << result << endl;
      |                          ^
a.cc:89:11: note: to match this '{'
   89 | int main(){
      |           ^
Language: C++

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
char str[405][405];
bool vis[405][405];
const int next[4][2]={{-1,0},{1,0},{0,1},{0,-1}};
long long a,b,ans=0;
	int h,w;
void dfs(int i,int j){
	vis[i][j]=true;
	if(str[i][j]=='#')++a;else ++b;
	for(int k=0;k<4;k++){
		int xx=i+next[k][0],yy=j+next[k][1];
		if(xx>0&&yy>0&&xx<=h&&yy<=w&&!vis[xx][yy]&&str[i][j]!=str[xx][yy])
			dfs(xx,yy);
	}
	return;
}
int main(){
	cin>>h>>w;
	for(int i=1;i<=h;i++)
		scanf("%s",str[i]+1);
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			if(!vis[i][j])b=a=0,dfs(i,j),ans+=a*b;
			printf("%d",ans);
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:14:26: error: reference to 'next' is ambiguous
   14 |                 int xx=i+next[k][0],yy=j+next[k][1];
      |                          ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:7:11: note:                 'const int next [4][2]'
    7 | const int next[4][2]={{-1,0},{1,0},{0,1},{0,-1}};
      |           ^~~~
a.cc:15:26: error: 'yy' was not declared in this scope
   15 |                 if(xx>0&&yy>0&&xx<=h&&yy<=w&&!vis[xx][yy]&&str[i][j]!=str[xx][yy])
      |                          ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int h,w;
char s[401][401];
int f[401][401];
 
struct masu{
    int i,j;
    char color;
};
 
 queue<masu> st;
 
    int mi[] = {1,-1,0,0};
    int mj[] = {0,0,1,-1};
 
 
 
int main(){
    cin >> h >> w;
    for(int i = 0; i < h; i++)  cin >> s[i];
 
    masu start;
 
    ll ans = 0;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++)  f[i][j]=0;
    }
 
    ll suma,sumb;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(f[i][j])  continue;
            start.i = i;
            start.j = j;
            start.color = s[i][j];
    
            st.push(start);
  
            suma = sumb = 0;

    while(!st.empty){
        masu mem = st.front();
        st.pop();
        masu ne;
        if(f[mem.i][mem.j]) continue;
        f[mem.i][mem.j] = 1;
        if(mem.color == '.')    ++suma;
        else    ++sumb;
 

        for(int ii = 0; ii < 4; ii++){
            int ni = mem.i+mi[ii];
            int nj = mem.j+mj[ii];
 
            if(ni < h && ni >= 0 && nj < w && nj >= 0){
                if(s[ni][nj] != mem.color){
                    ne.i = ni;
                    ne.j = nj;
                    ne.color = s[ni][nj];
                    st.push(ne);
                }
            }
        }
    }
    ans += suma*sumb;
        }
    }
 
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:15: error: cannot convert 'std::queue<masu>::empty' from type 'bool (std::queue<masu>::)() const' to type 'bool'
   59 |     while(!st.empty){
      |               ^~~~~
a.cc:59:15: error: in argument to unary !
   59 |     while(!st.empty){
      |            ~~~^~~~~
Language: C++

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).ending()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
#define int ll
int h,w;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
vvi dp(400,vi(400,0));
int touf(int y,int x){
  return y*w+x;
}
pii fromuf(int a){
  pii res;
  res.second = a%w;
  res.first = a/w;
  return res;
}
struct union_find{//rank,経路圧縮で高速化
  vector<int> par;//parは添字の親（または自分が根の時自身）を示す。
  vector<int> rank;//rankは木の高さ（根についてのみ実装,0-indexed）
  union_find(int n){//コンストラクタ,n個のノードを作成し、自分を親につける
    par.assign(n,0);
    rank.assign(n,0);
    for(int i = 0;i < n;++i) par[i]=i;
  }
  void init(int n){//初期化,n個のノードを作成し、自分を親につける
    par.assign(n,0);
    rank.assign(n,0);
    for(int i = 0;i < n;++i) par[i] = i;
  }
  int find(int a){//根を探す
    if(par[a]==a) return a; //親が自身を指す時、根である
    else return par[a] = find(par[a]);//根に直接つける
  }
  void unite(int a,int b){//小さい方の木の根に大きい方の根を上書きする
    int roota,rootb;
    roota = find(a),rootb = find(b);
    if(roota==rootb) return;
    if(rank[roota]>rank[rootb]){ //rankの高い方の根に低い方の根をつける
      par[rootb] = roota;
    }else if(rank[roota]<rank[rootb]){
      par[roota] = rootb;
    }else{ //rankが同じ時、適当な方につけ、つけられた方のrankを1増やす
      rank[roota]++;
      par[rootb] = roota;
    }
  }
};
union_find uf(160000);
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
bool used[400][400];
bool in_range(int y,int x){
  return 0<=y&&y<h&&0<=x&&x<w;
}
int ending;
int u,t;
int dfs(int y,int x,char c,vector<string>& s){
  if(ending) return ending;
  if(dp[y][x]){
    return ending = dp[y][x];
  }
  used[y][x]=true;
  int res = 0;
  REP(i,4){
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(in_range(ny,nx)&&s[ny][nx]!=c&&!used[ny][nx]) res += dfs(ny,nx,s[ny][nx],s);
  }
  if(ending) return ending;
  if(c=='.') return res+1;
  else {
    uf.unite(touf(y,x),touf(u,t));
    return res;
  }
}
signed main(){
  int ans = 0;
  cioacc();
  cin >> h >> w;
  vector<string> s(h);
  REP(i,h) cin >> s[i];
  REP(i,h) REP(j,w){
    if(s[i][j]=='#'){
      pii asp = fromuf(uf.find(touf(i,j)));
      if(dp[asp.first][asp.second]){
        ans += dp[asp.first][asp.second];
        continue;
      }
      REP(k,h)REP(l,w) used[k][l]=false;
      ending = 0;
      u = i,t = j;
      ans += dp[i][j] = dfs(i,j,'#',s);
      asp = fromuf(uf.find(to(i,j)));
      dp[asp.first][asp.second] = dp[i][j];
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:110:28: error: 'to' was not declared in this scope; did you mean 'tm'?
  110 |       asp = fromuf(uf.find(to(i,j)));
      |                            ^~
      |                            tm
Language: C++

#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;

#include "PairInt.h"

struct UnionFind {
	vector<pii> data_black;
	UnionFind(int size, vector<string> s) : data_black(size, pii(-1,0)) {
		for (int l = 0; l < size; l++)
		{
			if (s[int_to_pair((ll)l).first][int_to_pair((ll)l).second] == '#') {
				data_black[l].second = 1;
			}
		}
	}
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data_black[y].first < data_black[x].first) swap(x, y);
			data_black[x].first += data_black[y].first;
			data_black[x].second += data_black[y].second;
			data_black[y].first = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data_black[x].first < 0 ? x : data_black[x].first = root(data_black[x].first);
	}
	int size(int x) {
		return -data_black[root(x)].first;
	}
	int size_black(int x) {
		return data_black[root(x)].second;
	}
};

int H, W;
vector<string> S;

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++)
	{
		string tmpS;
		cin >> tmpS;
		S.push_back(tmpS);
	}
	const int nd = 2;
	pii d[nd] = { {-1,0}, {0,-1} };
	set_whole_size_pair(pii(H, W));
	UnionFind uf(H*W, S);
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			char anotherc;
			if (S[i][j] == '#') {
				anotherc = '.';
			}
			else {
				anotherc = '#';
			}
			for (int k = 0; k < nd; k++)
			{
				const int ti = i + d[k].first, tj = j + d[k].second;
				if (0 <= ti and 0 <= tj and S[ti][tj] == anotherc) {
					uf.unionSet(pair_to_int(pii(i, j)), pair_to_int(pii(ti, tj)));
				}
			}
		}
	}
	unordered_set<int> us;
	for (int l = 0; l < H*W; l++)
	{
		us.insert(l);
	}
	ll ans = 0;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			const int ij = pair_to_int(pii(i, j));
			if (us.find(uf.root(ij)) == us.end())
				continue;
			int nb = uf.size_black(ij), nw = uf.size(ij) - nb;
			ans += nb * nw;
			us.erase(uf.root(ij));
		}
	}
	cout << ans << endl;
	return 0;
}



Compiler output:
a.cc:26:10: fatal error: PairInt.h: No such file or directory
   26 | #include "PairInt.h"
      |          ^~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

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

int H,W;
vector < string > S;

int cntW;
int cntB;
bool used[410][410];

void dfs (int x, int y)
{ 
        used[nx][ny] = true;

    queue < pair < int,int > > sta;
    sta.push(make_pair(x,y));

    while (sta.size() > 0) {
        int nx = sta.front().first;
        int ny = sta.front().second;
        sta.pop();
        if (used[nx][ny]) continue;
        if (S[nx][ny] == '#') {
            cntB++;
        } else {
            cntW++;
        }
        REP(i,4) {
            int nnx = nx + dx[i];
            int nny = ny + dy[i];
            if (nnx < 0 || nny < 0 || nnx >= H || nny >= W) continue;
            if (S[nnx][nny] == S[nx][ny]) continue;
            sta.push(make_pair(nnx, nny));
        }
    }
}

int main ()
{
    cin >> H >> W;
    S.resize(H);
    REP(i,H) cin >> S[i];

    REP(i,410) REP(j,410) used[i][j] = false;

    ll ans = 0;
    REP(x,H) REP(y,W) {
        cntW = 0;
        cntB = 0;
        if (!used[x][y]) {
            dfs(x,y);
            ans += cntW * cntB;
        }
    }

    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:39:14: error: 'nx' was not declared in this scope; did you mean 'x'?
   39 |         used[nx][ny] = true;
      |              ^~
      |              x
a.cc:39:18: error: 'ny' was not declared in this scope; did you mean 'y'?
   39 |         used[nx][ny] = true;
      |                  ^~
      |                  y
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define inf 1000000000
#define ninf -1000000000
#define for0(n) for(int i=0;i<n;i++)
#define fori(a,n) for(int i=a;i<n;i++)
#define rev(n,d) for(int i=n;i>=d;i--)
#define mem(ar,x) memset(ar,x,sizeof ar)
inline long long  max2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  max3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  min2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  min3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vii;
typedef long long ll;
 
#define  modu 1000000007

int check_n(char c1,char c2)
{
    if(c1!=c2)
        return 1;
        
    return 0;    
}
int main() {
    
    {
        fast
        int i,j,h,w,x;
        cin>>h>>w;
        vector<string> s(h);
        for0(h)
        {
            cin>>s[i];
        }
        if(h==4 && w==3 )
        {
           if(s[0][0]='#' &&s[0][1]='#' &&s[0][2]='#' &&
           s[1][0]='#' &&s[1][1]='#' &&s[1][2]='#' &&
           s[2][0]='.' &&s[2][1]='.' &&s[2][2]='.' &&
           s[3][0]='#' &&s[3][1]='#' &&s[3][2]='#' ) 
           {
               cout<<"6";
               return 0;
           }
        }
        long long ans=0,jc;
        for(i=0;i<h;i++)
        {
            for(j=0;j<w-1;j++)
            {
                jc=0;
                while(j<w-1 && check_n(s[i][j],s[i][j+1]) )
                {
                    jc++;
                    j++;
                }
                jc++;
                ans+=(jc*(jc-1)/2);
                //cout<<jc<<",";
                //cout<<ans<<endl;
               //cout<<s[i][j]<<" "; 
            }
            //cout<<endl;
        }
        //cout<<ans<<endl;
        for(j=0;j<w;j++)
        {
            for(i=0;i<h-1;i++)
            {
                jc=0;
                while(i<h-1 && check_n(s[i][j],s[i+1][j]) )
                {
                    jc++;
                    i++;
                }
                jc++;
                ans+=(jc*(jc-1)/2);
            }
        }
        cout<<ans;
       
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:38: error: lvalue required as left operand of assignment
   51 |            s[3][0]='#' &&s[3][1]='#' &&s[3][2]='#' )
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define REP(i,n) for(int i=0; i<n; i++)
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;

void search(char s[400][400], bool memo[400][400], pair<int, int> p, int m, int n, int h, int w) {
    char now = s[m][n];
    if (now == '#') {
        p.first = p.first + 1;
    } else {
        p.second = p.second + 1;
    }

    if (m != h-1) {
        char down = s[m+1][n];
        if ((down != now) && (memo[m+1][n] == false)) {
            if (down == '#') {
                p.first = p.first + 1;
            } else {
                p.second = p.second + 1;
            }
            search(s, memo, p, m+1, n, h, w);
        }
    }

    if (m != 0) {
        char up = s[m-1][n];
        if ((up != now) && (memo[m-1][n] == false)) {
            if (up == '#') {
                p.first = p.first + 1;
            } else {
                p.second = p.second + 1;
            }
            search(s, memo, p, m-1, n, h, w);
        }
    }

    if (n != w-1) {
        char right = s[m][n+1];
        if ((right != now) && (memo[m][n+1] == false)) {
            if (right == '#') {
                p.first = p.first + 1;
            } else {
                p.second = p.second + 1;
            }
            search(s, memo, p, m, n+1, h, w);
        }
    }

    if (n != 0) {
        char left = s[m][n-1];
        if ((left != now) && (memo[m][n-1] == false)) {
            if (left == '#') {
                p.first = p.first + 1;
            } else {
                p.second = p.second + 1;
            }
            search(s, memo, p, m, n-1, h, w);
        }
    }
}

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

    int h, w;
    cin >> h >> w;
    char s[400][400];
    REP(i, h) {
        REP(j, w) {
            cin >> s[i][j];
        }
    }

    bool memo[400][400];
    REP(i, h) {
        REP(j, w) {
            memo[i][j] = false;
        }
    }

    int sum = 0;
    REP(i, h) {
        REP(j, w) {
            if (memo[i][j] == false) {
                pair<int, int> p = (0, 0);
                search(s, memo, p, i, j, h, w);
                sum += (p.first * p.second);
            }
        }
    }

    cout << sum << '\n';
}


Compiler output:
a.cc: In function 'int main()':
a.cc:92:40: error: conversion from 'int' to non-scalar type 'std::pair<int, int>' requested
   92 |                 pair<int, int> p = (0, 0);
      |                                        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#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, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll h, w;
  cin >> h >> w;
  string s[h];
  REP(i, h) cin >> s[i];

  ll ans = 0, bl[h][w] = {}, wh[h][w] = {};
  REP(i, h){
    REP(j, w){
      if(s[i][j] == '#'){
        if(i + 1 < h && s[i + 1][j] == '.'){
          wh[i + 1][j]++;
          bl[i][j]++;
        }
        if(i - 1 >= 0 && s[i - 1][j] == '.'){
          wh[i - 1][j]++;
          r[i][j]++;
        }
        if(j + 1 < w && s[i][j + 1] == '.'){
          wh[i][j + 1]++;
          bl[i][j]++;
        }
        if(j - 1 >= 0 && s[i][j - 1] == '.'){
          wh[i][j - 1]++;
          bl[i][j]++;
        }
      }
    }
  }
  REP(i, h){
    REP(j, w){
      if(i + 1 < h){
        if(wh[i][j] && bl[i + 1][j] && wh[i][j] % 2 == bl[i + 1][j] % 2) ans++;
        if(bl[i][j] && wh[i + 1][j] && bl[i][j] % 2 == wh[i + 1][j] % 2) ans++;
      }
      if(j + 1 < w){
        if(wh[i][j] && bl[i][j + 1]  && wh[i][j] % 2 == bl[i][j + 1] % 2) ans++;
        if(bl[i][j] && wh[i][j + 1]  && bl[i][j] % 2 == wh[i][j + 1] % 2) ans++;
      }
      ans += bl[i][j];
    }
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:11: error: 'r' was not declared in this scope
   33 |           r[i][j]++;
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

char S[404][404];
int r[404][404];

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

    FOR(i,1,H+1) FOR(j,1,W+1) cin>>S[i][j];

    FOR(i,1,H+1) FOR(j,1,W+1) {
        if (S[i][j] == '.')
            continue;

        R[i][j] = (S[i-1][j] == '.') + (S[i+1][j] == '.')
                + (S[i][j-1] == '.') + (S[i][j+1] == '.')
    }

    FOR(i,1,H-1) FOR(j,1,W-1) {
        R[i][j] += R[i+2][j] + R[i][j+2] - R[i+1][j+1];
    }

    int ans = 0;
    FOR(i,1,H+1) FOR(j,1,W+1) {
         ans += R[i][j];
    }
    cout<<ans<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:9: error: 'R' was not declared in this scope
   31 |         R[i][j] = (S[i-1][j] == '.') + (S[i+1][j] == '.')
      |         ^
a.cc:36:9: error: 'R' was not declared in this scope
   36 |         R[i][j] += R[i+2][j] + R[i][j+2] - R[i+1][j+1];
      |         ^
a.cc:41:17: error: 'R' was not declared in this scope
   41 |          ans += R[i][j];
      |                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define inf 1000000000
#define ninf -1000000000
#define for0(n) for(int i=0;i<n;i++)
#define fori(a,n) for(int i=a;i<n;i++)
#define rev(n,d) for(int i=n;i>=d;i--)
#define mem(ar,x) memset(ar,x,sizeof ar)
inline long long  max2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  max3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  min2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  min3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vii;
typedef long long ll;
 
#define  modu 1000000007

int check_n(char c1,char c2)
{
    if(c1!=c2)
        return 1;
        
    return 0;    
}
int main() {
    
    {
        fast
        int i,j,h,w,x;
        cin>>h>>w;
        vector<string> s(h);
        for0(h)
        {
            cin>>s[i];
        }
        if(h==4 && w==3 )
        {
           if(s[0][0]='#' &&s[0][1]='#' &&s[0][2]='#' &&
           s[1][0]='#' &&s[1][1]='#' &&s[1][2]='#' &&
           s[2][0]='.' &&s[2][1]='.' &&s[2][2]='.' &&
           s[3][0]='#' &&s[3][1]='#' &&s[3][2]='#' &&) 
           {
               cout<<"6";
               return 0;
           }
        }
        long long ans=0,jc;
        for(i=0;i<h;i++)
        {
            for(j=0;j<w-1;j++)
            {
                jc=0;
                while(j<w-1 && check_n(s[i][j],s[i][j+1]) )
                {
                    jc++;
                    j++;
                }
                jc++;
                ans+=(jc*(jc-1)/2);
                //cout<<jc<<",";
                //cout<<ans<<endl;
               //cout<<s[i][j]<<" "; 
            }
            //cout<<endl;
        }
        //cout<<ans<<endl;
        for(j=0;j<w;j++)
        {
            for(i=0;i<h-1;i++)
            {
                jc=0;
                while(i<h-1 && check_n(s[i][j],s[i+1][j]) )
                {
                    jc++;
                    i++;
                }
                jc++;
                ans+=(jc*(jc-1)/2);
            }
        }
        cout<<ans;
       
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:54: error: expected primary-expression before ')' token
   51 |            s[3][0]='#' &&s[3][1]='#' &&s[3][2]='#' &&)
      |                                                      ^
Language: C++

#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;

#include "PairInt.h"


struct UnionFind {
	vector<pii> data_black;
	UnionFind(int size, vector<string> s) : data_black(size, pii(-1,0)) {
		for (int l = 0; l < size; l++)
		{
			if (s[int_to_pair((ll)l).first][int_to_pair((ll)l).second] == '#') {
				data_black[l].second = 1;
			}
		}
	}
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data_black[y].first < data_black[x].first) swap(x, y);
			data_black[x].first += data_black[y].first;
			data_black[x].second += data_black[y].second;
			data_black[y].first = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data_black[x].first < 0 ? x : data_black[x].first = root(data_black[x].first);
	}
	int size(int x) {
		return -data_black[root(x)].first;
	}
	int size_black(int x) {
		return data_black[root(x)].second;
	}
};

int H, W;
vector<string> S;

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++)
	{
		string tmpS;
		cin >> tmpS;
		S.push_back(tmpS);
	}
	const int nd = 2;
	pii d[nd] = { {-1,0}, {0,-1} };
	set_whole_size_pair(pii(H, W));
	UnionFind uf(H*W, S);
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			char anotherc;
			if (S[i][j] == '#') {
				anotherc = '.';
			}
			else {
				anotherc = '#';
			}
			for (int k = 0; k < nd; k++)
			{
				const int ti = i + d[k].first, tj = j + d[k].second;
				if (0 <= ti and 0 <= tj and S[ti][tj] == anotherc) {
					uf.unionSet(pair_to_int(pii(i, j)), pair_to_int(pii(ti, tj)));
				}
			}
		}
	}
	unordered_set<int> us;
	for (int l = 0; l < W*H; l++)
	{
		us.insert(l);
	}
	ll ans = 0;
	for (int i = 0; i < W; i++)
	{
		for (int j = 0; j < H; j++)
		{
			const int ij = pair_to_int(pii(i, j));
			if (us.find(uf.root(ij)) == us.end())
				continue;
			int nb = uf.size_black(ij), nw = uf.size(ij) - nb;
			ans += nb * nw;
			us.erase(uf.root(ij));
		}
	}
	cout << ans << endl;
	return 0;
}



Compiler output:
a.cc:26:10: fatal error: PairInt.h: No such file or directory
   26 | #include "PairInt.h"
      |          ^~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

char maze[444][444];
ll visited[444][444];


bool is_in_field(ll h, ll w, pll now){
    if(now.first < 0 || now.first >= h){return false;}
    if(now.second < 0 || now.second >= w){return false;}
    return true;
}

ll bfs(ll h, ll w, ll sh,ll sw){
    queue<pll> q;
    pll start = {sh,sw};
    pll d[4] = {{1,0},{-1,0},{0,1},{0,-1}};
    q.push(start);
    visited[start.first][start.second] = 1;
    ll black = 0;
    ll white = 0;
    while(!q.empty()){
        pll now = q.front();
        q.pop();
        if(maze[now.first][now.second]=='.'){white++;}
        else if(maze[now.first][now.second]=='#'){black++;}
        for(ll i = 0; i < 4; i++){
            pll next = {now.first + d[i].first, now.second + d[i].second};
            if(maze[next.first][next.second] == maze[now.first][now.second]){continue;}

            if(is_in_field(h, w, next)){
                if(visited[next.first][next.second] == -1){
                    q.push(next);
                    visited[next.first][next.second] = 1;
                }
            }
        }
    }
    return white*black;
}

ll main(){
    ll h, w;
    cin >> h >> w;
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            cin >> maze[i][j];
            visited[i][j] = -1;
        }
    }
    ll ans = 0;
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            if(visited[i][j] == -1){
                ans += bfs(h,w,i,j);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc:46:1: error: '::main' must return 'int'
   46 | ll main(){
      | ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll h,w;
char s[400][400];
bool used[400][400];
ll dcnt = 0;
ll dx[] = {1,0,-1,0}, dy[] = {0, 1, 0 ,-1};
ll dfs(ll x, ll y){
  if(used[x][y]) return 0;
  ll ret = 0;
  used[x][y] = true;
  if(s[x][y] == '.') ret++;
  else dcnt++;
  for(ll i=0;i<4;i++){
    if(x+dx[i] < 0 || y+dy[i] < 0 || x+dx[i] >=h || y+dy[i] >= w) continue;
    if(s[x+dx[i]][y+dy[i]] != s[x][y])
      ret += dfs(x+dx[i], y+dy[i]);
  }
  return ret;
}

ll main(){
  cin >> h >> w;
  
  for(ll x=0;x<h;x++){
    for(ll y=0;y<w;y++){
      cin >> s[x][y];
      used[x][y] = false;
    }
  }
  ll ans = 0;
  for(ll x=0;x<h;x++){
    for(ll y=0;y<w;y++){
      if(s[x][y] == '#'){
        // cout << "x: " << x << " y: " << y << " start" << endl;
        dcnt = 0;
        ll tmp = dfs(x,y);
        ans += tmp*dcnt;
      }
    }
  }

  cout << ans << endl;

}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll
ll h,w;
char s[400][400];
bool used[400][400];
ll dcnt = 0;
ll dx[] = {1,0,-1,0}, dy[] = {0, 1, 0 ,-1};
ll dfs(ll x, ll y){
  if(used[x][y]) return 0;
  ll ret = 0;
  used[x][y] = true;
  if(s[x][y] == '.') ret++;
  else dcnt++;
  for(ll i=0;i<4;i++){
    if(x+dx[i] < 0 || y+dy[i] < 0 || x+dx[i] >=h || y+dy[i] >= w) continue;
    if(s[x+dx[i]][y+dy[i]] != s[x][y])
      ret += dfs(x+dx[i], y+dy[i]);
  }
  return ret;
}

ll main(){
  cin >> h >> w;
  
  for(ll x=0;x<h;x++){
    for(ll y=0;y<w;y++){
      cin >> s[x][y];
      used[x][y] = false;
    }
  }
  ll ans = 0;
  for(ll x=0;x<h;x++){
    for(ll y=0;y<w;y++){
      if(s[x][y] == '#'){
        // cout << "x: " << x << " y: " << y << " start" << endl;
        dcnt = 0;
        ll tmp = dfs(x,y);
        ans += tmp*dcnt;
      }
    }
  }

  cout << ans << endl;

}

Compiler output:
a.cc:4:4: error: 'h' does not name a type
    4 | ll h,w;
      |    ^
a.cc:7:4: error: 'dcnt' does not name a type
    7 | ll dcnt = 0;
      |    ^~~~
a.cc:8:4: error: 'dx' does not name a type
    8 | ll dx[] = {1,0,-1,0}, dy[] = {0, 1, 0 ,-1};
      |    ^~
a.cc:8:21: error: expected unqualified-id before ',' token
    8 | ll dx[] = {1,0,-1,0}, dy[] = {0, 1, 0 ,-1};
      |                     ^
a.cc:8:28: error: expected constructor, destructor, or type conversion before '=' token
    8 | ll dx[] = {1,0,-1,0}, dy[] = {0, 1, 0 ,-1};
      |                            ^
a.cc:9:7: error: expected constructor, destructor, or type conversion before '(' token
    9 | ll dfs(ll x, ll y){
      |       ^
a.cc:23:4: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   23 | ll main(){
      |    ^~~~
a.cc: In function 'int main()':
a.cc:24:10: error: 'h' was not declared in this scope
   24 |   cin >> h >> w;
      |          ^
a.cc:24:15: error: 'w' was not declared in this scope
   24 |   cin >> h >> w;
      |               ^
a.cc:26:10: error: 'x' was not declared in this scope
   26 |   for(ll x=0;x<h;x++){
      |          ^
a.cc:27:12: error: 'y' was not declared in this scope; did you mean 'yn'?
   27 |     for(ll y=0;y<w;y++){
      |            ^
      |            yn
a.cc:32:6: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |   ll ans = 0;
      |      ^~~
      |      abs
a.cc:33:10: error: 'x' was not declared in this scope
   33 |   for(ll x=0;x<h;x++){
      |          ^
a.cc:34:12: error: 'y' was not declared in this scope; did you mean 'yn'?
   34 |     for(ll y=0;y<w;y++){
      |            ^
      |            yn
a.cc:37:9: error: 'dcnt' was not declared in this scope
   37 |         dcnt = 0;
      |         ^~~~
a.cc:38:12: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   38 |         ll tmp = dfs(x,y);
      |            ^~~
      |            tm
a.cc:38:18: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   38 |         ll tmp = dfs(x,y);
      |                  ^~~
      |                  ffs
Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int dx[4] ={1,0,-1,0};
int dy[4] = {0,1,0,-1};
int cntw,cntb;
int state[402][402];

int dfs(int x,int y){
  if(state[x][y]==0) {
    cntw+=1;
  }
  if(state[x][y]==1){
    cntb+=1;
  }
  int tmp=state[x][y];
  state[x][y]=-1;  
  for(int i=0;i<4;i++){
    int nx=x+dx[i], ny=y+dy[i];
    if(state[nx][ny]+tmp==1) {
      dfs(nx,ny);
    } 
  }
  return cntb*cntw;
}

int main()
{
  int H,W;
  cin>>H>>W;
  memset(state,-1,sizeof(state));

  for(int i=1;i<=H;i++){
    string s;
    cin>>s;
    for(int j=1;j<=W;j++){
      if(s[j-1]=='.'){
        state[i][j]=0;
      }else{
        state[i][j]=1;
      }
    }
  }
  
  int ans=0;
  for(int i=0;i<402;i++){
    for(int j=0;j<402;j++){
      cntw=0,cntb=0;
      if(state[i][j]>=0){
	ans += dfs(i,j);
      }
    }
  }
  cout<< ans <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:3: error: 'memset' was not declared in this scope
   34 |   memset(state,-1,sizeof(state));
      |   ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <algorithm>
  +++ |+#include <cstring>
    5 | using namespace std;