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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF = LLONG_MAX;
vector<int> xnorm = {0, 1, 0, -1};
vector<int> ynorm = {1, 0, -1, 0};
vector<int> xmagic = {-2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2};
vector<int> ymagic = {2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1};

int main()
{
    int h, w;
    cin >> h >> w;
    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--;
    cw--;
    dh--;
    dw--;
    vector<vector<char>> s(h, vector<char>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> s[i][j];
        }
    };
    priority_queue<pair<ll, P>> q;
    vector<vector<ll>> dist(h + 5, vector<ll>(w + 5, INF));
    dist[ch][cw] = 0;
    q.emplace(0, make_pair(ch, cw));
    while (!q.empty())
    {
        auto item = q.top();
        q.pop();

        for (int i = 0; i < 4; i++)
        {
            ll tempx = item.second.first + xnorm[i];
            ll tempy = item.second.second + ynorm[i];
            if (tempx > h - 1 || tempx < 0 || tempy > w - 1 || tempy < 0)
            {
                continue;
            }
            if (s[tempx][tempy] != '.')
            {
                continue;
            }
            if (dist[tempx][tempy] <= item.first)
            {
                continue;
            }
            dist[tempx][tempy] = item.first;
            q.push(make_pair(dist[tempx][tempy], make_pair(tempx, tempy)));
        }
        for (int i = 0; i < 16; i++)
        {
            ll tempx = item.second.first + xmagic[i];
            ll tempy = item.second.second + ymagic[i];
            if (tempx > h - 1 || tempx < 0 || tempy > w - 1 || tempy < 0)
            {
                continue;
            }
            if (s[tempx][tempy] != '.')
            {
                continue;
            }
            if (dist[tempx][tempy] <= item.first + 1)
            {
                continue;
            }
            dist[tempx][tempy] = item.first + 1;
            q.push(make_pair(dist[tempx][tempy], make_pair(tempx, tempy)));
        }
    }
    if (dist[dh][dw] != INF)
    {
        cout << dist[dh][dw] << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    return 0;
}

Compiler output:
a.cc:11:16: error: 'LLONG_MAX' was not declared in this scope
   11 | const ll INF = LLONG_MAX;
      |                ^~~~~~~~~
a.cc:7:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <map>
  +++ |+#include <climits>
    7 |
Language: C++

from collections import deque

H,W = map(int,input().split())
C_h,C_w = map(lambda x:int(x)-1,input().split())
D_h,D_w = map(lambda x:int(x)-1,input().split())
S = [input() for _ in range(H)]

INF = int(1e10)
dist = [[INF]*(W) for _ in range(H)]
deq = deque()
deq.append((C_h,C_w,0))

move_a = [(1,0),(0,1),(-1,0),(0,-1)]
move_b = [(i,j)for i in range(-2,2+1) for j in range(-2,2+1) if abs(i)+abs(j)>=2]

while len(deq):
  h,w,c = deq.popleft()
  if dist[h][w] <= c:
    continue
  dist[h][w] = c
  for dh,dw in move_a:
    nh,nw = h+dh,w+dw
    if nh<0 or nw<0 or nh>=H or nw>=W:
      continue
    if S[nh][nw] == '#':
      continue
    if dist[nh][nw] > c:
      deq.appendleft((nh,nw,c))
  for dh,dw in move_b:
    nh,nw = h+dh,w+dw
    if nh<0 or nw<0 or nh>=H or nw>=W:
      continue
    if S[nh][nw] == '#':
      continue
    if dist[nh][nw] > c+1:
      deq.append((nh,nw,c+1))
  
print(dist[D_h][D_w] if dist[D_h][D_w]<INF else -1)

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

#include <vector>
#include <set>
#include <iostream>
#include "cmath"
#include <map>
#include <queue>

using namespace std;

typedef unsigned u;
pair<int, int> go[4] = {
        {1, 0},
        {0, 1},
        {-1, 0},
        {0, - 1}
};
vector<int> graph[(int)1e6 + 7];
void explore(map<pair<int ,int>, bool>& g, pair<int, int> v, vector<pair<int, int>>& carry) {
    if(!g[v]) return;
    else {
        carry.push_back(v);
        for(auto x: go) {
            g[v] = false;
            explore(g, {v.first + x.first, v.second + x.second}, carry);
        }
    }
}
int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int n, m;
   cin >> n >> m;
   int ch, cw;
   cin >> ch >> cw;
   int dh, dw;
   cin >> dh >> dw;
   map<pair<int, int>, bool> x;
   for(int i = 0; i < n; i++) {
       string g;
       cin >> g;
       for (int j = 0; j < m; j++) {a
           x[{i + 1, j + 1}] = g[j] == '.';
       }
   }
   map<pair<int, int>, int> belong;
   vector<vector<pair<int, int>>> comps;
   int k = 1;
   for(int i = 1; i <= n; i++) {
       for(int j = 1; j <= m; j++)
       {
           if(x[{i, j}]) {
               vector<pair<int, int>> new_comp;
               explore(x, {i, j}, new_comp);
               for(auto i: new_comp)
                   belong[i] = k;
               comps.push_back(new_comp);
               ++k;
           }
       }
   }

   for(auto &v : comps) {
       for(auto c: v) {
           for (int i = max(1, c.first - 2); i <= min(n, c.first + 2); ++i) {
               for (int j = max(1, c.second - 2); j <= min(m, c.second + 2); ++j) {
                   if (belong[{i, j}] != 0 && belong[{i, j}] != belong[c]) {
                       graph[belong[c]].push_back(belong[{i, j}]);
                       graph[belong[{i, j}]].push_back(belong[c]);;
                   }
               }
           }
       }
   }
   vector<int> used(comps.size() + 1, 0);
   vector<int> d(comps.size() + 1, (int)1e9 + 7);
   queue<int> bfs;
   bfs.push(belong[{ch, cw}]);
   d[belong[{ch, cw}]] = 0;
   while(!bfs.empty()) {
        int v = bfs.front();
        bfs.pop();
        used[v] = true;
        for(auto to: graph[v]) {
            if (!used[to]) {
                bfs.push(to);
                used[to] = true;
                d[to] = d[v] + 1;
            }
        }
   }
   if(d[belong[{dh, dw}]] == (int)1e9 + 7) {
       printf("-1\n");
   } else printf("%d", d[belong[{dh, dw}]]);



}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:37: error: 'a' was not declared in this scope
   42 |        for (int j = 0; j < m; j++) {a
      |                                     ^
a.cc:43:28: error: expected primary-expression before ']' token
   43 |            x[{i + 1, j + 1}] = g[j] == '.';
      |                            ^
Language: C++

#include <vector>
#include <set>
#include <iostream>
#include "cmath"
#include <map>
#include <queue>

using namespace std;

typedef unsigned u;
pair<int, int> go[4] = {
        {1, 0},
        {0, 1},
        {-1, 0},
        {0, - 1}
};
vector<int> graph[(int)1e6 + 7];
void explore(map<pair<int ,int>, bool>& g, pair<int, int> v, vector<pair<int, int>>& carry) {
    if(!g[v]) return;
    else {
        carry.push_back(v);
        for(auto x: go) {
            g[v] = false;
            explore(g, {v.first + x.first, v.second + x.second}, carry);
        }
    }
}
int main() {
   int n, m;
   cin >> n >> m;
   int ch, cw;
   cin >> ch >> cw;
   int dh, dw;
   cin >> dh >> dw;
   map<pair<int, int>, bool> x;
   for(int i = 0; i < n; i++) {
       string g;
       cin >> g;
       for (int j = 0; j < m; j++) {
           x[{i + 1, j + 1}] = g[j] == '.';
       }
   }
   map<pair<int, int>, int> belong;
   vector<vector<pair<int, int>>> comps;
   int k = 1;
   for(int i = 1; i <= n; i++) {
       for(int j = 1; j <= m; j++)
       {
           if(x[{i, j}]) {
               vector<pair<int, int>> new_comp;
               explore(x, {i, j}, new_comp);
               for(auto i: new_comp)
                   belong[i] = k;
               comps.push_back(new_comp);
               ++k;
           }
       }
   }

   for(auto &v : comps) {
       for(auto c: v) {
           for (int i = max(1, c.first - 2); i <= min(n, c.first + 2); ++i) {
               for (int j = max(1, c.second - 2); j <= min(m, c.second + 2); ++j) {
                   if (belong[{i, j}] != 0 && belong[{i, j}] != belong[c]) {
                       graph[belong[c]].push_back(belong[{i, j}]);
                       graph[belong[{i, j}]].push_back(belong[c]);;
                   }
               }
           }
       }
   }
   vector<int> used(comps.size() + 1, 0);
   vector<int> d(comps.size() + 1, (int)1e9 + 7);
   queue<int> bfs;
   bfs.push(belong[{ch, cw}]);
   d[belong[{ch, cw}]] = 0;
   while(!bfs.empty()) {
        int v = bfs.front();
        bfs.pop();
        used[v] = true;
        for(auto to: graph[v]) {
            if(!used[to]) {
                bfs.push(to);
                used[to] = true;
                d[to] = d[v] + 1;
            }
        }(int)1e9 + 7
   }
   if(d[belong[{dh, dw}]] == (int)1e9 + 7) {
       printf("-1\n");
   } else printf("%d", d[belong[{dh, dw}]]);



}

Compiler output:
a.cc: In function 'int main()':
a.cc:87:22: error: expected ';' before '}' token
   87 |         }(int)1e9 + 7
      |                      ^
      |                      ;
   88 |    }
      |    ~
Language: C++

#include <vector>
#include <set>
#include <iostream>
#include "cmath"
#include <map>
#include <queue>

using namespace std;

typedef unsigned u;
pair<int, int> go[4] = {
        {1, 0},
        {0, 1},
        {-1, 0},
        {0, - 1}
};
vector<int> graph[(int)1e6 + 7];
void explore(map<pair<int ,int>, bool>& g, pair<int, int> v, vector<pair<int, int>>& carry) {
    if(!g[v]) return;
    else {
        carry.push_back(v);
        for(auto x: go) {
            g[v] = false;
            explore(g, {v.first + x.first, v.second + x.second}, carry);
        }
    }
}
int main() {
   int n, m;
   cin >> n >> m;
   int ch, cw;
   cin >> ch >> cw;
   int dh, dw;
   cin >> dh >> dw;
   map<pair<int, int>, bool> x;
   for(int i = 0; i < n; i++) {
       string g;
       cin >> g;
       for (int j = 0; j < m; j++) {
           x[{i + 1, j + 1}] = g[j] == '.';
       }
   }
   map<pair<int, int>, int> belong;
   vector<vector<pair<int, int>>> comps;
   int k = 1;
   for(int i = 1; i <= n; i++) {
       for(int j = 1; j <= m; j++)
       {
           if(x[{i, j}]) {
               vector<pair<int, int>> new_comp;
               explore(x, {i, j}, new_comp);
               for(auto i: new_comp)
                   belong[i] = k;
               comps.push_back(new_comp);
               ++k;
           }
       }
   }

   for(auto &v : comps) {
       for(auto c: v) {
           for (int i = max(1, c.first - 2); i <= min(n, c.first + 2); ++i) {
               for (int j = max(1, c.second - 2); j <= min(m, c.second + 2); ++j) {
                   if (belong[{i, j}] != 0 && belong[{i, j}] != belong[c]) {
                       graph[belong[c]].push_back(belong[{i, j}]);
                       graph[belong[{i, j}]].push_back(belong[c]);;
                   }
               }
           }
       }
   }
   vector<int> used(comps.size() + 1, 0);
   vector<int> d(comps.size() + 1, INT_MAX);
   queue<int> bfs;
   bfs.push(belong[{ch, cw}]);
   d[belong[{ch, cw}]] = 0;
   while(!bfs.empty()) {
        int v = bfs.front();
        bfs.pop();
        used[v] = true;
        for(auto to: graph[v]) {
            if(!used[to]) {
                bfs.push(to);
                used[to] = true;
                d[to] = d[v] + 1;
            }
        }
   }
   if(d[belong[{dh, dw}]] == INT_MAX) {
       printf("-1\n");
   } else printf("%d", d[belong[{dh, dw}]]);



}

Compiler output:
a.cc: In function 'int main()':
a.cc:73:36: error: 'INT_MAX' was not declared in this scope
   73 |    vector<int> d(comps.size() + 1, INT_MAX);
      |                                    ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <queue>
  +++ |+#include <climits>
    7 |
Language: C++

#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
#define ll long long
using namespace std;
int main(){
	ll h, w, ch, cw, dh, dw ;
	cin >> h >> w >> ch >> cw >> dh >> dw;
	vector<vector<ll>> s(h, vector<ll>(w);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:46: error: expected ')' before ';' token
    9 |         vector<vector<ll>> s(h, vector<ll>(w);
      |                             ~                ^
      |                                              )
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
 
int main(){
  int INF = 1000000000;　/* 配列の上限*/
  int h, w; /* マスの大きさ*/
  int sy, sx; /* playerの位置*/
  int gy, gx; /* Goalの位置*/
  cin >> h >> w >> sy >> sx >> gy >> gx;
  sy--; sx--; gy--; gx--;
  vector<string> g(h);
  rep(i,h) cin >> g[i];
  vvi dist(h, vi(w, INF));
  deque<pair<int,int>> q;
  q.push_back({sy, sx});
  vi v = {1, 0, -1, 0, 1};
  dist[sy][sx] = 0;
  while(!q.empty()){
    int y = q.front().first;
    int x = q.front().second;
    q.pop_front();
    rep(i,4){
      int ny = y + v[i];
      int nx = x + v[i+1];   
      if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
      if(g[ny][nx] == '#') continue;
      if(dist[ny][nx] > dist[y][x]){
        dist[ny][nx] = dist[y][x];
        q.push_front({ny, nx});
      }
    }
    for(int i=-2; i<=2; i++){
      for(int j=-2; j<=2; j++){
        int ny = y + i;
        int nx = x + j;
        if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
        if(g[ny][nx] == '#') continue;
        if(dist[ny][nx] > dist[y][x] + 1){
          dist[ny][nx] = dist[y][x] + 1;
          q.push_back({ny, nx});
        }
      }
    }
  }
  if(dist[gy][gx] == INF) dist[gy][gx] = -1;
  cout << dist[gy][gx] << endl;
}


Compiler output:
a.cc:9:24: error: extended character 　 is not valid in an identifier
    9 |   int INF = 1000000000;　/* 配列の上限*/
      |                        ^
a.cc: In function 'int main()':
a.cc:9:24: error: '\U00003000' was not declared in this scope
    9 |   int INF = 1000000000;　/* 配列の上限*/
      |                        ^~
a.cc:13:10: error: 'h' was not declared in this scope
   13 |   cin >> h >> w >> sy >> sx >> gy >> gx;
      |          ^
a.cc:13:15: error: 'w' was not declared in this scope
   13 |   cin >> h >> w >> sy >> sx >> gy >> gx;
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
 
int main(){
  int INF = 1000000000;　// 配列の上限
  int h, w; // マスの大きさ
  int sy, sx; // playerの位置
  int gy, gx; // Goalの位置
  cin >> h >> w >> sy >> sx >> gy >> gx;
  sy--; sx--; gy--; gx--;
  vector<string> g(h);
  rep(i,h) cin >> g[i];
  vvi dist(h, vi(w, INF));
  deque<pair<int,int>> q;
  q.push_back({sy, sx});
  vi v = {1, 0, -1, 0, 1};
  dist[sy][sx] = 0;
  while(!q.empty()){
    int y = q.front().first;
    int x = q.front().second;
    q.pop_front();
    rep(i,4){
      int ny = y + v[i];
      int nx = x + v[i+1];   
      if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
      if(g[ny][nx] == '#') continue;
      if(dist[ny][nx] > dist[y][x]){
        dist[ny][nx] = dist[y][x];
        q.push_front({ny, nx});
      }
    }
    for(int i=-2; i<=2; i++){
      for(int j=-2; j<=2; j++){
        int ny = y + i;
        int nx = x + j;
        if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
        if(g[ny][nx] == '#') continue;
        if(dist[ny][nx] > dist[y][x] + 1){
          dist[ny][nx] = dist[y][x] + 1;
          q.push_back({ny, nx});
        }
      }
    }
  }
  if(dist[gy][gx] == INF) dist[gy][gx] = -1;
  cout << dist[gy][gx] << endl;
}

Compiler output:
a.cc:9:24: error: extended character 　 is not valid in an identifier
    9 |   int INF = 1000000000;　// 配列の上限
      |                        ^
a.cc: In function 'int main()':
a.cc:9:24: error: '\U00003000' was not declared in this scope
    9 |   int INF = 1000000000;　// 配列の上限
      |                        ^~
a.cc:13:10: error: 'h' was not declared in this scope
   13 |   cin >> h >> w >> sy >> sx >> gy >> gx;
      |          ^
a.cc:13:15: error: 'w' was not declared in this scope
   13 |   cin >> h >> w >> sy >> sx >> gy >> gx;
      |               ^
Language: C++

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	cin >> H >> W;
	int sy, sx, gy, gx;
	cin >> sy >> sx >> gy >> gx;
	sy--, sx--, gy--, gx--;
	vector<string>s(H);
	for (auto &i : s)cin >> i;
	vector<vector<int>>dis(H, vector<int>(W,MOD));
	deque<pair<int, int>>Q;
	Q.push_back({ sy,sx });
	dis[sy][sx] = 0;
	int dir[] = { 1,0,-1,0,1 };
	while (!Q.empty()) {
		int cy, cx;
		tie(cy, cx) = Q.front();
		Q.pop_front();
		for (int i = 0; i < 4; i++) {
			int ny = cy + dir[i];
			int nx = cx + dir[i + 1];
			//if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
			//if (s[ny][nx] == '#')continue;
            if(unsigned(nx)<W&&unsigned(y)<H&&s[ny][nx]=='.'){
			if (dis[ny][nx] > dis[cy][cx]) {
				dis[ny][nx] = dis[cy][cx];
				Q.push_front({ ny,nx });
			}
            }
		}
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				int ny = cy + i;
				int nx = cx + j;
				//if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
				//if (s[ny][nx] == '#')continue;
                if(unsigned(nx)<W&&unsigned(y)<H&&s[ny][nx]=='.'){
				if (dis[ny][nx] > dis[cy][cx] + 1) {
					dis[ny][nx] = dis[cy][cx] + 1;
					Q.push_back({ ny,nx });
				}
                }
			}
		}
	}
	if (dis[gy][gx] == MOD)dis[gy][gx] = -1;
	cout << dis[gy][gx] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:41: error: 'y' was not declared in this scope; did you mean 'ny'?
   58 |             if(unsigned(nx)<W&&unsigned(y)<H&&s[ny][nx]=='.'){
      |                                         ^
      |                                         ny
a.cc:71:45: error: 'y' was not declared in this scope; did you mean 'ny'?
   71 |                 if(unsigned(nx)<W&&unsigned(y)<H&&s[ny][nx]=='.'){
      |                                             ^
      |                                             ny
Language: C++

#include<bits/stdc++.h>
/* #define int long long */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

signed main(){
    cin >> h >> w;
    vector<string>s(h);
    int si, sj;
    cin >> si >> sj;
    int ti, tj;
    cin >> ti >> tj;
    --si; --sj; --ti; --tj;

    rep(i, h) cin >> s[i];

    const int INF = 1e9;

    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<P> q; /* 座標を入れる */
    dist[si][sj] = 0;

    q.emplace_back(si, sj);

    while(!q.empty()){
        int i = q.front().first;
        int j = q.front().second;
        q.pop_front();
        int d = dist[i][j];
        rep(v, 4){
            int ni = i+di[v], nj = j+dj[v];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if(s[ni][nj] == '#') continue;
            if(dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni, nj);
        }
        for(int ei = -2; ei <= 2; ++ei){
            for(int ej = -2; ej =< 2; ++ej){
                int ni = i+ei, nj = j+ej;
                if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if(s[ni][nj] == '#') continue;
                if(dist[ni][nj] <= d) continue;
                dist[ni][nj] = d+1;
                q.emplace_back(ni, nj);
            }
        }
    }

    int ans = dist[ti][tj];
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:12: error: 'h' was not declared in this scope
   18 |     cin >> h >> w;
      |            ^
a.cc:18:17: error: 'w' was not declared in this scope
   18 |     cin >> h >> w;
      |                 ^
a.cc:50:34: error: expected primary-expression before '<' token
   50 |             for(int ej = -2; ej =< 2; ++ej){
      |                                  ^
Language: C++

#include<bits/stdc++.h>
#define lim 1000000000000000007
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(),v.end()
#define mod ((int)1e9+7)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int>> pii;
const int N = (int)1e3+5;

vector<pii> v[N][N];
vector<vector<int>> distance_from_source;
vector<string> grid;

void dijksta(int source_x, int source_y) {
  distance_from_source[source_x][source_y] = 0;
  priority_queue<pii,vector<pii>,greater<pii>> pq;
  pq.push({0,{source_x,source_y}});
  while(!pq.empty()) {
    pii curr_node = pq.top();
    pq.pop();
    int x = curr_node.second.first, y = curr_node.second.second;
    if(distance_from_source[x][y] == curr_node.first) {
      for(auto it: v[x][y]) {
        int _x = it.second.first, _y = it.second.second;
        if(distance_from_source[_x][_y] > distance_from_source[x][y] + it.first) {
          distance_from_source[_x][_y] = distance_from_source[x][y] + it.first;
          pq.push({distance_from_source[_x][_y], {_x, _y}});
        }
      }
    }
  }
}

void solve() {
  int r,c;
  cin >> r >> c;
  distance_from_source = vector<vector<int>>(r,vector<int>(c,1e9));

  int source_x, source_y;
  int destination_x, destination_y;
  cin >> source_x >> source_y;
  cin >> destination_x >> destination_y;
  source_x--, source_y--;
  destination_x--, destination_y--;

  grid = vector<string>(r);
  REP(i,0,r-1) {
    cin>>grid[i];
  }
  REP(i,0,r-1) {
    REP(j,0,c-1) {
        REP(k,-2,2) {
          REP(l,-2,2) {
            if(i+k>=0 && i+k<r && j+l>=0 && j+l<c && grid[i+k][j+l]=='.') {
              v[i][j].push_back({(abs(i+k)+abs(j+l))!=1,{i+k,j+l}});
            }
          }
        }
      }
    }
  }
  dijksta(source_x, source_y);
  if(distance_from_source[destination_x][destination_y] == 1e9) {
    distance_from_source[destination_x][destination_y] = -1;
  }
  cout << distance_from_source[destination_x][destination_y];
}

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

  int T=1;
  //cin>>T;
  REP(TC,1,T) {
      //cout<<"Case #"<<TC<<": ";
      solve();
      cout<<"\n";
  }
}


Compiler output:
a.cc:64:10: error: expected constructor, destructor, or type conversion before '(' token
   64 |   dijksta(source_x, source_y);
      |          ^
a.cc:65:3: error: expected unqualified-id before 'if'
   65 |   if(distance_from_source[destination_x][destination_y] == 1e9) {
      |   ^~
a.cc:68:3: error: 'cout' does not name a type
   68 |   cout << distance_from_source[destination_x][destination_y];
      |   ^~~~
a.cc:69:1: error: expected declaration before '}' token
   69 | }
      | ^
Language: C++

from collections import deque
h,w=map(int,input().split())
ch,cw=map(lambda x:int(x)-1,input().split())
dh,dw=map(lambda x:int(x)-1,input().split())
tizu=[]
d=deque()
d.appendleft([ch,cw])
cost=[[-1 for i in range(w)]for j in range(h)]
dx=[1,0,-1,0,-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2]
dy=[0,1,0,-1,-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2]
for i in range(h):
    tizu.append(input())
cost[ch][cw]=0
while(d):
    x,y=d.popleft()
    for i in range(4):
        nx=x+dx[i]
        ny=y+dy[i]
        ####行ったことある、かつ、コストが手前より高い
        if(nx<0 or ny<0 or nx>=h or ny>=w):
            continue
        if(cost[nx][ny]>-1 and cost[nx][ny]<=cost[x][y]):
            continue
        if(tizu[nx][ny]=='.'):
            cost[nx][ny]=cost[x][y]
            d.appendleft([nx,ny])
    
    for i in range(4,24):
        nx=x+dx[i]
        ny=y+dy[i]
        if(nx<0 or ny<0 or nx>=h or ny>=w):
            continue
        if(cost[nx][ny]>-1):
            continue
        if(tizu[nx][ny]=='.'):
            cost[nx][ny]=cost[x][y]+1
            d.append([nx,ny])

print(cost[dh][dw])

Compiler output:
a.cc:19:9: error: stray '##' in program
   19 |         ####行ったことある、かつ、コストが手前より高い
      |         ^~
a.cc:19:11: error: stray '##' in program
   19 |         ####行ったことある、かつ、コストが手前より高い
      |           ^~
a.cc:19:13: error: extended character 、 is not valid in an identifier
   19 |         ####行ったことある、かつ、コストが手前より高い
      |             ^
a.cc:19:13: error: extended character 、 is not valid in an identifier
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import deque
      | ^~~~
Language: C

#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=3e5+10;
const int mod=1e9+7;
char mp[2020][2020];
int dis[2020][2020];
int vis[2020][2020];
int h,w,x11,y11,x2,y2;
int sum=inf;
int dx[4]= {0,0,1,-1};
int dy[4]= {1,-1,0,0};
struct A
{
    int x,y,v;
    A(int x=0,int y=0,int v=0):x(x),y(y),v(v) {}
    bool operator<(const A&o)const//优先队列的大小比较
    {
        return v>o.v;
    }
};
int main()
{
    cin>>h>>w;
    cin>>x11>>y11;
    cin>>x2>>y2;
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=w; j++)
        {
            cin>>mp[i][j];
        }
    }
    memset(dis,inf,sizeof(dis));
    priority_queue<A>q;
    q.push(A(x11,y11,dis[x11][y11]));
    dis[x11][y11]=0;
    while(!q.empty())
    {

        int x=q.top().x;
        int y=q.top().y;
        q.pop();
        if(vis[x][y])
        {
            continue;
        }
        vis[x][y]=1;
        for(int i=0; i<4; i++)
        {
            int xx=x+dx[i];
            int yy=y+dy[i];
            if(xx>=1&&xx<=h&&yy>=1&&yy<=w&&mp[xx][yy]!='#')//没有越界，不是#
            {
                if(dis[xx][yy]>dis[x][y])
                {
                    dis[xx][yy]=dis[x][y];
                    q.push(A(xx,yy,dis[xx][yy]));
                }
            }
        }
        for(int i=-2; i<=2; i++)
        {
            for(int j=-2; j<=2; j++)
            {
                int xx=x+i;
                int yy=y+j;
                if(xx>=1&&xx<=h&&yy>=1&&yy<=w&&mp[xx][yy]!='#')
                {
                    if(dis[xx][yy]>dis[x][y]+1)
                    {
                        dis[xx][yy]=dis[x][y]+1;
                        q.push(A(xx,yy,dis[xx][yy]));
                    }
                }
            }
        }
    }
    if(dis[x2][y2]==inf)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<dis[x2][y2]<<endl;
    }
    system("pause");
    return 0;
}


Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int>
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key
 
//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0);
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;
int inf=1e18;
 
int dx[5]={-2,-1,0,+1,+2},dy[5]={-2,-1,0,+1,+2};
int n,m,r1,c1,r2,c2,dp[1005][1005];
string s[1005];
 
 
void solve(){
    cin>>n>>m>>r1>>c1>>r2>>c2;
    rep(i,0,n) cin>>s[i];
    rep(i,0,n) rep(j,0,m) dp[i][j]=LLONG_MAX;
    r1--;r2--;c1--;c2--;
    dp[r2][c2]=0;
 
 
    queue<pair<int,pair<int,int>>> q;
 
    q.push(mp(0,mp(r2,c2)));
 
    while(sz(q)){
        auto d=-q.top().x;
        auto pos=q.top().y;
        q.pop();
 
        rep(i,0,5){
            rep(j,0,5){
                if(!dx[i] and !dy[j]) continue;
 
                int x=dx[i]+pos.x;
                int y=dy[j]+pos.y;
                if(x<0 or y<0 or x>=n or y>=m or s[x][y]=='#') continue;
                
 
                if((abs(dx[i])==1 and !dy[j]) or (abs(dy[j])==1 and !dx[i])){
                    if(dp[x][y]>d){
                        dp[x][y]=d;
                        q.push(mp(-d,mp(x,y)));
                    }
                }
                else{
                    if(dp[x][y]>d+1){
                        dp[x][y]=d+1;
                        q.push(mp(-d-1,mp(x,y)));
                    }
                }
            }
        }
    }
 
    if(dp[r1][c1]==LLONG_MAX) cout<<-1;
    else cout<<dp[r1][c1];
}
 
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:45:19: error: 'class std::queue<std::pair<long long int, std::pair<long long int, long long int> > >' has no member named 'top'; did you mean 'pop'?
   45 |         auto d=-q.top().x;
      |                   ^~~
      |                   pop
a.cc:46:20: error: 'class std::queue<std::pair<long long int, std::pair<long long int, long long int> > >' has no member named 'top'; did you mean 'pop'?
   46 |         auto pos=q.top().y;
      |                    ^~~
      |                    pop
Language: C++

#include<bits/stdc++.h>
using namespace std;
int m=INT_MAX,r,c,i,dr[4]={0,1,-1,0},dc[4]={1,0,0,-1},ar,ac,br,bc,vr[20]={-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2},vc[20]={-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2};
bool used[1002][1002]={0};
string st[1002];
void dfs(int i,int j,int p){
	if(i<0||i>=r||j<0||j>=c)return;
	if(used[i][j]||st[i][j]!='.')return;
	used[i][j]=1;
	if(i==br&&j==bc){
		cout<<p;
		exit(0);
	}
	for(int k=0;k<4;k++)dfs(i+dr[k],j+dc[k],p);
	for(int k=0;k<20;k++)a[p]=k,dfs(i+vr[k],j+vc[k],p+1);
	used[i][j]=0;
}
int main(){
	cin>>r>>c>>ar>>ac>>br>>bc;
	ar--;ac--;br--;bc--;
	for(i=0;i<r;i++)cin>>st[i];
	dfs(ar,ac,0);
	if(m!=INT_MAX)cout<<m;
	else cout<<-1;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:15:30: error: 'a' was not declared in this scope
   15 |         for(int k=0;k<20;k++)a[p]=k,dfs(i+vr[k],j+vc[k],p+1);
      |                              ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int H, W, sx, sy, dx, dy;
char grid[1011][1011];
int d1[4] = {-1,0,0,1}, d2[4] = {0,1,-1,0};

bool isSafe(int i, int j)
{
	return i >= 1 and i <= H and j >= 1 and j <= W and grid[i][j] != '#';
}

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> H >> W;
	cin >> sx >> sy;
	cin >> dx >> dy;
	int dist[H+1][W+1];
	for(int i = 1;i <= H;i++)
		for(int j = 1;j <= W;j++)
			cin >> grid[i][j], dist[i][j] = INT_MAX;
	if(grid[sx][sy] == '#')
		cout << -1;
	else 
	{
		deque<pair<int,int>> dq;
		dq.push_back({sx,sy});
		dist[sx][sy] = 0;
		while(!dq.empty())
		{
			auto x = dq.front();dq.pop_front();
			int i = x.first, j = x.second;
			for(int it = 0;it < 4;it++)
			{
				if(isSafe(i + d1[it],j + d2[jt]))
					dq.push_front({i + d1[it],j + d2[jt]});
			}
			for(int it = -2;it <= 2;it++)
			{
				for(int jt = -2;jt <= 2;jt++)
				{
					if(dist[i + it][j + jt] > dist[i][j] + 1)
					{
						dist[i+it][j+jt] = dist[i][j] + 1;
						dq.push_back({i + it, j + jt});
					}
				} 
			}
		}
		cout << dist[dx][dy] << '\n';
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:61: error: 'jt' was not declared in this scope; did you mean 'it'?
   36 |                                 if(isSafe(i + d1[it],j + d2[jt]))
      |                                                             ^~
      |                                                             it
a.cc:37:54: error: no matching function for call to 'std::deque<std::pair<int, int> >::push_front(<brace-enclosed initializer list>)'
   37 |                                         dq.push_front({i + d1[it],j + d2[jt]});
      |                                         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/deque:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:139,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_deque.h:1501:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_front(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1501 |       push_front(const value_type& __x)
      |       ^~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1501:36: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::deque<std::pair<int, int> >::value_type&' {aka 'const std::pair<int, int>&'}
 1501 |       push_front(const value_type& __x)
      |                  ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_deque.h:1516:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_front(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1516 |       push_front(value_type&& __x)
      |       ^~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1516:31: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::deque<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1516 |       push_front(value_type&& __x)
      |                  ~~~~~~~~~~~~~^~~
Language: C++

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

struct Ps{
  int r,c;
  Ps():r(0),c(0){}
  Ps(int r,int c):r(r),c(c){}
  Ps operator+(const Ps&p)const
  { return Ps(r+p.r,c+p.c);  }
  friend istream& operator>>(istream&is,Ps&p)
  {is >> p.r >> p.c; return is;  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w; cin >> h >> w;
  Ps s,g; cin >> s >> g;
  s = s+Ps(-1,-1);
  g = g+Ps(-1,-1);
  bitset<1000> mz[1000];
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      mz[i][j] = []{char c; cin >> c; return c=='.';}();
  optional<int> distance[1000][1000];
  deque<pair<Ps,int>> dq;
  dq.emplace_front(move(s),0);
  while(!dq.empty()){
    auto [ps,di] = move(dq.front());
    dq.pop_front();
    if(distance[ps.r][ps.c])continue;
    distance[ps.r][ps.c] = di;
    mz[ps.r][ps.c] = 0;
    if(ps.r==g.r && ps.c==g.c)break;
    for(int i = -2; i <= 2; ++i){
      for(int j = -2; j <= 2; ++j){
	Ps nps(ps.r+i,ps.c+j);
	if(nps.r < 0 || nps.c < 0 || nps.r >= h || nps.c >= w)continue;
	if(!mz[nps.r][nps.c])continue;
	if(abs(i)+abs(j) > 1){
	  dq.emplace_back(move(nps),di+1);
	} else {
	  mz[nps.r][nps.c] = 0;
	  dq.emplace_front(move(nps),di);
	}
      }
    }
  }
  cout << (distance[g.r][g.c] ? distance[g.r][g.c].value() : -1) << endl;
}


struct Ps{
  int r,c;
  Ps():r(0),c(0){}
  Ps(int r,int c):r(r),c(c){}
}

int main(){
  int h,w; cin >> h >> w;
  Ps s,g; cin >> s.r >> s.c >> g.r >> g.c;
  bitset<1000> mz[1000];
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      mz[i][j] = []{char c; cin >> c; return c == '.';}();  
  optional<int> distance[1000][1000];
  deque<P<Ps,int>> dq;
  dq.emplace_back(s,0);
  while(!dq.empty()){
    auto [ps,di] = dq.front();
    dq.pop_front();
    if(distance[ps.r][ps.c])continue;
    distance[ps.r][ps.c] = di;
    mz[ps.r][ps.c] = false;
    int mr[] = {1,-1,0,0};
    int mc[] = {0,0,1,-1};
    for(int i = 0; i < 4; ++i){
      auto [nps,ndi] = make_pair(Ps(ps.r+mr[i],ps.c+mc[i]),di);
      if(nps.r < 0 || nps.c < 0 || nps.r >= h || nps.c >= w)continue;
      if(!mz[nps.r][nps.c])continue;
      mz[nps.r][nps.c] = false;
      dq.emplace_front(nps,ndi);
    }
    for(int i = -2; i <= 2; ++i){
      for(int j = -2; j <= 2; ++j){
	auto [nps,ndi] = make_pair(Ps(ps.r+i,ps.c+j),di+1);
	if(nps.r < 0 || nps.c < 0 || nps.r >= h || nps.c >= w)continue;
	if(!mz[nps.r][nps.c])continue;
	dq.emplace_front(nps,ndi);
      }
    }
  }
  cout << (distance[g.r][g.c] ? distance[g.r][g.c] : -1) << endl;
}


Compiler output:
a.cc:53:8: error: redefinition of 'struct Ps'
   53 | struct Ps{
      |        ^~
a.cc:4:8: note: previous definition of 'struct Ps'
    4 | struct Ps{
      |        ^~
a.cc:53:1: error: new types may not be defined in a return type
   53 | struct Ps{
      | ^~~~~~
a.cc:53:1: note: (perhaps a semicolon is missing after the definition of '<type error>')
a.cc:53:1: error: two or more data types in declaration of 'main'
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i) // マクロ
using namespace std;                          // stdの省略
using pii = pair<int, int>;                   // pairの略記
using ll = long long;                         // long longの略記

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

int main(void)
{

    int h, w, si, sj, ti, tj;
    cin >> h >> w >> si >> sj >> ti >> tj;
    --si;
    --sj;
    --ti;
    --tj; // ０スタートなのでデクリメント

    vector<string> s(h);
    rep(i, h) cin >> s[i]; // repマクロの利用

    const int INF = 1e9; // あり得ない数字
    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<pii> q;
    dist[si][sj] = 0;
    q.emplace_back(si, sj);
    while (!q.empty())
    {
        int i = q.front().first;
        int j = q.front().second;
        q.pop_front();
        if (dist[i][j] != d) continue;
        rep(v, 4)
        {
            int ni = i + di[v], nj = j + dj[v];
            if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if (s[ni][nj] == '#') continue;
            if (dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni,nj);
        }
        for (int ei = -2; ei <= 2; ++ei) {
            for (int ej = -2; ej <= 2; ++ej) {
                int ni = i + ei, nj = j + ej;
                if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if (s[ni][nj] == '#') continue;
                if (dist[ni][nj] <= d+1) continue;
                dist[ni][nj] = d+1;
                q.emplace_back(ni,nj);
            }
        }
    }
    int ans = dist[ti][tj];
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

/**********************************

ll cnt = 0;
    while (ch!=dh || cw!=dw)
    {
        
}

int bf = -1;
for (auto x : a)
{
    if (bf > x)
        cnt += bf - x;
    else
        bf = x;
}

cout << cnt << endl;

return 0;

**********************************/

Compiler output:
a.cc: In function 'int main()':
a.cc:33:27: error: 'd' was not declared in this scope
   33 |         if (dist[i][j] != d) continue;
      |                           ^
a.cc:39:33: error: 'd' was not declared in this scope
   39 |             if (dist[ni][nj] <= d) continue;
      |                                 ^
a.cc:40:28: error: 'd' was not declared in this scope
   40 |             dist[ni][nj] = d;
      |                            ^
a.cc:48:37: error: 'd' was not declared in this scope
   48 |                 if (dist[ni][nj] <= d+1) continue;
      |                                     ^
a.cc:49:32: error: 'd' was not declared in this scope
   49 |                 dist[ni][nj] = d+1;
      |                                ^
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define INF 1000000000
#define endl "\n"
#define all(s) s.begin(),s.end()
#define pb push_back
#define uno unordered_map
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define w(zz) int zz; cin>>zz; while(zz--)
#define foreach(var,i) for(auto i = var.begin();i!=var.end();i++)
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll power(ll a, ll n) {ll res = 1; while (n) {if (n % 2) {res *= a;} n >>= 1; a *= a;} return res;}
ll powerm(ll a, ll n, ll m) {ll res = 1; while (n) {if (n % 2) {res = (res * a) % m;} n >>= 1; a = (a * a) % m;} return res;}
using namespace std;

ll n,m,a,b,c,d;
ll mat[1005][1005];
ll vis[1005][1005];

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

bool valid(ll r, ll c){
	return (r>=0 && r<n && c>=0 && c<m);
}

int main(){
	fast();
	
	cin>>n>>m>>a>>b>>c>>d;
	string s;
	for(ll i=0;i<n;i++){
		cin>>s;
		for(ll j=0;i<m;j++){
			mat[i][j] = (s[i]=='.');
		}
	}
	--a;--b;--c;--d;
	
	deque<pair<pair<ll, ll>, ll>> dq;
	dq.push_front(make_pair(make_pair(a,b),0));
	
	bool f = true;
	
	while(!dq.empty()){
		
		pair<pair<ll, ll> , ll> x = dq.front();
		dq.pop_front();
		
		pair<int, int> pos = x.first;
		
		if(vis[pos.first][pos.second]) continue;
		vis[pos.first][pos.second] = 1;
		
		if(pos.first==c && pos.second==d){
			cout<<x.second<<endl;
			f = false;
			break;
			
		}
		
		for(ll i=0;i<4;i++){
			
			ll x = pos.first + dx[i];
			ll y = pos.second + dy[i];
			
			if(valid(x,y) && mat[x][y] && !vis[x][y]){
				dq.push_front(make_pair(make_pair(x,y),x.second));
			}
			
		}
		for(ll i=-2;i<=2;i++){
			for(ll j=-2;j<=2;j++){
				ll x = pos.first+i;
				ll y = pos.second+j;
				
				if(valid(x,y) && mat[x][y] && !vis[x][y]){
					dq.push_back(make_pair(make_pair(x,y),x.second+1));
				}
			}
		}
	}
	if(f) cout<<-1<<endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:74: error: request for member 'second' in 'x', which is of non-class type 'll' {aka 'long long int'}
   70 |                                 dq.push_front(make_pair(make_pair(x,y),x.second));
      |                                                                          ^~~~~~
a.cc:80:81: error: request for member 'second' in 'x', which is of non-class type 'll' {aka 'long long int'}
   80 |                                         dq.push_back(make_pair(make_pair(x,y),x.second+1));
      |                                                                                 ^~~~~~
Language: C++

#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef std::vector<int> VI;
typedef std::pair<int, int> P;


struct Node {
    int x, y, step = 0;
};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int dir[4][2] = { 1,0,0,1,-1,0,0,-1 };
    int H, W, Ch, Dh, Cw, Dw;
    const int maxn = 1e3 + 5;
    char Maze[maxn][maxn];
    int visited[maxn][maxn], ans[maxn][maxn];
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            char temp;
            cin >> temp;
            Maze[i][j] = temp;
            ans[i][j] = -1;

        }
    }
    deque<Node> List;
    List.push_front((Node) { Cw, Ch, 0 });

    while (!List.empty())
    {
        Node nd = List.front(); List.pop_front();
        int x = nd.x, y = nd.y, step = nd.step;
        if (visited[y][x])continue;
        visited[y][x] = 1;
        ans[y][x] = step;
        for (int i = 0; i < 4; i++)
        {
            int xx = x + dir[i][0], yy = y + dir[i][1];
            if (xx > 0 && xx <= W && yy > 0 && yy <= H && !visited[yy][xx] && Maze[yy][xx] == '.')
            {
                List.push_front((Node) { xx, yy, step });
            }
        }
        for (int xx = x - 2; xx <= x + 2; xx++)
        {
            for (int yy = y - 2; yy <= y + 2; yy++)
            {
                if (xx > 0 && xx <= W && yy > 0 && yy <= H && !visited[yy][xx] && Maze[yy][xx] == '.')
                {
                    List.push_back((Node) { xx, yy, step + 1 });
                }

            }
        }
    }
    if (ans[Dh][Dw] < 0) cout << "-1";
    else cout << ans[Dh][Dw];

Compiler output:
a.cc: In function 'int main()':
a.cc:70:30: error: expected '}' at end of input
   70 |     else cout << ans[Dh][Dw];
      |                              ^
a.cc:19:1: note: to match this '{'
   19 | {
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MAX = 1000;
const int dy[4]={0,1,0,-1}, dx[4]={1,0,-1,0}; // 4近傍の移動
int H,W;
int goal_y, goal_x;
bool g[MAX][MAX]; // 通れるマスならtrue
bool visited[MAX][MAX];

int bfs(int warp_count, vector<P> prev_warped) {
  vector<P> reached_by_walking; // 今回新しく到達したマス
  // 前の階層でワープして到達したマスから四近傍移動で到達できる点を探索
  for(auto& start_pair : prev_warped) {
    queue<P> que;
    P current_p = start_pair;
    visited[current_p.first][current_p.second] = true;
    reached_by_walking.push_back(P(current_p.first, current_p.second));
    que.push(current_p);
    while(!que.empty()) {
      current_p = que.front();
      que.pop();
      for(int i = 0; i < 4; ++i) {
        int next_y = current_p.first + dy[i];
        int next_x = current_p.second + dx[i];
        // 範囲外
        if(next_y < 0 || next_y >= H) continue;
        if(next_x < 0 || next_x >= W) continue;

        if(next_y == goal_y && next_x == goal_x) return warp_count; // 目的のマスについた

        // 通れないまたはすでに到達済み
        if(!g[next_y][next_x]) continue;
        if(visited[next_y][next_x]) continue;
        reached_by_walking.push_back(P(next_y, next_x));
        que.push(P(next_y, next_x));
        // que.push(make_tuple(next_y, next_x, curr_d+1));
        visited[next_y][next_x] = true;
      }
    }
  }
  if(reached_by_walking.empty()) return -1; // 歩きで新しいマスに到達できない場合これ以上探索しても意味ない
  vector<P> warped; // この階層でワープしたマス
  // 新しく到達したマスからワープする
  for(auto& reached : reached_by_walking) {
    int current_y = reached.first, current_x = reached.second;
    for(int dy = -2; dy <= 2; ++dy) {
      for(int dx = -2; dx <= 2; ++dx) {
        if(!dy && !dx) continue;
        int next_y = current_y + dy;
        int next_x = current_x + dx;
        if(next_y < 0 || next_y >= H) continue;
        if(next_x < 0 || next_x >= W) continue;
        if(next_y == goal_y && next_x == goal_x) return warp_count+1; // 目的のマスについた

        // 通れないまたはすでに到達済み
        if(!g[next_y][next_x]) continue;
        if(visited[next_y][next_x]) continue;
        warped.push_back(P(next_y, next_x));
        visited[next_y][next_x] = true;
      }
    }
  }
  if(warped.empty()) return -1; // 歩きで到達できる範囲にも答えがなく、ワープを使っても到達点を拡大できない
  return bfs(warp_count+1, warped);
}

signed main() {
  cin >> H >> W;
  int start_y, start_x;
  cin >> start_y >> start_x; --start_y; --start_x;
  cin >> goal_y >> goal_x; --goal_y; --goal_x;
  REP(h, H) {
    REP(w, W) {
      char c;
      cin >> c;
      g[h][w] = (c == '.');
    }
  }
  cout << bfs(0, vector<P>{P(start_y, start_x)});
  cout << "\n";
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:75:7: error: 'h' was not declared in this scope
   75 |   REP(h, H) {
      |       ^
a.cc:75:3: error: 'REP' was not declared in this scope
   75 |   REP(h, H) {
      |   ^~~