
import sys

sys.set_int_max_str_digits(0)  # type: ignore
def lowerCamelCase_       (			A			:      int						):




      """simple docstring"""
      lowerCAmelCase_						=      [0] * 11
      lowerCAmelCase_						=      [0] * 11

      # mark last 9 numbers
      for _ in range(9						):
            lowerCAmelCase_						=      1
            lowerCAmelCase_						=      number // 10
      # flag
      lowerCAmelCase_						=      True

      # check last 9 numbers for pandigitality

      for x in range(9						):
            if not check_last[x + 1]:
                  lowerCAmelCase_						=      False
      if not f:
            return f

      # mark first 9 numbers
      lowerCAmelCase_						=      int(str(A						)[:9]						)

      for _ in range(9						):
            lowerCAmelCase_						=      1
            lowerCAmelCase_						=      number // 10

      # check first 9 numbers for pandigitality

      for x in range(9						):
            if not check_front[x + 1]:
                  lowerCAmelCase_						=      False
      return f
def lowerCamelCase_       (			A			:      int						):




      """simple docstring"""
      lowerCAmelCase_						=      [0] * 11

      # mark last 9 numbers
      for _ in range(9						):
            lowerCAmelCase_						=      1
            lowerCAmelCase_						=      number // 10
      # flag
      lowerCAmelCase_						=      True

      # check last 9 numbers for pandigitality

      for x in range(9						):
            if not check_last[x + 1]:
                  lowerCAmelCase_						=      False
      return f
def lowerCamelCase_       (			):




      """simple docstring"""
      lowerCAmelCase_						=      1
      lowerCAmelCase_						=      1
      lowerCAmelCase_						=      2
      # temporary Fibonacci numbers

      lowerCAmelCase_						=      1
      lowerCAmelCase_						=      1
      lowerCAmelCase_						=      2
      # temporary Fibonacci numbers mod 1e9

      # mod m=1e9, done for fast optimisation
      lowerCAmelCase_						=      [0] * 1_00_00_00
      lowerCAmelCase_						=      10_00_00_00_00

      for x in range(1_00_00_00						):
            lowerCAmelCase_						=      (aa + ba) % m
            lowerCAmelCase_						=      ba % m
            lowerCAmelCase_						=      ca % m
            if checka(A						):
                  lowerCAmelCase_						=      1

      for x in range(1_00_00_00						):
            lowerCAmelCase_						=      a + b
            lowerCAmelCase_						=      b
            lowerCAmelCase_						=      c
            # perform check only if in tocheck
            if tocheck[x + 3] and check(A						):
                  return x + 3  # first 2 already done
      return -1


if __name__ == "__main__":
 print(f'''{solution() = }''')






from typing import SupportsIndex

import numpy as np
from scipy.ndimage import convolve







def _a					(			SCREAMING_SNAKE_CASE						:     np.ndarray       ,   SCREAMING_SNAKE_CASE						:     np.ndarray       ,   SCREAMING_SNAKE_CASE						:     np.ndarray						)       ->       np.ndarray:

 """simple docstring"""






 __lowerCAmelCase:  Any        = np.stack((horizontal_flow, vertical_flow)       ,   2						)

 # Create a grid of all pixel coordinates and subtract the flow to get the
 # target pixels coordinates
 __lowerCAmelCase:  List[str]        = np.stack(
     np.meshgrid(np.arange(0       ,   image.shape[1]						)       ,   np.arange(0       ,   image.shape[0]						)						)       ,   2						)
 __lowerCAmelCase:  int        = np.round(grid - flow						).astype(np.intaa						)

 # Find the locations outside of the original image
 __lowerCAmelCase:  Dict        = (grid < 0) | (grid >= np.array([image.shape[1], image.shape[0]]						))
 __lowerCAmelCase:  str        = 0

 __lowerCAmelCase:  List[str]        = image[grid[:, :, 1], grid[:, :, 0]]

 # Set pixels at invalid locations to 0
 __lowerCAmelCase:  List[str]        = 0

 return warped







def _a					(			SCREAMING_SNAKE_CASE						:     np.ndarray       ,   SCREAMING_SNAKE_CASE						:     np.ndarray       ,   SCREAMING_SNAKE_CASE						:     SupportsIndex       ,   SCREAMING_SNAKE_CASE						:     float | None = None       ,   )       ->       tuple[np.ndarray, np.ndarray]:

 """simple docstring"""






 if alpha is None:
  __lowerCAmelCase:  Tuple        = 0.1

 # Initialize flow
 __lowerCAmelCase:  Optional[int]        = np.zeros_like(SCREAMING_SNAKE_CASE						)
 __lowerCAmelCase:  Dict        = np.zeros_like(SCREAMING_SNAKE_CASE						)

 # Prepare kernels for the calculation of the derivatives and the average velocity
 __lowerCAmelCase:  List[Any]        = np.array([[-1, 1], [-1, 1]]						) * 0.2_5
 __lowerCAmelCase:  int        = np.array([[-1, -1], [1, 1]]						) * 0.2_5
 __lowerCAmelCase:  Tuple        = np.array([[1, 1], [1, 1]]						) * 0.2_5
 __lowerCAmelCase:  Dict        = np.array(
     [[1 / 12, 1 / 6, 1 / 12], [1 / 6, 0, 1 / 6], [1 / 12, 1 / 6, 1 / 12]]						)

 # Iteratively refine the flow
 for _ in range(SCREAMING_SNAKE_CASE						):
  __lowerCAmelCase:  Optional[int]        = warp(SCREAMING_SNAKE_CASE       ,   SCREAMING_SNAKE_CASE       ,   SCREAMING_SNAKE_CASE						)
  __lowerCAmelCase:  List[str]        = convolve(SCREAMING_SNAKE_CASE       ,   SCREAMING_SNAKE_CASE						) + convolve(SCREAMING_SNAKE_CASE       ,   SCREAMING_SNAKE_CASE						)
  __lowerCAmelCase:  int        = convolve(SCREAMING_SNAKE_CASE       ,   SCREAMING_SNAKE_CASE						) + convolve(SCREAMING_SNAKE_CASE       ,   SCREAMING_SNAKE_CASE						)
  __lowerCAmelCase:  List[Any]        = convolve(SCREAMING_SNAKE_CASE       ,   SCREAMING_SNAKE_CASE						) + convolve(SCREAMING_SNAKE_CASE       ,   -kernel_t						)

  __lowerCAmelCase:  Any        = convolve(SCREAMING_SNAKE_CASE       ,   SCREAMING_SNAKE_CASE						)
  __lowerCAmelCase:  Dict        = convolve(SCREAMING_SNAKE_CASE       ,   SCREAMING_SNAKE_CASE						)

  # This updates the flow as proposed in the paper (Step 12)
  __lowerCAmelCase:  Tuple        = (
      derivative_x * avg_horizontal_velocity
      + derivative_y * avg_vertical_velocity
      + derivative_t
  )
  __lowerCAmelCase:  int        = update / (alpha**2 + derivative_x**2 + derivative_y**2)

  __lowerCAmelCase:  List[Any]        = avg_horizontal_velocity - derivative_x * update
  __lowerCAmelCase:  Union[str, Any]        = avg_vertical_velocity - derivative_y * update

 return horizontal_flow, vertical_flow


if __name__ == "__main__":
  import doctest

  doctest.testmod()





