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':
            if pos < length:
                fifo[pos] = value
                pos += 1
        elif op == 'unload':
            if pos > 0:
                dest = fifo[pos - 1]
                fifo[pos - 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: 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: 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: 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]]]],
  ['regression: 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: 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]]]],
  ['regression: 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: 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: 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: 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',
   [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]]]],
  ['control: 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 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: 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: 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: 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',
   [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]]]],
  ['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]]]]],
 [['regression: scenario 3',
   [4,
    [['unload', 22], ['load', 4], ['unload', 2], ['load', 69], ['load', 19], ['unload', 5], ['unload', 47]]],
   [[0, 0, False, True, [0, 0, 0, 0]],
    [1, 0, False, False, [4, 0, 0, 0]],
    [0, 4, False, True, [0, 0, 0, 0]],
    [1, 4, False, False, [69, 0, 0, 0]],
    [2, 4, False, False, [69, 19, 0, 0]],
    [1, 69, False, False, [19, 0, 0, 0]],
    [0, 19, False, True, [0, 0, 0, 0]]]],
  ['regression: scenario 5',
   [4,
    [['load', 53],
     ['load', 79],
     ['load', 69],
     ['unload', 57],
     ['load', 2],
     ['load', 76],
     ['unload', 73],
     ['load', 18],
     ['unload', 13],
     ['unload', 1],
     ['unload', 27]]],
   [[1, 0, False, False, [53, 0, 0, 0]],
    [2, 0, False, False, [53, 79, 0, 0]],
    [3, 0, False, False, [53, 79, 69, 0]],
    [2, 53, False, False, [79, 69, 0, 0]],
    [3, 53, False, False, [79, 69, 2, 0]],
    [4, 53, True, False, [79, 69, 2, 76]],
    [3, 79, False, False, [69, 2, 76, 0]],
    [4, 79, True, False, [69, 2, 76, 18]],
    [3, 69, False, False, [2, 76, 18, 0]],
    [2, 2, False, False, [76, 18, 0, 0]],
    [1, 76, False, False, [18, 0, 0, 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: 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: 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',
   [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]]]],
  ['regression: 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 6',
   [2,
    [['load', 16],
     ['unload', 9],
     ['unload', 70],
     ['unload', 14],
     ['unload', 85],
     ['unload', 40],
     ['load', 79],
     ['load', 16],
     ['unload', 1]]],
   [[1, 0, False, False, [16, 0]],
    [0, 16, False, True, [0, 0]],
    [0, 16, False, True, [0, 0]],
    [0, 16, False, True, [0, 0]],
    [0, 16, False, True, [0, 0]],
    [0, 16, False, True, [0, 0]],
    [1, 16, False, False, [79, 0]],
    [2, 16, True, False, [79, 16]],
    [1, 79, False, False, [16, 0]]]],
  ['regression: scenario 8',
   [4,
    [['unload', 17],
     ['load', 78],
     ['load', 34],
     ['unload', 48],
     ['load', 87],
     ['unload', 12],
     ['unload', 38],
     ['load', 75],
     ['unload', 80],
     ['unload', 88]]],
   [[0, 0, False, True, [0, 0, 0, 0]],
    [1, 0, False, False, [78, 0, 0, 0]],
    [2, 0, False, False, [78, 34, 0, 0]],
    [1, 78, False, False, [34, 0, 0, 0]],
    [2, 78, False, False, [34, 87, 0, 0]],
    [1, 34, False, False, [87, 0, 0, 0]],
    [0, 87, False, True, [0, 0, 0, 0]],
    [1, 87, False, False, [75, 0, 0, 0]],
    [0, 75, False, True, [0, 0, 0, 0]],
    [0, 75, False, True, [0, 0, 0, 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: 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: 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)

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
        elif op == 'unload':
            if pos > 0:
                dest = fifo[0]
                fifo[0] = 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: 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: 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: 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]]]],
  ['regression: 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: 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]]]],
  ['regression: 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: 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: 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: 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',
   [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]]]],
  ['control: 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 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: 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: 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: 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',
   [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]]]],
  ['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]]]]],
 [['regression: scenario 3',
   [4,
    [['unload', 22], ['load', 4], ['unload', 2], ['load', 69], ['load', 19], ['unload', 5], ['unload', 47]]],
   [[0, 0, False, True, [0, 0, 0, 0]],
    [1, 0, False, False, [4, 0, 0, 0]],
    [0, 4, False, True, [0, 0, 0, 0]],
    [1, 4, False, False, [69, 0, 0, 0]],
    [2, 4, False, False, [69, 19, 0, 0]],
    [1, 69, False, False, [19, 0, 0, 0]],
    [0, 19, False, True, [0, 0, 0, 0]]]],
  ['regression: scenario 5',
   [4,
    [['load', 53],
     ['load', 79],
     ['load', 69],
     ['unload', 57],
     ['load', 2],
     ['load', 76],
     ['unload', 73],
     ['load', 18],
     ['unload', 13],
     ['unload', 1],
     ['unload', 27]]],
   [[1, 0, False, False, [53, 0, 0, 0]],
    [2, 0, False, False, [53, 79, 0, 0]],
    [3, 0, False, False, [53, 79, 69, 0]],
    [2, 53, False, False, [79, 69, 0, 0]],
    [3, 53, False, False, [79, 69, 2, 0]],
    [4, 53, True, False, [79, 69, 2, 76]],
    [3, 79, False, False, [69, 2, 76, 0]],
    [4, 79, True, False, [69, 2, 76, 18]],
    [3, 69, False, False, [2, 76, 18, 0]],
    [2, 2, False, False, [76, 18, 0, 0]],
    [1, 76, False, False, [18, 0, 0, 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: 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: 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',
   [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]]]],
  ['regression: 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 6',
   [2,
    [['load', 16],
     ['unload', 9],
     ['unload', 70],
     ['unload', 14],
     ['unload', 85],
     ['unload', 40],
     ['load', 79],
     ['load', 16],
     ['unload', 1]]],
   [[1, 0, False, False, [16, 0]],
    [0, 16, False, True, [0, 0]],
    [0, 16, False, True, [0, 0]],
    [0, 16, False, True, [0, 0]],
    [0, 16, False, True, [0, 0]],
    [0, 16, False, True, [0, 0]],
    [1, 16, False, False, [79, 0]],
    [2, 16, True, False, [79, 16]],
    [1, 79, False, False, [16, 0]]]],
  ['regression: scenario 8',
   [4,
    [['unload', 17],
     ['load', 78],
     ['load', 34],
     ['unload', 48],
     ['load', 87],
     ['unload', 12],
     ['unload', 38],
     ['load', 75],
     ['unload', 80],
     ['unload', 88]]],
   [[0, 0, False, True, [0, 0, 0, 0]],
    [1, 0, False, False, [78, 0, 0, 0]],
    [2, 0, False, False, [78, 34, 0, 0]],
    [1, 78, False, False, [34, 0, 0, 0]],
    [2, 78, False, False, [34, 87, 0, 0]],
    [1, 34, False, False, [87, 0, 0, 0]],
    [0, 87, False, True, [0, 0, 0, 0]],
    [1, 87, False, False, [75, 0, 0, 0]],
    [0, 75, False, True, [0, 0, 0, 0]],
    [0, 75, False, True, [0, 0, 0, 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: 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: 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:
Parts leave the queue last-in first-out.

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


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':
            if pos < length:
                fifo[pos] = value
                pos += 1
        elif op == 'unload':
            if pos > 0:
                dest = fifo[0]
                fifo = fifo[1:] + [fifo[-1]]
                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]]]],
  ['regression: 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]]]],
  ['regression: 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]]]],
  ['regression: 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: 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]]]],
  ['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: 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,
    [['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: 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]]]],
  ['control: 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: 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]]]],
  ['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]]]],
  ['regression: 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',
   [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: 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]]]],
  ['regression: 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 5',
   [4,
    [['load', 53],
     ['load', 79],
     ['load', 69],
     ['unload', 57],
     ['load', 2],
     ['load', 76],
     ['unload', 73],
     ['load', 18],
     ['unload', 13],
     ['unload', 1],
     ['unload', 27]]],
   [[1, 0, False, False, [53, 0, 0, 0]],
    [2, 0, False, False, [53, 79, 0, 0]],
    [3, 0, False, False, [53, 79, 69, 0]],
    [2, 53, False, False, [79, 69, 0, 0]],
    [3, 53, False, False, [79, 69, 2, 0]],
    [4, 53, True, False, [79, 69, 2, 76]],
    [3, 79, False, False, [69, 2, 76, 0]],
    [4, 79, True, False, [69, 2, 76, 18]],
    [3, 69, False, False, [2, 76, 18, 0]],
    [2, 2, False, False, [76, 18, 0, 0]],
    [1, 76, False, False, [18, 0, 0, 0]]]],
  ['regression: 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: 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]]]],
  ['regression: 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]]]],
  ['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]]]],
  ['regression: 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 3',
   [4,
    [['unload', 22], ['load', 4], ['unload', 2], ['load', 69], ['load', 19], ['unload', 5], ['unload', 47]]],
   [[0, 0, False, True, [0, 0, 0, 0]],
    [1, 0, False, False, [4, 0, 0, 0]],
    [0, 4, False, True, [0, 0, 0, 0]],
    [1, 4, False, False, [69, 0, 0, 0]],
    [2, 4, False, False, [69, 19, 0, 0]],
    [1, 69, False, False, [19, 0, 0, 0]],
    [0, 19, False, True, [0, 0, 0, 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 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: 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]]]],
  ['regression: 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]]]],
  ['regression: 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 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]]]],
  ['regression: scenario 3',
   [3, [['unload', 7], ['unload', 28], ['load', 29], ['unload', 33], ['unload', 61], ['unload', 47]]],
   [[0, 0, False, True, [0, 0, 0]],
    [0, 0, False, True, [0, 0, 0]],
    [1, 0, False, False, [29, 0, 0]],
    [0, 29, False, True, [0, 0, 0]],
    [0, 29, False, True, [0, 0, 0]],
    [0, 29, False, True, [0, 0, 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
        elif op == 'unload':
            if pos > 0:
                dest = fifo[0]
                fifo = fifo[1:] + [dest]
                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]]]],
  ['regression: 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]]]],
  ['regression: 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]]]],
  ['regression: 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: 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]]]],
  ['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: 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,
    [['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: 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]]]],
  ['control: 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: 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]]]],
  ['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]]]],
  ['regression: 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',
   [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: 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]]]],
  ['regression: 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 5',
   [4,
    [['load', 53],
     ['load', 79],
     ['load', 69],
     ['unload', 57],
     ['load', 2],
     ['load', 76],
     ['unload', 73],
     ['load', 18],
     ['unload', 13],
     ['unload', 1],
     ['unload', 27]]],
   [[1, 0, False, False, [53, 0, 0, 0]],
    [2, 0, False, False, [53, 79, 0, 0]],
    [3, 0, False, False, [53, 79, 69, 0]],
    [2, 53, False, False, [79, 69, 0, 0]],
    [3, 53, False, False, [79, 69, 2, 0]],
    [4, 53, True, False, [79, 69, 2, 76]],
    [3, 79, False, False, [69, 2, 76, 0]],
    [4, 79, True, False, [69, 2, 76, 18]],
    [3, 69, False, False, [2, 76, 18, 0]],
    [2, 2, False, False, [76, 18, 0, 0]],
    [1, 76, False, False, [18, 0, 0, 0]]]],
  ['regression: 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: 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]]]],
  ['regression: 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]]]],
  ['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]]]],
  ['regression: 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 3',
   [4,
    [['unload', 22], ['load', 4], ['unload', 2], ['load', 69], ['load', 19], ['unload', 5], ['unload', 47]]],
   [[0, 0, False, True, [0, 0, 0, 0]],
    [1, 0, False, False, [4, 0, 0, 0]],
    [0, 4, False, True, [0, 0, 0, 0]],
    [1, 4, False, False, [69, 0, 0, 0]],
    [2, 4, False, False, [69, 19, 0, 0]],
    [1, 69, False, False, [19, 0, 0, 0]],
    [0, 19, False, True, [0, 0, 0, 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 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: 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]]]],
  ['regression: 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]]]],
  ['regression: 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 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]]]],
  ['regression: scenario 3',
   [3, [['unload', 7], ['unload', 28], ['load', 29], ['unload', 33], ['unload', 61], ['unload', 47]]],
   [[0, 0, False, True, [0, 0, 0]],
    [0, 0, False, True, [0, 0, 0]],
    [1, 0, False, False, [29, 0, 0]],
    [0, 29, False, True, [0, 0, 0]],
    [0, 29, False, True, [0, 0, 0]],
    [0, 29, False, True, [0, 0, 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:
Stale data remains visible in the file beyond the valid position.

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