Given an array of integers arr and an integer d. In one step you can jump from index i to index:

i + x where: i + x < arr.length and  0 < x <= d.
i - x where: i - x >= 0 and  0 < x <= d.

In addition, you can only jump from index i to index j if arr[i] > arr[j] and arr[i] > arr[k] for all indices k between i and j (More formally min(i, j) < k < max(i, j)).
You can choose any index of the array and start jumping. Return the maximum number of indices you can visit.
Notice that you can not jump outside of the array at any time.
 
Example 1:

Input: arr = [6,4,14,6,8,13,9,7,10,6,12], d = 2
Output: 4
Explanation: You can start at index 10. You can jump 10 --> 8 --> 6 --> 7 as shown.
Note that if you start at index 6 you can only jump to index 7. You cannot jump to index 5 because 13 > 9. You cannot jump to index 4 because index 5 is between index 4 and 6 and 13 > 9.
Similarly You cannot jump from index 3 to index 2 or index 1.

Example 2:
Input: arr = [3,3,3,3,3], d = 3
Output: 1
Explanation: You can start at any index. You always cannot jump to any index.

Example 3:
Input: arr = [7,6,5,4,3,2,1], d = 1
Output: 7
Explanation: Start at index 0. You can visit all the indicies. 

Example 4:
Input: arr = [7,1,7,1,7,1], d = 2
Output: 2

Example 5:
Input: arr = [66], d = 1
Output: 1

 
Constraints:

1 <= arr.length <= 1000
1 <= arr[i] <= 10^5
1 <= d <= arr.length

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

def _disabled_input(*args, **kwargs):
    raise RuntimeError("input() is disabled in callable mode")
builtins.input = _disabled_input

ns = {"__name__": "__judge__"}  # prevent if __name__ == "__main__" blocks
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'class Solution:\n    def maxJumps(self, arr: List[int], d: int) -> int:\n        n = len(arr)\n        if(n<=1):\n            return n\n        visited = [False for i in range(n)]\n        L_neighbor = {}\n        R_neighbor = {}\n        #limit = {}\n        \n        for i in range(n):\n            L_neighbor[i] = i\n            R_neighbor[i] = i\n            \n        dec = deque()\n        dec.append(0)\n        for i in range(1, n):\n            while(len(dec)>0):\n                if(dec[0]<i-d):\n                    dec.popleft()\n                else:\n                    break\n            while(len(dec)>0):\n                if(arr[dec[len(dec)-1]]<arr[i]):\n                    dec.pop() \n                else:\n                    break\n            if(len(dec)==0):\n                L_neighbor[i] = max(i-d, 0)\n                dec.append(i)\n            else:\n                L_neighbor[i] = max(dec[len(dec)-1]+1, i-d, 0)\n                dec.append(i)\n        \n        dec = deque()\n        dec.append(n-1)\n        for i in range(n-2, -1, -1):\n            while(len(dec)>0):\n                if(dec[0]>i+d):\n                    dec.popleft()\n                else:\n                    break\n            \n            while(len(dec)>0):\n                if(arr[dec[len(dec)-1]]<arr[i]):\n                    dec.pop()\n                else:\n                    break\n            if(len(dec)==0):\n                R_neighbor[i] = min(i+d, n-1)\n                dec.append(i)\n            else:\n                R_neighbor[i] = min(dec[len(dec)-1]-1, i+d, n-1)\n                dec.append(i)\n        res = 0\n        limit = [0 for i in range(n)]\n        \n        for i in range(n):\n            self.maxJumpDFS(i, arr, L_neighbor, R_neighbor, visited, limit)\n        \n        for i in range(n):\n            if(res<limit[i]):\n                res = limit[i]\n        \n        return res\n      \n    \n    def maxJumpDFS(self, start, arr, L_neighbor, R_neighbor, visited, limit):\n        if(visited[start]):\n            return limit[start]\n        else:\n            currmax = 0\n            for i in range(L_neighbor[start], R_neighbor[start]+1):\n                if(i==start):\n                    continue\n                curr = self.maxJumpDFS(i, arr, L_neighbor, R_neighbor, visited, limit)\n                if(currmax<curr):\n                    currmax = curr\n            visited[start] = True\n            limit[start] = currmax + 1\n            return limit[start]\n                \n                \n            \n        \n        \n        \n        \n        \n        \n        \n        \n                \n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

_target = None
_fn_name = 'maxJumps'
if _fn_name:
    if "Solution" in ns:
        try:
            _obj = ns["Solution"]()
            if hasattr(_obj, _fn_name):
                _target = getattr(_obj, _fn_name)
        except Exception:
            _target = None
    if _target is None and _fn_name in ns and callable(ns[_fn_name]):
        _target = ns[_fn_name]
# Fallback: if there's exactly one user-defined function, use it
if _target is None:
    _cands = [v for k, v in ns.items() if callable(v) and getattr(v, "__module__", "") in ("__judge__", "__main__")]
    _user_funcs = [c for c in _cands if getattr(c, "__name__", "").startswith("_") is False]
    if len(_user_funcs) == 1:
        _target = _user_funcs[0]
if _target is None:
    raise RuntimeError(f"Could not resolve callable '{_fn_name}'")

_raw = sys.stdin.read().strip()
if _raw:
    _parsed = json.loads(_raw)
    if isinstance(_parsed, dict):
        _kwargs = _parsed.get("kwargs", {})
        _args = _parsed.get("args", [])
    else:
        _args, _kwargs = _parsed, {}
else:
    _args, _kwargs = [], {}
if not isinstance(_args, (list, tuple)):
    _args = [_args]
_res = _target(*_args, **_kwargs)
try:
    sys.stdout.write(repr(_res) + "\n")
except Exception:
    pass

```

Measured memory_bytes: 10500