Primes in range
Your task
Count the number of primes in the inclusive range [lo, hi] using a segmented sieve, where 1 <= lo <= hi <= 10^7 and hi - lo <= 10^6. The range can start high (e.g. [9999900, 10000000]) so you must NOT sieve from 0 to hi naively for the whole window; sieve base primes up to sqrt(hi) and mark only the window.
Examples
count_primes_in_range(lo: int, hi: int) -> intExample 1
Input
count_primes_in_range(10, 20)Output
4