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

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

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

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

prompt:
Queue capture reverses normal and inverse-clip polarity.

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

split: open-access


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

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

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

prompt:
A second deferred draw overwrites the first pending submission.

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

split: open-access


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

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

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

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

prompt:
Cancellation keeps only the draw requested for removal.

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

split: open-access


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

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

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

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

prompt:
Queued coverage outside a resized target survives into flush.

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

split: open-access