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

N = 1
observations = []
def solve(cases):
    def run(c):
        out=[]; batch=None
        for kind,device,code,now,repeat in c:
            eligible=kind=='down' and repeat
            if eligible:
                if batch is not None and batch[0]==device and batch[1]==code:
                    batch[3]=now
                    batch[4]+=1
                else:
                    if batch is not None: out.append(['repeat']+batch)
                    batch=[device,code,now,now,1]
            else:
                if batch is not None:
                    out.append(['raw']+batch)
                    batch=None
                out.append(['raw',kind,device,code,now])
        if batch is not None: out.append(['repeat']+batch)
        return out
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat-coalescing scenario 0', solve([[]] * N), [[]] * N)
check('repeat-coalescing scenario 1', solve([[['down', 'a', 'A', 10, False]]] * N), [[['raw', 'down', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 2', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 12, 2]]] * N)
check('repeat-coalescing scenario 3', solve([[['down', 'a', 'A', 10, True], ['down', 'b', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'b', 'A', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 4', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'B', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'a', 'B', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 5', solve([[['down', 'a', 'A', 10, True], ['up', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]] * N)
check('repeat-coalescing scenario 6', solve([[['up', 'a', 'A', 10, True]]] * N), [[['raw', 'up', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 7', solve([[['down', 'a', 'A', 10, True], ['text', 'a', 'A', 12, False]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]] * N)
check('repeat-coalescing scenario 8', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 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):
        out=[]; batch=None
        for kind,device,code,now,repeat in c:
            eligible=kind=='down' and repeat
            if eligible:
                if batch is not None and batch[0]==device and batch[1]==code:
                    batch[3]=now
                    batch[4]+=1
                else:
                    if batch is not None: out.append(['repeat']+batch)
                    batch=[device,code,now,now,1]
            else:
                if batch is not None:
                    pass
                    batch=None
                out.append(['raw',kind,device,code,now])
        if batch is not None: out.append(['repeat']+batch)
        return out
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat-coalescing scenario 0', solve([[]] * N), [[]] * N)
check('repeat-coalescing scenario 1', solve([[['down', 'a', 'A', 10, False]]] * N), [[['raw', 'down', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 2', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 12, 2]]] * N)
check('repeat-coalescing scenario 3', solve([[['down', 'a', 'A', 10, True], ['down', 'b', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'b', 'A', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 4', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'B', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'a', 'B', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 5', solve([[['down', 'a', 'A', 10, True], ['up', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]] * N)
check('repeat-coalescing scenario 6', solve([[['up', 'a', 'A', 10, True]]] * N), [[['raw', 'up', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 7', solve([[['down', 'a', 'A', 10, True], ['text', 'a', 'A', 12, False]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]] * N)
check('repeat-coalescing scenario 8', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 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 barrier flush rule and produces incorrect keyboard state or command output.

Events [kind,device,code,time,repeat]. Consecutive repeated down events for the same device/code coalesce into [device,code,first,last,count]; any nonrepeat or non-down event flushes the batch and is emitted as a raw event. A repeated down for a different token flushes and starts another. Return ordered entries tagged repeat or raw. 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):
        out=[]; batch=None
        for kind,device,code,now,repeat in c:
            eligible=kind=='down' and repeat
            if eligible:
                if batch is not None and batch[0]==device and batch[1]==code:
                    batch[3]=now
                    batch[4]+=1
                else:
                    if batch is not None: out.append(['repeat']+batch)
                    batch=[device,code,now,now,1]
            else:
                if batch is not None:
                    out.append(['repeat']+batch)
                    batch=batch
                out.append(['raw',kind,device,code,now])
        if batch is not None: out.append(['repeat']+batch)
        return out
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat-coalescing scenario 0', solve([[]] * N), [[]] * N)
check('repeat-coalescing scenario 1', solve([[['down', 'a', 'A', 10, False]]] * N), [[['raw', 'down', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 2', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 12, 2]]] * N)
check('repeat-coalescing scenario 3', solve([[['down', 'a', 'A', 10, True], ['down', 'b', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'b', 'A', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 4', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'B', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'a', 'B', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 5', solve([[['down', 'a', 'A', 10, True], ['up', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]] * N)
check('repeat-coalescing scenario 6', solve([[['up', 'a', 'A', 10, True]]] * N), [[['raw', 'up', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 7', solve([[['down', 'a', 'A', 10, True], ['text', 'a', 'A', 12, False]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]] * N)
check('repeat-coalescing scenario 8', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 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)

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):
        out=[]; batch=None
        for kind,device,code,now,repeat in c:
            eligible=kind=='down' and repeat
            if eligible:
                if batch is not None and batch[0]==device and batch[1]==code:
                    batch[3]=now
                    batch[4]+=1
                else:
                    if batch is not None: out.append(['repeat']+batch)
                    batch=[device,code,now,now,1]
            else:
                if batch is not None:
                    out.append(['repeat']+batch)
                    batch[4]=0
                out.append(['raw',kind,device,code,now])
        if batch is not None: out.append(['repeat']+batch)
        return out
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat-coalescing scenario 0', solve([[]] * N), [[]] * N)
check('repeat-coalescing scenario 1', solve([[['down', 'a', 'A', 10, False]]] * N), [[['raw', 'down', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 2', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 12, 2]]] * N)
check('repeat-coalescing scenario 3', solve([[['down', 'a', 'A', 10, True], ['down', 'b', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'b', 'A', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 4', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'B', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'a', 'B', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 5', solve([[['down', 'a', 'A', 10, True], ['up', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]] * N)
check('repeat-coalescing scenario 6', solve([[['up', 'a', 'A', 10, True]]] * N), [[['raw', 'up', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 7', solve([[['down', 'a', 'A', 10, True], ['text', 'a', 'A', 12, False]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]] * N)
check('repeat-coalescing scenario 8', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 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 barrier reset rule and produces incorrect keyboard state or command output.

Events [kind,device,code,time,repeat]. Consecutive repeated down events for the same device/code coalesce into [device,code,first,last,count]; any nonrepeat or non-down event flushes the batch and is emitted as a raw event. A repeated down for a different token flushes and starts another. Return ordered entries tagged repeat or raw. 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):
        out=[]; batch=None
        for kind,device,code,now,repeat in c:
            eligible=kind=='down' and repeat
            if eligible:
                if batch is not None and batch[0]==device and batch[1]==code:
                    batch[3]=now
                    batch[4]+=1
                else:
                    if batch is not None: out.append(['repeat']+batch)
                    batch=[device,code,now,now,1]
            else:
                if batch is not None:
                    out.append(['repeat']+batch)
                    batch=None
                out.append(['raw',kind,code,device,now])
        if batch is not None: out.append(['repeat']+batch)
        return out
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat-coalescing scenario 0', solve([[]] * N), [[]] * N)
check('repeat-coalescing scenario 1', solve([[['down', 'a', 'A', 10, False]]] * N), [[['raw', 'down', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 2', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 12, 2]]] * N)
check('repeat-coalescing scenario 3', solve([[['down', 'a', 'A', 10, True], ['down', 'b', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'b', 'A', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 4', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'B', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'a', 'B', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 5', solve([[['down', 'a', 'A', 10, True], ['up', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]] * N)
check('repeat-coalescing scenario 6', solve([[['up', 'a', 'A', 10, True]]] * N), [[['raw', 'up', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 7', solve([[['down', 'a', 'A', 10, True], ['text', 'a', 'A', 12, False]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]] * N)
check('repeat-coalescing scenario 8', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 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):
        out=[]; batch=None
        for kind,device,code,now,repeat in c:
            eligible=kind=='down' and repeat
            if eligible:
                if batch is not None and batch[0]==device and batch[1]==code:
                    batch[3]=now
                    batch[4]+=1
                else:
                    if batch is not None: out.append(['repeat']+batch)
                    batch=[device,code,now,now,1]
            else:
                if batch is not None:
                    out.append(['repeat']+batch)
                    batch=None
                out.append(['raw',kind,device,code,0])
        if batch is not None: out.append(['repeat']+batch)
        return out
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat-coalescing scenario 0', solve([[]] * N), [[]] * N)
check('repeat-coalescing scenario 1', solve([[['down', 'a', 'A', 10, False]]] * N), [[['raw', 'down', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 2', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 12, 2]]] * N)
check('repeat-coalescing scenario 3', solve([[['down', 'a', 'A', 10, True], ['down', 'b', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'b', 'A', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 4', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'B', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'a', 'B', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 5', solve([[['down', 'a', 'A', 10, True], ['up', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]] * N)
check('repeat-coalescing scenario 6', solve([[['up', 'a', 'A', 10, True]]] * N), [[['raw', 'up', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 7', solve([[['down', 'a', 'A', 10, True], ['text', 'a', 'A', 12, False]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]] * N)
check('repeat-coalescing scenario 8', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 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 raw payload rule and produces incorrect keyboard state or command output.

Events [kind,device,code,time,repeat]. Consecutive repeated down events for the same device/code coalesce into [device,code,first,last,count]; any nonrepeat or non-down event flushes the batch and is emitted as a raw event. A repeated down for a different token flushes and starts another. Return ordered entries tagged repeat or raw. 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):
        out=[]; batch=None
        for kind,device,code,now,repeat in c:
            eligible=kind=='down' and repeat
            if eligible:
                if batch is not None and batch[0]==device and batch[1]==code:
                    batch[3]=now
                    batch[4]+=1
                else:
                    if batch is not None: out.append(['repeat']+batch)
                    batch=[device,code,now,now,1]
            else:
                if batch is not None:
                    out.append(['repeat']+batch)
                    batch=None
                out.append(['raw',kind,device,code,now])
        if batch is not None: pass
        return out
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat-coalescing scenario 0', solve([[]] * N), [[]] * N)
check('repeat-coalescing scenario 1', solve([[['down', 'a', 'A', 10, False]]] * N), [[['raw', 'down', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 2', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 12, 2]]] * N)
check('repeat-coalescing scenario 3', solve([[['down', 'a', 'A', 10, True], ['down', 'b', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'b', 'A', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 4', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'B', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'a', 'B', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 5', solve([[['down', 'a', 'A', 10, True], ['up', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]] * N)
check('repeat-coalescing scenario 6', solve([[['up', 'a', 'A', 10, True]]] * N), [[['raw', 'up', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 7', solve([[['down', 'a', 'A', 10, True], ['text', 'a', 'A', 12, False]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]] * N)
check('repeat-coalescing scenario 8', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 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):
        out=[]; batch=None
        for kind,device,code,now,repeat in c:
            eligible=kind=='down' and repeat
            if eligible:
                if batch is not None and batch[0]==device and batch[1]==code:
                    batch[3]=now
                    batch[4]+=1
                else:
                    if batch is not None: out.append(['repeat']+batch)
                    batch=[device,code,now,now,1]
            else:
                if batch is not None:
                    out.append(['repeat']+batch)
                    batch=None
                out.append(['raw',kind,device,code,now])
        if batch is not None: out.append(['raw']+batch)
        return out
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat-coalescing scenario 0', solve([[]] * N), [[]] * N)
check('repeat-coalescing scenario 1', solve([[['down', 'a', 'A', 10, False]]] * N), [[['raw', 'down', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 2', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 12, 2]]] * N)
check('repeat-coalescing scenario 3', solve([[['down', 'a', 'A', 10, True], ['down', 'b', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'b', 'A', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 4', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'B', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'a', 'B', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 5', solve([[['down', 'a', 'A', 10, True], ['up', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]] * N)
check('repeat-coalescing scenario 6', solve([[['up', 'a', 'A', 10, True]]] * N), [[['raw', 'up', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 7', solve([[['down', 'a', 'A', 10, True], ['text', 'a', 'A', 12, False]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]] * N)
check('repeat-coalescing scenario 8', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 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 final flush rule and produces incorrect keyboard state or command output.

Events [kind,device,code,time,repeat]. Consecutive repeated down events for the same device/code coalesce into [device,code,first,last,count]; any nonrepeat or non-down event flushes the batch and is emitted as a raw event. A repeated down for a different token flushes and starts another. Return ordered entries tagged repeat or raw. 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping.setdefault(key,value)
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=key
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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 future map rule and produces incorrect keyboard state or command output.

Events [kind,key,value]. Map replaces future press mapping; None disables output. Down captures current mapping once per physical key. Several physical keys mapping to one logical key share a reference count: emit logical down at 0->1 and up at 1->0. Release uses captured mapping even after remap. Reset emits sorted ups for all logical held keys and clears presses. Return events, captured physical map and logical counts. 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down':
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in counts:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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 repeat reference rule and produces incorrect keyboard state or command output.

Events [kind,key,value]. Map replaces future press mapping; None disables output. Down captures current mapping once per physical key. Several physical keys mapping to one logical key share a reference count: emit logical down at 0->1 and up at 1->0. Release uses captured mapping even after remap. Reset emits sorted ups for all logical held keys and clears presses. Return events, captured physical map and logical counts. 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,None)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,value)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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 unmapped identity rule and produces incorrect keyboard state or command output.

Events [kind,key,value]. Map replaces future press mapping; None disables output. Down captures current mapping once per physical key. Several physical keys mapping to one logical key share a reference count: emit logical down at 0->1 and up at 1->0. Release uses captured mapping even after remap. Reset emits sorted ups for all logical held keys and clears presses. Return events, captured physical map and logical counts. 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=key
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=value
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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 captured target rule and produces incorrect keyboard state or command output.

Events [kind,key,value]. Map replaces future press mapping; None disables output. Down captures current mapping once per physical key. Several physical keys mapping to one logical key share a reference count: emit logical down at 0->1 and up at 1->0. Release uses captured mapping even after remap. Reset emits sorted ups for all logical held keys and clears presses. Return events, captured physical map and logical counts. 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if True:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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 disabled target rule and produces incorrect keyboard state or command output.

Events [kind,key,value]. Map replaces future press mapping; None disables output. Down captures current mapping once per physical key. Several physical keys mapping to one logical key share a reference count: emit logical down at 0->1 and up at 1->0. Release uses captured mapping even after remap. Reset emits sorted ups for all logical held keys and clears presses. Return events, captured physical map and logical counts. 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+2
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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 logical increment rule and produces incorrect keyboard state or command output.

Events [kind,key,value]. Map replaces future press mapping; None disables output. Down captures current mapping once per physical key. Several physical keys mapping to one logical key share a reference count: emit logical down at 0->1 and up at 1->0. Release uses captured mapping even after remap. Reset emits sorted ups for all logical held keys and clears presses. Return events, captured physical map and logical counts. 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if True: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==1: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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 first owner edge rule and produces incorrect keyboard state or command output.

Events [kind,key,value]. Map replaces future press mapping; None disables output. Down captures current mapping once per physical key. Several physical keys mapping to one logical key share a reference count: emit logical down at 0->1 and up at 1->0. Release uses captured mapping even after remap. Reset emits sorted ups for all logical held keys and clears presses. Return events, captured physical map and logical counts. 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=mapping.get(key,key); active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=key; active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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 captured rule and produces incorrect keyboard state or command output.

Events [kind,key,value]. Map replaces future press mapping; None disables output. Down captures current mapping once per physical key. Several physical keys mapping to one logical key share a reference count: emit logical down at 0->1 and up at 1->0. Release uses captured mapping even after remap. Reset emits sorted ups for all logical held keys and clears presses. Return events, captured physical map and logical counts. 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=0
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear(); counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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 logical decrement rule and produces incorrect keyboard state or command output.

Events [kind,key,value]. Map replaces future press mapping; None disables output. Down captures current mapping once per physical key. Several physical keys mapping to one logical key share a reference count: emit logical down at 0->1 and up at 1->0. Release uses captured mapping even after remap. Reset emits sorted ups for all logical held keys and clears presses. Return events, captured physical map and logical counts. 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                active.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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):
        mapping={}; active={}; counts={}; out=[]
        for kind,key,value in c:
            if kind=='map': mapping[key]=value
            elif kind=='down' and key not in active:
                logical=mapping.get(key,key)
                active[key]=logical
                if logical is not None:
                    count=counts.get(logical,0)
                    counts[logical]=count+1
                    if count==0: out.append(['down',logical])
            elif kind=='up' and key in active:
                logical=active.pop(key)
                if logical is not None:
                    counts[logical]=counts.get(logical,0)-1
                    if counts[logical]==0:
                        out.append(['up',logical])
                        counts.pop(logical,None)
            elif kind=='reset':
                for logical in sorted(counts): out.append(['up',logical])
                counts.clear()
        return [out,sorted([[k,v] for k,v in active.items()]),sorted([[k,v] for k,v in counts.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-release-ownership scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('remap-release-ownership scenario 1', solve([[['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'A'], ['up', 'A']], [], []]] * N)
check('remap-release-ownership scenario 2', solve([[['map', 'A', 'X'], ['map', 'A', 'Y'], ['down', 'A', None]]] * N), [[[['down', 'Y']], [['A', 'Y']], [['Y', 1]]]] * N)
check('remap-release-ownership scenario 3', solve([[['map', 'A', 'X'], ['down', 'A', None], ['map', 'A', 'Y'], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 4', solve([[['map', 'A', 'X'], ['map', 'B', 'X'], ['down', 'A', None], ['down', 'B', None], ['up', 'A', None]]] * N), [[[['down', 'X']], [['B', 'X']], [['X', 1]]]] * N)
check('remap-release-ownership scenario 5', solve([[['map', 'A', 'X'], ['down', 'A', None], ['down', 'A', None], ['up', 'A', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * N)
check('remap-release-ownership scenario 6', solve([[['map', 'A', None], ['down', 'A', None]]] * N), [[[], [['A', None]], []]] * N)
check('remap-release-ownership scenario 7', solve([[['map', 'A', ''], ['down', 'A', None]]] * N), [[[['down', '']], [['A', '']], [['', 1]]]] * N)
check('remap-release-ownership scenario 8', solve([[['map', 'A', 'X'], ['down', 'A', None], ['reset', '', None]]] * N), [[[['down', 'X'], ['up', 'X']], [], []]] * 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 reset ownership rule and produces incorrect keyboard state or command output.

Events [kind,key,value]. Map replaces future press mapping; None disables output. Down captures current mapping once per physical key. Several physical keys mapping to one logical key share a reference count: emit logical down at 0->1 and up at 1->0. Release uses captured mapping even after remap. Reset emits sorted ups for all logical held keys and clears presses. Return events, captured physical map and logical counts. 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is not None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], 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 dual repeat rule and produces incorrect keyboard state or command output.

Case [dual,tap,modifier,threshold,events]. Events [kind,key,time]. Dual down arms tap; repeated dual downs ignored. A foreign down or threshold tick promotes pending dual into modifier down before forwarding foreign down. Dual up emits tap when pending, modifier up when promoted. Cancel releases a promoted modifier and cancels pending tap. Foreign up is forwarded. Return emitted [phase,key] and pending [start,promoted] or None. 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