Language: C++

#include<iostream>
#include<queue>
#include<vector>
#include<list>

using namespace std;

bool checker[8][8][8][8][8][8][8];
list<short[7]> checklist;

class Puzzle{

public:
  short p[2][4];
  short lastorder;//1 ???  3?????? 5 ??????
  short ordernum;

  Puzzle(){
    /*p = new short*[2];
    for(int i=0; i<2; i++){
      p[i] = new short[4];
    }*/
    this->lastorder = 8;
    this->ordernum = 0;
  }

  /*Puzzle(const Puzzle& puzzle){
    p = new short*[2];
    for(int i=0; i<2; i++){
      p[i] = new short[4];
    }
    for(int i=0;i<2;i++){
      for(int j=0;j<4;j++){
        p[i][j] = puzzle.p[i][j];
      }
    }
    this->lastorder = puzzle.lastorder;
    this->ordernum = puzzle.ordernum;
  }*/

  ~Puzzle(){
    /*for(int i=0; i<2; i++){
      delete[] p[i];
    }
    delete[] p;*/
  }

  /*inline bool check(){
    return(checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]]);
  }

  inline void throughpuzzle(){
    checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]] = false;
  }*/

};




int main(){

  for(int a=0;a<8;a++){
    for(int b=0;b<8;b++){
      for(int c=0;c<8;c++){
        for(int d=0;d<8;d++){
          for(int e=0;e<8;e++){
            for(int f=0;f<8;f++){
              for(int g=0;g<8;g++){
                checker[a][b][c][d][e][f][g] = true;
              }
            }
          }
        }
      }
    }
  }



  while(1){

    queue<Puzzle> q;

    Puzzle Start;

    cin >> Start.p[0][0];

    if(cin.eof()){
      break;
    }

    cin >> Start.p[0][1] >> Start.p[0][2] >> Start.p[0][3] >> Start.p[1][0] >> Start.p[1][1] >> Start.p[1][2] >> Start.p[1][3];

    q.push(Start);

    while(!q.empty()){

      Puzzle tmp;
      tmp = q.front();
      q.pop();


      if(tmp.p[0][0] == 0 && tmp.p[0][1] == 1 && tmp.p[0][2] == 2 && tmp.p[0][3] == 3 && tmp.p[1][0] == 4 && tmp.p[1][1] == 5 && tmp.p[1][2] == 6){
          cout << tmp.ordernum << endl;
          while(!q.empty()){
            q.pop();
          }
          break;
      }

      short x,y;

      for(short i=0;i < 2; i++){
        for(short j=0;j < 4; j++){
          if(tmp.p[i][j] == 0){
            x = j;
            y = i;
          }
        }
      }

      tmp.ordernum++;

      short Beforeorder = tmp.lastorder;
      short checktmp[7];

      Puzzle puzzle = tmp;
      short t;

      if(x != 3 && Beforeorder != 3){
        t  = puzzle.p[y][x];
        puzzle.p[y][x] = puzzle.p[y][x+1];
        puzzle.p[y][x+1] = t;

        if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
          puzzle.lastorder = 1;
          q.push(puzzle);
          checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
          for(int i=0;i<7;i++){
            checktmp[i] = puzzle.p[i/4][i%4];
          }
          checklist.push_back(checktmp);
        }
        puzzle = tmp;
      }

      if(x != 0 && Beforeorder != 1){
        t  = puzzle.p[y][x];
        puzzle.p[y][x] = puzzle.p[y][x-1];
        puzzle.p[y][x-1] = t;
        if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
          puzzle.lastorder = 3;
          q.push(puzzle);
          checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
          for(int i=0;i<7;i++){
            checktmp[i] = puzzle.p[i/4][i%4];
          }
          checklist.push_back(checktmp);

        }
        puzzle = tmp;
      }

      if(Beforeorder !=  5){
        t  = puzzle.p[0][x];
        puzzle.p[0][x] = puzzle.p[1][x];
        puzzle.p[1][x] = t;
        if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
          puzzle.lastorder = 5;
          checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
          for(int i=0;i<7;i++){
            checktmp[i] = puzzle.p[i/4][i%4];
          }
          checklist.push_back(checktmp);
          q.push(puzzle);
        }
      }

      list<short[7]>::iterator itr;

      for(itr = checklist.begin();itr!=checklist.end();itr++){
        checker[(*itr)[0]] [(*itr)[1]] [(*itr)[2]] [(*itr)[3]] [(*itr)[4]] [(*itr)[5]] [(*itr)[6]] = true;
      }



    }

  }


    return 0;
}

Compiler output:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
                 from /usr/include/c++/14/bits/allocator.h:46,
                 from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::destroy(_Up*) [with _Up = short int [7]; _Tp = std::_List_node<short int [7]>]':
/usr/include/c++/14/bits/alloc_traits.h:597:15:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::destroy(allocator_type&, _Up*) [with _Up = short int [7]; _Tp = std::_List_node<short int [7]>; allocator_type = std::allocator<std::_List_node<short int [7]> >]'
  597 |           __a.destroy(__p);
      |           ~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/list.tcc:77:31:   required from 'void std::__cxx11::_List_base<_Tp, _Alloc>::_M_clear() [with _Tp = short int [7]; _Alloc = std::allocator<short int [7]>]'
   77 |           _Node_alloc_traits::destroy(_M_get_Node_allocator(), __val);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_list.h:576:9:   required from 'std::__cxx11::_List_base<_Tp, _Alloc>::~_List_base() [with _Tp = short int [7]; _Alloc = std::allocator<short int [7]>]'
  576 |       { _M_clear(); }
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_list.h:750:7:   required from here
  750 |       list() = default;
      |       ^~~~
/usr/include/c++/14/bits/new_allocator.h:198:17: error: request for member '~short int [7]' in '* __p', which is of non-class type 'short int [7]'
  198 |         { __p->~_Up(); }
      |           ~~~~~~^~~
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = short int [7]; _Args = {const short int (&)[7]}; _Tp = std::_List_node<short int [7]>]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = short int [7]; _Args = {const short int (&)[7]}; _Tp = std::_List_node<short int [7]>; allocator_type = std::allocator<std::_List_node<short int [7]> >]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_list.h:714:33:   required from 'std::__cxx11::list<_Tp, _Alloc>::_Node* std::__cxx11::list<_Tp, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {const short int (&)[7]}; _Tp = short int [7]; _Alloc = std::allocator<short int [7]>; _Node = std::__cxx11::list<short int [7]>::_Node]'
  714 |           _Node_alloc_traits::construct(__alloc, __p->_M_valptr(),
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
  715 |                                         std::forward<_Args>(__args)...);
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_list.h:2013:32:   required from 'void std::__cxx11::list<_Tp, _Alloc>::_M_insert(iterator, _Args&& ...) [with _Args = {const short int (&)[7]}; _Tp = short int [7]; _Alloc = std::allocator<short int [7]>; iterator = std::__cxx11::list<short int [7]>::iterator]'
 2013 |          _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
      |                         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_list.h:1315:24:   required from 'void std::__cxx11::list<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = short int [7]; _Alloc = std::allocator<short int [7]>; value_type = short int [7]]'
 1315 |       { this->_M_insert(end(), __x); }
      |         ~~~~~~~~~~~~~~~^~~~~~~~~~~~
a.cc:143:30:   required from here
  143 |           checklist.push_back(checktmp);
      |           ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: parenthesized initializer in array new
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~