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

N = 1
observations = []
def solve(cases):
    def run(c):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now-start>threshold:
                        output.append(['hold',k])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now>=threshold:
                        output.append(['hold',k])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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 tick threshold rule and produces incorrect keyboard state or command output.

Case [threshold,events]. Events [kind,key,time]. Down arms an unarmed key. Tick emits hold once when age >= threshold. Up before threshold emits tap, at or after threshold emits hold if not yet emitted. Cancel removes just one key silently. Return output and pending [key,start,held] entries. 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if now-start>=threshold:
                        output.append(['hold',k])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if (not sent or now>start) and now-start>=threshold:
                        output.append(['hold',k])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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 single hold rule and produces incorrect keyboard state or command output.

Case [threshold,events]. Events [kind,key,time]. Down arms an unarmed key. Tick emits hold once when age >= threshold. Up before threshold emits tap, at or after threshold emits hold if not yet emitted. Cancel removes just one key silently. Return output and pending [key,start,held] entries. 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now-start>=threshold:
                        output.append(['tap',k])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now-start>=threshold:
                        output.append(['hold',key])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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 hold kind rule and produces incorrect keyboard state or command output.

Case [threshold,events]. Events [kind,key,time]. Down arms an unarmed key. Tick emits hold once when age >= threshold. Up before threshold emits tap, at or after threshold emits hold if not yet emitted. Cancel removes just one key silently. Return output and pending [key,start,held] entries. 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now-start>=threshold:
                        output.append(['hold',k])
                        pending[k][1]=False
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now-start>=threshold:
                        output.append(['hold',k])
                        pending[k][0]=now
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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 mark emitted rule and produces incorrect keyboard state or command output.

Case [threshold,events]. Events [kind,key,time]. Down arms an unarmed key. Tick emits hold once when age >= threshold. Up before threshold emits tap, at or after threshold emits hold if not yet emitted. Cancel removes just one key silently. Return output and pending [key,start,held] entries. 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now-start>=threshold:
                        output.append(['hold',k])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if True:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now-start>=threshold:
                        output.append(['hold',k])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if sent:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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 up after hold rule and produces incorrect keyboard state or command output.

Case [threshold,events]. Events [kind,key,time]. Down arms an unarmed key. Tick emits hold once when age >= threshold. Up before threshold emits tap, at or after threshold emits hold if not yet emitted. Cancel removes just one key silently. Return output and pending [key,start,held] entries. 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now-start>=threshold:
                        output.append(['hold',k])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now-start>threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now-start>=threshold:
                        output.append(['hold',k])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now>=threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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 up threshold rule and produces incorrect keyboard state or command output.

Case [threshold,events]. Events [kind,key,time]. Down arms an unarmed key. Tick emits hold once when age >= threshold. Up before threshold emits tap, at or after threshold emits hold if not yet emitted. Cancel removes just one key silently. Return output and pending [key,start,held] entries. 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now-start>=threshold:
                        output.append(['hold',k])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                pending.clear()
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now-start>=threshold:
                        output.append(['hold',k])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                pending[key][1]=True
            elif kind=='cancel':
                pending.pop(key,None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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 disarm rule and produces incorrect keyboard state or command output.

Case [threshold,events]. Events [kind,key,time]. Down arms an unarmed key. Tick emits hold once when age >= threshold. Up before threshold emits tap, at or after threshold emits hold if not yet emitted. Cancel removes just one key silently. Return output and pending [key,start,held] entries. 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now-start>=threshold:
                        output.append(['hold',k])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.clear()
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * 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):
        threshold,events=c
        pending={}; output=[]
        for kind,key,now in events:
            if kind=='down' and key not in pending:
                pending[key]=[now,False]
            elif kind=='tick':
                for k in sorted(pending):
                    start,sent=pending[k]
                    if not sent and now-start>=threshold:
                        output.append(['hold',k])
                        pending[k][1]=True
            elif kind=='up' and key in pending:
                start,sent=pending[key]
                if not sent:
                    output.append(['hold' if now-start>=threshold else 'tap',key])
                del pending[key]
            elif kind=='cancel':
                pending.pop(str(now),None)
        return [output,sorted([[k]+v for k,v in pending.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('hold-threshold scenario 0', solve([[5, []]] * N), [[[], []]] * N)
check('hold-threshold scenario 1', solve([[5, [['down', 'A', 10], ['tick', '', 12]]]] * N), [[[], [['A', 10, False]]]] * N)
check('hold-threshold scenario 2', solve([[5, [['down', 'A', 10], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], []]] * N)
check('hold-threshold scenario 3', solve([[5, [['down', 'A', 10], ['up', 'A', 15]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 4', solve([[5, [['down', 'A', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'A', 17]]]] * N), [[[['hold', 'A']], []]] * N)
check('hold-threshold scenario 5', solve([[5, [['down', 'A', 10], ['down', 'A', 13], ['tick', '', 15]]]] * N), [[[['hold', 'A']], [['A', 10, True]]]] * N)
check('hold-threshold scenario 6', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['up', 'A', 12]]]] * N), [[[['tap', 'A']], [['B', 11, False]]]] * N)
check('hold-threshold scenario 7', solve([[5, [['down', 'A', 10], ['down', 'B', 11], ['cancel', 'A', 12], ['tick', '', 16]]]] * N), [[[['hold', 'B']], [['B', 11, True]]]] * N)
check('hold-threshold scenario 8', solve([[5, [['up', 'A', 100]]]] * N), [[[], []]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Case [threshold,events]. Events [kind,key,time]. Down arms an unarmed key. Tick emits hold once when age >= threshold. Up before threshold emits tap, at or after threshold emits hold if not yet emitted. Cancel removes just one key silently. Return output and pending [key,start,held] entries. 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.symmetric_difference_update({key})
            elif kind=='up' and key in held:
                held.discard(key)
                taps+=1
                previous=last.get(key)
                if previous is not None and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held={key}
            elif kind=='up' and key in held:
                held.discard(key)
                taps+=1
                previous=last.get(key)
                if previous is not None and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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 repeat down rule and produces incorrect keyboard state or command output.

Case [window,events] with nondecreasing timestamps and events [kind,key,time]. Down repeats do not count. A matched up produces tap and may complete a double if the prior release of the same key is within the inclusive window. Completing a double consumes that prior release. Cancel clears that key, blur clears all state. Return doubles [key,time], held keys and remembered release times. 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up':
                held.discard(key)
                taps+=1
                previous=last.get(key)
                if previous is not None and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and bool(held):
                held.discard(key)
                taps+=1
                previous=last.get(key)
                if previous is not None and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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 matched release rule and produces incorrect keyboard state or command output.

Case [window,events] with nondecreasing timestamps and events [kind,key,time]. Down repeats do not count. A matched up produces tap and may complete a double if the prior release of the same key is within the inclusive window. Completing a double consumes that prior release. Cancel clears that key, blur clears all state. Return doubles [key,time], held keys and remembered release times. 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                pass
                taps+=1
                previous=last.get(key)
                if previous is not None and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                held.clear()
                taps+=1
                previous=last.get(key)
                if previous is not None and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Case [window,events] with nondecreasing timestamps and events [kind,key,time]. Down repeats do not count. A matched up produces tap and may complete a double if the prior release of the same key is within the inclusive window. Completing a double consumes that prior release. Cancel clears that key, blur clears all state. Return doubles [key,time], held keys and remembered release times. 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                held.discard(key)
                taps=1
                previous=last.get(key)
                if previous is not None and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                held.discard(key)
                taps+=len(held)
                previous=last.get(key)
                if previous is not None and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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 tap count rule and produces incorrect keyboard state or command output.

Case [window,events] with nondecreasing timestamps and events [kind,key,time]. Down repeats do not count. A matched up produces tap and may complete a double if the prior release of the same key is within the inclusive window. Completing a double consumes that prior release. Cancel clears that key, blur clears all state. Return doubles [key,time], held keys and remembered release times. 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                held.discard(key)
                taps+=1
                previous=next(iter(last.values()),None)
                if previous is not None and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                held.discard(key)
                taps+=1
                previous=max(last.values(),default=None)
                if previous is not None and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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 per key history rule and produces incorrect keyboard state or command output.

Case [window,events] with nondecreasing timestamps and events [kind,key,time]. Down repeats do not count. A matched up produces tap and may complete a double if the prior release of the same key is within the inclusive window. Completing a double consumes that prior release. Cancel clears that key, blur clears all state. Return doubles [key,time], held keys and remembered release times. 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                held.discard(key)
                taps+=1
                previous=last.get(key)
                if previous and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                held.discard(key)
                taps+=1
                previous=last.get(key)
                if previous is not None and previous>0 and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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 zero timestamp rule and produces incorrect keyboard state or command output.

Case [window,events] with nondecreasing timestamps and events [kind,key,time]. Down repeats do not count. A matched up produces tap and may complete a double if the prior release of the same key is within the inclusive window. Completing a double consumes that prior release. Cancel clears that key, blur clears all state. Return doubles [key,time], held keys and remembered release times. 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                held.discard(key)
                taps+=1
                previous=last.get(key)
                if previous is not None and now-previous<window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                held.discard(key)
                taps+=1
                previous=last.get(key)
                if previous is not None and now<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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 inclusive window rule and produces incorrect keyboard state or command output.

Case [window,events] with nondecreasing timestamps and events [kind,key,time]. Down repeats do not count. A matched up produces tap and may complete a double if the prior release of the same key is within the inclusive window. Completing a double consumes that prior release. Cancel clears that key, blur clears all state. Return doubles [key,time], held keys and remembered release times. 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                held.discard(key)
                taps+=1
                previous=last.get(key)
                if previous is not None and now-previous<=window:
                    doubles.append([key,now])
                    last[key]=now
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                held.discard(key)
                taps+=1
                previous=last.get(key)
                if previous is not None and now-previous<=window:
                    doubles.append([key,now])
                    last.clear()
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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 consume pair rule and produces incorrect keyboard state or command output.

Case [window,events] with nondecreasing timestamps and events [kind,key,time]. Down repeats do not count. A matched up produces tap and may complete a double if the prior release of the same key is within the inclusive window. Completing a double consumes that prior release. Cancel clears that key, blur clears all state. Return doubles [key,time], held keys and remembered release times. 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