Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;


int dp[53][53];
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int H,W;
int a[53][53]={0};
bool visited[53][53];

ll dfs(int p,int q){
  if(visited[p][q])return dp[p][q];
  visited[p][q]=true;
  if(p==H-1 && q==W-1){
    dp[p][q]=1;
    return dp[p][q];
  }
  for(int i=0;i<4;i++){
    int x=p+dx[i],y=q+dy[i];
    if(a[x][y]==1)continue;
    if(x<0 || y<0 || x>=H || y>=W) continue;
    dp[p][q]=min(dp[p][q],1+dfs(x,y));
  }
  return dp[p][q];
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> H >> W;
  char c;
  ll kuro=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> c;
      if(c=='#'){
        a[i][j]=1;
        kuro++;
      }
      dp[i][j]=100000;
    }
  }
  dfs(0,0);
  if(dp[0][0]==100000){
    cout << -1 << endl;
    return 0;
  }
  ll ans=H*W-kuro-dp[0][0];
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'long long int dfs(int, int)':
a.cc:57:17: error: no matching function for call to 'min(int&, long long int)'
   57 |     dp[p][q]=min(dp[p][q],1+dfs(x,y));
      |              ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:57:17: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   57 |     dp[p][q]=min(dp[p][q],1+dfs(x,y));
      |              ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:57:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   57 |     dp[p][q]=min(dp[p][q],1+dfs(x,y));
      |              ~~~^~~~~~~~~~~~~~~~~~~~~