Try this.

select id
from ( select id, code,
lag(code,1) over (partition by id order by code) prev_code1,
lead(code,1) over (partition by id order by code) next_code1,
lead(code,2) over (partition by id order by code) next_code2
from your_table)
where prev_code1 is null
and next_code2 is null
and next_code1 = 202
and code = 201