Generated by Cython 0.29.13

Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.

Raw output: CACompute.cpp

+001: # distutils: language=c++
  __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 002: """
 003: cdef extern from "Compute.cpp":
 004:     cdef struct compute_return:
 005:         int lower_x, lower_y, upper_x, upper_y
 006:         unordered_map[pair[int, int], int] dict_grid
 007:         unordered_set[pair[int, int]] cells_changed
 008: 
 009:     cdef compute_return compute(vector[pair[int, int]] neighbourhood, bool first,
 010:                                 unordered_set[pair[int, int]] cells_changed, int lower_x, int upper_x, int lower_y,
 011:                                 int upper_y, unordered_map[pair[int, int], int] copy_grid,
 012:                                 unordered_map[pair[int, int], int] dict_grid)
 013: 
 014: 
 015: cpdef pycompute(vector[pair[int, int]] neighbourhood, bool first,
 016:               unordered_set[pair[int, int]] cells_changed, int lower_x, int upper_x, int lower_y,
 017:               int upper_y, unordered_map[pair[int, int], int] copy_grid,
 018:               unordered_map[pair[int, int], int] dict_grid):
 019: 
 020:     cdef compute_return ans = compute(neighbourhood, first, cells_changed, lower_x, upper_x, lower_y, upper_y,
 021:                                       copy_grid, dict_grid)
 022: 
 023:     return ans.lower_x, ans.lower_y, ans.upper_x, ans.upper_y, ans.cells_changed, ans.dict_grid
 024: 
 025: 
 026: """
 027: from libcpp.map cimport map
 028: from libcpp.pair cimport pair
 029: from libcpp.unordered_map cimport unordered_map
 030: from libcpp.unordered_set cimport unordered_set
 031: from libcpp.vector cimport vector
 032: 
+033: from transFunc import transition_func, depend_on_neighbours, alternating_period
  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_transition_func);
  __Pyx_GIVEREF(__pyx_n_s_transition_func);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_transition_func);
  __Pyx_INCREF(__pyx_n_s_depend_on_neighbours);
  __Pyx_GIVEREF(__pyx_n_s_depend_on_neighbours);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_depend_on_neighbours);
  __Pyx_INCREF(__pyx_n_s_alternating_period);
  __Pyx_GIVEREF(__pyx_n_s_alternating_period);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_alternating_period);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_transFunc, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_transition_func); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_transition_func, __pyx_t_1) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_depend_on_neighbours); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_depend_on_neighbours, __pyx_t_1) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_alternating_period); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_alternating_period, __pyx_t_1) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 034: 
 035: cdef extern from "compute.cpp":
 036:     pass
 037: 
 038: cdef map[vector[int], vector[int]] DP
+039: cdef int alternating_period2 = alternating_period
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_alternating_period); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_9CACompute_alternating_period2 = __pyx_t_3;
 040: 
+041: cpdef compute(vector[pair[int, int]] neighbourhood, vector[pair[int, int]] DP_neighbourhood,
static PyObject *__pyx_pw_9CACompute_1compute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9CACompute_compute(std::vector<std::pair<int,int> >  __pyx_v_neighbourhood, std::vector<std::pair<int,int> >  __pyx_v_DP_neighbourhood, std::unordered_set<std::pair<int,int> >  __pyx_v_cells_changed, int __pyx_v_lower_x, int __pyx_v_upper_x, int __pyx_v_lower_y, int __pyx_v_upper_y, std::unordered_map<std::pair<int,int> ,int>  __pyx_v_copy_grid, std::unordered_map<std::pair<int,int> ,int>  __pyx_v_dict_grid, int __pyx_v_generations, CYTHON_UNUSED int __pyx_skip_dispatch) {
  std::vector<int>  __pyx_v_neighbours;
  std::vector<int>  __pyx_v_DP_result;
  std::vector<int>  __pyx_v_DP_neighbours;
  std::vector<std::pair<int,int> >  __pyx_v_neighbourhood_with_centre;
  std::unordered_set<std::pair<int,int> >  __pyx_v_cells_to_check;
  std::unordered_set<std::pair<int,int> >  __pyx_v_cells_checked;
  int __pyx_v_ans;
  std::pair<int,int>  __pyx_v_coordinates;
  std::pair<int,int>  __pyx_v_coordinates2;
  std::pair<int,int>  __pyx_v_neighbour;
  std::pair<int,int>  __pyx_v_cell;
  std::pair<int,int>  __pyx_v_k;
  std::vector<int> ::size_type __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compute", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("CACompute.compute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9CACompute_1compute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_9CACompute_1compute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  std::vector<std::pair<int,int> >  __pyx_v_neighbourhood;
  std::vector<std::pair<int,int> >  __pyx_v_DP_neighbourhood;
  std::unordered_set<std::pair<int,int> >  __pyx_v_cells_changed;
  int __pyx_v_lower_x;
  int __pyx_v_upper_x;
  int __pyx_v_lower_y;
  int __pyx_v_upper_y;
  std::unordered_map<std::pair<int,int> ,int>  __pyx_v_copy_grid;
  std::unordered_map<std::pair<int,int> ,int>  __pyx_v_dict_grid;
  int __pyx_v_generations;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compute (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_neighbourhood,&__pyx_n_s_DP_neighbourhood,&__pyx_n_s_cells_changed,&__pyx_n_s_lower_x,&__pyx_n_s_upper_x,&__pyx_n_s_lower_y,&__pyx_n_s_upper_y,&__pyx_n_s_copy_grid,&__pyx_n_s_dict_grid,&__pyx_n_s_generations,0};
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_neighbourhood)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_DP_neighbourhood)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compute", 1, 10, 10, 1); __PYX_ERR(0, 41, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cells_changed)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compute", 1, 10, 10, 2); __PYX_ERR(0, 41, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lower_x)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compute", 1, 10, 10, 3); __PYX_ERR(0, 41, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_upper_x)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compute", 1, 10, 10, 4); __PYX_ERR(0, 41, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lower_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compute", 1, 10, 10, 5); __PYX_ERR(0, 41, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_upper_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compute", 1, 10, 10, 6); __PYX_ERR(0, 41, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_copy_grid)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compute", 1, 10, 10, 7); __PYX_ERR(0, 41, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dict_grid)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compute", 1, 10, 10, 8); __PYX_ERR(0, 41, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_generations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compute", 1, 10, 10, 9); __PYX_ERR(0, 41, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compute") < 0)) __PYX_ERR(0, 41, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 10) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
    }
    __pyx_v_neighbourhood = __pyx_convert_vector_from_py_std_3a__3a_pair_3c_int_2c_int_3e___(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 41, __pyx_L3_error)
    __pyx_v_DP_neighbourhood = __pyx_convert_vector_from_py_std_3a__3a_pair_3c_int_2c_int_3e___(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 41, __pyx_L3_error)
    __pyx_v_cells_changed = __pyx_convert_unordered_set_from_py_std_3a__3a_pair_3c_int_2c_int_3e___(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error)
    __pyx_v_lower_x = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_lower_x == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L3_error)
    __pyx_v_upper_x = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_upper_x == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L3_error)
    __pyx_v_lower_y = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_lower_y == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L3_error)
    __pyx_v_upper_y = __Pyx_PyInt_As_int(values[6]); if (unlikely((__pyx_v_upper_y == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L3_error)
    __pyx_v_copy_grid = __pyx_convert_unordered_map_from_py_std_3a__3a_pair_3c_int_2c_int_3e_____and_int(values[7]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L3_error)
    __pyx_v_dict_grid = __pyx_convert_unordered_map_from_py_std_3a__3a_pair_3c_int_2c_int_3e_____and_int(values[8]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L3_error)
    __pyx_v_generations = __Pyx_PyInt_As_int(values[9]); if (unlikely((__pyx_v_generations == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("compute", 1, 10, 10, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 41, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("CACompute.compute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9CACompute_compute(__pyx_self, __pyx_v_neighbourhood, __pyx_v_DP_neighbourhood, __pyx_v_cells_changed, __pyx_v_lower_x, __pyx_v_upper_x, __pyx_v_lower_y, __pyx_v_upper_y, __pyx_v_copy_grid, __pyx_v_dict_grid, __pyx_v_generations);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9CACompute_compute(CYTHON_UNUSED PyObject *__pyx_self, std::vector<std::pair<int,int> >  __pyx_v_neighbourhood, std::vector<std::pair<int,int> >  __pyx_v_DP_neighbourhood, std::unordered_set<std::pair<int,int> >  __pyx_v_cells_changed, int __pyx_v_lower_x, int __pyx_v_upper_x, int __pyx_v_lower_y, int __pyx_v_upper_y, std::unordered_map<std::pair<int,int> ,int>  __pyx_v_copy_grid, std::unordered_map<std::pair<int,int> ,int>  __pyx_v_dict_grid, int __pyx_v_generations) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compute", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9CACompute_compute(__pyx_v_neighbourhood, __pyx_v_DP_neighbourhood, __pyx_v_cells_changed, __pyx_v_lower_x, __pyx_v_upper_x, __pyx_v_lower_y, __pyx_v_upper_y, __pyx_v_copy_grid, __pyx_v_dict_grid, __pyx_v_generations, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("CACompute.compute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 042:               unordered_set[pair[int, int]] cells_changed,
 043:               int lower_x, int upper_x, int lower_y, int upper_y,
 044:               unordered_map[pair[int, int], int] copy_grid, unordered_map[pair[int, int], int] dict_grid,
 045:               int generations):
 046: 
 047:     cdef vector[int] neighbours
 048:     cdef vector[int] DP_result
 049:     cdef vector[int] DP_neighbours
+050:     neighbours.reserve(neighbourhood.size() + 1)
  __pyx_v_neighbours.reserve((__pyx_v_neighbourhood.size() + 1));
+051:     DP_result.reserve(neighbourhood.size() + 1)
  __pyx_v_DP_result.reserve((__pyx_v_neighbourhood.size() + 1));
+052:     DP_neighbours.reserve(DP_neighbourhood.size() + 1)
  __pyx_v_DP_neighbours.reserve((__pyx_v_DP_neighbourhood.size() + 1));
 053: 
+054:     cdef vector[pair[int, int]] neighbourhood_with_centre = neighbourhood
  __pyx_v_neighbourhood_with_centre = __pyx_v_neighbourhood;
+055:     neighbourhood_with_centre.push_back(pair[int, int] (0, 0))
  try {
    __pyx_t_1 = std::pair<int,int> (0, 0);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 55, __pyx_L1_error)
  }
  try {
    __pyx_v_neighbourhood_with_centre.push_back(__pyx_t_1);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 55, __pyx_L1_error)
  }
 056: 
 057:     cdef unordered_set[pair[int, int]] cells_to_check
 058:     cdef unordered_set[pair[int, int]] cells_checked
 059: 
 060:     cdef int ans
 061:     cdef pair[int, int] coordinates, coordinates2
 062:     cdef pair[int, int] neighbour, cell
 063: 
+064:     for cell in cells_changed:
  __pyx_t_2 = __pyx_v_cells_changed.begin();
  for (;;) {
    if (!(__pyx_t_2 != __pyx_v_cells_changed.end())) break;
    __pyx_t_1 = *__pyx_t_2;
    ++__pyx_t_2;
    __pyx_v_cell = __pyx_t_1;
/* … */
  }
+065:         cells_to_check.insert(cell)
    (void)(__pyx_v_cells_to_check.insert(__pyx_v_cell));
 066: 
+067:     if alternating_period2 > 1:
  __pyx_t_3 = ((__pyx_v_9CACompute_alternating_period2 > 1) != 0);
  if (__pyx_t_3) {
/* … */
    goto __pyx_L5;
  }
+068:         if generations % (alternating_period2 - 1) == 0:
    __pyx_t_4 = (__pyx_v_9CACompute_alternating_period2 - 1);
    if (unlikely(__pyx_t_4 == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 68, __pyx_L1_error)
    }
    __pyx_t_3 = ((__Pyx_mod_long(__pyx_v_generations, __pyx_t_4) == 0) != 0);
    if (__pyx_t_3) {
/* … */
    }
+069:             cells_changed.clear()
      __pyx_v_cells_changed.clear();
 070:     else:
+071:         cells_changed.clear()
  /*else*/ {
    __pyx_v_cells_changed.clear();
  }
  __pyx_L5:;
 072: 
+073:     for cell in cells_to_check:
  __pyx_t_2 = __pyx_v_cells_to_check.begin();
  for (;;) {
    if (!(__pyx_t_2 != __pyx_v_cells_to_check.end())) break;
    __pyx_t_1 = *__pyx_t_2;
    ++__pyx_t_2;
    __pyx_v_cell = __pyx_t_1;
/* … */
  }
 074:         #if cells_checked.find(cell) != cells_checked.end():
 075:         #    continue
 076: 
+077:         for k in DP_neighbourhood:
    __pyx_t_5 = __pyx_v_DP_neighbourhood.begin();
    for (;;) {
      if (!(__pyx_t_5 != __pyx_v_DP_neighbourhood.end())) break;
      __pyx_t_1 = *__pyx_t_5;
      ++__pyx_t_5;
      __pyx_v_k = __pyx_t_1;
/* … */
    }
+078:             coordinates2 = pair[int, int] (cell.first + k.first,
      try {
        __pyx_t_1 = std::pair<int,int> ((__pyx_v_cell.first + __pyx_v_k.first), (__pyx_v_cell.second + __pyx_v_k.second));
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 78, __pyx_L1_error)
      }
      __pyx_v_coordinates2 = __pyx_t_1;
 079:                                            cell.second + k.second)
+080:             if copy_grid.find(coordinates2) != copy_grid.end():
      __pyx_t_3 = ((__pyx_v_copy_grid.find(__pyx_v_coordinates2) != __pyx_v_copy_grid.end()) != 0);
      if (__pyx_t_3) {
/* … */
        goto __pyx_L11;
      }
+081:                 DP_neighbours.push_back(copy_grid[coordinates2])
        try {
          __pyx_v_DP_neighbours.push_back((__pyx_v_copy_grid[__pyx_v_coordinates2]));
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 81, __pyx_L1_error)
        }
 082:             else:
+083:                 DP_neighbours.push_back(0)
      /*else*/ {
        try {
          __pyx_v_DP_neighbours.push_back(0);
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 83, __pyx_L1_error)
        }
      }
      __pyx_L11:;
 084: 
+085:         if DP.find(DP_neighbours) != DP.end():
    __pyx_t_3 = ((__pyx_v_9CACompute_DP.find(__pyx_v_DP_neighbours) != __pyx_v_9CACompute_DP.end()) != 0);
    if (__pyx_t_3) {
/* … */
      goto __pyx_L12;
    }
+086:             for i in range(DP[DP_neighbours].size()):
      __pyx_t_6 = (__pyx_v_9CACompute_DP[__pyx_v_DP_neighbours]).size();
      __pyx_t_7 = __pyx_t_6;
      for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
        __pyx_v_i = __pyx_t_8;
+087:                 ans = DP[DP_neighbours][i]
        __pyx_v_ans = ((__pyx_v_9CACompute_DP[__pyx_v_DP_neighbours])[__pyx_v_i]);
+088:                 coordinates = pair[int, int] (cell.first + neighbourhood_with_centre[i].first,
        try {
          __pyx_t_1 = std::pair<int,int> ((__pyx_v_cell.first + (__pyx_v_neighbourhood_with_centre[__pyx_v_i]).first), (__pyx_v_cell.second + (__pyx_v_neighbourhood_with_centre[__pyx_v_i]).second));
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 88, __pyx_L1_error)
        }
        __pyx_v_coordinates = __pyx_t_1;
 089:                                               cell.second + neighbourhood_with_centre[i].second)
+090:                 if cells_checked.find(coordinates) == cells_checked.end():
        __pyx_t_3 = ((__pyx_v_cells_checked.find(__pyx_v_coordinates) == __pyx_v_cells_checked.end()) != 0);
        if (__pyx_t_3) {
/* … */
          goto __pyx_L15;
        }
+091:                     cells_checked.insert(coordinates)
          (void)(__pyx_v_cells_checked.insert(__pyx_v_coordinates));
 092:                 else:
+093:                     continue
        /*else*/ {
          goto __pyx_L13_continue;
        }
        __pyx_L15:;
 094: 
+095:                 if copy_grid.find(coordinates) != copy_grid.end():
        __pyx_t_3 = ((__pyx_v_copy_grid.find(__pyx_v_coordinates) != __pyx_v_copy_grid.end()) != 0);
        if (__pyx_t_3) {
/* … */
          goto __pyx_L16;
        }
+096:                     if ans == 0 and dict_grid.find(coordinates) != dict_grid.end():
          __pyx_t_9 = ((__pyx_v_ans == 0) != 0);
          if (__pyx_t_9) {
          } else {
            __pyx_t_3 = __pyx_t_9;
            goto __pyx_L18_bool_binop_done;
          }
          __pyx_t_9 = ((__pyx_v_dict_grid.find(__pyx_v_coordinates) != __pyx_v_dict_grid.end()) != 0);
          __pyx_t_3 = __pyx_t_9;
          __pyx_L18_bool_binop_done:;
          if (__pyx_t_3) {
/* … */
            goto __pyx_L17;
          }
+097:                         dict_grid.erase(coordinates)
            (void)(__pyx_v_dict_grid.erase(__pyx_v_coordinates));
+098:                         cells_changed.insert(coordinates)
            (void)(__pyx_v_cells_changed.insert(__pyx_v_coordinates));
+099:                     elif ans != copy_grid[coordinates]:
          __pyx_t_3 = ((__pyx_v_ans != (__pyx_v_copy_grid[__pyx_v_coordinates])) != 0);
          if (__pyx_t_3) {
/* … */
          }
          __pyx_L17:;
+100:                         dict_grid[coordinates] = ans
            (__pyx_v_dict_grid[__pyx_v_coordinates]) = __pyx_v_ans;
+101:                         cells_changed.insert(coordinates)
            (void)(__pyx_v_cells_changed.insert(__pyx_v_coordinates));
 102:                 else:
+103:                     dict_grid.insert(pair[pair[int, int], int] (coordinates, ans))
        /*else*/ {
          try {
            __pyx_t_10 = std::pair<std::pair<int,int> ,int> (__pyx_v_coordinates, __pyx_v_ans);
          } catch(...) {
            __Pyx_CppExn2PyErr();
            __PYX_ERR(0, 103, __pyx_L1_error)
          }
          (void)(__pyx_v_dict_grid.insert(__pyx_t_10));
+104:                     cells_changed.insert(coordinates)
          (void)(__pyx_v_cells_changed.insert(__pyx_v_coordinates));
+105:                     if coordinates.second < lower_x:
          __pyx_t_3 = ((__pyx_v_coordinates.second < __pyx_v_lower_x) != 0);
          if (__pyx_t_3) {
/* … */
            goto __pyx_L20;
          }
+106:                         lower_x = coordinates.second
            __pyx_t_11 = __pyx_v_coordinates.second;
            __pyx_v_lower_x = __pyx_t_11;
+107:                     elif coordinates.second > upper_x:
          __pyx_t_3 = ((__pyx_v_coordinates.second > __pyx_v_upper_x) != 0);
          if (__pyx_t_3) {
/* … */
          }
          __pyx_L20:;
+108:                         upper_x = coordinates.second
            __pyx_t_11 = __pyx_v_coordinates.second;
            __pyx_v_upper_x = __pyx_t_11;
 109: 
+110:                     if coordinates.first < lower_y:
          __pyx_t_3 = ((__pyx_v_coordinates.first < __pyx_v_lower_y) != 0);
          if (__pyx_t_3) {
/* … */
            goto __pyx_L21;
          }
+111:                         lower_y = coordinates.first
            __pyx_t_11 = __pyx_v_coordinates.first;
            __pyx_v_lower_y = __pyx_t_11;
+112:                     elif coordinates.first > upper_y:
          __pyx_t_3 = ((__pyx_v_coordinates.first > __pyx_v_upper_y) != 0);
          if (__pyx_t_3) {
/* … */
          }
          __pyx_L21:;
        }
        __pyx_L16:;
        __pyx_L13_continue:;
      }
+113:                         upper_y = coordinates.first
            __pyx_t_11 = __pyx_v_coordinates.first;
            __pyx_v_upper_y = __pyx_t_11;
 114:         else:
+115:             DP_result.clear()
    /*else*/ {
      __pyx_v_DP_result.clear();
+116:             for neighbour in neighbourhood_with_centre:
      __pyx_t_5 = __pyx_v_neighbourhood_with_centre.begin();
      for (;;) {
        if (!(__pyx_t_5 != __pyx_v_neighbourhood_with_centre.end())) break;
        __pyx_t_1 = *__pyx_t_5;
        ++__pyx_t_5;
        __pyx_v_neighbour = __pyx_t_1;
/* … */
      }
+117:                 neighbours.clear()
        __pyx_v_neighbours.clear();
 118: 
+119:                 ans = -1
        __pyx_v_ans = -1;
+120:                 coordinates = pair[int, int] (cell.first + neighbour.first,
        try {
          __pyx_t_1 = std::pair<int,int> ((__pyx_v_cell.first + __pyx_v_neighbour.first), (__pyx_v_cell.second + __pyx_v_neighbour.second));
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 120, __pyx_L1_error)
        }
        __pyx_v_coordinates = __pyx_t_1;
 121:                                               cell.second + neighbour.second)
 122: 
+123:                 if cells_checked.find(coordinates) == cells_checked.end():
        __pyx_t_3 = ((__pyx_v_cells_checked.find(__pyx_v_coordinates) == __pyx_v_cells_checked.end()) != 0);
        if (__pyx_t_3) {
/* … */
        }
+124:                     cells_checked.insert(coordinates)
          (void)(__pyx_v_cells_checked.insert(__pyx_v_coordinates));
 125: 
+126:                 if copy_grid.find(coordinates) == copy_grid.end(): ans = depend_on_neighbours(0, generations)
        __pyx_t_3 = ((__pyx_v_copy_grid.find(__pyx_v_coordinates) == __pyx_v_copy_grid.end()) != 0);
        if (__pyx_t_3) {
          __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_depend_on_neighbours); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 126, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_generations); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 126, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_15 = NULL;
          __pyx_t_11 = 0;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
            __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_13);
            if (likely(__pyx_t_15)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
              __Pyx_INCREF(__pyx_t_15);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_13, function);
              __pyx_t_11 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_13)) {
            PyObject *__pyx_temp[3] = {__pyx_t_15, __pyx_int_0, __pyx_t_14};
            __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 126, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
            PyObject *__pyx_temp[3] = {__pyx_t_15, __pyx_int_0, __pyx_t_14};
            __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 126, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          } else
          #endif
          {
            __pyx_t_16 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 126, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_16);
            if (__pyx_t_15) {
              __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15); __pyx_t_15 = NULL;
            }
            __Pyx_INCREF(__pyx_int_0);
            __Pyx_GIVEREF(__pyx_int_0);
            PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_11, __pyx_int_0);
            __Pyx_GIVEREF(__pyx_t_14);
            PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_11, __pyx_t_14);
            __pyx_t_14 = 0;
            __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_16, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 126, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          }
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_12); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 126, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_v_ans = __pyx_t_11;
          goto __pyx_L25;
        }
+127:                 else: ans = depend_on_neighbours(copy_grid[coordinates], generations)
        /*else*/ {
          __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_depend_on_neighbours); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 127, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_16 = __Pyx_PyInt_From_int((__pyx_v_copy_grid[__pyx_v_coordinates])); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 127, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_16);
          __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_generations); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 127, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_15 = NULL;
          __pyx_t_11 = 0;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
            __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_13);
            if (likely(__pyx_t_15)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
              __Pyx_INCREF(__pyx_t_15);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_13, function);
              __pyx_t_11 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_13)) {
            PyObject *__pyx_temp[3] = {__pyx_t_15, __pyx_t_16, __pyx_t_14};
            __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 127, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
            PyObject *__pyx_temp[3] = {__pyx_t_15, __pyx_t_16, __pyx_t_14};
            __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 127, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          } else
          #endif
          {
            __pyx_t_17 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 127, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_17);
            if (__pyx_t_15) {
              __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_15); __pyx_t_15 = NULL;
            }
            __Pyx_GIVEREF(__pyx_t_16);
            PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_11, __pyx_t_16);
            __Pyx_GIVEREF(__pyx_t_14);
            PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_11, __pyx_t_14);
            __pyx_t_16 = 0;
            __pyx_t_14 = 0;
            __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_17, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 127, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          }
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_12); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_v_ans = __pyx_t_11;
        }
        __pyx_L25:;
 128: 
+129:                 if ans == -1:
        __pyx_t_3 = ((__pyx_v_ans == -1L) != 0);
        if (__pyx_t_3) {
/* … */
        }
+130:                     for k in neighbourhood:
          __pyx_t_18 = __pyx_v_neighbourhood.begin();
          for (;;) {
            if (!(__pyx_t_18 != __pyx_v_neighbourhood.end())) break;
            __pyx_t_1 = *__pyx_t_18;
            ++__pyx_t_18;
            __pyx_v_k = __pyx_t_1;
/* … */
          }
+131:                         coordinates2 = pair[int, int] (coordinates.first + k.first,
            try {
              __pyx_t_1 = std::pair<int,int> ((__pyx_v_coordinates.first + __pyx_v_k.first), (__pyx_v_coordinates.second + __pyx_v_k.second));
            } catch(...) {
              __Pyx_CppExn2PyErr();
              __PYX_ERR(0, 131, __pyx_L1_error)
            }
            __pyx_v_coordinates2 = __pyx_t_1;
 132:                                                        coordinates.second + k.second)
+133:                         if copy_grid.find(coordinates2) != copy_grid.end():
            __pyx_t_3 = ((__pyx_v_copy_grid.find(__pyx_v_coordinates2) != __pyx_v_copy_grid.end()) != 0);
            if (__pyx_t_3) {
/* … */
              goto __pyx_L29;
            }
+134:                             neighbours.push_back(copy_grid[coordinates2])
              try {
                __pyx_v_neighbours.push_back((__pyx_v_copy_grid[__pyx_v_coordinates2]));
              } catch(...) {
                __Pyx_CppExn2PyErr();
                __PYX_ERR(0, 134, __pyx_L1_error)
              }
 135:                         else:
+136:                             neighbours.push_back(0)
            /*else*/ {
              try {
                __pyx_v_neighbours.push_back(0);
              } catch(...) {
                __Pyx_CppExn2PyErr();
                __PYX_ERR(0, 136, __pyx_L1_error)
              }
            }
            __pyx_L29:;
 137: 
+138:                 if copy_grid.find(coordinates) != copy_grid.end():
        __pyx_t_3 = ((__pyx_v_copy_grid.find(__pyx_v_coordinates) != __pyx_v_copy_grid.end()) != 0);
        if (__pyx_t_3) {
/* … */
          goto __pyx_L30;
        }
+139:                     neighbours.push_back(copy_grid[coordinates])
          try {
            __pyx_v_neighbours.push_back((__pyx_v_copy_grid[__pyx_v_coordinates]));
          } catch(...) {
            __Pyx_CppExn2PyErr();
            __PYX_ERR(0, 139, __pyx_L1_error)
          }
+140:                     if ans == -1: ans = transition_func(neighbours, generations)
          __pyx_t_3 = ((__pyx_v_ans == -1L) != 0);
          if (__pyx_t_3) {
            __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_transition_func); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 140, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_17 = __pyx_convert_vector_to_py_int(__pyx_v_neighbours); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 140, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_generations); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 140, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            __pyx_t_16 = NULL;
            __pyx_t_11 = 0;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
              __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_13);
              if (likely(__pyx_t_16)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
                __Pyx_INCREF(__pyx_t_16);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_13, function);
                __pyx_t_11 = 1;
              }
            }
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_13)) {
              PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_t_17, __pyx_t_14};
              __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 140, __pyx_L1_error)
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
              PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_t_17, __pyx_t_14};
              __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 140, __pyx_L1_error)
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            } else
            #endif
            {
              __pyx_t_15 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 140, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_16) {
                __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_16); __pyx_t_16 = NULL;
              }
              __Pyx_GIVEREF(__pyx_t_17);
              PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_11, __pyx_t_17);
              __Pyx_GIVEREF(__pyx_t_14);
              PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_11, __pyx_t_14);
              __pyx_t_17 = 0;
              __pyx_t_14 = 0;
              __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 140, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            }
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_12); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 140, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __pyx_v_ans = __pyx_t_11;
          }
+141:                     if ans == 0:
          __pyx_t_3 = ((__pyx_v_ans == 0) != 0);
          if (__pyx_t_3) {
/* … */
            goto __pyx_L32;
          }
+142:                         if dict_grid.find(coordinates) != dict_grid.end(): dict_grid.erase(coordinates)
            __pyx_t_3 = ((__pyx_v_dict_grid.find(__pyx_v_coordinates) != __pyx_v_dict_grid.end()) != 0);
            if (__pyx_t_3) {
              (void)(__pyx_v_dict_grid.erase(__pyx_v_coordinates));
            }
+143:                         cells_changed.insert(coordinates)
            (void)(__pyx_v_cells_changed.insert(__pyx_v_coordinates));
+144:                     elif ans != copy_grid[coordinates]:
          __pyx_t_3 = ((__pyx_v_ans != (__pyx_v_copy_grid[__pyx_v_coordinates])) != 0);
          if (__pyx_t_3) {
/* … */
          }
          __pyx_L32:;
+145:                         dict_grid[coordinates] = ans
            (__pyx_v_dict_grid[__pyx_v_coordinates]) = __pyx_v_ans;
+146:                         cells_changed.insert(coordinates)
            (void)(__pyx_v_cells_changed.insert(__pyx_v_coordinates));
 147:                 else:
+148:                     neighbours.push_back(0)
        /*else*/ {
          try {
            __pyx_v_neighbours.push_back(0);
          } catch(...) {
            __Pyx_CppExn2PyErr();
            __PYX_ERR(0, 148, __pyx_L1_error)
          }
+149:                     if ans == -1: ans = transition_func(neighbours, generations)
          __pyx_t_3 = ((__pyx_v_ans == -1L) != 0);
          if (__pyx_t_3) {
            __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_transition_func); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 149, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_15 = __pyx_convert_vector_to_py_int(__pyx_v_neighbours); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 149, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_15);
            __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_generations); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 149, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            __pyx_t_17 = NULL;
            __pyx_t_11 = 0;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
              __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_13);
              if (likely(__pyx_t_17)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
                __Pyx_INCREF(__pyx_t_17);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_13, function);
                __pyx_t_11 = 1;
              }
            }
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_13)) {
              PyObject *__pyx_temp[3] = {__pyx_t_17, __pyx_t_15, __pyx_t_14};
              __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 149, __pyx_L1_error)
              __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
              PyObject *__pyx_temp[3] = {__pyx_t_17, __pyx_t_15, __pyx_t_14};
              __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 149, __pyx_L1_error)
              __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            } else
            #endif
            {
              __pyx_t_16 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 149, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_16);
              if (__pyx_t_17) {
                __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_17); __pyx_t_17 = NULL;
              }
              __Pyx_GIVEREF(__pyx_t_15);
              PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_11, __pyx_t_15);
              __Pyx_GIVEREF(__pyx_t_14);
              PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_11, __pyx_t_14);
              __pyx_t_15 = 0;
              __pyx_t_14 = 0;
              __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_16, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 149, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            }
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_12); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 149, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __pyx_v_ans = __pyx_t_11;
          }
+150:                     if ans != 0:
          __pyx_t_3 = ((__pyx_v_ans != 0) != 0);
          if (__pyx_t_3) {
/* … */
          }
        }
        __pyx_L30:;
+151:                         dict_grid.insert(pair[pair[int, int], int] (coordinates, ans))
            try {
              __pyx_t_10 = std::pair<std::pair<int,int> ,int> (__pyx_v_coordinates, __pyx_v_ans);
            } catch(...) {
              __Pyx_CppExn2PyErr();
              __PYX_ERR(0, 151, __pyx_L1_error)
            }
            (void)(__pyx_v_dict_grid.insert(__pyx_t_10));
+152:                         cells_changed.insert(coordinates)
            (void)(__pyx_v_cells_changed.insert(__pyx_v_coordinates));
+153:                         if coordinates.second < lower_x:
            __pyx_t_3 = ((__pyx_v_coordinates.second < __pyx_v_lower_x) != 0);
            if (__pyx_t_3) {
/* … */
              goto __pyx_L36;
            }
+154:                             lower_x = coordinates.second
              __pyx_t_11 = __pyx_v_coordinates.second;
              __pyx_v_lower_x = __pyx_t_11;
+155:                         elif coordinates.second > upper_x:
            __pyx_t_3 = ((__pyx_v_coordinates.second > __pyx_v_upper_x) != 0);
            if (__pyx_t_3) {
/* … */
            }
            __pyx_L36:;
+156:                             upper_x = coordinates.second
              __pyx_t_11 = __pyx_v_coordinates.second;
              __pyx_v_upper_x = __pyx_t_11;
 157: 
+158:                         if coordinates.first < lower_y:
            __pyx_t_3 = ((__pyx_v_coordinates.first < __pyx_v_lower_y) != 0);
            if (__pyx_t_3) {
/* … */
              goto __pyx_L37;
            }
+159:                             lower_y = coordinates.first
              __pyx_t_11 = __pyx_v_coordinates.first;
              __pyx_v_lower_y = __pyx_t_11;
+160:                         elif coordinates.first > upper_y:
            __pyx_t_3 = ((__pyx_v_coordinates.first > __pyx_v_upper_y) != 0);
            if (__pyx_t_3) {
/* … */
            }
            __pyx_L37:;
+161:                             upper_y = coordinates.first
              __pyx_t_11 = __pyx_v_coordinates.first;
              __pyx_v_upper_y = __pyx_t_11;
 162: 
+163:                 DP_result.push_back(ans)
        try {
          __pyx_v_DP_result.push_back(__pyx_v_ans);
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 163, __pyx_L1_error)
        }
 164: 
+165:             DP[DP_neighbours] = DP_result
      (__pyx_v_9CACompute_DP[__pyx_v_DP_neighbours]) = __pyx_v_DP_result;
    }
    __pyx_L12:;
 166: 
+167:     return lower_x, upper_x, lower_y, upper_y, cells_changed, dict_grid
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_lower_x); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_upper_x); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_lower_y); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_upper_y); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __pyx_convert_unordered_set_to_py_std_3a__3a_pair_3c_int_2c_int_3e___(__pyx_v_cells_changed); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_17 = __pyx_convert_unordered_map_to_py_std_3a__3a_pair_3c_int_2c_int_3e_______int(__pyx_v_dict_grid); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_19 = PyTuple_New(6); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_16);
  PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_t_16);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_19, 3, __pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_19, 4, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_17);
  PyTuple_SET_ITEM(__pyx_t_19, 5, __pyx_t_17);
  __pyx_t_12 = 0;
  __pyx_t_13 = 0;
  __pyx_t_16 = 0;
  __pyx_t_14 = 0;
  __pyx_t_15 = 0;
  __pyx_t_17 = 0;
  __pyx_r = __pyx_t_19;
  __pyx_t_19 = 0;
  goto __pyx_L0;