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)
    lanes=set(full)
    results={}
    active=None
    query_enabled=True
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1])&full
        elif op=='lanes': lanes=set(cmd[1])&full
        elif op=='begin': active=cmd[1]; results[active]=0
        elif op=='end': active=None
        elif op=='enable-query': query_enabled=cmd[1]
        elif op in ('draw','conditional'):
            samples=cmd[1]
            if op=='conditional' and (cmd[2]==active or results.get(cmd[2],0)==0): continue
            visible=set(samples)&clip&lanes
            if active is not None and query_enabled: results[active]+=sum(1 for x in samples if x in visible)
        elif op=='read': out.append(None if cmd[1]==active else results.get(cmd[1],0))
    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]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 4), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 4), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 4), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 4), [4])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 5), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 5), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 5), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 5), [5])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 6), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 6), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 6), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 6), [6])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 7), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 7), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 7), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 7), [7])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 8), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 8), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 8), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 8), [8])
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)
    lanes=set(full)
    results={}
    active=None
    query_enabled=True
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1])&full
        elif op=='lanes': lanes=set(cmd[1])&full
        elif op=='begin': active=cmd[1]; results[active]=0
        elif op=='end': active=None
        elif op=='enable-query': query_enabled=cmd[1]
        elif op in ('draw','conditional'):
            samples=cmd[1]
            if op=='conditional' and (cmd[2]==active or results.get(cmd[2],0)==0): continue
            visible=set(samples)&clip&lanes
            if active is not None and query_enabled: results[active]+=len(samples) if visible else 0
        elif op=='read': out.append(None if cmd[1]==active else results.get(cmd[1],0))
    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]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 4), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 4), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 4), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 4), [4])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 5), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 5), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 5), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 5), [5])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 6), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 6), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 6), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 6), [6])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 7), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 7), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 7), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 7), [7])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 8), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 8), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 8), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 8), [8])
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:
Duplicate IDs in one coverage draw are counted as independent raster samples.

Queries count distinct covered sample IDs per draw after path clipping and sample enable masking. Multiple draws accumulate independently, while duplicate sample IDs within one draw count once. Begin resets a named result and activates it; end makes it readable. Result reads while active return null. Conditional draws consult only completed query counts. Disabling queries pauses accumulation without disabling clipping.

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)
    lanes=set(full)
    results={}
    active=None
    query_enabled=True
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1])&full
        elif op=='lanes': lanes=set(cmd[1])&full
        elif op=='begin': active=cmd[1]; results[active]=0
        elif op=='end': active=None
        elif op=='enable-query': query_enabled=cmd[1]
        elif op in ('draw','conditional'):
            samples=cmd[1]
            if op=='conditional' and (cmd[2]==active or results.get(cmd[2],0)==0): continue
            visible=set(samples)&clip&lanes
            if active is not None and query_enabled: results[active]=len(visible)
        elif op=='read': out.append(None if cmd[1]==active else results.get(cmd[1],0))
    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]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 4), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 4), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 4), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 4), [4])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 5), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 5), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 5), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 5), [5])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 6), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 6), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 6), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 6), [6])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 7), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 7), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 7), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 7), [7])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 8), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 8), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 8), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 8), [8])
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)
    lanes=set(full)
    results={}
    active=None
    query_enabled=True
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1])&full
        elif op=='lanes': lanes=set(cmd[1])&full
        elif op=='begin': active=cmd[1]; results[active]=0
        elif op=='end': active=None
        elif op=='enable-query': query_enabled=cmd[1]
        elif op in ('draw','conditional'):
            samples=cmd[1]
            if op=='conditional' and (cmd[2]==active or results.get(cmd[2],0)==0): continue
            visible=set(samples)&clip&lanes
            if active is not None and query_enabled: results[active]=max(results[active],len(visible))
        elif op=='read': out.append(None if cmd[1]==active else results.get(cmd[1],0))
    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]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 4), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 4), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 4), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 4), [4])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 5), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 5), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 5), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 5), [5])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 6), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 6), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 6), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 6), [6])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 7), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 7), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 7), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 7), [7])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 8), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 8), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 8), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 8), [8])
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:
Each draw overwrites the earlier query count.

Queries count distinct covered sample IDs per draw after path clipping and sample enable masking. Multiple draws accumulate independently, while duplicate sample IDs within one draw count once. Begin resets a named result and activates it; end makes it readable. Result reads while active return null. Conditional draws consult only completed query counts. Disabling queries pauses accumulation without disabling clipping.

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)
    lanes=set(full)
    results={}
    active=None
    query_enabled=True
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1])&full
        elif op=='lanes': lanes=set(cmd[1])&full
        elif op=='begin': active=cmd[1]; results.setdefault(active,0)
        elif op=='end': active=None
        elif op=='enable-query': query_enabled=cmd[1]
        elif op in ('draw','conditional'):
            samples=cmd[1]
            if op=='conditional' and (cmd[2]==active or results.get(cmd[2],0)==0): continue
            visible=set(samples)&clip&lanes
            if active is not None and query_enabled: results[active]+=len(visible)
        elif op=='read': out.append(None if cmd[1]==active else results.get(cmd[1],0))
    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]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 4), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 4), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 4), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 4), [4])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 5), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 5), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 5), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 5), [5])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 6), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 6), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 6), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 6), [6])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 7), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 7), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 7), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 7), [7])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 8), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 8), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 8), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 8), [8])
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)
    lanes=set(full)
    results={}
    active=None
    query_enabled=True
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1])&full
        elif op=='lanes': lanes=set(cmd[1])&full
        elif op=='begin': active=cmd[1]; results[active]=results.get(active,0) if active in results else 0
        elif op=='end': active=None
        elif op=='enable-query': query_enabled=cmd[1]
        elif op in ('draw','conditional'):
            samples=cmd[1]
            if op=='conditional' and (cmd[2]==active or results.get(cmd[2],0)==0): continue
            visible=set(samples)&clip&lanes
            if active is not None and query_enabled: results[active]+=len(visible)
        elif op=='read': out.append(None if cmd[1]==active else results.get(cmd[1],0))
    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]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 4), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 4), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 4), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 4), [4])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 5), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 5), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 5), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 5), [5])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 6), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 6), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 6), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 6), [6])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 7), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 7), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 7), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 7), [7])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 8), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 8), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 8), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 8), [8])
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:
Reusing a query name retains its previous completed result.

Queries count distinct covered sample IDs per draw after path clipping and sample enable masking. Multiple draws accumulate independently, while duplicate sample IDs within one draw count once. Begin resets a named result and activates it; end makes it readable. Result reads while active return null. Conditional draws consult only completed query counts. Disabling queries pauses accumulation without disabling clipping.

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)
    lanes=set(full)
    results={}
    active=None
    query_enabled=True
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1])&full
        elif op=='lanes': lanes=set(cmd[1])&full
        elif op=='begin': active=cmd[1]; results[active]=0
        elif op=='end': pass
        elif op=='enable-query': query_enabled=cmd[1]
        elif op in ('draw','conditional'):
            samples=cmd[1]
            if op=='conditional' and (cmd[2]==active or results.get(cmd[2],0)==0): continue
            visible=set(samples)&clip&lanes
            if active is not None and query_enabled: results[active]+=len(visible)
        elif op=='read': out.append(None if cmd[1]==active else results.get(cmd[1],0))
    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]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 4), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 4), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 4), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 4), [4])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 5), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 5), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 5), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 5), [5])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 6), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 6), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 6), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 6), [6])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 7), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 7), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 7), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 7), [7])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 8), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 8), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 8), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 8), [8])
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)
    lanes=set(full)
    results={}
    active=None
    query_enabled=True
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1])&full
        elif op=='lanes': lanes=set(cmd[1])&full
        elif op=='begin': active=cmd[1]; results[active]=0
        elif op=='end': results[active]=0 if active is not None else 0
        elif op=='enable-query': query_enabled=cmd[1]
        elif op in ('draw','conditional'):
            samples=cmd[1]
            if op=='conditional' and (cmd[2]==active or results.get(cmd[2],0)==0): continue
            visible=set(samples)&clip&lanes
            if active is not None and query_enabled: results[active]+=len(visible)
        elif op=='read': out.append(None if cmd[1]==active else results.get(cmd[1],0))
    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]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 4), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 4), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 4), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 4), [4])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 5), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 5), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 5), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 5), [5])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 6), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 6), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 6), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 6), [6])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 7), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 7), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 7), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 7), [7])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 8), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 8), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 8), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 8), [8])
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:
Ending a query leaves it active for subsequent draws.

Queries count distinct covered sample IDs per draw after path clipping and sample enable masking. Multiple draws accumulate independently, while duplicate sample IDs within one draw count once. Begin resets a named result and activates it; end makes it readable. Result reads while active return null. Conditional draws consult only completed query counts. Disabling queries pauses accumulation without disabling clipping.

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)
    lanes=set(full)
    results={}
    active=None
    query_enabled=True
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1])&full
        elif op=='lanes': lanes=set(cmd[1])&full
        elif op=='begin': active=cmd[1]; results[active]=0
        elif op=='end': active=None
        elif op=='enable-query': query_enabled=cmd[1]
        elif op in ('draw','conditional'):
            samples=cmd[1]
            if op=='conditional' and (cmd[2]==active or results.get(cmd[2],0)==0): continue
            visible=set(samples)&clip&lanes
            if active is not None: results[active]+=len(visible)
        elif op=='read': out.append(None if cmd[1]==active else results.get(cmd[1],0))
    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]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 4), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 4), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 4), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 4), [4])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 5), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 5), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 5), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 5), [5])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 6), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 6), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 6), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 6), [6])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 7), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 7), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 7), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 7), [7])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 8), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 8), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 8), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 8), [8])
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)
    lanes=set(full)
    results={}
    active=None
    query_enabled=True
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1])&full
        elif op=='lanes': lanes=set(cmd[1])&full
        elif op=='begin': active=cmd[1]; results[active]=0
        elif op=='end': active=None
        elif op=='enable-query': query_enabled=cmd[1]
        elif op in ('draw','conditional'):
            samples=cmd[1]
            if op=='conditional' and (cmd[2]==active or results.get(cmd[2],0)==0): continue
            visible=set(samples)&clip&lanes
            if active is not None and (query_enabled or not results[active]): results[active]+=len(visible)
        elif op=='read': out.append(None if cmd[1]==active else results.get(cmd[1],0))
    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]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 4), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 4), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 4), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 4), [4])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 5), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 5), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 5), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 5), [5])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 6), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 6), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 6), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 6), [6])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 7), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 7), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 7), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 7), [7])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 8), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 8), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 8), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 8), [8])
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:
Query pause does not stop coverage accumulation.

Queries count distinct covered sample IDs per draw after path clipping and sample enable masking. Multiple draws accumulate independently, while duplicate sample IDs within one draw count once. Begin resets a named result and activates it; end makes it readable. Result reads while active return null. Conditional draws consult only completed query counts. Disabling queries pauses accumulation without disabling clipping.

split: open-access