Solution (source code)

= Solution

There are $N+1-p$ candidate values in $[p,N+1)$ and exactly $N-k$ occurrences there. If $k\geq p$, then
$$
N-k\leq N-p<N+1-p.
$$
Thus the <pigeonhole principle> gives
$$
\boxed{\text{Some value in }[p,N+1)\text{ is missing.}}
$$
This conclusion does not assert that every value on the lower side is present; duplicates may leave both sides deficient.