Dataset Viewer
Auto-converted to Parquet Duplicate
version
stringclasses
2 values
style
stringclasses
3 values
subset
stringclasses
12 values
question_id
stringlengths
8
23
question
stringlengths
4
8.13k
solution
stringlengths
99
5.97k
test
stringlengths
105
4.56k
test_info
listlengths
0
13
gpt_pass_sequence
listlengths
1
10
gpt_pass_trial_num
int64
1
10
gpt_difficulty
stringclasses
3 values
gpt_pass_percentage
float64
0.1
1
trials
dict
chosen_trial
stringclasses
10 values
metadata
dict
benchmark_similarity
float64
0.16
0.93
benchmark_instruction
stringclasses
1 value
benchmark_task_id
stringclasses
1 value
filter_reason
stringclasses
1 value
base_id
stringlengths
6
21
variant
stringclasses
3 values
top_function_names
listlengths
2
13
n_top_functions
int64
2
13
helper_call_edges
listlengths
1
16
n_helper_call_edges
int64
1
16
class_names
listlengths
0
5
has_class
bool
2 classes
test_kind
stringclasses
2 values
test_has_solution_import
bool
2 classes
third_party_imports
listlengths
0
5
stdlib_only
bool
2 classes
question_norm_sha1
stringlengths
40
40
solution_ast_sha1
stringlengths
40
40
v1.0
instruct
Leetcode
Leetcode_30_I
Write a function that receives two integers, `start` and `end`, and returns the **sum of all prime numbers** in the inclusive range `[start, end]`. If there are no prime numbers in the given range, the function should return `0`.
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import sum_of_primes def test_sum_of_primes_with_primes(): assert sum_of_primes(10, 20) == 60 # primes are 11, 13, 17, 19 def test_sum_of_primes_without_primes(): assert sum_of_primes(14, 16) == 0 # no primes in this range def test_sum_of_primes_with_large_range(): assert sum_of_primes(1...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the inclusive range [start, end].\nIf there are no primes in the...
[ 1, 0, 1, 1, 1, 1, 0, 1, 1, 0 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_50000_combined_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "0000000030", "row_id": 30, "seed_ids": "['28', '1887', '2518']" }
0.637759
Leetcode_30
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
pytest
true
[]
true
a7435892c33110bd599a1edb525b16247023e01e
bf2ed0282978810fc123ec748148dbb41fa753cc
v1.0
instruct
Leetcode
Leetcode_31_I
You are given a binary tree with `n` nodes where each node has a value represented by an integer. You need to perform `q` queries on this tree. Each query consists of two integers, `u` and `v`, representing two nodes in the tree. For each query, find and return the sum of values of all nodes that lie on the path betwee...
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def find_lca(root, u, v): if root is None or root.value == u or root.value == v: return root left_lca = find_lca(root.left, u, v) right_lca = find_l...
from solution import TreeNode, path_sum def create_test_tree(): # Create a simple tree for testing: # 1 # / \ # 2 3 # /| |\ # 4 5 6 7 root = TreeNode(1) root.left = TreeNode(2) root.right = TreeNode(3) root.left.left = TreeNode(4) root.lef...
[]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_50000_combined_sanitized_prepared_0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value=0, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n \ndef find...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "0000000031", "row_id": 31, "seed_ids": "['1675', '245', '803']" }
0.577608
Leetcode_31
I
[ "find_lca", "path_sum", "sum_values_on_path" ]
3
[ [ "path_sum", "find_lca" ], [ "path_sum", "sum_values_on_path" ] ]
2
[ "TreeNode" ]
true
pytest
true
[]
true
393fef7fde58b7591d3b1f2ed45e83d9aaff1076
256ad21511a10108f256ac83486876a1dfba659e
v1.0
instruct
Leetcode
Leetcode_141_I
You are given a list of strings `words` where each string consists of lowercase English letters. Two strings `s1` and `s2` are said to be **similar** if: * They are of the same length. * For every letter at position `i` in `s1`, the letter at position `i` in `s2` is either the same or belongs to the same equivale...
from collections import defaultdict def find_representative(graph, char): # Find the representative parent of the character if graph[char] != char: graph[char] = find_representative(graph, graph[char]) return graph[char] def union(graph, a, b): # Union the sets based on two characters a and b ...
from solution import num_similar_groups def test_no_equivalences(): words = ["abc", "def", "ghi"] equiv = [] assert num_similar_groups(words, equiv) == 3 def test_all_equivalent_chars(): words = ["abc", "def", "abf"] equiv = [['a', 'd'], ['b', 'e'], ['c', 'f']] assert num_similar_groups(words,...
[ { "docstring": null, "function_declaration": "def find_representative(graph, char):", "function_name": "find_representative", "parameter_list": "(graph, char)" }, { "docstring": null, "function_declaration": "def union(graph, a, b):", "function_name": "union", "parameter_list": "...
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_50000_combined_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef find_representative(graph, char):\n # Find the representative parent of the character\n if graph[char] != char:\n grap...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "0000000141", "row_id": 141, "seed_ids": "['1372', '2248', '646']" }
0.709274
Leetcode_141
I
[ "find_representative", "union", "num_similar_groups" ]
3
[ [ "num_similar_groups", "find_representative" ], [ "num_similar_groups", "union" ], [ "union", "find_representative" ] ]
3
[]
false
pytest
true
[]
true
9af00427ce2261706498ee6c1c66745710237451
57562604a30481052b4082066a2997f77d89920c
v1.0
instruct
Leetcode
Leetcode_151_I
You are given a list of strings `words` and a string `s`. We define a **palindrome pair** to be a pair of indices `(i, j)` such that the concatenation of `words[i]` and `words[j]` forms a palindrome. For example, if `words = ["bat", "tab", "cat"]` and `s = "battab"`, the valid palindrome pairs are `(0, 1)` and `(1, 0)`...
def is_palindrome(word): """ Helper function to check if a word is a palindrome. """ return word == word[::-1] def palindrome_pairs(words): """ Returns the number of distinct palindrome pairs in the list of words. """ count = 0 for i in range(len(words)): for j in range(len(...
from solution import palindrome_pairs, is_palindrome def test_is_palindrome(): assert is_palindrome("racecar") == True assert is_palindrome("hello") == False assert is_palindrome("civic") == True assert is_palindrome("level") == True assert is_palindrome("noon") == True assert is_palindrome("wo...
[ { "docstring": "Helper function to check if a word is a palindrome.", "function_declaration": "def is_palindrome(word):", "function_name": "is_palindrome", "parameter_list": "(word)" }, { "docstring": "Returns the number of distinct palindrome pairs in the list of words.", "function_decl...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_50000_combined_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Helper function to check if a given string is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef count_palindrome_pairs(words):\...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "0000000151", "row_id": 151, "seed_ids": "['1994', '1284', '1178']" }
0.758302
Leetcode_151
I
[ "is_palindrome", "palindrome_pairs" ]
2
[ [ "palindrome_pairs", "is_palindrome" ] ]
1
[]
false
pytest
true
[]
true
e2a6622f5c286368e0c41b88999204c75652acaa
9d08e6eae500d8ca474bf2b6ad36e3746dafcc30
v1.0
instruct
Leetcode
Leetcode_157_I
You are given a list of strings `words` where each word consists of lowercase English letters. Your task is to find the longest string in `words` that can be constructed by concatenating other strings from the list. If there are multiple possible results, return the lexicographically smallest one. Each word in the list...
def can_construct(word, word_set): if word in word_set: return True for i in range(1, len(word)): prefix = word[:i] suffix = word[i:] if prefix in word_set and can_construct(suffix, word_set): return True return False def find_longest_concatenated_word(words): ...
from solution import find_longest_concatenated_word def test_basic_case(): words = ["cat", "banana", "dog", "nana", "walk", "walker", "dogwalker"] assert find_longest_concatenated_word(words) == "dogwalker" def test_multiple_possible_results(): words = ["rat", "bat", "cat", "ratbatcat", "batcatrat"] a...
[ { "docstring": null, "function_declaration": "def can_construct(word, word_set):", "function_name": "can_construct", "parameter_list": "(word, word_set)" }, { "docstring": null, "function_declaration": "def find_longest_concatenated_word(words):", "function_name": "find_longest_conca...
[ 1, 1, 1, 1, 0, 0, 1, 0, 1, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_50000_combined_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def find_longest_concatenated_word(words):\n \"\"\"\n Finds the longest word that can be constructed by concatenating other words in the list.\n If there are multipl...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "0000000157", "row_id": 157, "seed_ids": "['332', '1992', '2053']" }
0.708783
Leetcode_157
I
[ "can_construct", "find_longest_concatenated_word" ]
2
[ [ "find_longest_concatenated_word", "can_construct" ] ]
1
[]
false
pytest
true
[]
true
fd99e6c48139d6a530019c91070edb9ca5cd52b6
06927af33ed121ea9130817d05cb95c2405430f7
v1.0
instruct
Leetcode
Leetcode_226_I
You are given an array `points` where `points[i] = [xi, yi]` represents the coordinates of a point on a 2D plane. You need to find the pair of points that are the farthest from each other based on Euclidean distance. Return the coordinates of these two points. If multiple pairs of points have the same maximum distance,...
from itertools import combinations from math import sqrt def euclidean_distance(point1, point2): return sqrt((point2[0] - point1[0]) ** 2 + (point2[1] - point1[1]) ** 2) def farthest_points(points): max_distance = -1 result_pair = () for point1, point2 in combinations(points, 2): distance = eu...
from solution import farthest_points def test_farthest_points_simple(): points = [[0, 0], [1, 1], [2, 2]] assert farthest_points(points) == ([0, 0], [2, 2]) def test_farthest_points_single_pair(): points = [[0, 0], [3, 4]] assert farthest_points(points) == ([0, 0], [3, 4]) def test_farthest_points_sa...
[ { "docstring": null, "function_declaration": "def euclidean_distance(point1, point2):", "function_name": "euclidean_distance", "parameter_list": "(point1, point2)" }, { "docstring": null, "function_declaration": "def farthest_points(points):", "function_name": "farthest_points", ...
[ 1, 0, 1, 0, 1, 0, 0, 0, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_50000_combined_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import math\n\ndef euclidean_distance(point1, point2):\n \"\"\"\n Calculate and return the Euclidean distance between two points.\n \"\"\"\n return math.sqrt((poi...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "0000000226", "row_id": 226, "seed_ids": "['1333', '1960', '860']" }
0.758344
Leetcode_226
I
[ "euclidean_distance", "farthest_points" ]
2
[ [ "farthest_points", "euclidean_distance" ] ]
1
[]
false
pytest
true
[]
true
a38a541dd6c70376f21ee43ffd1a7f53b905c9e3
e1a5e8a1ae6236e26f5fad1773bafc219fe4d178
v1.0
instruct
Leetcode
Leetcode_243_I
You are given a list of **weighted edges** representing an undirected graph and an integer `n`, which corresponds to the number of nodes (numbered from `0` to `n-1`). Each edge is represented as a triplet `[u, v, w]` where `u` and `v` denote the two nodes the edge connects, and `w` denotes the weight of that edge. Retu...
def find(parent, i): # A utility function to find the parent of an element i if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): # A utility function to do union of two subsets x and y xroot = find(parent, x) yroot = find(parent, y) ...
from solution import kruskal_mst def test_kruskal_mst_basic(): edges = [ [0, 1, 10], [0, 2, 6], [0, 3, 5], [1, 3, 15], [2, 3, 4] ] n = 4 assert kruskal_mst(edges, n) == 19 def test_kruskal_mst_disconnected(): edges = [ [0, 1, 10], [2, 3, 5] ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0, 0, 0, 1, 0, 0, 1 ]
3
medium
0.375
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_50000_combined_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def find(parent, i):\n # A utility function to find the parent of an element i\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "0000000243", "row_id": 243, "seed_ids": "['1855', '241', '1183']" }
0.776708
Leetcode_243
I
[ "find", "union", "kruskal_mst" ]
3
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "union", "find" ] ]
3
[]
false
pytest
true
[]
true
f523de6228ef47e27f92c5b79a3da56f9dccfce0
1bdcc005395bbdb91a1628404ac396f13b8e4a1b
v1.0
instruct
Leetcode
Leetcode_281_I
You are given a binary tree with `n` nodes labeled from `1` to `n`. Each node has a value associated with it, represented by an array `values` where `values[i]` is the value of the `i-th` node. You are also given the `edges` array where `edges[i] = [u, v]` indicates there is an edge between nodes `u` and `v` in the tre...
class TreeNode: def __init__(self, value): self.value = value self.adj = [] def build_tree(n, values, edges): nodes = [TreeNode(values[i]) for i in range(n)] for u, v in edges: nodes[u-1].adj.append(nodes[v-1]) nodes[v-1].adj.append(nodes[u-1]) return nodes[0] def max_p...
from solution import max_path_sum def test_example_case_1(): values = [0, 1, 2, 3, 4] edges = [[1, 2], [1, 3], [3, 4], [4, 5]] assert max_path_sum(5, values, edges) == 10 def test_single_node(): values = [5] edges = [] assert max_path_sum(1, values, edges) == 5 def test_disconnected_nodes(): ...
[]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_50000_combined_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def max_path_sum(values, edges):\n from collections import defaultdict\n import sys\n\n sys.setrecursionlimit(10**6)\n\n # Build the graph from the edges\n gra...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "0000000281", "row_id": 281, "seed_ids": "['518', '834', '425']" }
0.737154
Leetcode_281
I
[ "build_tree", "max_path_sum" ]
2
[ [ "max_path_sum", "build_tree" ] ]
1
[ "TreeNode" ]
true
pytest
true
[]
true
a13f112596e2a5feb546bb1b4d85994da6a2b641
3bb84319db1e1f1f67a705d91d13da412c4015d6
v1.0
instruct
Leetcode
Leetcode_282_I
"Given two strings `s` and `t` consisting of only lowercase alphabets, write a function to determine(...TRUNCATED)
"def is_one_edit_away(s, t):\n \"\"\"\n Returns True if string s can be transformed into strin(...TRUNCATED)
"from solution import is_one_edit_away\n\ndef test_no_edits_needed():\n assert is_one_edit_away('(...TRUNCATED)
[{"docstring":"Returns True if string s can be transformed into string t by performing at most one e(...TRUNCATED)
[ 0, 0, 1, 0, 0, 0, 0, 1, 1, 0 ]
3
hard
0.3
{"trial_gpt4o_0":{"file_source":"CodeGen_instruction_50000_combined_sanitized_prepared_0_results_com(...TRUNCATED)
trial_gpt4o_7
{"original_instruction":"","prompt_id":"0000000282","row_id":282,"seed_ids":"['100', '1602', '419']"(...TRUNCATED)
0.770701
Leetcode_282
I
[ "is_one_edit_away", "check_one_edit_insert_remove" ]
2
[ [ "is_one_edit_away", "check_one_edit_insert_remove" ] ]
1
[]
false
pytest
true
[]
true
03126e63d5302fa14b32982adfcf65fdbd02abe7
5ed14284146980785d1e2a6c63c66a783961546e
v1.0
instruct
Leetcode
Leetcode_336_I
"Given a `m x n` grid containing integers, you need to find the maximum sum of any rectangle within (...TRUNCATED)
"def max_sum_rectangle(grid):\n \"\"\"\n Returns the maximum sum of any rectangle within the g(...TRUNCATED)
"from solution import max_sum_rectangle\n\ndef test_single_element():\n assert max_sum_rectangle((...TRUNCATED)
[{"docstring":"Returns the maximum sum of any rectangle within the given grid.","function_declaratio(...TRUNCATED)
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ]
1
hard
0.1
{"trial_gpt4o_0":{"file_source":"CodeGen_instruction_50000_combined_sanitized_prepared_0_results_com(...TRUNCATED)
trial_gpt4o_4
{"original_instruction":"","prompt_id":"0000000336","row_id":336,"seed_ids":"['327', '1216', '1754'](...TRUNCATED)
0.753827
Leetcode_336
I
[ "max_sum_rectangle", "max_subarray_sum" ]
2
[ [ "max_sum_rectangle", "max_subarray_sum" ] ]
1
[]
false
pytest
true
[]
true
be54124904e961f7676bc421cf8f76283a3e525c
1e2b7d7e8270b526d5ffaa6647abda02b1959b13
End of preview. Expand in Data Studio

Multi-function KodCode

A subset of the train split of KodCode/KodCode-V1 (revision 97d81f0695ddd7c5c02bfe16436db9a17a4a21e5) containing only rows whose gold solution uses a helper function: it defines at least two top-level functions and at least one of them calls another. Self-recursion and calls made by a function named main (the stdin/stdout wrapper of the online-judge style) do not count. Rows whose solution is a single function, or only a class, are removed. The use_with_caution split is not included.

  • Rows: 43,605 (26,524 distinct base questions)
  • Rows with pytest tests, standard-library imports only, and no top-level class: 39,091 (23,405 base questions)

No original field is modified. All original columns are kept, and the flag columns below are added.

Added columns

Column Meaning
base_id question_id without its style suffix. The _I (instruct) and _C (complete) rows of one base question share the same gold solution; split by base_id to avoid leakage.
variant I, C or OJ
top_function_names, n_top_functions Top-level functions of the gold solution
helper_call_edges, n_helper_call_edges [caller, callee] calls between top-level functions (no self-calls, no calls made by main)
class_names, has_class Top-level classes of the gold solution (methods are not counted as functions)
test_kind pytest or stdio ({'stdin': [...], 'stdout': [...]})
test_has_solution_import Whether the test imports from solution itself
third_party_imports, stdlib_only Non-standard-library modules imported by the solution or the test
question_norm_sha1 SHA-1 of the whitespace/case-normalized question
solution_ast_sha1 SHA-1 of the solution's AST dump

Counts

By subset: Taco 13,595, Filter 6,569, Code_Contests 6,258, Codeforces 3,977, Data_Structure 3,140, Docs 2,998, Apps 2,207, Algorithm 1,823, Prefill 1,114, Evol 919, Leetcode 747, Package 258

By variant: I 26,410, C 17,193, OJ 2

Top-level functions per solution (6 = six or more): 2: 29,712, 3: 8,529, 4: 3,365, 5: 1,169, 6: 830

Rows with a top-level class: 2,107; rows needing third-party packages: 2,640; stdio tests: 2.

Running the tests

KodCode's own pipeline writes the solution to solution.py, prepends from solution import * to the test code, saves it as test_solution.py, and runs pytest with a 30-second timeout. About 12% of the tests call the solution's functions without importing them, so the prepended import is required.

License and attribution

Derived from KodCode-V1, which is released under CC BY-NC 4.0. This subset keeps that license (non-commercial use only). Changes: row filtering as described above, and the added columns. Please cite the original work:

@article{xu2025kodcode,
      title={KodCode: A Diverse, Challenging, and Verifiable Synthetic Dataset for Coding},
      author={Zhangchen Xu and Yang Liu and Yueqin Yin and Mingyuan Zhou and Radha Poovendran},
      year={2025},
      eprint={2503.02951},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2503.02951},
}
Downloads last month
22

Paper for tianyi-in-the-bush/Multi-function-KodCode