TypeScript Ladder
function ladder(a: number[], b: number[]): number[] {
  const size = a.length;
  const r: number[] = new Array(size).fill(0);
  const mod = (1 << Math.max(...b)) - 1;

  const fib: number[] = [0, 1];
  const limit = Math.max(...a);
  for (let i = 2; i < limit + 2; i++) {
    fib[i] = (fib[i - 1] + fib[i - 2]) & mod;
  }

  for (let i = 0; i < size; i++) {
    r[i] = fib[a[i] + 1] & ((1 << b[i]) - 1);
  }

  return r;
}

This precomputes climb counts once and applies the modulo per query, which avoids recalculating the same paths over and over.