How would you handle compression of structured text output in a backend utility? Implement a deterministic compressor that replaces repeated lines with references to their first occurrence when the reference is shorter. Given a list of complete text lines, return a list with the same length, using #REF:<index> for compressed repetitions; input lines never begin with #REF: followed only by digits.
#REF:<digits>def compress_structured_output(lines):