Three lessons from this problem:
Block size matters: use or slightly larger to avoid edge cases
Handle same-block queries separately: when and are in the same block, iterate directly
The constant factor is higher than segment trees, but implementation is simpler Sqrt decomposition shines when you need a quick, correct solution. But can you use it for minimum queries too?