Language: Java

#include <iostream>
#include <cstring>
#include <queue>

#define SIZE (8)
#define ANSWER_STATE_CODE (342391)
#define STATE_SIZE (16434824+1-ANSWER_STATE_CODE)

int coefficients[SIZE] = {2097152, 262144, 32768, 4096, 512, 64, 8, 1};


int movablePairs[SIZE][4] = {
    {1,4,-1,-1}, {0,2,5,-1}, {1,3,6,-1}, {2,7,-1,-1},
    {0,5,-1,-1}, {1,4,6,-1}, {2,5,7,-1}, {3,6,-1,-1}
};

bool isVisit[STATE_SIZE];

typedef struct {
    short state[SIZE];
    int depth;
    int movablePiecePoint;
    int stateCode;
} puzzle;

void move(short state[], short nextState[], int point1, int point2)
{
    memcpy(nextState, state, sizeof(short)*SIZE);
    short tmp = nextState[point1];
    nextState[point1] = nextState[point2];
    nextState[point2] = tmp;
    return;
}

int puzzleInit(puzzle *p)
{
    short movablePieceNum = 0;
    int tmpStateCode = -ANSWER_STATE_CODE;
    int tmpMovablePiecePoint = -1;
    for (int i=0; i<SIZE; i++) {
        if(movablePieceNum == (*p).state[i]){
            tmpMovablePiecePoint = i;
        }
        tmpStateCode += coefficients[i]*(int)(*p).state[i];
    }
    (*p).stateCode = tmpStateCode;
    (*p).movablePiecePoint = tmpMovablePiecePoint;
    return 0;
}

int solve(short input[])
{
    std::queue<puzzle> qu;
    for (int i=0; i<STATE_SIZE; i++) {
        isVisit[i] = false;
    }
    
    puzzle init;
    memcpy(init.state, input, sizeof(short)*SIZE);
    init.depth = 0;
    puzzleInit(&init);
    
    qu.push(init);
    while (!qu.empty()) {
        puzzle now = qu.front();
        qu.pop();
        if (0 == now.stateCode) {
            return now.depth;
        }
        
        if (!isVisit[now.stateCode]) {
            for (int i=0; movablePairs[now.movablePiecePoint][i]>=0; i++){
                int nextMove = movablePairs[now.movablePiecePoint][i];
                puzzle nextP;
                move(now.state, nextP.state, now.movablePiecePoint, nextMove);
                nextP.depth = now.depth+1;
                puzzleInit(&nextP);

                qu.push(nextP);
            }
            isVisit[now.stateCode] = true;
        }
    }
    return -1;
}

int main(int argc, const char * argv[])
{
    while (true) {
        short input[SIZE];
        for(int i=0; i<SIZE; i++){
            std::cin >> input[i];
        }
        int count = solve(input);
        std::cout << count<< std::endl;
    }
    
    return 0;
}

Compiler output:
Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <cstring>
^
Main.java:3: error: illegal character: '#'
#include <queue>
^
Main.java:5: error: illegal character: '#'
#define SIZE (8)
^
Main.java:6: error: illegal character: '#'
#define ANSWER_STATE_CODE (342391)
^
Main.java:7: error: illegal character: '#'
#define STATE_SIZE (16434824+1-ANSWER_STATE_CODE)
^
Main.java:12: error: class, interface, enum, or record expected
int movablePairs[SIZE][4] = {
^
Main.java:17: error: class, interface, enum, or record expected
bool isVisit[STATE_SIZE];
^
Main.java:19: error: class, interface, enum, or record expected
typedef struct {
^
Main.java:21: error: unnamed classes are a preview feature and are disabled by default.
    int depth;
    ^
  (use --enable-preview to enable unnamed classes)
Main.java:24: error: class, interface, enum, or record expected
} puzzle;
^
Main.java:28: error: '.class' expected
    memcpy(nextState, state, sizeof(short)*SIZE);
                                         ^
Main.java:35: error: <identifier> expected
int puzzleInit(puzzle *p)
                     ^
Main.java:41: error: illegal start of expression
        if(movablePieceNum == (*p).state[i]){
                               ^
Main.java:44: error: illegal start of expression
        tmpStateCode += coefficients[i]*(int)(*p).state[i];
                                              ^
Main.java:46: error: illegal start of expression
    (*p).stateCode = tmpStateCode;
     ^
Main.java:47: error: illegal start of expression
    (*p).movablePiecePoint = tmpMovablePiecePoint;
     ^
Main.java:53: error: not a statement
    std::queue<puzzle> qu;
                     ^
Main.java:59: error: '.class' expected
    memcpy(init.state, input, sizeof(short)*SIZE);
                                          ^
Main.java:61: error: illegal start of expression
    puzzleInit(&init);
               ^
Main.java:77: error: illegal start of expression
                puzzleInit(&nextP);
                           ^
Main.java:87: error: illegal start of type
int main(int argc, const char * argv[])
                   ^
Main.java:87: error: class, interface, enum, or record expected
int main(int argc, const char * argv[])
                         ^
Main.java:91: error: class, interface, enum, or record expected
        for(int i=0; i<SIZE; i++){
        ^
Main.java:91: error: class, interface, enum, or record expected
        for(int i=0; i<SIZE; i++){
                     ^
Main.java:91: error: class, interface, enum, or record expected
        for(int i=0; i<SIZE; i++){
                             ^
Main.java:93: error: class, interface, enum, or record expected
        }
        ^
Main.java:95: error: class, interface, enum, or record expected
        std::cout << count<< std::endl;
        ^
Main.java:96: error: class, interface, enum, or record expected
    }
    ^
Main.java:99: error: class, interface, enum, or record expected
}
^
30 errors