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

 import java.util.HashMap;
    import java.util.Scanner;
    public static int n;
    public static int limit;
    public static String ans;
    public static final int[] d = {4, -4, -1, 1};
    public static HashMap<String, Integer> hm;
    public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            n = 16;
            char[] s = new char[n];
            for (int i = 0; i < n; i++) {
                s[i] = (char)('0' + sc.nextInt());
            }
            ans = "123456789:;<=>?0";
            for (int i = 0; i < 46; i++) {
                hm = new HashMap<String, Integer>();
                limit = i;
                dfs(new Panel(toString(s), 0));
            }
            sc.close();
        }
        public static void dfs(Panel u) {
            if (u.s.equals(ans)) {
                System.out.println(u.count);
                System.exit(0);
            }
            if (u.count + u.min > limit) {
                return;
            }
            hm.put(u.s, u.count);
            StringBuffer str = new StringBuffer(u.s);
            int zero = str.indexOf("0");
            assert (zero != -1);
            for (int i = 0; i < d.length; i++) {
                if (zero + d[i] >= 0 && zero + d[i] < n && !(d[i] == -1 && (zero + d[i]) % 4 == 3) && !(d[i] == 1 && (zero + d[i]) % 4 == 0)) {
                    str.setCharAt(zero, str.charAt(zero + d[i]));
                    str.setCharAt(zero + d[i], '0');
                    String tmps = str.toString();
                    if (!hm.containsKey(tmps) || hm.get(tmps) > u.count + 1) {
                        dfs(new Panel(tmps, u.count + 1));
                    }
                    str.setCharAt(zero + d[i], str.charAt(zero));
                    str.setCharAt(zero, '0');
                }
            }
        }

        public static class Panel {
            String s;
            int count;
            int min;
            Panel (String s, int count) {
                this.s = s;
                this.count = count;
                this.min = getMin(s);
            }
            public int getMin(String s) {
                char[] c = s.toCharArray();
                int ret = 0;
                for (int i = 0; i < c.length; i++) {
                    int tmp = c[i] - '0';
                    if (tmp != 0) {
                        int x = (tmp - 1) % 4;
                        int y = (tmp - 1) / 4;
                        ret += Math.abs(x - i % 4) + Math.abs(y - i / 4);
                    }
                }
                return ret;
            }
        }
        public static String toString(char[] s) {
            String ret = "";
            for (int i = 0; i < s.length; i++) {
                ret += s[i];
            }
            return ret;
        }
    }


Compiler output:
Main.java:3: error: unnamed classes are a preview feature and are disabled by default.
    public static int n;
                  ^
  (use --enable-preview to enable unnamed classes)
1 error
Language: C

#include <stdio.h>
#include <stdlib.h>

// I/O
int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}


// Node
typedef struct NodeKey {
    int board[16];
    int space;
    // heuristic: manhattan distance
    int est;
} NodeKey;


// solve
int dfs(const int lim, const int depth, const int prev, const NodeKey *node, const int M, const int L1[][16]) {
    if(node->est == 0) return 1;
    if(depth + node->est > lim) return 0;

    static const int dx[] = {-1, 0, 1, 0};
    static const int dy[] = {0, -1, 0, 1};
    const int x = node->space % M;
    const int y = node->space / M;

    for(int i = 0; i < 4; ++i) {
        const int nx = x + dx[i];
        const int ny = y + dy[i];
        if(nx < 0 || M <= nx || ny < 0 || M <= ny) continue;
        if(abs(prev - i) == 2) continue;

        const int next_space = nx + ny * M;
        NodeKey next_node = *node;
        next_node.est -= L1[next_space][next_node.board[next_space] - 1];
        next_node.est += L1[next_node.space][next_node.board[next_space] - 1];
        next_node.board[next_node.space] = next_node.board[next_space];
        next_node.board[next_space] = 0;
        next_node.space = next_space;
        if(dfs(lim, depth + 1, i, &next_node, M, L1)) return 1;
    }
    return 0;
}

int iterative_deepening(NodeKey *node) {
    const int N = 16;
    const int M = 4;
    int L1[N][N];
    for(int i = 0; i < N; ++i)
        for(int j = 0; j < N; ++j) L1[i][j] = abs(i % M - j % M) + abs(i / M - j / M);

    int min = 0;
    for(int i = 0; i < N; ++i)
        if(i != node->space) min += L1[i][node->board[i] - 1];
    node->est = min;
    for(const int lim = 46; min < lim; ++min)
        if(dfs(min, 0, 9, node, M, L1)) return min;
    return -1;
}

int main(int argc, char **argv) {
    NodeKey initial;
    for(int i = 0; i < 16; ++i) {
        int x = get_uint();
        initial.board[i] = x;
        if(x == 0) initial.space = i;
    }
    put_uint(interative_deepening(&initial));
    putchar_unlocked('\n');
    return 0;
}



Compiler output:
main.c: In function 'main':
main.c:84:14: error: implicit declaration of function 'interative_deepening'; did you mean 'iterative_deepening'? [-Wimplicit-function-declaration]
   84 |     put_uint(interative_deepening(&initial));
      |              ^~~~~~~~~~~~~~~~~~~~
      |              iterative_deepening
Language: C

#include <stdio.h>

#define SIZE 4

int board[SIZE][SIZE];
const int goal[SIZE][SIZE] = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,0}};

void read_board() {
  for (int i = 0; i < SIZE; i++)
    for (int j = 0; j < SIZE; j++)
      scanf("%d", &board[i][j]);
}

void print() {
  for (int i = 0; i < SIZE; i++) {
    for (int j = 0; j < SIZE; j++)
      printf("%2d ", board[i][j]);
    printf("\n");
  }
}

void find(int num, int *row, int *col) {
  for (int i = 0; i < SIZE; i++) {
    for (int j = 0; j < SIZE; j++) {
      if (board[i][j] == num) {
        *row = i;
        *col = j;
      }
    }
  }
}

void switch_board(int row1, int col1, int row2, int col2) {
  int tmp = board[row1][col1];
  board[row1][col1] = board[row2][col2];
  board[row2][col2] = tmp;
}

int get_distance() {
  int sum = 0;
  for (int i = 0; i < SIZE; i++)
    for (int j = 0; j < SIZE; j++)
      if (board[i][j] !== goal[i][j]) ++sum;
  return sum / 2;
}

const int NOT_FOUND = 0;
const int FOUND = 1;

int iddfs(int step, int max, int row, int col) {
  if (step == max) {
    for (int i = 0; i < SIZE; i++)
      for (int j = 0; j < SIZE; j++)
        if (board[i][j] != goal[i][j]) return NOT_FOUND;
    return FOUND;
  }

  if (step + get_distance() > max) return NOT_FOUND;

  if (row > 0) {
    switch_board(row, col, row-1, col);
    if (iddfs(step + 1, max, row-1, col) == FOUND) return FOUND;
    switch_board(row, col, row-1, col);
  }
  if (row < 3) {
    switch_board(row, col, row+1, col);
    if (iddfs(step + 1, max, row+1, col) == FOUND) return FOUND;
    switch_board(row, col, row+1, col);
  }
  if (col > 0) {
    switch_board(row, col, row, col-1);
    if (iddfs(step + 1, max, row, col-1) == FOUND) return FOUND;
    switch_board(row, col, row, col-1);
  }
  if (col < 3) {
    switch_board(row, col, row, col+1);
    if (iddfs(step + 1, max, row, col+1) == FOUND) return FOUND;
    switch_board(row, col, row, col+1);
  }
  return NOT_FOUND;
}

int main() {
  int row, col, i;
  read_board();
  find(0, &row, &col);
  for (i = 0; i <= 45; i++)
    if (iddfs(0, i, row, col) == FOUND) break;
  printf("%d\n", i); 
  return 0;
}

Compiler output:
main.c: In function 'get_distance':
main.c:43:25: error: expected expression before '=' token
   43 |       if (board[i][j] !== goal[i][j]) ++sum;
      |                         ^
Language: C

#include <stdio.h>
#include <stdlib.h>

#define tate 4
#define yoko 4
#define Total (tate*yoko)

int main( void )
{
    int val[Total];
    int i = 0;
    int cnt, tmp = 0;
    int finish = 0;
    int num_0 = 0;
    
    for(i=0; i<Total; i++)
    {
        scanf("%d",&val[i]);
        if(val[i] == 0)
        {
            num_0 = i;
        }
    }
    
    printf("%d",num_0);
    
    while(finish==0)
    {
        val[num_0]
        tmp = 0;
        
        finish = 1;
        for(i=0; i<(Total-1); i++)
        {
            if(val[i] != (i+1))
            {
                finish = 0;
                break;
            }
        }
    }
    
    printf("%d\n",cnt);

    return 0;
}




Compiler output:
main.c: In function 'main':
main.c:29:19: error: expected ';' before 'tmp'
   29 |         val[num_0]
      |                   ^
      |                   ;
   30 |         tmp = 0;
      |         ~~~
Language: C

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 4;


struct Puzzle
{
    int f[maxn][maxn];
    int spaceX;
    int spaceY;
    int dis;
};

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

bool is_valid(int x, int y){
    return x >= 0 && x < maxn && y >= 0 && y < maxn;
}

int getH(const Puzzle& p)
{
    int cnt = 0;
    for(int i = 0; i < maxn; i++)
    {
        for(int j = 0; j < maxn; j++)
        {
            if(i == 3 && j == 3)
            {
                if(p.f[i][j] != 0) cnt++;
            }
            else if(p.f[i][j] != i*maxn+j+1) cnt++;
        }
    }
    cnt++;
}

bool dfs(Puzzle start, int d, int maxd)
{
    if(start.dis == 0) return true;
    if(start.dis/2 + d > maxd) return false;
    //if(start.dis == 0) return true;

    for(int i = 0; i < 4; i++)
    {
        int newX = start.spaceX + dx[i];
        int newY = start.spaceY + dy[i];
        if(!is_valid(newX, newY)) continue;
        Puzzle now = start;
        now.spaceX = newX;
        now.spaceY = newY;
        swap(now.f[start.spaceX][start.spaceY], now.f[newX][newY]);
        now.dis = getH(now);
        if(dfs(now, d+1, maxd)) return true;
    }
    return false;
}

int main()
{
    Puzzle start;
    for(int i = 0; i < maxn; i++)
        for(int j = 0; j < maxn ; j++)
        {
            scanf("%d", &start.f[i][j]);
            if(start.f[i][j] == 0) {start.spaceX = i; start.spaceY = j;}
        }
    start.dis = getH(start);
    for(int maxd = 0; maxd <= 45; maxd++)
        if(dfs(start, 0, maxd)) {printf("%d\n", maxd); break;}
    return 0;
}



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

#include<bits/stdc++.h>

using namespace std;

#define N 4
#define N2 16
#define LIMIT 100

int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};       //注意这块有的数据可能因为走的方向不同而导致TLE
char dir[4]={'r','u','l','d'};
int MDT[N2][N2];

struct Puzzle{
    int f[N2],space,MD;
};

Puzzle state;
int limit;
int path[LIMIT];

struct State{
    Puzzle puzzle;
    int estimated;
    bool operator < (const State &s) const{
        return estimated>s.estimated;
    }
};

int getallMD(Puzzle pz){
    int sum=0;
    for(int i=0;i<N2;i++){
        if(pz.f[i]==N2) continue;
        sum+=MDT[i][pz.f[i]-1];
    }
    return sum;
}

bool isSolved(){
    for(int i=0;i<N2;i++){
        if(state.f[i]!=i+1) return false;
    }return true;
}

bool dfs(int depth,int pre){
    if(state.MD==0) return 1;
    if(depth+state.MD>limit) return false;
    int sx=state.space/N;
    int sy=state.space%N;
    Puzzle tmp;
    for(int r=0;r<4;r++){
        int tx=sx+dx[r];
        int ty=sy+dy[r];
        if(tx<0||ty<0||tx>=N||ty>=N){
            continue;
        if(max(pre,r)-min(pre,r)==2) continue;//去重
        tmp=state;
        state.MD-=MDT[tx*N+ty][state.f[tx*N+ty]-1];
        state.MD+=MDT[sx*N+sy][state.f[tx*N+ty]-1];
        swap(state.f[sx*N+sy],state.f[tx*N+ty]);
        state.space=tx*N+ty;
        if(dfs(depth+1,r)){
            path[depth]=r;
            return true;
        }
        state=tmp;
    }
    return false;
}

string iterator_deeping(Puzzle in) {
    in.MD=getallMD(in);
    for(int limit=in.MD;limit<LIMIT;limit++){
        state=in;
        if(dfs(0,-100)){
            string ans="";
            for(int i=0;i<limit;i++){
                ans+=dir[path[i]];
            }
            return ans;
        }
    }
}

int main()
{
    for(int i=0;i<N2;i++){
        for(int j=0;j<N2;j++){
            MDT[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
        }
    }
    Puzzle in;
    for(int i=0;i<N2;i++){
        cin>>in.f[i];
        if(in.f[i]==0){
            in.f[i]=N2;
            in.space=i;
        }
    }
    string ans=iterator_deeping(in);
    cout<<ans.size()<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'bool dfs(int, int)':
a.cc:71:36: error: a function-definition is not allowed here before '{' token
   71 | string iterator_deeping(Puzzle in) {
      |                                    ^
a.cc:85:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   85 | int main()
      |         ^~
a.cc:85:9: note: remove parentheses to default-initialize a variable
   85 | int main()
      |         ^~
      |         --
a.cc:85:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:86:1: error: a function-definition is not allowed here before '{' token
   86 | {
      | ^
a.cc:103:2: error: expected '}' at end of input
  103 | }
      |  ^
a.cc:45:28: note: to match this '{'
   45 | bool dfs(int depth,int pre){
      |                            ^
a.cc:103:2: warning: control reaches end of non-void function [-Wreturn-type]
  103 | }
      |  ^
Language: C++

from collections import deque
def move(P):
    for i in range(4):
        for j in range(4):
            if P[i][j] == 0:
                r,c = i,j
    if not r == 0:
        tmp = [i[:] for i in P]
        tmp[r][c],tmp[r-1][c] = tmp[r-1][c],tmp[r][c]
        yield tmp
    if not r == 3:
        tmp = [i[:] for i in P]
        tmp[r][c],tmp[r+1][c] = tmp[r+1][c],tmp[r][c]
        yield tmp
    if not c == 0:
        tmp = [i[:] for i in P]
        tmp[r][c],tmp[r][c-1] = tmp[r][c-1],tmp[r][c]
        yield tmp
    if not c == 3:
        tmp = [i[:] for i in P]
        tmp[r][c],tmp[r][c+1] = tmp[r][c+1],tmp[r][c]
        yield tmp

A = [[int(i) for i in input().split()] for _ in range(4)]
dp = {dpkey(A) : 1}
d = deque([(A,0)])
c = 0
flag = True
while(flag):
    tmp,c = d.pop()
    for i in move(tmp):
        key = str(i)
        if key == "[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 0]]":
            ans = c + 1
            flag = False
        elif not key in dp:
            dp[key] = 1
            d.appendleft((i,c+1))
if str(A) == "[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 0]]":
    ans = 0
print(ans)


Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import deque
      | ^~~~
a.cc:26:1: error: 'd' does not name a type
   26 | d = deque([(A,0)])
      | ^
Language: C++

from collections import deque
def move(P):
    for i in range(4):
        for j in range(4):
            if P[i][j] == 0:
                r,c = i,j
    if not r == 0:
        tmp = [i[:] for i in P]
        tmp[r][c],tmp[r-1][c] = tmp[r-1][c],tmp[r][c]
        yield tmp
    if not r == 3:
        tmp = [i[:] for i in P]
        tmp[r][c],tmp[r+1][c] = tmp[r+1][c],tmp[r][c]
        yield tmp
    if not c == 0:
        tmp = [i[:] for i in P]
        tmp[r][c],tmp[r][c-1] = tmp[r][c-1],tmp[r][c]
        yield tmp
    if not c == 3:
        tmp = [i[:] for i in P]
        tmp[r][c],tmp[r][c+1] = tmp[r][c+1],tmp[r][c]
        yield tmp

A = [[int(i) for i in input().split()] for _ in range(4)]
dp = {str(A) : 1}
d = deque([(A,0)])
c = 0
flag = True
while(flag):
    tmp,c = d.pop()
    for i in move(tmp):
        key = str(i)
        if key == "[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 0]]":
            ans = c + 1
            flag = False
        elif not key in dp:
            dp[key] = 1
            d.appendleft((i,c+1))
if str(A) == "[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 0]]":
    ans = 0
print(ans)


Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import deque
      | ^~~~
a.cc:26:1: error: 'd' does not name a type
   26 | d = deque([(A,0)])
      | ^
Language: C++

from collections import deque

def move(P,p):
    if p > 3:
        tmp = P[:]
        tmp[p],tmp[p-4] = tmp[p-4],tmp[p]
        tmpp = p - 4
        yield tmp,tmpp
    if p < 12:
        tmp = P[:]
        tmp[p],tmp[p+4] = tmp[p+4],tmp[p]
        tmpp = p + 4
        yield tmp,tmpp
    if p%4 > 0:
        tmp = P[:]
        tmp[p],tmp[p-1] = tmp[p-1],tmp[p]
        tmpp = p - 1
        yield tmp,tmpp
    if p%4 < 3:
        tmp = P[:]
        tmp[p],tmp[p+1] = tmp[p+1],tmp[p]
        tmpp = p + 1
        yield tmp,tmpp

def evaluate(P,Q):
    mht = 0
    for i in range(16):
        pi = P.index(i)
        qi = Q.index(i)
        pc,pr = pi//4,pi%4
        qc,qr = qi//4,qi%4
        mht += abs(pc-qc)+abs(pr-qr)
    return mht

A = []
B = [int(i)%16 for i in range(1,17)]
for i in range(4):
        A+=[int(i) for i in input().split()]
dp = {str(A) : (1,0),str(B) : (2,0)}
d = deque([(A,0,A.index(0))])
e = deque([(B,0,15)])
ans = 46
while(len(d)>0 and len(e)>0):
    tmp,count,p = d.pop()
    for i,j in move(tmp,p):
        key = str(i)
        if key in dp:
            if dp[key][0] == 2:
                tmpans = count + 1 + dp[key][1]
                if tmpans < ans:
                    ans = tmpans
        else:
            if evaluate(B,i) + count < ans:
                dp[key] = (1,count+1)
                d.append((i,count+1,j))
    tmp,count,p = e.pop()
    for i,j in move(tmp,p):
        key = str(i)
        if key in dp:
            if dp[key][0] == 1:
                tmpans = count + 1 + dp[key][1]
                if tmpans < ans:
                    ans = tmpans
        else:
            if evaluate(A,i) + count < 46:
                dp[key] = (2,count+1)
                e.append((i,count+1,j))
            
if str(A) == "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]":
    ans = 0
print(ans)


Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import deque
      | ^~~~
a.cc:40:1: error: 'd' does not name a type
   40 | d = deque([(A,0,A.index(0))])
      | ^
Language: C++

from collections import deque
import heapq

def move(P,p):
    if p > 3:
        tmp = P[:]
        tmp[p],tmp[p-4] = tmp[p-4],tmp[p]
        tmpp = p - 4
        yield tmp,tmpp
    if p < 12:
        tmp = P[:]
        tmp[p],tmp[p+4] = tmp[p+4],tmp[p]
        tmpp = p + 4
        yield tmp,tmpp
    if p%4 > 0:
        tmp = P[:]
        tmp[p],tmp[p-1] = tmp[p-1],tmp[p]
        tmpp = p - 1
        yield tmp,tmpp
    if p%4 < 3:
        tmp = P[:]
        tmp[p],tmp[p+1] = tmp[p+1],tmp[p]
        tmpp = p + 1
        yield tmp,tmpp

def evaluate(P,Q):
    mht = 0
    for i in range(16):
        pi = P.index(i)
        qi = Q.index(i)
        pc,pr = pi//4,pi%4
        qc,qr = qi//4,qi%4
        mht += abs(pc-qc)+abs(pr-qr)
    return mht
        
A = []
B = [int(i)%16 for i in range(1,17)]
for i in range(4):
        A+=[int(i) for i in input().split()]
dp = {str(A) : (1,0),str(B) : (2,0)}
h = [(evaluate(A,B),A,0,A.index(0))]
e = [(evaluate(A,B),B,0,15)]
heapq.heapify(h)
heapq.heapify(e)
sw = False
ans = 46
while(len(h)>0 and len(e)>0):
    mht,tmp,count,p = heapq.heappop(h)
    if sw and len(h)>0:
        tmph = (mht,tmp,count,p)
        mht,tmp,count,p = heapq.heappop(h)
        heapq.heappush(h,tmph)
        sw = True
    else:
        if sw:
            sw = False
    for i,j in move(tmp,p):
        key = str(i)
        if key in dp:
            if dp[key][0] == 2:
                tmpcount = count + 1 + dp[key][1]
                if tmpcount < ans:
                    ans = tmpcount
            else:
                continue
        else:
            dp[key] = (1,count+1)
            mht = evaluate(B,i)
            if count+mht*14//13 < ans:
                heapq.heappush(h,(mht//2+count,i,count+1,j))
    _,tmp,count,p = heapq.heappop(e)
    for i,j in move(tmp,p):
        key = str(i)
        if key in dp:
            if dp[key][0] == 1:
                tmpcount = count + 1 + dp[key][1]
                if tmpcount < ans:
                    ans = tmpcount
            else:
                continue
        else:
            dp[key] = (2,count+1)
            mht = evaluate(A,i)
            if count+mht*14//13 < ans:
                heapq.heappush(e,(mht//2+count,i,count+1,j))

if str(A) == "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]":
    ans = 0
print(ans)


Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import deque
      | ^~~~
a.cc:41:1: error: 'h' does not name a type
   41 | h = [(evaluate(A,B),A,0,A.index(0))]
      | ^
Language: C++

// ------ Includes ------ //
  
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <iostream>
  
using namespace std;
  
  
// ------ Directions ------ //
  
const int dx[4] = { 0, 1, 0, -1 };
const int dy[4] = { 1, 0, -1, 0 };
  
  
// ------ BFS ------ //
  
int BFS(vector<vector<char> > p)
{
    // ------ Initialize ------ //
  
    vector<vector<char> > lastboard = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 }, { 13, 14, 15, 0 } };
  
    map<vector<vector<char> >, char> D;
  
    queue<pair<vector<vector<char> >, char> > que;
  
    D[p] = (char)1; que.push(make_pair(p, (char)1));
  
  
    // ------ Search ------ //
  
    if (p == lastboard)
    {
        return 0;
    }
  
    while (!que.empty())
    {
        pair<vector<vector<char> >, char> p1 = que.front(); que.pop();
  
  
        // ------ 0 Searching ------ //
  
        int tx = -1, ty = -1;
  
        for (int i = 0; i < p1.first.size(); i++)
        {
            for (int j = 0; j < p1.first[i].size(); j++)
            {
                if (p1.first[i][j] == (char)0)
                {
                    tx = j; ty = i;
                }
            }
        }
  
  
        // ------ Moving ------ //
  
        for (int dir = 0; dir < 4; dir++)
        {
            if (0 <= tx + dx[dir] && tx + dx[dir] < p1.first[0].size() && 0 <= ty + dy[dir] && ty + dy[dir] < p1.first.size())
            {
                vector<vector<char> > p2 = p1.first;
  
                swap(p2[ty][tx], p2[ty + dy[dir]][tx + dx[dir]]);
  
                if (D[p2] == 0)
                {
                    if (p2 == lastboard)
                    {
                        return p1.second;
                    }
  
                    D[p2] = p1.second + 1;
  
                    que.push(make_pair(p2, p1.second + (char)1));
                }
            }
        }
    }
  
    return -1;
}
  
int main()
{
    vector<vector<char> > board(4, vector<char>(4, -1)); int S;
  
    for (int i = 0; i < board.size(); i++)
    {
        for (int j = 0; j < board[i].size(); j++)
        {
            cin >> A;

            board[i][j] = A;
        }
    }
  
    cout << BFS(board) << endl;
  
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:97:20: error: 'A' was not declared in this scope
   97 |             cin >> A;
      |                    ^
Language: C++

#include <map>
#include <queue>
#include <iostream>
typedef unsigned long long ull;
using namespace std;
struct state { ull x; int zero, dist, remain; };
bool operator<(const state& s1, const state& s2) { return s1.dist + s1.remain > s2.dist + s2.remain; }
int a, dist[16][16], goals[16]; ull s, goal = 1147797409030816545;
int solve() {
	if (s == goal) return 0;
	map<ull, bool> dp; dp[s] = true;
	int zz = -1;
	for (int i = 0; i < 16; i++) {
		if (!((s >> (i * 4)) & 15)) zz = i;
	}
	int rr = 0;
	for (int i = 0; i < 16; i++) {
		int ww = ((s >> (i * 4)) & 15);
		if (!ww) continue;
		for (int j = 0; j < 16; j++) {
			if (ww == goals[j]) {
				rr += dist[i][j];
			}
		}
	}
	priority_queue<state> que;
	que.push(state{ s, zz, 0, rr });
	while (!que.empty()) {
		state a = que.front(); que.pop();
		ull v = a.x; int z = a.zero;
		int dir[4] = { 1, 0, -1, 0 };
		for (int i = 0; i < 4; i++) {
			int dx = dir[i], dy = dir[i ^ 1];
			int e = z + dy * 4 + dx;
			int g = ((v >> (e << 2)) & 15);
			if (0 <= e && e < 16 && (e & 3) - (z & 3) == dx) {
				ull w = v;
				w -= ((1ULL * g) << (e << 2));
				w += ((1ULL * g) << (z << 2));
				int xx = a.remain;
				xx -= dist[e][goals[g]];
				xx += dist[z][goals[g]];
				if (w == goal) return a.dist + 1;
				if(!dp[w]) que.push(state{ w, e, a.dist + 1, xx });
			}
		}
	}
	return -1;
}
int main() {
	for (int i = 0; i < 16; i++) {
		for (int j = 0; j < 16; j++) {
			dist[i][j] = abs((i >> 2) - (j >> 2)) + abs((i & 3) - (j & 3));
		}
	}
	for (int i = 0; i < 15; i++) goals[i] = i + 1; goals[15] = 0;
	for (int i = 0; i < 16; i++) {
		cin >> a;
		s += ((1ULL * a) << (i << 2));
	}
	cout << solve() << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:29:31: error: 'class std::priority_queue<state>' has no member named 'front'
   29 |                 state a = que.front(); que.pop();
      |                               ^~~~~
Language: C++

#include <map>
#include <queue>
#include <iostream>
#pragma warning(disable : 4996)
typedef unsigned long long ull;
using namespace std;
struct state { ull x; int zero, pre, dist, remain; };
bool operator<(const state& s1, const state& s2) { return s1.dist + s1.remain > s2.dist + s2.remain; }
int a, dist[16][16], goals[16], goals2[16]; ull s, goal = 1147797409030816545;
int dir[4] = { 1, 0, -1, 0 };
int solve() {
	if (s == goal) return 0;
	int zz = -1;
	for (int i = 0; i < 16; i++) {
		if (!((s >> (i * 4)) & 15)) zz = i;
	}
	int rr = 0;
	for (int i = 0; i < 16; i++) {
		int ww = ((s >> (i * 4)) & 15);
		if (!ww) continue;
		for (int j = 0; j < 16; j++) {
			if (ww == goals[j]) {
				rr += dist[i][j];
			}
		}
	}
	priority_queue<state> que;
	que.push(state{ s, zz, -99, 0, rr });
	while (!que.empty()) {
		state a = que.top(); que.pop();
		ull v = a.x; int z = a.zero;
		for (int i = 0; i < 4; i++) {
			if (abs(i - a.pre) == 2) continue;
			int dx = dir[i], dy = dir[i ^ 1];
			int e = z + dy * 4 + dx;
			int g = ((v >> (e << 2)) & 15);
			if (0 <= e && e < 16 && (e & 3) - (z & 3) == dx) {
				ull w = v;
				w -= ((1ULL * g) << (e << 2));
				w += ((1ULL * g) << (z << 2));
				int xx = a.remain;
				xx -= dist[e][goals2[g]];
				xx += dist[z][goals2[g]];
				if (w == goal) return a.dist + 1;
				que.push(state{ w, e, i, a.dist + 1, xx });
			}
		}
	}
	return -1;
}
int main() {
	for (int i = 0; i < 16; i++) {
		for (int j = 0; j < 16; j++) {
			dist[i][j] = abs((i >> 2) - (j >> 2)) + abs((i & 3) - (j & 3));
		}
	}
	for (int i = 0; i < 15; i++) goals[i] = i + 1; goals[15] = 0;
	for (int i = 0; i < 16; i++) goals2[goals[i]] = i;
	for (int i = 0; i < 16; i++) {
		cin >> a;
		s += ((1ULL * a) << (i * 4));
	}
	cout << solve() << endl;
	_sleep(2000);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:9: error: '_sleep' was not declared in this scope
   64 |         _sleep(2000);
      |         ^~~~~~
Language: C++

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vp;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1<<28;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const pi goal[] = {
	pi(3,3), pi(0,0), pi(0,1), pi(0,2),
	pi(0,3), pi(1,0), pi(1,1), pi(1,2),
	pi(1,3), pi(2,0), pi(2,1), pi(2,2),
	pi(2,3), pi(3,0), pi(3,1), pi(3,2)
};

struct S {
	vector<vi> vvi;
	int cnt, com;
	pi pnt;
	bool operator < (const S &a) const {
		return com > a.com;
	}
};

int getComp(vector<vi> vvi) {
	int res = 0;
	REP(i, 4) REP(j, 4) {
		res += abs(goal[vvi[i][j]].first - i);
		res += abs(goal[vvi[i][j]].second - j);
	}
	return res;
}

bool chk(int x, int y) {
	if(x < 0 || y < 0 || 4 <= x || 4 <= y)
		return false;
	return true;
}

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

	vector<vi> vvi(4);
	pi pnt;
	REP(i, 4) {
		vvi[i].resize(4);
		REP(j, 4) {
			cin >> vvi[i][j];
			if(vvi[i][j] == 0)
				pnt = pi(i, j);
		}
	}

	priority_queue<S> pq;
	pq.push(S{vvi, 0, getComp(vvi), pnt});

	while(!pq.empty()) {
		S s = pq.top(); pq.pop();
		/*
		cout << s.com << endl;
		REP(i, 4) {
			REP(j, 4)
				cout << s.vvi[i][j] << ' ';
			cout << endl;
		}
		*/

		if(s.com == 0) {
			cout << s.cnt << endl;
			return 0;
		}
		REP(i, 4) {
			vvi = s.vvi;
			int x = s.pnt.first + dx[i];

Compiler output:
a.cc: In function 'int main()':
a.cc:100:53: error: expected '}' at end of input
  100 |                         int x = s.pnt.first + dx[i];
      |                                                     ^
a.cc:98:27: note: to match this '{'
   98 |                 REP(i, 4) {
      |                           ^
a.cc:100:53: error: expected '}' at end of input
  100 |                         int x = s.pnt.first + dx[i];
      |                                                     ^
a.cc:83:28: note: to match this '{'
   83 |         while(!pq.empty()) {
      |                            ^
a.cc:100:53: error: expected '}' at end of input
  100 |                         int x = s.pnt.first + dx[i];
      |                                                     ^
a.cc:65:12: note: to match this '{'
   65 | int main() {
      |            ^
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
using namespace std;
const int num = 16, ud[] = { -1, 0, 1, 0 }, lr[] = { 0, -1, 0, 1 }, nd = 4;
const char wa[] = { 'u', 'l', 'd', 'r' };
int md[num][num];
vector<int> way;
int lm;
struct puzzle {
	int sp, p[num], mdp;
	string way;
	bool operator < (const puzzle &pu) const {
		for (int i = 0; i < num; i++) {
			if (p[i] == pu.p[i]) continue;
			return p[i] < pu.p[i];
		}
		return false;
	}
};
puzzle pu;
/*bool dfs(int de, int prev, puzzle pu) {
	if (pu.mdp + de> lm) return false;
	//cout << "prev" << prev << "pu.sp" << pu.sp << "mdp" <<  pu.mdp << endl;
	if (!pu.mdp) {return true; }
	int sx = pu.sp / nd;
	int sy = pu.sp % nd;
	int tx, ty, ns;
	//puzzle tmp = pu;
	puzzle tmp;
	for (int r = 0; r < nd; r++) {
		if (max(r, prev) - min(r, prev) == 2) continue;
		tx = sx + ud[r];
		ty = sy + lr[r];
		tmp = pu;
		if (tx >= nd || tx < 0 || ty >= nd || ty < 0) continue;
		ns = tx * nd + ty;
		pu.mdp = pu.mdp - md[ns][pu.p[ns]-1] + md[sx*nd + sy][pu.p[ns]-1];
		pu.sp = ns;
		swap(pu.p[ns], pu.p[pu.sp]);
		if (dfs(de + 1, r, pu)) { 
			cout << "r" << r << "sp" << pu.sp << endl;
			way.push_back(r);
			return true; 
		}
		pu = tmp;
	}
	return false;
}*/
bool dfs(int de, int pr) {
	if (pu.mdp == 0) return true;
	if (de + pu.mdp > lm) return false;
	int sx = pu.sp / nd;
	int sy = pu.sp % nd;
	int tx, ty, ns;
	puzzle tmp;
	puzzle tmp;
	for (int r = 0; r < nd; r++) {
		if (max(r, pr) - min(r, pr) == 2) continue;
		tx = sx + ud[r];
		ty = sy + lr[r];
		tmp = pu;
		if (tx >= nd || tx < 0 || ty >= nd || ty < 0) continue;
		ns = tx * nd + ty;
		pu.mdp -= md[ns][pu.p[ns]- 1];
		pu.mdp += md[pu.sp][pu.p[ns] - 1];
		pu.sp = ns;
		swap(pu.p[ns], pu.p[pu.sp]);
		if (dfs(de + 1, r)) {
			way.push_back(r);
			return true;
		}
		pu = tmp;
	}
	return false;
}

int main() {
	int sum = 0;
	for (int i = 0; i < num; i++) {
		cin >> pu.p[i];
		if (!pu.p[i]) { pu.sp = i; pu.p[i] = num; }
	}
	for (int i = 0; i < num; i++)
		for (int j = 0; j < num; j++)
			md[i][j] = abs(i / nd - j / nd) + abs(i%nd - j%nd);
	for (int i = 0; i < num; i++) {
		if (pu.p[i] == num) continue;
		sum += md[i][pu.p[i] - 1];
	}
	pu.mdp = sum;
	for (lm = pu.mdp; lm < 100; lm++) {
		if (dfs(0, -5/*, pu*/)) {
			cout << way.size() << endl; return 0;
		}
	}
}

Compiler output:
a.cc: In function 'bool dfs(int, int)':
a.cc:63:16: error: redeclaration of 'puzzle tmp'
   63 |         puzzle tmp;
      |                ^~~
a.cc:62:16: note: 'puzzle tmp' previously declared here
   62 |         puzzle tmp;
      |                ^~~
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
using namespace std;
const int num = 16, ud[] = { -1, 0, 1, 0 }, lr[] = { 0, -1, 0, 1 }, nd = 4;
const char wa[] = { 'u', 'l', 'd', 'r' };
int md[num][num];
vector<int> way;
int lm;
struct puzzle {
	int sp, p[num], mdp;
	string way;
	bool operator < (const puzzle &pu) const {
		for (int i = 0; i < num; i++) {
			if (p[i] == pu.p[i]) continue;
			return p[i] < pu.p[i];
		}
		return false;
	}
};
puzzle pu;
bool dfs(int de, int prev, puzzle pu) {
	if (pu.mdp + de> lm) return false;
	//cout << "mdp" << pu.mdp << endl;
	if (!pu.mdp) { /*cout << "mdp" << pu.mdp << endl; */return true; }
	int sx = pu.sp / nd;
	int sy = pu.sp % nd;
	int tx, ty, ns;
	puzzle tmp = pu;
	for (int r = 0; r < nd; r++) {
		if (max(r, prev) - min(r, prev) == 2) continue;
		tx = sx + ud[r];
		ty = sy + lr[r];
		if (tx >= nd || tx < 0 || ty >= nd || ty < 0) continue;
		ns = tx * nd + ty;
		tmp.mdp = pu.mdp - md[ns][pu.p[ns] - 1] + md[sx*nd + sy][pu.p[ns] - 1];
		tmp.sp = ns;
		swap(tmp.p[ns], tmp.p[sx * nd + sy]);
		if (dfs(de + 1, r, tmp)) { way.push_back(r); /*cout << "sp" << tmp.sp << "r" << r << endl;*/ return true; };
	}
	return false;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <assert.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <climits>

#define N 4
#define N2 16

using namespace std;

// const int N = 4;
// const int N2 = 16;

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'}; 


struct Node
{
	int puzzle[N2];
	int space;
	int md;
};

class Npuzzle
{
private:
	Node s_node;
	int limit;
	int md[N2][N2];
	vector<int> path;
	int ans;
public:
	Npuzzle() {
		s_node = Node();
		int in[N2];
		for (int i = 0; i < N2; ++i)
		{
			int tmp;
			cin >> tmp;
			if(tmp == 0) {
				tmp = N2;
				s_node.space = i;
			}
			s_node.puzzle[i] = tmp;
		}
		set_md();
		s_node.md = get_md_sum(s_node.puzzle);
	}

	int get_md_sum(int *puzzle) {
		int sum = 0;
		for (int i = 0; i < N2; ++i)
		{
			if(puzzle[i] == N2) continue;
			sum += md[i][puzzle[i]-1];
		}
		return sum;
	}

	void set_md() {
		for (int i = 0; i < N2; ++i)
		{
			for (int j = 0; j < N2; ++j)
			{
				md[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
			}
		}
	}

	bool dfs(Node cur_n, int depth, int pre) {
		if(cur_n.md == 0 ) {
			ans = depth;
			return true;
		}
		if(depth + cur_n.md > limit) return false;
		int s_x = cur_n.space / N;
		int s_y = cur_n.space % N;
		for (int i = 0; i < 4; ++i)
		{
			Node new_n = cur_n;
			int new_x = s_x + dx[i];
			int new_y = s_y + dy[i];
			if(new_x < 0  || new_y < 0 || new_x >= N || new_y >= N) continue; 
			if(max(pre, i) - min(pre, i) == 2) continue;

			new_n.md -= md[new_x * N + new_y][new_n.puzzle[new_x * N + new_y] - 1];
			new_n.md += md[s_x * N + s_y][new_n.puzzle[new_x * N + new_y] - 1];
			swap(new_n.puzzle[new_x * N + new_y], new_n.puzzle[s_x * N + s_y]);
			new_n.space = new_x * N + new_y;
			// assert(get_md_sum(new_n.puzzle) == new_n.md);
			// return dfs(new_n, depth+1, i);
			if(dfs(new_n, depth + 1, i)){
				path[depth] = i;
				return true;
			}
		}
		return false;
	}

	void ida_star() {
		for (limit = s_node.md; limit < 1000; ++limit)
		{
			path.resize(limit);
			if(dfs(s_node, 0, -10)) {
				cout << limit << endl;
				// string str = "";
				// for (int i = 0; i < limit; ++i)
				// {
				// 	str += dir[path[i]];
				// }
				// cout << str << endl;
				return;
			}
		}
	}

	void exec() {
		ida_star();
	}
};


int main() {
	Npuzzle np = Npuzzle();
	np.exec(); 
}

Compiler output:
a.cc:35:9: error: 'vector' does not name a type
   35 |         vector<int> path;
      |         ^~~~~~
a.cc: In member function 'bool Npuzzle::dfs(Node, int, int)':
a.cc:98:33: error: 'path' was not declared in this scope
   98 |                                 path[depth] = i;
      |                                 ^~~~
a.cc: In member function 'void Npuzzle::ida_star()':
a.cc:108:25: error: 'path' was not declared in this scope
  108 |                         path.resize(limit);
      |                         ^~~~
Language: C++

#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>
using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

struct Puzzle{
  int f[N2], space, MD;
};

static const int dx[4] = {0,-1,0,1};
static const int dy[4] = {1,0,-1,0};
static const char dir[4] = {'r','u','l','d'};
int MDT[N2][N2];
Puzzle state;
int limit;
int path[LIMIT];

int get(Puzzle pz){
  int sum = 0, i;
  for(i = 0; i < N2; i++){
    if(pz.f[i] == N2) continue;
    sum += MDT[i][pz.f[i] -1];
  }
  return sum;
}
bool isSolved(){
  for(int i = 0; i < N2; i++)
    if(state.f[i] != i + 1) return false;
  return true;
}

bool dfs(int depth, int prev){
  if(state.MD == 0) return true;
  if(depth + state.MD > limit) return false;
  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;
  for(int r = 0; r < 4; r++){
    int tx = sx + dx[r];
    int ty = sy + dy[r];
    if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
    if(max(prev, r) - min(prev, r) == 2) continue;
    tmp = state;
    state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
    state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
    swap(state.f[tx * N + ty], state.f[sx * N + sy]);
    state.space = tx * N + ty;
    if(dfs(depth + 1, r)){
      path[depth] = r;
      return true;
    }
    state = tmp;
  }
  return false;
}

string iterdeep(Puzzle in){
  in.MD = get(in);

  for(limit = in.MD; limit <= LIMIT; limit++){
    state = in;
    if(dfs(0, -100)){
      string ans = "";
      for(int i = 0; i <limit; i++)
        ans += dir[path[i]];
      return ans;
    }
  }
  return "unsolvable";
}
int main(){
  for(int i = 0; i < N2; i++){
    for(int j = 0; j < N2; j++){
      MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
    }
  }
  Puzzle in;
  for(int i = 0; i < N2; i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = iterdeep(in);
  cout << ans.size() << endl;

  return 0;
}
int main(){
  for(int i = 0; i < N2; i++){
    for(int j = 0; j < N2; j++){
      MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
    }
  }
  Puzzle in;
  for(int i = 0; i < N2; i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = iterdeep(in);
  cout << ans.size() << endl;

  return 0;
}

Compiler output:
a.cc:95:5: error: redefinition of 'int main()'
   95 | int main(){
      |     ^~~~
a.cc:76:5: note: 'int main()' previously defined here
   76 | int main(){
      |     ^~~~
Language: C++

#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
using namespace std;
int inf = 1000000000;

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

bool check(vector<int> a){
  for(int i=0; i<16; i++) if( a[i] != (i+1)%16 ) return false;
  return true;
}

int mandist(vector<int> a){
  int dist = 0;
  for(int i=0; i<16; i++){
    int tmp = (a[i] == 0 ? 16 : a[i]);
    int x = i % 4; int y = i / 4;
    int tx = (tmp-1) % 4; int ty = (tmp-1) / 4;
    dist += abs(x-tx) + abs(y-ty);
  }
  return -dist;
}

void bfs(vector<int> sss){
  priority_queue< pair< int, pair<int, vector<int> > > > q;
  q.push(make_pair(mandist(sss), make_pair(0, sss)));
  map< vector<int>, int> mpb;
  // map< vector<int>, bool> mpb;
  while( !q.empty() ){
    pair< int, pair<int, vector<int> > > p = q.top();
    q.pop();
    cerr << p.first << " " << p.second.first << " " << mpb[p.second.second] << " ->   ";
    for(int i=0; i<16; i++) cerr << p.second.second[i] << " ";
    cerr << endl;

    vector<int> s = p.second.second;
    if( mpb[s] == 0 ) mpb[s] = p.second.first;
    else mpb[s] = min(mpb[s], p.second.first);
    // mpb[s] = true;
    if( check(s) ){
      cout << p.second.first << endl;
      return;
    }

    for(int i=0; i<16; i++){
      if( s[i] == 0 ){
        int y = i / 4;
        int x = i % 4;
        for(int d=0; d<4; d++){
          int nx = x + dx[d]; int ny = y + dy[d];
          if( nx < 0 || ny < 0 || nx >= 4 || ny >= 4 ) continue;
          vector<int> t = s;
          swap(t[i], t[ny*4 + nx]);
          if( p.second.first > 46 ) continue:
          if( mpb.find(t) == mpb.end() ) q.push( make_pair(mandist(t), make_pair(p.second.first + 1, t)) );
          else if( mpb[t] > p.second.first + 1 ) q.push( make_pair(mandist(t), make_pair(p.second.first + 1, t)) );
          // if( mpb[t] == 0 ) q.push( make_pair(mandist(t), make_pair(p.second.first + 1, t)) );

          // if( !mpb[t] ) q.push( make_pair(mandist(t), make_pair(p.second.first + 1, t)) );
        }
      }
    }

  }
}

int main(){

  vector<int> a(16);
  for(int i=0; i<4; i++) for(int j=0; j<4; j++) cin >> a[i*4+j];

  bfs(a);
  // cerr << mandist(a) << endl;

  return 0;
}

Compiler output:
a.cc: In function 'void bfs(std::vector<int>)':
a.cc:61:45: error: expected ';' before ':' token
   61 |           if( p.second.first > 46 ) continue:
      |                                             ^
      |                                             ;
a.cc:61:45: error: expected primary-expression before ':' token
a.cc:63:11: error: 'else' without a previous 'if'
   63 |           else if( mpb[t] > p.second.first + 1 ) q.push( make_pair(mandist(t), make_pair(p.second.first + 1, t)) );
      |           ^~~~
Language: C++

#include <cstdio>
#include <iostream>
#include <cmath>
#include <map>
#include <queue>

using namespace std;
#define N 4
#define NN 16

static const int dx[4] = {0,-1,0,1};
static const int dy[4] = {1,0,-1,0};
int H[NN][NN];

struct Puzzle
{
  int f[NN],space,MD;
  int cost;

    bool operator < (const Puzzle& p) const {
    for(int i=0; i<N2; i++) {
        if( f[i] == p.f[i] ) continue;
        return f[i] < p.f[i];
    }
    return false;
    }
};

struct State
{
  Puzzle puzzle;
  int estimated;
  bool operator < (const State &s) const{
    return estimated > s.estimated;
  }
};

int getAllMD(Puzzle pz){
    int sum=0;
    for(int i=0; i<N2; i++) {
    if( pz.f[i] == N2 ) continue;
    sum += H[i][pz.f[i]-1];
    }
    return sum;
}

int astar(Puzzle s){
  priority_queue<State> PQ;
  s.MD = getAllMD(s);
  s.cost = 0;
  map<Puzzle,bool> V;
  Puzzle u,v;
  State initial;
  initial.puzzle = s;
  initial.estimated = getAllMD(s);
  PQ.push(initial);

  while(!PQ.empty()){
    State st = PQ.top(); PQ.pop();
    u = st.puzzle;
    if( u.MD == 0 ) return u.cost;
    V[u] = true;

    int sx = u.space / N;
    int sy = u.space % N;

    for(int r=0; r<4; r++) {
        int tx = sx + dx[r];
        int ty = sy + dy[r];
        if( tx<0 || ty<0 || tx>=N || ty>=N ) continue;
        v = u;

        v.MD -= H[tx*N+ty][v.f[tx*N+ty]-1];
        v.MD += H[sx*N+sy][v.f[tx*N+ty]-1];

        swap(v.f[sx*N+sy], v.f[tx*N+ty]);
        v.space = tx*N+ty;
        if( !V[v] ) {
        v.cost++;
        State news;
        news.puzzle = v;
        news.estimated = v.cost + v.MD;
        PQ.push(news);
        }
    }
    }
    return -1;
}

int main(){
for(int i = 0; i<NN; i++)
  for(int j =0;j < NN;j++)
    H[i][j] = abs(i / N - j / N) + abs(i % N - j % N);

  Puzzle in;

  for(int i=0;i<NN;i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = NN;
      in.space = i;
    }
  }

  cout << astar(in) << endl;
  return 0;
}


Compiler output:
a.cc: In member function 'bool Puzzle::operator<(const Puzzle&) const':
a.cc:21:20: error: 'N2' was not declared in this scope; did you mean 'NN'?
   21 |     for(int i=0; i<N2; i++) {
      |                    ^~
      |                    NN
a.cc: In function 'int getAllMD(Puzzle)':
a.cc:40:20: error: 'N2' was not declared in this scope; did you mean 'NN'?
   40 |     for(int i=0; i<N2; i++) {
      |                    ^~
      |                    NN
Language: C++

// Iterative Deepening
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>
using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const int char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle { int f[N2], space, MD; };

Puzzle state;
int limit;  /* 深さの制限 */
int path[LIMIT];

int getAllMD(Puzzle pz) {
  int sum = 0;
  for ( int i = 0; i < N2; i++ ) {
    if ( pz.f[i] == N2 ) continue;
    sum += MDT[i][pz.f[i] - 1];
  }
  return sum;
}

bool isSolved() {
  for ( int i = 0; i < N2; i++ ) if ( state.f[i] != i + 1 ) return false;
  return true;
}


bool dfs(int depth, int prev) {
  if ( state.MD == 0 ) return true;
  /* 現在の深さにヒューリスティックを足して制限を超えたら枝を刈る */
  if ( depth + state.MD > limit ) return false;

  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;

  for ( int r = 0; r < 4; r++ ) {
    int tx = sx + dx[r];
    int ty = sy + dy[r];
    if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
    if ( max(prev, r)-min(prev, r) == 2 ) continue;
    tmp = state;
    /* マンハッタン距離の差分を計算しつつ、ピースをスワップ */
    state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
    state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
    swap(state.f[tx * N + ty], state.f[sx * N + sy]);
    state.space = tx * N + ty;
    if ( dfs(depth + 1, r) ) { path[depth] = r; return true; }
    state = tmp;
  }

  return false;
}

/* 反復深化 */
string iterative_deepening(Puzzle in) {
  in.MD = getAllMD(in);  /* 初期状態のマンハッタン距離 */

  for ( limit = in.MD; limit <= LIMIT; limit++ ) {
    state = in;
    if ( dfs(0, -100) ) {
      string ans = "";
      for ( int i = 0; i < limit; i++ ) ans += dir[path[i]];
      return ans;
    }
  }

  return "unsolvable";
}

int main() {
  for ( int i = 0; i < N2; i++ )
    for ( int j = 0; j < N2; j++ )
      MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);

  Puzzle in;

  for ( int i = 0; i < N2; i++ ) {
    cin >> in.f[i];
    if ( in.f[i] == 0 ) {
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = iterative_deepening(in);
  cout << ans.size() << endl;

  return 0;
}


Compiler output:
a.cc:14:8: error: two or more data types in declaration of 'dir'
   14 | static const int char dir[4] = {'r', 'u', 'l', 'd'};
      |        ^~~~~
a.cc: In function 'std::string iterative_deepening(Puzzle)':
a.cc:73:48: error: 'dir' was not declared in this scope; did you mean 'div'?
   73 |       for ( int i = 0; i < limit; i++ ) ans += dir[path[i]];
      |                                                ^~~
      |                                                div