broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(commenced, diversity, defendants, holidays):
    c = dt.date.fromisoformat(commenced)
    hol = {dt.date.fromisoformat(x) for x in holidays}
    bar = c + dt.timedelta(days=365)
    triggers = []
    for name, served, received in defendants:
        s = dt.date.fromisoformat(served)
        r = dt.date.fromisoformat(received) if received else None
        triggers.append(max(s, r) if r else s)
    first = min(triggers)
    out = []
    for (name, served, received), trig in zip(defendants, triggers):
        base = trig
        d = base + dt.timedelta(days=30)
        while d.weekday() >= 5 or d in hol:
            d += dt.timedelta(days=1)
        if diversity:
            if trig > bar:
                out.append([name, 'barred'])
                continue
            d = min(d, bar)
        out.append([name, d.isoformat()])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']]),
  ('later receipt via agent',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-03-06']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-05']]),
  ('later served defendant',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-06-03', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-07-03']]),
  ('later served within 30',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-03-21']]),
  ('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']])],
 [('later served defendant',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-06-03', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-07-03']]),
  ('later served within 30',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-03-21']]),
  ('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']])],
 [('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']])],
 [('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('federal question two defendants late',
   ['2023-01-10',
    False,
    [['acme', '2023-02-01', None], ['beta', '2024-01-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-03-03'], ['beta', '2024-02-20']]),
  ('diversity before leap day',
   ['2023-03-01',
    True,
    [['acme', '2024-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-01']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']])],
 [('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('federal question two defendants late',
   ['2023-01-10',
    False,
    [['acme', '2023-02-01', None], ['beta', '2024-01-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-03-03'], ['beta', '2024-02-20']]),
  ('diversity before leap day',
   ['2023-03-01',
    True,
    [['acme', '2024-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-01']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']]),
  ('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']])]]
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
import datetime as dt
import calendar
N = 1
observations = []
def solve(commenced, diversity, defendants, holidays):
    c = dt.date.fromisoformat(commenced)
    hol = {dt.date.fromisoformat(x) for x in holidays}
    bar = dt.date(c.year + 1, 3, 1) if (c.month, c.day) == (2, 29) else dt.date(c.year + 1, c.month, c.day)
    triggers = []
    for name, served, received in defendants:
        s = dt.date.fromisoformat(served)
        r = dt.date.fromisoformat(received) if received else None
        triggers.append(max(s, r) if r else s)
    first = min(triggers)
    out = []
    for (name, served, received), trig in zip(defendants, triggers):
        base = trig
        d = base + dt.timedelta(days=30)
        while d.weekday() >= 5 or d in hol:
            d += dt.timedelta(days=1)
        if diversity:
            if trig > bar:
                out.append([name, 'barred'])
                continue
            d = min(d, bar)
        out.append([name, d.isoformat()])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']]),
  ('later receipt via agent',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-03-06']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-05']]),
  ('later served defendant',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-06-03', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-07-03']]),
  ('later served within 30',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-03-21']]),
  ('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']])],
 [('later served defendant',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-06-03', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-07-03']]),
  ('later served within 30',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-03-21']]),
  ('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']])],
 [('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']])],
 [('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('federal question two defendants late',
   ['2023-01-10',
    False,
    [['acme', '2023-02-01', None], ['beta', '2024-01-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-03-03'], ['beta', '2024-02-20']]),
  ('diversity before leap day',
   ['2023-03-01',
    True,
    [['acme', '2024-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-01']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']])],
 [('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('federal question two defendants late',
   ['2023-01-10',
    False,
    [['acme', '2023-02-01', None], ['beta', '2024-01-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-03-03'], ['beta', '2024-02-20']]),
  ('diversity before leap day',
   ['2023-03-01',
    True,
    [['acme', '2024-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-01']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']]),
  ('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']])]]
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:
For a case commenced on March 1 before a leap day, the one-year removal bar falls on February 29.

Stipulated: each defendant [name, served, received] has 30 days from its own trigger, where the trigger is formal service, or later receipt of the pleading when received (not None) after service; a courtesy copy received before service does not start the clock. A deadline on a weekend or listed holiday moves to the next open day. In diversity cases removal is additionally barred after one year from commencement (anniversary, never moved): the deadline is capped there, and a defendant whose trigger is after the bar gets "barred". Return [[name, deadline or "barred"]].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(commenced, diversity, defendants, holidays):
    c = dt.date.fromisoformat(commenced)
    hol = {dt.date.fromisoformat(x) for x in holidays}
    bar = dt.date(c.year + 1, c.month, min(c.day, calendar.monthrange(c.year + 1, c.month)[1]))
    triggers = []
    for name, served, received in defendants:
        s = dt.date.fromisoformat(served)
        r = dt.date.fromisoformat(received) if received else None
        triggers.append(min(s, r) if r else s)
    first = min(triggers)
    out = []
    for (name, served, received), trig in zip(defendants, triggers):
        base = trig
        d = base + dt.timedelta(days=30)
        while d.weekday() >= 5 or d in hol:
            d += dt.timedelta(days=1)
        if diversity:
            if trig > bar:
                out.append([name, 'barred'])
                continue
            d = min(d, bar)
        out.append([name, d.isoformat()])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']]),
  ('later receipt via agent',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-03-06']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-05']]),
  ('later served defendant',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-06-03', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-07-03']]),
  ('later served within 30',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-03-21']]),
  ('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']])],
 [('later served defendant',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-06-03', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-07-03']]),
  ('later served within 30',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-03-21']]),
  ('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']]),
  ('later receipt via agent',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-03-06']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-05']])],
 [('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']])],
 [('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('federal question two defendants late',
   ['2023-01-10',
    False,
    [['acme', '2023-02-01', None], ['beta', '2024-01-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-03-03'], ['beta', '2024-02-20']]),
  ('diversity before leap day',
   ['2023-03-01',
    True,
    [['acme', '2024-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-01']]),
  ('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']]),
  ('later receipt via agent',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-03-06']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-05']])],
 [('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('federal question two defendants late',
   ['2023-01-10',
    False,
    [['acme', '2023-02-01', None], ['beta', '2024-01-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-03-03'], ['beta', '2024-02-20']]),
  ('diversity before leap day',
   ['2023-03-01',
    True,
    [['acme', '2024-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-01']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']]),
  ('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']])]]
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
import datetime as dt
import calendar
N = 1
observations = []
def solve(commenced, diversity, defendants, holidays):
    c = dt.date.fromisoformat(commenced)
    hol = {dt.date.fromisoformat(x) for x in holidays}
    bar = dt.date(c.year + 1, c.month, min(c.day, calendar.monthrange(c.year + 1, c.month)[1]))
    triggers = []
    for name, served, received in defendants:
        s = dt.date.fromisoformat(served)
        r = dt.date.fromisoformat(received) if received else None
        triggers.append(r if r else s)
    first = min(triggers)
    out = []
    for (name, served, received), trig in zip(defendants, triggers):
        base = trig
        d = base + dt.timedelta(days=30)
        while d.weekday() >= 5 or d in hol:
            d += dt.timedelta(days=1)
        if diversity:
            if trig > bar:
                out.append([name, 'barred'])
                continue
            d = min(d, bar)
        out.append([name, d.isoformat()])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']]),
  ('later receipt via agent',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-03-06']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-05']]),
  ('later served defendant',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-06-03', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-07-03']]),
  ('later served within 30',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-03-21']]),
  ('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']])],
 [('later served defendant',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-06-03', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-07-03']]),
  ('later served within 30',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-03-21']]),
  ('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']]),
  ('later receipt via agent',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-03-06']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-05']])],
 [('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']])],
 [('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('federal question two defendants late',
   ['2023-01-10',
    False,
    [['acme', '2023-02-01', None], ['beta', '2024-01-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-03-03'], ['beta', '2024-02-20']]),
  ('diversity before leap day',
   ['2023-03-01',
    True,
    [['acme', '2024-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-01']]),
  ('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']]),
  ('later receipt via agent',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-03-06']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-05']])],
 [('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('federal question two defendants late',
   ['2023-01-10',
    False,
    [['acme', '2023-02-01', None], ['beta', '2024-01-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-03-03'], ['beta', '2024-02-20']]),
  ('diversity before leap day',
   ['2023-03-01',
    True,
    [['acme', '2024-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-01']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']]),
  ('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']])]]
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 courtesy copy emailed before formal service starts the 30-day clock early.

Stipulated: each defendant [name, served, received] has 30 days from its own trigger, where the trigger is formal service, or later receipt of the pleading when received (not None) after service; a courtesy copy received before service does not start the clock. A deadline on a weekend or listed holiday moves to the next open day. In diversity cases removal is additionally barred after one year from commencement (anniversary, never moved): the deadline is capped there, and a defendant whose trigger is after the bar gets "barred". Return [[name, deadline or "barred"]].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(commenced, diversity, defendants, holidays):
    c = dt.date.fromisoformat(commenced)
    hol = {dt.date.fromisoformat(x) for x in holidays}
    bar = dt.date(c.year + 1, c.month, min(c.day, calendar.monthrange(c.year + 1, c.month)[1]))
    triggers = []
    for name, served, received in defendants:
        s = dt.date.fromisoformat(served)
        r = dt.date.fromisoformat(received) if received else None
        triggers.append(max(s, r) if r else s)
    first = min(triggers)
    out = []
    for (name, served, received), trig in zip(defendants, triggers):
        base = first
        d = base + dt.timedelta(days=30)
        while d.weekday() >= 5 or d in hol:
            d += dt.timedelta(days=1)
        if diversity:
            if trig > bar:
                out.append([name, 'barred'])
                continue
            d = min(d, bar)
        out.append([name, d.isoformat()])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']]),
  ('later receipt via agent',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-03-06']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-05']]),
  ('later served defendant',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-06-03', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-07-03']]),
  ('later served within 30',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-03-21']]),
  ('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']])],
 [('later served defendant',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-06-03', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-07-03']]),
  ('later served within 30',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-03-21']]),
  ('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']])],
 [('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']])],
 [('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('federal question two defendants late',
   ['2023-01-10',
    False,
    [['acme', '2023-02-01', None], ['beta', '2024-01-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-03-03'], ['beta', '2024-02-20']]),
  ('diversity before leap day',
   ['2023-03-01',
    True,
    [['acme', '2024-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-01']])],
 [('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('federal question two defendants late',
   ['2023-01-10',
    False,
    [['acme', '2023-02-01', None], ['beta', '2024-01-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-03-03'], ['beta', '2024-02-20']]),
  ('diversity before leap day',
   ['2023-03-01',
    True,
    [['acme', '2024-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-01']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']]),
  ('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']])]]
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
import datetime as dt
import calendar
N = 1
observations = []
def solve(commenced, diversity, defendants, holidays):
    c = dt.date.fromisoformat(commenced)
    hol = {dt.date.fromisoformat(x) for x in holidays}
    bar = dt.date(c.year + 1, c.month, min(c.day, calendar.monthrange(c.year + 1, c.month)[1]))
    triggers = []
    for name, served, received in defendants:
        s = dt.date.fromisoformat(served)
        r = dt.date.fromisoformat(received) if received else None
        triggers.append(max(s, r) if r else s)
    first = min(triggers)
    out = []
    for (name, served, received), trig in zip(defendants, triggers):
        base = trig if (trig - first).days <= 30 else first
        d = base + dt.timedelta(days=30)
        while d.weekday() >= 5 or d in hol:
            d += dt.timedelta(days=1)
        if diversity:
            if trig > bar:
                out.append([name, 'barred'])
                continue
            d = min(d, bar)
        out.append([name, d.isoformat()])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']]),
  ('later receipt via agent',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-03-06']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-05']]),
  ('later served defendant',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-06-03', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-07-03']]),
  ('later served within 30',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-03-21']]),
  ('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']])],
 [('later served defendant',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-06-03', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-07-03']]),
  ('later served within 30',
   ['2024-01-10',
    False,
    [['acme', '2024-02-01', None], ['beta', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-04'], ['beta', '2024-03-21']]),
  ('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']])],
 [('federal question late',
   ['2023-01-10',
    False,
    [['acme', '2024-01-05', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-02-05']]),
  ('diversity capped',
   ['2023-01-10',
    True,
    [['acme', '2023-12-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-01-10']]),
  ('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']])],
 [('diversity barred',
   ['2023-01-10',
    True,
    [['acme', '2024-01-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', 'barred']]),
  ('diversity served eleven months',
   ['2023-03-15',
    True,
    [['acme', '2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('federal question two defendants late',
   ['2023-01-10',
    False,
    [['acme', '2023-02-01', None], ['beta', '2024-01-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-03-03'], ['beta', '2024-02-20']]),
  ('diversity before leap day',
   ['2023-03-01',
    True,
    [['acme', '2024-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-01']])],
 [('served on anniversary',
   ['2023-03-15',
    True,
    [['acme', '2024-03-15', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-15']]),
  ('two defendants diversity',
   ['2023-06-01',
    True,
    [['acme', '2023-07-03', None], ['beta', '2024-05-20', None]],
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-08-02'], ['beta', '2024-06-01']]),
  ('deadline lands on holiday',
   ['2024-01-10',
    False,
    [['acme', '2024-05-28', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-06-27']]),
  ('federal question two defendants late',
   ['2023-01-10',
    False,
    [['acme', '2023-02-01', None], ['beta', '2024-01-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2023-03-03'], ['beta', '2024-02-20']]),
  ('diversity before leap day',
   ['2023-03-01',
    True,
    [['acme', '2024-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-03-01']]),
  ('diversity commenced leap day',
   ['2024-02-29',
    True,
    [['acme', '2025-02-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2025-02-28']]),
  ('regression: courtesy copy before service',
   ['2024-01-10',
    False,
    [['acme', '2024-03-01', '2024-02-20']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   [['acme', '2024-04-01']])]]
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 defendant served months after the first defendant has already lost its right to remove.

Stipulated: each defendant [name, served, received] has 30 days from its own trigger, where the trigger is formal service, or later receipt of the pleading when received (not None) after service; a courtesy copy received before service does not start the clock. A deadline on a weekend or listed holiday moves to the next open day. In diversity cases removal is additionally barred after one year from commencement (anniversary, never moved): the deadline is capped there, and a defendant whose trigger is after the bar gets "barred". Return [[name, deadline or "barred"]].

split: open-access