C++ Ladder
#include <algorithm>
#include <vector>

std::vector<int> ladder(const std::vector<int>& a, const std::vector<int>& b)
{
    std::size_t size = a.size();
    std::vector<int> r(size, 0);

    int maxB = *std::max_element(b.begin(), b.end());
    long long mod = (1LL << maxB) - 1;

    int maxA = *std::max_element(a.begin(), a.end());
    std::vector<long long> fib(maxA + 2, 0);
    fib[1] = 1;
    for (int i = 2; i < maxA + 2; ++i) {
        fib[i] = (fib[i - 1] + fib[i - 2]) & mod;
    }

    for (std::size_t i = 0; i < size; ++i) {
        r[i] = static_cast<int>(fib[a[i] + 1] & ((1LL << 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.