Binary lifting uses space for the jump table. For large , this might exceed memory limits. You need alternatives that trade space for time. One improvement: compute jumps on-the-fly using recursion with memoization. This trades time for space. You compute jumps as needed rather than precomputing everything.
Cache results to avoid recomputation. Another approach: use square root decomposition. Store jumps for intervals and combine. This reduces space to with slightly worse query time of instead of . Pick based on constraints.