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

#include <cassert>
#include <iostream>
#include <vector>
/*
` `: Free
`Q`: Queen
`A`: Attackable
*/
typedef std::vector<std::vector<char> > TBoard;
struct TResult
{
    TBoard Board;
    bool IsOk;
    TResult(const TBoard& ABoard, bool AIsOk)
     : Board(ABoard), IsOk(AIsOk){}
};
TBoard AddQueen(const TBoard& ABoard, int r, int c)
{
    TBoard Board = ABoard;
    assert(Board[r][c] == ' ');
    Board[r][c] = 'Q';
    for(int i = 0; i < 8; ++i){
        Board[i][c] = 'A';
    }
    for(int i = 0; i < 8; ++i){
        Board[r][i] = 'A';
    }
    for(int i = -std::min(r, c); i < 8 - std::max(r, c); ++i){
        Board[r+i][c+i] = 'A';
    }
    for(int i = -std::min(r, 7-c); i < 8 -std::max(r, 7-c); ++i){
        Board[r+i][c-i] = 'A';
    }
    Board[r][c] = 'Q';
    return Board;
}

TResult Solve(const TBoard& ABoard, int n)
{
    if(n == 0) return TResult(ABoard, true);
    TBoard Board = ABoard;
    for(int r = 0; r < 8; ++r){
        for(int c = 0; c < 8; ++c){
            if(Board[r][c] != ' ') continue;
            TResult Result = Solve(AddQueen(Board, r, c), n-1);
            if(Result.IsOk) return Result;
        }
    }
    return TResult(Board, false);
}
void Print(const TBoard& Board, std::ostream& out)
{
    for(int r = 0; r < 8; ++r){
        for(int c = 0; c < 8; ++c){
            char symbol = Board[r][c] == 'Q' ? 'Q' : '.';
            out << symbol;
        }
        out << std::endl;
    }???
}
int main()
{
    int k;
    std::cin >> k;
    TBoard Board(8, std::vector<char>(8, ' '));
    for(int i = 0; i < k; ++i){
        int r, c;
        std::cin >> r >> c;
        Board = AddQueen(Board, r, c);
    }
    TResult Result = Solve(Board, 8 - k);
    Print(Result.Board, std::cout);
    return 0;
    
}

Compiler output:
a.cc: In function 'void Print(const TBoard&, std::ostream&)':
a.cc:59:6: error: expected primary-expression before '?' token
   59 |     }???
      |      ^
a.cc:59:7: error: expected primary-expression before '?' token
   59 |     }???
      |       ^
a.cc:59:8: error: expected primary-expression before '?' token
   59 |     }???
      |        ^
a.cc:60:1: error: expected primary-expression before '}' token
   60 | }
      | ^
a.cc:59:9: error: expected ':' before '}' token
   59 |     }???
      |         ^
      |         :
   60 | }
      | ~        
a.cc:60:1: error: expected primary-expression before '}' token
   60 | }
      | ^
a.cc:59:9: error: expected ':' before '}' token
   59 |     }???
      |         ^
      |         :
   60 | }
      | ~        
a.cc:60:1: error: expected primary-expression before '}' token
   60 | }
      | ^
a.cc:59:9: error: expected ':' before '}' token
   59 |     }???
      |         ^
      |         :
   60 | }
      | ~        
a.cc:60:1: error: expected primary-expression before '}' token
   60 | }
      | ^
Language: C++

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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N];

void initialize(){
  int i;
  for(i = 0 ; i < N ; i++) {row[i] = FREE, col[i] = FREE;}
  for(i = 0 ; i < 2 * N ; i++) {dpos[i] = FREE, dneg[i]] = FREE;}
}

void printBoard(){
  int i, j;
  for(i = 0 ; i < N ; i++){
    for(j = 0 ; j < N ; j++){
      if(X[i][j]){
        if(row[i] != j) return;
      }
    }
  }
  for(i = 0 ; i < N ; i++){
    for(j = 0 ; j < N ; j++){
      cout << ((row[i] == j) ? "Q" : ".");
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i == N){
    printBoard();
    return;
  }

  for(j = 0 ; j < N ; j++){
    if(NOT_FREE == col[j] || NOT_FREE == dpos[i + j] || NOT_FREE == dneg[i - j + N - 1]) co\
ntinue;
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
    recursive();
    row[i] = col[i] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
}

int main(){
  int i, j;
  initialize();

  for(i = 0 ; i < N ; i++){
    for(j = 0 ; j < N ; j++){
      X[i][j] = false;
    }
  }
  int k;
  cin >> k;

  for(i = 0 ; i < N ; i++){
    int r, c;
    cin >> r >> c;
    X[r][c] = true;
  }

  recursive();

  return 0;
}

Compiler output:
a.cc: In function 'void initialize()':
a.cc:16:56: error: expected ';' before ']' token
   16 |   for(i = 0 ; i < 2 * N ; i++) {dpos[i] = FREE, dneg[i]] = FREE;}
      |                                                        ^
      |                                                        ;
a.cc: In function 'void recursive(int)':
a.cc:48:14: error: too few arguments to function 'void recursive(int)'
   48 |     recursive();
      |     ~~~~~~~~~^~
a.cc:36:6: note: declared here
   36 | void recursive(int i){
      |      ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:71:12: error: too few arguments to function 'void recursive(int)'
   71 |   recursive();
      |   ~~~~~~~~~^~
a.cc:36:6: note: declared here
   36 | void recursive(int i){
      |      ^~~~~~~~~
Language: C++

#include <stdio.h>
#define NOT_FREE 1
#define FREE -1
#define N 8

int r,c,k,i,j;
int col[N],row[N],dneg[2*N-1],dpos[2*N-1];
int p[N][N];

void putqueen(int);
void printboard();

int main(){

  for(i=0;i<N;i++){
    col[i]=FREE;
    row[i]=FREE;
  }
  for(i=0;i<2*N-1;i++){
    dneg[i]=FREE;
    dpos[i]=FREE;
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      p[i][j]=FREE;
    }
  }

  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d %d",&r,&c);
    p[r][c]=1;
  }
  putqueen(0);

  return 0;
}
void putqueen(int i){
  if( i == N ){
    printboard();
    return;
  }

  int j;

  for( j = 0 ; j < N ; j++ ){
    if( NOT_FREE == col[j] || NOT_FREE == dpos[i+j] || NOT_FREE == dneg[i-j+N-1]) continue;

    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;

    recursive(i+1);

    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}
void printboard(){
  int i,j;

  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      if(p[i][j]){
    if(row[i] != j) return;
      }
    }
  }

  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      if(row[i] == j ) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

Compiler output:
a.cc: In function 'void putqueen(int)':
a.cc:52:5: error: 'recursive' was not declared in this scope
   52 |     recursive(i+1);
      |     ^~~~~~~~~
Language: C++

#include <iostream>
#include <string>
using namespace std;
int eight_queen[8];

bool check(int row, int value) {
	int data;
	for (int i = 0; i < 8; i++) {
		if (eight_queen[i] != -1) {
			data = eight_queen[i];
			if (value == data) return false;
			if ((value + row) == (data + i)) return false;
			if ((value - row) == (data - i)) return false;
		}
	}
	return true;
}

void solution(int row) {
	if (row > 7 && (eight_queen[7]!= -1)) 
		return;
	if (eight_queen[row] != -1 ) solution(row + 1);
	else {
		for (int index = 0; index < 8; index++) {
			if (check(row, index)) {
				eight_queen[row] = index;
				solution(row + 1);
			}
		}
	}
}

void print() {
	for (int j = 0; j < 8; j++) {
		for (int i = 0; i < 8; i++) {
			if (i == eight_queen[j])
				cout << "Q";
			else
				cout << ".";
		}
		cout << endl;
	}
}

int main() {
	int n;
	cin >> n;
	int row, index;
	memset(eight_queen, -1, sizeof(eight_queen));
	for (int i = 0; i < n; i++) {
		cin >> row >> index;
		eight_queen[row] = index;
	}
	solution(0);
	print();
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:9: error: 'memset' was not declared in this scope
   49 |         memset(eight_queen, -1, sizeof(eight_queen));
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <string>
Language: C++

// ALDS1_13_A.cpp
// Heuristic Search - 8 Queens Problem
#include <iostream>
#include <vector>
#include <stack>
#include <csdtio>
using namespace std;
const int N = 8;
vector<int> row(N);
vector<int> col(N);
vector<int> md(2*N - 1); // main diagonal
vector<int> ad(2*N - 1); // anti-diagnoal
vector<int> res(N);
//vector<int> flag(N);
int main()
{
    int k;
    cin >> k;
    int r, c;
    for (int i = 0; i < k; i++) {
        cin >> r >> c;
        row[r] = 1;
        col[c] = 1;
        md[r+c] = 1;
        ad[c-r+N-1] = 1;
        res[r] = c;
    }
    stack<pair<int, int> > ms;
    bool found = true;
    r = 0;
    c = 0;
    while (r < N) {
        if (row[r]) r++;
        if (c < N) {
            if (col[c] || md[r+c] || ad[c-r+N-1]) {
                c++;
            }
            else {
                ms.push({r, c});
                res[r] = c;
                col[c] = 1;
                md[r+c] = 1;
                ad[c-r+N-1] = 1;
                r++;
                c = 0;
            }
        }
        else {
            if (ms.empty()) {
                found = false;
                break;
            }
            r = ms.top().first;
            c = ms.top().second;
            ms.pop();
            col[c] = 0;
            md[r+c] = 0;
            ad[c-r+N-1] = 0;
            c++;
        }

    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (res[i] == j) printf("Q");
            else printf(".");
        }
        printf("\n");
    }

    return 0;
}

Compiler output:
a.cc:6:10: fatal error: csdtio: No such file or directory
    6 | #include <csdtio>
      |          ^~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
   
using namespace std;

#define number 8

int a[number][number] = {{}};
int row[number] = {};
int l[15] = {};
int r[15] = {};
int s[number] = {};


int main(){
   
  int r,c,k;
   
  cin >> k;
   
  for(int i = 0;i < k;i++){
    cin >> r >> c;
    a[r][c] = 1;
  }
  backtrack(0);
}
   
void print(){
   
  for(int i = 0;i < number;i++){
    for(int j = 0;j < number;j++){
      if(a[i][j] == 1){
        if(row[i] != j) {
          return;
        }
      }
    }
  }
  for(int i = 0;i < number;i++){
    for(int j = 0;j < number;j++){
      if(row[i] == j) {
          cout << "Q";
      }
      else cout << ".";
    }
    cout << endl;
  }
   
}
   
void solve(int i){
  if(i == number){
    print();
    return;
  }
   

  for(int j = 0;j < number;j++){
    if(s[j] == 1 || l[i + j] == 1 || r[i - j + 7] == 1) continue;
   
    row[i] = j;
    l[i + j] = r[i - j + 7] = s[j] = 1;
   
    solve(i + 1);
   
    row[i] = s[j] = l[i + j] = r[i - j + 7] = 0;
   
  }
   
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:3: error: 'backtrack' was not declared in this scope
   24 |   backtrack(0);
      |   ^~~~~~~~~
Language: C++


#include<iostream>

using namespace std;

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1]

bool X[N][N]

void initialize() {
  for (int i = 0; i < N; i++) {
    row[i] = FREE;
    col[i] = FREE;
  }
  for (int i = 0; i < 2 * N - 1; i++) {
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}

void printBoard() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (X[i][j]) {
        if (row[i] != j) {
          return;
        }
      }
    }
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cout << ((row[i] == j) ? "Q" : ".");
    }
    cout << endl;
  }
}

void recursive(int i) {
  if (i == N) {
    printBoard();
    return;
  }

  for (int j = 0; j < N; j++) {
    if (col[j] == NOT_FREE ||
        dpos[i + j] == NOT_FREE ||
        dneg[i - j + N - 1]) {
      continue
    }
    row[i] = j; col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
    recursive(i + 1);
    row[i] = j; col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
}

int main(){
  initialize();

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      X[i][j] = false;
    }
  }

  int k; cin >> k;
  for (int i = 0; i < k; i++) {
    int r, c; cin >> r >> c;
    X[r][c] = true;
  }

  recursive(0);

  return 0;
}


Compiler output:
a.cc:12:1: error: expected initializer before 'bool'
   12 | bool X[N][N]
      | ^~~~
a.cc: In function 'void printBoard()':
a.cc:28:11: error: 'X' was not declared in this scope
   28 |       if (X[i][j]) {
      |           ^
a.cc: In function 'void recursive(int)':
a.cc:53:9: error: 'dneg' was not declared in this scope
   53 |         dneg[i - j + N - 1]) {
      |         ^~~~
a.cc:54:15: error: expected ';' before '}' token
   54 |       continue
      |               ^
      |               ;
   55 |     }
      |     ~          
a.cc:56:40: error: 'dneg' was not declared in this scope
   56 |     row[i] = j; col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
      |                                        ^~~~
a.cc: In function 'int main()':
a.cc:63:3: error: 'initialize' was not declared in this scope
   63 |   initialize();
      |   ^~~~~~~~~~
a.cc:67:7: error: 'X' was not declared in this scope
   67 |       X[i][j] = false;
      |       ^
a.cc:74:5: error: 'X' was not declared in this scope
   74 |     X[r][c] = true;
      |     ^
Language: C++


#include<iostream>

using namespace std;

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N]

void initialize() {
  for (int i = 0; i < N; i++) {
    row[i] = FREE;
    col[i] = FREE;
  }
  for (int i = 0; i < 2 * N - 1; i++) {
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}

void printBoard() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (X[i][j]) {
        if (row[i] != j) {
          return;
        }
      }
    }
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cout << ((row[i] == j) ? "Q" : ".");
    }
    cout << endl;
  }
}

void recursive(int i) {
  if (i == N) {
    printBoard();
    return;
  }

  for (int j = 0; j < N; j++) {
    if (col[j] == NOT_FREE ||
        dpos[i + j] == NOT_FREE ||
        dneg[i - j + N - 1]) {
      continue
    }
    row[i] = j; col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
    recursive(i + 1);
    row[i] = j; col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
}

int main(){
  initialize();

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      X[i][j] = false;
    }
  }

  int k; cin >> k;
  for (int i = 0; i < k; i++) {
    int r, c; cin >> r >> c;
    X[r][c] = true;
  }

  recursive(0);

  return 0;
}


Compiler output:
a.cc:14:1: error: expected initializer before 'void'
   14 | void initialize() {
      | ^~~~
a.cc: In function 'void printBoard()':
a.cc:28:11: error: 'X' was not declared in this scope
   28 |       if (X[i][j]) {
      |           ^
a.cc: In function 'void recursive(int)':
a.cc:54:15: error: expected ';' before '}' token
   54 |       continue
      |               ^
      |               ;
   55 |     }
      |     ~          
a.cc: In function 'int main()':
a.cc:63:3: error: 'initialize' was not declared in this scope
   63 |   initialize();
      |   ^~~~~~~~~~
a.cc:67:7: error: 'X' was not declared in this scope
   67 |       X[i][j] = false;
      |       ^
a.cc:74:5: error: 'X' was not declared in this scope
   74 |     X[r][c] = true;
      |     ^
Language: C++


#include<iostream>

using namespace std;

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N];

void initialize() {
  for (int i = 0; i < N; i++) {
    row[i] = FREE;
    col[i] = FREE;
  }
  for (int i = 0; i < 2 * N - 1; i++) {
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}

void printBoard() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (X[i][j]) {
        if (row[i] != j) {
          return;
        }
      }
    }
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cout << ((row[i] == j) ? "Q" : ".");
    }
    cout << endl;
  }
}

void recursive(int i) {
  if (i == N) {
    printBoard();
    return;
  }

  for (int j = 0; j < N; j++) {
    if (col[j] == NOT_FREE ||
        dpos[i + j] == NOT_FREE ||
        dneg[i - j + N - 1]) {
      continue
    }
    row[i] = j; col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
    recursive(i + 1);
    row[i] = j; col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
}

int main(){
  initialize();

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      X[i][j] = false;
    }
  }

  int k; cin >> k;
  for (int i = 0; i < k; i++) {
    int r, c; cin >> r >> c;
    X[r][c] = true;
  }

  recursive(0);

  return 0;
}



Compiler output:
a.cc: In function 'void recursive(int)':
a.cc:54:15: error: expected ';' before '}' token
   54 |       continue
      |               ^
      |               ;
   55 |     }
      |     ~
Language: Java

import sys;
import heapq

def iterative(i,j):
    q = []
    heapq.heappush(q,(0,i,j,puz))
    global finding

    while len(q):
        items = heapq.heappop(q)
        c_depth = items[0]
        _i = items[1]
        _j = items[2]
        c_puz = items[3]
        if(puzzleCheck(c_puz)):
            finding = 1
            print(c_depth)
            break

        if((c_depth+simpleHS(c_puz)) > depth):
            continue

        if(_i != 0):
            heapq.heappush(q,(c_depth+1,_i-1,_j,swapPuz(c_puz[0:],_i,_j,_i-1,_j)))
        if(_i != 2):
            heapq.heappush(q,(c_depth+1,_i+1,_j,swapPuz(c_puz[0:],_i,_j,_i+1,_j)))
        if(_j != 0):
            heapq.heappush(q,(c_depth+1,_i,_j-1,swapPuz(c_puz[0:],_i,_j,_i,_j-1)))
        if(_j != 2):
            heapq.heappush(q,(c_depth+1,_i,_j+1,swapPuz(c_puz[0:],_i,_j,_i,_j+1)))

def simpleHS(c_puz):
    count = 0
    for i in range(len(correctPuz)):
        if(correctPuz[i] != c_puz[i]):
            count+=1
    return count

def HS(c_puz):
    value = 0
    for i in range(len(c_puz)):
        k = correctPuz.index(c_puz[i])
        _i = (int)(i/3)
        _j = i - _i
        ki = (int)(k/3)
        kj = k - ki
        value = abs(_i-ki)+abs(_j-kj) 

    return value


def swapPuz(c_puz, i, j, i2,j2):
    swap = c_puz[i*3+j]
    c_puz[i*3+j] = c_puz[i2*3+j2]
    c_puz[i2*3+j2] = swap
    return c_puz

def puzzleCheck(c_puz):
    if(c_puz[8] == 0):
        for i in range(len(correctPuz)):
            if(correctPuz[i] != c_puz[i]):
                return False
        return True
    return False

correctPuz = [i+1 for i in range(9)]
correctPuz[8] = 0
puz = [0 for i in range(9)]

i_start = 0
j_start = 0

for i in range(3):
    puz[i*3],puz[i*3+1],puz[i*3+2] = map(int, input().split());
    if(puz[i*3] == 0):
        i_start,j_start = i,0
    elif(puz[i*3+1] == 0):
        i_start,j_start = i,1
    elif(puz[i*3+2] == 0):
        i_start,j_start = i,2

finding = 0
depth = 0
while True:
    if(finding == 1):
        break
    iterative(i_start,j_start)
    depth+=1





Compiler output:
Main.java:1: error: '.' expected
import sys;
          ^
Main.java:2: error: '.' expected
import heapq
            ^
Main.java:4: error: ';' expected
def iterative(i,j):
   ^
Main.java:75: error: class, interface, enum, or record expected
    if(puz[i*3] == 0):
    ^
4 errors
Language: C

#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){

  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;

  for(i=0; i<n1; i++){
    L[i] = A[left+1];
  }
  for(i=0; i<n2; i++){
    R[i] = A[mid+i];
  }

  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;

  for(k=left; k<right; k++){
    if(L[i].value <= R[j].value){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
  }

}

void mergeSort(struct Card A[], int n, int left, int right){

  int mid;

  if(left+1 < right){
    mid = (left+right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }

}

int partition(struct Card A[], int n, int p, int r){

  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;

  for(j=p; j<r; j++){
    if(A[j].value <= x.value){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }

  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;

}
}

t = A[i+1];
A[i+1] = A[r];
A[r] = t;
  return i+1;

}

void quickSort(struct Card A[], int n, int p, int r){

  int q;

  if(p<r){
    q = partition(A, n , p, r);
    quickSort(A, n, p, q-1);
    quickSort(A, n, q+1, r);
  }

}

int main(){

  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable=1;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);

  for(i=0; i<n; i++){
    if(A[i].suit != B[i].suit){
      stable = 0;
    }
  }

 if(stable==1){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }

  for(i=0; i<n; i++){
    printf("%c %d\n", B[i].suit, B[i].value);
  }

  return 0;
}

Compiler output:
main.c:73:1: error: expected identifier or '(' before '}' token
   73 | }
      | ^
main.c:75:1: warning: data definition has no type or storage class
   75 | t = A[i+1];
      | ^
main.c:75:1: error: type defaults to 'int' in declaration of 't' [-Wimplicit-int]
main.c:75:5: error: 'A' undeclared here (not in a function)
   75 | t = A[i+1];
      |     ^
main.c:75:7: error: 'i' undeclared here (not in a function)
   75 | t = A[i+1];
      |       ^
main.c:76:1: warning: data definition has no type or storage class
   76 | A[i+1] = A[r];
      | ^
main.c:76:1: error: type defaults to 'int' in declaration of 'A' [-Wimplicit-int]
main.c:76:12: error: 'r' undeclared here (not in a function)
   76 | A[i+1] = A[r];
      |            ^
main.c:77:1: warning: data definition has no type or storage class
   77 | A[r] = t;
      | ^
main.c:77:1: error: type defaults to 'int' in declaration of 'A' [-Wimplicit-int]
main.c:78:3: error: expected identifier or '(' before 'return'
   78 |   return i+1;
      |   ^~~~~~
main.c:80:1: error: expected identifier or '(' before '}' token
   80 | }
      | ^
Language: C

#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9
 
struct Puzzle{
  int i,f[N2];
  int space;
  string path;
 
  bool operator < (const Puzzle &p) const{

    for(i = 0;i < N2;i ++)
      {
	if(f[i] == p.f[i]) continue;
	return f[i] > p.f[i];
      }
    return false;
  }
};
 
static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};
 
 
int main(){

  Puzzle in;

  int i;

  string ans;
  
  for(i = 0;i < N2;i ++)
    {
      cin >> in.f[i];
      if(in.f[i] == 0)
	{
	  in.f[i] = N2;
	  in.space = i;
	}
    }
  ans = bfs(in);

  cout << ans.size() << endl;
 
  return 0;
}

bool isTarget(Puzzle p){

  int i;
  
  for(i = 0;i < N2;i ++)
    {
      if(p.f[i] != (i + 1)) return false;
    }
  
  return true;
}
 
string bfs(Puzzle s){

  int sx,sy,tx,ty,r;
  
  queue<Puzzle> Q;

  map<Puzzle, bool> V;

  Puzzle u, v;

  s.path = "";

  Q.push(s);

  V[s] = true;
 
  while(!Q.empty()){

    u = Q.front();

    Q.pop();

    if(isTarget(u))return u.path;

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

    for(r = 0;r < 4;r ++)
      {
	tx = sx + dx[r];
	ty = sy + dy[r];

	if(tx < 0 || ty < 0 || tx >= N || ty >= N)continue;
       
	v = u;
      
	swap(v.f[u.space], v.f[tx * N + ty]);
      
	v.space = tx * N + ty;
      
	if(!V[v]){
	  V[v] = true;
	  v.path += dir[r];
	  Q.push(v);
	}
      }
  }
 
  return "unsolvable";
}

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

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

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

void empty(int *,int *);
int dfs(int,int,int,int,const int);
int cal();
void swap(int *,int *);

int main() {
    int i,j,a,x,y,l;
    for(i=0; i<3; i++) {
        for(j=0; j<3; j++) scanf("%d",&puzzle[i][j]);
    }

    empty(&x,&y);
    for(l=0; l<100; l++) {
        for(i=0; i<3; i++) {
            for(j=0; j<3; j++) tmp[i][j] = puzzle[i][j];
        }

        ans = dfs(x,y,-1,0,l);
        if(a!=-1) {
            printf("%d\n",a);
            break;
        }

        for(i=0 ; i<3 ; i++) {
            for(j=0 ; j<3 ; j++) puzzle[i][j] = tmp[i][j];
        }
        a = -1;
        if(l==99) printf("%d\n",a);
    } 
    return 0;
}

void empty(int *x,int *y) {
    int i,j;
    for(i=0; i<3; i++) {
        for(j=0; j<3; j++) {
            if(!puzzle[i][j]) {
                *x = j;
                *y = i;
                return;
            }
        }
    }
}

void swap(int *a,int *b) {
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int cal() {
    int i,a,sum=0;
    for(i=0; i<9; i++) {
        a = puzzle[i/3][i%3];
        if(a) {
            a--;
            sum += abs(i/3 - a/3) + abs(i%3 - a%3);
        }
    }
    return sum;
}

int dfs(int x,int y,int p,int dep,const int lim) {
    int i,h,nx,ny,res;

    h = cal();
    if(h==0) return dep;
    if(dep+h>lim) return -1;

    for(i=0; i<4; i++) {
        nx = x+dx[i];
        ny = y+dy[i];
 
        if(~p && i==(p+2)%4) continue;
        if(!(0<=nx && nx<3 && 0<=ny && ny<3)) continue;
 
        swap(&puzzle[y][x],&puzzle[ny][nx]);
        res = dfs(nx,ny,i,dep+1,lim);
        if(~res) return res;
 
        swap(&puzzle[y][x],&puzzle[ny][nx]);
    }

    return -1;
}

Compiler output:
main.c: In function 'main':
main.c:26:9: error: 'ans' undeclared (first use in this function); did you mean 'abs'?
   26 |         ans = dfs(x,y,-1,0,l);
      |         ^~~
      |         abs
main.c:26:9: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
 
using namespace std;
 
#define N 3
#define N2 9
 
struct Puzzle{
    int f[N2];
    int space;
    string path;
     
    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;
    }
};
 
static const int dx[4]={-1,0,1,0};
 
static const int dy[4]={0,-1,0,1};
 
static const char dir[4]={'u','a','d','r'};
 
bool isTarget(Puzzle p){
    for(int i=0;i<N2;i++){
        if(p.f[i]!=(i+1)) return false;
    }
    return true;
}
 
 
string bfs(Puzzle s){
    queue<Puzzle> Q;
    map<Puzzle,bool> V;
    Puzzle u,v;
    s.path="";
    Q.push(s);
    V[s]=true;
     
    while(!Q.empty()){
        u=Q.front();Q.pop();
        if(isTarget(u)) return u.path;
        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;
            swap(v.f[u.space],v.f[tx*N+ty]);
            v.space=tx*N+ty;
            if(!V[v]){
                V[v]=true;
                v.path+=dir[r];
                Q.push(v);
            }
        }
    }
     
    return "unsolvable";
}
 
 
int main(){
    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 = bfs(in);
     
    cout<<ans.size()<<endl;
}

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

#include <stdio.h>
#include <stdlib.h>
??
int puz[3][3];
int tmp[3][3];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
??
void empty(int *x,int *y) {
????int i,j;
????for(i=0;i<3;i++){
????????for(j=0;j<3;j++){
????????????if(!puz[i][j]){
????????????????*x=j;
????????????????*y=i;
????????????????return;
????????????}
????????}
????}
}
??
void swap(int *a, int *b) {
????int tmp;
????tmp= *a;
????*a= *b;
????*b=tmp;
}
??
int cal() {
????int i,a;
????int sum=0;
????for(i=0;i<9;i ++){
????????a=puz[i/3][i%3];
????????if(a){
????????????a--;
????????????sum+=abs(i/3-a/3)+abs(i%3-a%3);
????????}
????}
????return sum;
}
??
int dfs(int x, int y, int p, int dep, const int lim) {
????int i,h,nx,ny,res;
????h=cal();
????if(h==0){
????????return dep;
????}
????if(dep+h>lim){
????????return -1;
????}
????for(i=0;i<4;i++){
????????nx=x+dx[i];
????????ny=y+dy[i];
????????if(~p&&i==(p+2)%4) continue;
????????if(!(0<=nx&&nx<3&&0<=ny&&ny<3)) continue;
????????swap(&puz[y][x],&puz[ny][nx]);
????????res=dfs(nx,ny,i,dep+1,lim);
????????if(~res){
????????????return res;
????????}
????????swap(&puz[y][x],&puz[ny][nx]);
????????}
????return -1;
}
??
int main() {
????int i,j,ans,x,y,l;
????for(i=0;i<3;i++){
????????for(j=0;j<3;j++){
????????????scanf("%d",&puz[i][j]);
????????}
????}
????empty(&x,&y);
????for(l=0;l<100;l++){
????????for(i=0;i<3;i++){
????????????for(j =0;j<3;j++){
????????????????tmp[i][j] = puz[i][j];
????????????}
????????}
????????ans=dfs(x,y,-1,0,l);
????????if(ans!=-1){
????????????printf("%d\n",ans);
????????????break;
????????}
????????for(i=0;i<3;i++){
????????????for(j=0;j<3;j++){
????????????????puz[i][j]=tmp[i][j];
????????????}
????????}
????????ans= -1;
????????if(l==99){
????????????printf("%d\n",ans);
????????}
????}
????return 0;
}

Compiler output:
main.c:3:1: error: expected identifier or '(' before '?' token
    3 | ??
      | ^
main.c:8:1: error: expected identifier or '(' before '?' token
    8 | ??
      | ^
main.c:21:1: error: expected identifier or '(' before '?' token
   21 | ??
      | ^
main.c:28:1: error: expected identifier or '(' before '?' token
   28 | ??
      | ^
main.c:41:1: error: expected identifier or '(' before '?' token
   41 | ??
      | ^
main.c:65:1: error: expected identifier or '(' before '?' token
   65 | ??
      | ^
Language: C

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)
??
int H, A[MAX+1];
??
void swap(int *a, int *b) {
????????int t;
????????t = *a;
????????*a = *b;
????????*b = t;
}
??
void maxHeapify(int i) {
????????int largest;
????????int l = 2 * i;
????????int r = 2 * i + 1;
????????if (l <= H && A[l] > A[i]) largest = l;
????????else largest = i;
????????if (r <= H && A[r] > A[largest]) largest = r;
????
????????if (largest != i) {
????????????????swap(&A[i], &A[largest]);
????????????????maxHeapify(largest);
????????}
}
??
int extract() {
????????int maxv;
????????if ( H < 1 ) return -INFTY;
????????maxv = A[1];
????????A[1] = A[H--];
????????maxHeapify(1);
????????return maxv;
}
??
void increaseKey(int i, int key) {
????????if(key < A[i]) return;
????????A[i] = key;
????????while(i > 1 && A[i / 2] < A[i]) {
????????????????swap(&A[i], &A[i / 2]);
????????????????i = i / 2;
????????}
}
??
void insert(int key) {
????????H++;
????????A[H] = -INFTY;
????????increaseKey(H, key);
}
??
int main() {
????????int key;
????????char com[10];
??
????????while(1) {
????????????????scanf("%s", com);
????????????????if(com[0] == 'e' && com[1] == 'n') break;
????????????????if(com[0] == 'i') {
????????????????????????scanf("%d", &key);
????????????????????????insert(key);
????????????????}else {
????????????????????????printf("%d\n", extract());
????????????????}
????????}
??
????????return 0;
}

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

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

int mas[3][3];
int cpy[3][3];
????
void input() {
????int i, j;
????for(i = 0; i < 3; i++)
????????for(j = 0; j < 3; j++)
????????????scanf("%d", &mas[i][j]);
}
????
void output() {
????int i, j;
????for(i = 0; i < 3; i++) {
????????for(j = 0; j < 3; j++) printf("%3d", mas[i][j]);
????????puts("");
????}
}
????
void copy(int m[3][3], int t[3][3]) {
????int i, j;
????
????for(i = 0; i < 3; i++)
????????for(j = 0; j < 3; j++) m[i][j] = t[i][j];
}
????
int calc() {
????int i, sum = 0;
????for(i = 0; i < 9; i++) {
????????int v = mas[i/3][i%3];
????????if(v) {
????????????v--;
????????????sum += abs(i/3-v/3)+abs(i%3-v%3);
????????}
????}
????return sum;
}
????
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
????
void swap(int *a, int *b) {
????int tmp = *a;
????*a = *b;
????*b = tmp;
}
????
int is_in(int x, int y) {
????return 0<=x&&x<3&&0<=y&&y<3;
}
????
int dfs(int x, int y, int p, int dep, const int lim) {
????int i, h = calc();
????//output();
????if(h == 0) return dep;
????//printf("%d %d %d\n", h, lim, p);
????if(dep+h > lim) return -1;
????
????for(i = 0; i < 4; i++) {
????????int nx = x+dx[i], ny = y+dy[i], res;
????????if(~p && i == (p+2)%4) continue;
????????if(!is_in(nx, ny)) continue;
????????swap(&mas[y][x], &mas[ny][nx]);
????????res = dfs(nx, ny, i, dep+1, lim);
????????if(~res) return res;
????????swap(&mas[y][x], &mas[ny][nx]);
????}
????
????return -1;
}
????
void get_empty(int *x, int *y) {
????int i, j;
????for(i = 0; i < 3; i++) {
????????for(j = 0; j < 3; j++) {
????????????if(!mas[i][j]) {
????????*x = j;
????????*y = i;
????????return;
????????????}
????????}
????}
}
????
int solve() {
????int x, y, lim, ans;
????get_empty(&x, &y);
????for(lim = 0; lim < 50; lim++) {
????????copy(cpy, mas);
????????if((ans = dfs(x, y, -1, 0, lim)) != -1) return ans;
????????copy(mas, cpy);
????}
????return -1;
}
????
int main() {
????input();
????printf("%d\n", solve());
????return 0;
}

Compiler output:
main.c:6:1: error: expected identifier or '(' before '?' token
    6 | ????
      | ^
main.c:13:1: error: expected identifier or '(' before '?' token
   13 | ????
      | ^
main.c:21:1: error: expected identifier or '(' before '?' token
   21 | ????
      | ^
main.c:28:1: error: expected identifier or '(' before '?' token
   28 | ????
      | ^
main.c:40:1: error: expected identifier or '(' before '?' token
   40 | ????
      | ^
main.c:43:1: error: expected identifier or '(' before '?' token
   43 | ????
      | ^
main.c:49:1: error: expected identifier or '(' before '?' token
   49 | ????
      | ^
main.c:53:1: error: expected identifier or '(' before '?' token
   53 | ????
      | ^
main.c:56:3: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
   56 | ????//output();
main.c:58:3: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
   58 | ????//printf("%d %d %d\n", h, lim, p);
main.c:73:1: error: expected identifier or '(' before '?' token
   73 | ????
      | ^
main.c:86:1: error: expected identifier or '(' before '?' token
   86 | ????
      | ^
main.c:97:1: error: expected identifier or '(' before '?' token
   97 | ????
      | ^
Language: C

#include<stdio.h>
#include<string.h>
#include<queue>
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int c[4][2]={1,0,0,1,-1,0,0,-1};
int puzzle[10];

map<string,int> book;
struct yun
{
    int s;
    int state[9];
};

int bfs()
{
    int i,j,k,l;
    yun st,en;
    queue<yun> Q;
    st.s=0;
    for(i=0;i<9;i++)
        st.state[i]=puzzle[i];
    Q.push(st);
    while(Q.size())
    {
        st=Q.front();
        Q.pop();
        for(k=0;k<9;k++)
            if(!st.state[k])break;
        int x=k/3,y=k%3;
        for(j=0;j<4;j++)
        {
            int dx=x+c[j][0];
            int dy=y+c[j][1];
            int dz=dx*3+dy;
            if(dx<0||dy<0||dx>=3||dy>=3)continue;
            string ss="";
            for(l=0;l<9;l++)
                en.state[l]=st.state[l];
            en.state[k]=en.state[dz];
            en.state[dz]=0;
            int f=0;
            for(l=0;l<8;l++)
            {
                ss+=en.state[l]+'0';
                if(en.state[l]!=l+1)
                    f=1;
            }
          //  cout<<ss<<endl;
            if(!f)return st.s+1;
            if(book[ss])continue;
            book[ss]=1;
            en.s=st.s+1;
            Q.push(en);
        }
    }
}

int main()
{
    int i;
    for(i=0;i<9;i++)
        scanf("%d",&puzzle[i]);
    int g=0;
    for(i=0;i<8;i++)
    {
        if(puzzle[i]!=i+1)
            g=1;
    }
    int max1;
    if(!g)
        max1=0;
    else max1=bfs();
    printf("%d\n",max1);
}



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

int main() {
  int i, x, y;
  current = 0;

  for (i = 0; i < 9; i++) {
    scanf("%d", &board[i]);
    if (!board[i])
      zeroIndex = i;
  }

  x = cols - (zeroIndex / rows) - 1;
  y = rows - (zeroIndex % cols) - 1;

  while (current < 50) {
    if (blindSearch(x, y, current, -1)) {
      printf("%d\n", current);
      break;
    }
    current++;
  }
}



Compiler output:
main.c: In function 'main':
main.c:3:3: error: 'current' undeclared (first use in this function)
    3 |   current = 0;
      |   ^~~~~~~
main.c:3:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:6:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    6 |     scanf("%d", &board[i]);
      |     ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int main() {
main.c:6:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    6 |     scanf("%d", &board[i]);
      |     ^~~~~
main.c:6:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:6:18: error: 'board' undeclared (first use in this function)
    6 |     scanf("%d", &board[i]);
      |                  ^~~~~
main.c:8:7: error: 'zeroIndex' undeclared (first use in this function)
    8 |       zeroIndex = i;
      |       ^~~~~~~~~
main.c:11:7: error: 'cols' undeclared (first use in this function)
   11 |   x = cols - (zeroIndex / rows) - 1;
      |       ^~~~
main.c:11:27: error: 'rows' undeclared (first use in this function)
   11 |   x = cols - (zeroIndex / rows) - 1;
      |                           ^~~~
main.c:15:9: error: implicit declaration of function 'blindSearch' [-Wimplicit-function-declaration]
   15 |     if (blindSearch(x, y, current, -1)) {
      |         ^~~~~~~~~~~
main.c:16:7: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   16 |       printf("%d\n", current);
      |       ^~~~~~
main.c:16:7: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:16:7: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:16:7: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;
const int Max = 3;
int a[4][2]= {0,-1,1,0,0,1,-1,0};
int last[9][2]= {{2,2},{0,0},{0,1},{0,2},{1,0},{1,1},{1,2},{2,0},{2,1}}; // 目标状态的数字所在位置
int k[Max][Max],k2[Max*Max],flag=0,limit,Mi;   // k用来保存八数码状态，k2用来计算曼巴顿距离
int add(int k[Max][Max])       // 曼哈顿距离为 所有的数字要走到目标状态，最少要和0换的次数；
{
    int i,j;
    int sum = 0;
    for(i=0; i<3; i++)
        for(j=0; j<3; j++)
        {
            if(k[i][j]!=0)     //判断曼哈顿距离不能判断0；
                sum += abs(i-last[k[i][j]][0])+abs(j - last[k[i][j]][1]);  //求曼哈顿距离
        }
    return sum;
}
void dfs(int y,int x,int len,int f)     // x,y当前0的坐标 len 为已经走了几步了，f为当上一次的搜索方向
{
    int s = add(k);                     // 求当前状态的曼哈顿距离
    if(flag) return;                    // 如果找到符合的结果，不在搜索
    if(len<=limit)
    {
        if(s==0)                        //曼哈顿距离为零，为目标状态
        {
            flag=1;
            Mi=len;
            return ;
        }
        if(len==limit) return;          //递归到了本轮终点，结束
    }
    for(int i=0; i<4; i++)
    {
        int tx = x + a[i][0];
        int ty = y + a[i][1];
        if(tx>=0&&ty>=0&&ty<3&&tx<3&&((f==-1)||i!=(f+2)%4))
        {
            swap(k[y][x],k[ty][tx]);    // 让下一个数与 0 交换位置
            if(len+add(k)<=limit)       // IDA* 值减少，当前走的步数 加上 当前状态到达标状态的最小步数，
            {
                // 要小于等于当前枚举到的最小的 从起始状态到达目标状态的步数，不能超过；
                dfs(ty,tx,len+1,i);
                if(flag) return ;
            }
            swap(k[y][x],k[ty][tx]);    //还原
        }
    }
}
int main()
{
    int i,j;
    while(~scanf("%d",&k2[0]))
    {
        int y,x;
        k[0][0] = k2[0];
        if(k2[0]==0)    //记录 0 所在的位置
        {
            y = 0;
            x = 0;
        }
        for(i=1; i<Max*Max; i++)
        {
            scanf("%d",&k2[i]);
            k[i/3][i%3] = k2[i];//把输入的数存到二维数组
            if(k2[i]==0)        //记录 0 所在的位置
            {
                y = i/3;
                x = i%3;
            }
        }
        flag = 0;
        limit = add(k);        // 当前要达到目标状态的最小步数；
        while(!flag&&limit<=36)
        {
            dfs(y,x,0,-1);
            if(!flag)          //如果本轮没有满足的条件，扩大搜索范围
                limit ++;      // 深搜底线 +1
        }
        if(flag)
            printf("%d\n",Mi);
    }
    return 0;
}



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

#include<stdio.h>
#include<string.h>
#include<queue>
#include<map>
using namespace std;
int str[5][5];
struct edge
{
    int x,y,n;
    int s[5][5];
};
void bfs(int x,int y)
{
    int i,j,k=0,next[4][2]={0,1,1,0,0,-1,-1,0};    //四个方向
    long long l=0;                                  //初始化为0
    queue<edge>Q;
    map<int,int>book;                               //使用map容器可以放置很大的数
    while(!Q.empty())
        Q.pop();
    edge q,now;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            l=l*10+str[i][j];
            q.s[i][j]=str[i][j];                    //计算l的值 并将当前元素存入q.s[i][j]
        }  
    }
    if(l==123456780){printf("0\n");return;}
    book[l]=1;
    q.x=x;                                           //记录0的横纵坐标
    q.y=y;
    q.n=0;
    Q.push(q);                                       //放入对尾
    while(!Q.empty())
    {
        now=Q.front();
        Q.pop();
        for(i=0;i<4;i++)
        {
            int xx=now.x+next[i][0];                   //开始四个方向便利
            int yy=now.y+next[i][1];
            if(xx<0||yy<0||xx>=3||yy>=3)continue;
            q.x=xx;
            q.y=yy;
            q.n=now.n+1;
            for(k=0;k<3;k++)                           //步数加一
            {
                for(j=0;j<3;j++)
                {
                    q.s[k][j]=now.s[k][j];               //将此时元素的状态存入q.s[][]中
                }
            }
            k=q.s[now.x][now.y];
            q.s[now.x][now.y]=q.s[xx][yy];
            q.s[xx][yy]=k;                               //将此时0的位置放入q.[now.x][now,y]
            l=0;
            for(k=0;k<3;k++)
            {
                for(j=0;j<3;j++)
                {
                    l=l*10+q.s[k][j];
                }
            }
            if(l==123456780){printf("%d\n",q.n);return;}
            if(book[l]==0)
            {
                book[l]=1;
                Q.push(q);                             //如果没被标记 将其放入队列尾
            }       
        }
    }
}
int main()
{
    int i,j,a,ex,ey;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            scanf("%d",&a);
            str[i][j]=a;
            if(a==0)
            {
                ex=i;
                ey=j;
            }
        }
    }
    bfs(ex,ey);
}



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

#include <bits/stdc++.h>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
const int answer[9] = {1, 2, 3, 4, 5, 6, 7, 8, 0};
const bool dir[9][4] = {{false, false, true, true},
                        {true, false, true, true},
                        {true, false, true, false},
                        {false, true, true, true},
                        {true, true, true, true},
                        {true, true, true, false},
                        {false, true, false, true},
                        {true, true, false, true},
                        {true, true, false, false}}; /* left, up, down, right */
vector<int> original(9, 0);

class board;

priority_queue<board> pq;
vector<int> searched[9];

class board{
public:
    int moves;
    int wrongs;
    int zero_place;
    int cost;
    vector<int> tiles;

    explicit board(vector<int> num, int move){
        wrongs = 0;
        tiles = num;
        REP(i, 9){
            if(num[i] == 0)
                zero_place = i;
            if(num[i] != answer[i])
                wrongs++;
        }
        moves = move;
        cost = wrongs + moves;
    }

    void board_to_int(){
        int k = 0;
        REP(i, 9)
            k += (tiles[i] * pow(10, i));
        for(int i = searched[tiles[0]].size(); i > 0 ; i--)
            if(k == searched[tiles[0]][i-1])
                return;
        pq.push(board(tiles, moves+1));
        searched[tiles[0]].push_back(k);
        return;
    }

    void move() {
        if(dir[zero_place][0]){
            swap(tiles[zero_place], tiles[zero_place-1]);
            board_to_int();
            swap(tiles[zero_place], tiles[zero_place-1]);
        }
        if(dir[zero_place][1]){
            swap(tiles[zero_place], tiles[zero_place-3]);
            board_to_int();
            swap(tiles[zero_place], tiles[zero_place-3]);
        }
        if(dir[zero_place][2]){
            swap(tiles[zero_place], tiles[zero_place+3]);
            board_to_int();
            swap(tiles[zero_place], tiles[zero_place+3]);
        }
        if(dir[zero_place][3]){
            swap(tiles[zero_place], tiles[zero_place+1]);
            board_to_int();
            swap(tiles[zero_place], tiles[zero_place+1]);
        }
    }

    int get_wrongs(){
        return wrongs;
    }
};

bool operator< (board b1, board b2){
    return ((b1.cost > b2.cost) ? true : false;
}

int solve(){
    pq.push(board(original, 0));
    while(1){
        auto target = pq.top();
        pq.pop();
        if(target.wrongs == 0)
            return target.cost;
        target.move();
    }
}

int main() {
    REP(i, 9) cin >> original[i];
    int move = solve();
    cout << move << endl;
    return 0;
}

Compiler output:
a.cc: In function 'bool operator<(board, board)':
a.cc:87:47: error: expected ')' before ';' token
   87 |     return ((b1.cost > b2.cost) ? true : false;
      |            ~                                  ^
      |                                               )
Language: C++

#include <vector>
#include <queue>
#include <map>
#include <cstdio>
using namespace std;
#define X 3
#define Y 3
#define THRESHOLD 2
int manhattan(int x1,int y1,int x2,int y2){
	return abs(x1-x2)+abs(y1-y2);
}
int calc(vector<int>&v){
	int s=0;
	for(int coor=0;coor<X*Y;coor++){
		if(v[coor]!=0){
			s+=manhattan(coor%X,coor/X,(v[coor]-1)%X,(v[coor]-1)/X);
		}else{
			s+=manhattan(coor%X,coor/X,X-1,Y-1);
		}
	}
	return s;
}
int main(){
	int i=1,start_point;
	vector<int>start(X*Y),goal;
	for(;i<X*Y;i++)goal.push_back(i);goal.push_back(0);
	for(i=0;i<X*Y;i++){
		scanf("%d",&start[i]);
		if(start[i]==0)start_point=i;
	}
	if(start==goal){puts("0");return 0;}

	map<vector<int>,pair<int,int> >mstart,mgoal;
	queue<pair<vector<int>,bool> >q;
	mstart[start]=make_pair(start_point,0);
	mgoal[goal]=make_pair(X*Y-1,0);
	q.push(make_pair(start,false));
	q.push(make_pair(goal,true));
	for(;!q.empty();){
		vector<int> v=q.front().first;
		bool f=q.front().second;
		q.pop();
		int val=calc(v);
		map<vector<int>,pair<int,int> >&m=f?mgoal:mstart;
		map<vector<int>,pair<int,int> >&m2=f?mstart:mgoal;
		int coor=m[v].first,x=coor%X,y=coor/X;
		int depth=m[v].second;
		if(0<x){
			swap(v[coor],v[coor-1]);
			if(m.find(v)==m.end() && calc(v)<=val+THRESHOLD)m[v]=make_pair(coor-1,depth+1),q.push(make_pair(v,f));
			if(m2.find(v)!=m2.end()){printf("%d\n",m2[v].second+depth+1);return 0;}
			swap(v[coor],v[coor-1]);
		}
		if(x<X-1){
			swap(v[coor],v[coor+1]);
			if(m.find(v)==m.end() && calc(v)<=val+THRESHOLD)m[v]=make_pair(coor+1,depth+1),q.push(make_pair(v,f));
			if(m2.find(v)!=m2.end()){printf("%d\n",m2[v].second+depth+1);return 0;}
			swap(v[coor],v[coor+1]);
		}
		if(0<y){
			swap(v[coor],v[coor-X]);
			if(m.find(v)==m.end() && calc(v)<=val+THRESHOLD)m[v]=make_pair(coor-X,depth+1),q.push(make_pair(v,f));
			if(m2.find(v)!=m2.end()){printf("%d\n",m2[v].second+depth+1);return 0;}
			swap(v[coor],v[coor-X]);
		}
		if(y<Y-1){
			swap(v[coor],v[coor+X]);
			if(m.find(v)==m.end() && calc(v)<=val+THRESHOLD)m[v]=make_pair(coor+X,depth+1),q.push(make_pair(v,f));
			if(m2.find(v)!=m2.end()){printf("%d\n",m2[v].second+depth+1);return 0;}
			swap(v[coor],v[coor+X]);
		}
	}
}

Compiler output:
a.cc: In function 'int manhattan(int, int, int, int)':
a.cc:10:16: error: 'abs' was not declared in this scope
   10 |         return abs(x1-x2)+abs(y1-y2);
      |                ^~~