broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import codecs
N = 1
observations = []
def solve(chunks):
    return ''.join(chunk.decode('utf-8', errors='replace') for chunk in chunks)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
prefix = 'x' * N
check('two-byte sequence split', solve([prefix.encode() + b'\xc3', b'\xa9']), prefix + 'é')
check('four-byte sequence split into single bytes', solve([b'\xf0', b'\x9f', b'\x99', b'\x82'] * N), '🙂' * N)
check('ASCII stream', solve([b'a' * N, b'b']), 'a' * N + 'b')
check('empty chunks within a sequence', solve([b'\xc3', b'', b'\xa9', b'']), 'é')
check('incomplete final sequence rejected', solve([prefix.encode(), b'\xe7\x95']), None)
check('invalid continuation rejected', solve([b'\xc3', b'x']), None)
check('no chunks', solve([]), '')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import codecs
N = 1
observations = []
def solve(chunks):
    return ''.join(chunk.decode('utf-8', errors='ignore') for chunk in chunks)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
prefix = 'x' * N
check('two-byte sequence split', solve([prefix.encode() + b'\xc3', b'\xa9']), prefix + 'é')
check('four-byte sequence split into single bytes', solve([b'\xf0', b'\x9f', b'\x99', b'\x82'] * N), '🙂' * N)
check('ASCII stream', solve([b'a' * N, b'b']), 'a' * N + 'b')
check('empty chunks within a sequence', solve([b'\xc3', b'', b'\xa9', b'']), 'é')
check('incomplete final sequence rejected', solve([prefix.encode(), b'\xe7\x95']), None)
check('invalid continuation rejected', solve([b'\xc3', b'x']), None)
check('no chunks', solve([]), '')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A valid character split across chunks becomes replacement characters or vanishes.

Decode a list of byte chunks as one strict UTF-8 stream. Return the decoded string, or None for malformed or incomplete input. Empty chunks have no semantic effect.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from urllib.parse import parse_qs, parse_qsl
N = 1
observations = []
def solve(query):
    return [[key, values[-1]] for key, values in parse_qs(query, keep_blank_values=True).items()]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interleaved duplicate keys', solve('a=' + str(N) + '&b=x&a=last'), [['a', str(N)], ['b', 'x'], ['a', 'last']])
check('blank and missing value', solve('a=&b'), [['a', ''], ['b', '']])
check('empty parameter name', solve('=' + str(N)), [['', str(N)]])
check('encoded separators are data', solve('x=a%26b%3Dc'), [['x', 'a&b=c']])
check('plus and encoded plus differ', solve('x=a+b&x=a%2Bb'), [['x', 'a b'], ['x', 'a+b']])
check('repeated identical parameter', solve('&'.join(['k=v'] * (N + 1))), [['k', 'v']] * (N + 1))
check('empty query', solve(''), [])
check('separator-only segments ignored', solve('&&a=1&&'), [['a', '1']])
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
from urllib.parse import parse_qs, parse_qsl
N = 1
observations = []
def solve(query):
    return [[key, value] for key, values in parse_qs(query).items() for value in values]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interleaved duplicate keys', solve('a=' + str(N) + '&b=x&a=last'), [['a', str(N)], ['b', 'x'], ['a', 'last']])
check('blank and missing value', solve('a=&b'), [['a', ''], ['b', '']])
check('empty parameter name', solve('=' + str(N)), [['', str(N)]])
check('encoded separators are data', solve('x=a%26b%3Dc'), [['x', 'a&b=c']])
check('plus and encoded plus differ', solve('x=a+b&x=a%2Bb'), [['x', 'a b'], ['x', 'a+b']])
check('repeated identical parameter', solve('&'.join(['k=v'] * (N + 1))), [['k', 'v']] * (N + 1))
check('empty query', solve(''), [])
check('separator-only segments ignored', solve('&&a=1&&'), [['a', '1']])
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:
Repeated parameters disappear or move past parameters that originally separated them.

Parse an application/x-www-form-urlencoded query into ordered [key, value] pairs. Preserve repeated keys, empty keys, and empty values; ignore empty separator-only segments.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import csv
import io
N = 1
observations = []
def solve(text):
    return [line.split(',') for line in text.splitlines()]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
value = 'row' * N
check('embedded LF preserved', solve('"' + value + '\nnext",z\r\n'), [[value + '\nnext', 'z']])
check('embedded CRLF preserved', solve('"a\r\nb",' + str(N) + '\r\n'), [['a\r\nb', str(N)]])
check('quoted comma is field content', solve('"a,b",c\n'), [['a,b', 'c']])
check('doubled quote decoded', solve('"a""b",c\n'), [['a"b', 'c']])
check('trailing empty field', solve(value + ',\n'), [[value, '']])
check('blank records stay blank records', solve('\n' + value + '\n'), [[], [value]])
check('empty input', solve(''), [])
check('unterminated quoted field rejected', solve('"open,' + value), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import csv
import io
N = 1
observations = []
def solve(text):
    try:
        return list(csv.reader(text.splitlines(), strict=True))
    except csv.Error:
        return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
value = 'row' * N
check('embedded LF preserved', solve('"' + value + '\nnext",z\r\n'), [[value + '\nnext', 'z']])
check('embedded CRLF preserved', solve('"a\r\nb",' + str(N) + '\r\n'), [['a\r\nb', str(N)]])
check('quoted comma is field content', solve('"a,b",c\n'), [['a,b', 'c']])
check('doubled quote decoded', solve('"a""b",c\n'), [['a"b', 'c']])
check('trailing empty field', solve(value + ',\n'), [[value, '']])
check('blank records stay blank records', solve('\n' + value + '\n'), [[], [value]])
check('empty input', solve(''), [])
check('unterminated quoted field rejected', solve('"open,' + value), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A quoted multiline field is either split into records or silently concatenated without its newline.

Read comma-delimited CSV using double-quote escaping and strict parser mode. Preserve embedded CR/LF characters within quoted fields, empty fields, and blank records; return None for parser errors.

split: open-access


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

N = 1
observations = []
def solve(data):
    try:
        return data.decode('utf-8')
    except UnicodeDecodeError:
        return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
bom = b'\xef\xbb\xbf'
text = 'part' * N
check('leading BOM removed', solve(bom + text.encode()), text)
check('interior character preserved', solve(text.encode() + bom + b'end'), text + '\ufeffend')
check('only one leading signature consumed', solve(bom + bom + text.encode()), '\ufeff' + text)
check('signature-only input', solve(bom), '')
check('ordinary UTF-8 retained', solve(('é' * N).encode()), 'é' * N)
check('empty input', solve(b''), '')
check('invalid UTF-8 rejected', solve(bom + b'\xff'), None)
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(data):
    try:
        return data.decode('utf-8').replace('\ufeff', '')
    except UnicodeDecodeError:
        return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
bom = b'\xef\xbb\xbf'
text = 'part' * N
check('leading BOM removed', solve(bom + text.encode()), text)
check('interior character preserved', solve(text.encode() + bom + b'end'), text + '\ufeffend')
check('only one leading signature consumed', solve(bom + bom + text.encode()), '\ufeff' + text)
check('signature-only input', solve(bom), '')
check('ordinary UTF-8 retained', solve(('é' * N).encode()), 'é' * N)
check('empty input', solve(b''), '')
check('invalid UTF-8 rejected', solve(bom + b'\xff'), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A leading encoding signature is exposed as text, or cleanup also strips matching interior characters.

Decode UTF-8 bytes, removing at most one EF BB BF signature at the start. Preserve every subsequent U+FEFF character; return None for invalid UTF-8.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(text):
    if not text:
        return []
    fields = text.split('\n')
    return fields[:-1] if text.endswith('\n') else fields
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
label = 'record' * N
check('CRLF is one separator', solve(label + '\r\nend\r\n'), [label, 'end'])
check('lone CR remains a boundary', solve(label + '\rend\r'), [label, 'end'])
check('LF records', solve(label + '\nend\n'), [label, 'end'])
check('mixed blank records', solve(label + '\r\n\r\nend'), [label, '', 'end'])
check('Unicode separator is not a record boundary', solve(label + '\u2028end'), [label + '\u2028end'])
check('empty document', solve(''), [])
check('one empty record', solve('\r'), [''])
check('two terminators preserve one blank record', solve(label + '\n\n'), [label, ''])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(text):
    text = text.replace('\r', '')
    if not text:
        return []
    fields = text.split('\n')
    return fields[:-1] if text.endswith('\n') else fields
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
label = 'record' * N
check('CRLF is one separator', solve(label + '\r\nend\r\n'), [label, 'end'])
check('lone CR remains a boundary', solve(label + '\rend\r'), [label, 'end'])
check('LF records', solve(label + '\nend\n'), [label, 'end'])
check('mixed blank records', solve(label + '\r\n\r\nend'), [label, '', 'end'])
check('Unicode separator is not a record boundary', solve(label + '\u2028end'), [label + '\u2028end'])
check('empty document', solve(''), [])
check('one empty record', solve('\r'), [''])
check('two terminators preserve one blank record', solve(label + '\n\n'), [label, ''])
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:
CRLF input leaves stray carriage returns, while a cleanup step merges records separated by CR alone.

Split records on CRLF, CR, or LF only. Preserve empty records between separators, omit one final terminator-created empty element, and map empty input to []. Unicode line-separator characters are ordinary content.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from urllib.parse import unquote, unquote_plus
N = 1
observations = []
def solve(text):
    try:
        return unquote_plus(text, errors='strict')
    except UnicodeDecodeError:
        return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
label = 'a' * N
check('literal plus retained in path', solve(label + '+b'), label + '+b')
check('encoded slash decoded once', solve(label + '%2Fb'), label + '/b')
check('double-encoded slash remains encoded', solve(label + '%252Fb'), label + '%2Fb')
check('encoded plus becomes literal plus', solve('%2B' * N), '+' * N)
check('UTF-8 encoded character', solve('%C3%A9' * N), 'é' * N)
check('malformed percent token preserved', solve(label + '%QZ%'), label + '%QZ%')
check('invalid UTF-8 rejected', solve('%FF'), None)
check('empty path component', solve(''), '')
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
from urllib.parse import unquote, unquote_plus
N = 1
observations = []
def solve(text):
    try:
        while True:
            decoded = unquote(text, errors='strict')
            if decoded == text:
                return decoded
            text = decoded
    except UnicodeDecodeError:
        return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
label = 'a' * N
check('literal plus retained in path', solve(label + '+b'), label + '+b')
check('encoded slash decoded once', solve(label + '%2Fb'), label + '/b')
check('double-encoded slash remains encoded', solve(label + '%252Fb'), label + '%2Fb')
check('encoded plus becomes literal plus', solve('%2B' * N), '+' * N)
check('UTF-8 encoded character', solve('%C3%A9' * N), 'é' * N)
check('malformed percent token preserved', solve(label + '%QZ%'), label + '%QZ%')
check('invalid UTF-8 rejected', solve('%FF'), None)
check('empty path component', solve(''), '')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A literal plus becomes a space, or a double-encoded slash unexpectedly becomes a path separator.

Decode a URL path component once using UTF-8. Preserve literal plus signs and malformed percent tokens; return None when encoded bytes are invalid UTF-8. Do not normalize paths or separators.

split: open-access


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

N = 1
observations = []
def solve(text):
    return [part.strip() for part in text.split(',')] if text else []
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
nested = '(' * N + 'a,b' + ')' * N
check('nested parentheses', solve(nested + ',tail'), [nested, 'tail'])
check('square brackets', solve('[a,b],tail'), ['[a,b]', 'tail'])
check('mixed nested bracket types', solve('{a,[b,(c,d)]},tail'), ['{a,[b,(c,d)]}', 'tail'])
check('mismatched closer rejected', solve('([a,b)],tail'), None)
check('unclosed nesting rejected', solve('[' * N + 'a,b'), None)
check('unexpected closing bracket rejected', solve('a],tail'), None)
check('whitespace and empty fields', solve(' a , ,b '), ['a', '', 'b'])
check('empty list source', solve(''), [])
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(text):
    if not text:
        return []
    fields, current, depth = [], [], 0
    for char in text:
        depth += (char == '(') - (char == ')')
        if char == ',' and depth == 0:
            fields.append(''.join(current).strip())
            current = []
        else:
            current.append(char)
    return fields + [''.join(current).strip()]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
nested = '(' * N + 'a,b' + ')' * N
check('nested parentheses', solve(nested + ',tail'), [nested, 'tail'])
check('square brackets', solve('[a,b],tail'), ['[a,b]', 'tail'])
check('mixed nested bracket types', solve('{a,[b,(c,d)]},tail'), ['{a,[b,(c,d)]}', 'tail'])
check('mismatched closer rejected', solve('([a,b)],tail'), None)
check('unclosed nesting rejected', solve('[' * N + 'a,b'), None)
check('unexpected closing bracket rejected', solve('a],tail'), None)
check('whitespace and empty fields', solve(' a , ,b '), ['a', '', 'b'])
check('empty list source', solve(''), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A comma inside a nested expression becomes a top-level boundary, or mismatched brackets pass unchecked.

Split a comma-separated expression into trimmed top-level fields using (), [], and {} nesting. Preserve empty fields, return [] for an empty string, and return None for mismatched or unclosed brackets. Quotes and escapes have no special meaning in this restricted grammar.

split: open-access


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

N = 1
observations = []
def solve(value):
    try:
        return json.dumps(value, ensure_ascii=False, separators=(',', ':'), allow_nan=False)
    except (TypeError, ValueError):
        return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('root ordering', solve({'z': N, 'a': 0}), '{"a":0,"z":' + str(N) + '}')
check('nested ordering', solve({'outer': {'z': N, 'a': 0}}), '{"outer":{"a":0,"z":' + str(N) + '}}')
check('objects inside arrays', solve({'items': [{'z': i, 'a': 0} for i in range(N)]}), '{"items":[' + ','.join('{"a":0,"z":' + str(i) + '}' for i in range(N)) + ']}')
check('literal Unicode preserved', solve({'é': '界' * N, 'a': 0}), '{"a":0,"é":"' + '界' * N + '"}')
check('no optional whitespace', solve({'x': [1, True, None]}), '{"x":[1,true,null]}')
check('empty object', solve({}), '{}')
check('nonfinite number rejected', solve({'x': float('nan')}), None)
check('unsupported bytes rejected', solve({'x': b'abc'}), None)
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(value):
    try:
        value = dict(sorted(value.items()))
        return json.dumps(value, ensure_ascii=False, separators=(',', ':'), allow_nan=False)
    except (TypeError, ValueError):
        return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('root ordering', solve({'z': N, 'a': 0}), '{"a":0,"z":' + str(N) + '}')
check('nested ordering', solve({'outer': {'z': N, 'a': 0}}), '{"outer":{"a":0,"z":' + str(N) + '}}')
check('objects inside arrays', solve({'items': [{'z': i, 'a': 0} for i in range(N)]}), '{"items":[' + ','.join('{"a":0,"z":' + str(i) + '}' for i in range(N)) + ']}')
check('literal Unicode preserved', solve({'é': '界' * N, 'a': 0}), '{"a":0,"é":"' + '界' * N + '"}')
check('no optional whitespace', solve({'x': [1, True, None]}), '{"x":[1,true,null]}')
check('empty object', solve({}), '{}')
check('nonfinite number rejected', solve({'x': float('nan')}), None)
check('unsupported bytes rejected', solve({'x': b'abc'}), None)
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:
Equivalent nested objects produce different byte strings depending on insertion order.

Serialize a JSON-compatible object with string keys using Python's JSON representation, recursive key sorting, no optional spaces, literal Unicode, and finite numbers only. Return None for unsupported values. This is a specified deterministic format, not a claim of RFC 8785 conformance.

split: open-access


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

N = 1
observations = []
def solve(data):
    return sum((byte & 0x7f) << (7 * index) for index, byte in enumerate(data))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero uses one byte', solve(b'\x00'), 0)
check('single-byte variant', solve(bytes([N])), N)
check('two-byte variant', solve(bytes([0x80 | N, N])), 129 * N)
check('maximum uint32', solve(b'\xff\xff\xff\xff\x0f'), 4294967295)
check('overflow fifth group rejected', solve(b'\xff\xff\xff\xff' + bytes([15 + N])), None)
check('overlong zero rejected', solve(b'\x80' * N + b'\x00'), None)
check('trailing value rejected', solve(bytes([N, N + 1])), None)
check('unterminated input rejected', solve(b'\x80' * N), None)
check('empty input rejected', solve(b''), None)
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(data):
    value = 0
    for index, byte in enumerate(data[:5]):
        value |= (byte & 0x7f) << (7 * index)
        if byte < 0x80:
            return value
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero uses one byte', solve(b'\x00'), 0)
check('single-byte variant', solve(bytes([N])), N)
check('two-byte variant', solve(bytes([0x80 | N, N])), 129 * N)
check('maximum uint32', solve(b'\xff\xff\xff\xff\x0f'), 4294967295)
check('overflow fifth group rejected', solve(b'\xff\xff\xff\xff' + bytes([15 + N])), None)
check('overlong zero rejected', solve(b'\x80' * N + b'\x00'), None)
check('trailing value rejected', solve(bytes([N, N + 1])), None)
check('unterminated input rejected', solve(b'\x80' * N), None)
check('empty input rejected', solve(b''), None)
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:
Trailing bytes, overlong encodings, and values larger than the specified integer width are accepted.

Decode exactly one minimally encoded unsigned 32-bit LEB128 integer from bytes. Return None for an empty, unterminated, overlong, overflowing, or multi-value input; otherwise return the integer.

split: open-access


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

N = 1
observations = []
def solve(capacity, queue, batch):
    allowed = len(queue) < capacity
    return [list(queue)+list(batch), True] if allowed else [list(queue), False]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
queue = list(range(N))
check('oversize batch is rejected intact', solve(N+1, queue, ['a', 'b']), [queue, False])
check('exact fit admitted', solve(N+2, queue, ['a', 'b']), [queue+['a', 'b'], True])
check('empty batch on full queue', solve(N, queue, []), [queue, True])
check('zero capacity empty batch', solve(0, [], []), [[], True])
check('zero capacity nonempty batch', solve(0, [], [N]), [[], False])
check('oversize from empty', solve(N, [], list(range(N+1))), [[], False])
check('room for small batch', solve(3*N, queue, [N]), [queue+[N], True])
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(capacity, queue, batch):
    return [(list(queue)+list(batch))[:capacity], len(queue) < capacity]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
queue = list(range(N))
check('oversize batch is rejected intact', solve(N+1, queue, ['a', 'b']), [queue, False])
check('exact fit admitted', solve(N+2, queue, ['a', 'b']), [queue+['a', 'b'], True])
check('empty batch on full queue', solve(N, queue, []), [queue, True])
check('zero capacity empty batch', solve(0, [], []), [[], True])
check('zero capacity nonempty batch', solve(0, [], [N]), [[], False])
check('oversize from empty', solve(N, [], list(range(N+1))), [[], False])
check('room for small batch', solve(3*N, queue, [N]), [queue+[N], True])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A queue exceeds capacity or silently drops a suffix after accepting a batch.

Capacity is nonnegative and the initial queue fits. Return [new queue,accepted]. A batch is atomic: all items append in order or none do. An empty batch succeeds even at zero capacity. The check and append are one serialized state transition in this model.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from math import ceil
N = 1
observations = []
def solve(capacity, initial, rate, requests):
    tokens, last, accepted = Fraction(initial), Fraction(0), []
    for timestamp, cost in requests:
        now = Fraction(timestamp)
        refill = int(Fraction(rate)*(now-last))
        tokens = min(Fraction(capacity), tokens + refill)
        last = now
        allowed = tokens >= cost
        if allowed:
            tokens -= cost
        accepted.append(allowed)
    return [accepted, str(tokens)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
rate = 2*N+1
check('fraction survives consumption', solve(rate, 0, rate, [['0.5', N], ['1', N+1]]), [[True, True], '0'])
check('not yet enough for next token', solve(rate, 0, rate, [['0.5', N+1]]), [[False], str(Fraction(rate, 2))])
check('capacity clips idle accrual', solve(N, 0, rate, [['10', 0]]), [[True], str(N)])
check('same instant cannot refill twice', solve(N, N, rate, [['0', N], ['0', 1]]), [[True, False], '0'])
check('oversized cost is rejected', solve(N, N, rate, [['1', N+1]]), [[False], str(N)])
check('zero refill preserves balance', solve(N, N, 0, [['100', N]]), [[True], '0'])
check('no requests preserve initial', solve(N, N, rate, []), [[], str(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
from fractions import Fraction
from math import ceil
N = 1
observations = []
def solve(capacity, initial, rate, requests):
    tokens, last, accepted = Fraction(initial), Fraction(0), []
    for timestamp, cost in requests:
        now = Fraction(timestamp)
        refill = ceil(Fraction(rate)*(now-last))
        tokens = min(Fraction(capacity), tokens + refill)
        last = now
        allowed = tokens >= cost
        if allowed:
            tokens -= cost
        accepted.append(allowed)
    return [accepted, str(tokens)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
rate = 2*N+1
check('fraction survives consumption', solve(rate, 0, rate, [['0.5', N], ['1', N+1]]), [[True, True], '0'])
check('not yet enough for next token', solve(rate, 0, rate, [['0.5', N+1]]), [[False], str(Fraction(rate, 2))])
check('capacity clips idle accrual', solve(N, 0, rate, [['10', 0]]), [[True], str(N)])
check('same instant cannot refill twice', solve(N, N, rate, [['0', N], ['0', 1]]), [[True, False], '0'])
check('oversized cost is rejected', solve(N, N, rate, [['1', N+1]]), [[False], str(N)])
check('zero refill preserves balance', solve(N, N, 0, [['100', N]]), [[True], '0'])
check('no requests preserve initial', solve(N, N, rate, []), [[], str(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 limiter admits too few or too many operations when fractional refills occur between requests.

Capacity and initial balance are nonnegative integers with initial <= capacity; rate is nonnegative. Requests are [nondecreasing rational timestamp string,nonnegative integer cost]. Refill from time zero, cap at capacity, and accept iff sufficient credit exists. Return [acceptance flags,exact rational balance].

split: open-access


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

N = 1
observations = []
def solve(weights, slots):
    eligible = [i for i, w in enumerate(weights) if w > 0]
    return [eligible[i%len(eligible)] for i in range(slots)] if eligible else []
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two to one remains smooth', solve([2*N, N], 3*N), [0, 1, 0]*N)
check('one to three remains smooth', solve([N, 3*N], 4*N), [1, 0, 1, 1]*N)
check('zero-weight lane is excluded', solve([N, 0, N], 2*N), [0, 2]*N)
check('equal weights deterministic', solve([N, N, N], 3*N), [0, 1, 2]*N)
check('one worker', solve([N], N), [0]*N)
check('no capacity', solve([0, 0], N), [])
check('no scheduling slots', solve([N, N+1], 0), [])
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(weights, slots):
    cycle = [i for i, weight in enumerate(weights) for unused in range(weight)]
    return [cycle[i%len(cycle)] for i in range(slots)] if cycle else []
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two to one remains smooth', solve([2*N, N], 3*N), [0, 1, 0]*N)
check('one to three remains smooth', solve([N, 3*N], 4*N), [1, 0, 1, 1]*N)
check('zero-weight lane is excluded', solve([N, 0, N], 2*N), [0, 2]*N)
check('equal weights deterministic', solve([N, N, N], 3*N), [0, 1, 2]*N)
check('one worker', solve([N], N), [0]*N)
check('no capacity', solve([0, 0], N), [])
check('no scheduling slots', solve([N, N+1], 0), [])
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:
Round-robin ignores weights, while contiguous weighted blocks create avoidable short-prefix imbalance.

Weights are nonnegative integers. Starting all credits at zero, perform the stated smooth weighted round-robin update for each requested slot; lowest index wins ties. Zero-weight lanes are ineligible. Return chosen lane indices, or [] if all weights are zero or there are no slots.

split: open-access


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

N = 1
observations = []
def solve(cursor, requests):
    starts = []
    for size, alignment in requests:
        starts.append(cursor)
        cursor += ((size+alignment-1)//alignment)*alignment
    return [starts, cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unaligned starting cursor', solve(8*N+1, [[N, 8]]), [[8*N+8], 9*N+8])
check('already aligned cursor', solve(8*N, [[N, 8]]), [[8*N], 9*N])
check('non-power-of-two alignment', solve(3*N+1, [[N, 3]]), [[3*N+3], 4*N+3])
check('consecutive different alignments', solve(0, [[N, 1], [N, 8]]), [[0, 8], 8+N])
check('zero-size aligned reservation', solve(8*N, [[0, 8]]), [[8*N], 8*N])
check('no allocation requests', solve(N, []), [[], N])
check('unit alignment adds no padding', solve(N, [[N, 1]]), [[N], 2*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(cursor, requests):
    starts = []
    for size, alignment in requests:
        start = (cursor//alignment+1)*alignment
        starts.append(start)
        cursor = start+size
    return [starts, cursor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unaligned starting cursor', solve(8*N+1, [[N, 8]]), [[8*N+8], 9*N+8])
check('already aligned cursor', solve(8*N, [[N, 8]]), [[8*N], 9*N])
check('non-power-of-two alignment', solve(3*N+1, [[N, 3]]), [[3*N+3], 4*N+3])
check('consecutive different alignments', solve(0, [[N, 1], [N, 8]]), [[0, 8], 8+N])
check('zero-size aligned reservation', solve(8*N, [[0, 8]]), [[8*N], 8*N])
check('no allocation requests', solve(N, []), [[], N])
check('unit alignment adds no padding', solve(N, [[N, 1]]), [[N], 2*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:
An allocation starts at a misaligned cursor even though its padded size is a multiple of alignment.

Cursor and sizes are nonnegative integers; each requested alignment is a positive integer, not necessarily a power of two. Return [starting addresses,final cursor]. Each start is the least aligned address >= cursor, then cursor becomes start+size. Zero-size reservations may consume alignment padding.

split: open-access


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

N = 1
observations = []
def solve(events):
    handles, references, destroyed = {'root': True}, 1, 0
    for kind, identity in events:
        if kind == 'clone':
            handles[identity] = True
            references += 1
        elif kind == 'borrow':
            handles[identity] = False
            references += 1
        else:
            owned = handles.pop(identity)
            if True:
                references -= 1
                if references == 0:
                    destroyed += 1
    return [references, references > 0, destroyed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
borrows = [['borrow', 'b'+str(i)] for i in range(N)]
drops = [['drop', 'b'+str(i)] for i in range(N)]
check('borrows do not own', solve(borrows), [1, True, 0])
check('dropping borrows preserves owner', solve(borrows+drops), [1, True, 0])
check('last owner can die before borrow record', solve(borrows+[['drop', 'root']]), [0, False, 1])
check('clone keeps object alive', solve([['clone', 'second'], ['drop', 'root']]), [1, True, 0])
check('last cloned owner frees once', solve([['clone', 'second'], ['drop', 'root'], ['drop', 'second']]), [0, False, 1])
check('borrow after extra owner then drops', solve([['clone', 'second'], ['borrow', 'view'], ['drop', 'view'], ['drop', 'root']]), [1, True, 0])
check('no lifetime changes', solve([]), [1, True, 0])
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(events):
    handles, references, destroyed = {'root': True}, 1, 0
    for kind, identity in events:
        if kind == 'clone':
            handles[identity] = True
            references += 1
        elif kind == 'borrow':
            handles[identity] = False
            pass
        else:
            owned = handles.pop(identity)
            if True:
                references -= 1
                if references == 0:
                    destroyed += 1
    return [references, references > 0, destroyed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
borrows = [['borrow', 'b'+str(i)] for i in range(N)]
drops = [['drop', 'b'+str(i)] for i in range(N)]
check('borrows do not own', solve(borrows), [1, True, 0])
check('dropping borrows preserves owner', solve(borrows+drops), [1, True, 0])
check('last owner can die before borrow record', solve(borrows+[['drop', 'root']]), [0, False, 1])
check('clone keeps object alive', solve([['clone', 'second'], ['drop', 'root']]), [1, True, 0])
check('last cloned owner frees once', solve([['clone', 'second'], ['drop', 'root'], ['drop', 'second']]), [0, False, 1])
check('borrow after extra owner then drops', solve([['clone', 'second'], ['borrow', 'view'], ['drop', 'view'], ['drop', 'root']]), [1, True, 0])
check('no lifetime changes', solve([]), [1, True, 0])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A borrowed pointer either keeps an object alive or decrements an ownership count it never incremented.

The object starts with owning handle root. Events create distinct clone or borrow names, or drop an existing handle once. Cloning occurs only while a live owner exists. Borrowed handles do not extend lifetime and are not dereferenced here. Return [owning reference count,is alive,destruction transitions].

split: open-access


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

N = 1
observations = []
def solve(resources, cancel_after, failures):
    acquired = list(resources[:cancel_after]) if cancel_after is not None else list(resources)
    remaining, attempted, errors = set(acquired), [], []
    if cancel_after is None:
        for identity in reversed(acquired):
            attempted.append(identity)
            if identity in failures:
                errors.append(identity)
                continue
            else:
                remaining.remove(identity)
    return [attempted, errors, sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
resources = ['r'+str(i) for i in range(N+2)]
check('cancellation after partial acquisition', solve(resources, N, []), [list(reversed(resources[:N])), [], []])
check('normal completion also cleans', solve(resources, None, []), [list(reversed(resources)), [], []])
check('one failure does not suppress rest', solve(resources, None, [resources[-1]]), [list(reversed(resources)), [resources[-1]], [resources[-1]]])
check('cancel before first acquisition', solve(resources, 0, []), [[], [], []])
check('nothing acquired', solve([], None, []), [[], [], []])
check('multiple failures collected', solve(resources, None, [resources[0], resources[-1]]), [list(reversed(resources)), [resources[-1], resources[0]], sorted([resources[0], resources[-1]])])
check('unacquired failure irrelevant', solve(resources, N, [resources[-1]]), [list(reversed(resources[: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(resources, cancel_after, failures):
    acquired = list(resources[:cancel_after]) if cancel_after is not None else list(resources)
    remaining, attempted, errors = set(acquired), [], []
    if True:
        for identity in reversed(acquired):
            attempted.append(identity)
            if identity in failures:
                errors.append(identity)
                break
            else:
                remaining.remove(identity)
    return [attempted, errors, sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
resources = ['r'+str(i) for i in range(N+2)]
check('cancellation after partial acquisition', solve(resources, N, []), [list(reversed(resources[:N])), [], []])
check('normal completion also cleans', solve(resources, None, []), [list(reversed(resources)), [], []])
check('one failure does not suppress rest', solve(resources, None, [resources[-1]]), [list(reversed(resources)), [resources[-1]], [resources[-1]]])
check('cancel before first acquisition', solve(resources, 0, []), [[], [], []])
check('nothing acquired', solve([], None, []), [[], [], []])
check('multiple failures collected', solve(resources, None, [resources[0], resources[-1]]), [list(reversed(resources)), [resources[-1], resources[0]], sorted([resources[0], resources[-1]])])
check('unacquired failure irrelevant', solve(resources, N, [resources[-1]]), [list(reversed(resources[: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:
Cleanup is skipped after partial acquisition or stops when the first resource cleanup reports failure.

Resources have unique names. Acquire a prefix cancel_after, or all when it is None, then unwind. Every acquired resource receives one cleanup attempt in reverse order. Named simulated cleanup failures stay open; other resources close. Return [attempt order,failure names,sorted open names].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import OrderedDict
N = 1
observations = []
def solve(capacity, events):
    cache, reads = OrderedDict(), []
    for event in events:
        kind, key = event[:2]
        if kind == 'get':
            reads.append(cache.get(key))
            if key in cache:
                pass
        elif capacity > 0:
            existed = key in cache
            cache[key] = event[2]
            pass
            while len(cache) > capacity:
                cache.popitem(last=False)
    return [reads, list(cache)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
keys = ['k'+str(i) for i in range(N+1)]
puts = [['put', key, i+N] for i, key in enumerate(keys)]
new = 'new'
check('hit moves oldest before eviction', solve(N+1, puts+[['get', keys[0]], ['put', new, 99]]), [[N], keys[2:]+[keys[0], new]])
check('overwrite is also recent', solve(N+1, puts+[['put', keys[0], 100], ['put', new, 99]]), [[], keys[2:]+[keys[0], new]])
check('miss leaves recency alone', solve(N+1, puts+[['get', 'absent']]), [[None], keys])
check('zero-capacity cache', solve(0, [['put', 'a', N], ['get', 'a']]), [[None], []])
check('single entry replacement', solve(1, [['put', 'a', N], ['put', 'b', N+1], ['get', 'a'], ['get', 'b']]), [[None, N+1], ['b']])
check('read observes overwrite', solve(1, [['put', 'a', N], ['put', 'a', N+1], ['get', 'a']]), [[N+1], ['a']])
check('empty cache history', solve(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
from collections import OrderedDict
N = 1
observations = []
def solve(capacity, events):
    cache, reads = OrderedDict(), []
    for event in events:
        kind, key = event[:2]
        if kind == 'get':
            reads.append(cache.get(key))
            if key in cache:
                cache.move_to_end(key)
        elif capacity > 0:
            existed = key in cache
            cache[key] = event[2]
            if not existed:
                cache.move_to_end(key)
            while len(cache) > capacity:
                cache.popitem(last=False)
    return [reads, list(cache)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
keys = ['k'+str(i) for i in range(N+1)]
puts = [['put', key, i+N] for i, key in enumerate(keys)]
new = 'new'
check('hit moves oldest before eviction', solve(N+1, puts+[['get', keys[0]], ['put', new, 99]]), [[N], keys[2:]+[keys[0], new]])
check('overwrite is also recent', solve(N+1, puts+[['put', keys[0], 100], ['put', new, 99]]), [[], keys[2:]+[keys[0], new]])
check('miss leaves recency alone', solve(N+1, puts+[['get', 'absent']]), [[None], keys])
check('zero-capacity cache', solve(0, [['put', 'a', N], ['get', 'a']]), [[None], []])
check('single entry replacement', solve(1, [['put', 'a', N], ['put', 'b', N+1], ['get', 'a'], ['get', 'b']]), [[None, N+1], ['b']])
check('read observes overwrite', solve(1, [['put', 'a', N], ['put', 'a', N+1], ['get', 'a']]), [[N+1], ['a']])
check('empty cache history', solve(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:
Insertion order is mistaken for recency, or updating an existing value fails to refresh that recency.

Events are ['put',key,value] or ['get',key]; keys are strings and capacity is nonnegative. A get returns value or None, and only hits refresh recency. Every put refreshes its key. Capacity zero retains nothing. Return [read results,keys ordered least to most recent].

split: open-access


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

N = 1
observations = []
def solve(capacity, events):
    available, held, accepted = capacity, set(), []
    for kind, identity in events:
        if kind == 'acquire':
            allowed = available > 0 and identity not in held
            if allowed:
                held.add(identity)
                available -= 1
            accepted.append(allowed)
        else:
            held.discard(identity)
            available += 1
    return [available, sorted(held), accepted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
ids = ['owner-'+str(i) for i in range(N)]
fill = [['acquire', identity] for identity in ids]
check('nonholder cannot create spare permit', solve(N, fill+[['release', 'ghost'], ['acquire', 'extra']]), [0, sorted(ids), [True]*N+[False]])
check('duplicate release cannot exceed capacity', solve(N, [['acquire', 'a'], ['release', 'a'], ['release', 'a']]), [N, [], [True]])
check('valid release restores one', solve(N, fill+[['release', ids[0]]]), [1, sorted(ids[1:]), [True]*N])
check('full semaphore rejects acquire', solve(N, fill+[['acquire', 'extra']]), [0, sorted(ids), [True]*N+[False]])
check('same owner cannot acquire twice', solve(N, [['acquire', 'a'], ['acquire', 'a']]), [N-1, ['a'], [True, False]])
check('zero-capacity semaphore', solve(0, [['acquire', 'a'], ['release', 'a']]), [0, [], [False]])
check('idle semaphore', solve(N, []), [N, [], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(capacity, events):
    available, held, accepted = capacity, set(), []
    for kind, identity in events:
        if kind == 'acquire':
            allowed = available > 0 and identity not in held
            if allowed:
                held.add(identity)
                available -= 1
            accepted.append(allowed)
        else:
            held.discard(identity)
            available = min(capacity, available+1)
    return [available, sorted(held), accepted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
ids = ['owner-'+str(i) for i in range(N)]
fill = [['acquire', identity] for identity in ids]
check('nonholder cannot create spare permit', solve(N, fill+[['release', 'ghost'], ['acquire', 'extra']]), [0, sorted(ids), [True]*N+[False]])
check('duplicate release cannot exceed capacity', solve(N, [['acquire', 'a'], ['release', 'a'], ['release', 'a']]), [N, [], [True]])
check('valid release restores one', solve(N, fill+[['release', ids[0]]]), [1, sorted(ids[1:]), [True]*N])
check('full semaphore rejects acquire', solve(N, fill+[['acquire', 'extra']]), [0, sorted(ids), [True]*N+[False]])
check('same owner cannot acquire twice', solve(N, [['acquire', 'a'], ['acquire', 'a']]), [N-1, ['a'], [True, False]])
check('zero-capacity semaphore', solve(0, [['acquire', 'a'], ['release', 'a']]), [0, [], [False]])
check('idle semaphore', solve(N, []), [N, [], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
More callers enter than capacity permits after a duplicate or unowned release.

A nonnegative capacity counts permits. Each identity may hold at most one. Acquire is nonblocking and returns false if already held or full. Release of a nonholder is a no-op. Return [available,sorted active identities,acquire results]. Transitions are serialized; fairness is not modeled.

split: open-access


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

N = 1
observations = []
def solve(latency, arrivals, finish_time):
    pending, deadline, flushed = [], None, []
    for timestamp, value in arrivals:
        if pending and deadline <= timestamp:
            flushed.append([deadline, pending])
            pending, deadline = [], None
        if True:
            deadline = timestamp + latency
        pending.append(value)
    if pending and deadline <= finish_time:
        flushed.append([deadline, pending])
        pending = []
    return [flushed, pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('steady arrivals cannot postpone oldest', solve(3*N, [[0, 'a'], [N, 'b'], [2*N, 'c']], 3*N), [[[3*N, ['a', 'b', 'c']]], []])
check('arrival at deadline starts new batch', solve(3*N, [[0, 'a'], [3*N, 'b']], 3*N), [[[3*N, ['a']]], ['b']])
check('sparse arrivals create distinct batches', solve(3*N, [[0, 'a'], [4*N, 'b']], 8*N), [[[3*N, ['a']], [7*N, ['b']]], []])
check('not yet due remains buffered', solve(3*N, [[0, 'a']], N), [[], ['a']])
check('same-tick values share batch', solve(N, [[0, 'a'], [0, 'b']], N), [[[N, ['a', 'b']]], []])
check('zero-latency each item flushes', solve(0, [[N, 'a'], [N, 'b']], N), [[[N, ['a']], [N, ['b']]], []])
check('empty buffer never flushes', solve(N, [], 10*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(latency, arrivals, finish_time):
    pending, deadline, flushed = [], None, []
    for timestamp, value in arrivals:
        if pending and deadline < timestamp:
            flushed.append([deadline, pending])
            pending, deadline = [], None
        if not pending:
            deadline = timestamp + latency
        pending.append(value)
    if pending and deadline < finish_time:
        flushed.append([deadline, pending])
        pending = []
    return [flushed, pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('steady arrivals cannot postpone oldest', solve(3*N, [[0, 'a'], [N, 'b'], [2*N, 'c']], 3*N), [[[3*N, ['a', 'b', 'c']]], []])
check('arrival at deadline starts new batch', solve(3*N, [[0, 'a'], [3*N, 'b']], 3*N), [[[3*N, ['a']]], ['b']])
check('sparse arrivals create distinct batches', solve(3*N, [[0, 'a'], [4*N, 'b']], 8*N), [[[3*N, ['a']], [7*N, ['b']]], []])
check('not yet due remains buffered', solve(3*N, [[0, 'a']], N), [[], ['a']])
check('same-tick values share batch', solve(N, [[0, 'a'], [0, 'b']], N), [[[N, ['a', 'b']]], []])
check('zero-latency each item flushes', solve(0, [[N, 'a'], [N, 'b']], N), [[[N, ['a']], [N, ['b']]], []])
check('empty buffer never flushes', solve(N, [], 10*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:
Each arrival postpones a batch timer, so sustained low-rate traffic starves publication.

Arrivals have nondecreasing integer timestamps and latency is nonnegative. Before admitting an arrival, flush an existing batch if its first-item deadline <= arrival time. At finish_time (>= last arrival), flush if due. Record the scheduled deadline as flush time. Return [flushed [time,values] batches,remaining values]; actual event-loop delay is outside this model.

split: open-access


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

N = 1
observations = []
def solve(period, start, durations):
    times, current = [], start
    for duration in durations:
        times.append(current)
        current += duration+period
    return times
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('short callbacks do not accumulate drift', solve(10*N, 0, [N]*3), [0, 10*N, 20*N])
check('overrun skips expired slots', solve(10*N, 0, [25*N, N, N]), [0, 30*N, 40*N])
check('completion exactly on deadline', solve(10*N, 0, [10*N, N]), [0, 10*N])
check('zero-duration still waits a period', solve(N, 0, [0, 0, 0]), [0, N, 2*N])
check('nonzero initial phase preserved', solve(10*N, 3*N, [25*N, N, N]), [3*N, 33*N, 43*N])
check('no callbacks', solve(N, N, []), [])
check('single callback uses initial start', solve(N, 7*N, [100*N]), [7*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(period, start, durations):
    return [start+i*period for i in range(len(durations))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('short callbacks do not accumulate drift', solve(10*N, 0, [N]*3), [0, 10*N, 20*N])
check('overrun skips expired slots', solve(10*N, 0, [25*N, N, N]), [0, 30*N, 40*N])
check('completion exactly on deadline', solve(10*N, 0, [10*N, N]), [0, 10*N])
check('zero-duration still waits a period', solve(N, 0, [0, 0, 0]), [0, N, 2*N])
check('nonzero initial phase preserved', solve(10*N, 3*N, [25*N, N, N]), [3*N, 33*N, 43*N])
check('no callbacks', solve(N, N, []), [])
check('single callback uses initial start', solve(N, 7*N, [100*N]), [7*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:
A task sleeps a full period after finishing, or the attempted correction schedules overlapping callbacks.

Period is a positive integer, start and durations are nonnegative integers. The first callback starts at start. Later starts are the earliest start+k*period >= preceding completion and strictly greater than preceding start. Missed slots are skipped, not caught up. Return one start per duration.

split: open-access


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

N = 1
observations = []
def solve(size, events):
    free, generations, active, issued = list(range(size)), [0]*size, {}, []
    for event in events:
        if event[0] == 'get':
            if not free:
                issued.append(None)
                continue
            free.sort()
            slot = free.pop(0)
            generations[slot] += 1
            active[slot] = generations[slot]
            issued.append([slot, active[slot]])
        else:
            slot, generation = event[1:]
            if 0 <= slot < size:
                active.pop(slot, None)
                free.append(slot)
    return [issued, sorted(free), [[slot, active[slot]] for slot in sorted(active)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
prefix = [event for generation in range(1, N+1) for event in [['get'], ['put', 0, generation]]]
check('old handle cannot release new checkout', solve(1, prefix+[['get'], ['put', 0, N], ['get']]), [[[0, g] for g in range(1, N+2)]+[None], [], [[0, N+1]]])
check('return of never-issued handle', solve(1, [['put', 0, 0], ['get'], ['get']]), [[[0, 1], None], [], [[0, 1]]])
check('valid reuse advances generation', solve(1, [['get'], ['put', 0, 1], ['get']]), [[[0, 1], [0, 2]], [], [[0, 2]]])
check('pool exhaustion is explicit', solve(N, [['get']]*(N+1)), [[[i, 1] for i in range(N)]+[None], [], [[i, 1] for i in range(N)]])
check('zero-sized pool', solve(0, [['get'], ['put', 0, 1]]), [[None], [], []])
check('out-of-range return ignored', solve(N, [['put', N+1, 1]]), [[], list(range(N)), []])
check('no pool activity', solve(N, []), [[], list(range(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(size, events):
    free, generations, active, issued = list(range(size)), [0]*size, {}, []
    for event in events:
        if event[0] == 'get':
            if not free:
                issued.append(None)
                continue
            free.sort()
            slot = free.pop(0)
            generations[slot] += 1
            active[slot] = generations[slot]
            issued.append([slot, active[slot]])
        else:
            slot, generation = event[1:]
            if slot in active:
                active.pop(slot, None)
                free.append(slot)
    return [issued, sorted(free), [[slot, active[slot]] for slot in sorted(active)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
prefix = [event for generation in range(1, N+1) for event in [['get'], ['put', 0, generation]]]
check('old handle cannot release new checkout', solve(1, prefix+[['get'], ['put', 0, N], ['get']]), [[[0, g] for g in range(1, N+2)]+[None], [], [[0, N+1]]])
check('return of never-issued handle', solve(1, [['put', 0, 0], ['get'], ['get']]), [[[0, 1], None], [], [[0, 1]]])
check('valid reuse advances generation', solve(1, [['get'], ['put', 0, 1], ['get']]), [[[0, 1], [0, 2]], [], [[0, 2]]])
check('pool exhaustion is explicit', solve(N, [['get']]*(N+1)), [[[i, 1] for i in range(N)]+[None], [], [[i, 1] for i in range(N)]])
check('zero-sized pool', solve(0, [['get'], ['put', 0, 1]]), [[None], [], []])
check('out-of-range return ignored', solve(N, [['put', N+1, 1]]), [[], list(range(N)), []])
check('no pool activity', solve(N, []), [[], list(range(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 same slot becomes available while a later borrower still owns it.

A pool starts with size free numbered slots. Get chooses the smallest free slot and increments its generation, or emits None if exhausted. Put [slot,generation] releases only that active handle. Return [issued handles,sorted free slots,sorted active handles]. Generations never wrap in this model.

split: open-access


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

N = 1
observations = []
def solve(initial, edits):
    source, snapshot, yielded, index = list(initial), list(initial), [], 0
    while index < len(source):
        for step, kind, position, value in edits:
            if step != index:
                continue
            if kind == 'append':
                source.append(value)
            elif kind == 'delete':
                del source[position]
            elif kind == 'replace':
                source[position] = value
            elif kind == 'insert':
                source.insert(position, value)
            elif kind == 'clear':
                source.clear()
        yielded.append(source[index] if index < len(source) else None)
        index += 1
    return [yielded, source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
initial = list(range(N+2))
check('appended element is not visited', solve(initial, [[0, 'append', 0, 99]]), [initial, initial+[99]])
check('deleting first cannot skip original', solve(initial, [[0, 'delete', 0, None]]), [initial, initial[1:]])
check('replacement does not rewrite snapshot', solve(initial, [[0, 'replace', 0, 99]]), [initial, [99]+initial[1:]])
check('insertion does not repeat original', solve(initial, [[0, 'insert', 0, 99]]), [initial, [99]+initial])
check('clear still yields captured values', solve(initial, [[0, 'clear', 0, None]]), [initial, []])
check('empty iterator never invokes callbacks', solve([], [[0, 'append', 0, 99]]), [[], []])
check('no mutation preserves order', solve(initial, []), [initial, initial])
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(initial, edits):
    source, snapshot, yielded, index = list(initial), list(initial), [], 0
    while index < len(snapshot):
        for step, kind, position, value in edits:
            if step != index:
                continue
            if kind == 'append':
                source.append(value)
            elif kind == 'delete':
                del source[position]
            elif kind == 'replace':
                source[position] = value
            elif kind == 'insert':
                source.insert(position, value)
            elif kind == 'clear':
                source.clear()
        yielded.append(source[index] if index < len(source) else None)
        index += 1
    return [yielded, source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
initial = list(range(N+2))
check('appended element is not visited', solve(initial, [[0, 'append', 0, 99]]), [initial, initial+[99]])
check('deleting first cannot skip original', solve(initial, [[0, 'delete', 0, None]]), [initial, initial[1:]])
check('replacement does not rewrite snapshot', solve(initial, [[0, 'replace', 0, 99]]), [initial, [99]+initial[1:]])
check('insertion does not repeat original', solve(initial, [[0, 'insert', 0, 99]]), [initial, [99]+initial])
check('clear still yields captured values', solve(initial, [[0, 'clear', 0, None]]), [initial, []])
check('empty iterator never invokes callbacks', solve([], [[0, 'append', 0, 99]]), [[], []])
check('no mutation preserves order', solve(initial, []), [initial, initial])
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:
Inserting, deleting or replacing source elements alters an iteration that promised a stable snapshot.

Initial is a list of immutable scalar values. Edits are [yield index,operation,position,value] applied immediately before that snapshot yield. Operations append/delete/replace/insert/clear have valid positions at application time. Return [yielded original values,mutated source]. No yields means no scheduled edits execute. This is a shallow scalar snapshot, not object-graph isolation.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from datetime import date, timedelta
import calendar
N = 1
observations = []
def solve(text, months):
    return (date.fromisoformat(text) + timedelta(days=30 * months)).isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
year = 2019 + N
february_day = [29, 28, 28, 28, 29][N - 1]
check('January end clamps to actual February', solve(f'{year}-01-31', 1), f'{year}-02-{february_day}')
check('two-month move clamps only at destination', solve(f'{year}-01-31', 2), f'{year}-03-31')
check('reverse month movement', solve(f'{year}-03-31', -1), f'{year}-02-{february_day}')
check('year rollover with variable offset', solve('2023-12-15', N), f'2024-{N:02d}-15')
check('zero offset preserves month end', solve(f'{year}-07-31', 0), f'{year}-07-31')
check('century divisible by four hundred is leap', solve('2000-01-31', 1), '2000-02-29')
check('other century is not leap', solve('2100-01-31', 1), '2100-02-28')
check('thirty-day destination', solve(f'{year}-03-31', 1), f'{year}-04-30')
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
from datetime import date, timedelta
import calendar
N = 1
observations = []
def solve(text, months):
    original = date.fromisoformat(text)
    index = original.year * 12 + original.month - 1 + months
    year, month = divmod(index, 12)
    return date(year, month + 1, min(original.day, 28)).isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
year = 2019 + N
february_day = [29, 28, 28, 28, 29][N - 1]
check('January end clamps to actual February', solve(f'{year}-01-31', 1), f'{year}-02-{february_day}')
check('two-month move clamps only at destination', solve(f'{year}-01-31', 2), f'{year}-03-31')
check('reverse month movement', solve(f'{year}-03-31', -1), f'{year}-02-{february_day}')
check('year rollover with variable offset', solve('2023-12-15', N), f'2024-{N:02d}-15')
check('zero offset preserves month end', solve(f'{year}-07-31', 0), f'{year}-07-31')
check('century divisible by four hundred is leap', solve('2000-01-31', 1), '2000-02-29')
check('other century is not leap', solve('2100-01-31', 1), '2100-02-28')
check('thirty-day destination', solve(f'{year}-03-31', 1), f'{year}-04-30')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A month offset expressed as thirty days lands on the wrong date, or a blanket day cap loses valid month-end days.

Given a valid ISO calendar date and an integer month offset, return an ISO date in the destination month, keeping the original day when possible and otherwise clamping once to the last day. Supported results stay within years 1 through 9999.

split: open-access


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

N = 1
observations = []
def solve(milliseconds):
    return int(milliseconds / 1000)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('negative fractional second', solve(-1000 * N - 1), -N - 1)
check('negative fraction close to next boundary', solve(-1000 * N + 1), -N)
check('positive late fraction stays in containing second', solve(1000 * N + 999), N)
check('exact negative second', solve(-1000 * N), -N)
check('exact positive second', solve(1000 * N), N)
check('epoch itself', solve(0), 0)
check('large timestamp retains integer precision', solve((2 ** 60 + N) * 1000 + 999), 2 ** 60 + 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(milliseconds):
    return round(milliseconds / 1000)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('negative fractional second', solve(-1000 * N - 1), -N - 1)
check('negative fraction close to next boundary', solve(-1000 * N + 1), -N)
check('positive late fraction stays in containing second', solve(1000 * N + 999), N)
check('exact negative second', solve(-1000 * N), -N)
check('exact positive second', solve(1000 * N), N)
check('epoch itself', solve(0), 0)
check('large timestamp retains integer precision', solve((2 ** 60 + N) * 1000 + 999), 2 ** 60 + 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:
An instant just before the Unix epoch is assigned to second zero, or rounding moves a positive fraction into a later second.

Convert an integer count of milliseconds since the Unix epoch to the integer second s satisfying 1000*s <= milliseconds < 1000*(s+1). Do not round to the nearest second and do not pass through floating point.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from datetime import date
N = 1
observations = []
def solve(text):
    value = date.fromisoformat(text)
    _, week, weekday = value.isocalendar()
    return f'{value.year:04d}-W{week:02d}-{weekday}'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
january = ['2016-01-01', '2017-01-01', '2021-01-01', '2022-01-01', '2023-01-01'][N - 1]
expected = ['2015-W53-5', '2016-W52-7', '2020-W53-5', '2021-W52-6', '2022-W52-7'][N - 1]
check('January belongs to preceding ISO year', solve(january), expected)
check('December belongs to following ISO year', solve('2018-12-31'), '2019-W01-1')
check('December remains in week fifty-three', solve('2020-12-31'), '2020-W53-4')
check('Monday January first', solve('2024-01-01'), '2024-W01-1')
check('leap day', solve('2024-02-29'), '2024-W09-4')
check('Sunday ends the same ISO week', solve('2024-03-03'), '2024-W09-7')
check('Monday advances the week', solve('2024-03-04'), '2024-W10-1')
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
from datetime import date
N = 1
observations = []
def solve(text):
    value = date.fromisoformat(text)
    _, week, weekday = value.isocalendar()
    year = value.year + (value.month == 12 and week == 1)
    return f'{year:04d}-W{week:02d}-{weekday}'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
january = ['2016-01-01', '2017-01-01', '2021-01-01', '2022-01-01', '2023-01-01'][N - 1]
expected = ['2015-W53-5', '2016-W52-7', '2020-W53-5', '2021-W52-6', '2022-W52-7'][N - 1]
check('January belongs to preceding ISO year', solve(january), expected)
check('December belongs to following ISO year', solve('2018-12-31'), '2019-W01-1')
check('December remains in week fifty-three', solve('2020-12-31'), '2020-W53-4')
check('Monday January first', solve('2024-01-01'), '2024-W01-1')
check('leap day', solve('2024-02-29'), '2024-W09-4')
check('Sunday ends the same ISO week', solve('2024-03-03'), '2024-W09-7')
check('Monday advances the week', solve('2024-03-04'), '2024-W10-1')
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:
Dates near New Year receive a week number from one ISO year and a year label from another.

Return YYYY-Www-d for a valid ISO date using ISO week numbering: Monday is weekday one, and week one is the week containing January fourth. The year field is the ISO week year.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from datetime import datetime, timezone
N = 1
observations = []
def solve(records):
    return [record[0] for record in sorted(records, key=lambda record: record[1])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
offset = N + 1
check('positive offset reverses wall-clock order', solve([['east', f'2024-01-01T10:00:00+{offset:02d}:00'], ['utc', '2024-01-01T09:00:00+00:00']]), ['east', 'utc'])
check('negative offset reverses wall-clock order', solve([['west', '2024-01-01T08:00:00-05:00'], ['utc', '2024-01-01T12:00:00+00:00']]), ['utc', 'west'])
check('equal instants keep input order', solve([['first', '2024-01-01T10:00:00+02:00'], ['second', '2024-01-01T08:00:00+00:00']]), ['first', 'second'])
check('offset crosses calendar date', solve([['next-local-day', '2024-01-02T00:00:00+14:00'], ['same-utc-day', '2024-01-01T23:00:00+00:00']]), ['next-local-day', 'same-utc-day'])
check('fractional seconds retain order', solve([['later', '2024-01-01T00:00:00.002000+00:00'], ['earlier', '2024-01-01T00:00:00.001000+00:00']]), ['earlier', 'later'])
check('single record', solve([['only', f'2024-01-0{N}T00:00:00+00:00']]), ['only'])
check('no records', solve([]), [])
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
from datetime import datetime, timezone
N = 1
observations = []
def solve(records):
    return [record[0] for record in sorted(records, key=lambda record: datetime.fromisoformat(record[1]).replace(tzinfo=None))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
offset = N + 1
check('positive offset reverses wall-clock order', solve([['east', f'2024-01-01T10:00:00+{offset:02d}:00'], ['utc', '2024-01-01T09:00:00+00:00']]), ['east', 'utc'])
check('negative offset reverses wall-clock order', solve([['west', '2024-01-01T08:00:00-05:00'], ['utc', '2024-01-01T12:00:00+00:00']]), ['utc', 'west'])
check('equal instants keep input order', solve([['first', '2024-01-01T10:00:00+02:00'], ['second', '2024-01-01T08:00:00+00:00']]), ['first', 'second'])
check('offset crosses calendar date', solve([['next-local-day', '2024-01-02T00:00:00+14:00'], ['same-utc-day', '2024-01-01T23:00:00+00:00']]), ['next-local-day', 'same-utc-day'])
check('fractional seconds retain order', solve([['later', '2024-01-01T00:00:00.002000+00:00'], ['earlier', '2024-01-01T00:00:00.001000+00:00']]), ['earlier', 'later'])
check('single record', solve([['only', f'2024-01-0{N}T00:00:00+00:00']]), ['only'])
check('no records', solve([]), [])
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:
An event with a later wall-clock reading is placed after an event that actually occurred later in UTC.

Given [identifier, ISO timestamp] records with explicit numeric offsets, return identifiers in increasing absolute-time order. Keep input order for ties. This models explicit fixed offsets only, not named-zone DST resolution.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from datetime import timedelta
N = 1
observations = []
def solve(microseconds):
    value = timedelta(microseconds=microseconds)
    hours, rest = divmod(value.seconds, 3600)
    minutes, seconds = divmod(rest, 60)
    return f'{hours}:{minutes:02d}:{seconds:02d}.{value.microseconds:06d}'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
hours = 24 * N + 3
value = (hours * 3600 + 2 * 60 + 1) * 1000000 + N
check('multi-day positive duration', solve(value), f'{hours}:02:01.{N:06d}')
check('multi-day negative duration', solve(-value), f'-{hours}:02:01.{N:06d}')
check('negative subsecond value', solve(-N), f'-0:00:00.{N:06d}')
check('positive subsecond value', solve(N), f'0:00:00.{N:06d}')
check('zero has no sign', solve(0), '0:00:00.000000')
check('whole minute', solve(60000000), '0:01:00.000000')
check('exact full day is twenty-four hours', solve(86400000000), '24:00:00.000000')
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
from datetime import timedelta
N = 1
observations = []
def solve(microseconds):
    seconds, fraction = divmod(abs(microseconds), 1000000)
    hours, rest = divmod(seconds, 3600)
    minutes, seconds = divmod(rest, 60)
    sign = '-' if microseconds < 0 else ''
    return f'{sign}{hours % 24}:{minutes:02d}:{seconds:02d}.{fraction:06d}'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
hours = 24 * N + 3
value = (hours * 3600 + 2 * 60 + 1) * 1000000 + N
check('multi-day positive duration', solve(value), f'{hours}:02:01.{N:06d}')
check('multi-day negative duration', solve(-value), f'-{hours}:02:01.{N:06d}')
check('negative subsecond value', solve(-N), f'-0:00:00.{N:06d}')
check('positive subsecond value', solve(N), f'0:00:00.{N:06d}')
check('zero has no sign', solve(0), '0:00:00.000000')
check('whole minute', solve(60000000), '0:01:00.000000')
check('exact full day is twenty-four hours', solve(86400000000), '24:00:00.000000')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A multi-day duration loses its day component, and a negative duration looks like a positive time of day.

Format an integer microsecond duration as optional '-' followed by H:MM:SS.ffffff. Hours are unbounded, minutes and seconds are 00 through 59, and zero has no negative sign.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(samples):
    if not samples or any(weight < 0 for value, weight in samples) or not sum(weight for value, weight in samples):
        return None
    return str(Fraction(sum(value * weight for value, weight in samples), len(samples)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal weights including zero value', solve([[0, 1], [6 * N, 2]]), str(4 * N))
check('uniform weight scaling changes nothing', solve([[0, 7], [6 * N, 14]]), str(4 * N))
check('equal weights', solve([[2 * N, 3], [4 * N, 3]]), str(3 * N))
check('zero weight contributes nothing', solve([[100 * N, 0], [2 * N, 3]]), str(2 * N))
check('fractional result remains exact', solve([[N, 1], [N + 1, 2]]), f'{3 * N + 2}/3')
check('negative observed values allowed', solve([[-6 * N, 2], [0, 1]]), str(-4 * N))
check('zero total weight', solve([[N, 0]]), None)
check('negative weight rejected', solve([[N, -1], [N, 2]]), None)
check('no observations', solve([]), None)
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
from fractions import Fraction
N = 1
observations = []
def solve(samples):
    if not samples or any(weight < 0 for value, weight in samples):
        return None
    values = [value for value, weight in samples if weight > 0]
    return str(Fraction(sum(values), len(values))) if values else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal weights including zero value', solve([[0, 1], [6 * N, 2]]), str(4 * N))
check('uniform weight scaling changes nothing', solve([[0, 7], [6 * N, 14]]), str(4 * N))
check('equal weights', solve([[2 * N, 3], [4 * N, 3]]), str(3 * N))
check('zero weight contributes nothing', solve([[100 * N, 0], [2 * N, 3]]), str(2 * N))
check('fractional result remains exact', solve([[N, 1], [N + 1, 2]]), f'{3 * N + 2}/3')
check('negative observed values allowed', solve([[-6 * N, 2], [0, 1]]), str(-4 * N))
check('zero total weight', solve([[N, 0]]), None)
check('negative weight rejected', solve([[N, -1], [N, 2]]), None)
check('no observations', solve([]), None)
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:
Changing the scale of weights changes the result, or unequal-weight observations are treated as equally influential.

For integer [value, nonnegative weight] pairs, return the exact weighted mean as a reduced Fraction string. Negative weights, no records, or zero total weight return None. Zero-valued observations remain valid.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(values):
    total = 0.0
    for value in values:
        total += value
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
large = float(2 ** 54)
residual = N + 0.125
check('small residual between cancelling large terms', solve([large, residual, -large]), residual)
check('negative residual between cancelling large terms', solve([-large, -residual, large]), -residual)
check('small terms before cancellation', solve([0.25] * N + [large, -large]), N / 4)
check('ordinary exact binary fractions', solve([0.125, 0.25, 0.5] * N), 0.875 * N)
check('opposite terms cancel exactly', solve([large, -large] * N), 0.0)
check('one finite observation', solve([residual]), residual)
check('empty sum', solve([]), 0.0)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(values):
    total, correction = 0.0, 0.0
    for value in values:
        adjusted = value - correction
        updated = total + adjusted
        correction = (updated - total) - adjusted
        total = updated
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
large = float(2 ** 54)
residual = N + 0.125
check('small residual between cancelling large terms', solve([large, residual, -large]), residual)
check('negative residual between cancelling large terms', solve([-large, -residual, large]), -residual)
check('small terms before cancellation', solve([0.25] * N + [large, -large]), N / 4)
check('ordinary exact binary fractions', solve([0.125, 0.25, 0.5] * N), 0.875 * N)
check('opposite terms cancel exactly', solve([large, -large] * N), 0.0)
check('one finite observation', solve([residual]), residual)
check('empty sum', solve([]), 0.0)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A mathematically nonzero residual disappears when large positive and negative terms cancel.

Sum a finite sequence of finite binary floating-point values using math.fsum semantics. These bounded fixtures have exactly representable expected residuals and do not overflow the final result.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import statistics
N = 1
observations = []
def solve(values):
    if not values:
        return None
    mean = sum(values) / len(values)
    return sum(value * value for value in values) / len(values) - mean * mean
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base = float(10 ** (N + 6))
check('unit spread on large baseline', solve([base, base + 1, base + 2]), 2 / 3)
check('same spread around zero', solve([0.0, 1.0, 2.0]), 2 / 3)
check('symmetric wider spread on baseline', solve([base - 2, base, base + 2]), 8 / 3)
check('constant sample has zero variance', solve([base] * (N + 1)), 0.0)
check('population denominator for two values', solve([-float(N), float(N)]), float(N * N))
check('single value', solve([base]), 0.0)
check('empty sample', solve([]), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import statistics
N = 1
observations = []
def solve(values):
    if not values:
        return None
    mean = sum(values) / len(values)
    variance = sum(value * value for value in values) / len(values) - mean * mean
    return max(0.0, variance)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base = float(10 ** (N + 6))
check('unit spread on large baseline', solve([base, base + 1, base + 2]), 2 / 3)
check('same spread around zero', solve([0.0, 1.0, 2.0]), 2 / 3)
check('symmetric wider spread on baseline', solve([base - 2, base, base + 2]), 8 / 3)
check('constant sample has zero variance', solve([base] * (N + 1)), 0.0)
check('population denominator for two values', solve([-float(N), float(N)]), float(N * N))
check('single value', solve([base]), 0.0)
check('empty sample', solve([]), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A nonconstant sample reports zero or an inaccurate variance after its mean is shifted far from zero.

Return statistics.pvariance for a nonempty sequence of finite floats; return None for empty input. This is population variance, so the denominator is n rather than n-1.

split: open-access


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

N = 1
observations = []
def solve(ticks, source_rate, target_rate):
    if source_rate <= 0 or target_rate < 0:
        return None
    return int(ticks / source_rate * target_rate)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large identity conversion keeps low bits', solve(2 ** 60 + N, 1, 1), 2 ** 60 + N)
check('subunit source amount becomes whole target ticks', solve(N, N + 1, 2 * (N + 1)), 2 * N)
check('negative fractional result floors downward', solve(-1, N + 1, N), -1)
check('exact integral rescaling', solve(3 * N, 3, 7), 7 * N)
check('zero tick count', solve(0, N, 3), 0)
check('zero target rate', solve(2 ** 60 + N, N, 0), 0)
check('zero source rate rejected', solve(N, 0, 1), None)
check('negative target rate rejected', solve(N, 1, -1), None)
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(ticks, source_rate, target_rate):
    if source_rate <= 0 or target_rate < 0:
        return None
    return (ticks // source_rate) * target_rate
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large identity conversion keeps low bits', solve(2 ** 60 + N, 1, 1), 2 ** 60 + N)
check('subunit source amount becomes whole target ticks', solve(N, N + 1, 2 * (N + 1)), 2 * N)
check('negative fractional result floors downward', solve(-1, N + 1, N), -1)
check('exact integral rescaling', solve(3 * N, 3, 7), 7 * N)
check('zero tick count', solve(0, N, 3), 0)
check('zero target rate', solve(2 ** 60 + N, N, 0), 0)
check('zero source rate rejected', solve(N, 0, 1), None)
check('negative target rate rejected', solve(N, 1, -1), None)
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:
Large counters change by several ticks after a float conversion, or fractional source units disappear before multiplication.

For integer ticks, positive integer source_rate, and nonnegative integer target_rate, return floor(ticks * target_rate / source_rate) exactly. Invalid rates return None. Python arbitrary-size integers are part of this model.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(values, percent):
    if not values or not 0 <= percent <= 100:
        return None
    ordered = sorted(values)
    index = max(0, math.ceil(len(values) * percent / 100) - 1)
    return str(ordered[index])
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
values = [3 * N, 0, N, 2 * N]
check('unordered even-sample median', solve(values, 50), str(Fraction(3 * N, 2)))
check('quarter percentile interpolates', solve([0, N, 2 * N, 3 * N], 25), str(Fraction(3 * N, 4)))
check('zeroth percentile is minimum', solve(values, 0), '0')
check('hundredth percentile is maximum', solve(values, 100), str(3 * N))
check('duplicate observations stay weighted by count', solve([0, 0, N, N], 50), str(Fraction(N, 2)))
check('negative values interpolate', solve([-N, 0, N], 25), str(Fraction(-N, 2)))
check('single observation', solve([N], 73), str(N))
check('invalid percentile rejected', solve(values, 101), None)
check('empty sample', solve([], 50), None)
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
from fractions import Fraction
import math
N = 1
observations = []
def solve(values, percent):
    if not values or not 0 <= percent <= 100:
        return None
    rank = Fraction((len(values) - 1) * percent, 100)
    index = rank.numerator // rank.denominator
    upper = min(index + 1, len(values) - 1)
    return str(Fraction(values[index]) + (rank - index) * (values[upper] - values[index]))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
values = [3 * N, 0, N, 2 * N]
check('unordered even-sample median', solve(values, 50), str(Fraction(3 * N, 2)))
check('quarter percentile interpolates', solve([0, N, 2 * N, 3 * N], 25), str(Fraction(3 * N, 4)))
check('zeroth percentile is minimum', solve(values, 0), '0')
check('hundredth percentile is maximum', solve(values, 100), str(3 * N))
check('duplicate observations stay weighted by count', solve([0, 0, N, N], 50), str(Fraction(N, 2)))
check('negative values interpolate', solve([-N, 0, N], 25), str(Fraction(-N, 2)))
check('single observation', solve([N], 73), str(N))
check('invalid percentile rejected', solve(values, 101), None)
check('empty sample', solve([], 50), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A percentile depends on input order or jumps to a nearest-rank value instead of the specified interpolated value.

For an integer sample and integer percentile p from 0 through 100, return the reduced Fraction string for linear interpolation at h=(n-1)*p/100 in sorted order. Empty samples and out-of-range p return None.

split: open-access