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

N = 1
observations = []
def solve(steps, scans):
    active = 0
    elapsed = 0
    entered = True
    out = []
    for dt, inputs in scans:
        if not entered:
            elapsed += dt
        entered = False
        min_ms, cond = steps[active]
        if elapsed >= min_ms and inputs.get(cond, False):
            active = (active + 1) % len(steps)
            elapsed -= min_ms
            entered = True
        out.append([active, elapsed, entered])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: scenario 1',
   [[[0, 'T2'], [100, 'T3'], [100, 'T2'], [100, 'T2']],
    [[25, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [1, 90, False],
    [1, 110, False],
    [2, 0, True],
    [2, 0, False],
    [2, 50, False]]],
  ['regression: scenario 2',
   [[[20, 'T3'], [20, 'T3'], [20, 'T1']],
    [[50, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 40, False],
    [1, 0, True],
    [1, 0, False],
    [1, 40, False],
    [1, 80, False],
    [1, 105, False]]],
  ['regression: scenario 3',
   [[[0, 'T2'], [100, 'T3'], [100, 'T2']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}]]],
   [[1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [1, 20, False],
    [1, 40, False],
    [1, 80, False],
    [2, 0, True]]],
  ['regression: scenario 4',
   [[[0, 'T2'], [0, 'T3'], [0, 'T3'], [0, 'T2']],
    [[20, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [2, 0, True],
    [3, 0, True],
    [0, 0, True],
    [0, 0, False],
    [1, 0, True],
    [2, 0, True]]]],
 [['regression: scenario 1',
   [[[100, 'T3'], [0, 'T1']],
    [[50, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 65, False],
    [0, 75, False],
    [1, 0, True],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [0, 75, False]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 2',
   [[[100, 'T2'], [0, 'T1'], [50, 'T2'], [20, 'T2']],
    [[50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 20, False],
    [0, 40, False],
    [0, 65, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 10, False],
    [2, 20, False],
    [2, 45, False],
    [2, 70, False],
    [2, 120, False],
    [3, 0, True],
    [3, 0, False]]],
  ['regression: scenario 3',
   [[[0, 'T2'], [0, 'T1'], [50, 'T1']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}]]],
   [[1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [0, 0, True],
    [0, 0, False],
    [0, 25, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 25, False],
    [0, 0, True],
    [0, 0, False],
    [1, 0, True]]],
  ['regression: scenario 4',
   [[[0, 'T1'], [20, 'T2'], [20, 'T3']],
    [[40, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}]]],
   [[1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [2, 0, True],
    [2, 0, False],
    [2, 40, False],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False]]]],
 [['regression: scenario 2',
   [[[50, 'T3'], [0, 'T2'], [100, 'T1']],
    [[40, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 80, False],
    [1, 0, True],
    [1, 0, False],
    [1, 25, False],
    [1, 35, False],
    [1, 60, False],
    [2, 0, True],
    [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 1',
   [[[0, 'T3'], [20, 'T2'], [0, 'T2']],
    [[40, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 20, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [2, 0, True],
    [2, 0, False],
    [2, 50, False],
    [0, 0, True]]],
  ['regression: scenario 3',
   [[[50, 'T2'], [0, 'T3'], [100, 'T1'], [20, 'T3']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 25, False],
    [0, 35, False],
    [1, 0, True],
    [1, 0, False],
    [1, 40, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False],
    [2, 60, False],
    [3, 0, True],
    [3, 0, False]]],
  ['regression: scenario 4',
   [[[100, 'T1'], [50, 'T3'], [0, 'T1'], [0, 'T1']],
    [[10, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 50, False],
    [0, 70, False],
    [0, 90, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False]]]],
 [['regression: scenario 3',
   [[[100, 'T2'], [0, 'T2'], [0, 'T3']],
    [[50, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 10, False],
    [0, 30, False],
    [0, 70, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: scenario 1',
   [[[50, 'T1'], [50, 'T1'], [100, 'T3'], [20, 'T3']],
    [[20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [2, 0, True],
    [2, 0, False],
    [2, 25, False]]],
  ['regression: scenario 2',
   [[[0, 'T2'], [20, 'T3'], [0, 'T3'], [20, 'T1']],
    [[25, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}]]],
   [[0, 0, False], [0, 10, False], [0, 60, False], [1, 0, True], [1, 0, False], [2, 0, True]]],
  ['regression: scenario 4',
   [[[100, 'T2'], [20, 'T1'], [0, 'T3']],
    [[50, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 10, False],
    [0, 30, False],
    [0, 40, False],
    [0, 80, False],
    [0, 105, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [1, 70, False],
    [1, 120, False],
    [2, 0, True],
    [2, 0, False]]]],
 [['regression: scenario 4',
   [[[20, 'T1'], [50, 'T1'], [50, 'T3'], [0, 'T3']],
    [[25, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False],
    [2, 45, False],
    [2, 55, False],
    [3, 0, True],
    [3, 0, False],
    [0, 0, True]]],
  ['regression: scenario 1',
   [[[0, 'T2'], [100, 'T3'], [100, 'T1'], [20, 'T2']],
    [[40, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [0, 60, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [1, 40, False],
    [1, 80, False],
    [1, 90, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 2',
   [[[20, 'T1'], [20, 'T2'], [100, 'T3'], [0, 'T1']],
    [[50, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [1, 35, False],
    [1, 85, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False]]],
  ['regression: scenario 3',
   [[[20, 'T2'], [50, 'T2'], [0, 'T1']],
    [[50, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [2, 0, True],
    [0, 0, True],
    [0, 0, False],
    [0, 10, False],
    [0, 35, False],
    [1, 0, True]]]]]
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(steps, scans):
    active = 0
    elapsed = 0
    entered = True
    out = []
    for dt, inputs in scans:
        if not entered:
            elapsed += dt
        entered = False
        min_ms, cond = steps[active]
        if elapsed >= min_ms and inputs.get(cond, False):
            active = (active + 1) % len(steps)
            elapsed = dt
            entered = True
        out.append([active, elapsed, entered])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: scenario 1',
   [[[0, 'T2'], [100, 'T3'], [100, 'T2'], [100, 'T2']],
    [[25, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [1, 90, False],
    [1, 110, False],
    [2, 0, True],
    [2, 0, False],
    [2, 50, False]]],
  ['regression: scenario 2',
   [[[20, 'T3'], [20, 'T3'], [20, 'T1']],
    [[50, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 40, False],
    [1, 0, True],
    [1, 0, False],
    [1, 40, False],
    [1, 80, False],
    [1, 105, False]]],
  ['regression: scenario 3',
   [[[0, 'T2'], [100, 'T3'], [100, 'T2']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}]]],
   [[1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [1, 20, False],
    [1, 40, False],
    [1, 80, False],
    [2, 0, True]]],
  ['regression: scenario 4',
   [[[0, 'T2'], [0, 'T3'], [0, 'T3'], [0, 'T2']],
    [[20, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [2, 0, True],
    [3, 0, True],
    [0, 0, True],
    [0, 0, False],
    [1, 0, True],
    [2, 0, True]]]],
 [['regression: scenario 1',
   [[[100, 'T3'], [0, 'T1']],
    [[50, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 65, False],
    [0, 75, False],
    [1, 0, True],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [0, 75, False]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 2',
   [[[100, 'T2'], [0, 'T1'], [50, 'T2'], [20, 'T2']],
    [[50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 20, False],
    [0, 40, False],
    [0, 65, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 10, False],
    [2, 20, False],
    [2, 45, False],
    [2, 70, False],
    [2, 120, False],
    [3, 0, True],
    [3, 0, False]]],
  ['regression: scenario 3',
   [[[0, 'T2'], [0, 'T1'], [50, 'T1']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}]]],
   [[1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [0, 0, True],
    [0, 0, False],
    [0, 25, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 25, False],
    [0, 0, True],
    [0, 0, False],
    [1, 0, True]]],
  ['regression: scenario 4',
   [[[0, 'T1'], [20, 'T2'], [20, 'T3']],
    [[40, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}]]],
   [[1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [2, 0, True],
    [2, 0, False],
    [2, 40, False],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False]]]],
 [['regression: scenario 2',
   [[[50, 'T3'], [0, 'T2'], [100, 'T1']],
    [[40, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 80, False],
    [1, 0, True],
    [1, 0, False],
    [1, 25, False],
    [1, 35, False],
    [1, 60, False],
    [2, 0, True],
    [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 1',
   [[[0, 'T3'], [20, 'T2'], [0, 'T2']],
    [[40, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 20, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [2, 0, True],
    [2, 0, False],
    [2, 50, False],
    [0, 0, True]]],
  ['regression: scenario 3',
   [[[50, 'T2'], [0, 'T3'], [100, 'T1'], [20, 'T3']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 25, False],
    [0, 35, False],
    [1, 0, True],
    [1, 0, False],
    [1, 40, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False],
    [2, 60, False],
    [3, 0, True],
    [3, 0, False]]],
  ['regression: scenario 4',
   [[[100, 'T1'], [50, 'T3'], [0, 'T1'], [0, 'T1']],
    [[10, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 50, False],
    [0, 70, False],
    [0, 90, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False]]]],
 [['regression: scenario 3',
   [[[100, 'T2'], [0, 'T2'], [0, 'T3']],
    [[50, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 10, False],
    [0, 30, False],
    [0, 70, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: scenario 1',
   [[[50, 'T1'], [50, 'T1'], [100, 'T3'], [20, 'T3']],
    [[20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [2, 0, True],
    [2, 0, False],
    [2, 25, False]]],
  ['regression: scenario 2',
   [[[0, 'T2'], [20, 'T3'], [0, 'T3'], [20, 'T1']],
    [[25, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}]]],
   [[0, 0, False], [0, 10, False], [0, 60, False], [1, 0, True], [1, 0, False], [2, 0, True]]],
  ['regression: scenario 4',
   [[[100, 'T2'], [20, 'T1'], [0, 'T3']],
    [[50, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 10, False],
    [0, 30, False],
    [0, 40, False],
    [0, 80, False],
    [0, 105, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [1, 70, False],
    [1, 120, False],
    [2, 0, True],
    [2, 0, False]]]],
 [['regression: scenario 4',
   [[[20, 'T1'], [50, 'T1'], [50, 'T3'], [0, 'T3']],
    [[25, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False],
    [2, 45, False],
    [2, 55, False],
    [3, 0, True],
    [3, 0, False],
    [0, 0, True]]],
  ['regression: scenario 1',
   [[[0, 'T2'], [100, 'T3'], [100, 'T1'], [20, 'T2']],
    [[40, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [0, 60, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [1, 40, False],
    [1, 80, False],
    [1, 90, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 2',
   [[[20, 'T1'], [20, 'T2'], [100, 'T3'], [0, 'T1']],
    [[50, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [1, 35, False],
    [1, 85, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False]]],
  ['regression: scenario 3',
   [[[20, 'T2'], [50, 'T2'], [0, 'T1']],
    [[50, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [2, 0, True],
    [0, 0, True],
    [0, 0, False],
    [0, 10, False],
    [0, 35, False],
    [1, 0, True]]]]]
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:
A step can transition earlier than its minimum because leftover time from the previous step is carried in.

Cyclic step sequence with one active step. steps is a list of [min_time_ms, transition_tag]. Each scan [dt, inputs] first adds dt to the step time unless the step became active on the previous scan, then fires the transition if step time >= min_time and the transition tag is true. At most one transition fires per scan; after the last step the sequence returns to step 0; the new step time is 0. Step 0 is active before the first scan as if just entered. Return [active_step, step_time, entered_this_scan].

split: open-access


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

N = 1
observations = []
def solve(length, ops):
    fifo = [0] * length
    pos = 0
    dest = 0
    out = []
    for op, value in ops:
        if op == 'load':
            fifo[min(pos, length - 1)] = value
            pos = min(pos + 1, length)
        elif op == 'unload':
            if pos > 0:
                dest = fifo[0]
                fifo = fifo[1:] + [0]
                pos -= 1
        out.append([pos, dest, pos >= length, pos == 0, list(fifo)])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: fill overflow drain',
   [2, [['unload', 0], ['load', 5], ['load', 7], ['load', 9], ['unload', 0], ['unload', 0], ['unload', 0]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [5, 0]],
    [2, 0, True, False, [5, 7]],
    [2, 0, True, False, [5, 7]],
    [1, 5, False, False, [7, 0]],
    [0, 7, False, True, [0, 0]],
    [0, 7, False, True, [0, 0]]]],
  ['regression: single slot',
   [1, [['load', 4], ['load', 6], ['unload', 0], ['load', 8]]],
   [[1, 0, True, False, [4]], [1, 0, True, False, [4]], [0, 4, False, True, [0]], [1, 4, True, False, [8]]]],
  ['control: interleaved',
   [3, [['load', 1], ['load', 2], ['unload', 0], ['load', 3], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [1, 0, 0]],
    [2, 0, False, False, [1, 2, 0]],
    [1, 1, False, False, [2, 0, 0]],
    [2, 1, False, False, [2, 3, 0]],
    [1, 2, False, False, [3, 0, 0]],
    [0, 3, False, True, [0, 0, 0]]]],
  ['control: zero value part',
   [2, [['load', 3], ['unload', 0], ['load', 0], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [3, 0]],
    [0, 3, False, True, [0, 0]],
    [1, 3, False, False, [0, 0]],
    [0, 0, False, True, [0, 0]],
    [0, 0, False, True, [0, 0]]]],
  ['regression: scenario 1',
   [2,
    [['load', 13],
     ['unload', 80],
     ['load', 3],
     ['unload', 53],
     ['load', 38],
     ['load', 22],
     ['load', 1],
     ['load', 4],
     ['unload', 96],
     ['load', 42]]],
   [[1, 0, False, False, [13, 0]],
    [0, 13, False, True, [0, 0]],
    [1, 13, False, False, [3, 0]],
    [0, 3, False, True, [0, 0]],
    [1, 3, False, False, [38, 0]],
    [2, 3, True, False, [38, 22]],
    [2, 3, True, False, [38, 22]],
    [2, 3, True, False, [38, 22]],
    [1, 38, False, False, [22, 0]],
    [2, 38, True, False, [22, 42]]]],
  ['regression: scenario 2',
   [2,
    [['load', 44],
     ['load', 96],
     ['load', 30],
     ['load', 50],
     ['unload', 74],
     ['load', 69],
     ['load', 32],
     ['load', 2],
     ['load', 17],
     ['load', 33]]],
   [[1, 0, False, False, [44, 0]],
    [2, 0, True, False, [44, 96]],
    [2, 0, True, False, [44, 96]],
    [2, 0, True, False, [44, 96]],
    [1, 44, False, False, [96, 0]],
    [2, 44, True, False, [96, 69]],
    [2, 44, True, False, [96, 69]],
    [2, 44, True, False, [96, 69]],
    [2, 44, True, False, [96, 69]],
    [2, 44, True, False, [96, 69]]]],
  ['regression: scenario 3',
   [2,
    [['load', 41],
     ['load', 30],
     ['load', 37],
     ['unload', 92],
     ['load', 8],
     ['load', 87],
     ['unload', 97],
     ['load', 95],
     ['load', 23]]],
   [[1, 0, False, False, [41, 0]],
    [2, 0, True, False, [41, 30]],
    [2, 0, True, False, [41, 30]],
    [1, 41, False, False, [30, 0]],
    [2, 41, True, False, [30, 8]],
    [2, 41, True, False, [30, 8]],
    [1, 30, False, False, [8, 0]],
    [2, 30, True, False, [8, 95]],
    [2, 30, True, False, [8, 95]]]],
  ['control: scenario 4',
   [4,
    [['load', 81],
     ['load', 71],
     ['unload', 98],
     ['load', 25],
     ['unload', 33],
     ['load', 59],
     ['load', 39],
     ['unload', 31],
     ['load', 15]]],
   [[1, 0, False, False, [81, 0, 0, 0]],
    [2, 0, False, False, [81, 71, 0, 0]],
    [1, 81, False, False, [71, 0, 0, 0]],
    [2, 81, False, False, [71, 25, 0, 0]],
    [1, 71, False, False, [25, 0, 0, 0]],
    [2, 71, False, False, [25, 59, 0, 0]],
    [3, 71, False, False, [25, 59, 39, 0]],
    [2, 25, False, False, [59, 39, 0, 0]],
    [3, 25, False, False, [59, 39, 15, 0]]]]],
 [['regression: single slot',
   [1, [['load', 4], ['load', 6], ['unload', 0], ['load', 8]]],
   [[1, 0, True, False, [4]], [1, 0, True, False, [4]], [0, 4, False, True, [0]], [1, 4, True, False, [8]]]],
  ['regression: scenario 1',
   [1,
    [['unload', 80],
     ['load', 18],
     ['unload', 20],
     ['load', 68],
     ['load', 99],
     ['unload', 56],
     ['unload', 34],
     ['unload', 21],
     ['load', 94],
     ['unload', 43]]],
   [[0, 0, False, True, [0]],
    [1, 0, True, False, [18]],
    [0, 18, False, True, [0]],
    [1, 18, True, False, [68]],
    [1, 18, True, False, [68]],
    [0, 68, False, True, [0]],
    [0, 68, False, True, [0]],
    [0, 68, False, True, [0]],
    [1, 68, True, False, [94]],
    [0, 94, False, True, [0]]]],
  ['regression: fill overflow drain',
   [2, [['unload', 0], ['load', 5], ['load', 7], ['load', 9], ['unload', 0], ['unload', 0], ['unload', 0]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [5, 0]],
    [2, 0, True, False, [5, 7]],
    [2, 0, True, False, [5, 7]],
    [1, 5, False, False, [7, 0]],
    [0, 7, False, True, [0, 0]],
    [0, 7, False, True, [0, 0]]]],
  ['control: interleaved',
   [3, [['load', 1], ['load', 2], ['unload', 0], ['load', 3], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [1, 0, 0]],
    [2, 0, False, False, [1, 2, 0]],
    [1, 1, False, False, [2, 0, 0]],
    [2, 1, False, False, [2, 3, 0]],
    [1, 2, False, False, [3, 0, 0]],
    [0, 3, False, True, [0, 0, 0]]]],
  ['control: zero value part',
   [2, [['load', 3], ['unload', 0], ['load', 0], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [3, 0]],
    [0, 3, False, True, [0, 0]],
    [1, 3, False, False, [0, 0]],
    [0, 0, False, True, [0, 0]],
    [0, 0, False, True, [0, 0]]]],
  ['control: scenario 2',
   [3,
    [['load', 80],
     ['load', 62],
     ['unload', 32],
     ['load', 91],
     ['unload', 77],
     ['unload', 52],
     ['unload', 56],
     ['unload', 24],
     ['load', 57]]],
   [[1, 0, False, False, [80, 0, 0]],
    [2, 0, False, False, [80, 62, 0]],
    [1, 80, False, False, [62, 0, 0]],
    [2, 80, False, False, [62, 91, 0]],
    [1, 62, False, False, [91, 0, 0]],
    [0, 91, False, True, [0, 0, 0]],
    [0, 91, False, True, [0, 0, 0]],
    [0, 91, False, True, [0, 0, 0]],
    [1, 91, False, False, [57, 0, 0]]]],
  ['regression: scenario 3',
   [3, [['unload', 99], ['load', 16], ['load', 80], ['load', 77], ['load', 65], ['load', 25]]],
   [[0, 0, False, True, [0, 0, 0]],
    [1, 0, False, False, [16, 0, 0]],
    [2, 0, False, False, [16, 80, 0]],
    [3, 0, True, False, [16, 80, 77]],
    [3, 0, True, False, [16, 80, 77]],
    [3, 0, True, False, [16, 80, 77]]]],
  ['regression: scenario 4',
   [3,
    [['load', 83],
     ['load', 77],
     ['load', 45],
     ['unload', 87],
     ['unload', 91],
     ['load', 8],
     ['load', 82],
     ['load', 12],
     ['load', 10],
     ['load', 84]]],
   [[1, 0, False, False, [83, 0, 0]],
    [2, 0, False, False, [83, 77, 0]],
    [3, 0, True, False, [83, 77, 45]],
    [2, 83, False, False, [77, 45, 0]],
    [1, 77, False, False, [45, 0, 0]],
    [2, 77, False, False, [45, 8, 0]],
    [3, 77, True, False, [45, 8, 82]],
    [3, 77, True, False, [45, 8, 82]],
    [3, 77, True, False, [45, 8, 82]],
    [3, 77, True, False, [45, 8, 82]]]]],
 [['regression: scenario 1',
   [2,
    [['unload', 71],
     ['load', 30],
     ['load', 44],
     ['load', 14],
     ['unload', 84],
     ['load', 20],
     ['unload', 82],
     ['load', 34],
     ['unload', 85],
     ['unload', 41],
     ['load', 90],
     ['unload', 95]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [30, 0]],
    [2, 0, True, False, [30, 44]],
    [2, 0, True, False, [30, 44]],
    [1, 30, False, False, [44, 0]],
    [2, 30, True, False, [44, 20]],
    [1, 44, False, False, [20, 0]],
    [2, 44, True, False, [20, 34]],
    [1, 20, False, False, [34, 0]],
    [0, 34, False, True, [0, 0]],
    [1, 34, False, False, [90, 0]],
    [0, 90, False, True, [0, 0]]]],
  ['regression: scenario 2',
   [2,
    [['unload', 27],
     ['load', 29],
     ['load', 99],
     ['load', 77],
     ['load', 8],
     ['load', 1],
     ['load', 67],
     ['load', 51],
     ['load', 54]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [29, 0]],
    [2, 0, True, False, [29, 99]],
    [2, 0, True, False, [29, 99]],
    [2, 0, True, False, [29, 99]],
    [2, 0, True, False, [29, 99]],
    [2, 0, True, False, [29, 99]],
    [2, 0, True, False, [29, 99]],
    [2, 0, True, False, [29, 99]]]],
  ['regression: fill overflow drain',
   [2, [['unload', 0], ['load', 5], ['load', 7], ['load', 9], ['unload', 0], ['unload', 0], ['unload', 0]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [5, 0]],
    [2, 0, True, False, [5, 7]],
    [2, 0, True, False, [5, 7]],
    [1, 5, False, False, [7, 0]],
    [0, 7, False, True, [0, 0]],
    [0, 7, False, True, [0, 0]]]],
  ['regression: single slot',
   [1, [['load', 4], ['load', 6], ['unload', 0], ['load', 8]]],
   [[1, 0, True, False, [4]], [1, 0, True, False, [4]], [0, 4, False, True, [0]], [1, 4, True, False, [8]]]],
  ['control: interleaved',
   [3, [['load', 1], ['load', 2], ['unload', 0], ['load', 3], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [1, 0, 0]],
    [2, 0, False, False, [1, 2, 0]],
    [1, 1, False, False, [2, 0, 0]],
    [2, 1, False, False, [2, 3, 0]],
    [1, 2, False, False, [3, 0, 0]],
    [0, 3, False, True, [0, 0, 0]]]],
  ['control: zero value part',
   [2, [['load', 3], ['unload', 0], ['load', 0], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [3, 0]],
    [0, 3, False, True, [0, 0]],
    [1, 3, False, False, [0, 0]],
    [0, 0, False, True, [0, 0]],
    [0, 0, False, True, [0, 0]]]],
  ['control: scenario 3',
   [3,
    [['unload', 56],
     ['unload', 13],
     ['load', 74],
     ['unload', 36],
     ['unload', 80],
     ['load', 78],
     ['unload', 27],
     ['unload', 90],
     ['load', 46]]],
   [[0, 0, False, True, [0, 0, 0]],
    [0, 0, False, True, [0, 0, 0]],
    [1, 0, False, False, [74, 0, 0]],
    [0, 74, False, True, [0, 0, 0]],
    [0, 74, False, True, [0, 0, 0]],
    [1, 74, False, False, [78, 0, 0]],
    [0, 78, False, True, [0, 0, 0]],
    [0, 78, False, True, [0, 0, 0]],
    [1, 78, False, False, [46, 0, 0]]]],
  ['control: scenario 4',
   [4, [['unload', 9], ['load', 20], ['load', 22], ['unload', 50], ['unload', 69], ['load', 13]]],
   [[0, 0, False, True, [0, 0, 0, 0]],
    [1, 0, False, False, [20, 0, 0, 0]],
    [2, 0, False, False, [20, 22, 0, 0]],
    [1, 20, False, False, [22, 0, 0, 0]],
    [0, 22, False, True, [0, 0, 0, 0]],
    [1, 22, False, False, [13, 0, 0, 0]]]]],
 [['regression: scenario 6',
   [1,
    [['load', 92],
     ['load', 63],
     ['unload', 68],
     ['unload', 46],
     ['unload', 39],
     ['load', 33],
     ['load', 31],
     ['load', 44],
     ['unload', 68]]],
   [[1, 0, True, False, [92]],
    [1, 0, True, False, [92]],
    [0, 92, False, True, [0]],
    [0, 92, False, True, [0]],
    [0, 92, False, True, [0]],
    [1, 92, True, False, [33]],
    [1, 92, True, False, [33]],
    [1, 92, True, False, [33]],
    [0, 33, False, True, [0]]]],
  ['regression: scenario 7',
   [3,
    [['load', 79],
     ['load', 88],
     ['unload', 55],
     ['load', 21],
     ['load', 15],
     ['load', 18],
     ['load', 21],
     ['load', 13]]],
   [[1, 0, False, False, [79, 0, 0]],
    [2, 0, False, False, [79, 88, 0]],
    [1, 79, False, False, [88, 0, 0]],
    [2, 79, False, False, [88, 21, 0]],
    [3, 79, True, False, [88, 21, 15]],
    [3, 79, True, False, [88, 21, 15]],
    [3, 79, True, False, [88, 21, 15]],
    [3, 79, True, False, [88, 21, 15]]]],
  ['regression: fill overflow drain',
   [2, [['unload', 0], ['load', 5], ['load', 7], ['load', 9], ['unload', 0], ['unload', 0], ['unload', 0]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [5, 0]],
    [2, 0, True, False, [5, 7]],
    [2, 0, True, False, [5, 7]],
    [1, 5, False, False, [7, 0]],
    [0, 7, False, True, [0, 0]],
    [0, 7, False, True, [0, 0]]]],
  ['regression: single slot',
   [1, [['load', 4], ['load', 6], ['unload', 0], ['load', 8]]],
   [[1, 0, True, False, [4]], [1, 0, True, False, [4]], [0, 4, False, True, [0]], [1, 4, True, False, [8]]]],
  ['control: interleaved',
   [3, [['load', 1], ['load', 2], ['unload', 0], ['load', 3], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [1, 0, 0]],
    [2, 0, False, False, [1, 2, 0]],
    [1, 1, False, False, [2, 0, 0]],
    [2, 1, False, False, [2, 3, 0]],
    [1, 2, False, False, [3, 0, 0]],
    [0, 3, False, True, [0, 0, 0]]]],
  ['control: zero value part',
   [2, [['load', 3], ['unload', 0], ['load', 0], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [3, 0]],
    [0, 3, False, True, [0, 0]],
    [1, 3, False, False, [0, 0]],
    [0, 0, False, True, [0, 0]],
    [0, 0, False, True, [0, 0]]]],
  ['regression: scenario 1',
   [1,
    [['load', 95],
     ['load', 80],
     ['load', 83],
     ['load', 73],
     ['load', 60],
     ['unload', 25],
     ['unload', 21],
     ['load', 30]]],
   [[1, 0, True, False, [95]],
    [1, 0, True, False, [95]],
    [1, 0, True, False, [95]],
    [1, 0, True, False, [95]],
    [1, 0, True, False, [95]],
    [0, 95, False, True, [0]],
    [0, 95, False, True, [0]],
    [1, 95, True, False, [30]]]],
  ['control: scenario 2',
   [3,
    [['unload', 71],
     ['unload', 34],
     ['load', 70],
     ['unload', 18],
     ['unload', 8],
     ['unload', 11],
     ['load', 1],
     ['load', 16],
     ['unload', 76],
     ['load', 11]]],
   [[0, 0, False, True, [0, 0, 0]],
    [0, 0, False, True, [0, 0, 0]],
    [1, 0, False, False, [70, 0, 0]],
    [0, 70, False, True, [0, 0, 0]],
    [0, 70, False, True, [0, 0, 0]],
    [0, 70, False, True, [0, 0, 0]],
    [1, 70, False, False, [1, 0, 0]],
    [2, 70, False, False, [1, 16, 0]],
    [1, 1, False, False, [16, 0, 0]],
    [2, 1, False, False, [16, 11, 0]]]]],
 [['regression: scenario 5',
   [2,
    [['load', 7],
     ['load', 5],
     ['unload', 26],
     ['load', 47],
     ['load', 60],
     ['unload', 10],
     ['load', 8],
     ['load', 74],
     ['unload', 23],
     ['load', 39],
     ['load', 17]]],
   [[1, 0, False, False, [7, 0]],
    [2, 0, True, False, [7, 5]],
    [1, 7, False, False, [5, 0]],
    [2, 7, True, False, [5, 47]],
    [2, 7, True, False, [5, 47]],
    [1, 5, False, False, [47, 0]],
    [2, 5, True, False, [47, 8]],
    [2, 5, True, False, [47, 8]],
    [1, 47, False, False, [8, 0]],
    [2, 47, True, False, [8, 39]],
    [2, 47, True, False, [8, 39]]]],
  ['regression: scenario 7',
   [1,
    [['unload', 34], ['load', 58], ['load', 93], ['unload', 36], ['load', 57], ['unload', 73], ['load', 29]]],
   [[0, 0, False, True, [0]],
    [1, 0, True, False, [58]],
    [1, 0, True, False, [58]],
    [0, 58, False, True, [0]],
    [1, 58, True, False, [57]],
    [0, 57, False, True, [0]],
    [1, 57, True, False, [29]]]],
  ['regression: fill overflow drain',
   [2, [['unload', 0], ['load', 5], ['load', 7], ['load', 9], ['unload', 0], ['unload', 0], ['unload', 0]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [5, 0]],
    [2, 0, True, False, [5, 7]],
    [2, 0, True, False, [5, 7]],
    [1, 5, False, False, [7, 0]],
    [0, 7, False, True, [0, 0]],
    [0, 7, False, True, [0, 0]]]],
  ['regression: single slot',
   [1, [['load', 4], ['load', 6], ['unload', 0], ['load', 8]]],
   [[1, 0, True, False, [4]], [1, 0, True, False, [4]], [0, 4, False, True, [0]], [1, 4, True, False, [8]]]],
  ['control: interleaved',
   [3, [['load', 1], ['load', 2], ['unload', 0], ['load', 3], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [1, 0, 0]],
    [2, 0, False, False, [1, 2, 0]],
    [1, 1, False, False, [2, 0, 0]],
    [2, 1, False, False, [2, 3, 0]],
    [1, 2, False, False, [3, 0, 0]],
    [0, 3, False, True, [0, 0, 0]]]],
  ['control: zero value part',
   [2, [['load', 3], ['unload', 0], ['load', 0], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [3, 0]],
    [0, 3, False, True, [0, 0]],
    [1, 3, False, False, [0, 0]],
    [0, 0, False, True, [0, 0]],
    [0, 0, False, True, [0, 0]]]],
  ['control: scenario 1',
   [3, [['load', 95], ['unload', 26], ['load', 88], ['unload', 93], ['load', 84], ['load', 5]]],
   [[1, 0, False, False, [95, 0, 0]],
    [0, 95, False, True, [0, 0, 0]],
    [1, 95, False, False, [88, 0, 0]],
    [0, 88, False, True, [0, 0, 0]],
    [1, 88, False, False, [84, 0, 0]],
    [2, 88, False, False, [84, 5, 0]]]],
  ['regression: scenario 2',
   [4,
    [['load', 49],
     ['load', 58],
     ['unload', 66],
     ['load', 96],
     ['load', 53],
     ['load', 59],
     ['load', 76],
     ['unload', 9],
     ['load', 14],
     ['load', 69],
     ['load', 39],
     ['unload', 58]]],
   [[1, 0, False, False, [49, 0, 0, 0]],
    [2, 0, False, False, [49, 58, 0, 0]],
    [1, 49, False, False, [58, 0, 0, 0]],
    [2, 49, False, False, [58, 96, 0, 0]],
    [3, 49, False, False, [58, 96, 53, 0]],
    [4, 49, True, False, [58, 96, 53, 59]],
    [4, 49, True, False, [58, 96, 53, 59]],
    [3, 58, False, False, [96, 53, 59, 0]],
    [4, 58, True, False, [96, 53, 59, 14]],
    [4, 58, True, False, [96, 53, 59, 14]],
    [4, 58, True, False, [96, 53, 59, 14]],
    [3, 96, False, False, [53, 59, 14, 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(length, ops):
    fifo = [0] * length
    pos = 0
    dest = 0
    out = []
    for op, value in ops:
        if op == 'load':
            if pos < length:
                fifo[pos] = value
                pos += 1
            else:
                fifo = fifo[1:] + [value]
        elif op == 'unload':
            if pos > 0:
                dest = fifo[0]
                fifo = fifo[1:] + [0]
                pos -= 1
        out.append([pos, dest, pos >= length, pos == 0, list(fifo)])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: fill overflow drain',
   [2, [['unload', 0], ['load', 5], ['load', 7], ['load', 9], ['unload', 0], ['unload', 0], ['unload', 0]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [5, 0]],
    [2, 0, True, False, [5, 7]],
    [2, 0, True, False, [5, 7]],
    [1, 5, False, False, [7, 0]],
    [0, 7, False, True, [0, 0]],
    [0, 7, False, True, [0, 0]]]],
  ['regression: single slot',
   [1, [['load', 4], ['load', 6], ['unload', 0], ['load', 8]]],
   [[1, 0, True, False, [4]], [1, 0, True, False, [4]], [0, 4, False, True, [0]], [1, 4, True, False, [8]]]],
  ['control: interleaved',
   [3, [['load', 1], ['load', 2], ['unload', 0], ['load', 3], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [1, 0, 0]],
    [2, 0, False, False, [1, 2, 0]],
    [1, 1, False, False, [2, 0, 0]],
    [2, 1, False, False, [2, 3, 0]],
    [1, 2, False, False, [3, 0, 0]],
    [0, 3, False, True, [0, 0, 0]]]],
  ['control: zero value part',
   [2, [['load', 3], ['unload', 0], ['load', 0], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [3, 0]],
    [0, 3, False, True, [0, 0]],
    [1, 3, False, False, [0, 0]],
    [0, 0, False, True, [0, 0]],
    [0, 0, False, True, [0, 0]]]],
  ['regression: scenario 1',
   [2,
    [['load', 13],
     ['unload', 80],
     ['load', 3],
     ['unload', 53],
     ['load', 38],
     ['load', 22],
     ['load', 1],
     ['load', 4],
     ['unload', 96],
     ['load', 42]]],
   [[1, 0, False, False, [13, 0]],
    [0, 13, False, True, [0, 0]],
    [1, 13, False, False, [3, 0]],
    [0, 3, False, True, [0, 0]],
    [1, 3, False, False, [38, 0]],
    [2, 3, True, False, [38, 22]],
    [2, 3, True, False, [38, 22]],
    [2, 3, True, False, [38, 22]],
    [1, 38, False, False, [22, 0]],
    [2, 38, True, False, [22, 42]]]],
  ['regression: scenario 2',
   [2,
    [['load', 44],
     ['load', 96],
     ['load', 30],
     ['load', 50],
     ['unload', 74],
     ['load', 69],
     ['load', 32],
     ['load', 2],
     ['load', 17],
     ['load', 33]]],
   [[1, 0, False, False, [44, 0]],
    [2, 0, True, False, [44, 96]],
    [2, 0, True, False, [44, 96]],
    [2, 0, True, False, [44, 96]],
    [1, 44, False, False, [96, 0]],
    [2, 44, True, False, [96, 69]],
    [2, 44, True, False, [96, 69]],
    [2, 44, True, False, [96, 69]],
    [2, 44, True, False, [96, 69]],
    [2, 44, True, False, [96, 69]]]],
  ['regression: scenario 3',
   [2,
    [['load', 41],
     ['load', 30],
     ['load', 37],
     ['unload', 92],
     ['load', 8],
     ['load', 87],
     ['unload', 97],
     ['load', 95],
     ['load', 23]]],
   [[1, 0, False, False, [41, 0]],
    [2, 0, True, False, [41, 30]],
    [2, 0, True, False, [41, 30]],
    [1, 41, False, False, [30, 0]],
    [2, 41, True, False, [30, 8]],
    [2, 41, True, False, [30, 8]],
    [1, 30, False, False, [8, 0]],
    [2, 30, True, False, [8, 95]],
    [2, 30, True, False, [8, 95]]]],
  ['control: scenario 4',
   [4,
    [['load', 81],
     ['load', 71],
     ['unload', 98],
     ['load', 25],
     ['unload', 33],
     ['load', 59],
     ['load', 39],
     ['unload', 31],
     ['load', 15]]],
   [[1, 0, False, False, [81, 0, 0, 0]],
    [2, 0, False, False, [81, 71, 0, 0]],
    [1, 81, False, False, [71, 0, 0, 0]],
    [2, 81, False, False, [71, 25, 0, 0]],
    [1, 71, False, False, [25, 0, 0, 0]],
    [2, 71, False, False, [25, 59, 0, 0]],
    [3, 71, False, False, [25, 59, 39, 0]],
    [2, 25, False, False, [59, 39, 0, 0]],
    [3, 25, False, False, [59, 39, 15, 0]]]]],
 [['regression: single slot',
   [1, [['load', 4], ['load', 6], ['unload', 0], ['load', 8]]],
   [[1, 0, True, False, [4]], [1, 0, True, False, [4]], [0, 4, False, True, [0]], [1, 4, True, False, [8]]]],
  ['regression: scenario 1',
   [1,
    [['unload', 80],
     ['load', 18],
     ['unload', 20],
     ['load', 68],
     ['load', 99],
     ['unload', 56],
     ['unload', 34],
     ['unload', 21],
     ['load', 94],
     ['unload', 43]]],
   [[0, 0, False, True, [0]],
    [1, 0, True, False, [18]],
    [0, 18, False, True, [0]],
    [1, 18, True, False, [68]],
    [1, 18, True, False, [68]],
    [0, 68, False, True, [0]],
    [0, 68, False, True, [0]],
    [0, 68, False, True, [0]],
    [1, 68, True, False, [94]],
    [0, 94, False, True, [0]]]],
  ['regression: fill overflow drain',
   [2, [['unload', 0], ['load', 5], ['load', 7], ['load', 9], ['unload', 0], ['unload', 0], ['unload', 0]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [5, 0]],
    [2, 0, True, False, [5, 7]],
    [2, 0, True, False, [5, 7]],
    [1, 5, False, False, [7, 0]],
    [0, 7, False, True, [0, 0]],
    [0, 7, False, True, [0, 0]]]],
  ['control: interleaved',
   [3, [['load', 1], ['load', 2], ['unload', 0], ['load', 3], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [1, 0, 0]],
    [2, 0, False, False, [1, 2, 0]],
    [1, 1, False, False, [2, 0, 0]],
    [2, 1, False, False, [2, 3, 0]],
    [1, 2, False, False, [3, 0, 0]],
    [0, 3, False, True, [0, 0, 0]]]],
  ['control: zero value part',
   [2, [['load', 3], ['unload', 0], ['load', 0], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [3, 0]],
    [0, 3, False, True, [0, 0]],
    [1, 3, False, False, [0, 0]],
    [0, 0, False, True, [0, 0]],
    [0, 0, False, True, [0, 0]]]],
  ['control: scenario 2',
   [3,
    [['load', 80],
     ['load', 62],
     ['unload', 32],
     ['load', 91],
     ['unload', 77],
     ['unload', 52],
     ['unload', 56],
     ['unload', 24],
     ['load', 57]]],
   [[1, 0, False, False, [80, 0, 0]],
    [2, 0, False, False, [80, 62, 0]],
    [1, 80, False, False, [62, 0, 0]],
    [2, 80, False, False, [62, 91, 0]],
    [1, 62, False, False, [91, 0, 0]],
    [0, 91, False, True, [0, 0, 0]],
    [0, 91, False, True, [0, 0, 0]],
    [0, 91, False, True, [0, 0, 0]],
    [1, 91, False, False, [57, 0, 0]]]],
  ['regression: scenario 3',
   [3, [['unload', 99], ['load', 16], ['load', 80], ['load', 77], ['load', 65], ['load', 25]]],
   [[0, 0, False, True, [0, 0, 0]],
    [1, 0, False, False, [16, 0, 0]],
    [2, 0, False, False, [16, 80, 0]],
    [3, 0, True, False, [16, 80, 77]],
    [3, 0, True, False, [16, 80, 77]],
    [3, 0, True, False, [16, 80, 77]]]],
  ['regression: scenario 4',
   [3,
    [['load', 83],
     ['load', 77],
     ['load', 45],
     ['unload', 87],
     ['unload', 91],
     ['load', 8],
     ['load', 82],
     ['load', 12],
     ['load', 10],
     ['load', 84]]],
   [[1, 0, False, False, [83, 0, 0]],
    [2, 0, False, False, [83, 77, 0]],
    [3, 0, True, False, [83, 77, 45]],
    [2, 83, False, False, [77, 45, 0]],
    [1, 77, False, False, [45, 0, 0]],
    [2, 77, False, False, [45, 8, 0]],
    [3, 77, True, False, [45, 8, 82]],
    [3, 77, True, False, [45, 8, 82]],
    [3, 77, True, False, [45, 8, 82]],
    [3, 77, True, False, [45, 8, 82]]]]],
 [['regression: scenario 1',
   [2,
    [['unload', 71],
     ['load', 30],
     ['load', 44],
     ['load', 14],
     ['unload', 84],
     ['load', 20],
     ['unload', 82],
     ['load', 34],
     ['unload', 85],
     ['unload', 41],
     ['load', 90],
     ['unload', 95]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [30, 0]],
    [2, 0, True, False, [30, 44]],
    [2, 0, True, False, [30, 44]],
    [1, 30, False, False, [44, 0]],
    [2, 30, True, False, [44, 20]],
    [1, 44, False, False, [20, 0]],
    [2, 44, True, False, [20, 34]],
    [1, 20, False, False, [34, 0]],
    [0, 34, False, True, [0, 0]],
    [1, 34, False, False, [90, 0]],
    [0, 90, False, True, [0, 0]]]],
  ['regression: scenario 2',
   [2,
    [['unload', 27],
     ['load', 29],
     ['load', 99],
     ['load', 77],
     ['load', 8],
     ['load', 1],
     ['load', 67],
     ['load', 51],
     ['load', 54]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [29, 0]],
    [2, 0, True, False, [29, 99]],
    [2, 0, True, False, [29, 99]],
    [2, 0, True, False, [29, 99]],
    [2, 0, True, False, [29, 99]],
    [2, 0, True, False, [29, 99]],
    [2, 0, True, False, [29, 99]],
    [2, 0, True, False, [29, 99]]]],
  ['regression: fill overflow drain',
   [2, [['unload', 0], ['load', 5], ['load', 7], ['load', 9], ['unload', 0], ['unload', 0], ['unload', 0]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [5, 0]],
    [2, 0, True, False, [5, 7]],
    [2, 0, True, False, [5, 7]],
    [1, 5, False, False, [7, 0]],
    [0, 7, False, True, [0, 0]],
    [0, 7, False, True, [0, 0]]]],
  ['regression: single slot',
   [1, [['load', 4], ['load', 6], ['unload', 0], ['load', 8]]],
   [[1, 0, True, False, [4]], [1, 0, True, False, [4]], [0, 4, False, True, [0]], [1, 4, True, False, [8]]]],
  ['control: interleaved',
   [3, [['load', 1], ['load', 2], ['unload', 0], ['load', 3], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [1, 0, 0]],
    [2, 0, False, False, [1, 2, 0]],
    [1, 1, False, False, [2, 0, 0]],
    [2, 1, False, False, [2, 3, 0]],
    [1, 2, False, False, [3, 0, 0]],
    [0, 3, False, True, [0, 0, 0]]]],
  ['control: zero value part',
   [2, [['load', 3], ['unload', 0], ['load', 0], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [3, 0]],
    [0, 3, False, True, [0, 0]],
    [1, 3, False, False, [0, 0]],
    [0, 0, False, True, [0, 0]],
    [0, 0, False, True, [0, 0]]]],
  ['control: scenario 3',
   [3,
    [['unload', 56],
     ['unload', 13],
     ['load', 74],
     ['unload', 36],
     ['unload', 80],
     ['load', 78],
     ['unload', 27],
     ['unload', 90],
     ['load', 46]]],
   [[0, 0, False, True, [0, 0, 0]],
    [0, 0, False, True, [0, 0, 0]],
    [1, 0, False, False, [74, 0, 0]],
    [0, 74, False, True, [0, 0, 0]],
    [0, 74, False, True, [0, 0, 0]],
    [1, 74, False, False, [78, 0, 0]],
    [0, 78, False, True, [0, 0, 0]],
    [0, 78, False, True, [0, 0, 0]],
    [1, 78, False, False, [46, 0, 0]]]],
  ['control: scenario 4',
   [4, [['unload', 9], ['load', 20], ['load', 22], ['unload', 50], ['unload', 69], ['load', 13]]],
   [[0, 0, False, True, [0, 0, 0, 0]],
    [1, 0, False, False, [20, 0, 0, 0]],
    [2, 0, False, False, [20, 22, 0, 0]],
    [1, 20, False, False, [22, 0, 0, 0]],
    [0, 22, False, True, [0, 0, 0, 0]],
    [1, 22, False, False, [13, 0, 0, 0]]]]],
 [['regression: scenario 6',
   [1,
    [['load', 92],
     ['load', 63],
     ['unload', 68],
     ['unload', 46],
     ['unload', 39],
     ['load', 33],
     ['load', 31],
     ['load', 44],
     ['unload', 68]]],
   [[1, 0, True, False, [92]],
    [1, 0, True, False, [92]],
    [0, 92, False, True, [0]],
    [0, 92, False, True, [0]],
    [0, 92, False, True, [0]],
    [1, 92, True, False, [33]],
    [1, 92, True, False, [33]],
    [1, 92, True, False, [33]],
    [0, 33, False, True, [0]]]],
  ['regression: scenario 7',
   [3,
    [['load', 79],
     ['load', 88],
     ['unload', 55],
     ['load', 21],
     ['load', 15],
     ['load', 18],
     ['load', 21],
     ['load', 13]]],
   [[1, 0, False, False, [79, 0, 0]],
    [2, 0, False, False, [79, 88, 0]],
    [1, 79, False, False, [88, 0, 0]],
    [2, 79, False, False, [88, 21, 0]],
    [3, 79, True, False, [88, 21, 15]],
    [3, 79, True, False, [88, 21, 15]],
    [3, 79, True, False, [88, 21, 15]],
    [3, 79, True, False, [88, 21, 15]]]],
  ['regression: fill overflow drain',
   [2, [['unload', 0], ['load', 5], ['load', 7], ['load', 9], ['unload', 0], ['unload', 0], ['unload', 0]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [5, 0]],
    [2, 0, True, False, [5, 7]],
    [2, 0, True, False, [5, 7]],
    [1, 5, False, False, [7, 0]],
    [0, 7, False, True, [0, 0]],
    [0, 7, False, True, [0, 0]]]],
  ['regression: single slot',
   [1, [['load', 4], ['load', 6], ['unload', 0], ['load', 8]]],
   [[1, 0, True, False, [4]], [1, 0, True, False, [4]], [0, 4, False, True, [0]], [1, 4, True, False, [8]]]],
  ['control: interleaved',
   [3, [['load', 1], ['load', 2], ['unload', 0], ['load', 3], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [1, 0, 0]],
    [2, 0, False, False, [1, 2, 0]],
    [1, 1, False, False, [2, 0, 0]],
    [2, 1, False, False, [2, 3, 0]],
    [1, 2, False, False, [3, 0, 0]],
    [0, 3, False, True, [0, 0, 0]]]],
  ['control: zero value part',
   [2, [['load', 3], ['unload', 0], ['load', 0], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [3, 0]],
    [0, 3, False, True, [0, 0]],
    [1, 3, False, False, [0, 0]],
    [0, 0, False, True, [0, 0]],
    [0, 0, False, True, [0, 0]]]],
  ['regression: scenario 1',
   [1,
    [['load', 95],
     ['load', 80],
     ['load', 83],
     ['load', 73],
     ['load', 60],
     ['unload', 25],
     ['unload', 21],
     ['load', 30]]],
   [[1, 0, True, False, [95]],
    [1, 0, True, False, [95]],
    [1, 0, True, False, [95]],
    [1, 0, True, False, [95]],
    [1, 0, True, False, [95]],
    [0, 95, False, True, [0]],
    [0, 95, False, True, [0]],
    [1, 95, True, False, [30]]]],
  ['control: scenario 2',
   [3,
    [['unload', 71],
     ['unload', 34],
     ['load', 70],
     ['unload', 18],
     ['unload', 8],
     ['unload', 11],
     ['load', 1],
     ['load', 16],
     ['unload', 76],
     ['load', 11]]],
   [[0, 0, False, True, [0, 0, 0]],
    [0, 0, False, True, [0, 0, 0]],
    [1, 0, False, False, [70, 0, 0]],
    [0, 70, False, True, [0, 0, 0]],
    [0, 70, False, True, [0, 0, 0]],
    [0, 70, False, True, [0, 0, 0]],
    [1, 70, False, False, [1, 0, 0]],
    [2, 70, False, False, [1, 16, 0]],
    [1, 1, False, False, [16, 0, 0]],
    [2, 1, False, False, [16, 11, 0]]]]],
 [['regression: scenario 5',
   [2,
    [['load', 7],
     ['load', 5],
     ['unload', 26],
     ['load', 47],
     ['load', 60],
     ['unload', 10],
     ['load', 8],
     ['load', 74],
     ['unload', 23],
     ['load', 39],
     ['load', 17]]],
   [[1, 0, False, False, [7, 0]],
    [2, 0, True, False, [7, 5]],
    [1, 7, False, False, [5, 0]],
    [2, 7, True, False, [5, 47]],
    [2, 7, True, False, [5, 47]],
    [1, 5, False, False, [47, 0]],
    [2, 5, True, False, [47, 8]],
    [2, 5, True, False, [47, 8]],
    [1, 47, False, False, [8, 0]],
    [2, 47, True, False, [8, 39]],
    [2, 47, True, False, [8, 39]]]],
  ['regression: scenario 7',
   [1,
    [['unload', 34], ['load', 58], ['load', 93], ['unload', 36], ['load', 57], ['unload', 73], ['load', 29]]],
   [[0, 0, False, True, [0]],
    [1, 0, True, False, [58]],
    [1, 0, True, False, [58]],
    [0, 58, False, True, [0]],
    [1, 58, True, False, [57]],
    [0, 57, False, True, [0]],
    [1, 57, True, False, [29]]]],
  ['regression: fill overflow drain',
   [2, [['unload', 0], ['load', 5], ['load', 7], ['load', 9], ['unload', 0], ['unload', 0], ['unload', 0]]],
   [[0, 0, False, True, [0, 0]],
    [1, 0, False, False, [5, 0]],
    [2, 0, True, False, [5, 7]],
    [2, 0, True, False, [5, 7]],
    [1, 5, False, False, [7, 0]],
    [0, 7, False, True, [0, 0]],
    [0, 7, False, True, [0, 0]]]],
  ['regression: single slot',
   [1, [['load', 4], ['load', 6], ['unload', 0], ['load', 8]]],
   [[1, 0, True, False, [4]], [1, 0, True, False, [4]], [0, 4, False, True, [0]], [1, 4, True, False, [8]]]],
  ['control: interleaved',
   [3, [['load', 1], ['load', 2], ['unload', 0], ['load', 3], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [1, 0, 0]],
    [2, 0, False, False, [1, 2, 0]],
    [1, 1, False, False, [2, 0, 0]],
    [2, 1, False, False, [2, 3, 0]],
    [1, 2, False, False, [3, 0, 0]],
    [0, 3, False, True, [0, 0, 0]]]],
  ['control: zero value part',
   [2, [['load', 3], ['unload', 0], ['load', 0], ['unload', 0], ['unload', 0]]],
   [[1, 0, False, False, [3, 0]],
    [0, 3, False, True, [0, 0]],
    [1, 3, False, False, [0, 0]],
    [0, 0, False, True, [0, 0]],
    [0, 0, False, True, [0, 0]]]],
  ['control: scenario 1',
   [3, [['load', 95], ['unload', 26], ['load', 88], ['unload', 93], ['load', 84], ['load', 5]]],
   [[1, 0, False, False, [95, 0, 0]],
    [0, 95, False, True, [0, 0, 0]],
    [1, 95, False, False, [88, 0, 0]],
    [0, 88, False, True, [0, 0, 0]],
    [1, 88, False, False, [84, 0, 0]],
    [2, 88, False, False, [84, 5, 0]]]],
  ['regression: scenario 2',
   [4,
    [['load', 49],
     ['load', 58],
     ['unload', 66],
     ['load', 96],
     ['load', 53],
     ['load', 59],
     ['load', 76],
     ['unload', 9],
     ['load', 14],
     ['load', 69],
     ['load', 39],
     ['unload', 58]]],
   [[1, 0, False, False, [49, 0, 0, 0]],
    [2, 0, False, False, [49, 58, 0, 0]],
    [1, 49, False, False, [58, 0, 0, 0]],
    [2, 49, False, False, [58, 96, 0, 0]],
    [3, 49, False, False, [58, 96, 53, 0]],
    [4, 49, True, False, [58, 96, 53, 59]],
    [4, 49, True, False, [58, 96, 53, 59]],
    [3, 58, False, False, [96, 53, 59, 0]],
    [4, 58, True, False, [96, 53, 59, 14]],
    [4, 58, True, False, [96, 53, 59, 14]],
    [4, 58, True, False, [96, 53, 59, 14]],
    [3, 96, False, False, [53, 59, 14, 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:
A part queued while the FIFO is full replaces the last queued part instead of being rejected.

FIFO load (FFL) and unload (FFU) pair on one file of the given length. ops is a list of [op, value], one triggered instruction per scan. Load stores value at the position and increments it; when full (position == length) the load is ignored. Unload moves element 0 to dest, shifts the file toward 0 and zeroes the vacated last element; unloading an empty FIFO leaves dest unchanged. DN is position >= length and EM is position == 0. Return [position, dest, DN, EM, file] per scan.

split: open-access