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

N = 1
observations = []
def solve(samples, validity, conceal):
    out=[]
    previous=conceal
    for index,sample in enumerate(samples):
        valid=validity[index] if index<len(validity) else True
        if valid:
            previous=sample
        out.append([sample if valid else previous,bool(valid)])
    return [out,previous]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([1, 9, 3, 8], [True, False, True, False], 0)), [[[1, True], [1, False], [3, True], [3, False]], 3])
check('oracle 2', solve(*([9, 2], [False, True], 7)), [[[7, False], [2, True]], 2])
check('oracle 3', solve(*([1, 2, 3], [True], 0)), [[[1, True], [1, False], [1, False]], 1])
check('oracle 4', solve(*([], [], 4)), [[], 4])
check('oracle 5', solve(*([4, 5], [False, False], -1)), [[[-1, False], [-1, False]], -1])
check('oracle 6', solve(*([1, 2, 3], [False, True, False], 5)), [[[5, False], [2, True], [2, False]], 2])
check('oracle 7', solve(*([0], [True], 8)), [[[0, True]], 0])
if N == 1: check('variant packet 1', solve(*[[1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 2: check('variant packet 2', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 3: check('variant packet 3', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 4: check('variant packet 4', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 5: check('variant packet 5', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
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(samples, validity, conceal):
    out=[]
    previous=conceal
    for index,sample in enumerate(samples):
        valid=validity[index] if index<len(validity) else (validity[-1] if validity else True)
        if valid:
            previous=sample
        out.append([sample if valid else previous,bool(valid)])
    return [out,previous]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([1, 9, 3, 8], [True, False, True, False], 0)), [[[1, True], [1, False], [3, True], [3, False]], 3])
check('oracle 2', solve(*([9, 2], [False, True], 7)), [[[7, False], [2, True]], 2])
check('oracle 3', solve(*([1, 2, 3], [True], 0)), [[[1, True], [1, False], [1, False]], 1])
check('oracle 4', solve(*([], [], 4)), [[], 4])
check('oracle 5', solve(*([4, 5], [False, False], -1)), [[[-1, False], [-1, False]], -1])
check('oracle 6', solve(*([1, 2, 3], [False, True, False], 5)), [[[5, False], [2, True], [2, False]], 2])
check('oracle 7', solve(*([0], [True], 8)), [[[0, True]], 0])
if N == 1: check('variant packet 1', solve(*[[1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 2: check('variant packet 2', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 3: check('variant packet 3', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 4: check('variant packet 4', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 5: check('variant packet 5', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
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:
Uncovered PCM samples are treated as valid despite absent validity metadata.

Decode PCM with a parallel validity vector, missing flags invalid, holding the most recent valid sample for invalid positions while retaining explicit validity metadata.

split: open-access


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

N = 1
observations = []
def solve(samples, validity, conceal):
    out=[]
    previous=conceal
    for index,sample in enumerate(samples):
        valid=validity[index] if index<len(validity) else False
        if not valid:
            previous=sample
        out.append([sample if valid else previous,bool(valid)])
    return [out,previous]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([1, 9, 3, 8], [True, False, True, False], 0)), [[[1, True], [1, False], [3, True], [3, False]], 3])
check('oracle 2', solve(*([9, 2], [False, True], 7)), [[[7, False], [2, True]], 2])
check('oracle 3', solve(*([1, 2, 3], [True], 0)), [[[1, True], [1, False], [1, False]], 1])
check('oracle 4', solve(*([], [], 4)), [[], 4])
check('oracle 5', solve(*([4, 5], [False, False], -1)), [[[-1, False], [-1, False]], -1])
check('oracle 6', solve(*([1, 2, 3], [False, True, False], 5)), [[[5, False], [2, True], [2, False]], 2])
check('oracle 7', solve(*([0], [True], 8)), [[[0, True]], 0])
if N == 1: check('variant packet 1', solve(*[[1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 2: check('variant packet 2', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 3: check('variant packet 3', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 4: check('variant packet 4', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 5: check('variant packet 5', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
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(samples, validity, conceal):
    out=[]
    previous=conceal
    for index,sample in enumerate(samples):
        valid=validity[index] if index<len(validity) else False
        if valid:
            previous=conceal
        out.append([sample if valid else previous,bool(valid)])
    return [out,previous]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([1, 9, 3, 8], [True, False, True, False], 0)), [[[1, True], [1, False], [3, True], [3, False]], 3])
check('oracle 2', solve(*([9, 2], [False, True], 7)), [[[7, False], [2, True]], 2])
check('oracle 3', solve(*([1, 2, 3], [True], 0)), [[[1, True], [1, False], [1, False]], 1])
check('oracle 4', solve(*([], [], 4)), [[], 4])
check('oracle 5', solve(*([4, 5], [False, False], -1)), [[[-1, False], [-1, False]], -1])
check('oracle 6', solve(*([1, 2, 3], [False, True, False], 5)), [[[5, False], [2, True], [2, False]], 2])
check('oracle 7', solve(*([0], [True], 8)), [[[0, True]], 0])
if N == 1: check('variant packet 1', solve(*[[1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 2: check('variant packet 2', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 3: check('variant packet 3', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 4: check('variant packet 4', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 5: check('variant packet 5', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
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:
Invalid PCM amplitude contaminates the hold-last-valid concealment state.

Decode PCM with a parallel validity vector, missing flags invalid, holding the most recent valid sample for invalid positions while retaining explicit validity metadata.

split: open-access


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

N = 1
observations = []
def solve(samples, validity, conceal):
    out=[]
    previous=conceal
    for index,sample in enumerate(samples):
        valid=validity[index] if index<len(validity) else False
        if valid:
            previous=sample
        out.append([sample,bool(valid)])
    return [out,previous]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([1, 9, 3, 8], [True, False, True, False], 0)), [[[1, True], [1, False], [3, True], [3, False]], 3])
check('oracle 2', solve(*([9, 2], [False, True], 7)), [[[7, False], [2, True]], 2])
check('oracle 3', solve(*([1, 2, 3], [True], 0)), [[[1, True], [1, False], [1, False]], 1])
check('oracle 4', solve(*([], [], 4)), [[], 4])
check('oracle 5', solve(*([4, 5], [False, False], -1)), [[[-1, False], [-1, False]], -1])
check('oracle 6', solve(*([1, 2, 3], [False, True, False], 5)), [[[5, False], [2, True], [2, False]], 2])
check('oracle 7', solve(*([0], [True], 8)), [[[0, True]], 0])
if N == 1: check('variant packet 1', solve(*[[1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 2: check('variant packet 2', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 3: check('variant packet 3', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 4: check('variant packet 4', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 5: check('variant packet 5', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
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(samples, validity, conceal):
    out=[]
    previous=conceal
    for index,sample in enumerate(samples):
        valid=validity[index] if index<len(validity) else False
        if valid:
            previous=sample
        out.append([sample if valid else conceal,bool(valid)])
    return [out,previous]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([1, 9, 3, 8], [True, False, True, False], 0)), [[[1, True], [1, False], [3, True], [3, False]], 3])
check('oracle 2', solve(*([9, 2], [False, True], 7)), [[[7, False], [2, True]], 2])
check('oracle 3', solve(*([1, 2, 3], [True], 0)), [[[1, True], [1, False], [1, False]], 1])
check('oracle 4', solve(*([], [], 4)), [[], 4])
check('oracle 5', solve(*([4, 5], [False, False], -1)), [[[-1, False], [-1, False]], -1])
check('oracle 6', solve(*([1, 2, 3], [False, True, False], 5)), [[[5, False], [2, True], [2, False]], 2])
check('oracle 7', solve(*([0], [True], 8)), [[[0, True]], 0])
if N == 1: check('variant packet 1', solve(*[[1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 2: check('variant packet 2', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 3: check('variant packet 3', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 4: check('variant packet 4', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 5: check('variant packet 5', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
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:
Invalid PCM samples bypass the hold-last-valid policy.

Decode PCM with a parallel validity vector, missing flags invalid, holding the most recent valid sample for invalid positions while retaining explicit validity metadata.

split: open-access


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

N = 1
observations = []
def solve(samples, validity, conceal):
    out=[]
    previous=conceal
    for index,sample in enumerate(samples):
        valid=validity[0] if index<len(validity) else False
        if valid:
            previous=sample
        out.append([sample if valid else previous,bool(valid)])
    return [out,previous]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([1, 9, 3, 8], [True, False, True, False], 0)), [[[1, True], [1, False], [3, True], [3, False]], 3])
check('oracle 2', solve(*([9, 2], [False, True], 7)), [[[7, False], [2, True]], 2])
check('oracle 3', solve(*([1, 2, 3], [True], 0)), [[[1, True], [1, False], [1, False]], 1])
check('oracle 4', solve(*([], [], 4)), [[], 4])
check('oracle 5', solve(*([4, 5], [False, False], -1)), [[[-1, False], [-1, False]], -1])
check('oracle 6', solve(*([1, 2, 3], [False, True, False], 5)), [[[5, False], [2, True], [2, False]], 2])
check('oracle 7', solve(*([0], [True], 8)), [[[0, True]], 0])
if N == 1: check('variant packet 1', solve(*[[1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 2: check('variant packet 2', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 3: check('variant packet 3', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 4: check('variant packet 4', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 5: check('variant packet 5', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
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(samples, validity, conceal):
    out=[]
    previous=conceal
    for index,sample in enumerate(samples):
        valid=validity[-1-index] if index<len(validity) else False
        if valid:
            previous=sample
        out.append([sample if valid else previous,bool(valid)])
    return [out,previous]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([1, 9, 3, 8], [True, False, True, False], 0)), [[[1, True], [1, False], [3, True], [3, False]], 3])
check('oracle 2', solve(*([9, 2], [False, True], 7)), [[[7, False], [2, True]], 2])
check('oracle 3', solve(*([1, 2, 3], [True], 0)), [[[1, True], [1, False], [1, False]], 1])
check('oracle 4', solve(*([], [], 4)), [[], 4])
check('oracle 5', solve(*([4, 5], [False, False], -1)), [[[-1, False], [-1, False]], -1])
check('oracle 6', solve(*([1, 2, 3], [False, True, False], 5)), [[[5, False], [2, True], [2, False]], 2])
check('oracle 7', solve(*([0], [True], 8)), [[[0, True]], 0])
if N == 1: check('variant packet 1', solve(*[[1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 2: check('variant packet 2', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 3: check('variant packet 3', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 4: check('variant packet 4', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 5: check('variant packet 5', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
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:
All PCM samples use the first validity flag.

Decode PCM with a parallel validity vector, missing flags invalid, holding the most recent valid sample for invalid positions while retaining explicit validity metadata.

split: open-access


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

N = 1
observations = []
def solve(samples, validity, conceal):
    out=[]
    previous=conceal
    for index,sample in enumerate(samples):
        valid=validity[index] if index<len(validity) else False
        if valid:
            previous=sample
        out.append([sample if valid else previous,bool(valid)])
    return [out,conceal]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([1, 9, 3, 8], [True, False, True, False], 0)), [[[1, True], [1, False], [3, True], [3, False]], 3])
check('oracle 2', solve(*([9, 2], [False, True], 7)), [[[7, False], [2, True]], 2])
check('oracle 3', solve(*([1, 2, 3], [True], 0)), [[[1, True], [1, False], [1, False]], 1])
check('oracle 4', solve(*([], [], 4)), [[], 4])
check('oracle 5', solve(*([4, 5], [False, False], -1)), [[[-1, False], [-1, False]], -1])
check('oracle 6', solve(*([1, 2, 3], [False, True, False], 5)), [[[5, False], [2, True], [2, False]], 2])
check('oracle 7', solve(*([0], [True], 8)), [[[0, True]], 0])
if N == 1: check('variant packet 1', solve(*[[1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 2: check('variant packet 2', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 3: check('variant packet 3', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 4: check('variant packet 4', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 5: check('variant packet 5', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
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(samples, validity, conceal):
    out=[]
    previous=conceal
    for index,sample in enumerate(samples):
        valid=validity[index] if index<len(validity) else False
        if valid:
            previous=sample
        out.append([sample if valid else previous,bool(valid)])
    return [out,samples[-1] if samples else conceal]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([1, 9, 3, 8], [True, False, True, False], 0)), [[[1, True], [1, False], [3, True], [3, False]], 3])
check('oracle 2', solve(*([9, 2], [False, True], 7)), [[[7, False], [2, True]], 2])
check('oracle 3', solve(*([1, 2, 3], [True], 0)), [[[1, True], [1, False], [1, False]], 1])
check('oracle 4', solve(*([], [], 4)), [[], 4])
check('oracle 5', solve(*([4, 5], [False, False], -1)), [[[-1, False], [-1, False]], -1])
check('oracle 6', solve(*([1, 2, 3], [False, True, False], 5)), [[[5, False], [2, True], [2, False]], 2])
check('oracle 7', solve(*([0], [True], 8)), [[[0, True]], 0])
if N == 1: check('variant packet 1', solve(*[[1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 2: check('variant packet 2', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 3: check('variant packet 3', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 4: check('variant packet 4', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
if N == 5: check('variant packet 5', solve(*[[1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8, 1, 9, 3, 8], [True, False, True, False], 0]), [[[1, True], [1, False], [3, True], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False], [3, False]], 3])
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:
Continuation loses the most recent valid PCM amplitude.

Decode PCM with a parallel validity vector, missing flags invalid, holding the most recent valid sample for invalid positions while retaining explicit validity metadata.

split: open-access


prompt:
An adaptive PCM block omits its literal seed sample from presentation.

Decode independent seeded differential PCM blocks; seed is the first presented sample and declared sample count includes it, excluding padded residuals.

split: open-access


prompt:
Adaptive block reconstruction ignores its encoded anchor.

Decode independent seeded differential PCM blocks; seed is the first presented sample and declared sample count includes it, excluding padded residuals.

split: open-access


prompt:
Every residual is anchored directly to block seed.

Decode independent seeded differential PCM blocks; seed is the first presented sample and declared sample count includes it, excluding padded residuals.

split: open-access


prompt:
Declared block sample count is interpreted as excluding its seed.

Decode independent seeded differential PCM blocks; seed is the first presented sample and declared sample count includes it, excluding padded residuals.

split: open-access


prompt:
Later independently seeded blocks replace earlier PCM.

Decode independent seeded differential PCM blocks; seed is the first presented sample and declared sample count includes it, excluding padded residuals.

split: open-access


prompt:
An escaped absolute PCM anchor is added as a residual.

Decode a stipulated PCM residual stream with an escape token followed by an absolute sample anchor; report a dangling escape without losing valid prefix state.

split: open-access


prompt:
Escaped literal is decoded again as the next residual token.

Decode a stipulated PCM residual stream with an escape token followed by an absolute sample anchor; report a dangling escape without losing valid prefix state.

split: open-access


prompt:
A dangling PCM escape is falsely reported as a complete packet.

Decode a stipulated PCM residual stream with an escape token followed by an absolute sample anchor; report a dangling escape without losing valid prefix state.

split: open-access


prompt:
Ordinary residual replaces PCM amplitude rather than updating it.

Decode a stipulated PCM residual stream with an escape token followed by an absolute sample anchor; report a dangling escape without losing valid prefix state.

split: open-access


prompt:
Out-of-band residual values are incorrectly treated as escape symbols.

Decode a stipulated PCM residual stream with an escape token followed by an absolute sample anchor; report a dangling escape without losing valid prefix state.

split: open-access


prompt:
LPC coefficients see oldest-first PCM history instead of newest-first.

Reconstruct bounded integer PCM LPC residuals using newest-first history, floor-divided complete dot products and reconstructed-sample history feedback.

split: open-access


prompt:
Per-tap rounding changes the integer LPC prediction.

Reconstruct bounded integer PCM LPC residuals using newest-first history, floor-divided complete dot products and reconstructed-sample history feedback.

split: open-access


prompt:
LPC residual sign is inverted.

Reconstruct bounded integer PCM LPC residuals using newest-first history, floor-divided complete dot products and reconstructed-sample history feedback.

split: open-access


prompt:
Newest PCM sample is appended to oldest-first position.

Reconstruct bounded integer PCM LPC residuals using newest-first history, floor-divided complete dot products and reconstructed-sample history feedback.

split: open-access


prompt:
LPC decoder feeds residual instead of reconstructed sample into history.

Reconstruct bounded integer PCM LPC residuals using newest-first history, floor-divided complete dot products and reconstructed-sample history feedback.

split: open-access


prompt:
PCM partition seeds apply to continuation partitions instead of reset partitions.

PCM residual partitions optionally replace predictor with an absolute seed; continuation partitions ignore their seed field and empty partitions retain state transitions.

split: open-access


prompt:
An absolute partition predictor seed is added to old state.

PCM residual partitions optionally replace predictor with an absolute seed; continuation partitions ignore their seed field and empty partitions retain state transitions.

split: open-access


prompt:
Empty seeded partitions fabricate an audible sample.

PCM residual partitions optionally replace predictor with an absolute seed; continuation partitions ignore their seed field and empty partitions retain state transitions.

split: open-access


prompt:
Residual sign is reversed inside PCM partitions.

PCM residual partitions optionally replace predictor with an absolute seed; continuation partitions ignore their seed field and empty partitions retain state transitions.

split: open-access


prompt:
Reconstructed sample order reverses inside each partition.

PCM residual partitions optionally replace predictor with an absolute seed; continuation partitions ignore their seed field and empty partitions retain state transitions.

split: open-access


prompt:
Extra warmup samples are accepted despite exact predictor-order framing.

Decode fixed-order PCM packets with exactly one or two chronological warmup samples, followed by residuals for hold or linear-extrapolation prediction.

split: open-access


prompt:
Oldest warmup sample becomes newest predictor state.

Decode fixed-order PCM packets with exactly one or two chronological warmup samples, followed by residuals for hold or linear-extrapolation prediction.

split: open-access


prompt:
Literal warmup PCM samples are omitted from output.

Decode fixed-order PCM packets with exactly one or two chronological warmup samples, followed by residuals for hold or linear-extrapolation prediction.

split: open-access


prompt:
Second-order PCM prediction sums history rather than extrapolating slope.

Decode fixed-order PCM packets with exactly one or two chronological warmup samples, followed by residuals for hold or linear-extrapolation prediction.

split: open-access


prompt:
Warmup predictor later stores residuals instead of reconstructed amplitudes.

Decode fixed-order PCM packets with exactly one or two chronological warmup samples, followed by residuals for hold or linear-extrapolation prediction.

split: open-access


prompt:
PCM line-code boundary checks the end of the bit cell rather than its first half.

Decode stipulated biphase-mark PCM transport cells: every cell must transition at its start, midcell transition is one, and final physical level carries across packets.

split: open-access


prompt:
Biphase PCM payload interprets midcell transition as zero.

Decode stipulated biphase-mark PCM transport cells: every cell must transition at its start, midcell transition is one, and final physical level carries across packets.

split: open-access


prompt:
Decoder tracks first-half level instead of final cell level.

Decode stipulated biphase-mark PCM transport cells: every cell must transition at its start, midcell transition is one, and final physical level carries across packets.

split: open-access


prompt:
PCM payload value is confused with line-code validity.

Decode stipulated biphase-mark PCM transport cells: every cell must transition at its start, midcell transition is one, and final physical level carries across packets.

split: open-access


prompt:
Biphase continuation returns obsolete packet start level.

Decode stipulated biphase-mark PCM transport cells: every cell must transition at its start, midcell transition is one, and final physical level carries across packets.

split: open-access


prompt:
PCM line encoder omits mandatory bit-cell boundary transitions.

Encode PCM transport payload bits as stipulated biphase-mark half-cells with mandatory boundary transitions and explicit initial/final physical levels.

split: open-access


prompt:
Payload transition convention is inverted.

Encode PCM transport payload bits as stipulated biphase-mark half-cells with mandatory boundary transitions and explicit initial/final physical levels.

split: open-access


prompt:
PCM wire half-cells are transmitted in reverse temporal order.

Encode PCM transport payload bits as stipulated biphase-mark half-cells with mandatory boundary transitions and explicit initial/final physical levels.

split: open-access


prompt:
Encoder phase state tracks the wrong half-cell.

Encode PCM transport payload bits as stipulated biphase-mark half-cells with mandatory boundary transitions and explicit initial/final physical levels.

split: open-access


prompt:
Continuation phase is reset between PCM transport packets.

Encode PCM transport payload bits as stipulated biphase-mark half-cells with mandatory boundary transitions and explicit initial/final physical levels.

split: open-access


prompt:
An all-zero PCM block advertises arbitrary maximum wasted precision instead of canonical zero shift.

Losslessly factor the largest capped common trailing-zero count from signed PCM samples; zero samples do not constrain the count and all-silence blocks canonically use zero.

split: open-access


prompt:
One divisible PCM sample permits destructive shifting of another sample.

Losslessly factor the largest capped common trailing-zero count from signed PCM samples; zero samples do not constrain the count and all-silence blocks canonically use zero.

split: open-access


prompt:
Wasted-bit field exceeds its declared maximum.

Losslessly factor the largest capped common trailing-zero count from signed PCM samples; zero samples do not constrain the count and all-silence blocks canonically use zero.

split: open-access


prompt:
Removing common zero bits drops PCM polarity.

Losslessly factor the largest capped common trailing-zero count from signed PCM samples; zero samples do not constrain the count and all-silence blocks canonically use zero.

split: open-access


prompt:
Negative samples do not constrain common wasted-bit selection.

Losslessly factor the largest capped common trailing-zero count from signed PCM samples; zero samples do not constrain the count and all-silence blocks canonically use zero.

split: open-access


prompt:
Reversible interchannel PCM coding loses its literal first-channel anchor.

Losslessly represent each PCM frame as a first-channel anchor followed by differences from immediately preceding original channels; preserve empty and mono frames.

split: open-access


prompt:
Adjacent-channel lifting always references first channel instead of its immediate predecessor.

Losslessly represent each PCM frame as a first-channel anchor followed by differences from immediately preceding original channels; preserve empty and mono frames.

split: open-access


prompt:
Interchannel lifting feeds an encoded residual back as source amplitude.

Losslessly represent each PCM frame as a first-channel anchor followed by differences from immediately preceding original channels; preserve empty and mono frames.

split: open-access


prompt:
The literal anchor is also encoded as a residual, adding a channel.

Losslessly represent each PCM frame as a first-channel anchor followed by differences from immediately preceding original channels; preserve empty and mono frames.

split: open-access


prompt:
An empty channel frame invents a silence channel.

Losslessly represent each PCM frame as a first-channel anchor followed by differences from immediately preceding original channels; preserve empty and mono frames.

split: open-access


prompt:
Extra encoded channel blocks are accepted as a valid PCM layout.

Assemble independently decoded adaptive PCM channel blocks into complete frames, returning per-channel unconsumed tails; require exact channel descriptors.

split: open-access


prompt:
Output frame count is based on longest channel block, exposing missing samples.

Assemble independently decoded adaptive PCM channel blocks into complete frames, returning per-channel unconsumed tails; require exact channel descriptors.

split: open-access


prompt:
Independently decoded channel blocks are assigned reversed PCM destinations.

Assemble independently decoded adaptive PCM channel blocks into complete frames, returning per-channel unconsumed tails; require exact channel descriptors.

split: open-access


prompt:
Unconsumed channel tails are replaced by consumed prefixes.

Assemble independently decoded adaptive PCM channel blocks into complete frames, returning per-channel unconsumed tails; require exact channel descriptors.

split: open-access


prompt:
Complete decoded PCM frames are emitted in reverse temporal order.

Assemble independently decoded adaptive PCM channel blocks into complete frames, returning per-channel unconsumed tails; require exact channel descriptors.

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
    stack=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        mask=set(cmd[1]) & full if len(cmd)>1 else set()
        if op=='save': stack.append((clip,enabled))
        elif op=='restore':
            if stack: clip,enabled=stack.pop()
        elif op=='intersect': clip &= mask
        elif op=='exclude': clip -= mask
        elif op=='union': clip |= mask
        elif op=='replace': clip=set(mask)
        elif op=='invert': clip=full-clip
        elif op=='reset': clip=set(full)
        elif op=='disable': enabled=False
        elif op=='enable': enabled=True
        elif op=='draw': out.append(sorted(clip if enabled else full))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 4), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 4), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 4), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 4), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 4), [[2], [0, 1, 3], [0, 1, 2, 3]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 4), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 4), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 4), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 4), [[]])
if N == 2:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 5), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 5), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 5), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 5), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 5), [[2], [0, 1, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 5), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 5), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 5), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 5), [[]])
if N == 3:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 6), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 6), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 6), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 6), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 6), [[2], [0, 1, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 6), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 6), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 6), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 6), [[]])
if N == 4:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 7), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 7), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 7), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 7), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 7), [[2], [0, 1, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 7), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 7), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 7), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 7), [[]])
if N == 5:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 8), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 8), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 8), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 8), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 8), [[2], [0, 1, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 8), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 8), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 8), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 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)
    enabled=True
    stack=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        mask=set(cmd[1]) & full if len(cmd)>1 else set()
        if op=='save': stack.append((set(clip),True))
        elif op=='restore':
            if stack: clip,enabled=stack.pop()
        elif op=='intersect': clip &= mask
        elif op=='exclude': clip -= mask
        elif op=='union': clip |= mask
        elif op=='replace': clip=set(mask)
        elif op=='invert': clip=full-clip
        elif op=='reset': clip=set(full)
        elif op=='disable': enabled=False
        elif op=='enable': enabled=True
        elif op=='draw': out.append(sorted(clip if enabled else full))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 4), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 4), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 4), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 4), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 4), [[2], [0, 1, 3], [0, 1, 2, 3]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 4), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 4), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 4), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 4), [[]])
if N == 2:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 5), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 5), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 5), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 5), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 5), [[2], [0, 1, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 5), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 5), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 5), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 5), [[]])
if N == 3:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 6), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 6), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 6), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 6), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 6), [[2], [0, 1, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 6), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 6), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 6), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 6), [[]])
if N == 4:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 7), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 7), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 7), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 7), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 7), [[2], [0, 1, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 7), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 7), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 7), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 7), [[]])
if N == 5:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 8), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 8), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 8), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 8), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 8), [[2], [0, 1, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 8), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 8), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 8), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 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:
Saving aliases the mutable clip so later in-place intersections corrupt the saved region.

Commands act on finite sample indices [0,size). Save/restore includes the clip-enable bit; region edits update stored coverage even while clipping is disabled. Restore underflow is inert. Draw emits sorted effective samples.

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
    stack=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        mask=set(cmd[1]) & full if len(cmd)>1 else set()
        if op=='save': stack.append((set(clip),enabled))
        elif op=='restore':
            if stack: clip,enabled=stack.pop(0)
        elif op=='intersect': clip &= mask
        elif op=='exclude': clip -= mask
        elif op=='union': clip |= mask
        elif op=='replace': clip=set(mask)
        elif op=='invert': clip=full-clip
        elif op=='reset': clip=set(full)
        elif op=='disable': enabled=False
        elif op=='enable': enabled=True
        elif op=='draw': out.append(sorted(clip if enabled else full))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 4), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 4), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 4), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 4), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 4), [[2], [0, 1, 3], [0, 1, 2, 3]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 4), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 4), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 4), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 4), [[]])
if N == 2:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 5), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 5), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 5), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 5), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 5), [[2], [0, 1, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 5), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 5), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 5), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 5), [[]])
if N == 3:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 6), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 6), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 6), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 6), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 6), [[2], [0, 1, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 6), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 6), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 6), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 6), [[]])
if N == 4:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 7), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 7), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 7), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 7), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 7), [[2], [0, 1, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 7), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 7), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 7), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 7), [[]])
if N == 5:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 8), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 8), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 8), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 8), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 8), [[2], [0, 1, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 8), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 8), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 8), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 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)
    enabled=True
    stack=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        mask=set(cmd[1]) & full if len(cmd)>1 else set()
        if op=='save': stack.append((set(clip),enabled))
        elif op=='restore':
            if stack: clip,enabled=stack.pop(0) if len(stack)>1 else stack.pop()
        elif op=='intersect': clip &= mask
        elif op=='exclude': clip -= mask
        elif op=='union': clip |= mask
        elif op=='replace': clip=set(mask)
        elif op=='invert': clip=full-clip
        elif op=='reset': clip=set(full)
        elif op=='disable': enabled=False
        elif op=='enable': enabled=True
        elif op=='draw': out.append(sorted(clip if enabled else full))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 4), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 4), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 4), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 4), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 4), [[2], [0, 1, 3], [0, 1, 2, 3]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 4), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 4), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 4), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 4), [[]])
if N == 2:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 5), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 5), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 5), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 5), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 5), [[2], [0, 1, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 5), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 5), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 5), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 5), [[]])
if N == 3:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 6), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 6), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 6), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 6), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 6), [[2], [0, 1, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 6), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 6), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 6), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 6), [[]])
if N == 4:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 7), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 7), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 7), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 7), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 7), [[2], [0, 1, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 7), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 7), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 7), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 7), [[]])
if N == 5:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 8), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 8), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 8), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 8), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 8), [[2], [0, 1, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 8), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 8), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 8), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 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:
Nested restore retrieves the oldest saved clip instead of the nearest enclosing scope.

Commands act on finite sample indices [0,size). Save/restore includes the clip-enable bit; region edits update stored coverage even while clipping is disabled. Restore underflow is inert. Draw emits sorted effective samples.

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
    stack=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        mask=set(cmd[1]) & full if len(cmd)>1 else set()
        if op=='save': stack.append((set(clip),enabled))
        elif op=='restore':
            if stack: clip,_=stack.pop()
        elif op=='intersect': clip &= mask
        elif op=='exclude': clip -= mask
        elif op=='union': clip |= mask
        elif op=='replace': clip=set(mask)
        elif op=='invert': clip=full-clip
        elif op=='reset': clip=set(full)
        elif op=='disable': enabled=False
        elif op=='enable': enabled=True
        elif op=='draw': out.append(sorted(clip if enabled else full))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 4), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 4), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 4), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 4), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 4), [[2], [0, 1, 3], [0, 1, 2, 3]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 4), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 4), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 4), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 4), [[]])
if N == 2:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 5), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 5), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 5), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 5), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 5), [[2], [0, 1, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 5), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 5), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 5), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 5), [[]])
if N == 3:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 6), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 6), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 6), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 6), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 6), [[2], [0, 1, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 6), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 6), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 6), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 6), [[]])
if N == 4:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 7), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 7), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 7), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 7), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 7), [[2], [0, 1, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 7), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 7), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 7), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 7), [[]])
if N == 5:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 8), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 8), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 8), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 8), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 8), [[2], [0, 1, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 8), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 8), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 8), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 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)
    enabled=True
    stack=[]
    out=[]
    for cmd in commands:
        op=cmd[0]
        mask=set(cmd[1]) & full if len(cmd)>1 else set()
        if op=='save': stack.append((set(clip),enabled))
        elif op=='restore':
            if stack: clip,_=stack.pop(); enabled=True
        elif op=='intersect': clip &= mask
        elif op=='exclude': clip -= mask
        elif op=='union': clip |= mask
        elif op=='replace': clip=set(mask)
        elif op=='invert': clip=full-clip
        elif op=='reset': clip=set(full)
        elif op=='disable': enabled=False
        elif op=='enable': enabled=True
        elif op=='draw': out.append(sorted(clip if enabled else full))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 4), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 4), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 4), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 4), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 4), [[2], [0, 1, 3], [0, 1, 2, 3]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 4), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 4), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 4), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 4), [[]])
if N == 2:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 5), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 5), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 5), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 5), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 5), [[2], [0, 1, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 5), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 5), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 5), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 5), [[]])
if N == 3:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 6), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 6), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 6), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 6), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 6), [[2], [0, 1, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 6), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 6), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 6), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 6), [[]])
if N == 4:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 7), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 7), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 7), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 7), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 7), [[2], [0, 1, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 7), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 7), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 7), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 7), [[]])
if N == 5:
    check('explicit sequence 0', solve([['replace', [0, 1, 2]], ['save'], ['exclude', [1]], ['draw'], ['restore'], ['draw']], 8), [[0, 2], [0, 1, 2]])
    check('explicit sequence 1', solve([['replace', [0]], ['save'], ['replace', [1]], ['save'], ['replace', [2]], ['restore'], ['draw'], ['restore'], ['draw']], 8), [[1], [0]])
    check('explicit sequence 2', solve([['replace', [0]], ['disable'], ['save'], ['enable'], ['restore'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 3', solve([['replace', [1, 2]], ['disable'], ['enable'], ['draw']], 8), [[1, 2]])
    check('explicit sequence 4', solve([['replace', [0]], ['exclude', [2]], ['draw'], ['union', [0, 2]], ['draw']], 8), [[0], [0, 2]])
    check('explicit sequence 5', solve([['replace', [1]], ['replace', [2]], ['draw'], ['invert'], ['draw'], ['reset'], ['draw']], 8), [[2], [0, 1, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 6', solve([['restore'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 7', solve([['replace', []], ['draw']], 8), [[]])
    check('explicit sequence 8', solve([['disable'], ['replace', [0, 2, 8]], ['enable'], ['draw']], 8), [[0, 2]])
    check('explicit sequence 9', solve([['reset'], ['replace', [0]], ['draw']], 8), [[0]])
    check('explicit sequence 10', solve([['replace', []], ['disable'], ['enable'], ['draw']], 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:
Restoring a clip scope fails to restore its enable state.

Commands act on finite sample indices [0,size). Save/restore includes the clip-enable bit; region edits update stored coverage even while clipping is disabled. Restore underflow is inert. Draw emits sorted effective samples.

split: open-access