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;

char to_string(int n) {
	char a = n;
	string b = a;
	return a;
}

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 'char to_string(int)':
a.cc:15:20: error: conversion from 'char' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
   15 |         string b = a;
      |                    ^
a.cc: In function 'int main()':
a.cc:20:9: error: reference to 'data' is ambiguous
   20 |         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:22:17: error: 'first' was not declared in this scope
   22 |                 first.d[i] = i;
      |                 ^~~~~
a.cc:24:9: error: 'first' was not declared in this scope
   24 |         first.count = 0;
      |         ^~~~~
a.cc:25:13: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   25 |         bfs.push(first);
      |             ^~~~
a.cc:27:25: error: request for member 'empty' in 'bfs', which is of non-class type 'int'
   27 |                 if (bfs.empty()) break;
      |                         ^~~~~
a.cc:28:17: error: reference to 'data' is ambiguous
   28 |                 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:29:21: error: request for member 'pop' in 'bfs', which is of non-class type 'int'
   29 |                 bfs.pop();
      |                     ^~~
a.cc:30:40: error: 'front' was not declared in this scope
   30 |                 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:48:33: error: reference to 'data' is ambiguous
   48 |                                 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:49:38: error: expected unqualified-id before '.' token
   49 |                                 array.count = front.count + 1;
      |                                      ^
a.cc:50:42: error: missing template arguments before '.' token
   50 |                                 x = array.d[zero];
      |                                          ^
a.cc:51:38: error: expected unqualified-id before '.' token
   51 |                                 array.d[zero] = array.d[zero+4];
      |                                      ^
a.cc:52:38: error: expected unqualified-id before '.' token
   52 |                                 array.d[zero+4] = x;
      |                                      ^
a.cc:53:37: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   53 |                                 bfs.push(array);
      |                                     ^~~~
a.cc:53:47: error: missing template arguments before ')' token
   53 |                                 bfs.push(array);
      |                                               ^
a.cc:56:41: error: reference to 'data' is ambiguous
   56 |                                         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:57:41: error: 'array2' was not declared in this scope
   57 |                                         array2.count = front.count + 1;
      |                                         ^~~~~~
a.cc:61:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   61 |                                         bfs.push(array2);
      |                                             ^~~~
a.cc:65:41: error: reference to 'data' is ambiguous
   65 |                                         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:66:41: error: 'array3' was not declared in this scope
   66 |                                         array3.count = front.count + 1;
      |                                         ^~~~~~
a.cc:70:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   70 |                                         bfs.push(array3);
      |                                             ^~~~
a.cc:76:33: error: reference to 'data' is ambiguous
   76 |                                 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> constex