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 to_string(int n) {
	string x = n;
	return x;
}

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