Language: C++

#include <iostream>
#include <map>
#include <queue>
using namespace std;

typedef struct {
	int d[8];
	int count;
} data;
map <string,int> memo;
queue <data> bfs;

int main() {
	data first;
	for (int i = 0;i < 8;i++) {
		first.d[i] = i;
	}
	first.count = 0;
	bfs.push(first);
	for (;;) {
		if (bfs.empty()) break;
		data front = bfs.front();
		bfs.pop();
		string str = to_string(front.d[0])+to_string(front.d[1])+to_string(front.d[2])+to_string(front.d[3])+to_string(front.d[4])+to_string(front.d[5])+to_string(front.d[6])+to_string(front.d[7]);
		if(memo.find(str) !=memo.end()){
			continue;
		}
		memo[str] = front.count;
		//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.count = front.count + 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.count = front.count + 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.count = front.count + 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.count = front.count + 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.count = front.count + 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.count = front.count + 1;
					z = array3.d[zero];
					array3.d[zero] = array3.d[zero+1];
					array3.d[zero+1] = z;
					bfs.push(array3);
				}
			}
	} 
	while(true) {
		int puz[8];
		if (cin >> puz[0]) {
			for (int i = 1;i < 8;i++) {
				cin >> puz[i];
			}
			string str = to_string(puz[0])+to_string(puz[1])+to_string(puz[2])+to_string(puz[3])+to_string(puz[4])+to_string(puz[5])+to_string(puz[6])+to_string(puz[7]);
			cout << memo[str] << endl;
		}
		else break;
	}
	return 0;
}

Compiler output:
a.cc:11:12: error: template argument 1 is invalid
   11 | queue <data> bfs;
      |            ^
a.cc:11:12: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:14:9: error: reference to 'data' is ambiguous
   14 |         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:9:3: note:                 'typedef struct data data'
    9 | } data;
      |   ^~~~
a.cc:16:17: error: 'first' was not declared in this scope
   16 |                 first.d[i] = i;
      |                 ^~~~~
a.cc:18:9: error: 'first' was not declared in this scope
   18 |         first.count = 0;
      |         ^~~~~
a.cc:19:13: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   19 |         bfs.push(first);
      |             ^~~~
a.cc:21:25: error: request for member 'empty' in 'bfs', which is of non-class type 'int'
   21 |                 if (bfs.empty()) break;
      |                         ^~~~~
a.cc:22:17: error: reference to 'data' is ambiguous
   22 |                 data front = bfs.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:9:3: note:                 'typedef struct data data'
    9 | } data;
      |   ^~~~
a.cc:23:21: error: request for member 'pop' in 'bfs', which is of non-class type 'int'
   23 |                 bfs.pop();
      |                     ^~~
a.cc:24:40: error: 'front' was not declared in this scope
   24 |                 string str = to_string(front.d[0])+to_string(front.d[1])+to_string(front.d[2])+to_string(front.d[3])+to_string(front.d[4])+to_string(front.d[5])+to_string(front.d[6])+to_string(front.d[7]);
      |                                        ^~~~~
a.cc:42:33: error: reference to 'data' is ambiguous
   42 |                                 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:9:3: note:                 'typedef struct data data'
    9 | } data;
      |   ^~~~
a.cc:43:38: error: expected unqualified-id before '.' token
   43 |                                 array.count = front.count + 1;
      |                                      ^
a.cc:44:42: error: missing template arguments before '.' token
   44 |                                 x = array.d[zero];
      |                                          ^
a.cc:45:38: error: expected unqualified-id before '.' token
   45 |                                 array.d[zero] = array.d[zero+4];
      |                                      ^
a.cc:46:38: error: expected unqualified-id before '.' token
   46 |                                 array.d[zero+4] = x;
      |                                      ^
a.cc:47:37: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   47 |                                 bfs.push(array);
      |                                     ^~~~
a.cc:47:47: error: missing template arguments before ')' token
   47 |                                 bfs.push(array);
      |                                               ^
a.cc:50:41: error: reference to 'data' is ambiguous
   50 |                                         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:9:3: note:                 'typedef struct data data'
    9 | } data;
      |   ^~~~
a.cc:51:41: error: 'array2' was not declared in this scope
   51 |                                         array2.count = front.count + 1;
      |                                         ^~~~~~
a.cc:55:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   55 |                                         bfs.push(array2);
      |                                             ^~~~
a.cc:59:41: error: reference to 'data' is ambiguous
   59 |                                         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:9:3: note:                 'typedef struct data data'
    9 | } data;
      |   ^~~~
a.cc:60:41: error: 'array3' was not declared in this scope
   60 |                                         array3.count = front.count + 1;
      |                                         ^~~~~~
a.cc:64:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   64 |                                         bfs.push(array3);
      |                                             ^~~~
a.cc:70:33: error: reference to 'data' is ambiguous
   70 |                                 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:                 'temp