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

N = 1
observations = []
def solve(preset, samples):
    start = None
    done = False
    out = []
    for enable, clock in samples:
        if not enable:
            start = clock
            done = False
            out.append([False, 0])
            continue
        if start is None:
            start = clock
        elapsed = (clock - start) & 0xFFFF
        if elapsed >= preset:
            done = True
        out.append([done, preset if done else elapsed])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 1',
   [100,
    [[True, 53593],
     [True, 53635],
     [True, 10212],
     [False, 10250],
     [True, 24553],
     [True, 35364],
     [True, 35501],
     [True, 35591],
     [True, 65279],
     [True, 65379],
     [True, 65509]]],
   [[False, 0],
    [False, 42],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['control: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: scenario 2',
   [100,
    [[True, 17304],
     [True, 20531],
     [True, 27559],
     [False, 57396],
     [True, 19489],
     [True, 46000],
     [True, 46035],
     [True, 46209],
     [True, 5526]]],
   [[False, 0],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100]]],
  ['regression: scenario 3',
   [40000,
    [[True, 42783],
     [False, 4625],
     [True, 4670],
     [True, 8857],
     [False, 15422],
     [False, 15500],
     [True, 15560],
     [True, 27335],
     [True, 27471]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 4187],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 11775],
    [False, 11911]]],
  ['control: scenario 4',
   [100,
    [[True, 2607],
     [True, 18576],
     [True, 18609],
     [True, 18619],
     [True, 45272],
     [True, 45282],
     [True, 55824],
     [False, 61503]]],
   [[False, 0], [True, 100], [True, 100], [True, 100], [True, 100], [True, 100], [True, 100], [False, 0]]]],
 [['regression: scenario 1',
   [1000,
    [[False, 39404],
     [False, 39599],
     [True, 39752],
     [True, 39914],
     [False, 49270],
     [True, 53547],
     [True, 53700],
     [True, 4426]]],
   [[False, 0], [False, 0], [False, 0], [False, 162], [False, 0], [False, 0], [False, 153], [True, 1000]]],
  ['regression: scenario 2',
   [5,
    [[True, 40525],
     [True, 40666],
     [True, 40725],
     [True, 58227],
     [True, 18319],
     [False, 25775],
     [True, 25797],
     [True, 25799]]],
   [[False, 0], [True, 5], [True, 5], [True, 5], [True, 5], [False, 0], [False, 0], [False, 2]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['control: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 3',
   [5,
    [[False, 30258],
     [True, 30296],
     [True, 45510],
     [True, 2343],
     [True, 12538],
     [True, 12596],
     [False, 12635],
     [True, 37410],
     [True, 53676],
     [True, 10497],
     [True, 10628],
     [False, 10824],
     [True, 27527],
     [True, 55148]]],
   [[False, 0],
    [False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [False, 0],
    [False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [False, 0],
    [False, 0],
    [True, 5]]],
  ['regression: scenario 4',
   [65535,
    [[True, 43066],
     [True, 60153],
     [False, 2292],
     [True, 2392],
     [True, 12076],
     [False, 28626],
     [False, 28693],
     [False, 45850],
     [True, 5636]]],
   [[False, 0],
    [False, 17087],
    [False, 0],
    [False, 0],
    [False, 9684],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0]]]],
 [['regression: scenario 2',
   [40000,
    [[True, 54821],
     [True, 18035],
     [True, 32212],
     [True, 38340],
     [True, 38521],
     [True, 38565],
     [True, 38691],
     [True, 52834],
     [True, 6573],
     [False, 6717],
     [True, 13602]]],
   [[False, 0],
    [False, 28750],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [False, 0],
    [False, 0]]],
  ['regression: scenario 3',
   [5,
    [[False, 23870],
     [True, 46782],
     [True, 46917],
     [True, 46976],
     [True, 56255],
     [True, 61627],
     [True, 1767],
     [True, 1874]]],
   [[False, 0], [False, 0], [True, 5], [True, 5], [True, 5], [True, 5], [True, 5], [True, 5]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['control: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 1',
   [100,
    [[False, 22859],
     [True, 23009],
     [True, 46893],
     [True, 47082],
     [True, 47173],
     [True, 47274],
     [False, 47358],
     [True, 47448],
     [True, 54303],
     [True, 54477],
     [False, 54574]]],
   [[False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [False, 0]]],
  ['control: scenario 4',
   [5,
    [[True, 25219],
     [True, 25303],
     [True, 25491],
     [True, 33180],
     [True, 33370],
     [True, 34085],
     [True, 35832],
     [True, 46392],
     [True, 48652],
     [True, 48709],
     [True, 6073],
     [True, 6100]]],
   [[False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5]]]],
 [['regression: scenario 3',
   [65535,
    [[False, 15447],
     [True, 18837],
     [False, 18898],
     [True, 19006],
     [False, 33164],
     [True, 33164],
     [True, 41175],
     [True, 53503],
     [True, 53600],
     [True, 6331],
     [True, 35575],
     [True, 35594],
     [True, 35643]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 8011],
    [False, 20339],
    [False, 20436],
    [False, 38703],
    [False, 2411],
    [False, 2430],
    [False, 2479]]],
  ['regression: scenario 4',
   [40000,
    [[False, 63428],
     [False, 10454],
     [True, 36085],
     [False, 36231],
     [True, 36344],
     [True, 36357],
     [True, 36437],
     [True, 36476],
     [True, 59214],
     [False, 59324],
     [True, 23687],
     [True, 45223],
     [False, 61971]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 13],
    [False, 93],
    [False, 132],
    [False, 22870],
    [False, 0],
    [False, 0],
    [False, 21536],
    [False, 0]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['control: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 1',
   [65535,
    [[False, 3784],
     [False, 8211],
     [False, 33966],
     [True, 50163],
     [True, 63009],
     [False, 63184],
     [True, 63243],
     [True, 63325]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 12846], [False, 0], [False, 0], [False, 82]]],
  ['regression: scenario 2',
   [1000,
    [[False, 46148],
     [True, 57365],
     [False, 57416],
     [True, 57439],
     [True, 57613],
     [True, 57776],
     [True, 61872],
     [True, 62038],
     [True, 9532],
     [True, 32841],
     [True, 32973]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 174],
    [False, 337],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000]]]],
 [['regression: scenario 5',
   [100,
    [[True, 65059],
     [True, 12093],
     [True, 36229],
     [True, 36982],
     [False, 57476],
     [True, 57575],
     [True, 12126],
     [True, 20887],
     [False, 28367]]],
   [[False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [False, 0]]],
  ['regression: scenario 6',
   [5,
    [[True, 49632],
     [True, 11081],
     [True, 11114],
     [True, 11176],
     [True, 11291],
     [False, 25142],
     [True, 49288],
     [True, 49464],
     [True, 49662],
     [True, 56076],
     [True, 56119],
     [False, 62264]]],
   [[False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [False, 0],
    [False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [False, 0]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['control: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 1',
   [40000,
    [[True, 14860],
     [True, 43167],
     [True, 43310],
     [True, 43470],
     [False, 65246],
     [False, 2333],
     [True, 20092],
     [True, 45967],
     [False, 64834],
     [True, 20225],
     [False, 20250],
     [True, 21773],
     [True, 26780]]],
   [[False, 0],
    [False, 28307],
    [False, 28450],
    [False, 28610],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 25875],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 5007]]],
  ['regression: scenario 2',
   [1000,
    [[True, 51184],
     [True, 56535],
     [True, 13279],
     [True, 24517],
     [True, 24685],
     [True, 32146],
     [True, 59255],
     [False, 21739],
     [True, 21822],
     [True, 43196]]],
   [[False, 0],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [False, 0],
    [False, 0],
    [True, 1000]]]]]
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, samples):
    start = None
    done = False
    out = []
    for enable, clock in samples:
        if not enable:
            if start is None:
                start = clock
            done = False
            out.append([False, 0])
            continue
        if start is None:
            start = clock
        elapsed = (clock - start) & 0xFFFF
        if elapsed >= preset:
            done = True
        out.append([done, preset if done else elapsed])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 1',
   [100,
    [[True, 53593],
     [True, 53635],
     [True, 10212],
     [False, 10250],
     [True, 24553],
     [True, 35364],
     [True, 35501],
     [True, 35591],
     [True, 65279],
     [True, 65379],
     [True, 65509]]],
   [[False, 0],
    [False, 42],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['control: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: scenario 2',
   [100,
    [[True, 17304],
     [True, 20531],
     [True, 27559],
     [False, 57396],
     [True, 19489],
     [True, 46000],
     [True, 46035],
     [True, 46209],
     [True, 5526]]],
   [[False, 0],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100]]],
  ['regression: scenario 3',
   [40000,
    [[True, 42783],
     [False, 4625],
     [True, 4670],
     [True, 8857],
     [False, 15422],
     [False, 15500],
     [True, 15560],
     [True, 27335],
     [True, 27471]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 4187],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 11775],
    [False, 11911]]],
  ['control: scenario 4',
   [100,
    [[True, 2607],
     [True, 18576],
     [True, 18609],
     [True, 18619],
     [True, 45272],
     [True, 45282],
     [True, 55824],
     [False, 61503]]],
   [[False, 0], [True, 100], [True, 100], [True, 100], [True, 100], [True, 100], [True, 100], [False, 0]]]],
 [['regression: scenario 1',
   [1000,
    [[False, 39404],
     [False, 39599],
     [True, 39752],
     [True, 39914],
     [False, 49270],
     [True, 53547],
     [True, 53700],
     [True, 4426]]],
   [[False, 0], [False, 0], [False, 0], [False, 162], [False, 0], [False, 0], [False, 153], [True, 1000]]],
  ['regression: scenario 2',
   [5,
    [[True, 40525],
     [True, 40666],
     [True, 40725],
     [True, 58227],
     [True, 18319],
     [False, 25775],
     [True, 25797],
     [True, 25799]]],
   [[False, 0], [True, 5], [True, 5], [True, 5], [True, 5], [False, 0], [False, 0], [False, 2]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['control: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 3',
   [5,
    [[False, 30258],
     [True, 30296],
     [True, 45510],
     [True, 2343],
     [True, 12538],
     [True, 12596],
     [False, 12635],
     [True, 37410],
     [True, 53676],
     [True, 10497],
     [True, 10628],
     [False, 10824],
     [True, 27527],
     [True, 55148]]],
   [[False, 0],
    [False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [False, 0],
    [False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [False, 0],
    [False, 0],
    [True, 5]]],
  ['regression: scenario 4',
   [65535,
    [[True, 43066],
     [True, 60153],
     [False, 2292],
     [True, 2392],
     [True, 12076],
     [False, 28626],
     [False, 28693],
     [False, 45850],
     [True, 5636]]],
   [[False, 0],
    [False, 17087],
    [False, 0],
    [False, 0],
    [False, 9684],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0]]]],
 [['regression: scenario 2',
   [40000,
    [[True, 54821],
     [True, 18035],
     [True, 32212],
     [True, 38340],
     [True, 38521],
     [True, 38565],
     [True, 38691],
     [True, 52834],
     [True, 6573],
     [False, 6717],
     [True, 13602]]],
   [[False, 0],
    [False, 28750],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [False, 0],
    [False, 0]]],
  ['regression: scenario 3',
   [5,
    [[False, 23870],
     [True, 46782],
     [True, 46917],
     [True, 46976],
     [True, 56255],
     [True, 61627],
     [True, 1767],
     [True, 1874]]],
   [[False, 0], [False, 0], [True, 5], [True, 5], [True, 5], [True, 5], [True, 5], [True, 5]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['control: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 1',
   [100,
    [[False, 22859],
     [True, 23009],
     [True, 46893],
     [True, 47082],
     [True, 47173],
     [True, 47274],
     [False, 47358],
     [True, 47448],
     [True, 54303],
     [True, 54477],
     [False, 54574]]],
   [[False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [False, 0]]],
  ['control: scenario 4',
   [5,
    [[True, 25219],
     [True, 25303],
     [True, 25491],
     [True, 33180],
     [True, 33370],
     [True, 34085],
     [True, 35832],
     [True, 46392],
     [True, 48652],
     [True, 48709],
     [True, 6073],
     [True, 6100]]],
   [[False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5]]]],
 [['regression: scenario 3',
   [65535,
    [[False, 15447],
     [True, 18837],
     [False, 18898],
     [True, 19006],
     [False, 33164],
     [True, 33164],
     [True, 41175],
     [True, 53503],
     [True, 53600],
     [True, 6331],
     [True, 35575],
     [True, 35594],
     [True, 35643]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 8011],
    [False, 20339],
    [False, 20436],
    [False, 38703],
    [False, 2411],
    [False, 2430],
    [False, 2479]]],
  ['regression: scenario 4',
   [40000,
    [[False, 63428],
     [False, 10454],
     [True, 36085],
     [False, 36231],
     [True, 36344],
     [True, 36357],
     [True, 36437],
     [True, 36476],
     [True, 59214],
     [False, 59324],
     [True, 23687],
     [True, 45223],
     [False, 61971]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 13],
    [False, 93],
    [False, 132],
    [False, 22870],
    [False, 0],
    [False, 0],
    [False, 21536],
    [False, 0]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['control: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 1',
   [65535,
    [[False, 3784],
     [False, 8211],
     [False, 33966],
     [True, 50163],
     [True, 63009],
     [False, 63184],
     [True, 63243],
     [True, 63325]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 12846], [False, 0], [False, 0], [False, 82]]],
  ['regression: scenario 2',
   [1000,
    [[False, 46148],
     [True, 57365],
     [False, 57416],
     [True, 57439],
     [True, 57613],
     [True, 57776],
     [True, 61872],
     [True, 62038],
     [True, 9532],
     [True, 32841],
     [True, 32973]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 174],
    [False, 337],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000]]]],
 [['regression: scenario 5',
   [100,
    [[True, 65059],
     [True, 12093],
     [True, 36229],
     [True, 36982],
     [False, 57476],
     [True, 57575],
     [True, 12126],
     [True, 20887],
     [False, 28367]]],
   [[False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [False, 0]]],
  ['regression: scenario 6',
   [5,
    [[True, 49632],
     [True, 11081],
     [True, 11114],
     [True, 11176],
     [True, 11291],
     [False, 25142],
     [True, 49288],
     [True, 49464],
     [True, 49662],
     [True, 56076],
     [True, 56119],
     [False, 62264]]],
   [[False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [False, 0],
    [False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [False, 0]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['control: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 1',
   [40000,
    [[True, 14860],
     [True, 43167],
     [True, 43310],
     [True, 43470],
     [False, 65246],
     [False, 2333],
     [True, 20092],
     [True, 45967],
     [False, 64834],
     [True, 20225],
     [False, 20250],
     [True, 21773],
     [True, 26780]]],
   [[False, 0],
    [False, 28307],
    [False, 28450],
    [False, 28610],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 25875],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 5007]]],
  ['regression: scenario 2',
   [1000,
    [[True, 51184],
     [True, 56535],
     [True, 13279],
     [True, 24517],
     [True, 24685],
     [True, 32146],
     [True, 59255],
     [False, 21739],
     [True, 21822],
     [True, 43196]]],
   [[False, 0],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [False, 0],
    [False, 0],
    [True, 1000]]]]]
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 an idle period the timer finishes immediately because time before the enable is counted.

Delay timer built on a 16-bit free-running clock register (ticks wrap from 65535 to 0). samples is a list of [enable, clock] read each scan. The first enabled scan captures the start tick; elapsed is (clock - start) modulo 65536. Done latches once elapsed >= preset and stays set while enabled even if the elapsed value later wraps. A disabled scan clears start and done. Return [done, elapsed capped at preset once done] per scan, [False, 0] when disabled.

split: open-access


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

N = 1
observations = []
def solve(preset, samples):
    start = None
    done = False
    out = []
    for enable, clock in samples:
        if not enable:
            start = None
            done = False
            out.append([False, 0])
            continue
        if start is None:
            start = clock
        elapsed = (clock - start) & 0xFFFF
        if elapsed >= preset:
            done = True
        out.append([done, elapsed])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['regression: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 1',
   [100,
    [[True, 53593],
     [True, 53635],
     [True, 10212],
     [False, 10250],
     [True, 24553],
     [True, 35364],
     [True, 35501],
     [True, 35591],
     [True, 65279],
     [True, 65379],
     [True, 65509]]],
   [[False, 0],
    [False, 42],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100]]],
  ['regression: scenario 2',
   [100,
    [[True, 17304],
     [True, 20531],
     [True, 27559],
     [False, 57396],
     [True, 19489],
     [True, 46000],
     [True, 46035],
     [True, 46209],
     [True, 5526]]],
   [[False, 0],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100]]],
  ['control: scenario 3',
   [40000,
    [[True, 42783],
     [False, 4625],
     [True, 4670],
     [True, 8857],
     [False, 15422],
     [False, 15500],
     [True, 15560],
     [True, 27335],
     [True, 27471]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 4187],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 11775],
    [False, 11911]]],
  ['regression: scenario 4',
   [100,
    [[True, 2607],
     [True, 18576],
     [True, 18609],
     [True, 18619],
     [True, 45272],
     [True, 45282],
     [True, 55824],
     [False, 61503]]],
   [[False, 0], [True, 100], [True, 100], [True, 100], [True, 100], [True, 100], [True, 100], [False, 0]]]],
 [['regression: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 1',
   [1000,
    [[False, 39404],
     [False, 39599],
     [True, 39752],
     [True, 39914],
     [False, 49270],
     [True, 53547],
     [True, 53700],
     [True, 4426]]],
   [[False, 0], [False, 0], [False, 0], [False, 162], [False, 0], [False, 0], [False, 153], [True, 1000]]],
  ['regression: scenario 2',
   [5,
    [[True, 40525],
     [True, 40666],
     [True, 40725],
     [True, 58227],
     [True, 18319],
     [False, 25775],
     [True, 25797],
     [True, 25799]]],
   [[False, 0], [True, 5], [True, 5], [True, 5], [True, 5], [False, 0], [False, 0], [False, 2]]],
  ['regression: scenario 3',
   [5,
    [[False, 30258],
     [True, 30296],
     [True, 45510],
     [True, 2343],
     [True, 12538],
     [True, 12596],
     [False, 12635],
     [True, 37410],
     [True, 53676],
     [True, 10497],
     [True, 10628],
     [False, 10824],
     [True, 27527],
     [True, 55148]]],
   [[False, 0],
    [False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [False, 0],
    [False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [False, 0],
    [False, 0],
    [True, 5]]],
  ['control: scenario 4',
   [65535,
    [[True, 43066],
     [True, 60153],
     [False, 2292],
     [True, 2392],
     [True, 12076],
     [False, 28626],
     [False, 28693],
     [False, 45850],
     [True, 5636]]],
   [[False, 0],
    [False, 17087],
    [False, 0],
    [False, 0],
    [False, 9684],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0]]]],
 [['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 2',
   [40000,
    [[True, 54821],
     [True, 18035],
     [True, 32212],
     [True, 38340],
     [True, 38521],
     [True, 38565],
     [True, 38691],
     [True, 52834],
     [True, 6573],
     [False, 6717],
     [True, 13602]]],
   [[False, 0],
    [False, 28750],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [False, 0],
    [False, 0]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['regression: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['regression: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: scenario 1',
   [100,
    [[False, 22859],
     [True, 23009],
     [True, 46893],
     [True, 47082],
     [True, 47173],
     [True, 47274],
     [False, 47358],
     [True, 47448],
     [True, 54303],
     [True, 54477],
     [False, 54574]]],
   [[False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [False, 0]]],
  ['regression: scenario 3',
   [5,
    [[False, 23870],
     [True, 46782],
     [True, 46917],
     [True, 46976],
     [True, 56255],
     [True, 61627],
     [True, 1767],
     [True, 1874]]],
   [[False, 0], [False, 0], [True, 5], [True, 5], [True, 5], [True, 5], [True, 5], [True, 5]]],
  ['regression: scenario 4',
   [5,
    [[True, 25219],
     [True, 25303],
     [True, 25491],
     [True, 33180],
     [True, 33370],
     [True, 34085],
     [True, 35832],
     [True, 46392],
     [True, 48652],
     [True, 48709],
     [True, 6073],
     [True, 6100]]],
   [[False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5]]]],
 [['regression: scenario 2',
   [1000,
    [[False, 46148],
     [True, 57365],
     [False, 57416],
     [True, 57439],
     [True, 57613],
     [True, 57776],
     [True, 61872],
     [True, 62038],
     [True, 9532],
     [True, 32841],
     [True, 32973]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 174],
    [False, 337],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000]]],
  ['regression: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['regression: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['control: scenario 1',
   [65535,
    [[False, 3784],
     [False, 8211],
     [False, 33966],
     [True, 50163],
     [True, 63009],
     [False, 63184],
     [True, 63243],
     [True, 63325]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 12846], [False, 0], [False, 0], [False, 82]]],
  ['control: scenario 3',
   [65535,
    [[False, 15447],
     [True, 18837],
     [False, 18898],
     [True, 19006],
     [False, 33164],
     [True, 33164],
     [True, 41175],
     [True, 53503],
     [True, 53600],
     [True, 6331],
     [True, 35575],
     [True, 35594],
     [True, 35643]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 8011],
    [False, 20339],
    [False, 20436],
    [False, 38703],
    [False, 2411],
    [False, 2430],
    [False, 2479]]],
  ['control: scenario 4',
   [40000,
    [[False, 63428],
     [False, 10454],
     [True, 36085],
     [False, 36231],
     [True, 36344],
     [True, 36357],
     [True, 36437],
     [True, 36476],
     [True, 59214],
     [False, 59324],
     [True, 23687],
     [True, 45223],
     [False, 61971]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 13],
    [False, 93],
    [False, 132],
    [False, 22870],
    [False, 0],
    [False, 0],
    [False, 21536],
    [False, 0]]]],
 [['regression: scenario 3',
   [1000,
    [[True, 22897],
     [True, 22914],
     [True, 28312],
     [True, 28374],
     [True, 35057],
     [True, 50246],
     [True, 63704],
     [True, 65227],
     [True, 26677],
     [True, 39163]]],
   [[False, 0],
    [False, 17],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000]]],
  ['regression: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['regression: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['control: scenario 1',
   [40000,
    [[True, 14860],
     [True, 43167],
     [True, 43310],
     [True, 43470],
     [False, 65246],
     [False, 2333],
     [True, 20092],
     [True, 45967],
     [False, 64834],
     [True, 20225],
     [False, 20250],
     [True, 21773],
     [True, 26780]]],
   [[False, 0],
    [False, 28307],
    [False, 28450],
    [False, 28610],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 25875],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 5007]]],
  ['regression: scenario 2',
   [1000,
    [[True, 51184],
     [True, 56535],
     [True, 13279],
     [True, 24517],
     [True, 24685],
     [True, 32146],
     [True, 59255],
     [False, 21739],
     [True, 21822],
     [True, 43196]]],
   [[False, 0],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [False, 0],
    [False, 0],
    [True, 1000]]],
  ['regression: scenario 4',
   [1000,
    [[True, 38985],
     [True, 39119],
     [True, 46977],
     [True, 47168],
     [False, 6446],
     [True, 33057],
     [True, 33083],
     [True, 33130],
     [True, 49169],
     [True, 49195],
     [True, 49212],
     [True, 12968],
     [True, 13081]]],
   [[False, 0],
    [False, 134],
    [True, 1000],
    [True, 1000],
    [False, 0],
    [False, 0],
    [False, 26],
    [False, 73],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000]]]]]
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, samples):
    start = None
    done = False
    out = []
    for enable, clock in samples:
        if not enable:
            start = None
            done = False
            out.append([False, 0])
            continue
        if start is None:
            start = clock
        elapsed = (clock - start) & 0xFFFF
        if elapsed >= preset:
            done = True
        out.append([done, min(elapsed, preset)])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['regression: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 1',
   [100,
    [[True, 53593],
     [True, 53635],
     [True, 10212],
     [False, 10250],
     [True, 24553],
     [True, 35364],
     [True, 35501],
     [True, 35591],
     [True, 65279],
     [True, 65379],
     [True, 65509]]],
   [[False, 0],
    [False, 42],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100]]],
  ['regression: scenario 2',
   [100,
    [[True, 17304],
     [True, 20531],
     [True, 27559],
     [False, 57396],
     [True, 19489],
     [True, 46000],
     [True, 46035],
     [True, 46209],
     [True, 5526]]],
   [[False, 0],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100]]],
  ['control: scenario 3',
   [40000,
    [[True, 42783],
     [False, 4625],
     [True, 4670],
     [True, 8857],
     [False, 15422],
     [False, 15500],
     [True, 15560],
     [True, 27335],
     [True, 27471]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 4187],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 11775],
    [False, 11911]]],
  ['regression: scenario 4',
   [100,
    [[True, 2607],
     [True, 18576],
     [True, 18609],
     [True, 18619],
     [True, 45272],
     [True, 45282],
     [True, 55824],
     [False, 61503]]],
   [[False, 0], [True, 100], [True, 100], [True, 100], [True, 100], [True, 100], [True, 100], [False, 0]]]],
 [['regression: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 1',
   [1000,
    [[False, 39404],
     [False, 39599],
     [True, 39752],
     [True, 39914],
     [False, 49270],
     [True, 53547],
     [True, 53700],
     [True, 4426]]],
   [[False, 0], [False, 0], [False, 0], [False, 162], [False, 0], [False, 0], [False, 153], [True, 1000]]],
  ['regression: scenario 2',
   [5,
    [[True, 40525],
     [True, 40666],
     [True, 40725],
     [True, 58227],
     [True, 18319],
     [False, 25775],
     [True, 25797],
     [True, 25799]]],
   [[False, 0], [True, 5], [True, 5], [True, 5], [True, 5], [False, 0], [False, 0], [False, 2]]],
  ['regression: scenario 3',
   [5,
    [[False, 30258],
     [True, 30296],
     [True, 45510],
     [True, 2343],
     [True, 12538],
     [True, 12596],
     [False, 12635],
     [True, 37410],
     [True, 53676],
     [True, 10497],
     [True, 10628],
     [False, 10824],
     [True, 27527],
     [True, 55148]]],
   [[False, 0],
    [False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [False, 0],
    [False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [False, 0],
    [False, 0],
    [True, 5]]],
  ['control: scenario 4',
   [65535,
    [[True, 43066],
     [True, 60153],
     [False, 2292],
     [True, 2392],
     [True, 12076],
     [False, 28626],
     [False, 28693],
     [False, 45850],
     [True, 5636]]],
   [[False, 0],
    [False, 17087],
    [False, 0],
    [False, 0],
    [False, 9684],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0]]]],
 [['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['regression: scenario 2',
   [40000,
    [[True, 54821],
     [True, 18035],
     [True, 32212],
     [True, 38340],
     [True, 38521],
     [True, 38565],
     [True, 38691],
     [True, 52834],
     [True, 6573],
     [False, 6717],
     [True, 13602]]],
   [[False, 0],
    [False, 28750],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [True, 40000],
    [False, 0],
    [False, 0]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['regression: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['regression: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: scenario 1',
   [100,
    [[False, 22859],
     [True, 23009],
     [True, 46893],
     [True, 47082],
     [True, 47173],
     [True, 47274],
     [False, 47358],
     [True, 47448],
     [True, 54303],
     [True, 54477],
     [False, 54574]]],
   [[False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [True, 100],
    [True, 100],
    [False, 0],
    [False, 0],
    [True, 100],
    [True, 100],
    [False, 0]]],
  ['regression: scenario 3',
   [5,
    [[False, 23870],
     [True, 46782],
     [True, 46917],
     [True, 46976],
     [True, 56255],
     [True, 61627],
     [True, 1767],
     [True, 1874]]],
   [[False, 0], [False, 0], [True, 5], [True, 5], [True, 5], [True, 5], [True, 5], [True, 5]]],
  ['regression: scenario 4',
   [5,
    [[True, 25219],
     [True, 25303],
     [True, 25491],
     [True, 33180],
     [True, 33370],
     [True, 34085],
     [True, 35832],
     [True, 46392],
     [True, 48652],
     [True, 48709],
     [True, 6073],
     [True, 6100]]],
   [[False, 0],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5],
    [True, 5]]]],
 [['regression: scenario 2',
   [1000,
    [[False, 46148],
     [True, 57365],
     [False, 57416],
     [True, 57439],
     [True, 57613],
     [True, 57776],
     [True, 61872],
     [True, 62038],
     [True, 9532],
     [True, 32841],
     [True, 32973]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 174],
    [False, 337],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000]]],
  ['regression: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['regression: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['control: scenario 1',
   [65535,
    [[False, 3784],
     [False, 8211],
     [False, 33966],
     [True, 50163],
     [True, 63009],
     [False, 63184],
     [True, 63243],
     [True, 63325]]],
   [[False, 0], [False, 0], [False, 0], [False, 0], [False, 12846], [False, 0], [False, 0], [False, 82]]],
  ['control: scenario 3',
   [65535,
    [[False, 15447],
     [True, 18837],
     [False, 18898],
     [True, 19006],
     [False, 33164],
     [True, 33164],
     [True, 41175],
     [True, 53503],
     [True, 53600],
     [True, 6331],
     [True, 35575],
     [True, 35594],
     [True, 35643]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 8011],
    [False, 20339],
    [False, 20436],
    [False, 38703],
    [False, 2411],
    [False, 2430],
    [False, 2479]]],
  ['control: scenario 4',
   [40000,
    [[False, 63428],
     [False, 10454],
     [True, 36085],
     [False, 36231],
     [True, 36344],
     [True, 36357],
     [True, 36437],
     [True, 36476],
     [True, 59214],
     [False, 59324],
     [True, 23687],
     [True, 45223],
     [False, 61971]]],
   [[False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 13],
    [False, 93],
    [False, 132],
    [False, 22870],
    [False, 0],
    [False, 0],
    [False, 21536],
    [False, 0]]]],
 [['regression: scenario 3',
   [1000,
    [[True, 22897],
     [True, 22914],
     [True, 28312],
     [True, 28374],
     [True, 35057],
     [True, 50246],
     [True, 63704],
     [True, 65227],
     [True, 26677],
     [True, 39163]]],
   [[False, 0],
    [False, 17],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000]]],
  ['regression: long enable past a full wrap',
   [1000, [[True, 100], [True, 30100], [True, 60100], [True, 24564], [True, 700]]],
   [[False, 0], [True, 1000], [True, 1000], [True, 1000], [True, 1000]]],
  ['control: clock wrap',
   [100, [[True, 65500], [True, 65530], [True, 40], [True, 64], [False, 70]]],
   [[False, 0], [False, 30], [False, 76], [True, 100], [False, 0]]],
  ['regression: elapsed returns to zero',
   [5, [[True, 10], [True, 20], [True, 10], [True, 12]]],
   [[False, 0], [True, 5], [True, 5], [True, 5]]],
  ['regression: enable after idle',
   [50, [[False, 0], [False, 400], [True, 900], [True, 930], [True, 960]]],
   [[False, 0], [False, 0], [False, 0], [False, 30], [True, 50]]],
  ['control: scenario 1',
   [40000,
    [[True, 14860],
     [True, 43167],
     [True, 43310],
     [True, 43470],
     [False, 65246],
     [False, 2333],
     [True, 20092],
     [True, 45967],
     [False, 64834],
     [True, 20225],
     [False, 20250],
     [True, 21773],
     [True, 26780]]],
   [[False, 0],
    [False, 28307],
    [False, 28450],
    [False, 28610],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 25875],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 0],
    [False, 5007]]],
  ['regression: scenario 2',
   [1000,
    [[True, 51184],
     [True, 56535],
     [True, 13279],
     [True, 24517],
     [True, 24685],
     [True, 32146],
     [True, 59255],
     [False, 21739],
     [True, 21822],
     [True, 43196]]],
   [[False, 0],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [False, 0],
    [False, 0],
    [True, 1000]]],
  ['regression: scenario 4',
   [1000,
    [[True, 38985],
     [True, 39119],
     [True, 46977],
     [True, 47168],
     [False, 6446],
     [True, 33057],
     [True, 33083],
     [True, 33130],
     [True, 49169],
     [True, 49195],
     [True, 49212],
     [True, 12968],
     [True, 13081]]],
   [[False, 0],
    [False, 134],
    [True, 1000],
    [True, 1000],
    [False, 0],
    [False, 0],
    [False, 26],
    [False, 73],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000],
    [True, 1000]]]]]
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:
The reported accumulated time keeps changing (and wraps) after the timer is done.

Delay timer built on a 16-bit free-running clock register (ticks wrap from 65535 to 0). samples is a list of [enable, clock] read each scan. The first enabled scan captures the start tick; elapsed is (clock - start) modulo 65536. Done latches once elapsed >= preset and stays set while enabled even if the elapsed value later wraps. A disabled scan clears start and done. Return [done, elapsed capped at preset once done] per scan, [False, 0] when disabled.

split: open-access


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

N = 1
observations = []
def solve(window, samples):
    first_press = None
    armed = True
    run = False
    out = []
    for t, left, right in samples:
        left = bool(left)
        right = bool(right)
        if not left and not right:
            armed = True
            first_press = None
            run = False
        elif left and right:
            if not run:
                begin = t if first_press is None else first_press
                if armed and t - begin < window:
                    run = True
                armed = False
        else:
            run = False
            if first_press is None:
                first_press = t
        out.append(run)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: exact window',
   [200, [[0, False, True], [200, True, True], [300, False, False]]],
   [False, True, False]],
  ['regression: normal cycle',
   [500,
    [[0, True, False],
     [300, True, True],
     [400, True, True],
     [500, False, True],
     [600, False, False],
     [700, True, True]]],
   [False, True, True, False, False, True]],
  ['control: late second hand',
   [200, [[0, True, False], [300, True, True], [400, False, False], [500, True, False], [600, True, True]]],
   [False, False, False, False, True]],
  ['control: tie down one button',
   [200,
    [[0, True, False],
     [100, True, True],
     [200, True, False],
     [300, True, True],
     [400, True, False],
     [450, True, True]]],
   [False, True, False, False, False, False]],
  ['regression: simultaneous press then release one',
   [200, [[0, True, True], [100, True, False], [200, True, True]]],
   [True, False, False]],
  ['regression: scenario 1',
   [200,
    [[0, False, False],
     [100, True, True],
     [400, True, True],
     [500, True, True],
     [650, True, True],
     [850, True, True],
     [1050, True, False],
     [1100, False, False],
     [1300, True, True],
     [1600, True, True]]],
   [False, True, True, True, True, True, False, False, True, True]],
  ['regression: scenario 2',
   [200,
    [[0, True, True],
     [50, True, False],
     [200, True, True],
     [250, False, False],
     [300, False, True],
     [400, False, False],
     [450, False, False],
     [550, False, True]]],
   [True, False, False, False, False, False, False, False]],
  ['regression: scenario 3',
   [200,
    [[0, True, False],
     [150, True, True],
     [200, True, True],
     [400, False, False],
     [500, True, True],
     [700, True, True],
     [850, True, False],
     [1000, True, False],
     [1100, False, False],
     [1400, True, False],
     [1450, False, True],
     [1600, True, True],
     [1700, True, True]]],
   [False, True, True, False, True, True, False, False, False, False, False, True, True]]],
 [['regression: scenario 16',
   [500,
    [[0, True, False],
     [50, False, False],
     [350, False, True],
     [550, True, False],
     [850, True, True],
     [1050, True, False],
     [1150, False, False],
     [1250, True, True],
     [1550, True, False],
     [1700, True, False]]],
   [False, False, False, False, True, False, False, True, False, False]],
  ['regression: simultaneous press then release one',
   [200, [[0, True, True], [100, True, False], [200, True, True]]],
   [True, False, False]],
  ['regression: normal cycle',
   [500,
    [[0, True, False],
     [300, True, True],
     [400, True, True],
     [500, False, True],
     [600, False, False],
     [700, True, True]]],
   [False, True, True, False, False, True]],
  ['control: late second hand',
   [200, [[0, True, False], [300, True, True], [400, False, False], [500, True, False], [600, True, True]]],
   [False, False, False, False, True]],
  ['regression: exact window',
   [200, [[0, False, True], [200, True, True], [300, False, False]]],
   [False, True, False]],
  ['control: tie down one button',
   [200,
    [[0, True, False],
     [100, True, True],
     [200, True, False],
     [300, True, True],
     [400, True, False],
     [450, True, True]]],
   [False, True, False, False, False, False]],
  ['regression: scenario 1',
   [250,
    [[0, True, True],
     [50, True, True],
     [200, False, True],
     [300, True, True],
     [600, True, True],
     [750, False, True],
     [850, False, False],
     [1000, False, True],
     [1100, True, True]]],
   [True, True, False, False, False, False, False, False, True]],
  ['regression: scenario 2',
   [250,
    [[0, True, True],
     [50, False, True],
     [200, False, False],
     [250, True, False],
     [400, True, True],
     [500, True, True],
     [650, False, False],
     [700, True, True],
     [850, False, False],
     [1000, False, True],
     [1150, False, True],
     [1250, False, True],
     [1550, False, False]]],
   [True, False, False, False, True, True, False, True, False, False, False, False, False]]],
 [['regression: scenario 19',
   [500,
    [[0, True, False],
     [50, True, False],
     [350, False, True],
     [500, True, True],
     [550, True, False],
     [650, False, False],
     [850, False, False],
     [900, True, False],
     [1050, True, False]]],
   [False, False, False, True, False, False, False, False, False]],
  ['regression: scenario 2',
   [250,
    [[0, False, False],
     [150, False, False],
     [350, False, False],
     [400, True, True],
     [600, True, False],
     [750, False, True],
     [1050, True, True],
     [1150, True, True],
     [1350, True, False],
     [1400, False, False],
     [1550, True, False]]],
   [False, False, False, True, False, False, False, False, False, False, False]],
  ['regression: normal cycle',
   [500,
    [[0, True, False],
     [300, True, True],
     [400, True, True],
     [500, False, True],
     [600, False, False],
     [700, True, True]]],
   [False, True, True, False, False, True]],
  ['control: late second hand',
   [200, [[0, True, False], [300, True, True], [400, False, False], [500, True, False], [600, True, True]]],
   [False, False, False, False, True]],
  ['regression: exact window',
   [200, [[0, False, True], [200, True, True], [300, False, False]]],
   [False, True, False]],
  ['control: tie down one button',
   [200,
    [[0, True, False],
     [100, True, True],
     [200, True, False],
     [300, True, True],
     [400, True, False],
     [450, True, True]]],
   [False, True, False, False, False, False]],
  ['regression: simultaneous press then release one',
   [200, [[0, True, True], [100, True, False], [200, True, True]]],
   [True, False, False]],
  ['control: scenario 1',
   [200,
    [[0, False, True],
     [100, False, False],
     [250, False, False],
     [300, True, False],
     [400, True, False],
     [450, False, True],
     [550, True, False],
     [700, True, False],
     [800, False, True]]],
   [False, False, False, False, False, False, False, False, False]]],
 [['regression: scenario 55',
   [200,
    [[0, True, True],
     [100, False, False],
     [200, True, True],
     [250, True, True],
     [550, False, False],
     [750, True, True],
     [850, False, False],
     [950, False, True],
     [1150, True, True],
     [1200, False, False]]],
   [True, False, True, True, False, True, False, False, True, False]],
  ['regression: scenario 2',
   [250,
    [[0, True, False],
     [150, False, False],
     [200, True, True],
     [350, False, False],
     [400, True, False],
     [500, False, False],
     [800, True, False],
     [1000, True, False],
     [1050, False, False],
     [1100, True, False],
     [1400, False, False],
     [1450, False, False],
     [1600, False, True],
     [1800, True, False]]],
   [False, False, True, False, False, False, False, False, False, False, False, False, False, False]],
  ['regression: normal cycle',
   [500,
    [[0, True, False],
     [300, True, True],
     [400, True, True],
     [500, False, True],
     [600, False, False],
     [700, True, True]]],
   [False, True, True, False, False, True]],
  ['control: late second hand',
   [200, [[0, True, False], [300, True, True], [400, False, False], [500, True, False], [600, True, True]]],
   [False, False, False, False, True]],
  ['regression: exact window',
   [200, [[0, False, True], [200, True, True], [300, False, False]]],
   [False, True, False]],
  ['control: tie down one button',
   [200,
    [[0, True, False],
     [100, True, True],
     [200, True, False],
     [300, True, True],
     [400, True, False],
     [450, True, True]]],
   [False, True, False, False, False, False]],
  ['regression: simultaneous press then release one',
   [200, [[0, True, True], [100, True, False], [200, True, True]]],
   [True, False, False]],
  ['regression: scenario 1',
   [250,
    [[0, False, True],
     [200, False, False],
     [250, True, False],
     [550, True, False],
     [650, True, True],
     [700, True, False],
     [900, True, True],
     [1100, True, False],
     [1200, False, True],
     [1300, True, False],
     [1450, False, True],
     [1650, False, False],
     [1800, True, True]]],
   [False, False, False, False, False, False, False, False, False, False, False, False, True]]],
 [['regression: scenario 13',
   [200,
    [[0, False, True],
     [300, True, True],
     [600, False, False],
     [700, False, False],
     [850, False, True],
     [950, True, True],
     [1250, True, False],
     [1550, False, False],
     [1650, False, False],
     [1950, True, False],
     [2150, True, True],
     [2450, True, False],
     [2500, False, True]]],
   [False, False, False, False, False, True, False, False, False, False, True, False, False]],
  ['regression: scenario 6',
   [250,
    [[0, False, True],
     [150, True, True],
     [300, False, False],
     [400, False, True],
     [600, True, False],
     [650, True, True],
     [750, False, False],
     [1050, True, True]]],
   [False, True, False, False, False, True, False, True]],
  ['regression: normal cycle',
   [500,
    [[0, True, False],
     [300, True, True],
     [400, True, True],
     [500, False, True],
     [600, False, False],
     [700, True, True]]],
   [False, True, True, False, False, True]],
  ['control: late second hand',
   [200, [[0, True, False], [300, True, True], [400, False, False], [500, True, False], [600, True, True]]],
   [False, False, False, False, True]],
  ['regression: exact window',
   [200, [[0, False, True], [200, True, True], [300, False, False]]],
   [False, True, False]],
  ['control: tie down one button',
   [200,
    [[0, True, False],
     [100, True, True],
     [200, True, False],
     [300, True, True],
     [400, True, False],
     [450, True, True]]],
   [False, True, False, False, False, False]],
  ['regression: simultaneous press then release one',
   [200, [[0, True, True], [100, True, False], [200, True, True]]],
   [True, False, False]],
  ['control: scenario 1',
   [500,
    [[0, True, False],
     [150, True, False],
     [250, True, False],
     [300, False, False],
     [350, False, True],
     [650, False, True],
     [850, False, False],
     [1150, False, False],
     [1350, True, False],
     [1650, True, False],
     [1800, True, False],
     [1850, True, False],
     [1900, False, True]]],
   [False, False, False, False, False, False, False, False, False, False, False, False, False]]]]
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(window, samples):
    first_press = None
    armed = True
    run = False
    out = []
    for t, left, right in samples:
        left = bool(left)
        right = bool(right)
        if not left and not right:
            armed = True
            first_press = None
            run = False
        elif left and right:
            if not run:
                begin = t if first_press is None else first_press
                if armed and t - begin <= window and t > begin:
                    run = True
                armed = False
        else:
            run = False
            if first_press is None:
                first_press = t
        out.append(run)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: exact window',
   [200, [[0, False, True], [200, True, True], [300, False, False]]],
   [False, True, False]],
  ['regression: normal cycle',
   [500,
    [[0, True, False],
     [300, True, True],
     [400, True, True],
     [500, False, True],
     [600, False, False],
     [700, True, True]]],
   [False, True, True, False, False, True]],
  ['control: late second hand',
   [200, [[0, True, False], [300, True, True], [400, False, False], [500, True, False], [600, True, True]]],
   [False, False, False, False, True]],
  ['control: tie down one button',
   [200,
    [[0, True, False],
     [100, True, True],
     [200, True, False],
     [300, True, True],
     [400, True, False],
     [450, True, True]]],
   [False, True, False, False, False, False]],
  ['regression: simultaneous press then release one',
   [200, [[0, True, True], [100, True, False], [200, True, True]]],
   [True, False, False]],
  ['regression: scenario 1',
   [200,
    [[0, False, False],
     [100, True, True],
     [400, True, True],
     [500, True, True],
     [650, True, True],
     [850, True, True],
     [1050, True, False],
     [1100, False, False],
     [1300, True, True],
     [1600, True, True]]],
   [False, True, True, True, True, True, False, False, True, True]],
  ['regression: scenario 2',
   [200,
    [[0, True, True],
     [50, True, False],
     [200, True, True],
     [250, False, False],
     [300, False, True],
     [400, False, False],
     [450, False, False],
     [550, False, True]]],
   [True, False, False, False, False, False, False, False]],
  ['regression: scenario 3',
   [200,
    [[0, True, False],
     [150, True, True],
     [200, True, True],
     [400, False, False],
     [500, True, True],
     [700, True, True],
     [850, True, False],
     [1000, True, False],
     [1100, False, False],
     [1400, True, False],
     [1450, False, True],
     [1600, True, True],
     [1700, True, True]]],
   [False, True, True, False, True, True, False, False, False, False, False, True, True]]],
 [['regression: scenario 16',
   [500,
    [[0, True, False],
     [50, False, False],
     [350, False, True],
     [550, True, False],
     [850, True, True],
     [1050, True, False],
     [1150, False, False],
     [1250, True, True],
     [1550, True, False],
     [1700, True, False]]],
   [False, False, False, False, True, False, False, True, False, False]],
  ['regression: simultaneous press then release one',
   [200, [[0, True, True], [100, True, False], [200, True, True]]],
   [True, False, False]],
  ['regression: normal cycle',
   [500,
    [[0, True, False],
     [300, True, True],
     [400, True, True],
     [500, False, True],
     [600, False, False],
     [700, True, True]]],
   [False, True, True, False, False, True]],
  ['control: late second hand',
   [200, [[0, True, False], [300, True, True], [400, False, False], [500, True, False], [600, True, True]]],
   [False, False, False, False, True]],
  ['regression: exact window',
   [200, [[0, False, True], [200, True, True], [300, False, False]]],
   [False, True, False]],
  ['control: tie down one button',
   [200,
    [[0, True, False],
     [100, True, True],
     [200, True, False],
     [300, True, True],
     [400, True, False],
     [450, True, True]]],
   [False, True, False, False, False, False]],
  ['regression: scenario 1',
   [250,
    [[0, True, True],
     [50, True, True],
     [200, False, True],
     [300, True, True],
     [600, True, True],
     [750, False, True],
     [850, False, False],
     [1000, False, True],
     [1100, True, True]]],
   [True, True, False, False, False, False, False, False, True]],
  ['regression: scenario 2',
   [250,
    [[0, True, True],
     [50, False, True],
     [200, False, False],
     [250, True, False],
     [400, True, True],
     [500, True, True],
     [650, False, False],
     [700, True, True],
     [850, False, False],
     [1000, False, True],
     [1150, False, True],
     [1250, False, True],
     [1550, False, False]]],
   [True, False, False, False, True, True, False, True, False, False, False, False, False]]],
 [['regression: scenario 19',
   [500,
    [[0, True, False],
     [50, True, False],
     [350, False, True],
     [500, True, True],
     [550, True, False],
     [650, False, False],
     [850, False, False],
     [900, True, False],
     [1050, True, False]]],
   [False, False, False, True, False, False, False, False, False]],
  ['regression: scenario 2',
   [250,
    [[0, False, False],
     [150, False, False],
     [350, False, False],
     [400, True, True],
     [600, True, False],
     [750, False, True],
     [1050, True, True],
     [1150, True, True],
     [1350, True, False],
     [1400, False, False],
     [1550, True, False]]],
   [False, False, False, True, False, False, False, False, False, False, False]],
  ['regression: normal cycle',
   [500,
    [[0, True, False],
     [300, True, True],
     [400, True, True],
     [500, False, True],
     [600, False, False],
     [700, True, True]]],
   [False, True, True, False, False, True]],
  ['control: late second hand',
   [200, [[0, True, False], [300, True, True], [400, False, False], [500, True, False], [600, True, True]]],
   [False, False, False, False, True]],
  ['regression: exact window',
   [200, [[0, False, True], [200, True, True], [300, False, False]]],
   [False, True, False]],
  ['control: tie down one button',
   [200,
    [[0, True, False],
     [100, True, True],
     [200, True, False],
     [300, True, True],
     [400, True, False],
     [450, True, True]]],
   [False, True, False, False, False, False]],
  ['regression: simultaneous press then release one',
   [200, [[0, True, True], [100, True, False], [200, True, True]]],
   [True, False, False]],
  ['control: scenario 1',
   [200,
    [[0, False, True],
     [100, False, False],
     [250, False, False],
     [300, True, False],
     [400, True, False],
     [450, False, True],
     [550, True, False],
     [700, True, False],
     [800, False, True]]],
   [False, False, False, False, False, False, False, False, False]]],
 [['regression: scenario 55',
   [200,
    [[0, True, True],
     [100, False, False],
     [200, True, True],
     [250, True, True],
     [550, False, False],
     [750, True, True],
     [850, False, False],
     [950, False, True],
     [1150, True, True],
     [1200, False, False]]],
   [True, False, True, True, False, True, False, False, True, False]],
  ['regression: scenario 2',
   [250,
    [[0, True, False],
     [150, False, False],
     [200, True, True],
     [350, False, False],
     [400, True, False],
     [500, False, False],
     [800, True, False],
     [1000, True, False],
     [1050, False, False],
     [1100, True, False],
     [1400, False, False],
     [1450, False, False],
     [1600, False, True],
     [1800, True, False]]],
   [False, False, True, False, False, False, False, False, False, False, False, False, False, False]],
  ['regression: normal cycle',
   [500,
    [[0, True, False],
     [300, True, True],
     [400, True, True],
     [500, False, True],
     [600, False, False],
     [700, True, True]]],
   [False, True, True, False, False, True]],
  ['control: late second hand',
   [200, [[0, True, False], [300, True, True], [400, False, False], [500, True, False], [600, True, True]]],
   [False, False, False, False, True]],
  ['regression: exact window',
   [200, [[0, False, True], [200, True, True], [300, False, False]]],
   [False, True, False]],
  ['control: tie down one button',
   [200,
    [[0, True, False],
     [100, True, True],
     [200, True, False],
     [300, True, True],
     [400, True, False],
     [450, True, True]]],
   [False, True, False, False, False, False]],
  ['regression: simultaneous press then release one',
   [200, [[0, True, True], [100, True, False], [200, True, True]]],
   [True, False, False]],
  ['regression: scenario 1',
   [250,
    [[0, False, True],
     [200, False, False],
     [250, True, False],
     [550, True, False],
     [650, True, True],
     [700, True, False],
     [900, True, True],
     [1100, True, False],
     [1200, False, True],
     [1300, True, False],
     [1450, False, True],
     [1650, False, False],
     [1800, True, True]]],
   [False, False, False, False, False, False, False, False, False, False, False, False, True]]],
 [['regression: scenario 13',
   [200,
    [[0, False, True],
     [300, True, True],
     [600, False, False],
     [700, False, False],
     [850, False, True],
     [950, True, True],
     [1250, True, False],
     [1550, False, False],
     [1650, False, False],
     [1950, True, False],
     [2150, True, True],
     [2450, True, False],
     [2500, False, True]]],
   [False, False, False, False, False, True, False, False, False, False, True, False, False]],
  ['regression: scenario 6',
   [250,
    [[0, False, True],
     [150, True, True],
     [300, False, False],
     [400, False, True],
     [600, True, False],
     [650, True, True],
     [750, False, False],
     [1050, True, True]]],
   [False, True, False, False, False, True, False, True]],
  ['regression: normal cycle',
   [500,
    [[0, True, False],
     [300, True, True],
     [400, True, True],
     [500, False, True],
     [600, False, False],
     [700, True, True]]],
   [False, True, True, False, False, True]],
  ['control: late second hand',
   [200, [[0, True, False], [300, True, True], [400, False, False], [500, True, False], [600, True, True]]],
   [False, False, False, False, True]],
  ['regression: exact window',
   [200, [[0, False, True], [200, True, True], [300, False, False]]],
   [False, True, False]],
  ['control: tie down one button',
   [200,
    [[0, True, False],
     [100, True, True],
     [200, True, False],
     [300, True, True],
     [400, True, False],
     [450, True, True]]],
   [False, True, False, False, False, False]],
  ['regression: simultaneous press then release one',
   [200, [[0, True, True], [100, True, False], [200, True, True]]],
   [True, False, False]],
  ['control: scenario 1',
   [500,
    [[0, True, False],
     [150, True, False],
     [250, True, False],
     [300, False, False],
     [350, False, True],
     [650, False, True],
     [850, False, False],
     [1150, False, False],
     [1350, True, False],
     [1650, True, False],
     [1800, True, False],
     [1850, True, False],
     [1900, False, True]]],
   [False, False, False, False, False, False, False, False, False, False, False, False, False]]]]
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:
Operators pressing the second button right at the synchronous-time limit cannot start the press.

Two-hand press control sampled per scan; samples is a list of [t_ms, left, right]. The press may start only when both buttons become pressed within window ms of the first one being pressed (inclusive), starting from a state where both were released. Releasing either button stops the press, and both buttons must then be released before a new start is allowed (anti-tie-down). Return the run output per scan.

split: open-access