Language: C++

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

//vars;
int W,H,ans=0,shortest_pass=0;
char s[55][55];

int BFS(){
	//前後左右に動くことを想定するため,
	//(x,y)を(x+dx[i],y+dy[i])に移動させることを考える.
	int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
	queue<P> que;
	//初期位置からの距離(distance)を調べる;
	int dist[55][55];
	//わかりやすさのため,初期位置を(0,0)ではなく(1,1)にした.
	//すべての点をINF(=未訪であるというフラグ)にする.
	rep(j,1,H+1)rep(i,1,W+1)dist[i][j]=INF;
	//最初の点をスタートでありゴールと考えると,
	//dist[1][1]==1である.
	dist[1][1]=1;
	//(1,1)はすでに訪れた,という指標を立てる.
	que.push(P(1,1));
	//s[i][j]がゴール,もしくはゴールに行けないと
	//わかったときに終了する.
	while(que.size()){ 
		P p=que.front();
		que.pop();
		rep(i,0,4){
			//まず(1,1)の前後左右を調べる.
			int next_x=p.first+dx[i];
			int next_y=p.second+dy[i];
			if(s[next_x][next_y]=='.'&&
				next_x>0&&next_x<=W&&
				next_y>0&&next_y<=H&&
				dist[next_x][next_y]==INF){
				que.push(P(next_x,next_y));
				dist[next_x][next_y]=dist[p.first][p.second]+1;
			}
		}
	}
	return dist[W][H];
}

int main() {
	//input;
	cin>>H>>W;
	rep(j,1,H+1)rep(i,1,W+1){
		cin>>s[i][j];
		//'.'の点を数える.
		if(s[i][j]=='.')ans++;
	}

	//output;
	shortest_pass=BFS();
	//ゴールに行けないとき,dist[W][H]は更新されず
	//INFのままなので,"-1"を出力する.
	if(shortest_pass==INF)cout<<"-1"<<endl;
	//ゴールに行けるとき、その最短コース以外の'.'は
	//全て'#'にしても問題ない.
	else cout<<ans-shortest_pass<<endl;
}

Compiler output:
a.cc: In function 'int BFS()':
a.cc:3:24: error: 'll' was not declared in this scope
    3 | #define rep(i,a,n) for(ll i=a;i<n;i++)
      |                        ^~
a.cc:20:9: note: in expansion of macro 'rep'
   20 |         rep(j,1,H+1)rep(i,1,W+1)dist[i][j]=INF;
      |         ^~~
a.cc:20:13: error: 'j' was not declared in this scope
   20 |         rep(j,1,H+1)rep(i,1,W+1)dist[i][j]=INF;
      |             ^
a.cc:3:31: note: in definition of macro 'rep'
    3 | #define rep(i,a,n) for(ll i=a;i<n;i++)
      |                               ^
a.cc:20:25: error: expected ';' before 'i'
   20 |         rep(j,1,H+1)rep(i,1,W+1)dist[i][j]=INF;
      |                         ^
a.cc:3:27: note: in definition of macro 'rep'
    3 | #define rep(i,a,n) for(ll i=a;i<n;i++)
      |                           ^
a.cc:20:25: error: 'i' was not declared in this scope
   20 |         rep(j,1,H+1)rep(i,1,W+1)dist[i][j]=INF;
      |                         ^
a.cc:3:31: note: in definition of macro 'rep'
    3 | #define rep(i,a,n) for(ll i=a;i<n;i++)
      |                               ^
a.cc:3:24: error: 'll' was not declared in this scope
    3 | #define rep(i,a,n) for(ll i=a;i<n;i++)
      |                        ^~
a.cc:31:17: note: in expansion of macro 'rep'
   31 |                 rep(i,0,4){
      |                 ^~~
a.cc:31:21: error: 'i' was not declared in this scope
   31 |                 rep(i,0,4){
      |                     ^
a.cc:3:31: note: in definition of macro 'rep'
    3 | #define rep(i,a,n) for(ll i=a;i<n;i++)
      |                               ^
a.cc: In function 'int main()':
a.cc:3:24: error: 'll' was not declared in this scope
    3 | #define rep(i,a,n) for(ll i=a;i<n;i++)
      |                        ^~
a.cc:50:9: note: in expansion of macro 'rep'
   50 |         rep(j,1,H+1)rep(i,1,W+1){
      |         ^~~
a.cc:50:13: error: 'j' was not declared in this scope
   50 |         rep(j,1,H+1)rep(i,1,W+1){
      |             ^
a.cc:3:31: note: in definition of macro 'rep'
    3 | #define rep(i,a,n) for(ll i=a;i<n;i++)
      |                               ^
a.cc:50:25: error: expected ';' before 'i'
   50 |         rep(j,1,H+1)rep(i,1,W+1){
      |                         ^
a.cc:3:27: note: in definition of macro 'rep'
    3 | #define rep(i,a,n) for(ll i=a;i<n;i++)
      |                           ^
a.cc:50:25: error: 'i' was not declared in this scope
   50 |         rep(j,1,H+1)rep(i,1,W+1){
      |                         ^
a.cc:3:31: note: in definition of macro 'rep'
    3 | #define rep(i,a,n) for(ll i=a;i<n;i++)
      |                               ^