Language: Java

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))

int main()
{
	int h, w, counter = 0;
	cin >> h >> w;
	vector<string> a(h);
	rep(i, 0, h - 1)
	{
		cin >> a[i];
	}
	queue<pair<int, int>> q;
	int dx[] = { 1,0,-1,0 };
	int dy[] = { 0,1,0,-1 };
	vector<string> checker(h);
	rep(i, 0, h - 1)
	{
		string s = "";
		rep(j, 0, w - 1)
		{
			s += "#";
		}
		checker[i] = s;
	}
	rep(i, 0, h - 1)rep(j, 0, w - 1)
	{
		if (a[i][j] == '#')q.push({ i,j });
	}
	while (!q.empty())
	{
		if (a == checker)
		{
			break;
		}
		vector<pair<int, int>> vec;
		while (!q.empty())
		{
			int y = q.front().first;
			int x = q.front().second;
			vec.push_back({ y,x });
			q.pop();
		}
		rep(i, 0, vec.size() - 1)
		{
			rep(j, 0, 3)
			{
				int ny = vec[i].first + dy[j];
				int nx = vec[i].second + dx[j];
				if (0 <= ny && ny < h && 0 <= nx && nx < w && a[ny][nx] == '.')
				{
					a[ny][nx] = '#';
					q.push({ ny,nx });
				}
			}
		}
		++counter;
	}
	cout << counter << endl;
}

Compiler output:
Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <string>
^
Main.java:3: error: illegal character: '#'
#include <algorithm>
^
Main.java:4: error: illegal character: '#'
#include <cmath>
^
Main.java:5: error: illegal character: '#'
#include <cstdlib>
^
Main.java:6: error: illegal character: '#'
#include <vector>
^
Main.java:7: error: illegal character: '#'
#include <map>
^
Main.java:8: error: illegal character: '#'
#include <queue> 
^
Main.java:11: error: illegal character: '#'
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
^
Main.java:11: error: class, interface, enum, or record expected
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
        ^
Main.java:11: error: class, interface, enum, or record expected
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
                                        ^
Main.java:11: error: class, interface, enum, or record expected
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
                                                    ^
Main.java:16: error: class, interface, enum, or record expected
	cin >> h >> w;
	^
Main.java:17: error: unnamed classes are a preview feature and are disabled by default.
	vector<string> a(h);
	^
  (use --enable-preview to enable unnamed classes)
Main.java:17: error: <identifier> expected
	vector<string> a(h);
	                  ^
Main.java:18: error: class, interface, enum, or record expected
	rep(i, 0, h - 1)
	^
Main.java:21: error: class, interface, enum, or record expected
	}
	^
Main.java:23: error: class, interface, enum, or record expected
	int dx[] = { 1,0,-1,0 };
	^
Main.java:24: error: class, interface, enum, or record expected
	int dy[] = { 0,1,0,-1 };
	^
Main.java:25: error: <identifier> expected
	vector<string> checker(h);
	                        ^
Main.java:26: error: class, interface, enum, or record expected
	rep(i, 0, h - 1)
	^
Main.java:29: error: class, interface, enum, or record expected
		rep(j, 0, w - 1)
		^
Main.java:32: error: class, interface, enum, or record expected
		}
		^
Main.java:34: error: class, interface, enum, or record expected
	}
	^
Main.java:38: error: class, interface, enum, or record expected
	}
	^
Main.java:44: error: class, interface, enum, or record expected
		}
		^
Main.java:46: error: class, interface, enum, or record expected
		while (!q.empty())
		^
Main.java:50: error: class, interface, enum, or record expected
			vec.push_back({ y,x });
			^
Main.java:51: error: class, interface, enum, or record expected
			q.pop();
			^
Main.java:52: error: class, interface, enum, or record expected
		}
		^
Main.java:59: error: class, interface, enum, or record expected
				if (0 <= ny && ny < h && 0 <= nx && nx < w && a[ny][nx] == '.')
				^
Main.java:62: error: class, interface, enum, or record expected
					q.push({ ny,nx });
					^
Main.java:63: error: class, interface, enum, or record expected
				}
				^
Main.java:67: error: class, interface, enum, or record expected
	}
	^
Main.java:69: error: class, interface, enum, or record expected
}
^
35 errors