Java Ladder
import java.util.Arrays;

public class Solution {
    public static int[] ladder(int[] a, int[] b) {
        int size = a.length;
        int[] r = new int[size];
        int maxB = Arrays.stream(b).max().orElse(0);
        int mod = (1 << maxB) - 1;

        int maxA = Arrays.stream(a).max().orElse(0);
        int[] fib = new int[maxA + 2];
        fib[0] = 0;
        fib[1] = 1;
        for (int i = 2; i < maxA + 2; i++) {
            fib[i] = (fib[i - 1] + fib[i - 2]) & mod;
        }

        for (int 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.