Language: C++

#include <iostream>
#include <queue>
#define INF 9999999
using namespace std;
typedef struct {
	int d[9];	
}data;
int main() {
	while(true) {
		queue<data> bfs;
		data first;
		bool checked[8][8][8][8][8][8][8];

		int min = INF;
		for (int i = 0;i < 8;i++) {
			cin >> first.d[i];
		}
		first.d[8] = 0;
		bfs.push(first);
		for (;;) {
			if (bfs.empty()) break;
			data front;
			front = bfs.front();
			bfs.pop();
			for (int k = 0;k < 4;k++) {
				cout << front.d[k] << " ";
			}
			cout << endl;
			for (int k = 4;k < 8;k++) {
				cout << front.d[k] << " ";
			}
			cout << endl;
			//Is it already covered?
			if(checked[front.d[0]][front.d[1]][front.d[2]][front.d[3]][front.d[4]][front.d[5]][front.d[6]][front.d[7]] == true) {
				cout << "skipped" << endl;
				continue;
			}
			else {
				cout << "NOT" << endl;
			}
			//Check
			if (front.d[8] < min) {
				for (int i = 0;i < 8;i++) {
					if(front.d[i] != i) goto outofcheck;
				}
				min = front.d[8];
			}
			outofcheck:
			//Find Zero
			int zero;
			for (int i = 0;i < 8;i++) {
				if (front.d[i] == 0) {
					zero = i;
					break;
				}
			}
			//Move
			if (zero < 4) {
				//???????????\?????????
				int x;
				data array = front;
				array.d[8] = front.d[8] + 1;
				x = array.d[zero];
				array.d[zero] = array.d[zero+4];
				array.d[zero+4] = x;
				bfs.push(array);
				if (zero>0) {
					int y;
					data array2 = front;
					array2.d[8] = front.d[8] + 1;
					y = array2.d[zero];
					array2.d[zero] = array2.d[zero-1];
					array2.d[zero-1] = y;
					bfs.push(array2);
				}
				if(zero<3) {
					int z;
					data array3 = front;
					array3.d[8] = front.d[8] + 1;
					z = array3.d[zero];
					array3.d[zero] = array3.d[zero+1];
					array3.d[zero+1] = z;
					bfs.push(array3);
				}
			}
			else {
				//???????????\?????????
				int x;
				data array = front;
				array.d[8] = front.d[8] + 1;
				x = array.d[zero];
				array.d[zero] = array.d[zero-4];
				array.d[zero-4] = x;
				bfs.push(array);
				if (zero>4) {
					int y;
					data array2= front;
					array2.d[8] = front.d[8] + 1;
					y = array2.d[zero];
					array2.d[zero] = array2.d[zero-1];
					array2.d[zero-1] = y;
					bfs.push(array2);
				}
				if(zero<7) {
					int z;
					data array3 = front;
					array3.d[8] = front.d[8] + 1;
					z = array3.d[zero];
					array3.d[zero] = array3.d[zero+1];
					array3.d[zero+1] = z;
					bfs.push(array3);
				}
			}
			checked[front.d[0]][front.d[1]][front.d[2]][front.d[3]][front.d[4]][front.d[5]][front.d[6]][front.d[7]] = true;
		}
	cout << min << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:27: error: template argument 1 is invalid
   10 |                 queue<data> bfs;
      |                           ^
a.cc:10:27: error: template argument 2 is invalid
a.cc:11:17: error: reference to 'data' is ambiguous
   11 |                 data first;
      |                 ^~~~
In file included from /usr/include/c++/14/string:53,
                 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/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:2: note:                 'typedef struct data data'
    7 | }data;
      |  ^~~~
a.cc:16:32: error: 'first' was not declared in this scope
   16 |                         cin >> first.d[i];
      |                                ^~~~~
a.cc:18:17: error: 'first' was not declared in this scope
   18 |                 first.d[8] = 0;
      |                 ^~~~~
a.cc:19:21: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   19 |                 bfs.push(first);
      |                     ^~~~
a.cc:21:33: error: request for member 'empty' in 'bfs', which is of non-class type 'int'
   21 |                         if (bfs.empty()) break;
      |                                 ^~~~~
a.cc:22:25: error: reference to 'data' is ambiguous
   22 |                         data front;
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:2: note:                 'typedef struct data data'
    7 | }data;
      |  ^~~~
a.cc:23:25: error: 'front' was not declared in this scope
   23 |                         front = bfs.front();
      |                         ^~~~~
a.cc:23:37: error: request for member 'front' in 'bfs', which is of non-class type 'int'
   23 |                         front = bfs.front();
      |                                     ^~~~~
a.cc:24:29: error: request for member 'pop' in 'bfs', which is of non-class type 'int'
   24 |                         bfs.pop();
      |                             ^~~
a.cc:61:33: error: reference to 'data' is ambiguous
   61 |                                 data array = front;
      |                                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:2: note:                 'typedef struct data data'
    7 | }data;
      |  ^~~~
a.cc:62:38: error: expected unqualified-id before '.' token
   62 |                                 array.d[8] = front.d[8] + 1;
      |                                      ^
a.cc:63:42: error: missing template arguments before '.' token
   63 |                                 x = array.d[zero];
      |                                          ^
a.cc:64:38: error: expected unqualified-id before '.' token
   64 |                                 array.d[zero] = array.d[zero+4];
      |                                      ^
a.cc:65:38: error: expected unqualified-id before '.' token
   65 |                                 array.d[zero+4] = x;
      |                                      ^
a.cc:66:37: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   66 |                                 bfs.push(array);
      |                                     ^~~~
a.cc:66:47: error: missing template arguments before ')' token
   66 |                                 bfs.push(array);
      |                                               ^
a.cc:69:41: error: reference to 'data' is ambiguous
   69 |                                         data array2 = front;
      |                                         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:2: note:                 'typedef struct data data'
    7 | }data;
      |  ^~~~
a.cc:70:41: error: 'array2' was not declared in this scope
   70 |                                         array2.d[8] = front.d[8] + 1;
      |                                         ^~~~~~
a.cc:74:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   74 |                                         bfs.push(array2);
      |                                             ^~~~
a.cc:78:41: error: reference to 'data' is ambiguous
   78 |                                         data array3 = front;
      |                                         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:2: note:                 'typedef struct data data'
    7 | }data;
      |  ^~~~
a.cc:79:41: error: 'array3' was not declared in this scope
   79 |                                         array3.d[8] = front.d[8] + 1;
      |                                         ^~~~~~
a.cc:83:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   83 |                                         bfs.push(array3);
      |                                             ^~~~
a.cc:89:33: error: reference to 'data' is ambiguous
   89 |                                 data array = front;
      |                                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Conta