The first ID in any unused sequence has used=0 and either no immediate predecessor, or an immediate predecessor where used=1. The last ID of any unused sequence either has no successor or the successor has used=1. So:
1. Find the first first ID of every unused sequence by left joining each row with used=0 to the immediate predecessor row, conditioning the result on the predecessor row not existing or having used=1.
2. As a basis for finding the last ID of every unused sequence that is followed by a row with used=1, left join first unused rows to rows with larger IDs and used=1.
3. As a basis for finding the last ID of an unused sequence which is also the largest ID in the table, left join first unused rows to rows with larger IDs and used=0.
4. For each first unused ID, the last unused ID in its sequence is one less than the smallest used ID greater than the first ID if it exists, otherwise it is the maximum unused ID greater than the first ID.
SELECT firstUnused, IF(mincid IS NULL, IFNULL(did,firstUnused),mincid-1) AS lastUnused
FROM (
SELECT first.id AS firstUnused, MIN(c.id) AS mincid, MAX(d.id) AS did
FROM (
SELECT a.id
FROM tbl a
LEFT JOIN tbl b ON a.id=b.id + 1
WHERE a.used=0 AND (b.id IS NULL OR b.used=1)
) AS first
LEFT JOIN tbl c ON first.id
Thanks to Don Armstrong for finding a case where our previous algorithm failed.