Language: C++

#include <iostream>
#include <vector>
#include <utility>
#include <utility>
#include <algorithm>
#include <queue>
#include <numeric>
#include <unordered_map>


    typedef std::vector<std::vector<int>> State;
    const int N = 3;

    State int_to_state(int c){
      std::vector<std::vector<int>> state(N, std::vector<int>(N));
      FOR(i, N) {
        FOR(j, N) {
          int r = c%10;
          c = c/10;
          state[i][j] = r;
        }
      }
      return state;
    }
    int state_to_int(State state) {
      int c = 0;
      int p = 1;
      FOR(i, N) {
        FOR(j, N) {
          c += state[i][j] * p;
          p *= 10;
        }
      }
      return c;
    }


    void show(std::vector<std::vector<int>> state){
      FOR(i, N) {
        FOR(j, N) {
          std::cout << state[i][j] << " ";
        }
        std::cout << std::endl;
      }
    }

    bool is_solved(const State& state) {
      int N = state.size();

      FOR(i, N) {
        FOR(j, N) {
          if(state[i][j] != (1 + 3*i + j)) return false;
        }
      }
      return true;
    }

    std::vector<State> next_states_of(State state){
      std::vector<State> res;
      auto ns = state; std::swap(ns[0][0], ns[0][1]); res.push_back(ns);
      ns = state; std::swap(ns[0][1], ns[0][2]); res.push_back(ns);
      ns = state; std::swap(ns[1][0], ns[1][1]); res.push_back(ns);
      ns = state; std::swap(ns[1][1], ns[1][2]); res.push_back(ns);
      ns = state; std::swap(ns[2][0], ns[2][1]); res.push_back(ns);
      ns = state; std::swap(ns[2][1], ns[2][2]); res.push_back(ns);
      ns = state; std::swap(ns[0][0], ns[1][0]); res.push_back(ns);
      ns = state; std::swap(ns[1][0], ns[2][0]); res.push_back(ns);
      ns = state; std::swap(ns[0][1], ns[1][1]); res.push_back(ns);
      ns = state; std::swap(ns[1][1], ns[2][1]); res.push_back(ns);
      ns = state; std::swap(ns[0][2], ns[1][2]); res.push_back(ns);
      ns = state; std::swap(ns[1][2], ns[2][2]); res.push_back(ns);
//      std::cout << res.size() <<std::endl;
      return res;
    }

    int solve_puzzle(State state){

      std::priority_queue<
        std::pair<int, int>,
        std::vector<std::pair<int, int>>,
        std::greater<std::pair<int, int>>
      > q;
      std::unordered_map<int, int> h;

      q.push(std::make_pair(0, state_to_int(state)));

      for(;not q.empty();){
        auto d_s = q.top(); q.pop();
        int d = d_s.first;
        int st_int = d_s.second;
        State state = int_to_state(d_s.second);
//        show(state);

        if(st_int == 987654321){
//          std::cout << "z"<< std::endl;
          return d;
        }

        if(h.find(st_int) == h.end()){
          h[st_int] = d;
          std::vector<State> next_states = next_states_of(state);
          for(auto ns : next_states){
            q.push(std::make_pair(d+1, state_to_int(ns)));
          }
        }
      }
      return -1;
    }

    int main(){
      const int N = 3;
      std::vector<std::vector<int>> state(N, std::vector<int>(N));

      FOR(i, N){
        FOR(j, N){
          GET(int, x);
          if(x==0) x=9;
          state[i][j] = x;
        }
      }
//      show(state);
//      int c = state_to_int(state);
//      std::cout << c << std::endl;
//      std::cout << "?" <<std::endl;
//      State s2 = int_to_state(c);
//      std::cout << "!" <<std::endl;
//
//      show(s2);
//      int min_steps = rec_min_steps_
      std::cout << solve_puzzle(state) << std::endl;
      return 0;
    }

Compiler output:
a.cc: In function 'State int_to_state(int)':
a.cc:16:11: error: 'i' was not declared in this scope
   16 |       FOR(i, N) {
      |           ^
a.cc:16:7: error: 'FOR' was not declared in this scope
   16 |       FOR(i, N) {
      |       ^~~
a.cc: In function 'int state_to_int(State)':
a.cc:28:11: error: 'i' was not declared in this scope
   28 |       FOR(i, N) {
      |           ^
a.cc:28:7: error: 'FOR' was not declared in this scope
   28 |       FOR(i, N) {
      |       ^~~
a.cc: In function 'void show(std::vector<std::vector<int> >)':
a.cc:39:11: error: 'i' was not declared in this scope
   39 |       FOR(i, N) {
      |           ^
a.cc:39:7: error: 'FOR' was not declared in this scope
   39 |       FOR(i, N) {
      |       ^~~
a.cc: In function 'bool is_solved(const State&)':
a.cc:50:11: error: 'i' was not declared in this scope
   50 |       FOR(i, N) {
      |           ^
a.cc:50:7: error: 'FOR' was not declared in this scope
   50 |       FOR(i, N) {
      |       ^~~
a.cc: In function 'int main()':
a.cc:114:11: error: 'i' was not declared in this scope
  114 |       FOR(i, N){
      |           ^
a.cc:114:7: error: 'FOR' was not declared in this scope
  114 |       FOR(i, N){
      |       ^~~