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

N = 1
observations = []
def solve(cases):
    def run(c):
        desired=0; applied=0; serial=0; accepted=0; inflight={}; sent=[]
        for kind,value in c:
            if kind=='toggle': desired^=1<<value
            elif kind=='send' and desired!=applied:
                serial+=1
                inflight[serial]=desired
                sent.append([serial,desired])
            elif kind=='ack' and value in inflight and value>accepted:
                applied=inflight[value]
                accepted=serial
                inflight={k:v for k,v in inflight.items() if k>value}
            elif kind=='reset':
                applied=0; inflight={}; accepted=0
        return [desired,applied,serial,accepted,sorted([[k,v] for k,v in inflight.items()]),sent]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('lock-led-ack scenario 0', solve([[]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 1', solve([[['send', 0]]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 2', solve([[['toggle', 0], ['toggle', 0], ['send', 0]]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 3', solve([[['toggle', 2], ['send', 0], ['ack', 1]]] * N), [[4, 4, 1, 1, [], [[1, 4]]]] * N)
check('lock-led-ack scenario 4', solve([[['toggle', 0], ['send', 0], ['toggle', 1], ['send', 0], ['ack', 1]]] * N), [[3, 1, 2, 1, [[2, 3]], [[1, 1], [2, 3]]]] * N)
check('lock-led-ack scenario 5', solve([[['toggle', 0], ['send', 0], ['toggle', 1], ['send', 0], ['ack', 2], ['ack', 1]]] * N), [[3, 3, 2, 2, [], [[1, 1], [2, 3]]]] * N)
check('lock-led-ack scenario 6', solve([[['toggle', 1], ['send', 0], ['send', 0], ['ack', 1]]] * N), [[2, 2, 2, 1, [[2, 2]], [[1, 2], [2, 2]]]] * N)
check('lock-led-ack scenario 7', solve([[['toggle', 2], ['send', 0], ['reset', 0], ['send', 0]]] * N), [[4, 0, 2, 0, [[2, 4]], [[1, 4], [2, 4]]]] * N)
check('lock-led-ack scenario 8', solve([[['toggle', 0], ['send', 0], ['ack', 1], ['send', 0]]] * N), [[1, 1, 1, 1, [], [[1, 1]]]] * N)
check('lock-led-ack scenario 9', solve([[['ack', 999]]] * N), [[0, 0, 0, 0, [], []]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        desired=0; applied=0; serial=0; accepted=0; inflight={}; sent=[]
        for kind,value in c:
            if kind=='toggle': desired^=1<<value
            elif kind=='send' and desired!=applied:
                serial+=1
                inflight[serial]=desired
                sent.append([serial,desired])
            elif kind=='ack' and value in inflight and value>accepted:
                applied=inflight[value]
                accepted=applied
                inflight={k:v for k,v in inflight.items() if k>value}
            elif kind=='reset':
                applied=0; inflight={}; accepted=0
        return [desired,applied,serial,accepted,sorted([[k,v] for k,v in inflight.items()]),sent]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('lock-led-ack scenario 0', solve([[]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 1', solve([[['send', 0]]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 2', solve([[['toggle', 0], ['toggle', 0], ['send', 0]]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 3', solve([[['toggle', 2], ['send', 0], ['ack', 1]]] * N), [[4, 4, 1, 1, [], [[1, 4]]]] * N)
check('lock-led-ack scenario 4', solve([[['toggle', 0], ['send', 0], ['toggle', 1], ['send', 0], ['ack', 1]]] * N), [[3, 1, 2, 1, [[2, 3]], [[1, 1], [2, 3]]]] * N)
check('lock-led-ack scenario 5', solve([[['toggle', 0], ['send', 0], ['toggle', 1], ['send', 0], ['ack', 2], ['ack', 1]]] * N), [[3, 3, 2, 2, [], [[1, 1], [2, 3]]]] * N)
check('lock-led-ack scenario 6', solve([[['toggle', 1], ['send', 0], ['send', 0], ['ack', 1]]] * N), [[2, 2, 2, 1, [[2, 2]], [[1, 2], [2, 2]]]] * N)
check('lock-led-ack scenario 7', solve([[['toggle', 2], ['send', 0], ['reset', 0], ['send', 0]]] * N), [[4, 0, 2, 0, [[2, 4]], [[1, 4], [2, 4]]]] * N)
check('lock-led-ack scenario 8', solve([[['toggle', 0], ['send', 0], ['ack', 1], ['send', 0]]] * N), [[1, 1, 1, 1, [], [[1, 1]]]] * N)
check('lock-led-ack scenario 9', solve([[['ack', 999]]] * N), [[0, 0, 0, 0, [], []]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the accepted id rule and produces incorrect keyboard state or command output.

Events [kind,value]. Toggle flips desired lock bit 0..2. Send creates monotonically numbered snapshot request only when desired differs applied. Ack for an in-flight id newer than accepted applies that request snapshot, advances accepted id and discards requests <= ack. Unknown or stale ack is ignored. Reset sets applied=0, clears in-flight requests and accepted watermark but preserves desired and increasing request serial. Return desired,applied,serial,accepted,in-flight and sent [id,mask]. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        desired=0; applied=0; serial=0; accepted=0; inflight={}; sent=[]
        for kind,value in c:
            if kind=='toggle': desired^=1<<value
            elif kind=='send' and desired!=applied:
                serial+=1
                inflight[serial]=desired
                sent.append([serial,desired])
            elif kind=='ack' and value in inflight and value>accepted:
                applied=inflight[value]
                accepted=value
                inflight={k:v for k,v in inflight.items() if k>=value}
            elif kind=='reset':
                applied=0; inflight={}; accepted=0
        return [desired,applied,serial,accepted,sorted([[k,v] for k,v in inflight.items()]),sent]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('lock-led-ack scenario 0', solve([[]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 1', solve([[['send', 0]]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 2', solve([[['toggle', 0], ['toggle', 0], ['send', 0]]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 3', solve([[['toggle', 2], ['send', 0], ['ack', 1]]] * N), [[4, 4, 1, 1, [], [[1, 4]]]] * N)
check('lock-led-ack scenario 4', solve([[['toggle', 0], ['send', 0], ['toggle', 1], ['send', 0], ['ack', 1]]] * N), [[3, 1, 2, 1, [[2, 3]], [[1, 1], [2, 3]]]] * N)
check('lock-led-ack scenario 5', solve([[['toggle', 0], ['send', 0], ['toggle', 1], ['send', 0], ['ack', 2], ['ack', 1]]] * N), [[3, 3, 2, 2, [], [[1, 1], [2, 3]]]] * N)
check('lock-led-ack scenario 6', solve([[['toggle', 1], ['send', 0], ['send', 0], ['ack', 1]]] * N), [[2, 2, 2, 1, [[2, 2]], [[1, 2], [2, 2]]]] * N)
check('lock-led-ack scenario 7', solve([[['toggle', 2], ['send', 0], ['reset', 0], ['send', 0]]] * N), [[4, 0, 2, 0, [[2, 4]], [[1, 4], [2, 4]]]] * N)
check('lock-led-ack scenario 8', solve([[['toggle', 0], ['send', 0], ['ack', 1], ['send', 0]]] * N), [[1, 1, 1, 1, [], [[1, 1]]]] * N)
check('lock-led-ack scenario 9', solve([[['ack', 999]]] * N), [[0, 0, 0, 0, [], []]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(cases):
    def run(c):
        desired=0; applied=0; serial=0; accepted=0; inflight={}; sent=[]
        for kind,value in c:
            if kind=='toggle': desired^=1<<value
            elif kind=='send' and desired!=applied:
                serial+=1
                inflight[serial]=desired
                sent.append([serial,desired])
            elif kind=='ack' and value in inflight and value>accepted:
                applied=inflight[value]
                accepted=value
                inflight={k:v for k,v in inflight.items() if k<value}
            elif kind=='reset':
                applied=0; inflight={}; accepted=0
        return [desired,applied,serial,accepted,sorted([[k,v] for k,v in inflight.items()]),sent]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('lock-led-ack scenario 0', solve([[]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 1', solve([[['send', 0]]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 2', solve([[['toggle', 0], ['toggle', 0], ['send', 0]]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 3', solve([[['toggle', 2], ['send', 0], ['ack', 1]]] * N), [[4, 4, 1, 1, [], [[1, 4]]]] * N)
check('lock-led-ack scenario 4', solve([[['toggle', 0], ['send', 0], ['toggle', 1], ['send', 0], ['ack', 1]]] * N), [[3, 1, 2, 1, [[2, 3]], [[1, 1], [2, 3]]]] * N)
check('lock-led-ack scenario 5', solve([[['toggle', 0], ['send', 0], ['toggle', 1], ['send', 0], ['ack', 2], ['ack', 1]]] * N), [[3, 3, 2, 2, [], [[1, 1], [2, 3]]]] * N)
check('lock-led-ack scenario 6', solve([[['toggle', 1], ['send', 0], ['send', 0], ['ack', 1]]] * N), [[2, 2, 2, 1, [[2, 2]], [[1, 2], [2, 2]]]] * N)
check('lock-led-ack scenario 7', solve([[['toggle', 2], ['send', 0], ['reset', 0], ['send', 0]]] * N), [[4, 0, 2, 0, [[2, 4]], [[1, 4], [2, 4]]]] * N)
check('lock-led-ack scenario 8', solve([[['toggle', 0], ['send', 0], ['ack', 1], ['send', 0]]] * N), [[1, 1, 1, 1, [], [[1, 1]]]] * N)
check('lock-led-ack scenario 9', solve([[['ack', 999]]] * N), [[0, 0, 0, 0, [], []]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the retire requests rule and produces incorrect keyboard state or command output.

Events [kind,value]. Toggle flips desired lock bit 0..2. Send creates monotonically numbered snapshot request only when desired differs applied. Ack for an in-flight id newer than accepted applies that request snapshot, advances accepted id and discards requests <= ack. Unknown or stale ack is ignored. Reset sets applied=0, clears in-flight requests and accepted watermark but preserves desired and increasing request serial. Return desired,applied,serial,accepted,in-flight and sent [id,mask]. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        desired=0; applied=0; serial=0; accepted=0; inflight={}; sent=[]
        for kind,value in c:
            if kind=='toggle': desired^=1<<value
            elif kind=='send' and desired!=applied:
                serial+=1
                inflight[serial]=desired
                sent.append([serial,desired])
            elif kind=='ack' and value in inflight and value>accepted:
                applied=inflight[value]
                accepted=value
                inflight={k:v for k,v in inflight.items() if k>value}
            elif kind=='reset':
                desired=0; applied=0; inflight={}; accepted=0
        return [desired,applied,serial,accepted,sorted([[k,v] for k,v in inflight.items()]),sent]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('lock-led-ack scenario 0', solve([[]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 1', solve([[['send', 0]]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 2', solve([[['toggle', 0], ['toggle', 0], ['send', 0]]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 3', solve([[['toggle', 2], ['send', 0], ['ack', 1]]] * N), [[4, 4, 1, 1, [], [[1, 4]]]] * N)
check('lock-led-ack scenario 4', solve([[['toggle', 0], ['send', 0], ['toggle', 1], ['send', 0], ['ack', 1]]] * N), [[3, 1, 2, 1, [[2, 3]], [[1, 1], [2, 3]]]] * N)
check('lock-led-ack scenario 5', solve([[['toggle', 0], ['send', 0], ['toggle', 1], ['send', 0], ['ack', 2], ['ack', 1]]] * N), [[3, 3, 2, 2, [], [[1, 1], [2, 3]]]] * N)
check('lock-led-ack scenario 6', solve([[['toggle', 1], ['send', 0], ['send', 0], ['ack', 1]]] * N), [[2, 2, 2, 1, [[2, 2]], [[1, 2], [2, 2]]]] * N)
check('lock-led-ack scenario 7', solve([[['toggle', 2], ['send', 0], ['reset', 0], ['send', 0]]] * N), [[4, 0, 2, 0, [[2, 4]], [[1, 4], [2, 4]]]] * N)
check('lock-led-ack scenario 8', solve([[['toggle', 0], ['send', 0], ['ack', 1], ['send', 0]]] * N), [[1, 1, 1, 1, [], [[1, 1]]]] * N)
check('lock-led-ack scenario 9', solve([[['ack', 999]]] * N), [[0, 0, 0, 0, [], []]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        desired=0; applied=0; serial=0; accepted=0; inflight={}; sent=[]
        for kind,value in c:
            if kind=='toggle': desired^=1<<value
            elif kind=='send' and desired!=applied:
                serial+=1
                inflight[serial]=desired
                sent.append([serial,desired])
            elif kind=='ack' and value in inflight and value>accepted:
                applied=inflight[value]
                accepted=value
                inflight={k:v for k,v in inflight.items() if k>value}
            elif kind=='reset':
                applied=0; accepted=0
        return [desired,applied,serial,accepted,sorted([[k,v] for k,v in inflight.items()]),sent]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('lock-led-ack scenario 0', solve([[]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 1', solve([[['send', 0]]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 2', solve([[['toggle', 0], ['toggle', 0], ['send', 0]]] * N), [[0, 0, 0, 0, [], []]] * N)
check('lock-led-ack scenario 3', solve([[['toggle', 2], ['send', 0], ['ack', 1]]] * N), [[4, 4, 1, 1, [], [[1, 4]]]] * N)
check('lock-led-ack scenario 4', solve([[['toggle', 0], ['send', 0], ['toggle', 1], ['send', 0], ['ack', 1]]] * N), [[3, 1, 2, 1, [[2, 3]], [[1, 1], [2, 3]]]] * N)
check('lock-led-ack scenario 5', solve([[['toggle', 0], ['send', 0], ['toggle', 1], ['send', 0], ['ack', 2], ['ack', 1]]] * N), [[3, 3, 2, 2, [], [[1, 1], [2, 3]]]] * N)
check('lock-led-ack scenario 6', solve([[['toggle', 1], ['send', 0], ['send', 0], ['ack', 1]]] * N), [[2, 2, 2, 1, [[2, 2]], [[1, 2], [2, 2]]]] * N)
check('lock-led-ack scenario 7', solve([[['toggle', 2], ['send', 0], ['reset', 0], ['send', 0]]] * N), [[4, 0, 2, 0, [[2, 4]], [[1, 4], [2, 4]]]] * N)
check('lock-led-ack scenario 8', solve([[['toggle', 0], ['send', 0], ['ack', 1], ['send', 0]]] * N), [[1, 1, 1, 1, [], [[1, 1]]]] * N)
check('lock-led-ack scenario 9', solve([[['ack', 999]]] * N), [[0, 0, 0, 0, [], []]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the device reset rule and produces incorrect keyboard state or command output.

Events [kind,value]. Toggle flips desired lock bit 0..2. Send creates monotonically numbered snapshot request only when desired differs applied. Ack for an in-flight id newer than accepted applies that request snapshot, advances accepted id and discards requests <= ack. Unknown or stale ack is ignored. Reset sets applied=0, clears in-flight requests and accepted watermark but preserves desired and increasing request serial. Return desired,applied,serial,accepted,in-flight and sent [id,mask]. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<=rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the row domain rule and produces incorrect keyboard state or command output.

Case [rows,columns,reports]. Reports contain [row,column] cells. Ignore out-of-bounds coordinates. Any full observed rectangle with two distinct rows and columns makes its four corners ambiguous. Newly ambiguous presses are quarantined, but already accepted cells remain held while still observed. Emit sorted release edges then sorted press edges for each report. Return edges, accepted cells and final quarantined cells. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<=columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the column domain rule and produces incorrect keyboard state or command output.

Case [rows,columns,reports]. Reports contain [row,column] cells. Ignore out-of-bounds coordinates. Any full observed rectangle with two distinct rows and columns makes its four corners ambiguous. Newly ambiguous presses are quarantined, but already accepted cells remain held while still observed. Emit sorted release edges then sorted press edges for each report. Return edges, accepted cells and final quarantined cells. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows-1):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the distinct rows rule and produces incorrect keyboard state or command output.

Case [rows,columns,reports]. Reports contain [row,column] cells. Ignore out-of-bounds coordinates. Any full observed rectangle with two distinct rows and columns makes its four corners ambiguous. Newly ambiguous presses are quarantined, but already accepted cells remain held while still observed. Emit sorted release edges then sorted press edges for each report. Return edges, accepted cells and final quarantined cells. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns-1):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the distinct columns rule and produces incorrect keyboard state or command output.

Case [rows,columns,reports]. Reports contain [row,column] cells. Ignore out-of-bounds coordinates. Any full observed rectangle with two distinct rows and columns makes its four corners ambiguous. Newly ambiguous presses are quarantined, but already accepted cells remain held while still observed. Emit sorted release edges then sorted press edges for each report. Return edges, accepted cells and final quarantined cells. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if len(rectangle&raw)>=3: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle==raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the rectangle completeness rule and produces incorrect keyboard state or command output.

Case [rows,columns,reports]. Reports contain [row,column] cells. Ignore out-of-bounds coordinates. Any full observed rectangle with two distinct rows and columns makes its four corners ambiguous. Newly ambiguous presses are quarantined, but already accepted cells remain held while still observed. Emit sorted release edges then sorted press edges for each report. Return edges, accepted cells and final quarantined cells. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous&=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the rectangle union rule and produces incorrect keyboard state or command output.

Case [rows,columns,reports]. Reports contain [row,column] cells. Ignore out-of-bounds coordinates. Any full observed rectangle with two distinct rows and columns makes its four corners ambiguous. Newly ambiguous presses are quarantined, but already accepted cells remain held while still observed. Emit sorted release edges then sorted press edges for each report. Return edges, accepted cells and final quarantined cells. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=raw-ambiguous
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|old
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the preserve held rule and produces incorrect keyboard state or command output.

Case [rows,columns,reports]. Reports contain [row,column] cells. Ignore out-of-bounds coordinates. Any full observed rectangle with two distinct rows and columns makes its four corners ambiguous. Newly ambiguous presses are quarantined, but already accepted cells remain held while still observed. Emit sorted release edges then sorted press edges for each report. Return edges, accepted cells and final quarantined cells. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(accepted-old): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the release delta rule and produces incorrect keyboard state or command output.

Case [rows,columns,reports]. Reports contain [row,column] cells. Ignore out-of-bounds coordinates. Any full observed rectangle with two distinct rows and columns makes its four corners ambiguous. Newly ambiguous presses are quarantined, but already accepted cells remain held while still observed. Emit sorted release edges then sorted press edges for each report. Return edges, accepted cells and final quarantined cells. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(old-accepted): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted): output.append(['down',r,col])
            quarantined=raw-accepted
            old=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the press delta rule and produces incorrect keyboard state or command output.

Case [rows,columns,reports]. Reports contain [row,column] cells. Ignore out-of-bounds coordinates. Any full observed rectangle with two distinct rows and columns makes its four corners ambiguous. Newly ambiguous presses are quarantined, but already accepted cells remain held while still observed. Emit sorted release edges then sorted press edges for each report. Return edges, accepted cells and final quarantined cells. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old=raw
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        rows,columns,reports=c
        old=set(); output=[]; quarantined=set()
        for report in reports:
            raw={(r,col) for r,col in report if 0<=r<rows and 0<=col<columns}
            ambiguous=set()
            for r1 in range(rows):
                for r2 in range(r1+1,rows):
                    for c1 in range(columns):
                        for c2 in range(c1+1,columns):
                            rectangle={(r1,c1),(r1,c2),(r2,c1),(r2,c2)}
                            if rectangle<=raw: ambiguous|=rectangle
            accepted=(raw-ambiguous)|(old&raw)
            for r,col in sorted(old-accepted): output.append(['up',r,col])
            for r,col in sorted(accepted-old): output.append(['down',r,col])
            quarantined=raw-accepted
            old|=accepted
        return [output,[list(x) for x in sorted(old)],[list(x) for x in sorted(quarantined)]]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('matrix-ghost-quarantine scenario 0', solve([[2, 2, []]] * N), [[[], [], []]] * N)
check('matrix-ghost-quarantine scenario 1', solve([[2, 2, [[[0, 0], [0, 1], [1, 0]]]]] * N), [[[['down', 0, 0], ['down', 0, 1], ['down', 1, 0]], [[0, 0], [0, 1], [1, 0]], []]] * N)
check('matrix-ghost-quarantine scenario 2', solve([[2, 2, [[[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 3', solve([[2, 2, [[[0, 0], [0, 1]], [[0, 0], [0, 1], [1, 0], [1, 1]]]]] * N), [[[['down', 0, 0], ['down', 0, 1]], [[0, 0], [0, 1]], [[1, 0], [1, 1]]]] * N)
check('matrix-ghost-quarantine scenario 4', solve([[2, 2, [[[0, 0]], []]]] * N), [[[['down', 0, 0], ['up', 0, 0]], [], []]] * N)
check('matrix-ghost-quarantine scenario 5', solve([[2, 2, [[[-1, 0], [0, -1], [2, 0], [0, 2], [1, 1]]]]] * N), [[[['down', 1, 1]], [[1, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 6', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]]] * N), [[[], [], [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]]] * N)
check('matrix-ghost-quarantine scenario 7', solve([[2, 2, [[[0, 0]], [[0, 0]], [[0, 1]]]]] * N), [[[['down', 0, 0], ['up', 0, 0], ['down', 0, 1]], [[0, 1]], []]] * N)
check('matrix-ghost-quarantine scenario 8', solve([[3, 3, [[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]]]] * N), [[[['down', 2, 2]], [[2, 2]], [[0, 0], [0, 1], [1, 0], [1, 1]]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the accepted snapshot rule and produces incorrect keyboard state or command output.

Case [rows,columns,reports]. Reports contain [row,column] cells. Ignore out-of-bounds coordinates. Any full observed rectangle with two distinct rows and columns makes its four corners ambiguous. Newly ambiguous presses are quarantined, but already accepted cells remain held while still observed. Emit sorted release edges then sorted press edges for each report. Return edges, accepted cells and final quarantined cells. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        bindings,timeout,events=c
        buffer=[]; pending=None; deadline=None; out=[]
        for kind,key,now in events:
            if kind=='cancel':
                buffer=[]; deadline=None
                continue
            if deadline is not None and now>=deadline:
                if pending is not None: out.append([pending,deadline])
                buffer=[]; pending=None; deadline=None
            if kind!='down': continue
            candidate=buffer+[key]
            candidates=[b for b in bindings if b[0][:len(candidate)]==candidate]
            if not candidates:
                if pending is not None: out.append([pending,now])
                candidate=[key]
                candidates=[b for b in bindings if b[0][:1]==candidate]
                pending=None
            buffer=candidate if candidates else []
            exact=[b for b in candidates if len(b[0])==len(buffer)]
            longer=[b for b in candidates if len(b[0])>len(buffer)]
            if exact and not longer:
                out.append([exact[0][1],now])
                buffer=[]; pending=None; deadline=None
            else:
                pending=exact[0][1] if exact else None
                deadline=now+timeout if candidates else None
        return [out,buffer,pending,deadline]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ambiguous-shortcut-prefix scenario 0', solve([[[[['A'], 'short'], [['A', 'B'], 'long'], [['C'], 'other']], 5, []]] * N), [[[], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 1', solve([[[[['A'], 'short'], [['A', 'B'], 'long'], [['C'], 'other']], 5, [['down', 'A', 10], ['tick', '', 15]]]] * N), [[[['short', 15]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 2', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['tick', '', 20]]]] * N), [[[['short', 15]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 3', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['down', 'B', 12]]]] * N), [[[['long', 12]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 4', solve([[[[['A'], 'short'], [['A', 'B'], 'long'], [['C'], 'other']], 5, [['down', 'A', 10], ['down', 'C', 12]]]] * N), [[[['short', 12], ['other', 12]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 5', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['cancel', '', 11]]]] * N), [[[], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 6', solve([[[[['A', 'B'], 'long']], 5, [['down', 'A', 10], ['up', 'B', 11]]]] * N), [[[], ['A'], None, 15]] * N)
check('ambiguous-shortcut-prefix scenario 7', solve([[[[['A', 'B'], 'long']], 5, [['down', 'A', 10], ['tick', 'B', 11]]]] * N), [[[], ['A'], None, 15]] * N)
check('ambiguous-shortcut-prefix scenario 8', solve([[[[['A', 'B'], 'long']], 5, [['down', 'Z', 10]]]] * N), [[[], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 9', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['down', 'B', 15]]]] * N), [[[['short', 15]], [], None, None]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        bindings,timeout,events=c
        buffer=[]; pending=None; deadline=None; out=[]
        for kind,key,now in events:
            if kind=='cancel':
                pending=None; deadline=None
                continue
            if deadline is not None and now>=deadline:
                if pending is not None: out.append([pending,deadline])
                buffer=[]; pending=None; deadline=None
            if kind!='down': continue
            candidate=buffer+[key]
            candidates=[b for b in bindings if b[0][:len(candidate)]==candidate]
            if not candidates:
                if pending is not None: out.append([pending,now])
                candidate=[key]
                candidates=[b for b in bindings if b[0][:1]==candidate]
                pending=None
            buffer=candidate if candidates else []
            exact=[b for b in candidates if len(b[0])==len(buffer)]
            longer=[b for b in candidates if len(b[0])>len(buffer)]
            if exact and not longer:
                out.append([exact[0][1],now])
                buffer=[]; pending=None; deadline=None
            else:
                pending=exact[0][1] if exact else None
                deadline=now+timeout if candidates else None
        return [out,buffer,pending,deadline]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ambiguous-shortcut-prefix scenario 0', solve([[[[['A'], 'short'], [['A', 'B'], 'long'], [['C'], 'other']], 5, []]] * N), [[[], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 1', solve([[[[['A'], 'short'], [['A', 'B'], 'long'], [['C'], 'other']], 5, [['down', 'A', 10], ['tick', '', 15]]]] * N), [[[['short', 15]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 2', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['tick', '', 20]]]] * N), [[[['short', 15]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 3', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['down', 'B', 12]]]] * N), [[[['long', 12]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 4', solve([[[[['A'], 'short'], [['A', 'B'], 'long'], [['C'], 'other']], 5, [['down', 'A', 10], ['down', 'C', 12]]]] * N), [[[['short', 12], ['other', 12]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 5', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['cancel', '', 11]]]] * N), [[[], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 6', solve([[[[['A', 'B'], 'long']], 5, [['down', 'A', 10], ['up', 'B', 11]]]] * N), [[[], ['A'], None, 15]] * N)
check('ambiguous-shortcut-prefix scenario 7', solve([[[[['A', 'B'], 'long']], 5, [['down', 'A', 10], ['tick', 'B', 11]]]] * N), [[[], ['A'], None, 15]] * N)
check('ambiguous-shortcut-prefix scenario 8', solve([[[[['A', 'B'], 'long']], 5, [['down', 'Z', 10]]]] * N), [[[], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 9', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['down', 'B', 15]]]] * N), [[[['short', 15]], [], None, None]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the cancel discard rule and produces incorrect keyboard state or command output.

Case [bindings,timeout,events]. Binding [nonempty_key_sequence,action] has unique sequence. Events [kind,key,time]. Down extends prefix. Exact match with longer candidates is delayed until deadline; exact unambiguous match dispatches immediately. Tick or next event at deadline emits pending exact match and clears prefix. Mismatch dispatches pending match then retries only current key as fresh prefix. Cancel drops pending without dispatch. Return [action,time] dispatches,buffer,pending action,deadline. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        bindings,timeout,events=c
        buffer=[]; pending=None; deadline=None; out=[]
        for kind,key,now in events:
            if kind=='cancel':
                buffer=[]; pending=None; deadline=None
                continue
            if deadline is not None and now>deadline:
                if pending is not None: out.append([pending,deadline])
                buffer=[]; pending=None; deadline=None
            if kind!='down': continue
            candidate=buffer+[key]
            candidates=[b for b in bindings if b[0][:len(candidate)]==candidate]
            if not candidates:
                if pending is not None: out.append([pending,now])
                candidate=[key]
                candidates=[b for b in bindings if b[0][:1]==candidate]
                pending=None
            buffer=candidate if candidates else []
            exact=[b for b in candidates if len(b[0])==len(buffer)]
            longer=[b for b in candidates if len(b[0])>len(buffer)]
            if exact and not longer:
                out.append([exact[0][1],now])
                buffer=[]; pending=None; deadline=None
            else:
                pending=exact[0][1] if exact else None
                deadline=now+timeout if candidates else None
        return [out,buffer,pending,deadline]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ambiguous-shortcut-prefix scenario 0', solve([[[[['A'], 'short'], [['A', 'B'], 'long'], [['C'], 'other']], 5, []]] * N), [[[], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 1', solve([[[[['A'], 'short'], [['A', 'B'], 'long'], [['C'], 'other']], 5, [['down', 'A', 10], ['tick', '', 15]]]] * N), [[[['short', 15]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 2', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['tick', '', 20]]]] * N), [[[['short', 15]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 3', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['down', 'B', 12]]]] * N), [[[['long', 12]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 4', solve([[[[['A'], 'short'], [['A', 'B'], 'long'], [['C'], 'other']], 5, [['down', 'A', 10], ['down', 'C', 12]]]] * N), [[[['short', 12], ['other', 12]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 5', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['cancel', '', 11]]]] * N), [[[], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 6', solve([[[[['A', 'B'], 'long']], 5, [['down', 'A', 10], ['up', 'B', 11]]]] * N), [[[], ['A'], None, 15]] * N)
check('ambiguous-shortcut-prefix scenario 7', solve([[[[['A', 'B'], 'long']], 5, [['down', 'A', 10], ['tick', 'B', 11]]]] * N), [[[], ['A'], None, 15]] * N)
check('ambiguous-shortcut-prefix scenario 8', solve([[[[['A', 'B'], 'long']], 5, [['down', 'Z', 10]]]] * N), [[[], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 9', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['down', 'B', 15]]]] * N), [[[['short', 15]], [], None, None]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        bindings,timeout,events=c
        buffer=[]; pending=None; deadline=None; out=[]
        for kind,key,now in events:
            if kind=='cancel':
                buffer=[]; pending=None; deadline=None
                continue
            if deadline is not None and now>=timeout:
                if pending is not None: out.append([pending,deadline])
                buffer=[]; pending=None; deadline=None
            if kind!='down': continue
            candidate=buffer+[key]
            candidates=[b for b in bindings if b[0][:len(candidate)]==candidate]
            if not candidates:
                if pending is not None: out.append([pending,now])
                candidate=[key]
                candidates=[b for b in bindings if b[0][:1]==candidate]
                pending=None
            buffer=candidate if candidates else []
            exact=[b for b in candidates if len(b[0])==len(buffer)]
            longer=[b for b in candidates if len(b[0])>len(buffer)]
            if exact and not longer:
                out.append([exact[0][1],now])
                buffer=[]; pending=None; deadline=None
            else:
                pending=exact[0][1] if exact else None
                deadline=now+timeout if candidates else None
        return [out,buffer,pending,deadline]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ambiguous-shortcut-prefix scenario 0', solve([[[[['A'], 'short'], [['A', 'B'], 'long'], [['C'], 'other']], 5, []]] * N), [[[], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 1', solve([[[[['A'], 'short'], [['A', 'B'], 'long'], [['C'], 'other']], 5, [['down', 'A', 10], ['tick', '', 15]]]] * N), [[[['short', 15]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 2', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['tick', '', 20]]]] * N), [[[['short', 15]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 3', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['down', 'B', 12]]]] * N), [[[['long', 12]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 4', solve([[[[['A'], 'short'], [['A', 'B'], 'long'], [['C'], 'other']], 5, [['down', 'A', 10], ['down', 'C', 12]]]] * N), [[[['short', 12], ['other', 12]], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 5', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['cancel', '', 11]]]] * N), [[[], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 6', solve([[[[['A', 'B'], 'long']], 5, [['down', 'A', 10], ['up', 'B', 11]]]] * N), [[[], ['A'], None, 15]] * N)
check('ambiguous-shortcut-prefix scenario 7', solve([[[[['A', 'B'], 'long']], 5, [['down', 'A', 10], ['tick', 'B', 11]]]] * N), [[[], ['A'], None, 15]] * N)
check('ambiguous-shortcut-prefix scenario 8', solve([[[[['A', 'B'], 'long']], 5, [['down', 'Z', 10]]]] * N), [[[], [], None, None]] * N)
check('ambiguous-shortcut-prefix scenario 9', solve([[[[['A'], 'short'], [['A', 'B'], 'long']], 5, [['down', 'A', 10], ['down', 'B', 15]]]] * N), [[[['short', 15]], [], None, None]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the inclusive timeout rule and produces incorrect keyboard state or command output.

Case [bindings,timeout,events]. Binding [nonempty_key_sequence,action] has unique sequence. Events [kind,key,time]. Down extends prefix. Exact match with longer candidates is delayed until deadline; exact unambiguous match dispatches immediately. Tick or next event at deadline emits pending exact match and clears prefix. Mismatch dispatches pending match then retries only current key as fresh prefix. Cancel drops pending without dispatch. Return [action,time] dispatches,buffer,pending action,deadline. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access