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

N = 1
observations = []
def solve(preset, scans):
    acc = 0
    dn = False
    prev = False
    out = []
    for en, res, dt in scans:
        en = bool(en)
        if res:
            acc = 0
            dn = False
        if en:
            if prev:
                acc = min(preset, acc + dt)
            if acc >= preset:
                dn = True
        prev = en
        out.append([dn, acc])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: scenario 5',
   [0,
    [[True, False, 20],
     [False, False, 10],
     [True, False, 50],
     [True, False, 50],
     [True, False, 50],
     [True, True, 20],
     [True, False, 50],
     [True, False, 30],
     [False, True, 40],
     [True, False, 10],
     [False, False, 20],
     [False, True, 40]]],
   [[True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [False, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [100,
    [[False, False, 10],
     [False, False, 50],
     [False, False, 40],
     [True, True, 20],
     [False, False, 40],
     [True, False, 40],
     [True, False, 20],
     [False, False, 40]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 20], [False, 20]]],
  ['control: scenario 2',
   [50,
    [[False, False, 30],
     [False, False, 30],
     [True, False, 50],
     [False, False, 50],
     [False, False, 10],
     [True, False, 30],
     [False, False, 50],
     [True, False, 30],
     [True, False, 40]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40]]],
  ['regression: scenario 3',
   [100,
    [[False, False, 50],
     [False, False, 20],
     [True, False, 50],
     [True, False, 10],
     [True, False, 20],
     [True, False, 20],
     [True, False, 50],
     [True, False, 50],
     [True, True, 10],
     [True, False, 50]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 10],
    [False, 30],
    [False, 50],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 50]]]],
 [['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['regression: scenario 6',
   [0,
    [[True, True, 10],
     [True, False, 40],
     [False, True, 40],
     [True, True, 20],
     [True, False, 30],
     [False, True, 20],
     [True, False, 10],
     [True, False, 30],
     [True, False, 40],
     [False, False, 10],
     [False, False, 20],
     [False, False, 10]]],
   [[False, 0],
    [True, 0],
    [False, 0],
    [False, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 1',
   [80,
    [[False, False, 10],
     [True, False, 30],
     [True, False, 10],
     [True, True, 40],
     [True, False, 50],
     [False, False, 40],
     [False, False, 50],
     [False, False, 40]]],
   [[False, 0], [False, 0], [False, 10], [False, 0], [False, 50], [False, 50], [False, 50], [False, 50]]],
  ['regression: scenario 2',
   [0,
    [[True, False, 10],
     [False, False, 30],
     [True, False, 20],
     [True, False, 30],
     [True, False, 50],
     [True, False, 50],
     [True, True, 20],
     [True, False, 20],
     [False, False, 40]]],
   [[True, 0], [True, 0], [True, 0], [True, 0], [True, 0], [True, 0], [False, 0], [True, 0], [True, 0]]],
  ['control: scenario 3',
   [50,
    [[True, True, 10],
     [True, False, 20],
     [True, False, 10],
     [True, False, 20],
     [True, False, 40],
     [True, False, 50],
     [True, False, 30],
     [False, False, 20],
     [True, False, 40],
     [False, True, 20]]],
   [[False, 0],
    [False, 20],
    [False, 30],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [False, 0]]]],
 [['regression: scenario 4',
   [150,
    [[True, False, 20],
     [True, False, 20],
     [True, False, 40],
     [True, False, 30],
     [True, False, 20],
     [False, True, 20],
     [True, True, 10],
     [True, True, 40],
     [True, False, 40],
     [False, False, 10],
     [False, False, 10],
     [False, False, 20]]],
   [[False, 0],
    [False, 20],
    [False, 60],
    [False, 90],
    [False, 110],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40],
    [False, 40],
    [False, 40],
    [False, 40]]],
  ['regression: scenario 24',
   [0,
    [[False, False, 40],
     [True, False, 10],
     [True, True, 20],
     [False, False, 40],
     [True, False, 10],
     [True, False, 40],
     [False, False, 20]]],
   [[False, 0], [True, 0], [False, 0], [False, 0], [True, 0], [True, 0], [True, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [0,
    [[False, False, 40],
     [False, True, 30],
     [True, False, 10],
     [True, False, 30],
     [True, False, 20],
     [False, True, 30],
     [True, False, 40],
     [True, False, 30],
     [True, False, 30],
     [False, False, 20],
     [False, False, 10],
     [True, False, 30],
     [True, False, 50],
     [False, False, 10]]],
   [[False, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: scenario 2',
   [50,
    [[True, False, 10],
     [True, False, 20],
     [True, False, 50],
     [True, False, 20],
     [True, False, 20],
     [False, False, 50],
     [False, False, 40],
     [False, True, 10],
     [False, False, 10]]],
   [[False, 0],
    [False, 20],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [False, 0],
    [False, 0]]]],
 [['regression: scenario 2',
   [100,
    [[True, False, 20],
     [True, False, 30],
     [True, False, 10],
     [True, True, 10],
     [True, False, 10],
     [True, False, 20],
     [False, False, 50],
     [False, True, 40],
     [False, False, 30],
     [False, False, 40],
     [True, False, 10],
     [True, False, 50]]],
   [[False, 0],
    [False, 30],
    [False, 40],
    [False, 0],
    [False, 10],
    [False, 30],
    [False, 30],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 50]]],
  ['regression: scenario 19',
   [0,
    [[False, False, 10],
     [True, True, 30],
     [True, False, 20],
     [True, False, 20],
     [False, True, 40],
     [True, True, 40],
     [True, False, 30],
     [True, False, 30],
     [False, False, 10],
     [False, False, 30],
     [True, False, 30],
     [True, False, 10],
     [False, False, 40],
     [False, False, 50]]],
   [[False, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 1',
   [0,
    [[False, False, 50],
     [False, False, 20],
     [False, False, 30],
     [True, True, 40],
     [False, True, 10],
     [True, False, 10],
     [False, False, 30]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [True, 0], [True, 0]]],
  ['regression: scenario 3',
   [100,
    [[False, False, 10],
     [True, False, 20],
     [True, False, 10],
     [True, True, 50],
     [True, False, 40],
     [True, False, 50],
     [False, True, 50],
     [False, False, 10],
     [True, False, 30]]],
   [[False, 0],
    [False, 0],
    [False, 10],
    [False, 0],
    [False, 40],
    [False, 90],
    [False, 0],
    [False, 0],
    [False, 0]]]],
 [['regression: scenario 6',
   [0,
    [[True, True, 30],
     [True, True, 40],
     [False, False, 10],
     [False, False, 10],
     [True, False, 30],
     [True, True, 50],
     [True, False, 10],
     [False, False, 50],
     [True, False, 10],
     [False, False, 40],
     [False, False, 40],
     [False, False, 20]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['regression: scenario 32',
   [0,
    [[True, False, 10],
     [True, False, 10],
     [True, False, 30],
     [True, False, 10],
     [True, False, 30],
     [False, False, 40],
     [False, False, 50],
     [False, False, 30],
     [True, True, 40],
     [True, False, 50]]],
   [[True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [0,
    [[True, False, 30],
     [True, False, 10],
     [True, False, 10],
     [True, False, 40],
     [False, False, 30],
     [False, False, 50],
     [False, True, 40],
     [True, False, 10],
     [True, False, 30],
     [True, False, 50],
     [False, False, 20],
     [False, False, 30],
     [False, False, 40],
     [False, False, 50]]],
   [[True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: scenario 2',
   [50,
    [[True, True, 50],
     [False, False, 10],
     [True, False, 50],
     [False, True, 50],
     [False, False, 20],
     [True, False, 20]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0]]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
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(preset, scans):
    acc = 0
    dn = False
    prev = False
    out = []
    for en, res, dt in scans:
        en = bool(en)
        if res:
            acc = 0
            dn = False
            prev = False
        if en:
            if prev:
                acc = min(preset, acc + dt)
            if acc >= preset:
                dn = True
        prev = en
        if res:
            acc = 0
        out.append([dn, acc])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: scenario 5',
   [0,
    [[True, False, 20],
     [False, False, 10],
     [True, False, 50],
     [True, False, 50],
     [True, False, 50],
     [True, True, 20],
     [True, False, 50],
     [True, False, 30],
     [False, True, 40],
     [True, False, 10],
     [False, False, 20],
     [False, True, 40]]],
   [[True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [False, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [100,
    [[False, False, 10],
     [False, False, 50],
     [False, False, 40],
     [True, True, 20],
     [False, False, 40],
     [True, False, 40],
     [True, False, 20],
     [False, False, 40]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 20], [False, 20]]],
  ['control: scenario 2',
   [50,
    [[False, False, 30],
     [False, False, 30],
     [True, False, 50],
     [False, False, 50],
     [False, False, 10],
     [True, False, 30],
     [False, False, 50],
     [True, False, 30],
     [True, False, 40]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40]]],
  ['regression: scenario 3',
   [100,
    [[False, False, 50],
     [False, False, 20],
     [True, False, 50],
     [True, False, 10],
     [True, False, 20],
     [True, False, 20],
     [True, False, 50],
     [True, False, 50],
     [True, True, 10],
     [True, False, 50]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 10],
    [False, 30],
    [False, 50],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 50]]]],
 [['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['regression: scenario 6',
   [0,
    [[True, True, 10],
     [True, False, 40],
     [False, True, 40],
     [True, True, 20],
     [True, False, 30],
     [False, True, 20],
     [True, False, 10],
     [True, False, 30],
     [True, False, 40],
     [False, False, 10],
     [False, False, 20],
     [False, False, 10]]],
   [[False, 0],
    [True, 0],
    [False, 0],
    [False, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 1',
   [80,
    [[False, False, 10],
     [True, False, 30],
     [True, False, 10],
     [True, True, 40],
     [True, False, 50],
     [False, False, 40],
     [False, False, 50],
     [False, False, 40]]],
   [[False, 0], [False, 0], [False, 10], [False, 0], [False, 50], [False, 50], [False, 50], [False, 50]]],
  ['regression: scenario 2',
   [0,
    [[True, False, 10],
     [False, False, 30],
     [True, False, 20],
     [True, False, 30],
     [True, False, 50],
     [True, False, 50],
     [True, True, 20],
     [True, False, 20],
     [False, False, 40]]],
   [[True, 0], [True, 0], [True, 0], [True, 0], [True, 0], [True, 0], [False, 0], [True, 0], [True, 0]]],
  ['control: scenario 3',
   [50,
    [[True, True, 10],
     [True, False, 20],
     [True, False, 10],
     [True, False, 20],
     [True, False, 40],
     [True, False, 50],
     [True, False, 30],
     [False, False, 20],
     [True, False, 40],
     [False, True, 20]]],
   [[False, 0],
    [False, 20],
    [False, 30],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [False, 0]]]],
 [['regression: scenario 4',
   [150,
    [[True, False, 20],
     [True, False, 20],
     [True, False, 40],
     [True, False, 30],
     [True, False, 20],
     [False, True, 20],
     [True, True, 10],
     [True, True, 40],
     [True, False, 40],
     [False, False, 10],
     [False, False, 10],
     [False, False, 20]]],
   [[False, 0],
    [False, 20],
    [False, 60],
    [False, 90],
    [False, 110],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40],
    [False, 40],
    [False, 40],
    [False, 40]]],
  ['regression: scenario 24',
   [0,
    [[False, False, 40],
     [True, False, 10],
     [True, True, 20],
     [False, False, 40],
     [True, False, 10],
     [True, False, 40],
     [False, False, 20]]],
   [[False, 0], [True, 0], [False, 0], [False, 0], [True, 0], [True, 0], [True, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [0,
    [[False, False, 40],
     [False, True, 30],
     [True, False, 10],
     [True, False, 30],
     [True, False, 20],
     [False, True, 30],
     [True, False, 40],
     [True, False, 30],
     [True, False, 30],
     [False, False, 20],
     [False, False, 10],
     [True, False, 30],
     [True, False, 50],
     [False, False, 10]]],
   [[False, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: scenario 2',
   [50,
    [[True, False, 10],
     [True, False, 20],
     [True, False, 50],
     [True, False, 20],
     [True, False, 20],
     [False, False, 50],
     [False, False, 40],
     [False, True, 10],
     [False, False, 10]]],
   [[False, 0],
    [False, 20],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [False, 0],
    [False, 0]]]],
 [['regression: scenario 2',
   [100,
    [[True, False, 20],
     [True, False, 30],
     [True, False, 10],
     [True, True, 10],
     [True, False, 10],
     [True, False, 20],
     [False, False, 50],
     [False, True, 40],
     [False, False, 30],
     [False, False, 40],
     [True, False, 10],
     [True, False, 50]]],
   [[False, 0],
    [False, 30],
    [False, 40],
    [False, 0],
    [False, 10],
    [False, 30],
    [False, 30],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 50]]],
  ['regression: scenario 19',
   [0,
    [[False, False, 10],
     [True, True, 30],
     [True, False, 20],
     [True, False, 20],
     [False, True, 40],
     [True, True, 40],
     [True, False, 30],
     [True, False, 30],
     [False, False, 10],
     [False, False, 30],
     [True, False, 30],
     [True, False, 10],
     [False, False, 40],
     [False, False, 50]]],
   [[False, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 1',
   [0,
    [[False, False, 50],
     [False, False, 20],
     [False, False, 30],
     [True, True, 40],
     [False, True, 10],
     [True, False, 10],
     [False, False, 30]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [True, 0], [True, 0]]],
  ['regression: scenario 3',
   [100,
    [[False, False, 10],
     [True, False, 20],
     [True, False, 10],
     [True, True, 50],
     [True, False, 40],
     [True, False, 50],
     [False, True, 50],
     [False, False, 10],
     [True, False, 30]]],
   [[False, 0],
    [False, 0],
    [False, 10],
    [False, 0],
    [False, 40],
    [False, 90],
    [False, 0],
    [False, 0],
    [False, 0]]]],
 [['regression: scenario 6',
   [0,
    [[True, True, 30],
     [True, True, 40],
     [False, False, 10],
     [False, False, 10],
     [True, False, 30],
     [True, True, 50],
     [True, False, 10],
     [False, False, 50],
     [True, False, 10],
     [False, False, 40],
     [False, False, 40],
     [False, False, 20]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['regression: scenario 32',
   [0,
    [[True, False, 10],
     [True, False, 10],
     [True, False, 30],
     [True, False, 10],
     [True, False, 30],
     [False, False, 40],
     [False, False, 50],
     [False, False, 30],
     [True, True, 40],
     [True, False, 50]]],
   [[True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [0,
    [[True, False, 30],
     [True, False, 10],
     [True, False, 10],
     [True, False, 40],
     [False, False, 30],
     [False, False, 50],
     [False, True, 40],
     [True, False, 10],
     [True, False, 30],
     [True, False, 50],
     [False, False, 20],
     [False, False, 30],
     [False, False, 40],
     [False, False, 50]]],
   [[True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: scenario 2',
   [50,
    [[True, True, 50],
     [False, False, 10],
     [True, False, 50],
     [False, True, 50],
     [False, False, 20],
     [True, False, 20]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0]]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
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:
On a reset scan with the timer enabled, ACC ends the scan non-zero instead of cleared.

Retentive timer (RTO) on rung 1 and its reset (RES) on a later rung, evaluated per scan; scans is a list of [enable, reset, elapsed_ms]. An enabled scan whose previous scan was also enabled adds the elapsed time (clamped at preset); DN sets when ACC >= preset while enabled. A disabled rung retains ACC and DN. Because RES is a later rung, a reset in a scan clears ACC and DN after the RTO has run; the enable edge memory is not touched by RES. Return [DN, ACC] per scan.

split: open-access


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

N = 1
observations = []
def solve(preset, scans):
    acc = 0
    dn = False
    prev = False
    out = []
    for en, res, dt in scans:
        en = bool(en)
        if en:
            if prev:
                acc = min(preset, acc + dt)
            if acc >= preset:
                dn = True
        prev = en
        if res:
            acc = 0
        out.append([dn, acc])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['regression: scenario 3',
   [100,
    [[False, False, 50],
     [False, False, 20],
     [True, False, 50],
     [True, False, 10],
     [True, False, 20],
     [True, False, 20],
     [True, False, 50],
     [True, False, 50],
     [True, True, 10],
     [True, False, 50]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 10],
    [False, 30],
    [False, 50],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 50]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['control: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [100,
    [[False, False, 10],
     [False, False, 50],
     [False, False, 40],
     [True, True, 20],
     [False, False, 40],
     [True, False, 40],
     [True, False, 20],
     [False, False, 40]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 20], [False, 20]]],
  ['control: scenario 2',
   [50,
    [[False, False, 30],
     [False, False, 30],
     [True, False, 50],
     [False, False, 50],
     [False, False, 10],
     [True, False, 30],
     [False, False, 50],
     [True, False, 30],
     [True, False, 40]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40]]],
  ['control: scenario 4',
   [100,
    [[True, False, 20],
     [True, False, 10],
     [False, False, 20],
     [True, False, 30],
     [False, False, 20],
     [False, False, 30]]],
   [[False, 0], [False, 10], [False, 10], [False, 10], [False, 10], [False, 10]]]],
 [['regression: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 2',
   [0,
    [[True, False, 10],
     [False, False, 30],
     [True, False, 20],
     [True, False, 30],
     [True, False, 50],
     [True, False, 50],
     [True, True, 20],
     [True, False, 20],
     [False, False, 40]]],
   [[True, 0], [True, 0], [True, 0], [True, 0], [True, 0], [True, 0], [False, 0], [True, 0], [True, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['control: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: scenario 1',
   [80,
    [[False, False, 10],
     [True, False, 30],
     [True, False, 10],
     [True, True, 40],
     [True, False, 50],
     [False, False, 40],
     [False, False, 50],
     [False, False, 40]]],
   [[False, 0], [False, 0], [False, 10], [False, 0], [False, 50], [False, 50], [False, 50], [False, 50]]],
  ['regression: scenario 3',
   [50,
    [[True, True, 10],
     [True, False, 20],
     [True, False, 10],
     [True, False, 20],
     [True, False, 40],
     [True, False, 50],
     [True, False, 30],
     [False, False, 20],
     [True, False, 40],
     [False, True, 20]]],
   [[False, 0],
    [False, 20],
    [False, 30],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [False, 0]]],
  ['regression: scenario 4',
   [80,
    [[False, False, 20],
     [False, False, 40],
     [True, False, 50],
     [True, False, 40],
     [True, True, 40],
     [False, False, 10],
     [True, False, 10],
     [True, False, 30],
     [True, False, 50],
     [True, False, 40],
     [False, True, 30]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 40],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 30],
    [True, 80],
    [True, 80],
    [False, 0]]]],
 [['regression: scenario 1',
   [0,
    [[False, False, 40],
     [False, True, 30],
     [True, False, 10],
     [True, False, 30],
     [True, False, 20],
     [False, True, 30],
     [True, False, 40],
     [True, False, 30],
     [True, False, 30],
     [False, False, 20],
     [False, False, 10],
     [True, False, 30],
     [True, False, 50],
     [False, False, 10]]],
   [[False, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['regression: scenario 13',
   [0,
    [[True, False, 10],
     [True, False, 40],
     [False, False, 10],
     [True, False, 30],
     [False, False, 20],
     [True, False, 20],
     [False, False, 20],
     [True, False, 30],
     [True, True, 10],
     [True, False, 50]]],
   [[True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['control: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['regression: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 2',
   [50,
    [[True, False, 10],
     [True, False, 20],
     [True, False, 50],
     [True, False, 20],
     [True, False, 20],
     [False, False, 50],
     [False, False, 40],
     [False, True, 10],
     [False, False, 10]]],
   [[False, 0],
    [False, 20],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [False, 0],
    [False, 0]]],
  ['control: scenario 3',
   [150,
    [[True, False, 50],
     [True, False, 30],
     [False, False, 50],
     [False, False, 40],
     [False, False, 50],
     [False, False, 20]]],
   [[False, 0], [False, 30], [False, 30], [False, 30], [False, 30], [False, 30]]]],
 [['regression: scenario 4',
   [50,
    [[False, False, 30],
     [True, False, 10],
     [False, False, 40],
     [False, False, 40],
     [True, False, 50],
     [True, False, 40],
     [True, False, 50],
     [True, True, 10],
     [False, False, 10],
     [False, False, 20],
     [False, True, 40],
     [True, False, 30]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40],
    [True, 50],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0]]],
  ['regression: scenario 15',
   [0,
    [[True, True, 20],
     [True, False, 10],
     [True, True, 30],
     [False, False, 30],
     [False, True, 30],
     [False, False, 30],
     [False, False, 40]]],
   [[False, 0], [True, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['control: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['regression: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 1',
   [0,
    [[False, False, 50],
     [False, False, 20],
     [False, False, 30],
     [True, True, 40],
     [False, True, 10],
     [True, False, 10],
     [False, False, 30]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [True, 0], [True, 0]]],
  ['control: scenario 2',
   [100,
    [[True, False, 20],
     [True, False, 30],
     [True, False, 10],
     [True, True, 10],
     [True, False, 10],
     [True, False, 20],
     [False, False, 50],
     [False, True, 40],
     [False, False, 30],
     [False, False, 40],
     [True, False, 10],
     [True, False, 50]]],
   [[False, 0],
    [False, 30],
    [False, 40],
    [False, 0],
    [False, 10],
    [False, 30],
    [False, 30],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 50]]]],
 [['regression: scenario 7',
   [80,
    [[False, False, 10],
     [False, False, 40],
     [False, False, 30],
     [True, False, 40],
     [True, False, 10],
     [True, False, 50],
     [True, True, 20],
     [True, False, 20],
     [True, False, 30],
     [True, False, 20],
     [True, False, 20],
     [False, False, 40]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 10],
    [False, 60],
    [False, 0],
    [False, 20],
    [False, 50],
    [False, 70],
    [True, 80],
    [True, 80]]],
  ['regression: scenario 14',
   [80,
    [[True, True, 20],
     [True, False, 40],
     [False, False, 40],
     [True, False, 20],
     [True, False, 20],
     [True, False, 30],
     [False, False, 50],
     [True, True, 20],
     [True, False, 10],
     [False, True, 10]]],
   [[False, 0],
    [False, 40],
    [False, 40],
    [False, 40],
    [False, 60],
    [True, 80],
    [True, 80],
    [False, 0],
    [False, 10],
    [False, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['control: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['regression: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 1',
   [0,
    [[True, False, 30],
     [True, False, 10],
     [True, False, 10],
     [True, False, 40],
     [False, False, 30],
     [False, False, 50],
     [False, True, 40],
     [True, False, 10],
     [True, False, 30],
     [True, False, 50],
     [False, False, 20],
     [False, False, 30],
     [False, False, 40],
     [False, False, 50]]],
   [[True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: scenario 2',
   [50,
    [[True, True, 50],
     [False, False, 10],
     [True, False, 50],
     [False, True, 50],
     [False, False, 20],
     [True, False, 20]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0]]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
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(preset, scans):
    acc = 0
    dn = False
    prev = False
    out = []
    for en, res, dt in scans:
        en = bool(en)
        if en:
            if prev:
                acc = min(preset, acc + dt)
            if acc >= preset:
                dn = True
        prev = en
        if res:
            acc = 0
            if not en:
                dn = False
        out.append([dn, acc])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['regression: scenario 3',
   [100,
    [[False, False, 50],
     [False, False, 20],
     [True, False, 50],
     [True, False, 10],
     [True, False, 20],
     [True, False, 20],
     [True, False, 50],
     [True, False, 50],
     [True, True, 10],
     [True, False, 50]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 10],
    [False, 30],
    [False, 50],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 50]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['control: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [100,
    [[False, False, 10],
     [False, False, 50],
     [False, False, 40],
     [True, True, 20],
     [False, False, 40],
     [True, False, 40],
     [True, False, 20],
     [False, False, 40]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 20], [False, 20]]],
  ['control: scenario 2',
   [50,
    [[False, False, 30],
     [False, False, 30],
     [True, False, 50],
     [False, False, 50],
     [False, False, 10],
     [True, False, 30],
     [False, False, 50],
     [True, False, 30],
     [True, False, 40]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40]]],
  ['control: scenario 4',
   [100,
    [[True, False, 20],
     [True, False, 10],
     [False, False, 20],
     [True, False, 30],
     [False, False, 20],
     [False, False, 30]]],
   [[False, 0], [False, 10], [False, 10], [False, 10], [False, 10], [False, 10]]]],
 [['regression: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 2',
   [0,
    [[True, False, 10],
     [False, False, 30],
     [True, False, 20],
     [True, False, 30],
     [True, False, 50],
     [True, False, 50],
     [True, True, 20],
     [True, False, 20],
     [False, False, 40]]],
   [[True, 0], [True, 0], [True, 0], [True, 0], [True, 0], [True, 0], [False, 0], [True, 0], [True, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['control: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: scenario 1',
   [80,
    [[False, False, 10],
     [True, False, 30],
     [True, False, 10],
     [True, True, 40],
     [True, False, 50],
     [False, False, 40],
     [False, False, 50],
     [False, False, 40]]],
   [[False, 0], [False, 0], [False, 10], [False, 0], [False, 50], [False, 50], [False, 50], [False, 50]]],
  ['regression: scenario 3',
   [50,
    [[True, True, 10],
     [True, False, 20],
     [True, False, 10],
     [True, False, 20],
     [True, False, 40],
     [True, False, 50],
     [True, False, 30],
     [False, False, 20],
     [True, False, 40],
     [False, True, 20]]],
   [[False, 0],
    [False, 20],
    [False, 30],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [False, 0]]],
  ['regression: scenario 4',
   [80,
    [[False, False, 20],
     [False, False, 40],
     [True, False, 50],
     [True, False, 40],
     [True, True, 40],
     [False, False, 10],
     [True, False, 10],
     [True, False, 30],
     [True, False, 50],
     [True, False, 40],
     [False, True, 30]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 40],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 30],
    [True, 80],
    [True, 80],
    [False, 0]]]],
 [['regression: scenario 1',
   [0,
    [[False, False, 40],
     [False, True, 30],
     [True, False, 10],
     [True, False, 30],
     [True, False, 20],
     [False, True, 30],
     [True, False, 40],
     [True, False, 30],
     [True, False, 30],
     [False, False, 20],
     [False, False, 10],
     [True, False, 30],
     [True, False, 50],
     [False, False, 10]]],
   [[False, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['regression: scenario 13',
   [0,
    [[True, False, 10],
     [True, False, 40],
     [False, False, 10],
     [True, False, 30],
     [False, False, 20],
     [True, False, 20],
     [False, False, 20],
     [True, False, 30],
     [True, True, 10],
     [True, False, 50]]],
   [[True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['control: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['regression: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 2',
   [50,
    [[True, False, 10],
     [True, False, 20],
     [True, False, 50],
     [True, False, 20],
     [True, False, 20],
     [False, False, 50],
     [False, False, 40],
     [False, True, 10],
     [False, False, 10]]],
   [[False, 0],
    [False, 20],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [False, 0],
    [False, 0]]],
  ['control: scenario 3',
   [150,
    [[True, False, 50],
     [True, False, 30],
     [False, False, 50],
     [False, False, 40],
     [False, False, 50],
     [False, False, 20]]],
   [[False, 0], [False, 30], [False, 30], [False, 30], [False, 30], [False, 30]]]],
 [['regression: scenario 4',
   [50,
    [[False, False, 30],
     [True, False, 10],
     [False, False, 40],
     [False, False, 40],
     [True, False, 50],
     [True, False, 40],
     [True, False, 50],
     [True, True, 10],
     [False, False, 10],
     [False, False, 20],
     [False, True, 40],
     [True, False, 30]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40],
    [True, 50],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0]]],
  ['regression: scenario 15',
   [0,
    [[True, True, 20],
     [True, False, 10],
     [True, True, 30],
     [False, False, 30],
     [False, True, 30],
     [False, False, 30],
     [False, False, 40]]],
   [[False, 0], [True, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['control: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['regression: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 1',
   [0,
    [[False, False, 50],
     [False, False, 20],
     [False, False, 30],
     [True, True, 40],
     [False, True, 10],
     [True, False, 10],
     [False, False, 30]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [True, 0], [True, 0]]],
  ['control: scenario 2',
   [100,
    [[True, False, 20],
     [True, False, 30],
     [True, False, 10],
     [True, True, 10],
     [True, False, 10],
     [True, False, 20],
     [False, False, 50],
     [False, True, 40],
     [False, False, 30],
     [False, False, 40],
     [True, False, 10],
     [True, False, 50]]],
   [[False, 0],
    [False, 30],
    [False, 40],
    [False, 0],
    [False, 10],
    [False, 30],
    [False, 30],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 50]]]],
 [['regression: scenario 7',
   [80,
    [[False, False, 10],
     [False, False, 40],
     [False, False, 30],
     [True, False, 40],
     [True, False, 10],
     [True, False, 50],
     [True, True, 20],
     [True, False, 20],
     [True, False, 30],
     [True, False, 20],
     [True, False, 20],
     [False, False, 40]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 10],
    [False, 60],
    [False, 0],
    [False, 20],
    [False, 50],
    [False, 70],
    [True, 80],
    [True, 80]]],
  ['regression: scenario 14',
   [80,
    [[True, True, 20],
     [True, False, 40],
     [False, False, 40],
     [True, False, 20],
     [True, False, 20],
     [True, False, 30],
     [False, False, 50],
     [True, True, 20],
     [True, False, 10],
     [False, True, 10]]],
   [[False, 0],
    [False, 40],
    [False, 40],
    [False, 40],
    [False, 60],
    [True, 80],
    [True, 80],
    [False, 0],
    [False, 10],
    [False, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['control: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['regression: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 1',
   [0,
    [[True, False, 30],
     [True, False, 10],
     [True, False, 10],
     [True, False, 40],
     [False, False, 30],
     [False, False, 50],
     [False, True, 40],
     [True, False, 10],
     [True, False, 30],
     [True, False, 50],
     [False, False, 20],
     [False, False, 30],
     [False, False, 40],
     [False, False, 50]]],
   [[True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: scenario 2',
   [50,
    [[True, True, 50],
     [False, False, 10],
     [True, False, 50],
     [False, True, 50],
     [False, False, 20],
     [True, False, 20]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0]]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
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:
After a reset the done bit stays on while ACC reads zero.

Retentive timer (RTO) on rung 1 and its reset (RES) on a later rung, evaluated per scan; scans is a list of [enable, reset, elapsed_ms]. An enabled scan whose previous scan was also enabled adds the elapsed time (clamped at preset); DN sets when ACC >= preset while enabled. A disabled rung retains ACC and DN. Because RES is a later rung, a reset in a scan clears ACC and DN after the RTO has run; the enable edge memory is not touched by RES. Return [DN, ACC] per scan.

split: open-access


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

N = 1
observations = []
def solve(preset, scans):
    acc = 0
    dn = False
    prev = False
    out = []
    for en, res, dt in scans:
        en = bool(en)
        if en:
            if prev:
                acc = min(preset, acc + dt)
            if acc >= preset:
                dn = True
        prev = en
        if res:
            acc = 0
            dn = False
            prev = False
        out.append([dn, acc])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [100,
    [[False, False, 10],
     [False, False, 50],
     [False, False, 40],
     [True, True, 20],
     [False, False, 40],
     [True, False, 40],
     [True, False, 20],
     [False, False, 40]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 20], [False, 20]]],
  ['control: scenario 2',
   [50,
    [[False, False, 30],
     [False, False, 30],
     [True, False, 50],
     [False, False, 50],
     [False, False, 10],
     [True, False, 30],
     [False, False, 50],
     [True, False, 30],
     [True, False, 40]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40]]],
  ['regression: scenario 3',
   [100,
    [[False, False, 50],
     [False, False, 20],
     [True, False, 50],
     [True, False, 10],
     [True, False, 20],
     [True, False, 20],
     [True, False, 50],
     [True, False, 50],
     [True, True, 10],
     [True, False, 50]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 10],
    [False, 30],
    [False, 50],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 50]]],
  ['control: scenario 4',
   [100,
    [[True, False, 20],
     [True, False, 10],
     [False, False, 20],
     [True, False, 30],
     [False, False, 20],
     [False, False, 30]]],
   [[False, 0], [False, 10], [False, 10], [False, 10], [False, 10], [False, 10]]]],
 [['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['regression: scenario 16',
   [50,
    [[True, True, 20],
     [True, True, 20],
     [True, False, 30],
     [True, False, 40],
     [True, True, 20],
     [True, False, 20],
     [True, True, 30],
     [False, False, 10],
     [True, False, 10],
     [True, False, 30],
     [True, False, 30],
     [True, False, 20],
     [False, False, 50]]],
   [[False, 0],
    [False, 0],
    [False, 30],
    [True, 50],
    [False, 0],
    [False, 20],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 30],
    [True, 50],
    [True, 50],
    [True, 50]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 1',
   [80,
    [[False, False, 10],
     [True, False, 30],
     [True, False, 10],
     [True, True, 40],
     [True, False, 50],
     [False, False, 40],
     [False, False, 50],
     [False, False, 40]]],
   [[False, 0], [False, 0], [False, 10], [False, 0], [False, 50], [False, 50], [False, 50], [False, 50]]],
  ['control: scenario 2',
   [0,
    [[True, False, 10],
     [False, False, 30],
     [True, False, 20],
     [True, False, 30],
     [True, False, 50],
     [True, False, 50],
     [True, True, 20],
     [True, False, 20],
     [False, False, 40]]],
   [[True, 0], [True, 0], [True, 0], [True, 0], [True, 0], [True, 0], [False, 0], [True, 0], [True, 0]]],
  ['regression: scenario 3',
   [50,
    [[True, True, 10],
     [True, False, 20],
     [True, False, 10],
     [True, False, 20],
     [True, False, 40],
     [True, False, 50],
     [True, False, 30],
     [False, False, 20],
     [True, False, 40],
     [False, True, 20]]],
   [[False, 0],
    [False, 20],
    [False, 30],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [False, 0]]]],
 [['regression: scenario 4',
   [150,
    [[True, False, 20],
     [True, False, 20],
     [True, False, 40],
     [True, False, 30],
     [True, False, 20],
     [False, True, 20],
     [True, True, 10],
     [True, True, 40],
     [True, False, 40],
     [False, False, 10],
     [False, False, 10],
     [False, False, 20]]],
   [[False, 0],
    [False, 20],
    [False, 60],
    [False, 90],
    [False, 110],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40],
    [False, 40],
    [False, 40],
    [False, 40]]],
  ['regression: scenario 52',
   [100,
    [[False, False, 40],
     [True, False, 40],
     [True, False, 30],
     [True, False, 50],
     [False, False, 10],
     [False, False, 10],
     [False, True, 30],
     [False, False, 10],
     [True, True, 40],
     [True, True, 20],
     [True, False, 40],
     [True, False, 20],
     [True, True, 50],
     [True, False, 10]]],
   [[False, 0],
    [False, 0],
    [False, 30],
    [False, 80],
    [False, 80],
    [False, 80],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40],
    [False, 60],
    [False, 0],
    [False, 10]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [0,
    [[False, False, 40],
     [False, True, 30],
     [True, False, 10],
     [True, False, 30],
     [True, False, 20],
     [False, True, 30],
     [True, False, 40],
     [True, False, 30],
     [True, False, 30],
     [False, False, 20],
     [False, False, 10],
     [True, False, 30],
     [True, False, 50],
     [False, False, 10]]],
   [[False, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: scenario 2',
   [50,
    [[True, False, 10],
     [True, False, 20],
     [True, False, 50],
     [True, False, 20],
     [True, False, 20],
     [False, False, 50],
     [False, False, 40],
     [False, True, 10],
     [False, False, 10]]],
   [[False, 0],
    [False, 20],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [False, 0],
    [False, 0]]]],
 [['regression: scenario 3',
   [100,
    [[False, False, 10],
     [True, False, 20],
     [True, False, 10],
     [True, True, 50],
     [True, False, 40],
     [True, False, 50],
     [False, True, 50],
     [False, False, 10],
     [True, False, 30]]],
   [[False, 0],
    [False, 0],
    [False, 10],
    [False, 0],
    [False, 40],
    [False, 90],
    [False, 0],
    [False, 0],
    [False, 0]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [0,
    [[False, False, 50],
     [False, False, 20],
     [False, False, 30],
     [True, True, 40],
     [False, True, 10],
     [True, False, 10],
     [False, False, 30]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [True, 0], [True, 0]]],
  ['regression: scenario 2',
   [100,
    [[True, False, 20],
     [True, False, 30],
     [True, False, 10],
     [True, True, 10],
     [True, False, 10],
     [True, False, 20],
     [False, False, 50],
     [False, True, 40],
     [False, False, 30],
     [False, False, 40],
     [True, False, 10],
     [True, False, 50]]],
   [[False, 0],
    [False, 30],
    [False, 40],
    [False, 0],
    [False, 10],
    [False, 30],
    [False, 30],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 50]]],
  ['control: scenario 4',
   [50,
    [[False, False, 30],
     [True, False, 10],
     [False, False, 40],
     [False, False, 40],
     [True, False, 50],
     [True, False, 40],
     [True, False, 50],
     [True, True, 10],
     [False, False, 10],
     [False, False, 20],
     [False, True, 40],
     [True, False, 30]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40],
    [True, 50],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0]]]],
 [['regression: scenario 8',
   [150,
    [[True, False, 30],
     [True, True, 50],
     [True, False, 30],
     [True, False, 40],
     [True, False, 10],
     [True, False, 30],
     [True, True, 10],
     [True, False, 30],
     [True, False, 40],
     [True, False, 40],
     [False, True, 50],
     [True, False, 50],
     [True, False, 10]]],
   [[False, 0],
    [False, 0],
    [False, 30],
    [False, 70],
    [False, 80],
    [False, 110],
    [False, 0],
    [False, 30],
    [False, 70],
    [False, 110],
    [False, 0],
    [False, 0],
    [False, 10]]],
  ['regression: scenario 17',
   [50,
    [[False, False, 10],
     [True, False, 40],
     [True, False, 50],
     [True, False, 30],
     [True, True, 40],
     [True, False, 30],
     [True, True, 50]]],
   [[False, 0], [False, 0], [True, 50], [True, 50], [False, 0], [False, 30], [False, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [0,
    [[True, False, 30],
     [True, False, 10],
     [True, False, 10],
     [True, False, 40],
     [False, False, 30],
     [False, False, 50],
     [False, True, 40],
     [True, False, 10],
     [True, False, 30],
     [True, False, 50],
     [False, False, 20],
     [False, False, 30],
     [False, False, 40],
     [False, False, 50]]],
   [[True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: scenario 2',
   [50,
    [[True, True, 50],
     [False, False, 10],
     [True, False, 50],
     [False, True, 50],
     [False, False, 20],
     [True, False, 20]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0]]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
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(preset, scans):
    acc = 0
    dn = False
    prev = False
    out = []
    for en, res, dt in scans:
        en = bool(en)
        if en:
            if prev:
                acc = min(preset, acc + dt)
            if acc >= preset:
                dn = True
        prev = en
        if res:
            if dn:
                prev = False
            acc = 0
            dn = False
        out.append([dn, acc])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [100,
    [[False, False, 10],
     [False, False, 50],
     [False, False, 40],
     [True, True, 20],
     [False, False, 40],
     [True, False, 40],
     [True, False, 20],
     [False, False, 40]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 20], [False, 20]]],
  ['control: scenario 2',
   [50,
    [[False, False, 30],
     [False, False, 30],
     [True, False, 50],
     [False, False, 50],
     [False, False, 10],
     [True, False, 30],
     [False, False, 50],
     [True, False, 30],
     [True, False, 40]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40]]],
  ['regression: scenario 3',
   [100,
    [[False, False, 50],
     [False, False, 20],
     [True, False, 50],
     [True, False, 10],
     [True, False, 20],
     [True, False, 20],
     [True, False, 50],
     [True, False, 50],
     [True, True, 10],
     [True, False, 50]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 10],
    [False, 30],
    [False, 50],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 50]]],
  ['control: scenario 4',
   [100,
    [[True, False, 20],
     [True, False, 10],
     [False, False, 20],
     [True, False, 30],
     [False, False, 20],
     [False, False, 30]]],
   [[False, 0], [False, 10], [False, 10], [False, 10], [False, 10], [False, 10]]]],
 [['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['regression: scenario 16',
   [50,
    [[True, True, 20],
     [True, True, 20],
     [True, False, 30],
     [True, False, 40],
     [True, True, 20],
     [True, False, 20],
     [True, True, 30],
     [False, False, 10],
     [True, False, 10],
     [True, False, 30],
     [True, False, 30],
     [True, False, 20],
     [False, False, 50]]],
   [[False, 0],
    [False, 0],
    [False, 30],
    [True, 50],
    [False, 0],
    [False, 20],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 30],
    [True, 50],
    [True, 50],
    [True, 50]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['regression: scenario 1',
   [80,
    [[False, False, 10],
     [True, False, 30],
     [True, False, 10],
     [True, True, 40],
     [True, False, 50],
     [False, False, 40],
     [False, False, 50],
     [False, False, 40]]],
   [[False, 0], [False, 0], [False, 10], [False, 0], [False, 50], [False, 50], [False, 50], [False, 50]]],
  ['control: scenario 2',
   [0,
    [[True, False, 10],
     [False, False, 30],
     [True, False, 20],
     [True, False, 30],
     [True, False, 50],
     [True, False, 50],
     [True, True, 20],
     [True, False, 20],
     [False, False, 40]]],
   [[True, 0], [True, 0], [True, 0], [True, 0], [True, 0], [True, 0], [False, 0], [True, 0], [True, 0]]],
  ['regression: scenario 3',
   [50,
    [[True, True, 10],
     [True, False, 20],
     [True, False, 10],
     [True, False, 20],
     [True, False, 40],
     [True, False, 50],
     [True, False, 30],
     [False, False, 20],
     [True, False, 40],
     [False, True, 20]]],
   [[False, 0],
    [False, 20],
    [False, 30],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [False, 0]]]],
 [['regression: scenario 4',
   [150,
    [[True, False, 20],
     [True, False, 20],
     [True, False, 40],
     [True, False, 30],
     [True, False, 20],
     [False, True, 20],
     [True, True, 10],
     [True, True, 40],
     [True, False, 40],
     [False, False, 10],
     [False, False, 10],
     [False, False, 20]]],
   [[False, 0],
    [False, 20],
    [False, 60],
    [False, 90],
    [False, 110],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40],
    [False, 40],
    [False, 40],
    [False, 40]]],
  ['regression: scenario 52',
   [100,
    [[False, False, 40],
     [True, False, 40],
     [True, False, 30],
     [True, False, 50],
     [False, False, 10],
     [False, False, 10],
     [False, True, 30],
     [False, False, 10],
     [True, True, 40],
     [True, True, 20],
     [True, False, 40],
     [True, False, 20],
     [True, True, 50],
     [True, False, 10]]],
   [[False, 0],
    [False, 0],
    [False, 30],
    [False, 80],
    [False, 80],
    [False, 80],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40],
    [False, 60],
    [False, 0],
    [False, 10]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [0,
    [[False, False, 40],
     [False, True, 30],
     [True, False, 10],
     [True, False, 30],
     [True, False, 20],
     [False, True, 30],
     [True, False, 40],
     [True, False, 30],
     [True, False, 30],
     [False, False, 20],
     [False, False, 10],
     [True, False, 30],
     [True, False, 50],
     [False, False, 10]]],
   [[False, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: scenario 2',
   [50,
    [[True, False, 10],
     [True, False, 20],
     [True, False, 50],
     [True, False, 20],
     [True, False, 20],
     [False, False, 50],
     [False, False, 40],
     [False, True, 10],
     [False, False, 10]]],
   [[False, 0],
    [False, 20],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [True, 50],
    [False, 0],
    [False, 0]]]],
 [['regression: scenario 3',
   [100,
    [[False, False, 10],
     [True, False, 20],
     [True, False, 10],
     [True, True, 50],
     [True, False, 40],
     [True, False, 50],
     [False, True, 50],
     [False, False, 10],
     [True, False, 30]]],
   [[False, 0],
    [False, 0],
    [False, 10],
    [False, 0],
    [False, 40],
    [False, 90],
    [False, 0],
    [False, 0],
    [False, 0]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [0,
    [[False, False, 50],
     [False, False, 20],
     [False, False, 30],
     [True, True, 40],
     [False, True, 10],
     [True, False, 10],
     [False, False, 30]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [True, 0], [True, 0]]],
  ['regression: scenario 2',
   [100,
    [[True, False, 20],
     [True, False, 30],
     [True, False, 10],
     [True, True, 10],
     [True, False, 10],
     [True, False, 20],
     [False, False, 50],
     [False, True, 40],
     [False, False, 30],
     [False, False, 40],
     [True, False, 10],
     [True, False, 50]]],
   [[False, 0],
    [False, 30],
    [False, 40],
    [False, 0],
    [False, 10],
    [False, 30],
    [False, 30],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 50]]],
  ['control: scenario 4',
   [50,
    [[False, False, 30],
     [True, False, 10],
     [False, False, 40],
     [False, False, 40],
     [True, False, 50],
     [True, False, 40],
     [True, False, 50],
     [True, True, 10],
     [False, False, 10],
     [False, False, 20],
     [False, True, 40],
     [True, False, 30]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 40],
    [True, 50],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0]]]],
 [['regression: scenario 8',
   [150,
    [[True, False, 30],
     [True, True, 50],
     [True, False, 30],
     [True, False, 40],
     [True, False, 10],
     [True, False, 30],
     [True, True, 10],
     [True, False, 30],
     [True, False, 40],
     [True, False, 40],
     [False, True, 50],
     [True, False, 50],
     [True, False, 10]]],
   [[False, 0],
    [False, 0],
    [False, 30],
    [False, 70],
    [False, 80],
    [False, 110],
    [False, 0],
    [False, 30],
    [False, 70],
    [False, 110],
    [False, 0],
    [False, 0],
    [False, 10]]],
  ['regression: scenario 17',
   [50,
    [[False, False, 10],
     [True, False, 40],
     [True, False, 50],
     [True, False, 30],
     [True, True, 40],
     [True, False, 30],
     [True, True, 50]]],
   [[False, 0], [False, 0], [True, 50], [True, 50], [False, 0], [False, 30], [False, 0]]],
  ['control: interrupted timing retained',
   [100,
    [[True, False, 30],
     [True, False, 40],
     [False, False, 40],
     [True, False, 40],
     [True, False, 40],
     [True, False, 40]]],
   [[False, 0], [False, 40], [False, 40], [False, 40], [False, 80], [True, 100]]],
  ['regression: reset while enabled',
   [100, [[True, False, 30], [True, False, 60], [True, True, 30], [True, False, 30], [True, False, 30]]],
   [[False, 0], [False, 60], [False, 0], [False, 30], [False, 60]]],
  ['regression: reset done timer while enabled',
   [50,
    [[True, False, 30],
     [True, False, 60],
     [True, False, 10],
     [True, True, 10],
     [True, False, 25],
     [True, False, 25]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 25], [True, 50]]],
  ['control: reset done timer while disabled',
   [50, [[True, False, 30], [True, False, 60], [False, False, 10], [False, True, 10], [False, False, 10]]],
   [[False, 0], [True, 50], [True, 50], [False, 0], [False, 0]]],
  ['control: scenario 1',
   [0,
    [[True, False, 30],
     [True, False, 10],
     [True, False, 10],
     [True, False, 40],
     [False, False, 30],
     [False, False, 50],
     [False, True, 40],
     [True, False, 10],
     [True, False, 30],
     [True, False, 50],
     [False, False, 20],
     [False, False, 30],
     [False, False, 40],
     [False, False, 50]]],
   [[True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [False, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0],
    [True, 0]]],
  ['control: scenario 2',
   [50,
    [[True, True, 50],
     [False, False, 10],
     [True, False, 50],
     [False, True, 50],
     [False, False, 20],
     [True, False, 20]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 0], [False, 0]]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
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:
After a reset issued while the timer stays enabled, the next scan is not credited and completion is late.

Retentive timer (RTO) on rung 1 and its reset (RES) on a later rung, evaluated per scan; scans is a list of [enable, reset, elapsed_ms]. An enabled scan whose previous scan was also enabled adds the elapsed time (clamped at preset); DN sets when ACC >= preset while enabled. A disabled rung retains ACC and DN. Because RES is a later rung, a reset in a scan clears ACC and DN after the RTO has run; the enable edge memory is not touched by RES. Return [DN, ACC] per scan.

split: open-access