Language: C++

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

struct node{
    int x,y;
    node(){}
    node(int a,int b):x(a),y(b){}
};
char mp[100][100];
int minn,h,w;
int visit[100][100];
int step[100][100];
int next[4][2]={{0,-1},{-1,0},{0,1},{1,0}};
queue<node>q;
int bfs(){
    while(!q.empty()){
        int tx=q.front().x;
        int ty=q.front().y;
        q.pop();
        for(int i=0;i<4;i++){
            int xx=tx+next[i][0];
            int yy=ty+next[i][1];
            if(xx<0||xx>=h||yy<0||yy>=w) continue;
            if(xx==h-1&&yy==w-1) return step[tx][ty]+1;
            if(visit[xx][yy]==0&&mp[xx][yy]=='.'){
                visit[xx][yy]=1;
                q.push(node(xx,yy));
                step[xx][yy]=step[tx][ty]+1;
            }
        }
    }
    return -1;

}
int main(){
    int sum=0;
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++){
        getchar();
        for(int j=0;j<w;j++){
            scanf("%c",&mp[i][j]);
            if(mp[i][j]=='#') sum++;
        }
    }
    visit[0][0]=1;
    q.push(node(0,0));
    minn=bfs();
    if(minn==-1){
        printf("-1\n");
    }
    else printf("%d\n",h*w-minn-sum-1);
    return 0;
}

Compiler output:
a.cc: In function 'int bfs()':
a.cc:21:23: error: reference to 'next' is ambiguous
   21 |             int xx=tx+next[i][0];
      |                       ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/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:13:5: note:                 'int next [4][2]'
   13 | int next[4][2]={{0,-1},{-1,0},{0,1},{1,0}};
      |     ^~~~
a.cc:22:23: error: reference to 'next' is ambiguous
   22 |             int yy=ty+next[i][1];
      |                       ^~~~
/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:13:5: note:                 'int next [4][2]'
   13 | int next[4][2]={{0,-1},{-1,0},{0,1},{1,0}};
      |     ^~~~
a.cc:25:16: error: reference to 'visit' is ambiguous
   25 |             if(visit[xx][yy]==0&&mp[xx][yy]=='.'){
      |                ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:11:5: note:                 'int visit [100][100]'
   11 | int visit[100][100];
      |     ^~~~~
a.cc:26:17: error: reference to 'visit' is ambiguous
   26 |                 visit[xx][yy]=1;
      |                 ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:11:5: note:                 'int visit [100][100]'
   11 | int visit[100][100];
      |     ^~~~~
a.cc: In function 'int main()':
a.cc:45:5: error: reference to 'visit' is ambiguous
   45 |     visit[0][0]=1;
      |     ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:11:5: note:                 'int visit [100][100]'
   11 | int visit[100][100];
      |     ^~~~~