criyle/codenet-compile-errors huggingface dataset:
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, j) {
            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:82:16: error: 'j' was not declared in this scope
   82 |         rep(i, j) {
      |                ^
a.cc:31:32: note: in definition of macro 'rep'
   31 | #define rep(i,n) for(int i=0;i<n;i++)
      |                                ^
Language: C++

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

// 移動ベクトル
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int main(){
	int h,w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	
	ll res = 0;
	queue<P> q;
	vector<vector<bool>> checked(h,vector<bool>(w,false));
	
	rep(i,h){
		rep(j,w){
			ll cnt1 = 0; // "."の数
			ll cnt2 = 0; // "#"の数
			
			if(!checked[i][j]) q.push(P(i,j));
			checked[i][j] = true;
			
			while(!q.empty()){
				P nowp = q.front();
				q.pop();
				//cout << nowp.first << " " << nowp.second << endl;
				
				if(s[nowp.first][nowp.second] == '.'){
					cnt1++;
				}
				else{
					cnt2++;
				}
				
				rep(i,4){
					P nextp = P(nowp.first + dx[i], nowp.second + dy[i]);
					
					if(0 <= nextp.first && nextp.first < h && 
					   0 <= nextp.second && nextp.second < w && 
					   !checked[nextp.first][nextp.second] && 
					   s[nowp.first][nowp.second] != s[nextp.first][nextp.second]){
					   	q.push(nextp);
					   	checked[nextp.first][nextp.second] = true;
					}
				}
			}
			
			ll += cnt1 * cnt2;
		}
	}
	
	cout << res << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:28: error: expected unqualified-id before '+=' token
   53 |                         ll += cnt1 * cnt2;
      |                            ^~
Language: C++

#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

class UF
{
private:
	vector<int> parent;
	vector<int> black;
	vector<int> white;

public:
	UF(int n)
	{
		parent = vector<int>(n, -1);
		black = vector<int>(n, 0);
		white = vector<int>(n, 0);
	}

	int getParent(int x)
	{
		if(parent[x] == -1) return x;
		else return parent[x] = getParent(parent[x]);
	}

	int getBlack(int x)
	{
		return black[getParent(x)];
	}

	int getWhite(int x)
	{
		return white[getParent(x)];
	}

	void update(int x, int y)
	{
		x = getParent(x);
		y = getParent(y);
		if(x == y) return;
		if(x > y) swap(x, y);
		parent[y] = x;
		black[x] += black[y];
		white[x] += white[y];
	}

	void addBlack(int x)
	{
		black[x]++;
	}

	void addWhite(int x)
	{
		white[x]++;
	}

};

int main()
{
	int h, w;
	cin >> h >> w;
	UF uf(h * w);
	char s[401][401];
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> s[i][j];
			if(s[i][j] == '.') uf.addWhite(w * i + j);
			else uf.addBlack(w * i + j);
		}
	}

	int dx[2] = {1, 0, -1, 0};
	int dy[2] = {0, 1, 0, -1};
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			for(int k = 0; k < 4; k++){
				int nx = i + dx[k];
				int ny = j + dy[k];
				if(nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
				if(s[i][j] != s[nx][ny]){
					uf.update(i * w + j, nx * w + ny);
				}
			}
		}
	}
	long long int ans = 0;
	for(int i = 0; i < h * w; i++){
		// cout << uf.getParent(i) << " " << uf.getBlack(i) << " " << uf.getWhite(i) << endl;
		if(uf.getParent(i) == i) ans += uf.getBlack(i) * uf.getWhite(i);
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:93:33: error: too many initializers for 'int [2]'
   93 |         int dx[2] = {1, 0, -1, 0};
      |                                 ^
a.cc:94:33: error: too many initializers for 'int [2]'
   94 |         int dy[2] = {0, 1, 0, -1};
      |                                 ^
Language: C++

#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;cin>>h>>w;
    vector<string> s(h);
    rep(i,h){
        cin>>s[i];
    }
    vector<vector<bool>> chk(h,vector<bool>(w,false));
    function<ll(ll,ll)> check = [&](ll x, ll y){
        map<char,ll> mp;
        mp[s[x][y]]++;
        queue<pair<ll,ll>> que;
        que.push(make_pair(x,y));
        while(!que.empty()){
            ll xx = que.front().first,yy = que.front().second;
            DEBUG{
                prllf("x: %d, y: %d\n",xx,yy);
            }
            que.pop();
            for(ll i=-1;i<=1;i+=2){
                if(xx+i>=0&&xx+i<h&&s[xx][yy]!=s[xx+i][yy]&&!chk[xx+i][yy]) {
                    que.push(make_pair(xx+i,yy));
                    chk[xx+i][yy]=true;
                    mp[s[xx+i][yy]]++;
                }
                if(yy+i>=0&&yy+i<w&&s[xx][yy]!=s[xx][yy+i]&&!chk[xx][yy+i]) {
                    que.push(make_pair(xx,yy+i));
                    chk[xx][yy+i]=true;
                    mp[s[xx][yy+i]]++;
                }
            }
        }
        DEBUG{
            prllf("#: %d, .: %d\n",mp['.'], mp['#']);
        }
        return mp['.']*mp['#'];
    };
    ll res = 0;
    rep(i,h){
        rep(j,w){
            if(!chk[i][j]){
                chk[i][j]=true;
                res += check(i,j);
            }
        }
    }
    cout << res << endl;
    return 0;
}


Compiler output:
a.cc: In lambda function:
a.cc:37:17: error: 'prllf' was not declared in this scope
   37 |                 prllf("x: %d, y: %d\n",xx,yy);
      |                 ^~~~~
a.cc:54:13: error: 'prllf' was not declared in this scope
   54 |             prllf("#: %d, .: %d\n",mp['.'], mp['#']);
      |             ^~~~~
Language: C++

#include <bits/stdc++.h>
const int dx[] = { -1, 0, 0, 1, 0, -1, -1, 1, 1 };
const int dy[] = { 0, -1, 1, 0, 0, 1, -1, 1, -1 };

int H, W; 
string s[410];
int x = 0, y = 0;//xが黒yが白
bool visited[410][410];
void dfs(int Y,int X) {
	if (visited[Y][X]==true)return;
	visited[Y][X] = true;
	for (int k = 0; k < 4; ++k) {
		int ny = Y + dy[k], nx = X + dx[k];
		if (ny >= H || ny < 0 || nx >= W || nx < 0 || visited[ny][nx] || s[ny][nx] == s[Y][X])continue;
		dfs(ny, nx);
	}
	if (s[Y][X] == '#') {
		x++;
	}
	else {
		y++;
	}
	return;
}
signed main() {
	cin >> H >> W;
	for (int i = 0; i < H; ++i)cin >> s[i];
	int ans = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			dfs(i, j);
			ans += x * y;
			x = 0;
			y = 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc:6:1: error: 'string' does not name a type; did you mean 'stdin'?
    6 | string s[410];
      | ^~~~~~
      | stdin
a.cc: In function 'void dfs(int, int)':
a.cc:14:82: error: 's' was not declared in this scope
   14 |                 if (ny >= H || ny < 0 || nx >= W || nx < 0 || visited[ny][nx] || s[ny][nx] == s[Y][X])continue;
      |                                                                                  ^
a.cc:17:13: error: 's' was not declared in this scope
   17 |         if (s[Y][X] == '#') {
      |             ^
a.cc: In function 'int main()':
a.cc:26:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   26 |         cin >> H >> W;
      |         ^~~
      |         std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:27:43: error: 's' was not declared in this scope
   27 |         for (int i = 0; i < H; ++i)cin >> s[i];
      |                                           ^
a.cc:37:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   37 |         cout << ans << endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:37:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   37 |         cout << ans << endl;
      |                        ^~~~
      |                        std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  REP(i,h){
    cin>>s[i];
  }
  bool used[h][w]={};
  int dx[]={1,0,-1,0};
  int dy[]={0,1,0,-1};
  pair<int,int> p;
  int x,y,nx,ny;
  int b,w;
  long long ans=0;
  REP(i,h){
    REP(j,w){
      if(used[i][j])continue;
      b = 0;
      w = 0;
      if(s[i][j]=='#'){
        b++;
      }else{
        w++;
      }
      queue<pair<int,int>> q;
      q.push(make_pair(i,j));
      while(!q.empty()){
        p = q.top();
        q.pop();
        x = p.first;
        y = p.second;
        REP(k,4){
          nx = x + dx[k];
          ny = y + dy[k];
          if(0<=nx && nx<h && 0<=ny && ny<w && !used[nx][ny]){
            used[nx][ny] = true;
            q.push(make_pair(nx,ny));
            if(s[i][j]=='#'){
              b++;
            }else{
              w++;
            }
          }else{
            continue;
          }
        }
      }
      ans += (long long)b*w;
    }
  }
  
  cout<<ans<<endl;    
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:104:9: error: redeclaration of 'int w'
  104 |   int b,w;
      |         ^
a.cc:93:9: note: 'int w' previously declared here
   93 |   int h,w;
      |         ^
a.cc:119:15: error: 'class std::queue<std::pair<int, int> >' has no member named 'top'; did you mean 'pop'?
  119 |         p = q.top();
      |               ^~~
      |               pop
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

ll ans = 0;
bool searched[400][400];
char grid[400][400];
int H;
int W;
int move_x[4] = {-1, 0, 1, 0};
int move_y[4] = {0, -1, 0, 1};
int n_white;
int n_black;

bool isRange(int x, int y){
    if(x <  0) return false;
    if(x >= H) return false;
    if(y <  0) return false;
    if(y >= W) return false;
    return true;
}

void dfs(int x, int y){

    // 探索範囲外，または探索済であれば何もしない
    if(!isRange(x, y)) return ;
    if(searched[x][y]) return ;

    searched[x][y] = true;
    if(grid[x][y] == '#') n_black ++;
    else n_white ++;

    for(int i = 0; i < 4; i++){
        if(isRange(x + move_x[i],[y + move_y[i] ) ){
            if(grid[x][y] != grid[x + move_x[i]][y + move_y[i]]){
                dfs(x + move_x[i], y + move_y[i] );
            }
        }
    }
}

int main(){

    cin >> H >> W;

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> grid[i][j];
            searched[i][j] = false;
        }
    }

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(grid[i][j] == '#'){
                n_black = 0;
                n_white = 0;
                dfs(i, j);
                ans += n_white * n_black;
            }
        }
    }

    cout << ans << endl;

}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:42:36: error: expected ',' before '+' token
   42 |         if(isRange(x + move_x[i],[y + move_y[i] ) ){
      |                                    ^~
      |                                    ,
a.cc:42:37: error: expected identifier before '+' token
   42 |         if(isRange(x + move_x[i],[y + move_y[i] ) ){
      |                                     ^
a.cc:42:50: error: expected ']' before ')' token
   42 |         if(isRange(x + move_x[i],[y + move_y[i] ) ){
      |                                                  ^~
      |                                                  ]
a.cc: In lambda function:
a.cc:42:51: error: expected '{' before ')' token
   42 |         if(isRange(x + move_x[i],[y + move_y[i] ) ){
      |                                                   ^
a.cc: In function 'void dfs(int, int)':
a.cc:42:34: error: cannot convert 'dfs(int, int)::<lambda()>' to 'int'
   42 |         if(isRange(x + move_x[i],[y + move_y[i] ) ){
      |                                  ^~~~~~~~~~~~~~~~
      |                                  |
      |                                  dfs(int, int)::<lambda()>
a.cc:23:25: note:   initializing argument 2 of 'bool isRange(int, int)'
   23 | bool isRange(int x, int y){
      |                     ~~~~^
a.cc:42:52: error: expected ')' before '{' token
   42 |         if(isRange(x + move_x[i],[y + move_y[i] ) ){
      |           ~                                        ^
      |                                                    )
a.cc:47:5: error: expected primary-expression before '}' token
   47 |     }
      |     ^
Language: C++

#include <stdio.h>
long paint(char* field, int x, int y)
{
  int stack[160000];
  long odd = 0;
  long even = 0;
  int p = y * 402 + x;
  if((x + y) % 2)
  {
    odd = 1;
  }
  else
  {
    even = 1;
  }
  int color = field[p];
  int stn = 1;
  stack[0] = p;
  field[p] = 0;
  while(stn)
  {
    stn--;
    int pos = stack[stn];
    int way[4] = {-402, -1, 1, 402};
    int w;
    for(w = 0 ; w < 4 ; w++)
    {
	    if(field[pos+way[w]] == color)
	    {
	      field[pos+way[w]] = 0;
	      if(((pos+way[w]) / 402 + (pos+way[w]) % 402) % 2)
	      {
	        odd++;
	      }
	      else
	      {
	        even++;
	      }
	      stack[stn] = pos+way[w];
	      stn++;
	    }
    }
  }
  return odd * even;
}

int main()
{
  char field[402][402];
  int h, w;
  int x, y;
  scanf("%d%d", &h, &w);
  memset(field, 402*402, 0);
  for(y = 1 ; y <= h ; y++)
  {
    scanf("%s", field[y]+1);
    for(x = 1 ; x <= w ; x++)
    {
      if((x + y) % 2 == 0)
      {
        field[y][x] = field[y][x] ^ ('#' ^ '.');
      }
    }
  }
  long sum = 0;
  for(y = 1 ; y <= h ; y++)
  {
    for(x = 1 ; x <= w ; x++)
    {
    	if(field[y][x])
    	{
    		sum += paint(field, x, y);
    	}
    }
  }
  printf("%ld\n", sum);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:3: error: 'memset' was not declared in this scope
   53 |   memset(field, 402*402, 0);
      |   ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <stdio.h>
  +++ |+#include <cstring>
    2 | long paint(char* field, int x, int y)
a.cc:72:30: error: cannot convert 'char (*)[402]' to 'char*'
   72 |                 sum += paint(field, x, y);
      |                              ^~~~~
      |                              |
      |                              char (*)[402]
a.cc:2:18: note:   initializing argument 1 of 'long int paint(char*, int, int)'
    2 | long paint(char* field, int x, int y)
      |            ~~~~~~^~~~~
Language: C++

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

struct Point{
	int h,w;
	Point(){};
	Point(int h_,int w_){
		h=h_,w=w_;
	};
};

Point operator+(const Point& a,const Point& b){return Point(a.h+b.h,a.w+b.w);}

struct Board{

	int H,W;
	vector<string>s ;
	vector<Point>near;
	queue<Point> que;
	vector<vector<int>> dist;
	vector<vector<bool>> visited;
	int ans;

	Board(){};
	Board(int h_,int w_){
		H=h_,W=w_;
		s.resize(H);
		near={{-1,0},{1,0},{0,-1},{0,1}};
		init_dist();
		init_visited();
	};

	bool in_board(Point p){if(0<=p.h && p.h<H && 0<=p.w && p.w<W)return true;else return false;} 
	char get_char(Point p){return s[p.h][p.w];}
	vector<Point> get_near(Point p){vector<Point>ret;for(auto&& u:near)ret.emplace_back(p+u);return ret;}

	int  get_dist(Point p){return dist[p.h][p.w];}
	int  set_dist(Point p,int i){dist[p.h][p.w]=i;}
	void init_dist(){dist.assign(H,vector<int>(W,-1));}

	int  is_visited(Point p){return visited[p.h][p.w];}
	int  set_visited(Point p,bool i){visited[p.h][p.w]=i;}
	void init_visited(){visited.assign(H,vector<bool>(W,false));}


	void dfs(Point p){
		if(is_visited(p))return;
		set_visited(p,true);
		char c1,c2;
		c1=get_char(p);
		for(auto&& q:near){
			Point u=p+q;
		
		if(! in_bound(u))continue;
		c2=get_char(u);	
	    if(!is_visited(u) && c1!=c2){
				 
				if(c2=='.'){ans++;}//cout<<"w "<<u.h<<" "<<u.w<<endl;}
				dfs(u);
		}
		}
	}

	int do_all_dfs(){
		ans=0;
		for (int i;i<H;i++)for(int j=0;j<W;j++){
		Point p(i,j);
		if(get_char(p)=='#'){
	//		cout<<"b "<<p.h<<" "<<p.w<<endl;
		init_visited();
		dfs(p);
		}}
		return ans;
	}

	void bfs(){
		while(! que.empty()){
		Point p=que.front();que.pop();	
		for(auto&& u:get_near(p)){
		if(in_board(u) && ! is_visited(u) && get_char(p)!=get_char(u)){
			set_visited(u,true);
			if(get_char(u)=='.')ans++;
			que.push(u);
		}}
		}}

	int do_all_bfs(){for (int i;i<H;i++)for(int j=0;j<W;j++){
		ans=0;
		for (int i;i<H;i++)for(int j=0;j<W;j++){
		Point p(i,j);
		if(get_char(p)=='#'){
	//		cout<<"b "<<p.h<<" "<<p.w<<endl;
		init_visited();
		que.push(p);
		set_visited(p,true);
		bfs();
		}}
		return ans;
	}
	}

};


int main(){
	int h,w;cin>>h>>w;
	Board bd(h,w);
	for(auto&& u:bd.s)cin>>u;
//	for(auto&& u:bd.s)cout<<u<<endl;
	cout<<bd.do_all_dfs()<<endl;
}


Compiler output:
a.cc: In member function 'int Board::set_dist(Point, int)':
a.cc:38:55: warning: no return statement in function returning non-void [-Wreturn-type]
   38 |         int  set_dist(Point p,int i){dist[p.h][p.w]=i;}
      |                                                       ^
a.cc: In member function 'int Board::set_visited(Point, bool)':
a.cc:42:62: warning: no return statement in function returning non-void [-Wreturn-type]
   42 |         int  set_visited(Point p,bool i){visited[p.h][p.w]=i;}
      |                                                              ^
a.cc: In member function 'void Board::dfs(Point)':
a.cc:54:22: error: 'in_bound' was not declared in this scope; did you mean 'in_board'?
   54 |                 if(! in_bound(u))continue;
      |                      ^~~~~~~~
      |                      in_board
Language: C++

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

struct Point{
	int h,w;
	Point(){};
	Point(int h_,int w_){
		h=h_,w=w_;
	};
};

Point operator+(const Point& a,const Point& b){return Point(a.h+b.h,a.w+b.w);}

struct Board{

	int H,W;
	vector<string>s ;
	vector<Point>near;
	queue<Point> que;
	vector<vector<int>> dist;
	vector<vector<bool>> visited;
	int ans;

	Board(){};
	Board(int h_,int w_){
		H=h_,W=w_;
		s.resize(H);
		near={{-1,0},{1,0},{0,-1},{0,1}};
		init_dist();
		init_visited();
	};

	bool in_board(Point p){if(0<=p.h && p.h<H && 0<=p.w && p.w<W)return true;else return false;} 
	char get_char(Point p){return s[p.h][p.w];}
	vector<Point> get_near(Point p){vector<Point>ret;for(auto&& u:near)ret.emplace_back(p+u);return ret;}

	int  get_dist(Point p){return dist[p.h][p.w];}
	int  set_dist(Point p,int i){dist[p.h][p.w]=i;}
	void init_dist(){dist.assign(H,vector<int>(W,-1));}

	int  is_visited(Point p){return visited[p.h][p.w];}
	int  set_visited(Point p,bool i){visited[p.h][p.w]=i;}
	void init_visited(){visited.assign(H,vector<bool>(W,false));}


	void dfs(Point p){
		if(is_visited(p))return;
		set_visited(p,true);
		for(auto&& u:get_near(p)){
		if(in_board(u) && !is_visited(u) && get_char(p)!=get_char(u)){
				 
				if(get_char(u)=='.'){ans++;}//cout<<"w "<<u.h<<" "<<u.w<<endl;}
				dfs(u);
		}
		}
	}

	int do_all_dfs(){
		ans=0;
		for (int i;i<H;i++)for(int j=0;j<W;j++){
		Point p(i,j);
		if(get_char(p)=='#'){
	//		cout<<"b "<<p.h<<" "<<p.w<<endl;
		init_visited();
		dfs(p);
		}}
		return ans;
	}

	void bfs(){
		while(! que.empty()){
		Point p=que.front();que.pop();	
		for(auto&& u:get_near(p)){
		if(in_board(u) && ! is_visited(u) && get_char(p)!=get_char(u)){
			set_visited(u,true);
			if(get_char(u)=='.')ans++;
			que.push(u);
		}}
		}}

	void do_all_bfs(){for (int i;i<H;i++)for(int j=0;j<W;j++){
		ans=0;
		for (int i;i<H;i++)for(int j=0;j<W;j++){
		Point p(i,j);
		if(get_char(p)=='#'){
	//		cout<<"b "<<p.h<<" "<<p.w<<endl;
		init_visited();
		que.push(p);
		set_visited(p,true);
		bfs();
		}}
		return ans;
	}
	}

};


int main(){
	int h,w;cin>>h>>w;
	Board bd(h,w);
	for(auto&& u:bd.s)cin>>u;
//	for(auto&& u:bd.s)cout<<u<<endl;
	cout<<bd.do_all_dfs()<<endl;
}


Compiler output:
a.cc: In member function 'int Board::set_dist(Point, int)':
a.cc:38:55: warning: no return statement in function returning non-void [-Wreturn-type]
   38 |         int  set_dist(Point p,int i){dist[p.h][p.w]=i;}
      |                                                       ^
a.cc: In member function 'int Board::set_visited(Point, bool)':
a.cc:42:62: warning: no return statement in function returning non-void [-Wreturn-type]
   42 |         int  set_visited(Point p,bool i){visited[p.h][p.w]=i;}
      |                                                              ^
a.cc: In member function 'void Board::do_all_bfs()':
a.cc:92:24: error: return-statement with a value, in function returning 'void' [-fpermissive]
   92 |                 return ans;
      |                        ^~~
Language: C++

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

struct Point{
	int h,w;
	Point(){};
	Point(int h_,int w_){
		h=h_,w=w_;
	};
};

Point operator+(const Point& a,const Point& b){return Point(a.h+b.h,a.w+b.w);}

struct Board{

	int H,W;
	vector<string>s ;
	vector<Point>near;
	vector<vector<bool>> visited;
	int ans;

	Board(){};
	Board(int h_,int w_){
		H=h_,W=w_;
		s.resize(H);
		near={{-1,0},{1,0},{0,-1},{0,1}};
		init_visited();
	};

	bool in_board(Point p){if(0<=p.h && p.h<H && 0<=p.w && p.w<W)return true;else return false;} 
	char get_char(Point p){return s[p.h][p.w];}
	vector<Point> get_near(Point p){vector<Point>ret;for(auto&& u:near)ret.push_back(p+u);return ret;}

	int  get_dist(Point p){return dist[p.h][p.w];}
	int  set_dist(Point p,int i){dist[p.h][p.w]=i;}
	void init_dist(){dist.assign(H,vector<int>(W,-1));}

	int  is_visited(Point p){return visited[p.h][p.w];}
	int  set_visited(Point p,bool i){visited[p.h][p.w]=i;}
	void init_visited(){visited.assign(H,vector<bool>(W,false));}


	void dfs(Point p){
		if(is_visited(p))return;
		set_visited(p,true);
		for(auto&& u:get_near(p)){
		if(in_board(u) && !is_visited(u) && get_char(p)!=get_char(u)){
				 
				if(get_char(u)=='.'){ans++;}//cout<<"w "<<u.h<<" "<<u.w<<endl;}
				dfs(u);
		}
		}
	}

	int do_all_dfs(){
		ans=0;
		for (int i;i<H;i++)for(int j=0;j<W;j++){
		Point p(i,j);
		if(get_char(p)=='#'){
	//		cout<<"b "<<p.h<<" "<<p.w<<endl;
		init_visited();
		dfs(p);
		}}
		return ans;
	}



};


int main(){
	int h,w;cin>>h>>w;
	Board bd(h,w);
	for(auto&& u:bd.s)cin>>u;
	for(auto&& u:bd.s)cout<<u<<endl;
	cout<<bd.do_all_dfs()<<endl;
}

Compiler output:
a.cc: In member function 'int Board::get_dist(Point)':
a.cc:34:39: error: 'dist' was not declared in this scope
   34 |         int  get_dist(Point p){return dist[p.h][p.w];}
      |                                       ^~~~
a.cc: In member function 'int Board::set_dist(Point, int)':
a.cc:35:38: error: 'dist' was not declared in this scope
   35 |         int  set_dist(Point p,int i){dist[p.h][p.w]=i;}
      |                                      ^~~~
a.cc:35:55: warning: no return statement in function returning non-void [-Wreturn-type]
   35 |         int  set_dist(Point p,int i){dist[p.h][p.w]=i;}
      |                                                       ^
a.cc: In member function 'void Board::init_dist()':
a.cc:36:26: error: 'dist' was not declared in this scope
   36 |         void init_dist(){dist.assign(H,vector<int>(W,-1));}
      |                          ^~~~
a.cc: In member function 'int Board::set_visited(Point, bool)':
a.cc:39:62: warning: no return statement in function returning non-void [-Wreturn-type]
   39 |         int  set_visited(Point p,bool i){visited[p.h][p.w]=i;}
      |                                                              ^
Language: C++

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

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];
        }
    }

    long long ans = 0;
    vector<int> di = {-1, 0, 1, 0}, dj = {0, -1, 0, 1};
    vector<vector<bool>> done(h, vector<bool>(w, false));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (done[i][j] == false) {
                lint white = 0, black = 0;
                if (s[i][j] == '.') {
                    white++;
                } else {
                    black++;
                }
                queue<pair<int, int>> que;
                done[i][j] = true;
                que.push({i, j});
                while (que.size() > 0) {
                    auto pos = que.front();
                    que.pop();
                    int pi = pos.first, pj = pos.second;
                    for (int k = 0; k < 4; k++) {
                        int ni = pi + di[k], nj = pj + dj[k];
                        if (0 <= ni and ni < h and 0 <= nj and nj < w) {
                            if (done[ni][nj] == false and s[pi][pj] != s[ni][nj]) {
                                if (s[ni][nj] == '.') {
                                    white++;
                                } else {
                                    black++;
                                }
                                done[ni][nj] = true;
                                que.push({ni, nj});
                            }
                        }
                    }
                }
                ans += white * black;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:17: error: 'lint' was not declared in this scope; did you mean 'uint'?
   20 |                 lint white = 0, black = 0;
      |                 ^~~~
      |                 uint
a.cc:22:21: error: 'white' was not declared in this scope; did you mean 'write'?
   22 |                     white++;
      |                     ^~~~~
      |                     write
a.cc:24:21: error: 'black' was not declared in this scope
   24 |                     black++;
      |                     ^~~~~
a.cc:38:37: error: 'white' was not declared in this scope; did you mean 'write'?
   38 |                                     white++;
      |                                     ^~~~~
      |                                     write
a.cc:40:37: error: 'black' was not declared in this scope
   40 |                                     black++;
      |                                     ^~~~~
a.cc:48:24: error: 'white' was not declared in this scope; did you mean 'write'?
   48 |                 ans += white * black;
      |                        ^~~~~
      |                        write
a.cc:48:32: error: 'black' was not declared in this scope
   48 |                 ans += white * black;
      |                                ^~~~~
Language: C++

#include<cstdio>
#include<queue>
#include<utility>

using namespace std;

typedef pair<int, int> P;

const int MAX_N = 400;

const int di[] = {1, 0, -1, 0};
const int dj[] = {0, 1, 0, -1};

bool color[MAX_N][MAX_N];
int H, W;

char ch[MAX_N + 1];

void input(){
	scanf("%d%d", &H, &W);
	for(int i = 0; i < H; ++i){
		scanf("%s", ch);
		for(int j = 0; j < W; ++j){
			color[i][j] = (ch[j] == '#');
		}
	}
}

bool isin_(int i, int j){
	return i >= 0 && i < H && j >= 0 && j < W;
}

bool check_(int i, int j, int d){
	int ni = i + di[d];
	int nj = j + dj[d];
	if(!isin_(ni, nj)) return false;
	if(color[i][j] == color[ni][nj]) return false;
	return true;
}

bool used[MAX_N][MAX_N];

long long solve(){
	long long ans = 0;
	long long b = 0, w = 0;
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			if(used[i][j]) continue;
			b = 0;
			w = 0;
			queue<P> que;
			used[i][j] = true;
			que.push(P(i, j));
			while(!que.empty()){
				P p = que.front();
				que.pop();
				int ci = p.first, cj = p.second;
				if(color[ci][cj]) b++;
				else w++;
				for(int d = 0; d < 4; ++d){
					if(!check_(ci, cj, d)) continue;
					int ni = ci + di[d], nj = cj + dj[d];
					if(used[ni][nj]) continue;
					used[ni][nj] = true;
					que.push(P(ni, nj));
				}
			}
			ans += b * w;
		}
	}
	return ans;
}

int main(){
	input();
	long long ans = solve();
	cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:77:9: error: 'cout' was not declared in this scope
   77 |         cout << ans;
      |         ^~~~
a.cc:4:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include<utility>
  +++ |+#include <iostream>
    4 |
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int maxn = 404 * 404;
int u[maxn], s0[maxn], s1[maxn];
void init(){
  iota(u, u + maxn, 0);
}
int find(int x){
  if(x == u[x]) return x;
  return u[x] = find(u[x]);
int join(int x, int y){
  x = find(x);
  y = find(y);
  if(x ^ y){
    u[x] = y;
    s0[y] += s0[x];
    s1[y] += s1[x];
  	return 1;
  }
  return 0;
}
int main(){
  int n, w; cin >> n >> w;
  vector<string> grid(n);
  for(auto & i : grid) cin >> i;
  for(int i = 0; i < n; i++) for(int j = 0; j < w; j++) {
    if(grid[i][j] == '*') s0[i*w+j] = 1;
    else s1[i*w+j] = 1;
  }
  init();
  for(int i = 0; i < n; i++) for(int j = 0; j < w; j++) {
    for(int di: {-1, 0, 1}){
      for(int dj: {-1, 0, 1}){
        if(abs(di) + abs(dj) == 1){
          int ni = di + i, nj = dj + j;
          if(ni >= 0 && ni < n && nj >= 0 && nj < w){
            if(grid[i][j] != grid[ni][nj]){
              join(i*w+j,ni*w+nj);
            }
          }
        }
      }
    }
  }
  long long ans = 0;
  for(int i = 0; i < n * w; i++) if(find(i) == i){
    ans += 1ll * s0[i] * s1[i];
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int find(int)':
a.cc:11:23: error: a function-definition is not allowed here before '{' token
   11 | int join(int x, int y){
      |                       ^
a.cc:22:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   22 | int main(){
      |         ^~
a.cc:22:9: note: remove parentheses to default-initialize a variable
   22 | int main(){
      |         ^~
      |         --
a.cc:22:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:22:11: error: a function-definition is not allowed here before '{' token
   22 | int main(){
      |           ^
a.cc:51:2: error: expected '}' at end of input
   51 | }
      |  ^
a.cc:8:16: note: to match this '{'
    8 | int find(int x){
      |                ^
Language: C++

#include <iostream>
#include <queue>

using namespace std;

int Init(bool (*visited)[401], int w, int h)
{
	int i, j;

	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			visited[i][j] = false;
		}
	}
	return 1;
}

int Input(char (*s)[401], int& w, int& h, int (*score)[401])
{
	cin >> h >> w;

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> s[i][j];
			score[i][j] = (s[i][j] == '#') ? 1 : 0;
		}
	}

	return 1;
}


int Process(int (*score)[401], bool (*visited)[401], int w, int h, int &result)
{
	int i, j ,k;
	int curr_x, curr_y;
	int next_x, next_y;
	int move[4][2] = { { 1, 0 },{ 0, 1 },{ -1,0 },{ 0,-1 } };
	vector<int> logging;
	queue<pair<int, int>> q;
	
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			if (!visited[i][j])
			{
				q.push(pair<int, int>(i, j));
				visited[i][j] = true;

				while (!q.empty())
				{
					curr_y = q.front().first;
					curr_x = q.front().second;
					q.pop();
					logging.push_back(score[curr_y][curr_x]);
					
					
					for (k = 0; k < 4; k++)
					{
						next_y = curr_y + move[k][0];
						next_x = curr_x + move[k][1];

						if (0 <= next_x && next_x < w && 0 <= next_y && next_y < h && !visited[next_y][next_x]
							&& (score[curr_y][curr_x] + score[next_y][next_x] == 1))
						{
							q.push(pair<int, int>(next_y, next_x));
							visited[next_y][next_x] = true;
						}
					}
				}

				result += (count(logging.begin(), logging.end(), 1) * count(logging.begin(), logging.end(), 0));
				
				cout << endl;
				logging.clear();
			}
		}
	}
	
	return 1;
}

int main()
{
	int h, w, result = 0;
	
	char s[401][401];
	int score[401][401];
	bool visited[401][401] = { false, };
	
	Input(s, w, h, score);
	Init(visited, w, h);

	Process(score, visited, w, h, result);
	
	cout << result << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int Process(int (*)[401], bool (*)[401], int, int, int&)':
a.cc:77:44: error: 'count' was not declared in this scope
   77 |                                 result += (count(logging.begin(), logging.end(), 1) * count(logging.begin(), logging.end(), 0));
      |                                            ^~~~~
Language: C++

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

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

int h,w;
char cmap[400][400];
int ans;
int cnt, cnt2;     //cnt2 number of white grid

void dfs(int x, int y){
    if(cmap[y][x] == '*' || x < 0 || x >= w || y < 0 || y >= h) return;
    ++cnt;
    if(cmap[y][x] == '#')    ans += cnt;
    else        ans += cnt - cnt2++;
    cmap[y][x] = '*';

    for(int i = 0;i < 4;i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        dfs(nx,ny);
    }
}
int main()
{   
    bool flg = true;

    cin >> h >> w;

    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++) cin >> cmap[i][j];
    }
    for(int i = 0;i < h;i++){
        for(int j  = 0;j < w;j++){
            cnt = -1;
            if(cmap[i][j] == '#') dfs(j,i);
        }   
    }

    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:5:5: error: scalar object 'dx' requires one element in initializer
    5 | int dx = {0,0,1,-1};
      |     ^~
a.cc:6:5: error: scalar object 'dy' requires one element in initializer
    6 | int dy = {-1,1,0,0};
      |     ^~
Language: C++

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

int h,w;
char cmap[400][400];
int ans;
int cnt, cnt2;     //cnt2 number of white grid

void dfs(int x, int y){
    if(cmap[y][x] == '*' || x < 0 || x >= w || y < 0 || y >= h) return;
    ++cnt;
    if(cmap[y][x] == '#')    ans += cnt;
    else        ans += cnt - cnt2++;
    cmap[y][x] = '*';

    for(int i = 0;i < 4;i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        dfs(nx,ny);
    }
}
int main()
{   
    bool flg = true;

    cin >> h >> w;

    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++) cin >> cmap[i][j];
    }
    for(int i = 0;i < h;i++){
        for(int j  = 0;j < w;j++){
            cnt = -1;
            if(cmap[i][j] == '#') dfs(j,i);
        }   
    }

    cout << ans << endl;
    return 0;
}

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

H, W = map(int, input().split())
C = [input() for i in range(H)]

import sys
sys.setrecursionlimit(500000)


def search(x, y, z):
    if y >= H or x >= W or x < 0 or y <  0:
        return
    elif C[y][x] == z:
        return
    #elif [x, y] in itta:
    elif itta[y][x] == 1:
        return
    else:
        # itta.append([x,y])
        itta[y][x] = 1 # appendすると遅くなる
        prez = C[y][x]
        if C[y][x] == '.':
            itta_white[y][x] = 1
    
    search(x+1, y, prez)
    search(x-1, y, prez)
    search(x, y+1, prez)
    search(x, y-1, prez) 

ans = 0
# #を探しに行く
for y in range(H):
    for x in range(W):
        if C[y][x] != '#':
            pass
        else:
            itta = [[0] * W for i in range(H)]
            itta_white = [[0] * W for i in range(H)]
            search(x, y, '.')
            ans += sum(map(sum, itta_white)) 
            # 入れ子リスト（２次元配列）の合計値
            # https://maku77.github.io/python/numstr/sum.html

print(ans)

Compiler output:
a.cc:13:6: error: #elif without #if
   13 |     #elif [x, y] in itta:
      |      ^~~~
a.cc:17:11: error: invalid preprocessing directive #itta
   17 |         # itta.append([x,y])
      |           ^~~~
a.cc:18:24: error: stray '#' in program
   18 |         itta[y][x] = 1 # appendすると遅くなる
      |                        ^
a.cc:29:3: error: invalid preprocessing directive ##
   29 | # #を探しに行く
      |   ^
a.cc:39:15: error: invalid preprocessing directive #\U00005165\U0000308c\U00005b50\U000030ea\U000030b9\U000030c8\U0000ff08\U0000ff12\U00006b21\U00005143\U0000914d\U00005217\U0000ff09\U0000306e\U00005408\U00008a08\U00005024
   39 |             # 入れ子リスト（２次元配列）の合計値
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:40:15: error: invalid preprocessing directive #https
   40 |             # https://maku77.github.io/python/numstr/sum.html
      |               ^~~~~
a.cc:1:1: error: 'H' does not name a type
    1 | H, W = map(int, input().split())
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define DBG(x) cout<<#x<<":"<<x<<endl
#define int long long
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll p = 1e9+7;
const ll INF = 1LL << 60;

int h,w;
char s[444][444];
int used[444][444];
int used2[444][444];
int cnt_w[444][444];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

void rec2(int x,int y,int k){
  if(used2[x][y])return;
  used2[x][y]=1;
  cnt_w[x][y]=k;
  for(int i=0;i<4;i++){
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(nx<0||h<=nx||ny<0||w<=ny)continue;
    if(s[x][y]==s[nx][ny])continue;
    rec2(nx,ny,k);
  }
}

int rec(int x,int y){
  if(used[x][y])return 0;
  used[x][y]=1;
  int sum=(s[x][y]=='.');
  for(int i=0;i<4;i++){
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(nx<0||h<=nx||ny<0||w<=ny)continue;
    if(s[x][y]==s[nx][ny])continue;
    sum+=rec(nx,ny);
  }
  return sum;
}

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

  int ans=0;

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
	 if(used[i][j]){
	   if(s[i][j]=='#')ans+=cnt_w[i][j];
	   continue;
	 }
	 int k=rec(i,j);
	 //	 DBG(k);
	 rec2(i,j,k);
	 if(s[i][j]=='#')ans+=cnt_w[i][j];
	 //	 DBG(ans);
    }
  }

  cout<<ans<<endl;
  return 0;
}


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

/Users/sashi/Code/CLionProjects/cppoj/cmake-build-debug/cppoj
3 3
.#.
..#
#..
10

Process finished with exit code 0


Compiler output:
a.cc:3:2: error: stray '#' in program
    3 | .#.
      |  ^
a.cc:4:3: error: stray '#' in program
    4 | ..#
      |   ^
a.cc:5:2: error: invalid preprocessing directive #.
    5 | #..
      |  ^
a.cc:1:1: error: expected unqualified-id before '/' token
    1 | /Users/sashi/Code/CLionProjects/cppoj/cmake-build-debug/cppoj
      | ^
Language: C++

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

#define ll long long
#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define repr(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back
#define debug(x) cout << x << endl;
#define END cout << endl;
#define sorti(x) sort(x.begin(), x.end())

typedef int long long;

int d[401][401];
ll ans = 0;
int h,w;
// count
int cs = 0, cp = 0;
char s[401][401];

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
map<pair<int,int>, bool> mp;

void dfs(int x, int y, char now) {
  if (now == '#') {
    cs++;
    pair<int,int> p = make_pair(x,y);
    mp[p] = true;
  }
  else cp++;
  d[x][y] = 1;

  for (int i = 0; i < 4; ++i) {
    int nx = x + dx[i], ny = y + dy[i];
    if (nx >= 0 and nx < h and ny >= 0 and ny < w and s[nx][ny] != now and d[nx][ny] == 0) {
      dfs(nx,ny,s[nx][ny]);
    }
  }
}

int main() {
  cin >> h >> w;

  vector<pair<int,int> > p;
  rep(i,h) rep(j,w){
    cin >> s[i][j];
  }

  pair<int,int> pp;
  for (int tt = 0; tt < h; ++tt) {
    for (int i = 0; i < w; ++i) {
      // kuromasukara
      pp = make_pair(tt,i);
      if (s[tt][i] == '#' and !mp[pp]) {
        dfs(tt,i,'#');
        ans += cs * cp;
        cs = 0, cp = 0;
      }
    }
  }

  cout << ans << endl;
}

Compiler output:
a.cc:15:18: error: declaration does not declare anything [-fpermissive]
   15 | typedef int long long;
      |                  ^~~~
Language: C++

#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int

using namespace std;

struct UnionFind
{
  vector<int> par; //par[i]がiの根を表す

  // コンストラクタ
  UnionFind(int n)
  {
    par = vector<int>(n);
    for (int i = 0; i < n; i++)
    {
      par[i] = i;
    }
  }

  // データxの根を求める
  int root(int x)
  {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]); // 木構造の縮約を行っている
  }

  // xとyの親が違うとき、マージする。そのときyの根がxの根の子になる
  void merge(int x, int y)
  {
    int rootx = root(x);
    int rooty = root(y);
    if (rootx == rooty)
      return;
    par[rooty] = rootx;
  }

  // 同じグループに属しているか
  bool isSame(int x, int y)
  {
    return root(x) == root(y);
  }
};

int main()
{
  // 黒が#で0、白が.で1
  int map[400][400] = {};
  int h = 0, w = 0;
  cin >> h >> w;
  REP(i, h)
  {
    string s;
    cin >> s;
    REP(j, s.length())
    {
      if (s[j] == '#')
      {
        map[i][j] = 0;
      }
      else
      {
        map[i][j] = 1;
      }
    }
  }

  UnionFind tree(h * w);

  REP(i, h)
  {
    REP(j, w)
    {
      if (j < w - 1)
      {
        if (map[i][j] != map[i][j + 1])
        {
          tree.merge(i * w + j, i * w + j + 1);
        }
      }

      if (i < h - 1)
      {
        if (map[i][j] != map[i + 1][j])
        {
          tree.merge(i * w + j, (i + 1) * w + j);
        }
      }
    }
  }

  return;

  int a[16000] = {};
  int b[16000] = {};

  REP(i, h)
  {
    REP(j, w)
    {
      int r = tree.root(i * w + j);
      if (map[i][j] == 0)
      {
        a[r]++;
      }
      else
      {
        b[r]++;
      }
    }
  }

  int result = 0;

  REP(i, h * w)
  {
    result += a[i] * b[i];
  }

  cout << result << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:101:3: error: return-statement with no value, in function returning 'int' [-fpermissive]
  101 |   return;
      |   ^~~~~~
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int H,W;
char S[405][405];
int reached[405][405];
int b[160010],w[160010];
void init(int x,int y){
    for(int i = 0;i < x+5i++){
        for(int j = 0;j < y+5;j++){
            reached[i][j] = 0;
        }
    }
    for(int i = 0;i < x*y+5;i++){
        b[i] = 0;
        w[i] = 0;
    }
}
void search(int x,int y,int k){
    if(x < 0 || x >= H || y < 0 || y >= W || reached[x][y] == 1)return;

    reached[x][y] = 1;
    if(S[x][y] == '#')b[k]++;
    if(S[x][y] == '.')w[k]++;

    if(S[x][y] != S[x+1][y])search(x+1,y,k);
    if(S[x][y] != S[x-1][y])search(x-1,y,k);
    if(S[x][y] != S[x][y+1])search(x,y+1,k);
    if(S[x][y] != S[x][y-1])search(x,y-1,k);
}



int main(){
    scanf("%d%d",&H,&W);
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            scanf("%c",&S[i][j]);
            if(S[i][j] == '\n')j = j - 1;
        }
    }


    int count = 0;
    for(int k = 0;k < H*W;k++){
        search(k/W,k%W,k);
        count += b[k]*w[k];
        printf("%d %d %d\n",k,b[k],w[k]);
    }

    printf("%d\n",count);
    return 0;
}


Compiler output:
a.cc: In function 'void init(int, int)':
a.cc:11:27: error: lvalue required as increment operand
   11 |     for(int i = 0;i < x+5i++){
      |                           ^~
a.cc:11:29: error: expected ';' before ')' token
   11 |     for(int i = 0;i < x+5i++){
      |                             ^
      |                             ;