broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    clip=set(full)
    coverage=set()
    stack=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip &= set(cmd[1])
        elif op=='replace': clip=set(cmd[1]) & full
        elif op=='begin':
            stack.append((set(clip),set(coverage)))
            clip=set(full)
            coverage=set()
        elif op=='draw': coverage |= set(cmd[1]) & clip
        elif op=='clear': coverage.clear()
        elif op=='end' and stack:
            parent_clip,parent_coverage=stack.pop()
            coverage=parent_coverage | (coverage & parent_clip)
            clip=parent_clip
        elif op=='discard' and stack:
            clip,parent=stack.pop()
            coverage |= parent
        elif op=='inspect': out.append(sorted(coverage))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 4), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 4), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 4), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 4), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 4), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 4), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 4), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 4), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 4), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 4), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 4), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 4), [[0, 1, 2, 3]])
if N == 2:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 5), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 5), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 5), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 5), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 5), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 5), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 5), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 5), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 5), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 5), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 5), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 5), [[0, 1, 2, 3, 4]])
if N == 3:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 6), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 6), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 6), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 6), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 6), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 6), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 6), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 6), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 6), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 6), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 6), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 6), [[0, 1, 2, 3, 4, 5]])
if N == 4:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 7), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 7), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 7), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 7), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 7), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 7), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 7), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 7), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 7), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 7), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 7), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 7), [[0, 1, 2, 3, 4, 5, 6]])
if N == 5:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 8), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 8), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 8), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 8), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 8), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 8), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 8), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 8), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 8), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 8), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 8), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    clip=set(full)
    coverage=set()
    stack=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip &= set(cmd[1])
        elif op=='replace': clip=set(cmd[1]) & full
        elif op=='begin':
            stack.append((set(clip),set(coverage)))
            clip=set(full)
            coverage=set()
        elif op=='draw': coverage |= set(cmd[1]) & clip
        elif op=='clear': coverage.clear()
        elif op=='end' and stack:
            parent_clip,parent_coverage=stack.pop()
            coverage=parent_coverage | (coverage & parent_clip)
            clip=parent_clip
        elif op=='discard' and stack:
            clip,parent=stack.pop()
            coverage=(coverage & clip)|parent
        elif op=='inspect': out.append(sorted(coverage))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 4), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 4), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 4), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 4), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 4), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 4), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 4), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 4), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 4), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 4), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 4), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 4), [[0, 1, 2, 3]])
if N == 2:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 5), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 5), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 5), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 5), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 5), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 5), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 5), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 5), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 5), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 5), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 5), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 5), [[0, 1, 2, 3, 4]])
if N == 3:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 6), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 6), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 6), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 6), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 6), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 6), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 6), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 6), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 6), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 6), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 6), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 6), [[0, 1, 2, 3, 4, 5]])
if N == 4:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 7), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 7), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 7), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 7), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 7), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 7), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 7), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 7), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 7), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 7), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 7), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 7), [[0, 1, 2, 3, 4, 5, 6]])
if N == 5:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 8), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 8), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 8), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 8), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 8), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 8), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 8), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 8), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 8), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 8), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 8), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Discarding a layer leaks its temporary coverage into the parent.

A layer captures the parent clip and starts with its own full local clip. Child drawing accumulates coverage in that layer; layer completion intersects child coverage with the saved parent clip. Discard removes the layer without publishing. A layer-local clear erases only its accumulated coverage. Parent clip edits after opening cannot change the captured parent clip.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    clip=set(full)
    coverage=set()
    stack=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip &= set(cmd[1])
        elif op=='replace': clip=set(cmd[1]) & full
        elif op=='begin':
            stack.append((set(clip),set(coverage)))
            clip=set(full)
            coverage=set()
        elif op=='draw': coverage |= set(cmd[1]) & clip
        elif op=='clear': coverage.clear()
        elif op=='end' and stack:
            parent_clip,parent_coverage=stack.pop(0)
            coverage=parent_coverage | (coverage & parent_clip)
            clip=parent_clip
        elif op=='discard' and stack: clip,coverage=stack.pop()
        elif op=='inspect': out.append(sorted(coverage))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 4), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 4), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 4), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 4), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 4), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 4), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 4), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 4), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 4), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 4), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 4), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 4), [[0, 1, 2, 3]])
if N == 2:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 5), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 5), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 5), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 5), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 5), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 5), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 5), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 5), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 5), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 5), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 5), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 5), [[0, 1, 2, 3, 4]])
if N == 3:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 6), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 6), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 6), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 6), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 6), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 6), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 6), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 6), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 6), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 6), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 6), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 6), [[0, 1, 2, 3, 4, 5]])
if N == 4:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 7), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 7), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 7), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 7), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 7), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 7), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 7), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 7), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 7), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 7), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 7), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 7), [[0, 1, 2, 3, 4, 5, 6]])
if N == 5:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 8), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 8), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 8), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 8), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 8), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 8), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 8), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 8), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 8), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 8), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 8), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    clip=set(full)
    coverage=set()
    stack=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip &= set(cmd[1])
        elif op=='replace': clip=set(cmd[1]) & full
        elif op=='begin':
            stack.append((set(clip),set(coverage)))
            clip=set(full)
            coverage=set()
        elif op=='draw': coverage |= set(cmd[1]) & clip
        elif op=='clear': coverage.clear()
        elif op=='end' and stack:
            parent_clip,parent_coverage=stack.pop(0) if len(stack)>1 else stack.pop()
            coverage=parent_coverage | (coverage & parent_clip)
            clip=parent_clip
        elif op=='discard' and stack: clip,coverage=stack.pop()
        elif op=='inspect': out.append(sorted(coverage))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 4), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 4), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 4), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 4), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 4), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 4), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 4), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 4), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 4), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 4), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 4), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 4), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 4), [[0, 1, 2, 3]])
if N == 2:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 5), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 5), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 5), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 5), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 5), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 5), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 5), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 5), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 5), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 5), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 5), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 5), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 5), [[0, 1, 2, 3, 4]])
if N == 3:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 6), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 6), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 6), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 6), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 6), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 6), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 6), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 6), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 6), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 6), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 6), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 6), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 6), [[0, 1, 2, 3, 4, 5]])
if N == 4:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 7), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 7), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 7), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 7), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 7), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 7), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 7), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 7), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 7), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 7), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 7), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 7), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 7), [[0, 1, 2, 3, 4, 5, 6]])
if N == 5:
    check('explicit sequence 0', solve([['replace', [0]], ['begin'], ['draw', [1]], ['inspect'], ['end'], ['inspect']], 8), [[1], []])
    check('explicit sequence 1', solve([['draw', [0]], ['begin'], ['inspect']], 8), [[]])
    check('explicit sequence 2', solve([['begin'], ['draw', [0]], ['draw', [1]], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [1]], ['draw', [0, 1]], ['inspect']], 8), [[1]])
    check('explicit sequence 4', solve([['begin'], ['draw', [0]], ['clear'], ['draw', [1]], ['inspect']], 8), [[1]])
    check('explicit sequence 5', solve([['replace', [0]], ['begin'], ['draw', [0, 1]], ['end'], ['inspect']], 8), [[0]])
    check('explicit sequence 6', solve([['draw', [0]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 7', solve([['replace', [0]], ['begin'], ['end'], ['draw', [1]], ['inspect']], 8), [[]])
    check('explicit sequence 8', solve([['draw', [0]], ['begin'], ['draw', [1]], ['discard'], ['inspect']], 8), [[0]])
    check('explicit sequence 9', solve([['replace', [0, 1]], ['draw', [0]], ['begin'], ['replace', [1]], ['begin'], ['draw', [1, 2]], ['end'], ['inspect'], ['end'], ['inspect']], 8), [[1], [0, 1]])
    check('explicit sequence 10', solve([['draw', [0]], ['draw', [0, 1]], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 11', solve([['replace', []], ['draw', [0]], ['inspect']], 8), [[]])
    check('explicit sequence 12', solve([['replace', [0]], ['draw', [0]], ['clear'], ['draw', [0, 1]], ['inspect']], 8), [[0]])
    check('explicit sequence 13', solve([['draw', [0]], ['replace', [1]], ['begin'], ['draw', [1]], ['end'], ['inspect']], 8), [[0, 1]])
    check('explicit sequence 14', solve([['replace', []], ['begin'], ['end'], ['draw', [1]], ['inspect']], 8), [[]])
    check('explicit sequence 15', solve([['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['inspect']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Nested layer completion resolves into the outermost parent first.

A layer captures the parent clip and starts with its own full local clip. Child drawing accumulates coverage in that layer; layer completion intersects child coverage with the saved parent clip. Discard removes the layer without publishing. A layer-local clear erases only its accumulated coverage. Parent clip edits after opening cannot change the captured parent clip.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    clip=set(full)
    enabled=True
    inverted=False
    queue=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1]) & full
        elif op=='enable': enabled=cmd[1]
        elif op=='invert': inverted=cmd[1]
        elif op=='submit':
            effective=(full-clip if inverted else clip) if enabled else full
            queue.append((cmd[1],set(cmd[2]) & effective))
        elif op=='cancel': queue=[(k,v) for k,v in queue if k!=cmd[1]]
        elif op=='resize':
            full=set(range(cmd[1]))
            clip &= full
            queue=[(k,v & full) for k,v in queue]
        elif op in ('flush','barrier'):
            out.extend([[k,sorted(v & clip)] for k,v in queue])
            queue=[]
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 4), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 4), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 4), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 4), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 4), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 4), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 4), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 4), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 4), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 4), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 4), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 4), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 4), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 4), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 4), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 4), [['a', [0, 1, 2, 3]]])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 5), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 5), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 5), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 5), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 5), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 5), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 5), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 5), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 5), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 5), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 5), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 5), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 5), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 5), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 5), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 5), [['a', [0, 1, 2, 3, 4]]])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 6), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 6), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 6), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 6), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 6), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 6), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 6), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 6), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 6), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 6), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 6), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 6), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 6), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 6), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 6), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 6), [['a', [0, 1, 2, 3, 4, 5]]])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 7), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 7), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 7), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 7), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 7), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 7), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 7), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 7), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 7), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 7), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 7), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 7), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 7), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 7), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 7), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 7), [['a', [0, 1, 2, 3, 4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 8), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 8), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 8), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 8), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 8), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 8), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 8), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 8), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 8), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 8), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 8), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 8), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 8), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 8), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 8), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 8), [['a', [0, 1, 2, 3, 4, 5, 6, 7]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    clip=set(full)
    enabled=True
    inverted=False
    queue=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1]) & full
        elif op=='enable': enabled=cmd[1]
        elif op=='invert': inverted=cmd[1]
        elif op=='submit':
            effective=(full-clip if inverted else clip) if enabled else full
            queue.append((cmd[1],set(cmd[2]) & effective))
        elif op=='cancel': queue=[(k,v) for k,v in queue if k!=cmd[1]]
        elif op=='resize':
            full=set(range(cmd[1]))
            clip &= full
            queue=[(k,v & full) for k,v in queue]
        elif op in ('flush','barrier'):
            out.extend([[k,sorted(v & clip if enabled else v)] for k,v in queue])
            queue=[]
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 4), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 4), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 4), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 4), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 4), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 4), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 4), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 4), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 4), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 4), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 4), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 4), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 4), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 4), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 4), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 4), [['a', [0, 1, 2, 3]]])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 5), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 5), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 5), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 5), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 5), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 5), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 5), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 5), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 5), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 5), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 5), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 5), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 5), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 5), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 5), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 5), [['a', [0, 1, 2, 3, 4]]])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 6), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 6), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 6), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 6), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 6), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 6), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 6), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 6), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 6), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 6), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 6), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 6), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 6), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 6), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 6), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 6), [['a', [0, 1, 2, 3, 4, 5]]])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 7), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 7), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 7), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 7), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 7), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 7), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 7), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 7), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 7), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 7), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 7), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 7), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 7), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 7), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 7), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 7), [['a', [0, 1, 2, 3, 4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 8), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 8), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 8), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 8), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 8), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 8), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 8), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 8), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 8), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 8), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 8), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 8), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 8), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 8), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 8), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 8), [['a', [0, 1, 2, 3, 4, 5, 6, 7]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Flush clips old submissions with the current clip rather than the submit-time snapshot.

Submission captures coverage, enabled state and clip polarity at enqueue time. Flush emits queued draw samples in order and consumes the queue. Cancel removes matching draw IDs. Barrier flushes but does not reset clip state. A target resize clips queued samples to the new extent without expanding old snapshots.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    clip=set(full)
    enabled=True
    inverted=False
    queue=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1]) & full
        elif op=='enable': enabled=cmd[1]
        elif op=='invert': inverted=cmd[1]
        elif op=='submit':
            effective=(full-clip if inverted else clip) if enabled else set()
            queue.append((cmd[1],set(cmd[2]) & effective))
        elif op=='cancel': queue=[(k,v) for k,v in queue if k!=cmd[1]]
        elif op=='resize':
            full=set(range(cmd[1]))
            clip &= full
            queue=[(k,v & full) for k,v in queue]
        elif op in ('flush','barrier'):
            out.extend([[k,sorted(v)] for k,v in queue])
            queue=[]
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 4), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 4), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 4), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 4), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 4), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 4), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 4), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 4), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 4), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 4), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 4), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 4), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 4), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 4), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 4), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 4), [['a', [0, 1, 2, 3]]])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 5), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 5), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 5), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 5), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 5), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 5), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 5), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 5), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 5), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 5), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 5), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 5), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 5), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 5), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 5), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 5), [['a', [0, 1, 2, 3, 4]]])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 6), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 6), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 6), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 6), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 6), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 6), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 6), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 6), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 6), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 6), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 6), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 6), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 6), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 6), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 6), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 6), [['a', [0, 1, 2, 3, 4, 5]]])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 7), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 7), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 7), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 7), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 7), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 7), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 7), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 7), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 7), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 7), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 7), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 7), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 7), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 7), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 7), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 7), [['a', [0, 1, 2, 3, 4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 8), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 8), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 8), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 8), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 8), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 8), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 8), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 8), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 8), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 8), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 8), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 8), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 8), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 8), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 8), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 8), [['a', [0, 1, 2, 3, 4, 5, 6, 7]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    clip=set(full)
    enabled=True
    inverted=False
    queue=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1]) & full
        elif op=='enable': enabled=cmd[1]
        elif op=='invert': inverted=cmd[1]
        elif op=='submit':
            effective=(full-clip if inverted else clip) if enabled else clip
            queue.append((cmd[1],set(cmd[2]) & effective))
        elif op=='cancel': queue=[(k,v) for k,v in queue if k!=cmd[1]]
        elif op=='resize':
            full=set(range(cmd[1]))
            clip &= full
            queue=[(k,v & full) for k,v in queue]
        elif op in ('flush','barrier'):
            out.extend([[k,sorted(v)] for k,v in queue])
            queue=[]
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 4), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 4), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 4), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 4), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 4), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 4), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 4), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 4), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 4), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 4), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 4), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 4), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 4), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 4), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 4), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 4), [['a', [0, 1, 2, 3]]])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 5), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 5), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 5), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 5), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 5), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 5), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 5), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 5), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 5), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 5), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 5), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 5), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 5), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 5), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 5), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 5), [['a', [0, 1, 2, 3, 4]]])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 6), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 6), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 6), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 6), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 6), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 6), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 6), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 6), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 6), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 6), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 6), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 6), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 6), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 6), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 6), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 6), [['a', [0, 1, 2, 3, 4, 5]]])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 7), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 7), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 7), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 7), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 7), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 7), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 7), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 7), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 7), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 7), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 7), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 7), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 7), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 7), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 7), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 7), [['a', [0, 1, 2, 3, 4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0, 1]], ['submit', 'a', [0, 1]], ['clip', [2]], ['flush']], 8), [['a', [0, 1]]])
    check('explicit sequence 1', solve([['clip', [0]], ['enable', False], ['submit', 'a', [0, 1]], ['flush']], 8), [['a', [0, 1]]])
    check('explicit sequence 2', solve([['clip', [0]], ['invert', True], ['submit', 'a', [0, 1]], ['flush']], 8), [['a', [1]]])
    check('explicit sequence 3', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['flush']], 8), [['a', [0]], ['b', [1]]])
    check('explicit sequence 4', solve([['submit', 'a', [0]], ['submit', 'b', [1]], ['cancel', 'a'], ['flush']], 8), [['b', [1]]])
    check('explicit sequence 5', solve([['submit', 'a', [0, 3]], ['resize', 2], ['flush']], 8), [['a', [0]]])
    check('explicit sequence 6', solve([['clip', [0]], ['resize', 3], ['submit', 'a', [0, 1]], ['flush']], 8), [['a', [0]]])
    check('explicit sequence 7', solve([['submit', 'a', [0]], ['flush'], ['flush']], 8), [['a', [0]]])
    check('explicit sequence 8', solve([['submit', 'a', [0]], ['barrier'], ['cancel', 'a'], ['submit', 'b', [1]], ['flush']], 8), [['a', [0]], ['b', [1]]])
    check('explicit sequence 9', solve([['clip', []], ['submit', 'e', [0]], ['flush']], 8), [['e', []]])
    check('explicit sequence 10', solve([['submit', 'a', [0]], ['submit', 'a', [1]], ['flush']], 8), [['a', [0]], ['a', [1]]])
    check('explicit sequence 11', solve([['clip', []], ['submit', 'a', [0]], ['cancel', 'a'], ['flush']], 8), [])
    check('explicit sequence 12', solve([['submit', 'a', [3]], ['resize', 2], ['flush']], 8), [['a', []]])
    check('explicit sequence 13', solve([['clip', [3]], ['resize', 2], ['submit', 'a', [0]], ['flush']], 8), [['a', []]])
    check('explicit sequence 14', solve([['submit', 'z', [0]], ['submit', 'a', [1]], ['flush']], 8), [['z', [0]], ['a', [1]]])
    check('explicit sequence 15', solve([['submit', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['flush']], 8), [['a', [0, 1, 2, 3, 4, 5, 6, 7]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A disabled clipping test suppresses drawing instead of passing full target coverage.

Submission captures coverage, enabled state and clip polarity at enqueue time. Flush emits queued draw samples in order and consumes the queue. Cancel removes matching draw IDs. Barrier flushes but does not reset clip state. A target resize clips queued samples to the new extent without expanding old snapshots.

split: open-access