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

N = 1
observations = []
def solve(cases):
    def run(c):
        sequence,timeout,events=c
        buffer=[]; last=None; matches=[]
        for kind,key,now,repeat in events:
            if kind=='cancel': buffer=[]; last=None
            elif kind=='tick':
                if last is not None and now-last>timeout: buffer=[]; last=None
            elif kind=='down' and not repeat:
                if last is not None and now-last>timeout: buffer=[]
                candidate=buffer+[key]
                last=now
                buffer=[]
                for size in range(min(len(sequence),len(candidate)),0,-1):
                    if candidate[-size:]==sequence[:size]:
                        buffer=candidate[-size:]
                        break
                if buffer==sequence:
                    matches.append(last-timeout)
                    buffer=[]
                    for size in range(len(sequence)-1,0,-1):
                        if sequence[-size:]==sequence[:size]:
                            buffer=sequence[:size]
                            break
        return [matches,buffer,last]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sequence-prefix scenario 0', solve([[['A', 'B'], 5, []]] * N), [[[], [], None]] * N)
check('sequence-prefix scenario 1', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 15, False]]]] * N), [[[15], [], 15]] * N)
check('sequence-prefix scenario 2', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['tick', '', 15, False]]]] * N), [[[], ['A'], 10]] * N)
check('sequence-prefix scenario 3', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 16, False]]]] * N), [[[], [], 16]] * N)
check('sequence-prefix scenario 4', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 11, True], ['up', 'B', 12, False]]]] * N), [[[], ['A'], 10]] * N)
check('sequence-prefix scenario 5', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['cancel', '', 11, False]]]] * N), [[[], [], None]] * N)
check('sequence-prefix scenario 6', solve([[['A', 'B', 'A'], 5, [['down', 'A', 10, False], ['down', 'B', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False], ['down', 'A', 14, False]]]] * N), [[[12, 14], ['A'], 14]] * N)
check('sequence-prefix scenario 7', solve([[['A', 'B', 'A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False], ['down', 'A', 14, False], ['down', 'B', 15, False]]]] * N), [[[13, 15], ['A', 'B'], 15]] * N)
check('sequence-prefix scenario 8', solve([[['A', 'A', 'B'], 5, [['down', 'A', 10, False], ['down', 'A', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False]]]] * N), [[[13], [], 13]] * N)
check('sequence-prefix scenario 9', solve([[['A', 'B', 'C'], 5, [['down', 'A', 10, False], ['down', 'X', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False], ['down', 'C', 14, False]]]] * N), [[[14], [], 14]] * 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):
        sequence,timeout,events=c
        buffer=[]; last=None; matches=[]
        for kind,key,now,repeat in events:
            if kind=='cancel': buffer=[]; last=None
            elif kind=='tick':
                if last is not None and now-last>timeout: buffer=[]; last=None
            elif kind=='down' and not repeat:
                if last is not None and now-last>timeout: buffer=[]
                candidate=buffer+[key]
                last=now
                buffer=[]
                for size in range(min(len(sequence),len(candidate)),0,-1):
                    if candidate[-size:]==sequence[:size]:
                        buffer=candidate[-size:]
                        break
                if buffer==sequence:
                    matches.append(len(buffer))
                    buffer=[]
                    for size in range(len(sequence)-1,0,-1):
                        if sequence[-size:]==sequence[:size]:
                            buffer=sequence[:size]
                            break
        return [matches,buffer,last]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sequence-prefix scenario 0', solve([[['A', 'B'], 5, []]] * N), [[[], [], None]] * N)
check('sequence-prefix scenario 1', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 15, False]]]] * N), [[[15], [], 15]] * N)
check('sequence-prefix scenario 2', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['tick', '', 15, False]]]] * N), [[[], ['A'], 10]] * N)
check('sequence-prefix scenario 3', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 16, False]]]] * N), [[[], [], 16]] * N)
check('sequence-prefix scenario 4', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 11, True], ['up', 'B', 12, False]]]] * N), [[[], ['A'], 10]] * N)
check('sequence-prefix scenario 5', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['cancel', '', 11, False]]]] * N), [[[], [], None]] * N)
check('sequence-prefix scenario 6', solve([[['A', 'B', 'A'], 5, [['down', 'A', 10, False], ['down', 'B', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False], ['down', 'A', 14, False]]]] * N), [[[12, 14], ['A'], 14]] * N)
check('sequence-prefix scenario 7', solve([[['A', 'B', 'A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False], ['down', 'A', 14, False], ['down', 'B', 15, False]]]] * N), [[[13, 15], ['A', 'B'], 15]] * N)
check('sequence-prefix scenario 8', solve([[['A', 'A', 'B'], 5, [['down', 'A', 10, False], ['down', 'A', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False]]]] * N), [[[13], [], 13]] * N)
check('sequence-prefix scenario 9', solve([[['A', 'B', 'C'], 5, [['down', 'A', 10, False], ['down', 'X', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False], ['down', 'C', 14, False]]]] * N), [[[14], [], 14]] * 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 match clock rule and produces incorrect keyboard state or command output.

Case [sequence,timeout,events]. Nonempty sequence is list of key names. Events [kind,key,time,repeat]. Only nonrepeat down feeds matcher. Accepted downs more than timeout after the previous accepted down discard the prefix; tick likewise expires it. Cancel resets prefix and clock. Keep longest suffix matching a sequence prefix, and after a match retain the longest proper overlapping prefix. Return match timestamps, partial prefix and last accepted time. 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):
        sequence,timeout,events=c
        buffer=[]; last=None; matches=[]
        for kind,key,now,repeat in events:
            if kind=='cancel': buffer=[]; last=None
            elif kind=='tick':
                if last is not None and now-last>timeout: buffer=[]; last=None
            elif kind=='down' and not repeat:
                if last is not None and now-last>timeout: buffer=[]
                candidate=buffer+[key]
                last=now
                buffer=[]
                for size in range(min(len(sequence),len(candidate)),0,-1):
                    if candidate[-size:]==sequence[:size]:
                        buffer=candidate[-size:]
                        break
                if buffer==sequence:
                    matches.append(now)
                    buffer=[]
                    for size in range(len(sequence)-1,0,-1):
                        if sequence[-size:]==sequence[:size]:
                            buffer=[]
                            break
        return [matches,buffer,last]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sequence-prefix scenario 0', solve([[['A', 'B'], 5, []]] * N), [[[], [], None]] * N)
check('sequence-prefix scenario 1', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 15, False]]]] * N), [[[15], [], 15]] * N)
check('sequence-prefix scenario 2', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['tick', '', 15, False]]]] * N), [[[], ['A'], 10]] * N)
check('sequence-prefix scenario 3', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 16, False]]]] * N), [[[], [], 16]] * N)
check('sequence-prefix scenario 4', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 11, True], ['up', 'B', 12, False]]]] * N), [[[], ['A'], 10]] * N)
check('sequence-prefix scenario 5', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['cancel', '', 11, False]]]] * N), [[[], [], None]] * N)
check('sequence-prefix scenario 6', solve([[['A', 'B', 'A'], 5, [['down', 'A', 10, False], ['down', 'B', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False], ['down', 'A', 14, False]]]] * N), [[[12, 14], ['A'], 14]] * N)
check('sequence-prefix scenario 7', solve([[['A', 'B', 'A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False], ['down', 'A', 14, False], ['down', 'B', 15, False]]]] * N), [[[13, 15], ['A', 'B'], 15]] * N)
check('sequence-prefix scenario 8', solve([[['A', 'A', 'B'], 5, [['down', 'A', 10, False], ['down', 'A', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False]]]] * N), [[[13], [], 13]] * N)
check('sequence-prefix scenario 9', solve([[['A', 'B', 'C'], 5, [['down', 'A', 10, False], ['down', 'X', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False], ['down', 'C', 14, False]]]] * N), [[[14], [], 14]] * 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):
        sequence,timeout,events=c
        buffer=[]; last=None; matches=[]
        for kind,key,now,repeat in events:
            if kind=='cancel': buffer=[]; last=None
            elif kind=='tick':
                if last is not None and now-last>timeout: buffer=[]; last=None
            elif kind=='down' and not repeat:
                if last is not None and now-last>timeout: buffer=[]
                candidate=buffer+[key]
                last=now
                buffer=[]
                for size in range(min(len(sequence),len(candidate)),0,-1):
                    if candidate[-size:]==sequence[:size]:
                        buffer=candidate[-size:]
                        break
                if buffer==sequence:
                    matches.append(now)
                    buffer=[]
                    for size in range(len(sequence)-1,0,-1):
                        if sequence[-size:]==sequence[:size]:
                            buffer=sequence[-1:]
                            break
        return [matches,buffer,last]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sequence-prefix scenario 0', solve([[['A', 'B'], 5, []]] * N), [[[], [], None]] * N)
check('sequence-prefix scenario 1', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 15, False]]]] * N), [[[15], [], 15]] * N)
check('sequence-prefix scenario 2', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['tick', '', 15, False]]]] * N), [[[], ['A'], 10]] * N)
check('sequence-prefix scenario 3', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 16, False]]]] * N), [[[], [], 16]] * N)
check('sequence-prefix scenario 4', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 11, True], ['up', 'B', 12, False]]]] * N), [[[], ['A'], 10]] * N)
check('sequence-prefix scenario 5', solve([[['A', 'B'], 5, [['down', 'A', 10, False], ['cancel', '', 11, False]]]] * N), [[[], [], None]] * N)
check('sequence-prefix scenario 6', solve([[['A', 'B', 'A'], 5, [['down', 'A', 10, False], ['down', 'B', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False], ['down', 'A', 14, False]]]] * N), [[[12, 14], ['A'], 14]] * N)
check('sequence-prefix scenario 7', solve([[['A', 'B', 'A', 'B'], 5, [['down', 'A', 10, False], ['down', 'B', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False], ['down', 'A', 14, False], ['down', 'B', 15, False]]]] * N), [[[13, 15], ['A', 'B'], 15]] * N)
check('sequence-prefix scenario 8', solve([[['A', 'A', 'B'], 5, [['down', 'A', 10, False], ['down', 'A', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False]]]] * N), [[[13], [], 13]] * N)
check('sequence-prefix scenario 9', solve([[['A', 'B', 'C'], 5, [['down', 'A', 10, False], ['down', 'X', 11, False], ['down', 'A', 12, False], ['down', 'B', 13, False], ['down', 'C', 14, False]]]] * N), [[[14], [], 14]] * 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 overlap retention rule and produces incorrect keyboard state or command output.

Case [sequence,timeout,events]. Nonempty sequence is list of key names. Events [kind,key,time,repeat]. Only nonrepeat down feeds matcher. Accepted downs more than timeout after the previous accepted down discard the prefix; tick likewise expires it. Cancel resets prefix and clock. Keep longest suffix matching a sequence prefix, and after a match retain the longest proper overlapping prefix. Return match timestamps, partial prefix and last accepted time. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: pass
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(value)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Case [mapping,events], mapping uses accent+character string keys and string replacements; events [kind,value]. Dead event sets pending accent and flushes a previous accent literally. Text with pending accent maps a pair or emits accent then character; space emits only accent. Backspace cancels pending accent, otherwise emits deletion action. Cancel clears accent; flush emits accent then clears. Return output string chunks and pending accent. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=accent or value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=None
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Case [mapping,events], mapping uses accent+character string keys and string replacements; events [kind,value]. Dead event sets pending accent and flushes a previous accent literally. Text with pending accent maps a pair or emits accent then character; space emits only accent. Backspace cancels pending accent, otherwise emits deletion action. Cancel clears accent; flush emits accent then clears. Return output string chunks and pending accent. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.extend(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append("")
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Case [mapping,events], mapping uses accent+character string keys and string replacements; events [kind,value]. Dead event sets pending accent and flushes a previous accent literally. Text with pending accent maps a pair or emits accent then character; space emits only accent. Backspace cancels pending accent, otherwise emits deletion action. Cancel clears accent; flush emits accent then clears. Return output string chunks and pending accent. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent+value)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(value)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Case [mapping,events], mapping uses accent+character string keys and string replacements; events [kind,value]. Dead event sets pending accent and flushes a previous accent literally. Text with pending accent maps a pair or emits accent then character; space emits only accent. Backspace cancels pending accent, otherwise emits deletion action. Cancel clears accent; flush emits accent then clears. Return output string chunks and pending accent. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(value+accent,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Case [mapping,events], mapping uses accent+character string keys and string replacements; events [kind,value]. Dead event sets pending accent and flushes a previous accent literally. Text with pending accent maps a pair or emits accent then character; space emits only accent. Backspace cancels pending accent, otherwise emits deletion action. Cancel clears accent; flush emits accent then clears. Return output string chunks and pending accent. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Case [mapping,events], mapping uses accent+character string keys and string replacements; events [kind,value]. Dead event sets pending accent and flushes a previous accent literally. Text with pending accent maps a pair or emits accent then character; space emits only accent. Backspace cancels pending accent, otherwise emits deletion action. Cancel clears accent; flush emits accent then clears. Return output string chunks and pending accent. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=value
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    pass
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Case [mapping,events], mapping uses accent+character string keys and string replacements; events [kind,value]. Dead event sets pending accent and flushes a previous accent literally. Text with pending accent maps a pair or emits accent then character; space emits only accent. Backspace cancels pending accent, otherwise emits deletion action. Cancel clears accent; flush emits accent then clears. Return output string chunks and pending accent. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: deletes+=1
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=""
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Case [mapping,events], mapping uses accent+character string keys and string replacements; events [kind,value]. Dead event sets pending accent and flushes a previous accent literally. Text with pending accent maps a pair or emits accent then character; space emits only accent. Backspace cancels pending accent, otherwise emits deletion action. Cancel clears accent; flush emits accent then clears. Return output string chunks and pending accent. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=len(output)
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=None
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Case [mapping,events], mapping uses accent+character string keys and string replacements; events [kind,value]. Dead event sets pending accent and flushes a previous accent literally. Text with pending accent maps a pair or emits accent then character; space emits only accent. Backspace cancels pending accent, otherwise emits deletion action. Cancel clears accent; flush emits accent then clears. Return output string chunks and pending accent. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                pass
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        mapping,events=c
        accent=None; output=[]; deletes=0
        for kind,value in events:
            if kind=='dead':
                if accent is not None: output.append(accent)
                accent=value
            elif kind=='text':
                if accent is None: output.append(value)
                else:
                    if value==' ': output.append(accent)
                    else: output.append(mapping.get(accent+value,accent+value))
                    accent=None
            elif kind=='backspace':
                if accent is not None: accent=None
                else: deletes+=1
            elif kind=='cancel': accent=None
            elif kind=='flush' and accent is not None:
                output.append(accent)
                accent=""
        return [output,accent,deletes]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dead-key scenario 0', solve([[{}, []]] * N), [[[], None, 0]] * N)
check('dead-key scenario 1', solve([[{}, [['backspace', ''], ['backspace', '']]]] * N), [[[], None, 2]] * N)
check('dead-key scenario 2', solve([[{}, [['dead', '^'], ['backspace', '']]]] * N), [[[], None, 0]] * N)
check('dead-key scenario 3', solve([[{}, [['text', 'word']]]] * N), [[['word'], None, 0]] * N)
check('dead-key scenario 4', solve([[{'^a': 'â'}, [['dead', '^'], ['text', 'a'], ['text', 'b']]]] * N), [[['â', 'b'], None, 0]] * N)
check('dead-key scenario 5', solve([[{}, [['dead', '^'], ['text', 'z']]]] * N), [[['^z'], None, 0]] * N)
check('dead-key scenario 6', solve([[{}, [['dead', '^'], ['text', ' ']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 7', solve([[{}, [['dead', '^'], ['dead', '~'], ['text', 'a']]]] * N), [[['^', '~a'], None, 0]] * N)
check('dead-key scenario 8', solve([[{}, [['dead', '^'], ['backspace', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
check('dead-key scenario 9', solve([[{}, [['text', 'abc'], ['backspace', ''], ['backspace', '']]]] * N), [[['abc'], None, 2]] * N)
check('dead-key scenario 10', solve([[{}, [['dead', '^'], ['flush', ''], ['flush', '']]]] * N), [[['^'], None, 0]] * N)
check('dead-key scenario 11', solve([[{}, [['dead', '^'], ['cancel', ''], ['text', 'a']]]] * N), [[['a'], None, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Case [mapping,events], mapping uses accent+character string keys and string replacements; events [kind,value]. Dead event sets pending accent and flushes a previous accent literally. Text with pending accent maps a pair or emits accent then character; space emits only accent. Backspace cancels pending accent, otherwise emits deletion action. Cancel clears accent; flush emits accent then clears. Return output string chunks and pending accent. 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):
        recording=False; origin=0; paused=None; excluded=0; records=[]
        for kind,key,now,injected in c:
            if kind=='start':
                recording=True; origin=now; paused=None; excluded=0
            elif kind=='pause' and recording and paused is None:
                paused=now
            elif kind=='resume' and recording and paused is not None:
                excluded+=now-paused
                paused=None
            elif kind=='stop': recording=False; paused=None
            elif kind=='clear': records=[]
            elif kind in ('down','up') and recording and paused is None and not injected:
                records.append([kind,key,now-origin-excluded])
        return [records,recording,paused is not None,excluded]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('macro-record scenario 0', solve([[]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 1', solve([[['start', '', 10, False], ['down', 'A', 12, False], ['up', 'A', 13, False], ['text', 'A', 14, False]]] * N), [[[['down', 'A', 2], ['up', 'A', 3]], True, False, 0]] * N)
check('macro-record scenario 2', solve([[['start', '', 10, False], ['down', 'A', 12, True], ['up', 'A', 13, True]]] * N), [[[], True, False, 0]] * N)
check('macro-record scenario 3', solve([[['start', '', 10, False], ['pause', '', 12, False], ['pause', '', 13, False], ['resume', '', 15, False], ['down', 'A', 16, False]]] * N), [[[['down', 'A', 3]], True, False, 3]] * N)
check('macro-record scenario 4', solve([[['start', '', 10, False], ['pause', '', 12, False], ['resume', '', 15, False], ['pause', '', 17, False], ['resume', '', 20, False], ['down', 'A', 21, False]]] * N), [[[['down', 'A', 5]], True, False, 6]] * N)
check('macro-record scenario 5', solve([[['start', '', 10, False], ['down', 'A', 11, False], ['start', '', 20, False]]] * N), [[[], True, False, 0]] * N)
check('macro-record scenario 6', solve([[['start', '', 10, False], ['pause', '', 12, False], ['resume', '', 15, False], ['start', '', 20, False], ['down', 'A', 21, False]]] * N), [[[['down', 'A', 1]], True, False, 0]] * N)
check('macro-record scenario 7', solve([[['start', '', 10, False], ['pause', '', 12, False], ['stop', '', 15, False], ['down', 'A', 16, False]]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 8', solve([[['pause', '', 10, False]]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 9', solve([[['start', '', 10, False], ['down', 'A', 11, False], ['up', 'A', 12, False], ['clear', '', 13, False]]] * N), [[[], True, False, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        recording=False; origin=0; paused=None; excluded=0; records=[]
        for kind,key,now,injected in c:
            if kind=='start':
                recording=True; origin=now; paused=None; records=[]
            elif kind=='pause' and recording and paused is None:
                paused=now
            elif kind=='resume' and recording and paused is not None:
                excluded+=now-paused
                paused=None
            elif kind=='stop': recording=False; paused=None
            elif kind=='clear': records=[]
            elif kind in ('down','up') and recording and paused is None and not injected:
                records.append([kind,key,now-origin-excluded])
        return [records,recording,paused is not None,excluded]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('macro-record scenario 0', solve([[]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 1', solve([[['start', '', 10, False], ['down', 'A', 12, False], ['up', 'A', 13, False], ['text', 'A', 14, False]]] * N), [[[['down', 'A', 2], ['up', 'A', 3]], True, False, 0]] * N)
check('macro-record scenario 2', solve([[['start', '', 10, False], ['down', 'A', 12, True], ['up', 'A', 13, True]]] * N), [[[], True, False, 0]] * N)
check('macro-record scenario 3', solve([[['start', '', 10, False], ['pause', '', 12, False], ['pause', '', 13, False], ['resume', '', 15, False], ['down', 'A', 16, False]]] * N), [[[['down', 'A', 3]], True, False, 3]] * N)
check('macro-record scenario 4', solve([[['start', '', 10, False], ['pause', '', 12, False], ['resume', '', 15, False], ['pause', '', 17, False], ['resume', '', 20, False], ['down', 'A', 21, False]]] * N), [[[['down', 'A', 5]], True, False, 6]] * N)
check('macro-record scenario 5', solve([[['start', '', 10, False], ['down', 'A', 11, False], ['start', '', 20, False]]] * N), [[[], True, False, 0]] * N)
check('macro-record scenario 6', solve([[['start', '', 10, False], ['pause', '', 12, False], ['resume', '', 15, False], ['start', '', 20, False], ['down', 'A', 21, False]]] * N), [[[['down', 'A', 1]], True, False, 0]] * N)
check('macro-record scenario 7', solve([[['start', '', 10, False], ['pause', '', 12, False], ['stop', '', 15, False], ['down', 'A', 16, False]]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 8', solve([[['pause', '', 10, False]]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 9', solve([[['start', '', 10, False], ['down', 'A', 11, False], ['up', 'A', 12, False], ['clear', '', 13, False]]] * N), [[[], True, False, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Events [kind,key,time,injected]. Start resets capture and origin; physical down/up record relative active time; injected events are ignored. Pause freezes recording and resume excludes paused duration. Stop ends recording; clear erases recording. Return [kind,key,offset] records, recording flag, paused flag and excluded time. Ordered times and paired pause/resume. 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):
        recording=False; origin=0; paused=None; excluded=0; records=[]
        for kind,key,now,injected in c:
            if kind=='start':
                recording=True; origin=now; paused=None; excluded=0; records=[]
            elif kind=='pause' and recording:
                paused=now
            elif kind=='resume' and recording and paused is not None:
                excluded+=now-paused
                paused=None
            elif kind=='stop': recording=False; paused=None
            elif kind=='clear': records=[]
            elif kind in ('down','up') and recording and paused is None and not injected:
                records.append([kind,key,now-origin-excluded])
        return [records,recording,paused is not None,excluded]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('macro-record scenario 0', solve([[]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 1', solve([[['start', '', 10, False], ['down', 'A', 12, False], ['up', 'A', 13, False], ['text', 'A', 14, False]]] * N), [[[['down', 'A', 2], ['up', 'A', 3]], True, False, 0]] * N)
check('macro-record scenario 2', solve([[['start', '', 10, False], ['down', 'A', 12, True], ['up', 'A', 13, True]]] * N), [[[], True, False, 0]] * N)
check('macro-record scenario 3', solve([[['start', '', 10, False], ['pause', '', 12, False], ['pause', '', 13, False], ['resume', '', 15, False], ['down', 'A', 16, False]]] * N), [[[['down', 'A', 3]], True, False, 3]] * N)
check('macro-record scenario 4', solve([[['start', '', 10, False], ['pause', '', 12, False], ['resume', '', 15, False], ['pause', '', 17, False], ['resume', '', 20, False], ['down', 'A', 21, False]]] * N), [[[['down', 'A', 5]], True, False, 6]] * N)
check('macro-record scenario 5', solve([[['start', '', 10, False], ['down', 'A', 11, False], ['start', '', 20, False]]] * N), [[[], True, False, 0]] * N)
check('macro-record scenario 6', solve([[['start', '', 10, False], ['pause', '', 12, False], ['resume', '', 15, False], ['start', '', 20, False], ['down', 'A', 21, False]]] * N), [[[['down', 'A', 1]], True, False, 0]] * N)
check('macro-record scenario 7', solve([[['start', '', 10, False], ['pause', '', 12, False], ['stop', '', 15, False], ['down', 'A', 16, False]]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 8', solve([[['pause', '', 10, False]]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 9', solve([[['start', '', 10, False], ['down', 'A', 11, False], ['up', 'A', 12, False], ['clear', '', 13, False]]] * N), [[[], True, False, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        recording=False; origin=0; paused=None; excluded=0; records=[]
        for kind,key,now,injected in c:
            if kind=='start':
                recording=True; origin=now; paused=None; excluded=0; records=[]
            elif kind=='pause' and paused is None:
                paused=now
            elif kind=='resume' and recording and paused is not None:
                excluded+=now-paused
                paused=None
            elif kind=='stop': recording=False; paused=None
            elif kind=='clear': records=[]
            elif kind in ('down','up') and recording and paused is None and not injected:
                records.append([kind,key,now-origin-excluded])
        return [records,recording,paused is not None,excluded]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('macro-record scenario 0', solve([[]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 1', solve([[['start', '', 10, False], ['down', 'A', 12, False], ['up', 'A', 13, False], ['text', 'A', 14, False]]] * N), [[[['down', 'A', 2], ['up', 'A', 3]], True, False, 0]] * N)
check('macro-record scenario 2', solve([[['start', '', 10, False], ['down', 'A', 12, True], ['up', 'A', 13, True]]] * N), [[[], True, False, 0]] * N)
check('macro-record scenario 3', solve([[['start', '', 10, False], ['pause', '', 12, False], ['pause', '', 13, False], ['resume', '', 15, False], ['down', 'A', 16, False]]] * N), [[[['down', 'A', 3]], True, False, 3]] * N)
check('macro-record scenario 4', solve([[['start', '', 10, False], ['pause', '', 12, False], ['resume', '', 15, False], ['pause', '', 17, False], ['resume', '', 20, False], ['down', 'A', 21, False]]] * N), [[[['down', 'A', 5]], True, False, 6]] * N)
check('macro-record scenario 5', solve([[['start', '', 10, False], ['down', 'A', 11, False], ['start', '', 20, False]]] * N), [[[], True, False, 0]] * N)
check('macro-record scenario 6', solve([[['start', '', 10, False], ['pause', '', 12, False], ['resume', '', 15, False], ['start', '', 20, False], ['down', 'A', 21, False]]] * N), [[[['down', 'A', 1]], True, False, 0]] * N)
check('macro-record scenario 7', solve([[['start', '', 10, False], ['pause', '', 12, False], ['stop', '', 15, False], ['down', 'A', 16, False]]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 8', solve([[['pause', '', 10, False]]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 9', solve([[['start', '', 10, False], ['down', 'A', 11, False], ['up', 'A', 12, False], ['clear', '', 13, False]]] * N), [[[], True, False, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Events [kind,key,time,injected]. Start resets capture and origin; physical down/up record relative active time; injected events are ignored. Pause freezes recording and resume excludes paused duration. Stop ends recording; clear erases recording. Return [kind,key,offset] records, recording flag, paused flag and excluded time. Ordered times and paired pause/resume. 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):
        recording=False; origin=0; paused=None; excluded=0; records=[]
        for kind,key,now,injected in c:
            if kind=='start':
                recording=True; origin=now; paused=None; excluded=0; records=[]
            elif kind=='pause' and recording and paused is None:
                paused=origin
            elif kind=='resume' and recording and paused is not None:
                excluded+=now-paused
                paused=None
            elif kind=='stop': recording=False; paused=None
            elif kind=='clear': records=[]
            elif kind in ('down','up') and recording and paused is None and not injected:
                records.append([kind,key,now-origin-excluded])
        return [records,recording,paused is not None,excluded]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('macro-record scenario 0', solve([[]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 1', solve([[['start', '', 10, False], ['down', 'A', 12, False], ['up', 'A', 13, False], ['text', 'A', 14, False]]] * N), [[[['down', 'A', 2], ['up', 'A', 3]], True, False, 0]] * N)
check('macro-record scenario 2', solve([[['start', '', 10, False], ['down', 'A', 12, True], ['up', 'A', 13, True]]] * N), [[[], True, False, 0]] * N)
check('macro-record scenario 3', solve([[['start', '', 10, False], ['pause', '', 12, False], ['pause', '', 13, False], ['resume', '', 15, False], ['down', 'A', 16, False]]] * N), [[[['down', 'A', 3]], True, False, 3]] * N)
check('macro-record scenario 4', solve([[['start', '', 10, False], ['pause', '', 12, False], ['resume', '', 15, False], ['pause', '', 17, False], ['resume', '', 20, False], ['down', 'A', 21, False]]] * N), [[[['down', 'A', 5]], True, False, 6]] * N)
check('macro-record scenario 5', solve([[['start', '', 10, False], ['down', 'A', 11, False], ['start', '', 20, False]]] * N), [[[], True, False, 0]] * N)
check('macro-record scenario 6', solve([[['start', '', 10, False], ['pause', '', 12, False], ['resume', '', 15, False], ['start', '', 20, False], ['down', 'A', 21, False]]] * N), [[[['down', 'A', 1]], True, False, 0]] * N)
check('macro-record scenario 7', solve([[['start', '', 10, False], ['pause', '', 12, False], ['stop', '', 15, False], ['down', 'A', 16, False]]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 8', solve([[['pause', '', 10, False]]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 9', solve([[['start', '', 10, False], ['down', 'A', 11, False], ['up', 'A', 12, False], ['clear', '', 13, False]]] * N), [[[], True, False, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        recording=False; origin=0; paused=None; excluded=0; records=[]
        for kind,key,now,injected in c:
            if kind=='start':
                recording=True; origin=now; paused=None; excluded=0; records=[]
            elif kind=='pause' and recording and paused is None:
                paused=0
            elif kind=='resume' and recording and paused is not None:
                excluded+=now-paused
                paused=None
            elif kind=='stop': recording=False; paused=None
            elif kind=='clear': records=[]
            elif kind in ('down','up') and recording and paused is None and not injected:
                records.append([kind,key,now-origin-excluded])
        return [records,recording,paused is not None,excluded]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('macro-record scenario 0', solve([[]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 1', solve([[['start', '', 10, False], ['down', 'A', 12, False], ['up', 'A', 13, False], ['text', 'A', 14, False]]] * N), [[[['down', 'A', 2], ['up', 'A', 3]], True, False, 0]] * N)
check('macro-record scenario 2', solve([[['start', '', 10, False], ['down', 'A', 12, True], ['up', 'A', 13, True]]] * N), [[[], True, False, 0]] * N)
check('macro-record scenario 3', solve([[['start', '', 10, False], ['pause', '', 12, False], ['pause', '', 13, False], ['resume', '', 15, False], ['down', 'A', 16, False]]] * N), [[[['down', 'A', 3]], True, False, 3]] * N)
check('macro-record scenario 4', solve([[['start', '', 10, False], ['pause', '', 12, False], ['resume', '', 15, False], ['pause', '', 17, False], ['resume', '', 20, False], ['down', 'A', 21, False]]] * N), [[[['down', 'A', 5]], True, False, 6]] * N)
check('macro-record scenario 5', solve([[['start', '', 10, False], ['down', 'A', 11, False], ['start', '', 20, False]]] * N), [[[], True, False, 0]] * N)
check('macro-record scenario 6', solve([[['start', '', 10, False], ['pause', '', 12, False], ['resume', '', 15, False], ['start', '', 20, False], ['down', 'A', 21, False]]] * N), [[[['down', 'A', 1]], True, False, 0]] * N)
check('macro-record scenario 7', solve([[['start', '', 10, False], ['pause', '', 12, False], ['stop', '', 15, False], ['down', 'A', 16, False]]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 8', solve([[['pause', '', 10, False]]] * N), [[[], False, False, 0]] * N)
check('macro-record scenario 9', solve([[['start', '', 10, False], ['down', 'A', 11, False], ['up', 'A', 12, False], ['clear', '', 13, False]]] * N), [[[], True, False, 0]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Events [kind,key,time,injected]. Start resets capture and origin; physical down/up record relative active time; injected events are ignored. Pause freezes recording and resume excludes paused duration. Stop ends recording; clear erases recording. Return [kind,key,offset] records, recording flag, paused flag and excluded time. Ordered times and paired pause/resume. 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