task_id
stringlengths
4
25
family
stringclasses
12 values
bug_pattern
stringclasses
37 values
case_seed
int64
20.3M
20.5M
prompt
stringlengths
299
1.09k
starter
stringclasses
48 values
split
stringclasses
1 value
arena_selected
bool
2 classes
num_cases
int64
92
188
cases_json
stringlengths
5.75k
15.3k
csv-row-b0-s20
csv-row
baseline
20,419,388
Implement solve(row). Parse one valid CSV record into strings, comma delimiter, double-quote quoting, and doubled quotes inside quoted fields. No embedded newlines. Empty row means []. Do not trim spaces. Use no imports. Examples (JSON args and expected result): [{"args": ["\"x11,y\",z"], "expected": ["x11,y", "z"]}, {...
def solve(row): return row.split(',') if row else []
train
true
146
[{"args":[""],"expected":[]},{"args":["a,b"],"expected":["a","b"]},{"args":["\"a,b\",c"],"expected":["a,b","c"]},{"args":["\"a\"\"b\",,c"],"expected":["a\"b","","c"]},{"args":[",,"],"expected":["","",""]},{"args":["\"\""],"expected":[""]},{"args":["\"a,babb猫猫\",\"a\"\"\"\"\"\",\"\"猫ba\"\"\""],"expected":["a,babb猫猫","a\...
csv-row-b1-s20
csv-row
quoted-comma
20,419,388
Implement solve(row). Parse one valid CSV record into strings, comma delimiter, double-quote quoting, and doubled quotes inside quoted fields. No embedded newlines. Empty row means []. Do not trim spaces. Use no imports. Examples (JSON args and expected result): [{"args": ["\",\"\"猫bb,,\",\"\"\"\"\"ab\"\"猫\",\",\"\"\"\...
def solve(row): if not row: return [] out = [] field = '' quoted = False i = 0 while i < len(row): c = row[i] if c == '"': if quoted and i+1 < len(row) and row[i+1] == '"': field += '"' i += 1 else: quoted = not quoted ...
train
false
146
[{"args":[""],"expected":[]},{"args":["a,b"],"expected":["a","b"]},{"args":["\"a,b\",c"],"expected":["a,b","c"]},{"args":["\"a\"\"b\",,c"],"expected":["a\"b","","c"]},{"args":[",,"],"expected":["","",""]},{"args":["\"\""],"expected":[""]},{"args":["\"a,babb猫猫\",\"a\"\"\"\"\"\",\"\"猫ba\"\"\""],"expected":["a,babb猫猫","a\...
csv-row-b2-s20
csv-row
escaped-quote
20,419,388
Implement solve(row). Parse one valid CSV record into strings, comma delimiter, double-quote quoting, and doubled quotes inside quoted fields. No embedded newlines. Empty row means []. Do not trim spaces. Use no imports. Examples (JSON args and expected result): [{"args": ["\"x2\"\"y\",z"], "expected": ["x2\"y", "z"]},...
def solve(row): if not row: return [] out = [] field = '' quoted = False i = 0 while i < len(row): c = row[i] if c == '"': if quoted and i+1 < len(row) and row[i+1] == '"': field += '""' i += 1 else: quoted = not quoted ...
train
false
146
[{"args":[""],"expected":[]},{"args":["a,b"],"expected":["a","b"]},{"args":["\"a,b\",c"],"expected":["a,b","c"]},{"args":["\"a\"\"b\",,c"],"expected":["a\"b","","c"]},{"args":[",,"],"expected":["","",""]},{"args":["\"\""],"expected":[""]},{"args":["\"a,babb猫猫\",\"a\"\"\"\"\"\",\"\"猫ba\"\"\""],"expected":["a,babb猫猫","a\...
csv-row-b3-s20
csv-row
lost-final-field
20,419,388
Implement solve(row). Parse one valid CSV record into strings, comma delimiter, double-quote quoting, and doubled quotes inside quoted fields. No embedded newlines. Empty row means []. Do not trim spaces. Use no imports. Examples (JSON args and expected result): [{"args": ["\",a\"\" \"\"\",猫"], "expected": [",a\" \"", ...
def solve(row): if not row: return [] out = [] field = '' quoted = False i = 0 while i < len(row): c = row[i] if c == '"': if quoted and i+1 < len(row) and row[i+1] == '"': field += '"' i += 1 else: quoted = not quoted ...
train
false
146
[{"args":[""],"expected":[]},{"args":["a,b"],"expected":["a","b"]},{"args":["\"a,b\",c"],"expected":["a,b","c"]},{"args":["\"a\"\"b\",,c"],"expected":["a\"b","","c"]},{"args":[",,"],"expected":["","",""]},{"args":["\"\""],"expected":[""]},{"args":["\"a,babb猫猫\",\"a\"\"\"\"\"\",\"\"猫ba\"\"\""],"expected":["a,babb猫猫","a\...
shortest-path-b0-s20
shortest-path
baseline
20,419,388
Implement solve(graph,start,target). graph maps string nodes to lists of [neighbor,nonnegative_integer_weight] directed edges. Return shortest distance, or None if unreachable. start==target returns 0. Nodes without a key have no outgoing edges. Examples (JSON args and expected result): [{"args": [{"0": [], "1": [], "2...
def solve(graph,start,target): return 0 if start == target else None
train
false
97
[{"args":[{},"a","a"],"expected":0},{"args":[{},"a","b"],"expected":null},{"args":[{"a":[["b",5],["c",1]],"c":[["b",1]]},"a","b"],"expected":2},{"args":[{"0":[],"1":[]},"0","1"],"expected":null},{"args":[{"0":[],"1":[["2",9]],"2":[]},"0","2"],"expected":null},{"args":[{"0":[["2",5],["4",8],["5",5],["6",6]],"1":[["0",2]...
shortest-path-b1-s20
shortest-path
farthest-first
20,419,388
Implement solve(graph,start,target). graph maps string nodes to lists of [neighbor,nonnegative_integer_weight] directed edges. Return shortest distance, or None if unreachable. start==target returns 0. Nodes without a key have no outgoing edges. Examples (JSON args and expected result): [{"args": [{"0": [["1", 7], ["2"...
def solve(graph,start,target): dist = {start:0} visited = set() while True: candidates = [n for n in dist if n not in visited] if not candidates: return None n = max(candidates,key=lambda x:dist[x]) if n == target: return dist[n] visited.add(n) for nxt,w in gr...
train
false
97
[{"args":[{},"a","a"],"expected":0},{"args":[{},"a","b"],"expected":null},{"args":[{"a":[["b",5],["c",1]],"c":[["b",1]]},"a","b"],"expected":2},{"args":[{"0":[],"1":[]},"0","1"],"expected":null},{"args":[{"0":[],"1":[["2",9]],"2":[]},"0","2"],"expected":null},{"args":[{"0":[["2",5],["4",8],["5",5],["6",6]],"1":[["0",2]...
shortest-path-b2-s20
shortest-path
lost-path-prefix
20,419,388
Implement solve(graph,start,target). graph maps string nodes to lists of [neighbor,nonnegative_integer_weight] directed edges. Return shortest distance, or None if unreachable. start==target returns 0. Nodes without a key have no outgoing edges. Examples (JSON args and expected result): [{"args": [{"0": [["2", 3]], "1"...
def solve(graph,start,target): dist = {start:0} visited = set() while True: candidates = [n for n in dist if n not in visited] if not candidates: return None n = min(candidates,key=lambda x:dist[x]) if n == target: return dist[n] visited.add(n) for nxt,w in gr...
train
false
97
[{"args":[{},"a","a"],"expected":0},{"args":[{},"a","b"],"expected":null},{"args":[{"a":[["b",5],["c",1]],"c":[["b",1]]},"a","b"],"expected":2},{"args":[{"0":[],"1":[]},"0","1"],"expected":null},{"args":[{"0":[],"1":[["2",9]],"2":[]},"0","2"],"expected":null},{"args":[{"0":[["2",5],["4",8],["5",5],["6",6]],"1":[["0",2]...
shortest-path-b3-s20
shortest-path
missing-relaxation
20,419,388
Implement solve(graph,start,target). graph maps string nodes to lists of [neighbor,nonnegative_integer_weight] directed edges. Return shortest distance, or None if unreachable. start==target returns 0. Nodes without a key have no outgoing edges. Examples (JSON args and expected result): [{"args": [{"0": [["4", 1], ["5"...
def solve(graph,start,target): dist = {start:0} visited = set() while True: candidates = [n for n in dist if n not in visited] if not candidates: return None n = min(candidates,key=lambda x:dist[x]) if n == target: return dist[n] visited.add(n) for nxt,w in gr...
train
false
97
[{"args":[{},"a","a"],"expected":0},{"args":[{},"a","b"],"expected":null},{"args":[{"a":[["b",5],["c",1]],"c":[["b",1]]},"a","b"],"expected":2},{"args":[{"0":[],"1":[]},"0","1"],"expected":null},{"args":[{"0":[],"1":[["2",9]],"2":[]},"0","2"],"expected":null},{"args":[{"0":[["2",5],["4",8],["5",5],["6",6]],"1":[["0",2]...
merge-intervals-b0-s21
merge-intervals
baseline
20,427,307
Implement solve(intervals). Merge closed intervals that overlap or touch, sort by start, and return lists [start,end]. Inputs may be unsorted; do not mutate them. Empty input returns []. Examples (JSON args and expected result): [{"args": [[[26, 27], [16, 19], [17, 18], [25, 31], [-11, -7]]], "expected": [[-11, -7], [1...
def solve(intervals): return sorted(intervals)
train
false
108
[{"args":[[]],"expected":[]},{"args":[[[1,4],[2,3],[4,8]]],"expected":[[1,8]]},{"args":[[[-3,3],[22,28],[-1,5],[-3,0],[-11,-4],[-18,-15]]],"expected":[[-18,-15],[-11,-4],[-3,5],[22,28]]},{"args":[[[18,25],[18,23],[17,19],[-17,-12],[9,15],[5,12]]],"expected":[[-17,-12],[5,15],[17,25]]},{"args":[[[1,2],[18,21],[-12,-10]]...
merge-intervals-b1-s21
merge-intervals
touching-boundary
20,427,307
Implement solve(intervals). Merge closed intervals that overlap or touch, sort by start, and return lists [start,end]. Inputs may be unsorted; do not mutate them. Empty input returns []. Examples (JSON args and expected result): [{"args": [[[29, 33], [-3, 4], [14, 15], [-7, -3], [19, 25], [-10, -10], [-5, -1], [-11, -1...
def solve(intervals): out = [] for a,b in sorted(intervals): if out and a < out[-1][1]: out[-1][1] = max(b, out[-1][1]) else: out.append([a,b]) return out
train
false
108
[{"args":[[]],"expected":[]},{"args":[[[1,4],[2,3],[4,8]]],"expected":[[1,8]]},{"args":[[[-3,3],[22,28],[-1,5],[-3,0],[-11,-4],[-18,-15]]],"expected":[[-18,-15],[-11,-4],[-3,5],[22,28]]},{"args":[[[18,25],[18,23],[17,19],[-17,-12],[9,15],[5,12]]],"expected":[[-17,-12],[5,15],[17,25]]},{"args":[[[1,2],[18,21],[-12,-10]]...
merge-intervals-b2-s21
merge-intervals
nested-endpoint
20,427,307
Implement solve(intervals). Merge closed intervals that overlap or touch, sort by start, and return lists [start,end]. Inputs may be unsorted; do not mutate them. Empty input returns []. Examples (JSON args and expected result): [{"args": [[[-17, -17], [2, 3], [-7, -1], [13, 14], [-3, 0], [2, 3], [6, 9], [3, 7], [24, 3...
def solve(intervals): out = [] for a,b in sorted(intervals): if out and a <= out[-1][1]: out[-1][1] = min(b, out[-1][1]) else: out.append([a,b]) return out
train
false
108
[{"args":[[]],"expected":[]},{"args":[[[1,4],[2,3],[4,8]]],"expected":[[1,8]]},{"args":[[[-3,3],[22,28],[-1,5],[-3,0],[-11,-4],[-18,-15]]],"expected":[[-18,-15],[-11,-4],[-3,5],[22,28]]},{"args":[[[18,25],[18,23],[17,19],[-17,-12],[9,15],[5,12]]],"expected":[[-17,-12],[5,15],[17,25]]},{"args":[[[1,2],[18,21],[-12,-10]]...
merge-intervals-b3-s21
merge-intervals
unsorted-input
20,427,307
Implement solve(intervals). Merge closed intervals that overlap or touch, sort by start, and return lists [start,end]. Inputs may be unsorted; do not mutate them. Empty input returns []. Examples (JSON args and expected result): [{"args": [[[-24, -19], [-27, -24]]], "expected": [[-27, -19]]}, {"args": [[[29, 34], [28, ...
def solve(intervals): out = [] for a,b in intervals: if out and a <= out[-1][1]: out[-1][1] = max(b, out[-1][1]) else: out.append([a,b]) return out
train
false
108
[{"args":[[]],"expected":[]},{"args":[[[1,4],[2,3],[4,8]]],"expected":[[1,8]]},{"args":[[[-3,3],[22,28],[-1,5],[-3,0],[-11,-4],[-18,-15]]],"expected":[[-18,-15],[-11,-4],[-3,5],[22,28]]},{"args":[[[18,25],[18,23],[17,19],[-17,-12],[9,15],[5,12]]],"expected":[[-17,-12],[5,15],[17,25]]},{"args":[[[1,2],[18,21],[-12,-10]]...
moving-sums-b0-s21
moving-sums
baseline
20,427,307
Implement solve(values,k). Return sums of every contiguous window of length k. k<=0 or k>len(values) returns []. Examples (JSON args and expected result): [{"args": [[46, -32, -6, 46, -77, -59], 17], "expected": []}, {"args": [[-73, 0, 14], -1], "expected": []}, {"args": [[-3, 88, -18, 45, -64, 74, 5, 48, 82, 55, -80, ...
def solve(values,k): return [sum(values[i:i+k]) for i in range(len(values)-k)]
train
false
144
[{"args":[[],1],"expected":[]},{"args":[[1,2,3],2],"expected":[3,5]},{"args":[[5],1],"expected":[5]},{"args":[[1],0],"expected":[]},{"args":[[50,71,-93,16,75,0,31,45],12],"expected":[]},{"args":[[33,21,-51,34,45,-62,-55,-19,-99,33,33,-77,87],21],"expected":[]},{"args":[[-38,-29,-46,-45,39,-16,35,-41,39,-36,-3,-46,-11,8...
moving-sums-b1-s21
moving-sums
zero-window
20,427,307
Implement solve(values,k). Return sums of every contiguous window of length k. k<=0 or k>len(values) returns []. Examples (JSON args and expected result): [{"args": [[98, 75, 46], 11], "expected": []}, {"args": [[-19, -24, 12, -22, -27, -13], 1], "expected": [-19, -24, 12, -22, -27, -13]}, {"args": [[-65, -80, -85, 24,...
def solve(values,k): if k < 0 or k > len(values): return [] return [sum(values[i:i+k]) for i in range(len(values)-k+1)]
train
false
144
[{"args":[[],1],"expected":[]},{"args":[[1,2,3],2],"expected":[3,5]},{"args":[[5],1],"expected":[5]},{"args":[[1],0],"expected":[]},{"args":[[50,71,-93,16,75,0,31,45],12],"expected":[]},{"args":[[33,21,-51,34,45,-62,-55,-19,-99,33,33,-77,87],21],"expected":[]},{"args":[[-38,-29,-46,-45,39,-16,35,-41,39,-36,-3,-46,-11,8...
moving-sums-b2-s21
moving-sums
window-width
20,427,307
Implement solve(values,k). Return sums of every contiguous window of length k. k<=0 or k>len(values) returns []. Examples (JSON args and expected result): [{"args": [[98, 30], -1], "expected": []}, {"args": [[25, 64, -54, -75, 7, 89, 92, 62, -47, 54, -49, -71, -82, 34, -7], 22], "expected": []}, {"args": [[1, -69, 91, ...
def solve(values,k): if k <= 0 or k > len(values): return [] return [sum(values[i:i+k-1]) for i in range(len(values)-k+1)]
train
false
144
[{"args":[[],1],"expected":[]},{"args":[[1,2,3],2],"expected":[3,5]},{"args":[[5],1],"expected":[5]},{"args":[[1],0],"expected":[]},{"args":[[50,71,-93,16,75,0,31,45],12],"expected":[]},{"args":[[33,21,-51,34,45,-62,-55,-19,-99,33,33,-77,87],21],"expected":[]},{"args":[[-38,-29,-46,-45,39,-16,35,-41,39,-36,-3,-46,-11,8...
moving-sums-b3-s21
moving-sums
missing-first-window
20,427,307
Implement solve(values,k). Return sums of every contiguous window of length k. k<=0 or k>len(values) returns []. Examples (JSON args and expected result): [{"args": [[1, 11, -30], 0], "expected": []}, {"args": [[], 22], "expected": []}, {"args": [[-17, 8, -12, -22, -30, -4, -29, 11, 27, 10], 1], "expected": [-17, 8, -1...
def solve(values,k): if k <= 0 or k > len(values): return [] return [sum(values[i:i+k]) for i in range(1,len(values)-k+1)]
train
false
144
[{"args":[[],1],"expected":[]},{"args":[[1,2,3],2],"expected":[3,5]},{"args":[[5],1],"expected":[5]},{"args":[[1],0],"expected":[]},{"args":[[50,71,-93,16,75,0,31,45],12],"expected":[]},{"args":[[33,21,-51,34,45,-62,-55,-19,-99,33,33,-77,87],21],"expected":[]},{"args":[[-38,-29,-46,-45,39,-16,35,-41,39,-36,-3,-46,-11,8...
weighted-mean-b0-s21
weighted-mean
baseline
20,427,307
Implement solve(values,weights). Inputs have equal length and nonnegative weights. Return weighted arithmetic mean; return None if total weight is zero (including empty inputs). Examples (JSON args and expected result): [{"args": [[-44, -28, -17, 8, 40, 19, 3, -46, -26], [5, 0, 3, 5, 5, 5, 0, 5, 5]], "expected": -8.969...
def solve(values,weights): return sum(values)/len(values) if values else None
train
false
119
[{"args":[[],[]],"expected":null},{"args":[[2,10],[0,1]],"expected":10.0},{"args":[[2],[0]],"expected":null},{"args":[[38,31,23,7,37,22,-49,17,47,31,17,-7,7,-12,18,-34],[2,2,0,2,4,4,4,1,5,4,4,5,2,5,3,4]],"expected":9.27450980392157},{"args":[[25,31,-41,27,-2,-48,33,-10,-22,-31],[5,1,0,3,0,4,5,5,4,5]],"expected":-2.5937...
weighted-mean-b1-s21
weighted-mean
unweighted-numerator
20,427,307
Implement solve(values,weights). Inputs have equal length and nonnegative weights. Return weighted arithmetic mean; return None if total weight is zero (including empty inputs). Examples (JSON args and expected result): [{"args": [[34, 29, -7, 43, -2, -29, -37, -17, 8, 42, 5, 35, -23], [0, 1, 3, 0, 5, 0, 1, 3, 1, 1, 2,...
def solve(values,weights): total = sum(weights) return sum(x for x,w in zip(values,weights))/total if total else None
train
false
119
[{"args":[[],[]],"expected":null},{"args":[[2,10],[0,1]],"expected":10.0},{"args":[[2],[0]],"expected":null},{"args":[[38,31,23,7,37,22,-49,17,47,31,17,-7,7,-12,18,-34],[2,2,0,2,4,4,4,1,5,4,4,5,2,5,3,4]],"expected":9.27450980392157},{"args":[[25,31,-41,27,-2,-48,33,-10,-22,-31],[5,1,0,3,0,4,5,5,4,5]],"expected":-2.5937...
weighted-mean-b2-s21
weighted-mean
wrong-denominator
20,427,307
Implement solve(values,weights). Inputs have equal length and nonnegative weights. Return weighted arithmetic mean; return None if total weight is zero (including empty inputs). Examples (JSON args and expected result): [{"args": [[14, 27, -25, -17, 2, -28, 47, -23, 42, -41, 25, 47, -3, 33, -9, 48, 34, 2, -14], [1, 5, ...
def solve(values,weights): total = len(weights) return sum(x*w for x,w in zip(values,weights))/total if total else None
train
false
119
[{"args":[[],[]],"expected":null},{"args":[[2,10],[0,1]],"expected":10.0},{"args":[[2],[0]],"expected":null},{"args":[[38,31,23,7,37,22,-49,17,47,31,17,-7,7,-12,18,-34],[2,2,0,2,4,4,4,1,5,4,4,5,2,5,3,4]],"expected":9.27450980392157},{"args":[[25,31,-41,27,-2,-48,33,-10,-22,-31],[5,1,0,3,0,4,5,5,4,5]],"expected":-2.5937...
weighted-mean-b3-s21
weighted-mean
zero-weight-result
20,427,307
Implement solve(values,weights). Inputs have equal length and nonnegative weights. Return weighted arithmetic mean; return None if total weight is zero (including empty inputs). Examples (JSON args and expected result): [{"args": [[22, 29], [0, 0]], "expected": null}, {"args": [[9, -41, 48, 46, 26, -6, -8, 44, -5, -18,...
def solve(values,weights): total = sum(weights) return sum(x*w for x,w in zip(values,weights))/total if total else 0
train
false
119
[{"args":[[],[]],"expected":null},{"args":[[2,10],[0,1]],"expected":10.0},{"args":[[2],[0]],"expected":null},{"args":[[38,31,23,7,37,22,-49,17,47,31,17,-7,7,-12,18,-34],[2,2,0,2,4,4,4,1,5,4,4,5,2,5,3,4]],"expected":9.27450980392157},{"args":[[25,31,-41,27,-2,-48,33,-10,-22,-31],[5,1,0,3,0,4,5,5,4,5]],"expected":-2.5937...
stable-unique-b0-s21
stable-unique
baseline
20,427,307
Implement solve(values). Deduplicate integer values while preserving first occurrence order. Empty list stays empty. Examples (JSON args and expected result): [{"args": [[5, -8, 6, 6, 5, 4, 1, 3, 0, 5, -1, -6, -9, -10, -8, 6, 6, 5, -2, -7, -8, 1, -9, 9, -10, 2, -4, 5, 2]], "expected": [5, -8, 6, 4, 1, 3, 0, -1, -6, -9,...
def solve(values): return sorted(set(values))
train
false
93
[{"args":[[]],"expected":[]},{"args":[[3,1,3,2,1]],"expected":[3,1,2]},{"args":[[-8,-10,3,10,-7]],"expected":[-8,-10,3,10,-7]},{"args":[[2,2,9,-1,-10,-4,3]],"expected":[2,9,-1,-10,-4,3]},{"args":[[-3,3,10,9,-1]],"expected":[-3,3,10,9,-1]},{"args":[[5,-2,-6,3,-3,4]],"expected":[5,-2,-6,3,-3,4]},{"args":[[6,-4,1,-7,4,9,7...
stable-unique-b1-s21
stable-unique
reverse-traversal
20,427,307
Implement solve(values). Deduplicate integer values while preserving first occurrence order. Empty list stays empty. Examples (JSON args and expected result): [{"args": [[-1, 6, -10, 0, 3, -3, 1, -10, -4, -2, 8, 6, 9, -10, -5, -3, 4, -9]], "expected": [-1, 6, -10, 0, 3, -3, 1, -4, -2, 8, 9, -5, 4, -9]}, {"args": [[-5, ...
def solve(values): seen = set() out = [] for x in reversed(values): if x not in seen: seen.add(x) out.append(x) return out
train
false
93
[{"args":[[]],"expected":[]},{"args":[[3,1,3,2,1]],"expected":[3,1,2]},{"args":[[-8,-10,3,10,-7]],"expected":[-8,-10,3,10,-7]},{"args":[[2,2,9,-1,-10,-4,3]],"expected":[2,9,-1,-10,-4,3]},{"args":[[-3,3,10,9,-1]],"expected":[-3,3,10,9,-1]},{"args":[[5,-2,-6,3,-3,4]],"expected":[5,-2,-6,3,-3,4]},{"args":[[6,-4,1,-7,4,9,7...
stable-unique-b2-s21
stable-unique
reverse-output
20,427,307
Implement solve(values). Deduplicate integer values while preserving first occurrence order. Empty list stays empty. Examples (JSON args and expected result): [{"args": [[-5, 9, 5, -10, -8, 5, -7, -7, 10, 1, 4, 10, 7, -7, -4, -2, -2, -4, 8, 0, 8, 0]], "expected": [-5, 9, 5, -10, -8, -7, 10, 1, 4, 7, -4, -2, 8, 0]}, {"a...
def solve(values): seen = set() out = [] for x in values: if x not in seen: seen.add(x) out.insert(0,x) return out
train
false
93
[{"args":[[]],"expected":[]},{"args":[[3,1,3,2,1]],"expected":[3,1,2]},{"args":[[-8,-10,3,10,-7]],"expected":[-8,-10,3,10,-7]},{"args":[[2,2,9,-1,-10,-4,3]],"expected":[2,9,-1,-10,-4,3]},{"args":[[-3,3,10,9,-1]],"expected":[-3,3,10,9,-1]},{"args":[[5,-2,-6,3,-3,4]],"expected":[5,-2,-6,3,-3,4]},{"args":[[6,-4,1,-7,4,9,7...
stable-unique-b3-s21
stable-unique
wrong-seen-value
20,427,307
Implement solve(values). Deduplicate integer values while preserving first occurrence order. Empty list stays empty. Examples (JSON args and expected result): [{"args": [[-7, -1, -6, 4, -9, 9, -6, 4, 10, 10, -8, -10, -4, -6, 10, -7, 5, 1, -5, -3, 2, -9, -10, -8, 8, -8, 7]], "expected": [-7, -1, -6, 4, -9, 9, 10, -8, -1...
def solve(values): seen = set() out = [] for x in values: if x not in seen: seen.add(-x) out.append(x) return out
train
true
93
[{"args":[[]],"expected":[]},{"args":[[3,1,3,2,1]],"expected":[3,1,2]},{"args":[[-8,-10,3,10,-7]],"expected":[-8,-10,3,10,-7]},{"args":[[2,2,9,-1,-10,-4,3]],"expected":[2,9,-1,-10,-4,3]},{"args":[[-3,3,10,9,-1]],"expected":[-3,3,10,9,-1]},{"args":[[5,-2,-6,3,-3,4]],"expected":[5,-2,-6,3,-3,4]},{"args":[[6,-4,1,-7,4,9,7...
run-length-b0-s21
run-length
baseline
20,427,307
Implement solve(text). Run-length encode consecutive Unicode characters as a list of [character,count] pairs. Empty text returns []. Nonadjacent occurrences remain separate. Examples (JSON args and expected result): [{"args": ["c🙂猫a🙂 cb猫a"], "expected": [["c", 1], ["🙂", 1], ["猫", 1], ["a", 1], ["🙂", 1], [" ", 1], [...
def solve(text): return [[c,text.count(c)] for c in sorted(set(text))]
train
false
100
[{"args":[""],"expected":[]},{"args":["aabbaa"],"expected":[["a",2],["b",2],["a",2]]},{"args":["猫猫🙂🙂猫"],"expected":[["猫",2],["🙂",2],["猫",1]]},{"args":["aa🙂bac猫c"],"expected":[["a",2],["🙂",1],["b",1],["a",1],["c",1],["猫",1],["c",1]]},{"args":["猫cbbcbb🙂 aa猫 a猫猫c🙂abc猫abbca🙂aa a🙂a"],"expected":[["猫",1],["c",1],["b...
run-length-b1-s21
run-length
inverted-grouping
20,427,307
Implement solve(text). Run-length encode consecutive Unicode characters as a list of [character,count] pairs. Empty text returns []. Nonadjacent occurrences remain separate. Examples (JSON args and expected result): [{"args": [" abb猫bbcaca"], "expected": [[" ", 1], ["a", 1], ["b", 2], ["猫", 1], ["b", 2], ["c", 1], ["a"...
def solve(text): out = [] for c in text: if out and out[-1][0] != c: out[-1][1] += 1 else: out.append([c,1]) return out
train
false
100
[{"args":[""],"expected":[]},{"args":["aabbaa"],"expected":[["a",2],["b",2],["a",2]]},{"args":["猫猫🙂🙂猫"],"expected":[["猫",2],["🙂",2],["猫",1]]},{"args":["aa🙂bac猫c"],"expected":[["a",2],["🙂",1],["b",1],["a",1],["c",1],["猫",1],["c",1]]},{"args":["猫cbbcbb🙂 aa猫 a猫猫c🙂abc猫abbca🙂aa a🙂a"],"expected":[["猫",1],["c",1],["b...
run-length-b2-s21
run-length
double-increment
20,427,307
Implement solve(text). Run-length encode consecutive Unicode characters as a list of [character,count] pairs. Empty text returns []. Nonadjacent occurrences remain separate. Examples (JSON args and expected result): [{"args": ["bbba c 🙂b"], "expected": [["b", 3], ["a", 1], [" ", 1], ["c", 1], [" ", 2], ["🙂", 1], ["b...
def solve(text): out = [] for c in text: if out and out[-1][0] == c: out[-1][1] += 2 else: out.append([c,1]) return out
train
false
100
[{"args":[""],"expected":[]},{"args":["aabbaa"],"expected":[["a",2],["b",2],["a",2]]},{"args":["猫猫🙂🙂猫"],"expected":[["猫",2],["🙂",2],["猫",1]]},{"args":["aa🙂bac猫c"],"expected":[["a",2],["🙂",1],["b",1],["a",1],["c",1],["猫",1],["c",1]]},{"args":["猫cbbcbb🙂 aa猫 a猫猫c🙂abc猫abbca🙂aa a🙂a"],"expected":[["猫",1],["c",1],["b...
run-length-b3-s21
run-length
zero-initial-count
20,427,307
Implement solve(text). Run-length encode consecutive Unicode characters as a list of [character,count] pairs. Empty text returns []. Nonadjacent occurrences remain separate. Examples (JSON args and expected result): [{"args": ["🙂猫bac🙂bac cbc bb🙂bba 猫"], "expected": [["🙂", 1], ["猫", 1], ["b", 1], ["a", 1], ["c", 1],...
def solve(text): out = [] for c in text: if out and out[-1][0] == c: out[-1][1] += 1 else: out.append([c,0]) return out
train
false
100
[{"args":[""],"expected":[]},{"args":["aabbaa"],"expected":[["a",2],["b",2],["a",2]]},{"args":["猫猫🙂🙂猫"],"expected":[["猫",2],["🙂",2],["猫",1]]},{"args":["aa🙂bac猫c"],"expected":[["a",2],["🙂",1],["b",1],["a",1],["c",1],["猫",1],["c",1]]},{"args":["猫cbbcbb🙂 aa猫 a猫猫c🙂abc猫abbca🙂aa a🙂a"],"expected":[["猫",1],["c",1],["b...
luhn-b0-s21
luhn
baseline
20,427,307
Implement solve(text). Return whether a nonempty ASCII digit string satisfies the Luhn checksum: starting from right, double every second digit, subtract 9 if >9, and require total divisible by 10. Nondigits/empty input return False. Examples (JSON args and expected result): [{"args": ["1512"], "expected": false}, {"ar...
def solve(text): return bool(text) and text.isdigit() and sum(int(c) for c in text)%10 == 0
train
false
188
[{"args":[""],"expected":false},{"args":["0"],"expected":true},{"args":["79927398713"],"expected":true},{"args":["79927398714"],"expected":false},{"args":["12x"],"expected":false},{"args":[" 0"],"expected":false},{"args":["12"],"expected":false},{"args":["0000"],"expected":true},{"args":["083072"],"expected":false},{"a...
luhn-b1-s21
luhn
wrong-parity
20,427,307
Implement solve(text). Return whether a nonempty ASCII digit string satisfies the Luhn checksum: starting from right, double every second digit, subtract 9 if >9, and require total divisible by 10. Nondigits/empty input return False. Examples (JSON args and expected result): [{"args": ["52480008228"], "expected": false...
def solve(text): if not text or any(c not in '0123456789' for c in text): return False total = 0 for i,c in enumerate(reversed(text)): v = int(c) if not i%2: v *= 2 if v > 9: v -= 9 total += v return total%10 == 0
train
false
188
[{"args":[""],"expected":false},{"args":["0"],"expected":true},{"args":["79927398713"],"expected":true},{"args":["79927398714"],"expected":false},{"args":["12x"],"expected":false},{"args":[" 0"],"expected":false},{"args":["12"],"expected":false},{"args":["0000"],"expected":true},{"args":["083072"],"expected":false},{"a...
luhn-b2-s21
luhn
wrong-reduction
20,427,307
Implement solve(text). Return whether a nonempty ASCII digit string satisfies the Luhn checksum: starting from right, double every second digit, subtract 9 if >9, and require total divisible by 10. Nondigits/empty input return False. Examples (JSON args and expected result): [{"args": ["5433828641926"], "expected": tru...
def solve(text): if not text or any(c not in '0123456789' for c in text): return False total = 0 for i,c in enumerate(reversed(text)): v = int(c) if i%2: v *= 2 if v > 9: v -= 8 total += v return total%10 == 0
train
false
188
[{"args":[""],"expected":false},{"args":["0"],"expected":true},{"args":["79927398713"],"expected":true},{"args":["79927398714"],"expected":false},{"args":["12x"],"expected":false},{"args":[" 0"],"expected":false},{"args":["12"],"expected":false},{"args":["0000"],"expected":true},{"args":["083072"],"expected":false},{"a...
luhn-b3-s21
luhn
wrong-modulus
20,427,307
Implement solve(text). Return whether a nonempty ASCII digit string satisfies the Luhn checksum: starting from right, double every second digit, subtract 9 if >9, and require total divisible by 10. Nondigits/empty input return False. Examples (JSON args and expected result): [{"args": ["13287388"], "expected": true}, {...
def solve(text): if not text or any(c not in '0123456789' for c in text): return False total = 0 for i,c in enumerate(reversed(text)): v = int(c) if i%2: v *= 2 if v > 9: v -= 9 total += v return total%9 == 0
train
false
188
[{"args":[""],"expected":false},{"args":["0"],"expected":true},{"args":["79927398713"],"expected":true},{"args":["79927398714"],"expected":false},{"args":["12x"],"expected":false},{"args":[" 0"],"expected":false},{"args":["12"],"expected":false},{"args":["0000"],"expected":true},{"args":["083072"],"expected":false},{"a...
edit-distance-b0-s21
edit-distance
baseline
20,427,307
Implement solve(a,b). Return Levenshtein edit distance with unit-cost insertion, deletion, and substitution over Unicode characters. Examples (JSON args and expected result): [{"args": ["猫bccbcba", "猫bccbcba"], "expected": 0}, {"args": ["", "c猫acb"], "expected": 5}, {"args": ["badca猫猫d", "adb猫b猫bab"], "expected": 7}]
def solve(a,b): return abs(len(a)-len(b))
train
false
140
[{"args":["",""],"expected":0},{"args":["kitten","sitting"],"expected":3},{"args":["猫","狗"],"expected":1},{"args":["dbdb猫猫猫aa猫c","ad猫猫"],"expected":8},{"args":["abca","b猫cbdcd"],"expected":5},{"args":["abcdcab","猫caa"],"expected":5},{"args":["c","猫ccad猫ddb猫b"],"expected":10},{"args":["","猫"],"expected":1},{"args":["dba...
edit-distance-b1-s21
edit-distance
row-boundary
20,427,307
Implement solve(a,b). Return Levenshtein edit distance with unit-cost insertion, deletion, and substitution over Unicode characters. Examples (JSON args and expected result): [{"args": ["d猫dcda猫a", "d猫"], "expected": 6}, {"args": ["abc", "cba"], "expected": 2}, {"args": ["猫", "猫猫dcddaa"], "expected": 7}]
def solve(a,b): row = list(range(len(b)+1)) for i,x in enumerate(a,1): nxt = [0] for j,y in enumerate(b,1): nxt.append(min(nxt[-1]+1,row[j]+1,row[j-1]+(x != y))) row = nxt return row[-1]
train
false
140
[{"args":["",""],"expected":0},{"args":["kitten","sitting"],"expected":3},{"args":["猫","狗"],"expected":1},{"args":["dbdb猫猫猫aa猫c","ad猫猫"],"expected":8},{"args":["abca","b猫cbdcd"],"expected":5},{"args":["abcdcab","猫caa"],"expected":5},{"args":["c","猫ccad猫ddb猫b"],"expected":10},{"args":["","猫"],"expected":1},{"args":["dba...
edit-distance-b2-s21
edit-distance
inverted-substitution
20,427,307
Implement solve(a,b). Return Levenshtein edit distance with unit-cost insertion, deletion, and substitution over Unicode characters. Examples (JSON args and expected result): [{"args": ["abb猫baa猫b", "cbcdbda猫cdc"], "expected": 7}, {"args": ["c", ""], "expected": 1}, {"args": ["dbca", ""], "expected": 4}]
def solve(a,b): row = list(range(len(b)+1)) for i,x in enumerate(a,1): nxt = [i] for j,y in enumerate(b,1): nxt.append(min(nxt[-1]+1,row[j]+1,row[j-1]+(x == y))) row = nxt return row[-1]
train
false
140
[{"args":["",""],"expected":0},{"args":["kitten","sitting"],"expected":3},{"args":["猫","狗"],"expected":1},{"args":["dbdb猫猫猫aa猫c","ad猫猫"],"expected":8},{"args":["abca","b猫cbdcd"],"expected":5},{"args":["abcdcab","猫caa"],"expected":5},{"args":["c","猫ccad猫ddb猫b"],"expected":10},{"args":["","猫"],"expected":1},{"args":["dba...
edit-distance-b3-s21
edit-distance
diagonal-index
20,427,307
Implement solve(a,b). Return Levenshtein edit distance with unit-cost insertion, deletion, and substitution over Unicode characters. Examples (JSON args and expected result): [{"args": ["cb猫猫caaa", ""], "expected": 8}, {"args": ["ccb猫猫db", "d猫acbb"], "expected": 6}, {"args": ["ccbcbabba", "ccbcbabba"], "expected": 0}]
def solve(a,b): row = list(range(len(b)+1)) for i,x in enumerate(a,1): nxt = [i] for j,y in enumerate(b,1): nxt.append(min(nxt[-1]+1,row[j]+1,row[j]+(x != y))) row = nxt return row[-1]
train
false
140
[{"args":["",""],"expected":0},{"args":["kitten","sitting"],"expected":3},{"args":["猫","狗"],"expected":1},{"args":["dbdb猫猫猫aa猫c","ad猫猫"],"expected":8},{"args":["abca","b猫cbdcd"],"expected":5},{"args":["abcdcab","猫caa"],"expected":5},{"args":["c","猫ccad猫ddb猫b"],"expected":10},{"args":["","猫"],"expected":1},{"args":["dba...
meeting-rooms-b0-s21
meeting-rooms
baseline
20,427,307
Implement solve(intervals). Return minimum rooms for positive-length half-open meetings [start,end). A meeting ending at time t frees its room for one starting at t. Empty input returns 0. Examples (JSON args and expected result): [{"args": [[[10, 14], [2, 3], [3, 8], [4, 7], [12, 16], [18, 26], [18, 24], [3, 6], [11, ...
def solve(intervals): return len(intervals)
train
false
113
[{"args":[[]],"expected":0},{"args":[[[0,1],[1,2]]],"expected":1},{"args":[[[0,5],[1,3],[2,4]]],"expected":3},{"args":[[[11,13],[17,25],[8,11],[12,19],[15,19],[9,12],[0,8],[18,26],[4,12],[13,14],[0,6]]],"expected":4},{"args":[[[10,16],[16,21],[2,5],[8,15],[19,27],[17,23],[6,8],[19,27],[7,9]]],"expected":4},{"args":[[[1...
meeting-rooms-b1-s21
meeting-rooms
tie-order
20,427,307
Implement solve(intervals). Return minimum rooms for positive-length half-open meetings [start,end). A meeting ending at time t frees its room for one starting at t. Empty input returns 0. Examples (JSON args and expected result): [{"args": [[[1, 8], [15, 22], [8, 15], [12, 20], [0, 6]]], "expected": 2}, {"args": [[[8,...
def solve(intervals): events = [] for a,b in intervals: events.append([a,1]) events.append([b,-1]) active = best = 0 for t,d in sorted(events,key=lambda item:(item[0],-item[1])): active += d best = max(best,active) return best
train
false
113
[{"args":[[]],"expected":0},{"args":[[[0,1],[1,2]]],"expected":1},{"args":[[[0,5],[1,3],[2,4]]],"expected":3},{"args":[[[11,13],[17,25],[8,11],[12,19],[15,19],[9,12],[0,8],[18,26],[4,12],[13,14],[0,6]]],"expected":4},{"args":[[[10,16],[16,21],[2,5],[8,15],[19,27],[17,23],[6,8],[19,27],[7,9]]],"expected":4},{"args":[[[1...
meeting-rooms-b2-s21
meeting-rooms
peak-tracking
20,427,307
Implement solve(intervals). Return minimum rooms for positive-length half-open meetings [start,end). A meeting ending at time t frees its room for one starting at t. Empty input returns 0. Examples (JSON args and expected result): [{"args": [[[14, 15], [4, 12], [2, 3], [9, 14], [16, 20], [12, 14], [8, 13]]], "expected"...
def solve(intervals): events = [] for a,b in intervals: events.append([a,1]) events.append([b,-1]) active = best = 0 for t,d in sorted(events): active += d best = min(best,active) return best
train
false
113
[{"args":[[]],"expected":0},{"args":[[[0,1],[1,2]]],"expected":1},{"args":[[[0,5],[1,3],[2,4]]],"expected":3},{"args":[[[11,13],[17,25],[8,11],[12,19],[15,19],[9,12],[0,8],[18,26],[4,12],[13,14],[0,6]]],"expected":4},{"args":[[[10,16],[16,21],[2,5],[8,15],[19,27],[17,23],[6,8],[19,27],[7,9]]],"expected":4},{"args":[[[1...
meeting-rooms-b3-s21
meeting-rooms
end-event-sign
20,427,307
Implement solve(intervals). Return minimum rooms for positive-length half-open meetings [start,end). A meeting ending at time t frees its room for one starting at t. Empty input returns 0. Examples (JSON args and expected result): [{"args": [[[2, 3], [5, 9], [12, 15], [2, 6], [10, 15], [13, 14]]], "expected": 3}, {"arg...
def solve(intervals): events = [] for a,b in intervals: events.append([a,1]) events.append([b,1]) active = best = 0 for t,d in sorted(events): active += d best = max(best,active) return best
train
false
113
[{"args":[[]],"expected":0},{"args":[[[0,1],[1,2]]],"expected":1},{"args":[[[0,5],[1,3],[2,4]]],"expected":3},{"args":[[[11,13],[17,25],[8,11],[12,19],[15,19],[9,12],[0,8],[18,26],[4,12],[13,14],[0,6]]],"expected":4},{"args":[[[10,16],[16,21],[2,5],[8,15],[19,27],[17,23],[6,8],[19,27],[7,9]]],"expected":4},{"args":[[[1...
nearest-percentile-b0-s21
nearest-percentile
baseline
20,427,307
Implement solve(values,p). Return nearest-rank percentile: sort ascending and take 1-based rank max(1,ceil(p/100*n)). p is integer 0..100. Empty input returns None. Examples (JSON args and expected result): [{"args": [[-44, 23, -50, -5, 22, -30, -77, -69, -96, -49, 12, 21], 50], "expected": -44}, {"args": [[-12, -81, -...
def solve(values,p): return sorted(values)[int(p/100*len(values))] if values else None
train
false
144
[{"args":[[],50],"expected":null},{"args":[[1,2,3,4],100],"expected":4},{"args":[[1,2,3,4],50],"expected":2},{"args":[[4],0],"expected":4},{"args":[[80,-84,88,-6,-80,27,66,-89,71,-67,36,-78,56,-31,76,-13,-6,-28,-41,-83],50],"expected":-13},{"args":[[100,85,68,-91,-99,4,27,-48,-16,16,37,35,-82,3],100],"expected":100},{"...
nearest-percentile-b1-s21
nearest-percentile
floor-not-ceiling
20,427,307
Implement solve(values,p). Return nearest-rank percentile: sort ascending and take 1-based rank max(1,ceil(p/100*n)). p is integer 0..100. Empty input returns None. Examples (JSON args and expected result): [{"args": [[-70, 100, 59, 95, -91, 19, 6, -52, -20, -38], 100], "expected": 100}, {"args": [[29, 16, 17, 12, 18, ...
def solve(values,p): if not values: return None rank = max(1,(p*len(values)+0)//100) return sorted(values)[rank-1]
train
true
144
[{"args":[[],50],"expected":null},{"args":[[1,2,3,4],100],"expected":4},{"args":[[1,2,3,4],50],"expected":2},{"args":[[4],0],"expected":4},{"args":[[80,-84,88,-6,-80,27,66,-89,71,-67,36,-78,56,-31,76,-13,-6,-28,-41,-83],50],"expected":-13},{"args":[[100,85,68,-91,-99,4,27,-48,-16,16,37,35,-82,3],100],"expected":100},{"...
nearest-percentile-b2-s21
nearest-percentile
rank-index
20,427,307
Implement solve(values,p). Return nearest-rank percentile: sort ascending and take 1-based rank max(1,ceil(p/100*n)). p is integer 0..100. Empty input returns None. Examples (JSON args and expected result): [{"args": [[-29, -74], 100], "expected": -29}, {"args": [[74, 92, -98, -47, 97, -9, -19, 89, 19, -51], 100], "exp...
def solve(values,p): if not values: return None rank = max(1,(p*len(values)+99)//100) return sorted(values)[rank-2]
train
false
144
[{"args":[[],50],"expected":null},{"args":[[1,2,3,4],100],"expected":4},{"args":[[1,2,3,4],50],"expected":2},{"args":[[4],0],"expected":4},{"args":[[80,-84,88,-6,-80,27,66,-89,71,-67,36,-78,56,-31,76,-13,-6,-28,-41,-83],50],"expected":-13},{"args":[[100,85,68,-91,-99,4,27,-48,-16,16,37,35,-82,3],100],"expected":100},{"...
nearest-percentile-b3-s21
nearest-percentile
descending-order
20,427,307
Implement solve(values,p). Return nearest-rank percentile: sort ascending and take 1-based rank max(1,ceil(p/100*n)). p is integer 0..100. Empty input returns None. Examples (JSON args and expected result): [{"args": [[-1, 8, 6, -2, 5, 14, 1, 3, 13, 4, 12, 7, 9, 0, 10, 11, 2], 33], "expected": 3}, {"args": [[72, 9, 0, ...
def solve(values,p): if not values: return None rank = max(1,(p*len(values)+99)//100) return sorted(values,reverse=True)[rank-1]
train
false
144
[{"args":[[],50],"expected":null},{"args":[[1,2,3,4],100],"expected":4},{"args":[[1,2,3,4],50],"expected":2},{"args":[[4],0],"expected":4},{"args":[[80,-84,88,-6,-80,27,66,-89,71,-67,36,-78,56,-31,76,-13,-6,-28,-41,-83],50],"expected":-13},{"args":[[100,85,68,-91,-99,4,27,-48,-16,16,37,35,-82,3],100],"expected":100},{"...
fifo-inventory-b0-s21
fifo-inventory
baseline
20,427,307
Implement solve(lots,demand). lots are [quantity,unit_price_cents] in purchase order with nonnegative integers. Return [cost_cents,remaining_lots] after fulfilling demand FIFO, dropping zero-quantity lots. If inventory cannot cover demand, return None. Do not mutate input; demand>=0. Examples (JSON args and expected re...
def solve(lots,demand): return [0,lots]
train
false
123
[{"args":[[],0],"expected":[0,[]]},{"args":[[],1],"expected":null},{"args":[[[2,100],[3,200]],3],"expected":[400,[[2,200]]]},{"args":[[[0,50],[2,80]],0],"expected":[0,[[2,80]]]},{"args":[[[2,103],[4,719],[5,427],[7,940],[2,38],[6,846]],31],"expected":null},{"args":[[[7,641],[5,80]],7],"expected":[4487,[[5,80]]]},{"args...
fifo-inventory-b1-s21
fifo-inventory
zero-lot-retention
20,427,307
Implement solve(lots,demand). lots are [quantity,unit_price_cents] in purchase order with nonnegative integers. Return [cost_cents,remaining_lots] after fulfilling demand FIFO, dropping zero-quantity lots. If inventory cannot cover demand, return None. Do not mutate input; demand>=0. Examples (JSON args and expected re...
def solve(lots,demand): if sum(q for q,p in lots) < demand: return None remaining = [] cost = 0 for q,p in lots: used = min(q,demand) demand -= used cost += used*p if q >= used: remaining.append([q-used,p]) return [cost,remaining]
train
false
123
[{"args":[[],0],"expected":[0,[]]},{"args":[[],1],"expected":null},{"args":[[[2,100],[3,200]],3],"expected":[400,[[2,200]]]},{"args":[[[0,50],[2,80]],0],"expected":[0,[[2,80]]]},{"args":[[[2,103],[4,719],[5,427],[7,940],[2,38],[6,846]],31],"expected":null},{"args":[[[7,641],[5,80]],7],"expected":[4487,[[5,80]]]},{"args...
fifo-inventory-b2-s21
fifo-inventory
over-consumption
20,427,307
Implement solve(lots,demand). lots are [quantity,unit_price_cents] in purchase order with nonnegative integers. Return [cost_cents,remaining_lots] after fulfilling demand FIFO, dropping zero-quantity lots. If inventory cannot cover demand, return None. Do not mutate input; demand>=0. Examples (JSON args and expected re...
def solve(lots,demand): if sum(q for q,p in lots) < demand: return None remaining = [] cost = 0 for q,p in lots: used = max(q,demand) demand -= used cost += used*p if q-used: remaining.append([q-used,p]) return [cost,remaining]
train
false
123
[{"args":[[],0],"expected":[0,[]]},{"args":[[],1],"expected":null},{"args":[[[2,100],[3,200]],3],"expected":[400,[[2,200]]]},{"args":[[[0,50],[2,80]],0],"expected":[0,[[2,80]]]},{"args":[[[2,103],[4,719],[5,427],[7,940],[2,38],[6,846]],31],"expected":null},{"args":[[[7,641],[5,80]],7],"expected":[4487,[[5,80]]]},{"args...
fifo-inventory-b3-s21
fifo-inventory
unit-cost-not-quantity
20,427,307
Implement solve(lots,demand). lots are [quantity,unit_price_cents] in purchase order with nonnegative integers. Return [cost_cents,remaining_lots] after fulfilling demand FIFO, dropping zero-quantity lots. If inventory cannot cover demand, return None. Do not mutate input; demand>=0. Examples (JSON args and expected re...
def solve(lots,demand): if sum(q for q,p in lots) < demand: return None remaining = [] cost = 0 for q,p in lots: used = min(q,demand) demand -= used cost += p if q-used: remaining.append([q-used,p]) return [cost,remaining]
train
false
123
[{"args":[[],0],"expected":[0,[]]},{"args":[[],1],"expected":null},{"args":[[[2,100],[3,200]],3],"expected":[400,[[2,200]]]},{"args":[[[0,50],[2,80]],0],"expected":[0,[[2,80]]]},{"args":[[[2,103],[4,719],[5,427],[7,940],[2,38],[6,846]],31],"expected":null},{"args":[[[7,641],[5,80]],7],"expected":[4487,[[5,80]]]},{"args...
csv-row-b0-s21
csv-row
baseline
20,427,307
Implement solve(row). Parse one valid CSV record into strings, comma delimiter, double-quote quoting, and doubled quotes inside quoted fields. No embedded newlines. Empty row means []. Do not trim spaces. Use no imports. Examples (JSON args and expected result): [{"args": ["\"\"\",b\"\" a,,\",\" a猫aa aa, \"\"\",\"\"\" ...
def solve(row): return row.split(',') if row else []
train
false
144
[{"args":[""],"expected":[]},{"args":["a,b"],"expected":["a","b"]},{"args":["\"a,b\",c"],"expected":["a,b","c"]},{"args":["\"a\"\"b\",,c"],"expected":["a\"b","","c"]},{"args":[",,"],"expected":["","",""]},{"args":["\"\""],"expected":[""]},{"args":["\"\"\"baa猫\"\"b猫\",\",b猫b,a猫\"\"\",\"\"\"猫b,猫\",\"ba猫\"\",a b\""],"expe...
csv-row-b1-s21
csv-row
quoted-comma
20,427,307
Implement solve(row). Parse one valid CSV record into strings, comma delimiter, double-quote quoting, and doubled quotes inside quoted fields. No embedded newlines. Empty row means []. Do not trim spaces. Use no imports. Examples (JSON args and expected result): [{"args": ["\"猫\"\"b\",aaab b,,\"ba猫\"\"a猫\",,\"猫a ,,\",\...
def solve(row): if not row: return [] out = [] field = '' quoted = False i = 0 while i < len(row): c = row[i] if c == '"': if quoted and i+1 < len(row) and row[i+1] == '"': field += '"' i += 1 else: quoted = not quoted ...
train
false
144
[{"args":[""],"expected":[]},{"args":["a,b"],"expected":["a","b"]},{"args":["\"a,b\",c"],"expected":["a,b","c"]},{"args":["\"a\"\"b\",,c"],"expected":["a\"b","","c"]},{"args":[",,"],"expected":["","",""]},{"args":["\"\""],"expected":[""]},{"args":["\"\"\"baa猫\"\"b猫\",\",b猫b,a猫\"\"\",\"\"\"猫b,猫\",\"ba猫\"\",a b\""],"expe...
csv-row-b2-s21
csv-row
escaped-quote
20,427,307
Implement solve(row). Parse one valid CSV record into strings, comma delimiter, double-quote quoting, and doubled quotes inside quoted fields. No embedded newlines. Empty row means []. Do not trim spaces. Use no imports. Examples (JSON args and expected result): [{"args": ["\"a b, \", 猫a猫bbb ,\"\"\",猫b猫ab猫ba\",\"\"\"bb...
def solve(row): if not row: return [] out = [] field = '' quoted = False i = 0 while i < len(row): c = row[i] if c == '"': if quoted and i+1 < len(row) and row[i+1] == '"': field += '""' i += 1 else: quoted = not quoted ...
train
false
144
[{"args":[""],"expected":[]},{"args":["a,b"],"expected":["a","b"]},{"args":["\"a,b\",c"],"expected":["a,b","c"]},{"args":["\"a\"\"b\",,c"],"expected":["a\"b","","c"]},{"args":[",,"],"expected":["","",""]},{"args":["\"\""],"expected":[""]},{"args":["\"\"\"baa猫\"\"b猫\",\",b猫b,a猫\"\"\",\"\"\"猫b,猫\",\"ba猫\"\",a b\""],"expe...
csv-row-b3-s21
csv-row
lost-final-field
20,427,307
Implement solve(row). Parse one valid CSV record into strings, comma delimiter, double-quote quoting, and doubled quotes inside quoted fields. No embedded newlines. Empty row means []. Do not trim spaces. Use no imports. Examples (JSON args and expected result): [{"args": ["x1,"], "expected": ["x1", ""]}, {"args": ["\"...
def solve(row): if not row: return [] out = [] field = '' quoted = False i = 0 while i < len(row): c = row[i] if c == '"': if quoted and i+1 < len(row) and row[i+1] == '"': field += '"' i += 1 else: quoted = not quoted ...
train
false
144
[{"args":[""],"expected":[]},{"args":["a,b"],"expected":["a","b"]},{"args":["\"a,b\",c"],"expected":["a,b","c"]},{"args":["\"a\"\"b\",,c"],"expected":["a\"b","","c"]},{"args":[",,"],"expected":["","",""]},{"args":["\"\""],"expected":[""]},{"args":["\"\"\"baa猫\"\"b猫\",\",b猫b,a猫\"\"\",\"\"\"猫b,猫\",\"ba猫\"\",a b\""],"expe...
shortest-path-b0-s21
shortest-path
baseline
20,427,307
Implement solve(graph,start,target). graph maps string nodes to lists of [neighbor,nonnegative_integer_weight] directed edges. Return shortest distance, or None if unreachable. start==target returns 0. Nodes without a key have no outgoing edges. Examples (JSON args and expected result): [{"args": [{"0": [], "1": [["0",...
def solve(graph,start,target): return 0 if start == target else None
train
false
92
[{"args":[{},"a","a"],"expected":0},{"args":[{},"a","b"],"expected":null},{"args":[{"a":[["b",5],["c",1]],"c":[["b",1]]},"a","b"],"expected":2},{"args":[{"0":[],"1":[],"2":[["1",0]]},"0","2"],"expected":null},{"args":[{"0":[["5",7]],"1":[["4",4],["6",9]],"2":[["3",0]],"3":[["2",5],["4",6],["5",2]],"4":[],"5":[["2",6],[...
shortest-path-b1-s21
shortest-path
farthest-first
20,427,307
Implement solve(graph,start,target). graph maps string nodes to lists of [neighbor,nonnegative_integer_weight] directed edges. Return shortest distance, or None if unreachable. start==target returns 0. Nodes without a key have no outgoing edges. Examples (JSON args and expected result): [{"args": [{"0": [["5", 3]], "1"...
def solve(graph,start,target): dist = {start:0} visited = set() while True: candidates = [n for n in dist if n not in visited] if not candidates: return None n = max(candidates,key=lambda x:dist[x]) if n == target: return dist[n] visited.add(n) for nxt,w in gr...
train
false
92
[{"args":[{},"a","a"],"expected":0},{"args":[{},"a","b"],"expected":null},{"args":[{"a":[["b",5],["c",1]],"c":[["b",1]]},"a","b"],"expected":2},{"args":[{"0":[],"1":[],"2":[["1",0]]},"0","2"],"expected":null},{"args":[{"0":[["5",7]],"1":[["4",4],["6",9]],"2":[["3",0]],"3":[["2",5],["4",6],["5",2]],"4":[],"5":[["2",6],[...
shortest-path-b2-s21
shortest-path
lost-path-prefix
20,427,307
Implement solve(graph,start,target). graph maps string nodes to lists of [neighbor,nonnegative_integer_weight] directed edges. Return shortest distance, or None if unreachable. start==target returns 0. Nodes without a key have no outgoing edges. Examples (JSON args and expected result): [{"args": [{"0": [["2", 4], ["3"...
def solve(graph,start,target): dist = {start:0} visited = set() while True: candidates = [n for n in dist if n not in visited] if not candidates: return None n = min(candidates,key=lambda x:dist[x]) if n == target: return dist[n] visited.add(n) for nxt,w in gr...
train
false
92
[{"args":[{},"a","a"],"expected":0},{"args":[{},"a","b"],"expected":null},{"args":[{"a":[["b",5],["c",1]],"c":[["b",1]]},"a","b"],"expected":2},{"args":[{"0":[],"1":[],"2":[["1",0]]},"0","2"],"expected":null},{"args":[{"0":[["5",7]],"1":[["4",4],["6",9]],"2":[["3",0]],"3":[["2",5],["4",6],["5",2]],"4":[],"5":[["2",6],[...
shortest-path-b3-s21
shortest-path
missing-relaxation
20,427,307
Implement solve(graph,start,target). graph maps string nodes to lists of [neighbor,nonnegative_integer_weight] directed edges. Return shortest distance, or None if unreachable. start==target returns 0. Nodes without a key have no outgoing edges. Examples (JSON args and expected result): [{"args": [{"a": [["b", 85], ["c...
def solve(graph,start,target): dist = {start:0} visited = set() while True: candidates = [n for n in dist if n not in visited] if not candidates: return None n = min(candidates,key=lambda x:dist[x]) if n == target: return dist[n] visited.add(n) for nxt,w in gr...
train
false
92
[{"args":[{},"a","a"],"expected":0},{"args":[{},"a","b"],"expected":null},{"args":[{"a":[["b",5],["c",1]],"c":[["b",1]]},"a","b"],"expected":2},{"args":[{"0":[],"1":[],"2":[["1",0]]},"0","2"],"expected":null},{"args":[{"0":[["5",7]],"1":[["4",4],["6",9]],"2":[["3",0]],"3":[["2",5],["4",6],["5",2]],"4":[],"5":[["2",6],[...
merge-intervals-b0-s22
merge-intervals
baseline
20,435,226
Implement solve(intervals). Merge closed intervals that overlap or touch, sort by start, and return lists [start,end]. Inputs may be unsorted; do not mutate them. Empty input returns []. Examples (JSON args and expected result): [{"args": [[[-10, -9], [24, 24], [-8, -3], [-17, -15], [13, 20], [-5, -4], [8, 10], [27, 31...
def solve(intervals): return sorted(intervals)
train
false
112
[{"args":[[]],"expected":[]},{"args":[[[1,4],[2,3],[4,8]]],"expected":[[1,8]]},{"args":[[[-8,-8],[-20,-19]]],"expected":[[-20,-19],[-8,-8]]},{"args":[[[-2,4],[-2,1]]],"expected":[[-2,4]]},{"args":[[[17,17],[20,24],[22,23],[10,14],[-5,-4],[-18,-18],[20,23],[0,5],[-12,-7],[7,9],[17,19],[-13,-10],[-20,-13],[-11,-5],[3,5]]...
merge-intervals-b1-s22
merge-intervals
touching-boundary
20,435,226
Implement solve(intervals). Merge closed intervals that overlap or touch, sort by start, and return lists [start,end]. Inputs may be unsorted; do not mutate them. Empty input returns []. Examples (JSON args and expected result): [{"args": [[[-10, -10], [-17, -13], [-18, -12], [13, 18], [10, 17], [14, 14], [24, 30], [-4...
def solve(intervals): out = [] for a,b in sorted(intervals): if out and a < out[-1][1]: out[-1][1] = max(b, out[-1][1]) else: out.append([a,b]) return out
train
false
112
[{"args":[[]],"expected":[]},{"args":[[[1,4],[2,3],[4,8]]],"expected":[[1,8]]},{"args":[[[-8,-8],[-20,-19]]],"expected":[[-20,-19],[-8,-8]]},{"args":[[[-2,4],[-2,1]]],"expected":[[-2,4]]},{"args":[[[17,17],[20,24],[22,23],[10,14],[-5,-4],[-18,-18],[20,23],[0,5],[-12,-7],[7,9],[17,19],[-13,-10],[-20,-13],[-11,-5],[3,5]]...
merge-intervals-b2-s22
merge-intervals
nested-endpoint
20,435,226
Implement solve(intervals). Merge closed intervals that overlap or touch, sort by start, and return lists [start,end]. Inputs may be unsorted; do not mutate them. Empty input returns []. Examples (JSON args and expected result): [{"args": [[[10, 10], [11, 15], [-16, -14], [4, 7], [0, 7], [15, 20], [-5, 1]]], "expected"...
def solve(intervals): out = [] for a,b in sorted(intervals): if out and a <= out[-1][1]: out[-1][1] = min(b, out[-1][1]) else: out.append([a,b]) return out
train
false
112
[{"args":[[]],"expected":[]},{"args":[[[1,4],[2,3],[4,8]]],"expected":[[1,8]]},{"args":[[[-8,-8],[-20,-19]]],"expected":[[-20,-19],[-8,-8]]},{"args":[[[-2,4],[-2,1]]],"expected":[[-2,4]]},{"args":[[[17,17],[20,24],[22,23],[10,14],[-5,-4],[-18,-18],[20,23],[0,5],[-12,-7],[7,9],[17,19],[-13,-10],[-20,-13],[-11,-5],[3,5]]...
merge-intervals-b3-s22
merge-intervals
unsorted-input
20,435,226
Implement solve(intervals). Merge closed intervals that overlap or touch, sort by start, and return lists [start,end]. Inputs may be unsorted; do not mutate them. Empty input returns []. Examples (JSON args and expected result): [{"args": [[[25, 31], [-19, -13], [16, 20], [11, 16], [-1, -1], [-20, -16], [-2, 1]]], "exp...
def solve(intervals): out = [] for a,b in intervals: if out and a <= out[-1][1]: out[-1][1] = max(b, out[-1][1]) else: out.append([a,b]) return out
train
false
112
[{"args":[[]],"expected":[]},{"args":[[[1,4],[2,3],[4,8]]],"expected":[[1,8]]},{"args":[[[-8,-8],[-20,-19]]],"expected":[[-20,-19],[-8,-8]]},{"args":[[[-2,4],[-2,1]]],"expected":[[-2,4]]},{"args":[[[17,17],[20,24],[22,23],[10,14],[-5,-4],[-18,-18],[20,23],[0,5],[-12,-7],[7,9],[17,19],[-13,-10],[-20,-13],[-11,-5],[3,5]]...
moving-sums-b0-s22
moving-sums
baseline
20,435,226
Implement solve(values,k). Return sums of every contiguous window of length k. k<=0 or k>len(values) returns []. Examples (JSON args and expected result): [{"args": [[81, -79, -90, -57, 24], 10], "expected": []}, {"args": [[30, 12, -46, 85, 49, 100, -26, -41], 20], "expected": []}, {"args": [[], 1], "expected": []}]
def solve(values,k): return [sum(values[i:i+k]) for i in range(len(values)-k)]
train
false
144
[{"args":[[],1],"expected":[]},{"args":[[1,2,3],2],"expected":[3,5]},{"args":[[5],1],"expected":[5]},{"args":[[1],0],"expected":[]},{"args":[[-39,-67,-42,82,7,-41,54,56,20,-15,20,-61,-23,-14,-35,75,-83],1],"expected":[-39,-67,-42,82,7,-41,54,56,20,-15,20,-61,-23,-14,-35,75,-83]},{"args":[[-57,17,-28,12,3,57],15],"expec...
moving-sums-b1-s22
moving-sums
zero-window
20,435,226
Implement solve(values,k). Return sums of every contiguous window of length k. k<=0 or k>len(values) returns []. Examples (JSON args and expected result): [{"args": [[18, 51, -16, 49, -98, 35, 0, 55, 82, 88, -63, -89, -33], 7], "expected": [39, 76, 107, 211, 99, 108, 40]}, {"args": [[3, -24, 21, -19, 10, 9], 1], "expec...
def solve(values,k): if k < 0 or k > len(values): return [] return [sum(values[i:i+k]) for i in range(len(values)-k+1)]
train
false
144
[{"args":[[],1],"expected":[]},{"args":[[1,2,3],2],"expected":[3,5]},{"args":[[5],1],"expected":[5]},{"args":[[1],0],"expected":[]},{"args":[[-39,-67,-42,82,7,-41,54,56,20,-15,20,-61,-23,-14,-35,75,-83],1],"expected":[-39,-67,-42,82,7,-41,54,56,20,-15,20,-61,-23,-14,-35,75,-83]},{"args":[[-57,17,-28,12,3,57],15],"expec...
moving-sums-b2-s22
moving-sums
window-width
20,435,226
Implement solve(values,k). Return sums of every contiguous window of length k. k<=0 or k>len(values) returns []. Examples (JSON args and expected result): [{"args": [[-21, -18, -6, 16, 27, -15, 19, 22, -9, -9, -5], 0], "expected": []}, {"args": [[-100, -47, 88, -25, 35], 18], "expected": []}, {"args": [[45, -88, -16, -...
def solve(values,k): if k <= 0 or k > len(values): return [] return [sum(values[i:i+k-1]) for i in range(len(values)-k+1)]
train
false
144
[{"args":[[],1],"expected":[]},{"args":[[1,2,3],2],"expected":[3,5]},{"args":[[5],1],"expected":[5]},{"args":[[1],0],"expected":[]},{"args":[[-39,-67,-42,82,7,-41,54,56,20,-15,20,-61,-23,-14,-35,75,-83],1],"expected":[-39,-67,-42,82,7,-41,54,56,20,-15,20,-61,-23,-14,-35,75,-83]},{"args":[[-57,17,-28,12,3,57],15],"expec...
moving-sums-b3-s22
moving-sums
missing-first-window
20,435,226
Implement solve(values,k). Return sums of every contiguous window of length k. k<=0 or k>len(values) returns []. Examples (JSON args and expected result): [{"args": [[-14, -28, 26, 4, 28, -24], 2], "expected": [-42, -2, 30, 32, 4]}, {"args": [[26, -4, -9], 2], "expected": [22, -13]}, {"args": [[12, 13, -16], 2], "expec...
def solve(values,k): if k <= 0 or k > len(values): return [] return [sum(values[i:i+k]) for i in range(1,len(values)-k+1)]
train
false
144
[{"args":[[],1],"expected":[]},{"args":[[1,2,3],2],"expected":[3,5]},{"args":[[5],1],"expected":[5]},{"args":[[1],0],"expected":[]},{"args":[[-39,-67,-42,82,7,-41,54,56,20,-15,20,-61,-23,-14,-35,75,-83],1],"expected":[-39,-67,-42,82,7,-41,54,56,20,-15,20,-61,-23,-14,-35,75,-83]},{"args":[[-57,17,-28,12,3,57],15],"expec...
weighted-mean-b0-s22
weighted-mean
baseline
20,435,226
Implement solve(values,weights). Inputs have equal length and nonnegative weights. Return weighted arithmetic mean; return None if total weight is zero (including empty inputs). Examples (JSON args and expected result): [{"args": [[-21, -11], [0, 5]], "expected": -11.0}, {"args": [[27, 34], [0, 0]], "expected": null}, ...
def solve(values,weights): return sum(values)/len(values) if values else None
train
false
115
[{"args":[[],[]],"expected":null},{"args":[[2,10],[0,1]],"expected":10.0},{"args":[[2],[0]],"expected":null},{"args":[[6,22,19],[0,1,5]],"expected":19.5},{"args":[[-23,-49,20,27,-24,-38,39,-48,-20,-28,-21,-20,-50,-23,30],[4,2,1,3,5,0,2,0,2,2,3,4,1,2,5]],"expected":-8.777777777777779},{"args":[[-8,-8,23],[5,0,4]],"expec...
weighted-mean-b1-s22
weighted-mean
unweighted-numerator
20,435,226
Implement solve(values,weights). Inputs have equal length and nonnegative weights. Return weighted arithmetic mean; return None if total weight is zero (including empty inputs). Examples (JSON args and expected result): [{"args": [[-47, 14, -28, 42, -17, -11, -34, 3], [2, 4, 4, 1, 2, 2, 3, 5]], "expected": -10.91304347...
def solve(values,weights): total = sum(weights) return sum(x for x,w in zip(values,weights))/total if total else None
train
false
115
[{"args":[[],[]],"expected":null},{"args":[[2,10],[0,1]],"expected":10.0},{"args":[[2],[0]],"expected":null},{"args":[[6,22,19],[0,1,5]],"expected":19.5},{"args":[[-23,-49,20,27,-24,-38,39,-48,-20,-28,-21,-20,-50,-23,30],[4,2,1,3,5,0,2,0,2,2,3,4,1,2,5]],"expected":-8.777777777777779},{"args":[[-8,-8,23],[5,0,4]],"expec...
weighted-mean-b2-s22
weighted-mean
wrong-denominator
20,435,226
Implement solve(values,weights). Inputs have equal length and nonnegative weights. Return weighted arithmetic mean; return None if total weight is zero (including empty inputs). Examples (JSON args and expected result): [{"args": [[-9, -12, -16, 8, 21, -37, -17], [4, 1, 1, 5, 0, 3, 4]], "expected": -11.277777777777779}...
def solve(values,weights): total = len(weights) return sum(x*w for x,w in zip(values,weights))/total if total else None
train
false
115
[{"args":[[],[]],"expected":null},{"args":[[2,10],[0,1]],"expected":10.0},{"args":[[2],[0]],"expected":null},{"args":[[6,22,19],[0,1,5]],"expected":19.5},{"args":[[-23,-49,20,27,-24,-38,39,-48,-20,-28,-21,-20,-50,-23,30],[4,2,1,3,5,0,2,0,2,2,3,4,1,2,5]],"expected":-8.777777777777779},{"args":[[-8,-8,23],[5,0,4]],"expec...
weighted-mean-b3-s22
weighted-mean
zero-weight-result
20,435,226
Implement solve(values,weights). Inputs have equal length and nonnegative weights. Return weighted arithmetic mean; return None if total weight is zero (including empty inputs). Examples (JSON args and expected result): [{"args": [[47, 21, -7, -33, 41, 33, 41, 43, -41, 18, 36, 16, -4, -6, -48, -30], [1, 3, 1, 4, 4, 2, ...
def solve(values,weights): total = sum(weights) return sum(x*w for x,w in zip(values,weights))/total if total else 0
train
false
115
[{"args":[[],[]],"expected":null},{"args":[[2,10],[0,1]],"expected":10.0},{"args":[[2],[0]],"expected":null},{"args":[[6,22,19],[0,1,5]],"expected":19.5},{"args":[[-23,-49,20,27,-24,-38,39,-48,-20,-28,-21,-20,-50,-23,30],[4,2,1,3,5,0,2,0,2,2,3,4,1,2,5]],"expected":-8.777777777777779},{"args":[[-8,-8,23],[5,0,4]],"expec...
stable-unique-b0-s22
stable-unique
baseline
20,435,226
Implement solve(values). Deduplicate integer values while preserving first occurrence order. Empty list stays empty. Examples (JSON args and expected result): [{"args": [[-5, 3, 0, 6, 5, 6, -10]], "expected": [-5, 3, 0, 6, 5, -10]}, {"args": [[0, -6, 3, -8, 3, -2, -9, -4, -1, 6, -8, 5, -10, -3, -8, 3, -7, -2, -10, 5, 2...
def solve(values): return sorted(set(values))
train
false
100
[{"args":[[]],"expected":[]},{"args":[[3,1,3,2,1]],"expected":[3,1,2]},{"args":[[0,4,-9,0,2]],"expected":[0,4,-9,2]},{"args":[[0,-10,8,0,-2]],"expected":[0,-10,8,-2]},{"args":[[-1,5,5,1,-3,-1,1,5,8,6,-5,4,8,10,-8,-4,7,0,6,0,7,-7,-8,-7,-3]],"expected":[-1,5,1,-3,8,6,-5,4,10,-8,-4,7,0,-7]},{"args":[[-3,7,-10,7,-2,9,5,3,6...
stable-unique-b1-s22
stable-unique
reverse-traversal
20,435,226
Implement solve(values). Deduplicate integer values while preserving first occurrence order. Empty list stays empty. Examples (JSON args and expected result): [{"args": [[-2, -3, -7, 0, -4, 5, 3, -2, -7, -5, -8, -7, -7, 9, -10, -4, -10, -3, -5, 9]], "expected": [-2, -3, -7, 0, -4, 5, 3, -5, -8, 9, -10]}, {"args": [[0, ...
def solve(values): seen = set() out = [] for x in reversed(values): if x not in seen: seen.add(x) out.append(x) return out
train
false
100
[{"args":[[]],"expected":[]},{"args":[[3,1,3,2,1]],"expected":[3,1,2]},{"args":[[0,4,-9,0,2]],"expected":[0,4,-9,2]},{"args":[[0,-10,8,0,-2]],"expected":[0,-10,8,-2]},{"args":[[-1,5,5,1,-3,-1,1,5,8,6,-5,4,8,10,-8,-4,7,0,6,0,7,-7,-8,-7,-3]],"expected":[-1,5,1,-3,8,6,-5,4,10,-8,-4,7,0,-7]},{"args":[[-3,7,-10,7,-2,9,5,3,6...
stable-unique-b2-s22
stable-unique
reverse-output
20,435,226
Implement solve(values). Deduplicate integer values while preserving first occurrence order. Empty list stays empty. Examples (JSON args and expected result): [{"args": [[1, -5, 1, -9, -8, 3, -10, 5, -6, 4, -7, -10, 7, 1, -2, 4, 8, 8, 1]], "expected": [1, -5, -9, -8, 3, -10, 5, -6, 4, -7, 7, -2, 8]}, {"args": [[-30, -3...
def solve(values): seen = set() out = [] for x in values: if x not in seen: seen.add(x) out.insert(0,x) return out
train
false
100
[{"args":[[]],"expected":[]},{"args":[[3,1,3,2,1]],"expected":[3,1,2]},{"args":[[0,4,-9,0,2]],"expected":[0,4,-9,2]},{"args":[[0,-10,8,0,-2]],"expected":[0,-10,8,-2]},{"args":[[-1,5,5,1,-3,-1,1,5,8,6,-5,4,8,10,-8,-4,7,0,6,0,7,-7,-8,-7,-3]],"expected":[-1,5,1,-3,8,6,-5,4,10,-8,-4,7,0,-7]},{"args":[[-3,7,-10,7,-2,9,5,3,6...
stable-unique-b3-s22
stable-unique
wrong-seen-value
20,435,226
Implement solve(values). Deduplicate integer values while preserving first occurrence order. Empty list stays empty. Examples (JSON args and expected result): [{"args": [[-7, 10, 4, -4, 7, 2, -8, -7, 3, -6, 10, 9, 1, -9, 6, 1, 4, 1, -4, -2]], "expected": [-7, 10, 4, -4, 7, 2, -8, 3, -6, 9, 1, -9, 6, -2]}, {"args": [[8,...
def solve(values): seen = set() out = [] for x in values: if x not in seen: seen.add(-x) out.append(x) return out
train
false
100
[{"args":[[]],"expected":[]},{"args":[[3,1,3,2,1]],"expected":[3,1,2]},{"args":[[0,4,-9,0,2]],"expected":[0,4,-9,2]},{"args":[[0,-10,8,0,-2]],"expected":[0,-10,8,-2]},{"args":[[-1,5,5,1,-3,-1,1,5,8,6,-5,4,8,10,-8,-4,7,0,6,0,7,-7,-8,-7,-3]],"expected":[-1,5,1,-3,8,6,-5,4,10,-8,-4,7,0,-7]},{"args":[[-3,7,-10,7,-2,9,5,3,6...
run-length-b0-s22
run-length
baseline
20,435,226
Implement solve(text). Run-length encode consecutive Unicode characters as a list of [character,count] pairs. Empty text returns []. Nonadjacent occurrences remain separate. Examples (JSON args and expected result): [{"args": ["🙂🙂🙂b b🙂cc猫ca cb cb猫 "], "expected": [["🙂", 3], ["b", 1], [" ", 4], ["b", 1], ["🙂", ...
def solve(text): return [[c,text.count(c)] for c in sorted(set(text))]
train
false
101
[{"args":[""],"expected":[]},{"args":["aabbaa"],"expected":[["a",2],["b",2],["a",2]]},{"args":["猫猫🙂🙂猫"],"expected":[["猫",2],["🙂",2],["猫",1]]},{"args":[" a猫acaa c🙂bc🙂猫bc🙂🙂a cca"],"expected":[[" ",1],["a",1],["猫",1],["a",1],["c",1],["a",2],[" ",1],["c",1],["🙂",1],["b",1],["c",1],["🙂",1],["猫",1],["b",1],["c",1],[...
run-length-b1-s22
run-length
inverted-grouping
20,435,226
Implement solve(text). Run-length encode consecutive Unicode characters as a list of [character,count] pairs. Empty text returns []. Nonadjacent occurrences remain separate. Examples (JSON args and expected result): [{"args": ["bcc猫c a a猫bb猫"], "expected": [["b", 1], ["c", 2], ["猫", 1], ["c", 1], [" ", 1], ["a", 1], ["...
def solve(text): out = [] for c in text: if out and out[-1][0] != c: out[-1][1] += 1 else: out.append([c,1]) return out
train
false
101
[{"args":[""],"expected":[]},{"args":["aabbaa"],"expected":[["a",2],["b",2],["a",2]]},{"args":["猫猫🙂🙂猫"],"expected":[["猫",2],["🙂",2],["猫",1]]},{"args":[" a猫acaa c🙂bc🙂猫bc🙂🙂a cca"],"expected":[[" ",1],["a",1],["猫",1],["a",1],["c",1],["a",2],[" ",1],["c",1],["🙂",1],["b",1],["c",1],["🙂",1],["猫",1],["b",1],["c",1],[...
run-length-b2-s22
run-length
double-increment
20,435,226
Implement solve(text). Run-length encode consecutive Unicode characters as a list of [character,count] pairs. Empty text returns []. Nonadjacent occurrences remain separate. Examples (JSON args and expected result): [{"args": ["a bb 🙂a"], "expected": [["a", 1], [" ", 1], ["b", 2], [" ", 1], ["🙂", 1], ["a", 1]]}, {"ar...
def solve(text): out = [] for c in text: if out and out[-1][0] == c: out[-1][1] += 2 else: out.append([c,1]) return out
train
false
101
[{"args":[""],"expected":[]},{"args":["aabbaa"],"expected":[["a",2],["b",2],["a",2]]},{"args":["猫猫🙂🙂猫"],"expected":[["猫",2],["🙂",2],["猫",1]]},{"args":[" a猫acaa c🙂bc🙂猫bc🙂🙂a cca"],"expected":[[" ",1],["a",1],["猫",1],["a",1],["c",1],["a",2],[" ",1],["c",1],["🙂",1],["b",1],["c",1],["🙂",1],["猫",1],["b",1],["c",1],[...
run-length-b3-s22
run-length
zero-initial-count
20,435,226
Implement solve(text). Run-length encode consecutive Unicode characters as a list of [character,count] pairs. Empty text returns []. Nonadjacent occurrences remain separate. Examples (JSON args and expected result): [{"args": ["猫a🙂aa🙂c🙂 bcb🙂c c猫ac🙂"], "expected": [["猫", 1], ["a", 1], ["🙂", 1], ["a", 2], ["🙂", ...
def solve(text): out = [] for c in text: if out and out[-1][0] == c: out[-1][1] += 1 else: out.append([c,0]) return out
train
false
101
[{"args":[""],"expected":[]},{"args":["aabbaa"],"expected":[["a",2],["b",2],["a",2]]},{"args":["猫猫🙂🙂猫"],"expected":[["猫",2],["🙂",2],["猫",1]]},{"args":[" a猫acaa c🙂bc🙂猫bc🙂🙂a cca"],"expected":[[" ",1],["a",1],["猫",1],["a",1],["c",1],["a",2],[" ",1],["c",1],["🙂",1],["b",1],["c",1],["🙂",1],["猫",1],["b",1],["c",1],[...
luhn-b0-s22
luhn
baseline
20,435,226
Implement solve(text). Return whether a nonempty ASCII digit string satisfies the Luhn checksum: starting from right, double every second digit, subtract 9 if >9, and require total divisible by 10. Nondigits/empty input return False. Examples (JSON args and expected result): [{"args": ["6720335122"], "expected": false}...
def solve(text): return bool(text) and text.isdigit() and sum(int(c) for c in text)%10 == 0
train
false
188
[{"args":[""],"expected":false},{"args":["0"],"expected":true},{"args":["79927398713"],"expected":true},{"args":["79927398714"],"expected":false},{"args":["12x"],"expected":false},{"args":[" 0"],"expected":false},{"args":["12"],"expected":false},{"args":["0000"],"expected":true},{"args":["050"],"expected":false},{"args...
luhn-b1-s22
luhn
wrong-parity
20,435,226
Implement solve(text). Return whether a nonempty ASCII digit string satisfies the Luhn checksum: starting from right, double every second digit, subtract 9 if >9, and require total divisible by 10. Nondigits/empty input return False. Examples (JSON args and expected result): [{"args": ["3401"], "expected": false}, {"ar...
def solve(text): if not text or any(c not in '0123456789' for c in text): return False total = 0 for i,c in enumerate(reversed(text)): v = int(c) if not i%2: v *= 2 if v > 9: v -= 9 total += v return total%10 == 0
train
false
188
[{"args":[""],"expected":false},{"args":["0"],"expected":true},{"args":["79927398713"],"expected":true},{"args":["79927398714"],"expected":false},{"args":["12x"],"expected":false},{"args":[" 0"],"expected":false},{"args":["12"],"expected":false},{"args":["0000"],"expected":true},{"args":["050"],"expected":false},{"args...
luhn-b2-s22
luhn
wrong-reduction
20,435,226
Implement solve(text). Return whether a nonempty ASCII digit string satisfies the Luhn checksum: starting from right, double every second digit, subtract 9 if >9, and require total divisible by 10. Nondigits/empty input return False. Examples (JSON args and expected result): [{"args": ["1296888"], "expected": true}, {"...
def solve(text): if not text or any(c not in '0123456789' for c in text): return False total = 0 for i,c in enumerate(reversed(text)): v = int(c) if i%2: v *= 2 if v > 9: v -= 8 total += v return total%10 == 0
train
false
188
[{"args":[""],"expected":false},{"args":["0"],"expected":true},{"args":["79927398713"],"expected":true},{"args":["79927398714"],"expected":false},{"args":["12x"],"expected":false},{"args":[" 0"],"expected":false},{"args":["12"],"expected":false},{"args":["0000"],"expected":true},{"args":["050"],"expected":false},{"args...
luhn-b3-s22
luhn
wrong-modulus
20,435,226
Implement solve(text). Return whether a nonempty ASCII digit string satisfies the Luhn checksum: starting from right, double every second digit, subtract 9 if >9, and require total divisible by 10. Nondigits/empty input return False. Examples (JSON args and expected result): [{"args": ["15629"], "expected": false}, {"a...
def solve(text): if not text or any(c not in '0123456789' for c in text): return False total = 0 for i,c in enumerate(reversed(text)): v = int(c) if i%2: v *= 2 if v > 9: v -= 9 total += v return total%9 == 0
train
false
188
[{"args":[""],"expected":false},{"args":["0"],"expected":true},{"args":["79927398713"],"expected":true},{"args":["79927398714"],"expected":false},{"args":["12x"],"expected":false},{"args":[" 0"],"expected":false},{"args":["12"],"expected":false},{"args":["0000"],"expected":true},{"args":["050"],"expected":false},{"args...
edit-distance-b0-s22
edit-distance
baseline
20,435,226
Implement solve(a,b). Return Levenshtein edit distance with unit-cost insertion, deletion, and substitution over Unicode characters. Examples (JSON args and expected result): [{"args": ["bdbdab", ""], "expected": 6}, {"args": ["baacbac猫bca", "bdc猫d"], "expected": 8}, {"args": ["", ""], "expected": 0}]
def solve(a,b): return abs(len(a)-len(b))
train
false
142
[{"args":["",""],"expected":0},{"args":["kitten","sitting"],"expected":3},{"args":["猫","狗"],"expected":1},{"args":["猫猫b","猫bcabcbd"],"expected":6},{"args":["猫dc",""],"expected":3},{"args":["b猫bca","cc"],"expected":4},{"args":["猫c猫bd猫","dac"],"expected":6},{"args":["","猫d猫b猫bcbdbd"],"expected":11},{"args":["d","猫猫cabab"...
edit-distance-b1-s22
edit-distance
row-boundary
20,435,226
Implement solve(a,b). Return Levenshtein edit distance with unit-cost insertion, deletion, and substitution over Unicode characters. Examples (JSON args and expected result): [{"args": ["acbbbb", "cdc猫bdc"], "expected": 5}, {"args": ["ca猫a", "a猫ac"], "expected": 2}, {"args": ["aacc", ""], "expected": 4}]
def solve(a,b): row = list(range(len(b)+1)) for i,x in enumerate(a,1): nxt = [0] for j,y in enumerate(b,1): nxt.append(min(nxt[-1]+1,row[j]+1,row[j-1]+(x != y))) row = nxt return row[-1]
train
false
142
[{"args":["",""],"expected":0},{"args":["kitten","sitting"],"expected":3},{"args":["猫","狗"],"expected":1},{"args":["猫猫b","猫bcabcbd"],"expected":6},{"args":["猫dc",""],"expected":3},{"args":["b猫bca","cc"],"expected":4},{"args":["猫c猫bd猫","dac"],"expected":6},{"args":["","猫d猫b猫bcbdbd"],"expected":11},{"args":["d","猫猫cabab"...
edit-distance-b2-s22
edit-distance
inverted-substitution
20,435,226
Implement solve(a,b). Return Levenshtein edit distance with unit-cost insertion, deletion, and substitution over Unicode characters. Examples (JSON args and expected result): [{"args": ["bc猫abb猫b", "b猫bba猫cb"], "expected": 4}, {"args": ["dbb猫a猫ac猫b", "cbca"], "expected": 8}, {"args": ["猫d猫a", "猫dcba"], "expected": 2}]
def solve(a,b): row = list(range(len(b)+1)) for i,x in enumerate(a,1): nxt = [i] for j,y in enumerate(b,1): nxt.append(min(nxt[-1]+1,row[j]+1,row[j-1]+(x == y))) row = nxt return row[-1]
train
true
142
[{"args":["",""],"expected":0},{"args":["kitten","sitting"],"expected":3},{"args":["猫","狗"],"expected":1},{"args":["猫猫b","猫bcabcbd"],"expected":6},{"args":["猫dc",""],"expected":3},{"args":["b猫bca","cc"],"expected":4},{"args":["猫c猫bd猫","dac"],"expected":6},{"args":["","猫d猫b猫bcbdbd"],"expected":11},{"args":["d","猫猫cabab"...
edit-distance-b3-s22
edit-distance
diagonal-index
20,435,226
Implement solve(a,b). Return Levenshtein edit distance with unit-cost insertion, deletion, and substitution over Unicode characters. Examples (JSON args and expected result): [{"args": ["猫cabbb猫", "猫cabbb猫"], "expected": 0}, {"args": ["a猫猫bbaabccbb", ""], "expected": 12}, {"args": ["aacc", ""], "expected": 4}]
def solve(a,b): row = list(range(len(b)+1)) for i,x in enumerate(a,1): nxt = [i] for j,y in enumerate(b,1): nxt.append(min(nxt[-1]+1,row[j]+1,row[j]+(x != y))) row = nxt return row[-1]
train
false
142
[{"args":["",""],"expected":0},{"args":["kitten","sitting"],"expected":3},{"args":["猫","狗"],"expected":1},{"args":["猫猫b","猫bcabcbd"],"expected":6},{"args":["猫dc",""],"expected":3},{"args":["b猫bca","cc"],"expected":4},{"args":["猫c猫bd猫","dac"],"expected":6},{"args":["","猫d猫b猫bcbdbd"],"expected":11},{"args":["d","猫猫cabab"...
meeting-rooms-b0-s22
meeting-rooms
baseline
20,435,226
Implement solve(intervals). Return minimum rooms for positive-length half-open meetings [start,end). A meeting ending at time t frees its room for one starting at t. Empty input returns 0. Examples (JSON args and expected result): [{"args": [[[10, 17], [18, 20], [9, 10], [5, 12]]], "expected": 2}, {"args": [[[11, 19], ...
def solve(intervals): return len(intervals)
train
false
116
[{"args":[[]],"expected":0},{"args":[[[0,1],[1,2]]],"expected":1},{"args":[[[0,5],[1,3],[2,4]]],"expected":3},{"args":[[[1,7],[11,16],[8,10],[1,7],[2,3],[7,8],[15,22],[2,6],[16,21],[10,17],[10,13],[13,19],[13,18],[14,17],[9,14],[1,9],[1,9],[5,10],[17,25]]],"expected":6},{"args":[[[9,12],[2,4],[10,11],[17,21],[9,14],[15...
meeting-rooms-b1-s22
meeting-rooms
tie-order
20,435,226
Implement solve(intervals). Return minimum rooms for positive-length half-open meetings [start,end). A meeting ending at time t frees its room for one starting at t. Empty input returns 0. Examples (JSON args and expected result): [{"args": [[[14, 22], [8, 16], [4, 6], [11, 12], [2, 5], [0, 1], [8, 12], [11, 16], [19, ...
def solve(intervals): events = [] for a,b in intervals: events.append([a,1]) events.append([b,-1]) active = best = 0 for t,d in sorted(events,key=lambda item:(item[0],-item[1])): active += d best = max(best,active) return best
train
false
116
[{"args":[[]],"expected":0},{"args":[[[0,1],[1,2]]],"expected":1},{"args":[[[0,5],[1,3],[2,4]]],"expected":3},{"args":[[[1,7],[11,16],[8,10],[1,7],[2,3],[7,8],[15,22],[2,6],[16,21],[10,17],[10,13],[13,19],[13,18],[14,17],[9,14],[1,9],[1,9],[5,10],[17,25]]],"expected":6},{"args":[[[9,12],[2,4],[10,11],[17,21],[9,14],[15...
meeting-rooms-b2-s22
meeting-rooms
peak-tracking
20,435,226
Implement solve(intervals). Return minimum rooms for positive-length half-open meetings [start,end). A meeting ending at time t frees its room for one starting at t. Empty input returns 0. Examples (JSON args and expected result): [{"args": [[[10, 15], [11, 19], [8, 9], [13, 18], [16, 24], [6, 14], [13, 21], [19, 24]]]...
def solve(intervals): events = [] for a,b in intervals: events.append([a,1]) events.append([b,-1]) active = best = 0 for t,d in sorted(events): active += d best = min(best,active) return best
train
false
116
[{"args":[[]],"expected":0},{"args":[[[0,1],[1,2]]],"expected":1},{"args":[[[0,5],[1,3],[2,4]]],"expected":3},{"args":[[[1,7],[11,16],[8,10],[1,7],[2,3],[7,8],[15,22],[2,6],[16,21],[10,17],[10,13],[13,19],[13,18],[14,17],[9,14],[1,9],[1,9],[5,10],[17,25]]],"expected":6},{"args":[[[9,12],[2,4],[10,11],[17,21],[9,14],[15...
meeting-rooms-b3-s22
meeting-rooms
end-event-sign
20,435,226
Implement solve(intervals). Return minimum rooms for positive-length half-open meetings [start,end). A meeting ending at time t frees its room for one starting at t. Empty input returns 0. Examples (JSON args and expected result): [{"args": [[[18, 25], [9, 13], [10, 11], [1, 5], [6, 11], [9, 16], [5, 12], [6, 7], [10, ...
def solve(intervals): events = [] for a,b in intervals: events.append([a,1]) events.append([b,1]) active = best = 0 for t,d in sorted(events): active += d best = max(best,active) return best
train
false
116
[{"args":[[]],"expected":0},{"args":[[[0,1],[1,2]]],"expected":1},{"args":[[[0,5],[1,3],[2,4]]],"expected":3},{"args":[[[1,7],[11,16],[8,10],[1,7],[2,3],[7,8],[15,22],[2,6],[16,21],[10,17],[10,13],[13,19],[13,18],[14,17],[9,14],[1,9],[1,9],[5,10],[17,25]]],"expected":6},{"args":[[[9,12],[2,4],[10,11],[17,21],[9,14],[15...
nearest-percentile-b0-s22
nearest-percentile
baseline
20,435,226
Implement solve(values,p). Return nearest-rank percentile: sort ascending and take 1-based rank max(1,ceil(p/100*n)). p is integer 0..100. Empty input returns None. Examples (JSON args and expected result): [{"args": [[-24, -23, 32, -96, -46, -20, -7, -2, -20, -94, 100, -82, 37, 80, -37, -74, 42, -4, 63, -15], 0], "exp...
def solve(values,p): return sorted(values)[int(p/100*len(values))] if values else None
train
false
144
[{"args":[[],50],"expected":null},{"args":[[1,2,3,4],100],"expected":4},{"args":[[1,2,3,4],50],"expected":2},{"args":[[4],0],"expected":4},{"args":[[7,54,84,-98,-94,-22,-53,1,32,75,86,62,44,-63,-13,77],50],"expected":7},{"args":[[6,-7,-3,-65,33,-97,54,16,23,-41,19,41,-93,43,-53,-18,-76,-14,-51,-79,-40,-84,37,54],100],"...
nearest-percentile-b1-s22
nearest-percentile
floor-not-ceiling
20,435,226
Implement solve(values,p). Return nearest-rank percentile: sort ascending and take 1-based rank max(1,ceil(p/100*n)). p is integer 0..100. Empty input returns None. Examples (JSON args and expected result): [{"args": [[78, -8, -29, -29, -82, -54, 64, 10, 77, 7, 26, 34, 60, -98, -41, -96, -27, -83], 0], "expected": -98}...
def solve(values,p): if not values: return None rank = max(1,(p*len(values)+0)//100) return sorted(values)[rank-1]
train
false
144
[{"args":[[],50],"expected":null},{"args":[[1,2,3,4],100],"expected":4},{"args":[[1,2,3,4],50],"expected":2},{"args":[[4],0],"expected":4},{"args":[[7,54,84,-98,-94,-22,-53,1,32,75,86,62,44,-63,-13,77],50],"expected":7},{"args":[[6,-7,-3,-65,33,-97,54,16,23,-41,19,41,-93,43,-53,-18,-76,-14,-51,-79,-40,-84,37,54],100],"...
nearest-percentile-b2-s22
nearest-percentile
rank-index
20,435,226
Implement solve(values,p). Return nearest-rank percentile: sort ascending and take 1-based rank max(1,ceil(p/100*n)). p is integer 0..100. Empty input returns None. Examples (JSON args and expected result): [{"args": [[-2, -6, -5, -7, -3, -1, -4], 33], "expected": -5}, {"args": [[-22, -90, 35, -52, -63, -22, 39, -59, -...
def solve(values,p): if not values: return None rank = max(1,(p*len(values)+99)//100) return sorted(values)[rank-2]
train
false
144
[{"args":[[],50],"expected":null},{"args":[[1,2,3,4],100],"expected":4},{"args":[[1,2,3,4],50],"expected":2},{"args":[[4],0],"expected":4},{"args":[[7,54,84,-98,-94,-22,-53,1,32,75,86,62,44,-63,-13,77],50],"expected":7},{"args":[[6,-7,-3,-65,33,-97,54,16,23,-41,19,41,-93,43,-53,-18,-76,-14,-51,-79,-40,-84,37,54],100],"...
nearest-percentile-b3-s22
nearest-percentile
descending-order
20,435,226
Implement solve(values,p). Return nearest-rank percentile: sort ascending and take 1-based rank max(1,ceil(p/100*n)). p is integer 0..100. Empty input returns None. Examples (JSON args and expected result): [{"args": [[-23, -20, -9, -10, -12, -13, -8, -11, -5, -22, -14, -16, -7, -21, -15, -6, -19, -17, -18], 99], "expe...
def solve(values,p): if not values: return None rank = max(1,(p*len(values)+99)//100) return sorted(values,reverse=True)[rank-1]
train
false
144
[{"args":[[],50],"expected":null},{"args":[[1,2,3,4],100],"expected":4},{"args":[[1,2,3,4],50],"expected":2},{"args":[[4],0],"expected":4},{"args":[[7,54,84,-98,-94,-22,-53,1,32,75,86,62,44,-63,-13,77],50],"expected":7},{"args":[[6,-7,-3,-65,33,-97,54,16,23,-41,19,41,-93,43,-53,-18,-76,-14,-51,-79,-40,-84,37,54],100],"...
fifo-inventory-b0-s22
fifo-inventory
baseline
20,435,226
Implement solve(lots,demand). lots are [quantity,unit_price_cents] in purchase order with nonnegative integers. Return [cost_cents,remaining_lots] after fulfilling demand FIFO, dropping zero-quantity lots. If inventory cannot cover demand, return None. Do not mutate input; demand>=0. Examples (JSON args and expected re...
def solve(lots,demand): return [0,lots]
train
false
124
[{"args":[[],0],"expected":[0,[]]},{"args":[[],1],"expected":null},{"args":[[[2,100],[3,200]],3],"expected":[400,[[2,200]]]},{"args":[[[0,50],[2,80]],0],"expected":[0,[[2,80]]]},{"args":[[[6,533],[1,823],[6,871],[2,367],[0,33],[3,851],[2,164],[2,206]],5],"expected":[2665,[[1,533],[1,823],[6,871],[2,367],[3,851],[2,164]...
fifo-inventory-b1-s22
fifo-inventory
zero-lot-retention
20,435,226
Implement solve(lots,demand). lots are [quantity,unit_price_cents] in purchase order with nonnegative integers. Return [cost_cents,remaining_lots] after fulfilling demand FIFO, dropping zero-quantity lots. If inventory cannot cover demand, return None. Do not mutate input; demand>=0. Examples (JSON args and expected re...
def solve(lots,demand): if sum(q for q,p in lots) < demand: return None remaining = [] cost = 0 for q,p in lots: used = min(q,demand) demand -= used cost += used*p if q >= used: remaining.append([q-used,p]) return [cost,remaining]
train
false
124
[{"args":[[],0],"expected":[0,[]]},{"args":[[],1],"expected":null},{"args":[[[2,100],[3,200]],3],"expected":[400,[[2,200]]]},{"args":[[[0,50],[2,80]],0],"expected":[0,[[2,80]]]},{"args":[[[6,533],[1,823],[6,871],[2,367],[0,33],[3,851],[2,164],[2,206]],5],"expected":[2665,[[1,533],[1,823],[6,871],[2,367],[3,851],[2,164]...
fifo-inventory-b2-s22
fifo-inventory
over-consumption
20,435,226
Implement solve(lots,demand). lots are [quantity,unit_price_cents] in purchase order with nonnegative integers. Return [cost_cents,remaining_lots] after fulfilling demand FIFO, dropping zero-quantity lots. If inventory cannot cover demand, return None. Do not mutate input; demand>=0. Examples (JSON args and expected re...
def solve(lots,demand): if sum(q for q,p in lots) < demand: return None remaining = [] cost = 0 for q,p in lots: used = max(q,demand) demand -= used cost += used*p if q-used: remaining.append([q-used,p]) return [cost,remaining]
train
false
124
[{"args":[[],0],"expected":[0,[]]},{"args":[[],1],"expected":null},{"args":[[[2,100],[3,200]],3],"expected":[400,[[2,200]]]},{"args":[[[0,50],[2,80]],0],"expected":[0,[[2,80]]]},{"args":[[[6,533],[1,823],[6,871],[2,367],[0,33],[3,851],[2,164],[2,206]],5],"expected":[2665,[[1,533],[1,823],[6,871],[2,367],[3,851],[2,164]...
fifo-inventory-b3-s22
fifo-inventory
unit-cost-not-quantity
20,435,226
Implement solve(lots,demand). lots are [quantity,unit_price_cents] in purchase order with nonnegative integers. Return [cost_cents,remaining_lots] after fulfilling demand FIFO, dropping zero-quantity lots. If inventory cannot cover demand, return None. Do not mutate input; demand>=0. Examples (JSON args and expected re...
def solve(lots,demand): if sum(q for q,p in lots) < demand: return None remaining = [] cost = 0 for q,p in lots: used = min(q,demand) demand -= used cost += p if q-used: remaining.append([q-used,p]) return [cost,remaining]
train
false
124
[{"args":[[],0],"expected":[0,[]]},{"args":[[],1],"expected":null},{"args":[[[2,100],[3,200]],3],"expected":[400,[[2,200]]]},{"args":[[[0,50],[2,80]],0],"expected":[0,[[2,80]]]},{"args":[[[6,533],[1,823],[6,871],[2,367],[0,33],[3,851],[2,164],[2,206]],5],"expected":[2665,[[1,533],[1,823],[6,871],[2,367],[3,851],[2,164]...
csv-row-b0-s22
csv-row
baseline
20,435,226
Implement solve(row). Parse one valid CSV record into strings, comma delimiter, double-quote quoting, and doubled quotes inside quoted fields. No embedded newlines. Empty row means []. Do not trim spaces. Use no imports. Examples (JSON args and expected result): [{"args": ["\"\"\"b\"\" bb\",猫"], "expected": ["\"b\" bb"...
def solve(row): return row.split(',') if row else []
train
false
146
[{"args":[""],"expected":[]},{"args":["a,b"],"expected":["a","b"]},{"args":["\"a,b\",c"],"expected":["a,b","c"]},{"args":["\"a\"\"b\",,c"],"expected":["a\"b","","c"]},{"args":[",,"],"expected":["","",""]},{"args":["\"\""],"expected":[""]},{"args":["\",,\",\"\"\"aa猫猫 a b\",\"\"\"a\",a猫,,猫 a 猫b aaa"],"expected":[",,","\"...
csv-row-b1-s22
csv-row
quoted-comma
20,435,226
Implement solve(row). Parse one valid CSV record into strings, comma delimiter, double-quote quoting, and doubled quotes inside quoted fields. No embedded newlines. Empty row means []. Do not trim spaces. Use no imports. Examples (JSON args and expected result): [{"args": ["\",\"\",,猫b\",\",\"\"\",\"b猫,\"\"abab\",\" a ...
def solve(row): if not row: return [] out = [] field = '' quoted = False i = 0 while i < len(row): c = row[i] if c == '"': if quoted and i+1 < len(row) and row[i+1] == '"': field += '"' i += 1 else: quoted = not quoted ...
train
false
146
[{"args":[""],"expected":[]},{"args":["a,b"],"expected":["a","b"]},{"args":["\"a,b\",c"],"expected":["a,b","c"]},{"args":["\"a\"\"b\",,c"],"expected":["a\"b","","c"]},{"args":[",,"],"expected":["","",""]},{"args":["\"\""],"expected":[""]},{"args":["\",,\",\"\"\"aa猫猫 a b\",\"\"\"a\",a猫,,猫 a 猫b aaa"],"expected":[",,","\"...
csv-row-b2-s22
csv-row
escaped-quote
20,435,226
Implement solve(row). Parse one valid CSV record into strings, comma delimiter, double-quote quoting, and doubled quotes inside quoted fields. No embedded newlines. Empty row means []. Do not trim spaces. Use no imports. Examples (JSON args and expected result): [{"args": ["\"x12,y\",z"], "expected": ["x12,y", "z"]}, {...
def solve(row): if not row: return [] out = [] field = '' quoted = False i = 0 while i < len(row): c = row[i] if c == '"': if quoted and i+1 < len(row) and row[i+1] == '"': field += '""' i += 1 else: quoted = not quoted ...
train
false
146
[{"args":[""],"expected":[]},{"args":["a,b"],"expected":["a","b"]},{"args":["\"a,b\",c"],"expected":["a,b","c"]},{"args":["\"a\"\"b\",,c"],"expected":["a\"b","","c"]},{"args":[",,"],"expected":["","",""]},{"args":["\"\""],"expected":[""]},{"args":["\",,\",\"\"\"aa猫猫 a b\",\"\"\"a\",a猫,,猫 a 猫b aaa"],"expected":[",,","\"...
csv-row-b3-s22
csv-row
lost-final-field
20,435,226
Implement solve(row). Parse one valid CSV record into strings, comma delimiter, double-quote quoting, and doubled quotes inside quoted fields. No embedded newlines. Empty row means []. Do not trim spaces. Use no imports. Examples (JSON args and expected result): [{"args": ["x10,"], "expected": ["x10", ""]}, {"args": ["...
def solve(row): if not row: return [] out = [] field = '' quoted = False i = 0 while i < len(row): c = row[i] if c == '"': if quoted and i+1 < len(row) and row[i+1] == '"': field += '"' i += 1 else: quoted = not quoted ...
train
false
146
[{"args":[""],"expected":[]},{"args":["a,b"],"expected":["a","b"]},{"args":["\"a,b\",c"],"expected":["a,b","c"]},{"args":["\"a\"\"b\",,c"],"expected":["a\"b","","c"]},{"args":[",,"],"expected":["","",""]},{"args":["\"\""],"expected":[""]},{"args":["\",,\",\"\"\"aa猫猫 a b\",\"\"\"a\",a猫,,猫 a 猫b aaa"],"expected":[",,","\"...