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;

string tto_string(int n) {
std::stringstream ss;
ss << n;
std::string str = ss.str();  
return str;
}

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 = tto_string(front.d[0])+tto_string(front.d[1])+tto_string(front.d[2])+tto_string(front.d[3])+tto_string(front.d[4])+tto_string(front.d[5])+tto_string(front.d[6])+tto_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 = tto_string(puz[0])+tto_string(puz[1])+tto_string(puz[2])+tto_string(puz[3])+tto_string(puz[4])+tto_string(puz[5])+tto_string(puz[6])+tto_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 'std::string tto_string(int)':
a.cc:14:19: error: aggregate 'std::stringstream ss' has incomplete type and cannot be defined
   14 | std::stringstream ss;
      |                   ^~
a.cc: In function 'int main()':
a.cc:21:9: error: reference to 'data' is ambiguous
   21 |         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:23:17: error: 'first' was not declared in this scope
   23 |                 first.d[i] = i;
      |                 ^~~~~
a.cc:25:9: error: 'first' was not declared in this scope
   25 |         first.count = 0;
      |         ^~~~~
a.cc:26:13: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   26 |         bfs.push(first);
      |             ^~~~
a.cc:28:25: error: request for member 'empty' in 'bfs', which is of non-class type 'int'
   28 |                 if (bfs.empty()) break;
      |                         ^~~~~
a.cc:29:17: error: reference to 'data' is ambiguous
   29 |                 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:30:21: error: request for member 'pop' in 'bfs', which is of non-class type 'int'
   30 |                 bfs.pop();
      |                     ^~~
a.cc:31:41: error: 'front' was not declared in this scope
   31 |                 string str = tto_string(front.d[0])+tto_string(front.d[1])+tto_string(front.d[2])+tto_string(front.d[3])+tto_string(front.d[4])+tto_string(front.d[5])+tto_string(front.d[6])+tto_string(front.d[7]);
      |                                         ^~~~~
a.cc:49:33: error: reference to 'data' is ambiguous
   49 |                                 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:50:38: error: expected unqualified-id before '.' token
   50 |                                 array.count = front.count + 1;
      |                                      ^
a.cc:51:42: error: missing template arguments before '.' token
   51 |                                 x = array.d[zero];
      |                                          ^
a.cc:52:38: error: expected unqualified-id before '.' token
   52 |                                 array.d[zero] = array.d[zero+4];
      |                                      ^
a.cc:53:38: error: expected unqualified-id before '.' token
   53 |                                 array.d[zero+4] = x;
      |                                      ^
a.cc:54:37: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   54 |                                 bfs.push(array);
      |                                     ^~~~
a.cc:54:47: error: missing template arguments before ')' token
   54 |                                 bfs.push(array);
      |                                               ^
a.cc:57:41: error: reference to 'data' is ambiguous
   57 |                                         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:58:41: error: 'array2' was not declared in this scope
   58 |                                         array2.count = front.count + 1;
      |                                         ^~~~~~
a.cc:62:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   62 |                                         bfs.push(array2);
      |                                             ^~~~
a.cc:66:41: error: reference to 'data' is ambiguous
   66 |                                         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:67:41: error: 'array3' was not declared in this scope
   67 |                                         array3.count = front.count + 1;
      |                                         ^~~~~~
a.cc:71:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   71 |                                         bfs.push(array3);
      |                                             ^~~~
a.cc:77:33: error: reference to 'data' is ambiguous
   77 |                                 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 (__