criyle/codenet-compile-errors huggingface dataset:
Language: C

#include<stdio.h>
#define inf 2000000

int stock[1000000000][3];
int fla[55][55];

int main(){
		int h,w,i,j,white=0;
		char s[55][55];
		scanf("%d%d",&h,&w);
		for(i=0;i<h;i++){
				scanf("%s",s[i]);
				for(j=0;j<w;j++){
						if(s[i][j]=='.')white++;
				}
		}
		for(i=0;i<h;i++){
				for(j=0;j<w;j++){
						fla[i][j]=inf;
				}
		}
		fla[0][0]=0;
		int st=0,fn=1;stock[0][0]=0,stock[0][1]=0,stock[0][2]=0;
		while(fn>st){
				int x=stock[st][0],y=stock[st][1];
				if(x!=0){
						if(fla[x-1][y]==inf){
								fla[x-1][y]=stock[st][2]+1;
								stock[fn][0]=x-1;
								stock[fn][1]=y;
								stock[fn][2]=stock[st][2]+1;
								fn++;
						}
				}if(x!=h-1){
						if(fla[x+1][y]==inf){
								fla[x+1][y]=stock[st][2]+1;
								stock[fn][0]=x+1;
								stock[fn][1]=y;
								stock[fn][2]=stock[st][2]+1;
								fn++;
						}
				}if(y!=0){
						if(fla[x][y-1]==inf){
								fla[x][y-1]=stock[st][2]+1;
								stock[fn][0]=x;
								stock[fn][1]=y-1;
								stock[fn][2]=stock[st][2]+1;
								fn++;
						}
				}if(y!=w-1){
						if(fla[x][y+1]==inf){
								fla[x][y+1]=stock[st][2]+1;
								stock[fn][0]=x;
								stock[fn][1]=y+1;
								stock[fn][2]=stock[st][2]+1;
								fn++;
						}
				}
				st++;
				if(fla[h-1][w-1]!=inf)break;
		}
		if(fla[h-1][w-1]==inf)puts("-1");
		else printf("%d\n",white-fla[h-1][w-1]-1);
		return 0;
}


Compiler output:
/tmp/ccLs9W0R.o: in function `main':
main.c:(.text+0x129): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccLs9W0R.o
main.c:(.text+0x14e): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccLs9W0R.o
main.c:(.text+0x20f): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccLs9W0R.o
main.c:(.text+0x27c): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccLs9W0R.o
main.c:(.text+0x35a): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccLs9W0R.o
main.c:(.text+0x3c7): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccLs9W0R.o
main.c:(.text+0x4a0): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccLs9W0R.o
main.c:(.text+0x50d): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccLs9W0R.o
main.c:(.text+0x5eb): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccLs9W0R.o
main.c:(.text+0x658): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccLs9W0R.o
main.c:(.text+0x72e): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
#define inf 2000000

int stock[10000000000][3];
int fla[55][55];

int main(){
		int h,w,i,j,white=0;
		char s[55][55];
		scanf("%d%d",&h,&w);
		for(i=0;i<h;i++){
				scanf("%s",s[i]);
				for(j=0;j<w;j++){
						if(s[i][j]=='.')white++;
				}
		}
		for(i=0;i<h;i++){
				for(j=0;j<w;j++){
						fla[i][j]=inf;
				}
		}
		fla[0][0]=0;
		int st=0,fn=1;stock[0][0]=0,stock[0][1]=0,stock[0][2]=0;
		while(fn>st){
				int x=stock[st][0],y=stock[st][1];
				if(x!=0){
						if(fla[x-1][y]==inf){
								fla[x-1][y]=stock[st][2]+1;
								stock[fn][0]=x-1;
								stock[fn][1]=y;
								stock[fn][2]=stock[st][2]+1;
								fn++;
						}
				}if(x!=h-1){
						if(fla[x+1][y]==inf){
								fla[x+1][y]=stock[st][2]+1;
								stock[fn][0]=x+1;
								stock[fn][1]=y;
								stock[fn][2]=stock[st][2]+1;
								fn++;
						}
				}if(y!=0){
						if(fla[x][y-1]==inf){
								fla[x][y-1]=stock[st][2]+1;
								stock[fn][0]=x;
								stock[fn][1]=y-1;
								stock[fn][2]=stock[st][2]+1;
								fn++;
						}
				}if(y!=w-1){
						if(fla[x][y+1]==inf){
								fla[x][y+1]=stock[st][2]+1;
								stock[fn][0]=x;
								stock[fn][1]=y+1;
								stock[fn][2]=stock[st][2]+1;
								fn++;
						}
				}
				st++;
				if(fla[h-1][w-1]!=inf)break;
		}
		if(fla[h-1][w-1]==inf)puts("-1");
		else printf("%d\n",white-fla[h-1][w-1]-1);
		return 0;
}


Compiler output:
/tmp/ccD4S3Pc.o: in function `main':
main.c:(.text+0x129): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccD4S3Pc.o
main.c:(.text+0x14e): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccD4S3Pc.o
main.c:(.text+0x20f): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccD4S3Pc.o
main.c:(.text+0x27c): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccD4S3Pc.o
main.c:(.text+0x35a): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccD4S3Pc.o
main.c:(.text+0x3c7): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccD4S3Pc.o
main.c:(.text+0x4a0): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccD4S3Pc.o
main.c:(.text+0x50d): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccD4S3Pc.o
main.c:(.text+0x5eb): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccD4S3Pc.o
main.c:(.text+0x658): relocation truncated to fit: R_X86_64_PC32 against symbol `fla' defined in .bss section in /tmp/ccD4S3Pc.o
main.c:(.text+0x72e): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

from collections import deque

def calc_min_root(start_x, start_y, goal_x, goal_y):
    global maze, row, column
    X = [0, 0, 1, -1]
    Y = [1, -1, 0, 0]
    visited = [[None] * (goal_y+1) for _ in range(goal_x+1)]
    visited[start_x][start_y] = 1
    q_row = deque()
    q_column = deque()
    q_row.append(start_x)
    q_column.append(start_y)
    while q_row:
        row = q_row.popleft()
        column = q_column.popleft()
        for dx, dy in zip(X, Y):
            new_row = row + dx
            new_column = column + dy
            if 0 <= new_row < row and 0 <= new_column < column:
                if visited[new_row][new_column] == None and maze[new_row][new_column] == '.':
                    visited[new_row][new_column] = visited[row][column] + 1
                    q_row.append(new_row)
                    q_column.append(new_column)
                if new_row == goal_x and new_column == goal_y:
                    return visited[goal_x][goal_y]

if __name__ == "__main__":
    row, column = map(int, input().split())
    maze = []
    for _ in range(row):
        one_row = list(input())
        maze.append(one_row)
    count_sharp = 0
    for one_row in maze:
        count_sharp += one_row.count('#')
    
    count_min_root_cost = calc_min_root(0, 0, row-1, column-1)
    
    print(row * column - count_min_root_cost - count_sharp)


Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import deque
      | ^~~~
Language: C++

#include"bits/stdc++.h"
using namespace std;
int main(){
    int H,W;
    cin >> H >> W;
    string S[50];
    for(int i=0; i<H; i++) cin >> S[i];
    int white = 0;
    int cost[50][50];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cost[i][j] = 3000;
            if(S[i][j] == '.') white+++
        }
    }
    
    int dy[4] = {-1,1,0,0};
    int dx[4] = {0,0,-1,1};
    queue<pair<int,int>> que;
    cost[0][0] = 0;
    que.push(make_pair(0,0));
    while(!que.empty()){
        int y = que.front().first;
        int x = que.front().second;
        que.pop();
        for(int i=0; i<4; i++){
            if(y+dy[i] < 0 || y+dy[i] >= H || x+dx[i] < 0 || x+dx[i] >= W) continue;
            if(S[y+dy[i]][x+dx[i]] == '.'){
                if(cost[y+dy[i]][x+dx[i]] > cost[y][x]+1){
                    cost[y+dy[i]][x+dx[i]] = cost[y][x]+1;
                    que.push(make_pair(y+dy[i],x+dx[i]));
                }
            }
            else{
                if(cost[y+dy[i]][x+dx[i]] > cost[y][x]){
                    cost[y+dy[i]][x+dx[i]] = cost[y][x];
                    que.push(make_pair(y+dy[i],x+dx[i]));
                }
            }
        }
    }

    if(cost[H-1][W-1] == 3000) cout << -1 << endl;
    else cout << white - cost[H-1][W-1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: expected primary-expression before '}' token
   14 |         }
      |         ^
Language: C++

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

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

int main(void) {
    int h, w;
    cin >> h >> w;
    vector<string> mp(h);

    for(auto &l: mp)
        cin >> l;

    priority_queue<pair<int,int>> q;
    q.push(pair<int,int>(-0, 0*w+0));

    vector<int> dis(w*h, 1e9);

    while(!q.empty()) {
        int c = -q.top().first;
        int i = q.top().second / w;
        int j = q.top().second % w;
        q.pop();
        if(c > dis[i*w + j]) continue;
        dis[i*w + j] = c;

        for(int k=0; k<4; k++) {
            int ni = i + dy[k];
            int nj = j + dx[k];
            if(!(0 <= ni && ni < h)) continue;
            if(!(0 <= nj && nj < w)) continue;
            if(mp[ni][nj] != '.') continue;
            if(c+1 > dis[ni*w + nj]) continue;
            q.push(pair<int,int>(-(c+1), ni*w + nj));
        }
    }

    if(dis[w*h-1] == 1e9) {
        cout << -1 << endl;
        return;
    }

    long wcnt = 0;
    for(auto &l: mp)
        for(auto &c: l)
            if(c == '.') wcnt++;

    cout << wcnt - dis[w*h-1] - 1 << endl;
}


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

#include <bits/stdc++.h>

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

typedef pair<int,int> pi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

const int maxn = 55;

char G[maxn][maxn];
int D[maxn][maxn];
int H,W;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

bool valid(int x,int y){
    if(x >= 0 && x < H && y>=0 && y < W && G[x][y]=='.' && D[x][y] == -1) return true;
    return false;
}

int main()
{
    scanf("%d %d",&H,&W);
    getchar();
    _for(i,0,H){
        gets(G[i]);
    }
    int white = 0;
    _for(i,0,H){
        _for(j,0,W){
            if(G[i][j] == '.') white++;
        }
    }
    if(G[0][0] == '#'){printf("-1");return 0;}
    memset(D,-1,sizeof(D));
    D[0][0] = 1;
    pi st = make_pair(0,0);
    queue<pi> que;
    que.push(st);
    while(!que.empty()){
        pi pp = que.front();
        que.pop();
        int x = pp.first;
        int y = pp.second;
        _for(i,0,4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(valid(nx,ny)){
                D[nx][ny] = D[x][y] + 1;
                que.push(make_pair(nx,ny));
            }
        }
    }

    if(D[H-1][W-1] == -1)printf("-1");
    else printf("%d\n",white-D[H-1][W-1]);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   44 |         gets(G[i]);
      |         ^~~~
      |         getw
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int maxn = 500;
int dist[maxn][maxn];
char g[maxn][maxn];
int main(){
  int n, m; cin >> n >> m;
  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin >> g[i][j];
  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) dist[i][j] = -1;
  int tot = 0;
  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) tot += g[i][j] == '.';
  dist[0][0] = 0;
  queue<pair<int,int>> q;
  q.push({0,0});
  while(!q.empty()){
    int x, y; tie(x, y) = q.front(); q.pop();
    for(int dx = -1; dx <= 1; dx++) for(int dy = -1; dy <= 1; dy++){
      if(abs(dx) + abs(dy) != 1) continue;
      int nx = x + dx, ny = y + dy;
      if(nx >= 0 && nx < n && ny >= 0 && ny < m && g[nx][ny] == '.' && dist[nx][ny] == -1){
        dist[nx][ny] = dist[x][y] + 1;
        q.push({nx, ny});
      }
  }
  if(dist[n - 1][m - 1] == -1) cout << -1 << endl;
  else cout << tot - dist[n - 1][m - 1] - 1 << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:2: error: expected '}' at end of input
   28 | }
      |  ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9+7
using namespace std;
typedef pair<int,int> P;
int h, w;
char ch[50][50];
int a[50][50];
queue<P> que;
int ax[4] = {0, -1 , 0, 1}, ay[4] = {1, 0, -1, 0};
int bfs() {
    rep(i, h) {
        rep(j, w) {
            a[i][j] = INF;
        }
    }
    que.push(P(0, 0));
    a[0][0] = 0;
    while (que.size()) {
        P p = que.front();que.pop();
        rep(i, 4) {
            int px = p.first + ax[i], py = p.second + ay[i];
            if (px >= 0 && py >= 0 && px < h && py < w && a[px][py] == INF && ch[px][py] != '#') {
                que.push(P(px, py));
                a[px][py] = a[p.first][p.second] + 1;
            }
        }
    }
    return a[h - 1][w - 1];
}
signed main() {
    int c = 0;
    cin >> h >> w;
    rep(i, h) {
        rep(j, w) {
            cin >> ch[i][j];
            if (ch[i][j] == '#') {
                c++;
            }
        }
    }
    if (h * w - 1 - bfs() - c < 0) {
        cout < -1 << endl;
    } else {
        cout << h * w - 1 - bfs() - c << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:19: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   52 |         cout < -1 << endl;
      |                ~~~^~~~~~~
Language: Java

import java.util.stream.*;
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        char[][] s = IntStream.range(0, h).mapToObj(i -> scanner.next().toCharArray()).toArray(char[][]::new);
        int[][] dist = new int[h][w];
        Arrays.stream(dist).forEach(array -> Arrays.fill(array, 10000));
        dist[0][0] = 0;
        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(0);
        while (!deque.isEmpty()) {
            int i = deque.poll();
            int y = i % w;
            int x = i / w;

            Util.println(i, y, x);
            if (y > 0 && dist[y - 1][x] > dist[y][x] + 1 && s[y - 1][x] == '.') {
                dist[y - 1][x] = dist[y][x] + 1;
                deque.add(i - 1);
            }
            if (y < h - 1 && dist[y + 1][x] > dist[y][x] + 1 && s[y + 1][x] == '.') {
                dist[y + 1][x] = dist[y][x] + 1;
                deque.add(i + 1);
            }
            if (x > 0 && dist[y][x - 1] > dist[y][x] + 1 && s[y][x - 1] == '.') {
                dist[y][x - 1] = dist[y][x] + 1;
                deque.add(i - w);
            }
            if (x < w - 1 && dist[y][x + 1] > dist[y][x] + 1 && s[y][x + 1] == '.') {
                dist[y][x + 1] = dist[y][x] + 1;
                deque.add(i + w);
            }
        }

        int ans = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (s[i][j] == '.') {
                    ans++;
                }
            }
        }

        if (dist[h - 1][w - 1] == 10000) {
            System.out.println(-1);
        } else {
            ans -= dist[h - 1][w - 1] + 1;
            System.out.println(ans);
        }
        Arrays.stream(dist).map(Arrays::toString).forEach(System.out::println);
    }
}

Compiler output:
Main.java:21: error: cannot find symbol
            Util.println(i, y, x);
            ^
  symbol:   variable Util
  location: class Main
1 error
Language: Java

import java.util.stream.*;
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        char[][] s = IntStream.range(0, h).mapToObj(i -> scanner.next().toCharArray()).toArray(char[][]::new);
        int[][] dist = new int[h][w];
        Arrays.stream(dist).forEach(array -> Arrays.fill(array, 10000));
        dist[0][0] = 0;
        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(0);
        while (!deque.isEmpty()) {
            int i = deque.poll();
            int y = i % w;
            int x = i / w;

            Util.println(i, y, x);
            if (y > 0 && dist[y - 1][x] > dist[y][x] + 1 && s[y - 1][x] == '.') {
                dist[y - 1][x] = dist[y][x] + 1;
                deque.add(i - 1);
            }
            if (y < h - 1 && dist[y + 1][x] > dist[y][x] + 1 && s[y + 1][x] == '.') {
                dist[y + 1][x] = dist[y][x] + 1;
                deque.add(i + 1);
            }
            if (x > 0 && dist[y][x - 1] > dist[y][x] + 1 && s[y][x - 1] == '.') {
                dist[y][x - 1] = dist[y][x] + 1;
                deque.add(i - w);
            }
            if (x < w - 1 && dist[y][x + 1] > dist[y][x] + 1 && s[y][x + 1] == '.') {
                dist[y][x + 1] = dist[y][x] + 1;
                deque.add(i + w);
            }
        }

        int ans = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (s[i][j] == '.') {
                    ans++;
                }
            }
        }
        ans -= dist[h - 1][w - 1] + 1;
        System.out.println(ans);
    }
}

Compiler output:
Main.java:21: error: cannot find symbol
            Util.println(i, y, x);
            ^
  symbol:   variable Util
  location: class Main
1 error
Language: C++

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>

// template {{{
using namespace std;

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))

using int64 = long long;

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

bool in_field(int W, int H, int x, int y) {
  return (0 <= x && x < W) && (0 <= y && y < H);
}

// pair
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) {
  return s << "(" << p.first << ", " << p.second << ")";
}
// vector
template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << "\t";
  }
  return s;
}

// 2 dimentional vector
template <typename T>
ostream &operator<<(ostream &s, const vector<vector<T>> &vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

// }}}

// url: https://atcoder.jp/contests/abc088/tasks/abc088_d

int H, W;
char s[50][50];
int num[50][50];

typedef pair<int, int> P;

int main() {
  fill(num, 0);
  cin >> H >> W;
  rep(i, H) rep(j, W) { cin >> s[j][i]; }

  queue<P> que;
  que.push(P(0, 0));
  num[0][0] = 1;

  int white = 0;
  rep(i, H) rep(j, W) {
    if (s[j][i] == '.') {
      white++;
    }
  }
  // cout << "white:" << white << endl;
  while (que.size()) {
    P p = que.front();
    que.pop();
    // cout << p << endl;

    rep(i, 4) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];

      if (nx == W - 1 && ny == H - 1) {
        cout << white - (num[p.first][p.second] + 1) << endl;
        return 0;
      }

      if (in_field(W, H, nx, ny) && num[nx][ny] == 0 && s[nx][ny] == '.') {
        que.push(P(nx, ny));
        num[nx][ny] = num[p.first][p.second] + 1;
      }
    }
  }

  cout << -1 << endl;
  return 0;
}

// vim: foldmethod=marker


Compiler output:
a.cc: In function 'int main()':
a.cc:13:20: error: 'memset' was not declared in this scope
   13 | #define fill(x, y) memset(x, y, sizeof(x))
      |                    ^~~~~~
a.cc:61:3: note: in expansion of macro 'fill'
   61 |   fill(num, 0);
      |   ^~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <set>
  +++ |+#include <cstring>
    6 | #include <string>
Language: C++


int H,W;
char field[100][100];

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> H >> W;

	int cnt_w = 0;

	for (int i = 0;i < 100;i++){
		for (int j = 0;j < 100;j++){
			field[i][j] = '#';
		}
	}

	for (int i = 1;i <= H;i++){
		for (int j = 1;j <= W;j++){
			cin >> field[i][j];
			if(field[i][j] == '.') cnt_w++;
		}
	}

	int dist[100][100]; memset(dist,-1,sizeof(dist));
	queue<P> que;
	dist[1][1] = 1;
	que.push(P(1,1));

	while(que.size()){
		P p = que.front(); que.pop();
		int x = p.second, y = p.first;
		for (int i = 0;i < 4;i++){
			int ny = y+dy[i];
			int nx = x+dx[i];
			if(dist[ny][nx] == -1 && field[ny][nx] == '.'){
				dist[ny][nx] = dist[y][x]+1;
				que.push(P(ny,nx));
			}
		}
	}

	if(dist[H][W] == -1) cout << -1 << endl;
	else cout << cnt_w-dist[H][W] << endl;

	return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'cin' was not declared in this scope
    9 |         cin.tie(0);
      |         ^~~
a.cc:10:9: error: 'ios' has not been declared
   10 |         ios::sync_with_stdio(false);
      |         ^~~
a.cc:29:29: error: 'memset' was not declared in this scope
   29 |         int dist[100][100]; memset(dist,-1,sizeof(dist));
      |                             ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | 
a.cc:30:9: error: 'queue' was not declared in this scope
   30 |         queue<P> que;
      |         ^~~~~
a.cc:30:15: error: 'P' was not declared in this scope
   30 |         queue<P> que;
      |               ^
a.cc:30:18: error: 'que' was not declared in this scope
   30 |         queue<P> que;
      |                  ^~~
a.cc:35:18: error: expected ';' before 'p'
   35 |                 P p = que.front(); que.pop();
      |                  ^~
      |                  ;
a.cc:36:25: error: 'p' was not declared in this scope
   36 |                 int x = p.second, y = p.first;
      |                         ^
a.cc:38:34: error: 'y' was not declared in this scope; did you mean 'ny'?
   38 |                         int ny = y+dy[i];
      |                                  ^
      |                                  ny
a.cc:47:30: error: 'cout' was not declared in this scope
   47 |         if(dist[H][W] == -1) cout << -1 << endl;
      |                              ^~~~
a.cc:47:44: error: 'endl' was not declared in this scope
   47 |         if(dist[H][W] == -1) cout << -1 << endl;
      |                                            ^~~~
a.cc:48:14: error: 'cout' was not declared in this scope
   48 |         else cout << cnt_w-dist[H][W] << endl;
      |              ^~~~
a.cc:48:42: error: 'endl' was not declared in this scope
   48 |         else cout << cnt_w-dist[H][W] << endl;
      |                                          ^~~~
Language: C++

#include <iostream>
#include <string>
#include <queue>
using namespace std;

int H, W, dist[55][55], num_white;
string S[55];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
queue<pair<int, int>> Q;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> H >> W;
  for (int i = 0; i < H; ++i){
    cin >> S[i];
    for (int j = 0; j < W; ++j){
      if (S[i][j] == '.') {
        ++num_white;
        dist[i][j] = 1e8;
      }
      else dist[i][j] = 1e9;
    }
  }
  
  dist[0][0] = 0;


  Q.push(make_pair(0, 0));


  while (!Q.empty()){
    int x, y;
    x = Q.front().first; y = Q.front().second;
    Q.pop();

    for (int i = 0; i < 4; ++i){
      int x1, y1;
      x1 = x + dx[i]; y1 = y + dy[i];
      if (x1 < 0 || H <= x1 || y1 < 0 || W <= y1 || S[i][j] == '#' || dist[x1][y1] < dist[x][y]) continue;
      dist[x1][y1] = dist[x][y] + 1;
      Q.push(make_pair(x1, y1));
    }
  }

  if (dist[H-1][W-1] == 1e8){
    cout << "-1" << endl;
  }else{
    cout << '\n' << (num_white - dist[H-1][W-1] - 1) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:58: error: 'j' was not declared in this scope
   42 |       if (x1 < 0 || H <= x1 || y1 < 0 || W <= y1 || S[i][j] == '#' || dist[x1][y1] < dist[x][y]) continue;
      |                                                          ^
Language: C++

#include <iostream>
#include <string>
#include <queue>
using namespace std;
#define INF 100000000

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int H, W, dist[55][55];
  int num_white = 0;
  cin >> H >> W;
  for (int i = 0; i < H; ++i){
    string S; cin >> S;
    for (int j = 0; j < W; ++j){
      if (S[i][j] == '.') ++num_white;
    }
  }
  for (int i = 0; i < H; ++i){
    for (int j = 0; j < W; ++j){
      dist[i][j] = 1e9;
    }
  }
  dist[0][0] = 0;

  queue<pair<int, int>> Q;
  Q.push(make_pair(0, 0));
  int dx[4] = {1, 0, -1, 0};
  int dy[4] = {0, 1, 0, -1};

  while (!Q.empty()){
    int x, y;
    x = Q.front().first; y = Q.front().second;
    Q.pop();

    for (int i = 0; i < 4; ++i){
      int x1, y1;
      x1 = x + dx[i]; y1 = y + dy[i];
      if (x1 < 0 || H <= x1 || y1 < 0 || W <= y1 || S[x1][y1] == '#' || dist[x1][y1] < dist[x][y]) continue;
      dist[x1][y1] = dist[x][y] + 1;
      Q.push(make_pair(x1, y1));
    }
  }

  if (dist[H-1][W-1] == INF - 1){
    cout << "-1" << endl;
  }else{
    cout << '\n' << (num_white - dist[H-1][W-1] - 1) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:15: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   17 |       if (S[i][j] == '.') ++num_white;
      |               ^
a.cc:40:53: error: 'S' was not declared in this scope
   40 |       if (x1 < 0 || H <= x1 || y1 < 0 || W <= y1 || S[x1][y1] == '#' || dist[x1][y1] < dist[x][y]) continue;
      |                                                     ^
Language: C++

#include <iostream>
#include <queue>
using namespace std;
#define INF 100000000

int main(){

  int H, W, dist[55][55];
  char S[55][55];
  int num_white = 0;
  cin >> H >> W;
  for (int i = 0; i < H; ++i){
    for (int j = 0; j < W; ++j){
      cin >> S[i][j];
      if (c == '.'){
        ++num_white;
      }else{
        dist[i][j] = INF;
      }
    }
  }
  dist[H-1][W-1] = INF - 1;

  queue<pair<int, int>> Q;
  Q.push(make_pair(0, 0));
  int dx[4] = {1, 0, -1, 0};
  int dy[4] = {0, 1, 0, -1};

  while (!Q.empty()){
    int x, y;
    x = Q.front().first; y = Q.front().second;
    Q.pop();

    for (int i = 0; i < 4; ++i){
      int x1, y1;
      x1 = x + dx[i]; y1 = y + dy[i];
      if (x1 < 0 || H <= x1 || y1 < 0 || W <= y1 || S[x1][y1] == '#' || dist[x1][y1] < dist[x][y]) continue;
      dist[x1][y1] = dist[x][y] + 1;
      Q.push(make_pair(x1, y1));
    }
  }

  if (dist[H-1][W-1] == INF - 1){
    cout << "-1" << endl;
  }else{
    cout << '\n' << (num_white - dist[H-1][W-1] - 1) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:11: error: 'c' was not declared in this scope
   15 |       if (c == '.'){
      |           ^
Language: C++

#include <iostream>
#include <queue>
using namespace std;
#define INF 100000000

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int H, W, dist[55][55];
  int num_white = 0;
  cin >> H >> W;
  for (int i = 0; i < H; ++i){
    for (int j = 0; j < W; ++j){
      char c; cin >> c;
      if (c == '.'){
        dist[i][j] = INF - 1;
        ++num_white;
      }else{
        dist[i][j] = INF;
      }
    }
  }
  dist[0][0] = 0;

  queue<pair<int, int>> Q;
  Q.push(make_pair(0, 0))
  int dx[4] = {1, 0, -1, 0};
  int dy[4] = {0, 1, 0, -1};

  while (!Q.empty()){
    int x, y;
    x = Q.front().first; y = Q.front().second;
    Q.pop();

    for (int i = 0; i < 4; ++i){
      int x1, y1;
      x1 = x + dx[i]; y1 = y + dy[i];
      if (x1 < 0 || H <= x1 || y1 < 0 || W <= y1 || dist[x1][y1] == INF || dist[x1][y1] < dist[x][y]) continue;
      dist[x1][y1] = dist[x][y] + 1;
      Q.push(make_pair(x1, y1));
    }
  }

  if (dist[H-1][W-1] == INF - 1){
    cout << "-1" << endl;
  }else{
    cout << '\n' << (num_white - dist[H-1][W-1] - 1) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:26: error: expected ';' before 'int'
   27 |   Q.push(make_pair(0, 0))
      |                          ^
      |                          ;
   28 |   int dx[4] = {1, 0, -1, 0};
      |   ~~~                     
a.cc:38:16: error: 'dx' was not declared in this scope; did you mean 'x'?
   38 |       x1 = x + dx[i]; y1 = y + dy[i];
      |                ^~
      |                x
Language: C++

#include <bits/stdc++.h>
using namespace std;
int H,W;
char board[50][50];
int white;
struct P {int h,w,d;};
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};


int dfs(){
	queue<P> Q;
  	Q.push(P{0,0,0});
    board[0][0]='#';  
  
    while(true){  
  	P p=Q.front();Q.pop();
    if (p.h==H-1 && p.w==W-1)return p.d;
  	board[p.h][p.w]='#';
	int nh,nw;
  	for(int i=;i<4;i++){
      nh=p.h+dh[i];nw=p.h+dw[i];
  	  if(0<=nh && nh<H && 0<=nw && nw<W &&  board[nh][nw]=='.'){
        Q.push(P{nh,nw,p.d+1});
      }
    }
    }
}
		
int main(){
	cin >>H >>W;
  for (int i=0;i<W;i++){
    for (int j=0;j<H;j++){
      cin >>board[i][j];  
      if(>board[i][j]=='.')white++;
    }}
  cout << white - dfs() << endl;
  
    }
    

Compiler output:
a.cc: In function 'int dfs()':
a.cc:21:19: error: expected primary-expression before ';' token
   21 |         for(int i=;i<4;i++){
      |                   ^
a.cc: In function 'int main()':
a.cc:35:10: error: expected primary-expression before '>' token
   35 |       if(>board[i][j]=='.')white++;
      |          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int H,W;
char board[50][50];
int white;
struct P {int h,w,d;};
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};


int dfs(){
	queue<P> Q;
  	Q.push(P{0,0,0});
    board[0][0]='#';  
  
    while(true){  
  	P p=Q.top();Q.pop();
    if (p.h==H-1 && p.w==W-1)return p.d;
  	board[p.h][p.w]='#';
	int nh,nw;
  	for(int i=;i<4;i++){
      nh=p.h+dh[i];nw=p.h+dw[i];
  	  if(0<=nh && nh<H && 0<=nw && nw<W &&  board[nh][nw]=='.'){
        Q.push(P{nh,nw,p.d+1});
      }
    }
    }
		
int main(){
	cin >>H >>W;
  for (int i=0;i<W;i++){
    for (int j=0;j<H;j++){
      cin >>board[i][j];  
      if(>board[i][j]=='.')white++;
    }}
  cout << white - dfs() << endl;
  
    }
    

Compiler output:
a.cc: In function 'int dfs()':
a.cc:17:15: error: 'class std::queue<P>' has no member named 'top'; did you mean 'pop'?
   17 |         P p=Q.top();Q.pop();
      |               ^~~
      |               pop
a.cc:21:19: error: expected primary-expression before ';' token
   21 |         for(int i=;i<4;i++){
      |                   ^
a.cc:29:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   29 | int main(){
      |         ^~
a.cc:29:9: note: remove parentheses to default-initialize a variable
   29 | int main(){
      |         ^~
      |         --
a.cc:29:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:29:11: error: a function-definition is not allowed here before '{' token
   29 | int main(){
      |           ^
a.cc:38:6: error: expected '}' at end of input
   38 |     }
      |      ^
a.cc:11:10: note: to match this '{'
   11 | int dfs(){
      |          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int H,W;
char board[50][50];
int white;
struct P {int h,w,d;}
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};


int dfs(){
	queue<P> Q;
  	Q.push(P{0,0,0})
    board[0][0]='#';  
  
    while(true){  
  	P p=Q.top();Q.pop();
    if (p.h==H-1 && p.w==W-1)return p.d;
  	board[p.h][p.w]='#';
	int nh,nw;
  	for(int i=;i<4;i++){
      nh=p.h+dh[i];nw=p.h+dw[i];
  	  if(0<=nh && nh<H && 0<=nw && nw<W &&  board[nh][nw]=='.'){
        board.push(P{nh,nw,p.d+1})
      }
    }
    }
		
int main(){
	cin >>H >>W;
  for (int i=0;i<W;i++){
    for (int j=0;j<H;j++){
      cin >>board[i][j];  
      if(>board[i][j]=='.')white++;
    }}
  cout << white - dfs() << endl;
  
    }
    

Compiler output:
a.cc:6:22: error: expected ';' after struct definition
    6 | struct P {int h,w,d;}
      |                      ^
      |                      ;
a.cc: In function 'int dfs()':
a.cc:13:25: error: expected ';' before 'board'
   13 |         Q.push(P{0,0,0})
      |                         ^
      |                         ;
   14 |     board[0][0]='#';
      |     ~~~~~                
a.cc:17:15: error: 'class std::queue<P>' has no member named 'top'; did you mean 'pop'?
   17 |         P p=Q.top();Q.pop();
      |               ^~~
      |               pop
a.cc:21:19: error: expected primary-expression before ';' token
   21 |         for(int i=;i<4;i++){
      |                   ^
a.cc:24:15: error: request for member 'push' in 'board', which is of non-class type 'char [50][50]'
   24 |         board.push(P{nh,nw,p.d+1})
      |               ^~~~
a.cc:29:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   29 | int main(){
      |         ^~
a.cc:29:9: note: remove parentheses to default-initialize a variable
   29 | int main(){
      |         ^~
      |         --
a.cc:29:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:29:11: error: a function-definition is not allowed here before '{' token
   29 | int main(){
      |           ^
a.cc:38:6: error: expected '}' at end of input
   38 |     }
      |      ^
a.cc:11:10: note: to match this '{'
   11 | int dfs(){
      |          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int INF = 10000;
int R, C;
int sx, sy, gx, gy;
vector<int> move_x = {0, 0, 1, -1};
vector<int> move_y = {1, -1, 0, 0};
typedef pair <int, int> P;

void bfs(vector<vector<int>>& Time, vector<vector<char>>& MAP){
    queue<P> que;
    que.push(P(sx, sy));
    Time.at(sx).at(sy) = 0;
    
    int prex, prey;
    while (que.size()){
        P p = que.front(); que.pop();
        if (p.first == gx && p.second == gy){
            return;
        }
        for (int i = 0; i < 4; i++){
            prex = p.first + move_x.at(i); prey = p.second + move_y.at(i);
            if (prex >= 0 && prey >= 0 && prex < R && prey < C && MAP.at(prex).at(prey) != '#' && Time.at(prex).at(prey) == INF){
                que.push(P(prex, prey));
                Time.at(prex).at(prey) = Time.at(p.first).at(p.second) + 1;
            }
        }        
    }
}

int main(){
    cin >> R >> C;
    char temp;
    sx = 0; sy = 0; gx = R - 1; gy = C - 1;
    vector<vector<char>> MAP(R, vector<char>(C));
    vector<vector<int>> Time(R, vector<int>(C));
    int cnt = 0;
    for (int i = 0; i < R; i++){
        for (int j = 0; j < C; j++){
            cin >> temp;
            MAP.at(i).at(j) = temp; 
            Time.at(i).at(j) = INF;
            if (temp == '.'){
              cnt++;
            }
        }
    }

    bfs(Time, MAP);
    if (Time.at(gx).at(gy) == INF){
      cout << -1 << endl;
    }else{
      cout << cnt - Time.at(i).at(j) - 1 << endl; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:29: error: 'i' was not declared in this scope
   53 |       cout << cnt - Time.at(i).at(j) - 1 << endl;
      |                             ^
a.cc:53:35: error: 'j' was not declared in this scope; did you mean 'jn'?
   53 |       cout << cnt - Time.at(i).at(j) - 1 << endl;
      |                                   ^
      |                                   jn
a.cc:54:2: error: expected '}' at end of input
   54 | }
      |  ^
a.cc:31:11: note: to match this '{'
   31 | int main(){
      |           ^
Language: Java

import  java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    
    String[] s = sc.nextLine().split(" ");
    int H = Integer.parseInt(s[0]);
    int W = Integer.parseInt(s[1]);
    
    char[][] map = new char[H][W];
    int[][] route = new int[H][W];
    
    int dots = 0;
    for(int i = 0; i < H; i++){
      String str = sc.nextLine();
      for(int j = 0; j < W; j++){
        map[i][j] = str.charAt(j);
        if(i == 0 && j == 0){
          route[i][j] = 1;
          dots++;
        }else if(map[i][j] == '.'){
          route[i][j] = 0;
          dots++;
        }else{
          route[i][j] = -1;
        }
      } 
    }
    
    int[] ih = {+1, 0, -1, 0};
    int[] iw = {0, +1, 0, -1};
    
    Queue<Integer> qh = new ArrayDeque<>();
    Queue<Integer> qw = new ArrayDeque<>();
    qh.add(0);
    qw.add(0);
    
    while(qh.size() > 0){
      int nh = qx.poll();
      int nw = qy.poll();
      
      if(nh == H - 1 && nw == W - 1){
        break;
      }
      
      for(int i = 0; i < 4; i++){
        int fh = nh + ih[i];
        int fw = nw + iw[i];
        
        if(fh >= 0 && fw >= 0 && fh < H && fw < W && route[fh][fw] == 0){
          qh.add(fh);
          qw.add(fw);
          route[fh][fw] = route[nh][nw] + 1;
        }
      }
    }
    int ans = dots - route[H - 1][W - 1];
    System.out.println(ans);
  }
}

Compiler output:
Main.java:40: error: cannot find symbol
      int nh = qx.poll();
               ^
  symbol:   variable qx
  location: class Main
Main.java:41: error: cannot find symbol
      int nw = qy.poll();
               ^
  symbol:   variable qy
  location: class Main
2 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define M 1000000000
int h,w,cnt;
char c[52][52];
vector<vector<int>> a(52,vector<int>(52,M));
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
queue<pair<int,int>> q;
bfs(int i,int j){
  for(int k=0;k<4;k++){
    if(c[i+dx[k]][j+dy[k]]=='.'){
      if(a[i][j]+1<a[i+dx[k]][j+dy[k]]){
        a[i+dx[k]][j+dy[k]]=a[i][j]+1;
        q.push(make_pair(i+dx[k],j+dy[k]));
      }
    }
  }
}
int main(){
  cin>>h>>w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>c[i][j];
      if(c[i][j]=='#'){
        cnt++;
      }
    }
  }
  a[1][1]=1;
  bfs(1,1);
  while(!q.empty()){
    bfs(q.front().first,q.front().second);
    q.pop();
  }
  if(a[h][w]==M)cout<<-1;
  else cout<<h*w-a[h][w]-cnt;
}

Compiler output:
a.cc:9:1: error: ISO C++ forbids declaration of 'bfs' with no type [-fpermissive]
    9 | bfs(int i,int j){
      | ^~~
a.cc: In function 'int bfs(int, int)':
a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
   18 | }
      | ^
Language: Java

import java.util.Scanner;
import java.util.ArrayDeque;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] a = new char[h][w];
		long black=0;
		ArrayDeque<Integer> queueh = new ArrayDeque<Integer>();
		ArrayDeque<Integer> queuew = new ArrayDeque<Integer>();
		for(int i = 0; i<h; i++){
			String c = sc.next();
			for(int j = 0; j<w; j++){
				a[i][j]=c.charAt(j);
				if(a[i][j]=='#'){
					black++;
				}
			}
		}
		int[] start = {0,0};
		queueh.add(start);
		long countsub=1;
		long count=1;
		while(a[h-1][w-1]!='#' && !queueh.isEmpty()){
			int[] now = queueh.poll();
			int i = now[0];
			int j = now[1];
			a[i][j]='#';
			if(i!=h-1 && a[i+1][j]!='#'){
				int[] tmp = {i+1,j};
				queueh.add(tmp);
			}
			if(i!=0 && a[i-1][j]!='#'){
				int[] tmp = {i-1,j};
				queueh.add(tmp);
			}
			if(j!=w-1 && a[i][j+1]!='#'){
				int[] tmp = {i,j+1};
				queueh.add(tmp);
			}
			if(j!=0 && a[i][j-1]!='#'){
				int[] tmp = {i,j-1};
				queueh.add(tmp);
			}
			if(countsub==1){
				count++;
				countsub+=queueh.size();
			}
			countsub--;
		}
		if(a[h-1][w-1]!='#'){
			System.out.println(-1);
			return;
		}
		if(queueh.isEmpty()){
			count--;
		}
		System.out.println(h*w-count-black);
	}
}

Compiler output:
Main.java:22: error: incompatible types: int[] cannot be converted to Integer
		queueh.add(start);
		           ^
Main.java:26: error: incompatible types: Integer cannot be converted to int[]
			int[] now = queueh.poll();
			                       ^
Main.java:32: error: incompatible types: int[] cannot be converted to Integer
				queueh.add(tmp);
				           ^
Main.java:36: error: incompatible types: int[] cannot be converted to Integer
				queueh.add(tmp);
				           ^
Main.java:40: error: incompatible types: int[] cannot be converted to Integer
				queueh.add(tmp);
				           ^
Main.java:44: error: incompatible types: int[] cannot be converted to Integer
				queueh.add(tmp);
				           ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
6 errors
Language: C++

#include <iostream>
#include <vector>
#include <set>

using namespace std;


int H, W;
char field[50][51];
int chkd[50][50] = { 0 };

void search(int px, int py, int score, int &min)
{
	if (px == W - 1 && py == H - 1)
	{
		if (min > score) min = score;
		return;
	}

	int dx[] = { 0, 1, 0, -1 }, dy[] = { -1, 0, 1, 0 };
	for (int i = 0; i < 4; i++)
	{
		int x = px + dx[i], y = py + dy[i];
		if (x < 0 || x >= W || y < 0 || y >= H) continue;
		if (chkd[y][x]) continue;
		if (field[y][x] == '#') continue;
		chkd[y][x] = 1;
		search(x, y, score + 1, min);
	}
}

int main()
{
	cin >> H >> W;

	int black = 0;
	for (int i = 0; i < H; i++)
	{
		cin >> field[i];
		cout << field[i] << endl;
		for (int j = 0; j < W; j++)
		{
			if (field[i][j] == '#') black++;
		}
	}

	int ans = INT_MAX;
	search(0, 0, 0, ans);
	cout << (W * H - black - ans - 1) << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:19: error: 'INT_MAX' was not declared in this scope
   47 |         int ans = INT_MAX;
      |                   ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <set>
  +++ |+#include <climits>
    4 |
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int H, W;
	cin >> H >> W;
	char maze[H][W];
	int rsl = H * W;
	rep(i, 0, H) rep(j, 0, W) {
		cin >> maze[i][j];
		if(maze[i][j] == '#') rsl--;
	}

	queue<pair<int, int> > q;
	q.push(make_pair(0, 0));

	int dx[4] = {0, -1, 1, 0};
	int dy[4] = {-1, 0, 0, 1};

	int dis[H][W];
	rep(i, 0, H) rep(j, 0, W) dis[i][j] = -1;
	dis[0][0] = 0;
	while(!q.empty()) {
		pair<int, int> p = q.front();
		q.pop();
		int x = p.first, y = p.second;
		if(x == (W - 1) and y == (H - 1)) break;

		rep(i, 0, 4) {
			int nx = x + dx[i], ny = y + dy[i];
			if(0 <= nx and nx < W and 0 <= ny and ny < H) {
				if(dis[ny][nx] == -1) {
					if(maze[ny][nx] == '.') {
						dis[ny][nx] = dis[y][x] + 1;
						q.push(make_pair(nx, ny));
					}
				}
			}
		}
	}

	if(d[H - 1][W - 1] == -1) cout << -1 << endl;
	else {
		rsl -= dis[H - 1][W - 1];
		cout << rsl - 1<< endl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:72:12: error: 'd' was not declared in this scope; did you mean 'dy'?
   72 |         if(d[H - 1][W - 1] == -1) cout << -1 << endl;
      |            ^
      |            dy
Language: C++

run: a.out
	./a.out < input1.txt
	./a.out < input2.txt
	./a.out < input3.txt

a.out: Main.cpp
	g++ -std=gnu++03 -O2 -I/opt/boost/gcc/include -L/opt/boost/gcc/lib -o a.out Main.cpp

clean:
	rm a.out



Compiler output:
a.cc:1:4: error: found ':' in nested-name-specifier, expected '::'
    1 | run: a.out
      |    ^
      |    ::
a.cc:1:1: error: 'run' does not name a type
    1 | run: a.out
      | ^~~
Language: C++

#include <iostream>
#include <string>
#include <queue>
using namespace std;

using PP = pair<int, int>;
const int INF = 1e9;
int h, w;
string s[50];

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

int dist[50][50];
int BFS() {
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      dist[i][j] = INF;
    }
  }
  
  queue<pair<int, PP>> Q;
  Q.push(make_pair(0, PP(0, 0)));
  while (!Q.empty()) {
    auto q = Q.front();
    int d = p.first;
    int i = p.second.first;
    int j = p.second.second;
    
    if (s[i][j] == '#') continue;
    if (i < 0 || i >= h) continue;
    if (j < 0 || j >= w) continue;
    if (dist[i][j] != INF) continue;
    dist[i][j] = d;
    
    for (int k = 0; k < 4; ++k) {
      int ni = i + di[k];
      int nj = j + dj[k];
      Q.push(make_pair(d + 1, PP(ni, nj)));
    }
  }
  return dist[h - 1][w - 1];
}

int main() {
  cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    cin >> s[i];
  }
  int dist = BFS();
  if (dist == INF) {
    cout << -1 << endl; 
  } else {
    int cnt = 0;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (s[i][j] == '.') ++cnt;
      }
    }
    cout << cnt - dist - 1 << endl;
  }
}


Compiler output:
a.cc: In function 'int BFS()':
a.cc:26:13: error: 'p' was not declared in this scope
   26 |     int d = p.first;
      |             ^
Language: C++

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

using PP = pair<int, int>;
const int INF = 1e9;
int h, w;
string s[50];

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

int dist[50][50];
int BFS() {
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      dist[i][j] = INF;
    }
  }
  
  queue<pair<int, PP>> Q;
  Q.push(make_pair(0, PP(0, 0)));
  while (!Q.empty()) {
    auto q = Q.front();
    int d = p.first;
    int i = p.second.first;
    int j = p.second.second;
    
    if (s[i][j] == '#') continue;
    if (i < 0 || i >= h) continue;
    if (j < 0 || j >= w) continue;
    if (dist[i][j] != INF) continue;
    dist[i][j] = d;
    
    for (int k = 0; k < 4; ++k) {
      int ni = i + di[k];
      int nj = j + dj[k];
      Q.push(make_pair(d + 1, PP(ni, nj)));
    }
  }
  return dist[h - 1][w - 1];
}

int main() {
  cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    cin >> s[i];
  }
  int dist = BFS();
  if (dist == INF) {
    cout << -1 << endl; 
  } else {
    int cnt = 0;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (s[i][j] == '.') ++cnt;
      }
    }
    cout << cnt - dist - 1 << endl;
  }
}

Compiler output:
a.cc: In function 'int BFS()':
a.cc:21:3: error: 'queue' was not declared in this scope
   21 |   queue<pair<int, PP>> Q;
      |   ^~~~~
a.cc:2:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    1 | #include <iostream>
  +++ |+#include <queue>
    2 | #include <string>
a.cc:21:21: error: expected primary-expression before '>' token
   21 |   queue<pair<int, PP>> Q;
      |                     ^~
a.cc:21:24: error: 'Q' was not declared in this scope
   21 |   queue<pair<int, PP>> Q;
      |                        ^
a.cc:25:13: error: 'p' was not declared in this scope
   25 |     int d = p.first;
      |             ^