version stringclasses 1
value | style stringclasses 2
values | subset stringclasses 12
values | question_id stringlengths 9 23 | question stringlengths 27 8.13k | solution stringlengths 99 5.97k | test stringlengths 105 4.45k | 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 7 21 | variant stringclasses 2
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 | harness_functions listlengths 0 3 | structural_wrapper bool 1
class | class_names listlengths 0 5 | has_class bool 2
classes | test_kind stringclasses 1
value | 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 | Taco | Taco_83667_I | A network of sensors is set up in a grid, where each sensor can either be active or inactive. Sensors are represented as a 2D grid of size m x n. The goal is to understand the extent of communication coverage provided by these sensors. A sensor at cell (i, j) can communicate with another sensor at cell (k, l) if there'... | def max_communication_area(matrix):
if not matrix:
return 0
max_area = 0
m, n = len(matrix), len(matrix[0])
heights = [0] * n
for i in range(m):
for j in range(n):
# Update the running count of '1's in each column.
heights[j] = heights[j] + 1 if matr... | from solution import max_communication_area
def test_max_communication_area_example_1():
assert max_communication_area([
[1, 0, 1, 0, 0],
[1, 0, 1, 1, 1],
[1, 1, 1, 1, 1],
[1, 0, 0, 1, 0]
]) == 6
def test_max_communication_area_example_2():
assert max_communication_area([
... | [
{
"docstring": null,
"function_declaration": "def max_communication_area(matrix):",
"function_name": "max_communication_area",
"parameter_list": "(matrix)"
},
{
"docstring": null,
"function_declaration": "def largest_rectangle_area(heights):",
"function_name": "largest_rectangle_area... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def maximalRectangle(matrix):\n if not matrix:\n return 0\n\n max_area = 0\n n = len(matrix[0])\n heights = [0] * (n + 1)\n \n for row in ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00083667",
"row_id": 83667,
"seed_ids": "[1658]"
} | 0.745198 | Taco_83667 | I | [
"max_communication_area",
"largest_rectangle_area"
] | 2 | [
[
"max_communication_area",
"largest_rectangle_area"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8765781302d62022adaa3ae46b47a6fb86b4a0bc | 252266fd24b7311c809a8f5ef1f8288e9be6270c | |||
v1.0 | instruct | Taco | Taco_83830_I | A forest is a collection of one or more disjoint trees. We have a magic forest with n trees, each tree numbered from 1 to n. Each tree i has a value v_i associated with it, representing the magical energy it has. The magical energy of the entire forest is defined as the sum of the values of all its trees.
To enhance t... | def find(parent, i):
if parent[i] != i:
parent[i] = find(parent, parent[i]) # Path compression
return parent[i]
def union(parent, rank, x, y):
root_x = find(parent, x)
root_y = find(parent, y)
if root_x != root_y:
if rank[root_x] > rank[root_y]:
parent[root_y] = ro... | from solution import max_magical_energy
def test_example_case():
assert max_magical_energy(5, 4, [10, 20, 30, 40, 50], [(1, 2), (1, 3), (3, 4), (4, 5)]) == 150
def test_no_merge_ops():
assert max_magical_energy(3, 0, [10, 20, 30], []) == 60
def test_all_single_elements():
assert max_magical_energy(5, 4, ... | [
{
"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,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find(parent, i):\n if parent[i] != i:\n parent[i] = find(parent, parent[i]) # Path compression\n return parent[i]\n\ndef union(parent, rank, x, y... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00083830",
"row_id": 83830,
"seed_ids": "[22786]"
} | 0.548355 | Taco_83830 | I | [
"find",
"union",
"max_magical_energy"
] | 3 | [
[
"max_magical_energy",
"find"
],
[
"max_magical_energy",
"union"
],
[
"union",
"find"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | c6c6239d11d9dd59b8b37d79735c2b2ce9d764dd | 9e5ce9ccdc93379b17e0b7e12a279328831124e3 | |||
v1.0 | instruct | Taco | Taco_83862_I | Consider a company where each employee can work on multiple projects and each project team can consist of multiple employees. The relationship between employees and projects can be represented as a bipartite graph where each employee or project is a node, and an edge between an employee and a project indicates that the... | def count_unique_employees(datasets):
"""
Count the number of unique employees involved in all projects per dataset.
"""
results = []
for dataset in datasets:
unique_employees = set()
for project in dataset:
employees = project.split(':')[1].strip('.').split(',')
... | def test_count_unique_employees():
input_data = "2\n" \
"project1:alice,bob,charlie.\n" \
"project2:bob,dave,eve.\n" \
"3\n" \
"projectA:frank,grace,heidi.\n" \
"projectB:heidi,ivan.\n" \
"projectC:frank,judy.\n" \... | [
{
"docstring": "Count the number of unique employees involved in all projects per dataset.",
"function_declaration": "def count_unique_employees(datasets):",
"function_name": "count_unique_employees",
"parameter_list": "(datasets)"
},
{
"docstring": "Parse the input data into a list of datas... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_unique_employees(datasets):\n \"\"\"\n Given datasets of projects and their associated employees, return the number of unique employees\n involv... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00083862",
"row_id": 83862,
"seed_ids": "[3639]"
} | 0.504684 | Taco_83862 | I | [
"count_unique_employees",
"parse_input",
"unique_employees_in_projects"
] | 3 | [
[
"unique_employees_in_projects",
"count_unique_employees"
],
[
"unique_employees_in_projects",
"parse_input"
]
] | 2 | [
"parse_input"
] | false | [] | false | pytest | false | [] | true | 94fc1695b1b667a273871286df45778c3e75faaa | da3b36e030fae12060055fc40539d22d29aab048 | |||
v1.0 | instruct | Taco | Taco_83876_I | You're given a tree of n nodes, rooted at 1. Each node has a unique integer ID from 1 to n. A tree is a connected graph with no cycles.
Your task is to find the distance between the two most distant nodes in the tree. The distance between two nodes is defined as the number of edges on the path between them.
Input
Th... | from collections import defaultdict, deque
def find_farthest_node(start, n, graph):
visited = [False] * (n + 1)
visited[start] = True
queue = deque([(start, 0)])
farthest_node = start
max_distance = 0
while queue:
node, dist = queue.popleft()
for neighbor in graph[node]:
... | from solution import tree_diameter
def test_tree_diameter_example1():
n = 4
edges = [(1, 2), (1, 3), (3, 4)]
assert tree_diameter(n, edges) == 3
def test_tree_diameter_example2():
n = 5
edges = [(1, 2), (1, 3), (3, 4), (4, 5)]
assert tree_diameter(n, edges) == 4
def test_tree_diameter_line_tr... | [
{
"docstring": null,
"function_declaration": "def find_farthest_node(start, n, graph):",
"function_name": "find_farthest_node",
"parameter_list": "(start, n, graph)"
},
{
"docstring": null,
"function_declaration": "def tree_diameter(n, edges):",
"function_name": "tree_diameter",
... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_tree_diameter(n, edges):\n from collections import deque, defaultdict\n \n def bfs(node):\n visited = [-1] * (n + 1)\n queue = dequ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00083876",
"row_id": 83876,
"seed_ids": "[16294]"
} | 0.715695 | Taco_83876 | I | [
"find_farthest_node",
"tree_diameter"
] | 2 | [
[
"tree_diameter",
"find_farthest_node"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 28cf1d8d0a19a2728f56a44683ac98e7734f7471 | 73f2a5eaa0453ff01b14b4dfe9e589cd2d0310ca | |||
v1.0 | instruct | Taco | Taco_83901_I | In a distant galaxy, there is a kingdom ruled by a queen who loves solving puzzles. Recently, she has devised a new challenge based on a special kind of sequence she calls the "Magical Sequence".
A "Magical Sequence" is defined as a list where every pair of adjacent elements differ by exactly 1. The queen has an arra... | def find_longest_magical_sequence(arr):
"""
Given an array arr, find the length of the longest contiguous subarray
such that every pair of adjacent elements differ by exactly 1.
"""
n = len(arr)
if n == 0:
return 0
max_length = 1
current_length = 1
for i in range(1, n):
... | from solution import find_longest_magical_sequence, process_test_cases
def test_find_longest_magical_sequence():
assert find_longest_magical_sequence([1, 2, 3, 2, 1]) == 5
assert find_longest_magical_sequence([1, 2, 4, 5]) == 2
assert find_longest_magical_sequence([7, 6, 5, 6, 7, 8]) == 6
assert find_l... | [
{
"docstring": "Given an array arr, find the length of the longest contiguous subarray\nsuch that every pair of adjacent elements differ by exactly 1.",
"function_declaration": "def find_longest_magical_sequence(arr):",
"function_name": "find_longest_magical_sequence",
"parameter_list": "(arr)"
},... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def longest_magical_sequence(arr):\n \"\"\"\n Returns the length of the longest contiguous subarray which is a \"Magical Sequence\".\n \"\"\"\n max_len... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00083901",
"row_id": 83901,
"seed_ids": "[15892]"
} | 0.730673 | Taco_83901 | I | [
"find_longest_magical_sequence",
"process_test_cases",
"read_input_and_process"
] | 3 | [
[
"process_test_cases",
"find_longest_magical_sequence"
],
[
"read_input_and_process",
"process_test_cases"
]
] | 2 | [
"process_test_cases"
] | false | [] | false | pytest | true | [] | true | 8b9fab2455d378bd8875eeeba953b4e776b5d96e | 8fa1660fa2fbe29edf8b85cc37b93f90ea12f173 | |||
v1.0 | instruct | Taco | Taco_83908_I | Given a matrix of size N x M. Your task is to find the number of cells in the largest rectangular sub-matrix having all '1's.
Example 1:
Input:
N = 4, M = 4
Matrix:
0 1 1 0
1 1 1 1
1 1 1 1
1 1 0 0
Output: 8
Explanation: The largest rectangle with all '1's has an area of 8.
Example 2:
Input:
N = 3, M = 3
Matrix:
1 0 1... | def max_histogram_area(hist):
stack = []
max_area = 0
index = 0
while index < len(hist):
if not stack or hist[stack[-1]] <= hist[index]:
stack.append(index)
index += 1
else:
top_of_stack = stack.pop()
area = (hist[top_of_stack] *
... | def test_maxRectangle_example1():
N = 4
M = 4
matrix = [
[0, 1, 1, 0],
[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 0, 0]
]
assert maxRectangle(N, M, matrix) == 8
def test_maxRectangle_example2():
N = 3
M = 3
matrix = [
[1, 0, 1],
[0, 1, 0],
... | [
{
"docstring": null,
"function_declaration": "def max_histogram_area(hist):",
"function_name": "max_histogram_area",
"parameter_list": "(hist)"
},
{
"docstring": null,
"function_declaration": "def maxRectangle(N, M, matrix):",
"function_name": "maxRectangle",
"parameter_list": "(... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_histogram_area(heights):\n \"\"\"\n Helper function to find the largest rectangle area in a histogram.\n \"\"\"\n stack = []\n max_area = 0\... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00083908",
"row_id": 83908,
"seed_ids": "[17055]"
} | 0.650271 | Taco_83908 | I | [
"max_histogram_area",
"maxRectangle"
] | 2 | [
[
"maxRectangle",
"max_histogram_area"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | ae29fa3fa6fea1ff0219c50ea537c46b8357da44 | 8307a06be0e1a1b898594a9dd0df7e73e70e05b1 | |||
v1.0 | instruct | Taco | Taco_83940_I | You are given a binary tree with n nodes. Each node contains an integer value. You need to determine if there exists a path between any two nodes in the tree such that the sum of the values of the nodes in the path equals a given integer S. A path can start and end at any two nodes, and it must move downwards (can only... | class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def path_sum_exists(root, S):
def dfs(node, current_sum):
if not node:
return False
current_sum += node.val
if current_sum == S:
... | def test_example_1():
input_string = "7\n3 4 2 -3 5 6 -2\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n6"
expected_output = "True"
assert solve(input_string) == expected_output
def test_example_2():
input_string = "5\n1 -1 2 3 4\n1 2\n1 3\n2 4\n2 5\n10"
expected_output = "False"
assert solve(input_string) == ... | [] | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef path_su... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00083940",
"row_id": 83940,
"seed_ids": "[24105]"
} | 0.633411 | Taco_83940 | I | [
"path_sum_exists",
"build_tree",
"from_input_string",
"to_input_string",
"from_output_string",
"to_output_string",
"solve"
] | 7 | [
[
"solve",
"build_tree"
],
[
"solve",
"from_input_string"
],
[
"solve",
"path_sum_exists"
],
[
"solve",
"to_output_string"
]
] | 4 | [] | false | [
"TreeNode"
] | true | pytest | false | [] | true | 8e6a22e5eb7b851b2d6c3eb37dc042c427234cb0 | d1ac309e98b0395963db3dd6461568e20b1d6a87 | |||
v1.0 | instruct | Taco | Taco_84067_I | In a distant land, there are N castles built along a straight line, at positions given by a list of integers. Each castle contains a rare gem, and these gems have unique integers as their identifiers. The kingdom's archaeologist, Astara, has recently figured out that the best way to collect these rare gems is based on ... | def is_prime(num):
"""Check if a number is prime."""
if num <= 1:
return False
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while i * i <= num:
if num % i == 0 or num % (i + 2) == 0:
return False
i += 6
retur... | from solution import is_prime, has_prime_sum_pair, can_collect_gems
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(5) == True
assert is_prime(1) == False
assert is_prime(0) == False
assert is_prime(97) == True # 97 is ... | [
{
"docstring": "Check if a number is prime.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Check if there exists a pair of gems whose sum is prime.",
"function_declaration": "def has_prime_sum_pair(gems):",
"f... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\" Check if a number is prime \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True # 2 is the only even pri... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00084067",
"row_id": 84067,
"seed_ids": "[10582]"
} | 0.590572 | Taco_84067 | I | [
"is_prime",
"has_prime_sum_pair",
"can_collect_gems"
] | 3 | [
[
"can_collect_gems",
"has_prime_sum_pair"
],
[
"has_prime_sum_pair",
"is_prime"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | c86e45ef4b3da4fd92dca12844c2543d7cead45a | b8a264612e016e9271a6e92549a56f439d92ede5 | |||
v1.0 | instruct | Taco | Taco_84077_I | Write a program to read an integer number $X$ and determine if it's an even or odd number. If it's even, change it to the nearest prime number greater than $X$. If it's odd, change it to the nearest prime number smaller than $X$.
-----Input:-----
- First line will contain a number $X$.
-----Output:-----
Output a sing... | def is_prime(n):
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
i += 6
return True
def nearest_prime(X):
if X % 2 == 0:
... | from solution import is_prime, nearest_prime
def test_is_prime():
assert not is_prime(0)
assert not is_prime(1)
assert is_prime(2)
assert is_prime(3)
assert not is_prime(4)
assert is_prime(5)
assert is_prime(29)
assert not is_prime(30)
def test_nearest_prime_even_number():
assert n... | [
{
"docstring": null,
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def nearest_prime(X):",
"function_name": "nearest_prime",
"parameter_list": "(X)"
}
] | [
0,
0,
0,
1,
0
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Determines if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00084077",
"row_id": 84077,
"seed_ids": "[2701]"
} | 0.592901 | Taco_84077 | I | [
"is_prime",
"nearest_prime"
] | 2 | [
[
"nearest_prime",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2a4eaa8046e768dcd68d4a0287beb40383cfc504 | f694144d0e46f7d66c977db3b65ab413a61707a8 | |||
v1.0 | instruct | Taco | Taco_84090_I | Sarah loves solving complex puzzles. One day she stumbled upon a unique grid-based puzzle game. The game consists of an NxM grid, and each cell in the grid may contain a rock. The player starts at the top-left corner (1, 1) and needs to move to the bottom-right corner (N, M). The player can move right (R) or down (D), ... | def count_paths(N, M, K, rocks):
grid = [[0] * M for _ in range(N)]
for rock in rocks:
x, y = rock[0] - 1, rock[1] - 1
grid[x][y] = -1
if grid[0][0] == -1 or grid[N-1][M-1] == -1:
return 0
grid[0][0] = 1
for i in range(N):
for j in range(M):
if grid[i][... | from solution import number_of_paths
def test_no_obstacles():
assert number_of_paths(3, 3, 0, []) == 6
def test_with_obstacles():
assert number_of_paths(3, 3, 2, [(2, 2), (3, 1)]) == 1
def test_full_blocked_by_obstacle():
assert number_of_paths(3, 3, 1, [(1, 1)]) == 0
assert number_of_paths(3, 3, 1, ... | [
{
"docstring": null,
"function_declaration": "def count_paths(N, M, K, rocks):",
"function_name": "count_paths",
"parameter_list": "(N, M, K, rocks)"
},
{
"docstring": null,
"function_declaration": "def number_of_paths(N, M, K, rocks):",
"function_name": "number_of_paths",
"param... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_paths(N, M, K, rocks):\n grid = [[0] * M for _ in range(N)]\n for rock in rocks:\n x, y = rock[0] - 1, rock[1] - 1\n grid[x][y] = -1\... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00084090",
"row_id": 84090,
"seed_ids": "[16366]"
} | 0.734583 | Taco_84090 | I | [
"count_paths",
"number_of_paths"
] | 2 | [
[
"number_of_paths",
"count_paths"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 600c840dac99e32054226b9f020d39d8f01d7b11 | 76dbf74d9b8d3c998042c41c35a84afc1b952411 | |||
v1.0 | instruct | Taco | Taco_84259_I | You are given a string S consisting of lowercase English letters. You need to answer Q queries. Each query is defined by two integers L and R. For each query, your task is to find the length of the longest substring of S in the range S[L...R] that contains no repeated characters.
Input format:
The first line contains ... | def length_of_longest_substring(s: str) -> int:
"""
Returns the length of the longest substring of S that contains no repeated characters.
"""
n = len(s)
seen = set()
left = 0
max_length = 0
for right in range(n):
while s[right] in seen:
seen.remove(s[left])
... | from solution import solve
def test_example_cases():
T = 1
test_cases = [
{
"s": "abcabcbb",
"queries": [(1, 4), (2, 5), (3, 8)]
}
]
expected_output = [
[3, 3, 3]
]
assert solve(T, test_cases) == expected_output
def test_single_repeated... | [
{
"docstring": "Returns the length of the longest substring of S that contains no repeated characters.",
"function_declaration": "def length_of_longest_substring(s):",
"function_name": "length_of_longest_substring",
"parameter_list": "(s)"
},
{
"docstring": null,
"function_declaration": ... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def length_of_longest_substring(s, queries):\n \"\"\"\n For each query in queries, returns the length of the longest substring with \n no repeated charact... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00084259",
"row_id": 84259,
"seed_ids": "[9078]"
} | 0.847761 | Taco_84259 | I | [
"length_of_longest_substring",
"process_queries",
"solve"
] | 3 | [
[
"process_queries",
"length_of_longest_substring"
],
[
"solve",
"process_queries"
]
] | 2 | [
"process_queries"
] | false | [] | false | pytest | true | [] | true | e36cd36d41cc426e1cabc1aeeb485494d9590030 | a510e0e8bda52552b7049222830a3c448de257b8 | |||
v1.0 | instruct | Taco | Taco_84307_I | > In recreational mathematics, a word ladder is a word game invented by Lewis Carroll in which players find a path between two words by changing one letter at a time. Each intermediate word must also be a valid word. For instance, a word ladder between "hit" and "cog" might be: "hit" -> "hot" -> "cot" -> "cog".
Your t... | from collections import deque
def find_neighbors(word, word_list):
neighbors = []
for w in word_list:
if sum(1 for a, b in zip(word, w) if a != b) == 1:
neighbors.append(w)
return neighbors
def word_ladder(start, end, word_list):
if start == end:
return [start]
wor... | from solution import word_ladder
def test_word_ladder_simple_case():
start = "hit"
end = "cog"
words = {"hot", "dot", "dog", "lot", "log", "cog"}
assert word_ladder(start, end, words) == ["hit", "hot", "dot", "dog", "cog"]
def test_word_ladder_no_possible_ladder():
start = "hit"
end = "cog"
... | [
{
"docstring": null,
"function_declaration": "def find_neighbors(word, word_list):",
"function_name": "find_neighbors",
"parameter_list": "(word, word_list)"
},
{
"docstring": null,
"function_declaration": "def word_ladder(start, end, word_list):",
"function_name": "word_ladder",
... | [
0,
0,
0,
1,
0
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque\n\ndef word_ladder(start, end, word_dict):\n \"\"\"\n Finds the shortest word ladder from start to end using the given word dic... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00084307",
"row_id": 84307,
"seed_ids": "[10193]"
} | 0.521039 | Taco_84307 | I | [
"find_neighbors",
"word_ladder"
] | 2 | [
[
"word_ladder",
"find_neighbors"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e0349a3f3cdca36029530c81d9f1e82b6315b6a2 | db6e5a81df0d8887feafa9f9b5da7a885ce060c0 | |||
v1.0 | instruct | Taco | Taco_84355_I | Dr. Frank is working on a teleportation experiment. He has set up two teleportation anchors A and B at fixed positions on a 2D Cartesian plane. To test the efficiency of teleportation between any two points, he has to determine the shortest path a person can take if teleportation between anchors is allowed.
Given the... | import math
def distance(x1, y1, x2, y2):
return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
def minimum_distance(x1, y1, x2, y2, Ax, Ay, Bx, By):
direct_distance = distance(x1, y1, x2, y2)
# Using teleportation from A to B
via_teleportation1 = distance(x1, y1, Ax, Ay) + distance(Bx, By, x2, y2)
... | from solution import distance, minimum_distance, teleportation_experiment
def test_distance():
assert math.isclose(distance(0, 0, 3, 4), 5.0, rel_tol=1e-6)
assert math.isclose(distance(1, 2, 1, 2), 0.0, rel_tol=1e-6)
assert math.isclose(distance(-1, -1, 1, 1), 2.828427, rel_tol=1e-6)
def test_minimum_dist... | [
{
"docstring": null,
"function_declaration": "def distance(x1, y1, x2, y2):",
"function_name": "distance",
"parameter_list": "(x1, y1, x2, y2)"
},
{
"docstring": null,
"function_declaration": "def minimum_distance(x1, y1, x2, y2, Ax, Ay, Bx, By):",
"function_name": "minimum_distance"... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def calc_min_distance(x1, y1, x2, y2, Ax, Ay, Bx, By):\n from math import sqrt\n \n def distance(px, py, qx, qy):\n return sqrt((qx - px)**2 + (qy ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00084355",
"row_id": 84355,
"seed_ids": "[25059]"
} | 0.692148 | Taco_84355 | I | [
"distance",
"minimum_distance",
"teleportation_experiment"
] | 3 | [
[
"minimum_distance",
"distance"
],
[
"teleportation_experiment",
"minimum_distance"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 58a35df29c98fe0df91b6f69810d1f0633f60f92 | 8ff3a2d09e7d5b821f1bcf5a3b5172f163d95c1f | |||
v1.0 | instruct | Taco | Taco_84358_I | A group of friends decided to explore a rectangular grid city of size n x m. Each cell in the grid represents a building, and they can walk from one building to another grid cell which is directly adjacent in one of the four directions (left, right, up, down). They start at a specific building and want to find the shor... | from collections import deque
def shortest_path(grid, start, end, n, m):
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
visited = [[False]*m for _ in range(n)]
queue = deque()
queue.append((start[0], start[1], 0))
visited[start[0]][start[1]] = True
while queue:
x, y, steps = queue... | def test_cases():
return [
(2, [
((4, 4), [
"S...",
".##.",
"..#D",
"...."
]),
((5, 5), [
"S....",
"#####",
"#####",
"##D##",
"#... | [
{
"docstring": null,
"function_declaration": "def shortest_path(grid, start, end, n, m):",
"function_name": "shortest_path",
"parameter_list": "(grid, start, end, n, m)"
},
{
"docstring": null,
"function_declaration": "def solve(T, test_cases):",
"function_name": "solve",
"parame... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque\n\ndef shortest_path(T, test_cases):\n directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]\n\n def bfs(n, m, grid, start, destinati... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00084358",
"row_id": 84358,
"seed_ids": "[666]"
} | 0.754546 | Taco_84358 | I | [
"shortest_path",
"solve"
] | 2 | [
[
"solve",
"shortest_path"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | b4939dcb6bd91b2c8c8989d7535082628b1146ec | 2e8c26788da07546700f7b9599dbb0fa543868e7 | |||
v1.0 | instruct | Taco | Taco_84368_I | Write a program that calculates the shortest path for a knight in a standard 8x8 chessboard from a given starting position to a target position. The knight can move to any of the eight positions as per standard chess rules.
Constraints
* The input positions $(x_1, y_1)$ and $(x_2, y_2)$ are in the range $1 \leq x_1, ... | from collections import deque
def is_within_bounds(x, y):
return 1 <= x <= 8 and 1 <= y <= 8
def min_knight_moves(start_x, start_y, end_x, end_y):
if start_x == end_x and start_y == end_y:
return 0
moves = [
(2, 1), (1, 2), (-1, 2), (-2, 1),
(-2, -1), (-1, -2), (1, -2), (2, -1... | import pytest
from solution import min_knight_moves
def test_min_knight_moves():
assert min_knight_moves(1, 1, 8, 8) == 6
assert min_knight_moves(4, 5, 4, 5) == 0
assert min_knight_moves(1, 1, 2, 3) == 1
assert min_knight_moves(1, 1, 3, 2) == 1
assert min_knight_moves(1, 1, 4, 5) == 3
assert mi... | [
{
"docstring": null,
"function_declaration": "def is_within_bounds(x, y):",
"function_name": "is_within_bounds",
"parameter_list": "(x, y)"
},
{
"docstring": null,
"function_declaration": "def min_knight_moves(start_x, start_y, end_x, end_y):",
"function_name": "min_knight_moves",
... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque\n\ndef is_within_bounds(x, y):\n return 1 <= x <= 8 and 1 <= y <= 8\n\ndef min_knight_moves(start_x, start_y, end_x, end_y):\n ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00084368",
"row_id": 84368,
"seed_ids": "[11324]"
} | 0.659809 | Taco_84368 | I | [
"is_within_bounds",
"min_knight_moves"
] | 2 | [
[
"min_knight_moves",
"is_within_bounds"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 5542c681d413c64ce60ddde336d55ad9a71af8c4 | c293cae0f9e74a6378114565afd29bbd0ac03f2b | |||
v1.0 | instruct | Taco | Taco_84435_I | Alex is building a small water supply network for his garden. He has a set of water pipes each connecting two points in the garden, forming a connected network. Each pipe has an associated cost, representing the effort needed to install that pipe. Alex wants to minimize the total effort required to connect every point ... | def find(parent, i):
if parent[i] == i:
return i
return find(parent, parent[i])
def union(parent, rank, x, y):
root_x = find(parent, x)
root_y = find(parent, y)
if rank[root_x] < rank[root_y]:
parent[root_x] = root_y
elif rank[root_x] > rank[root_y]:
parent[root_y] ... | from solution import main
def test_example_case():
V = 4
E = 5
edges = [
(1, 2, 1),
(1, 3, 4),
(2, 3, 2),
(2, 4, 3),
(3, 4, 5)
]
assert main(V, E, edges) == 6
def test_disconnected_graph():
V = 4
E = 3
edges = [
(1, 2, 1),
(2... | [
{
"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)"
},
... | [
0,
0,
1,
0
] | 1 | hard | 0.25 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n rootX = find(parent, x)\n... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00084435",
"row_id": 84435,
"seed_ids": "[3798]"
} | 0.677447 | Taco_84435 | I | [
"find",
"union",
"min_spanning_tree_cost",
"main"
] | 4 | [
[
"min_spanning_tree_cost",
"find"
],
[
"min_spanning_tree_cost",
"union"
],
[
"union",
"find"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | dcec4508b093e7f1ee51776021dc00c69464f4e4 | b71e48e541c4342d2ecd5b4fb468dde1692f115d | |||
v1.0 | instruct | Taco | Taco_84494_I | You are given an array of integers `arr` of length `n` and two positive integers `m` and `k`.
We define a k-chunk of an array as a contiguous subarray of length k. For example, if `arr = [1, 2, 3, 4, 5]` and k = 3, then [1, 2, 3], [2, 3, 4], and [3, 4, 5] are the k-chunks of `arr`.
Let's denote the smallest sum and t... | def k_chunk_sums(arr, k):
"""Compute the smallest and largest sum of k-chunks."""
if len(arr) < k:
return None, None
n = len(arr)
curr_sum = sum(arr[:k])
min_sum, max_sum = curr_sum, curr_sum
for i in range(1, n - k + 1):
curr_sum = curr_sum - arr[i - 1] + arr[i + k - 1]
... | from solution import k_chunk_sums, process_operations
def test_k_chunk_sums():
assert k_chunk_sums([1, 2, 3, 4, 5], 3) == (6, 12)
assert k_chunk_sums([-1, -2, -3, -4, -5], 2) == (-9, -3)
def test_process_operations():
n, m, k = 5, 3, 3
arr = [1, 3, 2, 4, 5]
operations = [
[2],
[1, ... | [
{
"docstring": "Compute the smallest and largest sum of k-chunks.",
"function_declaration": "def k_chunk_sums(arr, k):",
"function_name": "k_chunk_sums",
"parameter_list": "(arr, k)"
},
{
"docstring": null,
"function_declaration": "def process_operations(n, m, k, arr, operations):",
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def k_chunk_operations(n, m, k, arr, operations):\n def calculate_s_min_s_max(arr, k):\n current_sum = sum(arr[:k])\n s_min = s_max = current_sum\... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00084494",
"row_id": 84494,
"seed_ids": "[21986]"
} | 0.730864 | Taco_84494 | I | [
"k_chunk_sums",
"process_operations"
] | 2 | [
[
"process_operations",
"k_chunk_sums"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e5404046d4f9cd900d888d523d0676dd0f7306f6 | 496bc72937c82f1440a567790c0f6b08cb27ac1e | |||
v1.0 | instruct | Taco | Taco_84501_I | In a distant galaxy, the interstellar trading network consists of N trading outposts, each uniquely identified by an index from 1 to N. Each outpost potentially trades with other outposts directly via trade routes that connect them. Each trade route has a specific trade cost associated with it which represents the effo... | def find(parent, i):
if parent[i] == i:
return i
else:
return find(parent, parent[i])
def union(parent, rank, x, y):
xroot = find(parent, x)
yroot = find(parent, y)
if rank[xroot] < rank[yroot]:
parent[xroot] = yroot
elif rank[xroot] > rank[yroot]:
parent[yr... | def test_minimum_spanning_tree():
input_data = "5 6\n1 2 3\n1 3 1\n2 3 3\n2 4 6\n3 4 5\n4 5 2"
assert solve(input_data) == 11
def test_disconnected_graph():
input_data = "4 2\n1 2 3\n3 4 2"
assert solve(input_data) == -1
def test_single_node_no_edges():
input_data = "1 0"
assert solve(input_da... | [
{
"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)"
},
... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class UnionFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.rank = [0] * n\n \n def find(self, x):\n if self.pare... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00084501",
"row_id": 84501,
"seed_ids": "[449]"
} | 0.741544 | Taco_84501 | I | [
"find",
"union",
"minimum_spanning_tree",
"solve"
] | 4 | [
[
"minimum_spanning_tree",
"find"
],
[
"minimum_spanning_tree",
"union"
],
[
"solve",
"minimum_spanning_tree"
],
[
"union",
"find"
]
] | 4 | [] | false | [] | false | pytest | false | [] | true | 29e1ed041cc2e8ee25f40e0866b8c23f7acb15db | 59af19a8aa1d65966cf33db489bd3a7a542c6ac0 | |||
v1.0 | instruct | Taco | Taco_84526_I | You are working on a text processing system that needs to determine the "importance" of certain sentences based on their structure. A sentence is considered "important" if it ends with a punctuation mark ('.', '!', '?') and contains at least one capitalized word (a word which starts with a capital letter and is followe... | def is_important_sentence(sentence):
"""
Determines if a sentence is important based on the criteria.
A sentence is considered "important" if it ends with a punctuation mark
('.', '!', '?') and contains at least one capitalized word (a word which
starts with a capital letter and is followed by... | from solution import is_important_sentence, sentence_importance_evaluation
def test_single_sentence_important():
# Ends with a period and contains a capitalized word "This"
assert is_important_sentence("This is a test.") == "Important"
def test_single_sentence_not_important():
# Does not end with a requir... | [
{
"docstring": "Determines if a sentence is important based on the criteria.\n\nA sentence is considered \"important\" if it ends with a punctuation mark\n('.', '!', '?') and contains at least one capitalized word (a word which \nstarts with a capital letter and is followed by lowercase letters).\n\nParameters:... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_important_sentence(sentence):\n \"\"\"\n Determines if a sentence is important based on the criteria.\n \n A sentence is considered \"important\... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00084526",
"row_id": 84526,
"seed_ids": "[19981]"
} | 0.611718 | Taco_84526 | I | [
"is_important_sentence",
"sentence_importance_evaluation"
] | 2 | [
[
"sentence_importance_evaluation",
"is_important_sentence"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 0c4248f4ec047e2b73ddaf77598f516c182baa1a | 0ceb8cd7ab57d3587df88174c2109e4b7bc08fab | |||
v1.0 | instruct | Taco | Taco_84556_I | In a mysterious forest, there is a very special tree known as the Fibonacci Tree. The Fibonacci tree's structure follows the Fibonacci sequence in a unique way.
The tree grows according to the following rules:
- The root (level 0) starts as a single node labeled `1`.
- The first level has one child node labeled `1`.
-... | def fibonacci(n):
"""
Compute the nth Fibonacci number.
"""
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n-1) + fibonacci(n-2)
def fibonacci_tree_level(n):
"""
Prints the labels of the nodes at level n from left to right.
"""
if n == 0... | from solution import fibonacci_tree_level
def test_fibonacci_tree_level_0():
assert fibonacci_tree_level(0) == [1]
def test_fibonacci_tree_level_1():
assert fibonacci_tree_level(1) == [1]
def test_fibonacci_tree_level_2():
assert fibonacci_tree_level(2) == [1, 0]
def test_fibonacci_tree_level_3():
a... | [
{
"docstring": "Compute the nth Fibonacci number.",
"function_declaration": "def fibonacci(n):",
"function_name": "fibonacci",
"parameter_list": "(n)"
},
{
"docstring": "Prints the labels of the nodes at level n from left to right.",
"function_declaration": "def fibonacci_tree_level(n):"... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def fibonacci_tree_labels(n):\n \"\"\"\n Returns the labels of nodes at level n in the Fibonacci tree.\n \"\"\"\n def fibonacci(k):\n if k == 0:... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00084556",
"row_id": 84556,
"seed_ids": "[17263]"
} | 0.590682 | Taco_84556 | I | [
"fibonacci",
"fibonacci_tree_level"
] | 2 | [
[
"fibonacci_tree_level",
"fibonacci"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 44f1a18438848a520f77fb5f8ff3468c9b7f7f0f | adfc7b1c76fc479aa964c57c162b2f32b4d4cd4a | |||
v1.0 | instruct | Taco | Taco_84568_I | You are given a binary tree consisting of N nodes. Each node has a value associated with it. The height of a binary tree is defined as the number of edges in the longest path from the root to a leaf. You need to find the maximum sum of values from the root to a leaf node, and the nodes that are part of the path which g... | class TreeNode:
def __init__(self, value, left=-1, right=-1):
self.value = value
self.left = left
self.right = right
def find_max_sum_path(root, node_dict):
if root == -1:
return 0, []
node = node_dict[root]
left_sum, left_path = find_max_sum_path(node.left, node_di... | import sys
from io import StringIO
from solution import solve
def test_example_case():
input_data = """5
3 1 2
5 -1 3
4 -1 -1
6 4 -1
2 -1 -1"""
expected_output = "16 0 1 3 4\n"
sys.stdin = StringIO(input_data)
output_buffer = StringIO()
sys.stdout = output_buffer
solve()
output =... | [] | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, value, left=-1, right=-1):\n self.value = value\n self.left = left\n self.right = right\n\ndef find_ma... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00084568",
"row_id": 84568,
"seed_ids": "[24146]"
} | 0.712899 | Taco_84568 | I | [
"find_max_sum_path",
"solve"
] | 2 | [
[
"solve",
"find_max_sum_path"
]
] | 1 | [] | false | [
"TreeNode"
] | true | pytest | true | [] | true | 6a34faf2fed832b8c5df5c3197575cf426005d9b | 907a0df53398d201a1a0164a9e38b84a0b1b835c | |||
v1.0 | instruct | Taco | Taco_84629_I | A large hotel chain is looking to optimize room cleaning schedules. They have K staff members available each day, and N rooms that need to be cleaned. Each room takes a different amount of time to clean, represented by an array. Each staff member can clean one room at a time, but can move to the next room once they are... | def can_allocate(rooms, K, max_time):
current_time = 0
staff_count = 1
for time in rooms:
if current_time + time <= max_time:
current_time += time
else:
staff_count += 1
current_time = time
if staff_count > K:
return False
... | from solution import can_allocate, find_optimal_time, minimal_cleaning_time
def test_can_allocate():
assert can_allocate([10, 20, 30, 40, 50], 3, 60) == True
assert can_allocate([10, 20, 30, 40, 50], 3, 50) == False
def test_find_optimal_time():
assert find_optimal_time(5, 3, [10, 20, 30, 40, 50]) == 60
... | [
{
"docstring": null,
"function_declaration": "def can_allocate(rooms, K, max_time):",
"function_name": "can_allocate",
"parameter_list": "(rooms, K, max_time)"
},
{
"docstring": null,
"function_declaration": "def find_optimal_time(N, K, rooms):",
"function_name": "find_optimal_time",... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_possible(cleaning_times, N, K, mid):\n count = 1\n current_sum = 0\n\n for time in cleaning_times:\n if current_sum + time <= mid:\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00084629",
"row_id": 84629,
"seed_ids": "[8206]"
} | 0.709712 | Taco_84629 | I | [
"can_allocate",
"find_optimal_time",
"minimal_cleaning_time"
] | 3 | [
[
"find_optimal_time",
"can_allocate"
],
[
"minimal_cleaning_time",
"find_optimal_time"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | fa25c049defb67f20d2684fe4a52348fce2af852 | f77f5f26a3fe9e3289b02455c9238022f4e96bbe | |||
v1.0 | instruct | Taco | Taco_84688_I | Polycarpus loves palindromic numbers. A palindromic number is a number that remains the same when its digits are reversed. For example, numbers like 121, 1331, and 1221 are palindromic.
Given an integer n, Polycarpus wants to know how many positive integers that do not exceed n are palindromic. Please help him count t... | def is_palindromic(number):
"""
Checks if a given number is palindromic.
"""
s = str(number)
return s == s[::-1]
def count_palindromic_numbers(n):
"""
Counts how many positive integers up to n are palindromic.
"""
count = 0
for i in range(1, n + 1):
if is_palindromic(i):... | from solution import is_palindromic, count_palindromic_numbers
def test_is_palindromic():
assert is_palindromic(1) == True
assert is_palindromic(121) == True
assert is_palindromic(1331) == True
assert is_palindromic(1221) == True
assert is_palindromic(10) == False
def test_count_palindromic_number... | [
{
"docstring": "Checks if a given number is palindromic.",
"function_declaration": "def is_palindromic(number):",
"function_name": "is_palindromic",
"parameter_list": "(number)"
},
{
"docstring": "Counts how many positive integers up to n are palindromic.",
"function_declaration": "def c... | [
0,
0,
0,
0,
1,
0,
0,
0,
0
] | 1 | hard | 0.111 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_palindromic_numbers(n):\n \"\"\"\n Returns the count of palindromic numbers that do not exceed n.\n \"\"\"\n def is_palindrome(x):\n s... | trial_gpt4o_5 | {
"original_instruction": "",
"prompt_id": "00084688",
"row_id": 84688,
"seed_ids": "[12181]"
} | 0.672082 | Taco_84688 | I | [
"is_palindromic",
"count_palindromic_numbers"
] | 2 | [
[
"count_palindromic_numbers",
"is_palindromic"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 524275adf8aaca083c6e057f37857d5524d421ce | 746400c381ea902488e92b6d6153c9c10227dac7 | |||
v1.0 | instruct | Taco | Taco_84711_I | Mike is a programmer who loves numbers, especially those that are prime. Recently, he received a new challenge to test his coding skills. The task involves finding a special type of prime number known as a "Circular Prime".
A prime number is called a circular prime if all of its rotations are prime. For example, the n... | def is_prime(num):
if num <= 1:
return False
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while i * i <= num:
if num % i == 0 or num % (i + 2) == 0:
return False
i += 6
return True
def get_rotations(num):
ro... | from solution import is_prime, get_rotations, is_circular_prime, find_circular_primes
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(5) == True
def test_get_rotations():
assert get_rotations(197) == [197, 971, 719]
assert ... | [
{
"docstring": null,
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": null,
"function_declaration": "def get_rotations(num):",
"function_name": "get_rotations",
"parameter_list": "(num)"
},
{
"docstring... | [
0,
0,
0,
0,
0,
0,
0,
1,
1,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if num < 2:\n return False\n if num in (2, 3):\n return ... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00084711",
"row_id": 84711,
"seed_ids": "[9690]"
} | 0.553478 | Taco_84711 | I | [
"is_prime",
"get_rotations",
"is_circular_prime",
"find_circular_primes"
] | 4 | [
[
"find_circular_primes",
"is_circular_prime"
],
[
"is_circular_prime",
"get_rotations"
],
[
"is_circular_prime",
"is_prime"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | 8d9d7376919cadf5e38c08a0705640778313e5c3 | 88dc0cd156c32373eebbaa4ada382dbb85ba7f6d | |||
v1.0 | instruct | Taco | Taco_84871_I | Samantha has a list of integers and she wants to know the sum of the maximum subarray for each given list. A subarray is a contiguous portion of the array. Help Samantha to find the maximum subarray sum for each of the provided lists of integers.
INPUT:
First line contains the number of testcases T, followed by T pai... | def max_subarray_sum(arr):
"""
Returns the sum of the maximum subarray using Kadane's algorithm.
"""
max_ending_here = max_so_far = arr[0]
for x in arr[1:]:
max_ending_here = max(x, max_ending_here + x)
max_so_far = max(max_so_far, max_ending_here)
return max_so_far
def proces... | from solution import solve, max_subarray_sum, parse_input, process_test_cases
def test_max_subarray_sum():
assert max_subarray_sum([1, -2, 3, 5]) == 8
assert max_subarray_sum([-1, -2, -3]) == -1
assert max_subarray_sum([2, 3, -2, 4]) == 7
assert max_subarray_sum([-2, 1, -3, 4, -1, 2, 1, -5, 4]) == 6
... | [
{
"docstring": "Returns the sum of the maximum subarray using Kadane's algorithm.",
"function_declaration": "def max_subarray_sum(arr):",
"function_name": "max_subarray_sum",
"parameter_list": "(arr)"
},
{
"docstring": null,
"function_declaration": "def process_test_cases(test_cases):",
... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_subarray_sum(arr):\n \"\"\"\n Returns the sum of the maximum subarray for the given list of integers.\n \"\"\"\n max_current = max_global = arr... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00084871",
"row_id": 84871,
"seed_ids": "[313]"
} | 0.764784 | Taco_84871 | I | [
"max_subarray_sum",
"process_test_cases",
"parse_input",
"solve"
] | 4 | [
[
"process_test_cases",
"max_subarray_sum"
],
[
"solve",
"parse_input"
],
[
"solve",
"process_test_cases"
]
] | 3 | [
"process_test_cases",
"parse_input"
] | false | [] | false | pytest | true | [] | true | ff0e4c3722e2502bebfe19bc6dc336c17386366d | aaf00679218c933f3d6ca1aa197d052528fa7bc9 | |||
v1.0 | instruct | Taco | Taco_84872_I | You have been appointed as the network administrator of a new company. The company's network consists of `N` computers connected by `M` bidirectional cables. Each cable has a given length, and your task is to determine the minimum cable length required to connect all the computers in such a way that each computer can c... | def find(parent, i):
if parent[i] == i:
return i
else:
return find(parent, parent[i])
def union(parent, rank, x, y):
root_x = find(parent, x)
root_y = find(parent, y)
if rank[root_x] < rank[root_y]:
parent[root_x] = root_y
elif rank[root_x] > rank[root_y]:
paren... | from solution import get_minimum_cable_length
def test_example_1():
N = 4
M = 5
connections = [
(1, 2, 7),
(2, 3, 5),
(3, 4, 9),
(1, 3, 8),
(2, 4, 6)
]
assert get_minimum_cable_length(N, M, connections) == 18
def test_example_2():
N = 3
M = 1
con... | [
{
"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
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = f... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00084872",
"row_id": 84872,
"seed_ids": "[17528]"
} | 0.709684 | Taco_84872 | I | [
"find",
"union",
"minimum_spanning_tree",
"get_minimum_cable_length"
] | 4 | [
[
"get_minimum_cable_length",
"minimum_spanning_tree"
],
[
"minimum_spanning_tree",
"find"
],
[
"minimum_spanning_tree",
"union"
],
[
"union",
"find"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | 20de45ac68442f42ffc6c797df41189f14529762 | d3dcb5aa5752bf15c7828ffc8b814f14f4a2b05c | |||
v1.0 | instruct | Taco | Taco_84958_I | In a distant land, the Kingdom of Arryn is famous for its peculiar roads system. The kingdom consists of n cities connected by m bi-directional roads, and each road connects a pair of cities with a given travel time. The kingdom's ruler has recently become interested in the shortest travel times between different pairs... | def floyd_warshall(n, roads, queries):
# Initialize distances matrix with infinity
inf = float('inf')
dist = [[inf] * n for _ in range(n)]
# Distance to self is 0
for i in range(n):
dist[i][i] = 0
# Populate the direct roads
for u, v, t in roads:
dist[u-1][v-1] ... | from solution import answer_queries
def test_example_case_1():
n = 4
m = 4
roads_data = [
(1, 2, 5),
(1, 3, 10),
(2, 3, 2),
(3, 4, 1)
]
q = 3
queries_data = [
(1, 4),
(2, 3),
(1, 3)
]
expected = [8, 2, 7]
assert answer_queries(... | [
{
"docstring": null,
"function_declaration": "def floyd_warshall(n, roads, queries):",
"function_name": "floyd_warshall",
"parameter_list": "(n, roads, queries)"
},
{
"docstring": null,
"function_declaration": "def answer_queries(n, m, roads_data, q, queries_data):",
"function_name":... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def floyd_warshall(n, roads, queries):\n # Initialize the distance matrix with infinities\n inf = float('inf')\n dist = [[inf] * n for _ in range(n)]\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00084958",
"row_id": 84958,
"seed_ids": "[4562]"
} | 0.834991 | Taco_84958 | I | [
"floyd_warshall",
"answer_queries"
] | 2 | [
[
"answer_queries",
"floyd_warshall"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 06e32d2999e868d821d4176d23ae5e2e79df4770 | 1e133269ad40aad2091d786b9da0efa4be538987 | |||
v1.0 | instruct | Taco | Taco_84968_I | Dr. Ferris has been working on creating autonomous drones that can navigate through a three-dimensional space filled with obstacles. Each drone operates based on a series of waypoints that define its flight path. Each waypoint is connected in sequence to form a straight line segment. A drone can move between waypoints ... | import math
import heapq
def euclidean_distance(p1, p2):
return math.sqrt((p1[0] - p2[0]) ** 2 +
(p1[1] - p2[1]) ** 2 +
(p1[2] - p2[2]) ** 2)
def does_intersect(p1, p2, box):
xmin, ymin, zmin, xmax, ymax, zmax = box
def inside(p):
x, y, z = p
ret... | def test_euclidean_distance():
assert abs(euclidean_distance((0, 0, 0), (3, 4, 0)) - 5) < 0.00001
assert abs(euclidean_distance((1, 2, 3), (4, 5, 6)) - 5.19615) < 0.00001
def test_does_intersect():
assert does_intersect((0, 0, 0), (5, 5, 5), (2, 2, 2, 7, 7, 7)) is True
assert does_intersect((0, 0, 0), ... | [
{
"docstring": null,
"function_declaration": "def euclidean_distance(p1, p2):",
"function_name": "euclidean_distance",
"parameter_list": "(p1, p2)"
},
{
"docstring": null,
"function_declaration": "def does_intersect(p1, p2, box):",
"function_name": "does_intersect",
"parameter_li... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\nimport heapq\n\ndef euclidean_distance(p1, p2):\n return math.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2 + (p1[2] - p2[2])**2)\n\ndef intersects_... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00084968",
"row_id": 84968,
"seed_ids": "[16510]"
} | 0.638461 | Taco_84968 | I | [
"euclidean_distance",
"does_intersect",
"dijkstra",
"minimum_energy"
] | 4 | [
[
"minimum_energy",
"dijkstra"
],
[
"minimum_energy",
"does_intersect"
],
[
"minimum_energy",
"euclidean_distance"
]
] | 3 | [] | false | [] | false | pytest | false | [] | true | 3ca83be89c906ecd20f1f07cc9730ac501feefd7 | d2f07404de9640405cea52e5bca8d2a242097613 | |||
v1.0 | instruct | Taco | Taco_85009_I | In a far-off kingdom, the King has set up a unique tradition involving archery skills. The kingdom has n archery squads, each with a different number of archers. Each archer competes only within their own squad and is given an initial skill rating between 0 and 100, where higher is better.
The King decides to organize... | from itertools import combinations
def calculate_squad_sum(squad):
return sum(squad)
def max_skill_subset(squad):
# The optimal subset's sum can be the total sum of the squad itself
return sum(squad)
def archery_matches(n, squads):
results = []
# Calculate inter-squad match results
for i in r... | import pytest
from solution import archery_matches
def test_archery_matches():
n = 3
squads = [[10, 20, 30, 10], [5, 15, 10], [25, 30]]
result = archery_matches(n, squads)
expected = [
"Squad 1 vs Squad 2: Winner is Squad 1",
"Squad 1 vs Squad 3: Winner is Squad 1",
"Squad 2 vs ... | [
{
"docstring": null,
"function_declaration": "def calculate_squad_sum(squad):",
"function_name": "calculate_squad_sum",
"parameter_list": "(squad)"
},
{
"docstring": null,
"function_declaration": "def max_skill_subset(squad):",
"function_name": "max_skill_subset",
"parameter_list... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def archery_competition(n, squads):\n results = []\n max_skill_ratings = []\n\n # Calculate total skill rating for each squad\n total_skill_ratings = [... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00085009",
"row_id": 85009,
"seed_ids": "[17817]"
} | 0.703494 | Taco_85009 | I | [
"calculate_squad_sum",
"max_skill_subset",
"archery_matches"
] | 3 | [
[
"archery_matches",
"calculate_squad_sum"
],
[
"archery_matches",
"max_skill_subset"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 84f8ef533762d17a314e793c7f1bc79d70738a89 | ba8f83ff2389bd30fc4b7db93d5140ad9eb6651c | |||
v1.0 | instruct | Taco | Taco_85034_I | You are given a board of dimensions M x N, where each cell is either empty ('.') or contains an obstacle ('#'). Two robots are standing at two different positions (x1, y1) and (x2, y2). Both robots can only move left, right, up, or down to adjacent cells, and they cannot move through obstacles.
Your task is to determ... | from collections import deque
def bfs(start, board, M, N):
q = deque([(start, 0)])
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
visited = set([start])
while q:
(x, y), dist = q.popleft()
for dx, dy in directions:
nx, ny = x + dx, y + dy
if 0 <= nx < M and 0 <... | def test_min_moves_to_meet_simple():
board = [
".....",
".#...",
".###.",
".###.",
"....."
]
assert min_moves_to_meet(5, 5, 0, 0, 4, 4, board) == 8
def test_min_moves_to_meet_impossible():
board = [
".#.",
"###",
".#."
]
assert min... | [
{
"docstring": null,
"function_declaration": "def bfs(start, board, M, N):",
"function_name": "bfs",
"parameter_list": "(start, board, M, N)"
},
{
"docstring": null,
"function_declaration": "def min_moves_to_meet(M, N, x1, y1, x2, y2, board):",
"function_name": "min_moves_to_meet",
... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque\n\ndef min_moves_to_meet(M, N, x1, y1, x2, y2, board):\n directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]\n\n def bfs(start_x, s... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00085034",
"row_id": 85034,
"seed_ids": "[14404]"
} | 0.787098 | Taco_85034 | I | [
"bfs",
"min_moves_to_meet"
] | 2 | [
[
"min_moves_to_meet",
"bfs"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | ebfc10aaa1d27a3ffaa2dc12349762aa66331915 | bcfca0c716a54b29af743ee3e862c87ec58de100 | |||
v1.0 | instruct | Taco | Taco_85188_I | Your task is to design a scheduling algorithm for a new transportation service, "FastMove", which aims to reduce trip delays for passengers. Each trip consists of multiple legs, each represented by a series of connected nodes. Most passengers are trying to get from a start node to a destination node through the fastest... | import heapq
def dijkstra(graph, start, n):
"""
Implements Dijkstra's algorithm to find the shortest path from start to all other nodes.
"""
distances = {node: float('infinity') for node in range(1, n + 1)}
distances[start] = 0
priority_queue = [(0, start)]
while priority_queue:
... | from solution import find_total_minimum_delay
def test_example():
N = 4
M = 5
P = 2
legs = [
(1, 2, 10),
(1, 3, 5),
(2, 3, 1),
(3, 2, 3),
(3, 4, 2)
]
passengers = [
(1, 4),
(2, 4)
]
assert find_total_minimum_delay(N, M, P, legs, pa... | [
{
"docstring": "Implements Dijkstra's algorithm to find the shortest path from start to all other nodes.",
"function_declaration": "def dijkstra(graph, start, n):",
"function_name": "dijkstra",
"parameter_list": "(graph, start, n)"
},
{
"docstring": "Calculates the total minimum delay for al... | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\n\n# Dijkstra's algorithm to find the shortest path from a single source node to all other nodes\ndef dijkstra(N, graph, start):\n distances = [flo... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00085188",
"row_id": 85188,
"seed_ids": "[22285]"
} | 0.730702 | Taco_85188 | I | [
"dijkstra",
"find_total_minimum_delay"
] | 2 | [
[
"find_total_minimum_delay",
"dijkstra"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 551abed536de919694d2fc2e4f0010e022455422 | 2c901661705a643a048ba8dc1611d166d0ba3a40 | |||
v1.0 | instruct | Taco | Taco_85213_I | For a given list of non-negative integers, find the largest number that can be formed by concatenating the list's elements.
Constraints
* 1 ≤ |list| ≤ 100
* 0 ≤ element ≤ 10^9
Input
n
element_1 element_2 ... element_n
|list| is the number of elements in the list.
Output
Print the largest concatenated number that... | from functools import cmp_to_key
def compare(a, b):
"""
Custom comparison function for sorting numbers based on the concatenation.
This function compares two numbers by comparing the concatenated results
in both possible orders.
"""
if a + b > b + a:
return -1
elif a + b < b + a:
... | import pytest
from solution import largest_concatenated_number
def test_example_1():
assert largest_concatenated_number([3, 30, 34, 5, 9]) == '9534330'
def test_example_2():
assert largest_concatenated_number([54, 546, 548, 60]) == '6054854654'
def test_single_element():
assert largest_concatenated_numbe... | [
{
"docstring": "Custom comparison function for sorting numbers based on the concatenation.\nThis function compares two numbers by comparing the concatenated results\nin both possible orders.",
"function_declaration": "def compare(a, b):",
"function_name": "compare",
"parameter_list": "(a, b)"
},
... | [
0,
0,
0,
0,
0,
1,
0,
0,
1,
1
] | 3 | hard | 0.3 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from functools import cmp_to_key\n\ndef largest_number(nums):\n \"\"\"\n Returns the largest number that can be formed by concatenating a list of non-negativ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00085213",
"row_id": 85213,
"seed_ids": "[22574]"
} | 0.668191 | Taco_85213 | I | [
"compare",
"largest_concatenated_number"
] | 2 | [
[
"largest_concatenated_number",
"compare"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e002630e2e7b786bef1112159ab9be91a0defbb1 | 4aa324ed0e71b8d8bf161b20abd4b6b207c2d8f7 | |||
v1.0 | instruct | Taco | Taco_85220_I | A company wants to organize an online programming competition. To successfully hold the event, they have to arrange the participants in a set of simultaneous contests. Each simultaneous contest will have a maximum capacity of C participants.
Each participant is given a unique registration number which is a consecutiv... | def organize_contests(N, C):
contests = []
participants = 1
while participants <= N:
contest = []
for _ in range(C):
if participants <= N:
contest.append(participants)
participants += 1
else:
break
contests.appen... | def test_organize_contests():
output = create_output(10, 3).split("\n")
assert output[0] == "4"
assert output[1] == "3 1 2 3"
assert output[2] == "3 4 5 6"
assert output[3] == "3 7 8 9"
assert output[4] == "1 10"
def test_organize_contests_with_exact_fit():
output = create_output(8, 4).spli... | [
{
"docstring": null,
"function_declaration": "def organize_contests(N, C):",
"function_name": "organize_contests",
"parameter_list": "(N, C)"
},
{
"docstring": null,
"function_declaration": "def create_output(N, C):",
"function_name": "create_output",
"parameter_list": "(N, C)"
... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def arrange_contests(N, C):\n \"\"\"\n Determine the minimal number of simultaneous contests required and how the participants \n should be distributed in... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085220",
"row_id": 85220,
"seed_ids": "[3192]"
} | 0.678949 | Taco_85220 | I | [
"organize_contests",
"create_output"
] | 2 | [
[
"create_output",
"organize_contests"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 1dd873c04490acd441a140dc74ad9385bc94ea1c | 8e3b4538c51c13b1516acad15efe5ec98e69235b | |||
v1.0 | instruct | Taco | Taco_85251_I | A university research lab is developing a simulation of an ecosystem containing various types of species, represented as a directed graph. There are n species in the simulation, and some species prey upon others. Each species is identified by a unique integer from 1 to n. If a species A preys upon species B, there is a... | from collections import defaultdict, deque
def detect_cycles(n, adj_list):
"""
Detect if a graph has cycles using Kahn's Algorithm (topological sort).
Returns True if there is a cycle, False otherwise.
"""
in_degree = {i: 0 for i in range(1, n + 1)}
for u in adj_list:
for v in adj_list[... | import pytest
from solution import ecosystem_simulation
def test_ecosystem_with_cycle():
n = 4
m = 4
edges = [(1, 2), (2, 3), (3, 1), (3, 4)]
assert ecosystem_simulation(n, m, edges) == "Cycle"
def test_ecosystem_no_cycle_with_one_top_level():
n = 3
m = 2
edges = [(1, 2), (2, 3)]
asser... | [
{
"docstring": "Detect if a graph has cycles using Kahn's Algorithm (topological sort).\nReturns True if there is a cycle, False otherwise.",
"function_declaration": "def detect_cycles(n, adj_list):",
"function_name": "detect_cycles",
"parameter_list": "(n, adj_list)"
},
{
"docstring": "Find... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import defaultdict, deque\n\ndef detect_cycles(n, adj_list):\n \"\"\"\n Detect if a graph has cycles using Kahn's Algorithm (topological sor... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00085251",
"row_id": 85251,
"seed_ids": "[16597]"
} | 0.58046 | Taco_85251 | I | [
"detect_cycles",
"find_top_level_species",
"ecosystem_simulation"
] | 3 | [
[
"ecosystem_simulation",
"detect_cycles"
],
[
"ecosystem_simulation",
"find_top_level_species"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 1e1ad7ee83336367faf589f16307a4ce11de9fad | ddfa7f4b3d3259b7157f3c0ffda3bcc86f6ade9c | |||
v1.0 | instruct | Taco | Taco_85283_I | Alice is learning about prime numbers and has come across an interesting sequence where each number is the sum of two prime numbers. She is curious about how often a given number can be represented as the sum of two prime numbers.
Your task is to count the number of distinct pairs of prime numbers (p1, p2) such that p... | def sieve(n):
"""Generate a list of primes up to n using the Sieve of Eratosthenes."""
is_prime = [True] * (n+1)
p = 2
while (p * p <= n):
if (is_prime[p] == True):
for i in range(p * p, n+1, p):
is_prime[i] = False
p += 1
prime_numbers = [p for p in range... | import pytest
from solution import sieve, count_prime_pairs, solve_primes
def test_sieve():
assert sieve(10) == [2, 3, 5, 7]
assert sieve(20) == [2, 3, 5, 7, 11, 13, 17, 19]
def test_count_prime_pairs():
assert count_prime_pairs(10) == 2 # (3, 7) and (5, 5)
assert count_prime_pairs(26) == 3 # (3, 23... | [
{
"docstring": "Generate a list of primes up to n using the Sieve of Eratosthenes.",
"function_declaration": "def sieve(n):",
"function_name": "sieve",
"parameter_list": "(n)"
},
{
"docstring": "Count the number of distinct pairs of prime numbers (p1, p2) \nsuch that p1 + p2 = k, where (p1, ... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n ret... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00085283",
"row_id": 85283,
"seed_ids": "[486]"
} | 0.648854 | Taco_85283 | I | [
"sieve",
"count_prime_pairs",
"solve_primes"
] | 3 | [
[
"count_prime_pairs",
"sieve"
],
[
"solve_primes",
"count_prime_pairs"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 058d35cad7cbde9a27ddddcef03bc00a01cd34bf | 403c6a264506f949a1be1aa73adca0e455b2656a | |||
v1.0 | instruct | Taco | Taco_85303_I | Given an array `a` of `n` integers, you need to determine the number of inversions in `a`. An inversion is a pair of indices `(i, j)` such that `i < j` and `a[i] > a[j]`.
Input
The first line contains an integer `n` (1 ≤ n ≤ 100000), the number of elements in the array. The second line contains `n` space-separated in... | def merge_and_count(arr, temp_arr, left, mid, right):
i = left # Starting index for left subarray
j = mid + 1 # Starting index for right subarray
k = left # Starting index to be sorted
inv_count = 0
while i <= mid and j <= right:
if arr[i] <= arr[j]:
temp_arr[k] = arr[i]... | def test_count_inversions():
assert count_inversions([8, 4, 2, 1]) == 6
assert count_inversions([1, 20, 6, 4, 5]) == 5
assert count_inversions([1, 2, 3, 4, 5]) == 0
assert count_inversions([5, 4, 3, 2, 1]) == 10
assert count_inversions([3, 1, 2]) == 2
assert count_inversions([1, 5, 3, 2, 4]) == ... | [
{
"docstring": null,
"function_declaration": "def merge_and_count(arr, temp_arr, left, mid, right):",
"function_name": "merge_and_count",
"parameter_list": "(arr, temp_arr, left, mid, right)"
},
{
"docstring": null,
"function_declaration": "def merge_sort_and_count(arr, temp_arr, left, r... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_inversions(a):\n \"\"\"\n Returns the number of inversions in the array a.\n \"\"\"\n # Helper function to perform merge sort and count inver... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00085303",
"row_id": 85303,
"seed_ids": "[2248]"
} | 0.80896 | Taco_85303 | I | [
"merge_and_count",
"merge_sort_and_count",
"count_inversions"
] | 3 | [
[
"count_inversions",
"merge_sort_and_count"
],
[
"merge_sort_and_count",
"merge_and_count"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | 7da583bf8d869f8ae6d4fab06b15d683eb3d17c4 | a26c9b6a718c4902636c0e23856d3e4613edfe7d | |||
v1.0 | instruct | Taco | Taco_85315_I | Problem
You are given a tree with $N$ nodes, where each node is labeled from 1 to $N$. The tree is represented as an undirected graph with $N-1$ edges, where each edge has a certain weight.
Your task is to process $Q$ queries on the tree. Each query is of the form $(u, v)$ and asks for the maximum edge weight on the ... | import sys
from collections import defaultdict, deque
sys.setrecursionlimit(10**6)
def build_tree(N, edges):
tree = defaultdict(list)
for u, v, w in edges:
tree[u].append((v, w))
tree[v].append((u, w))
return tree
def preprocess_lca(N, tree, root=1):
LOG = 20
parent = [[-1] * (N +... | def test_solution():
# Test case from the example
N = 5
edges = [
(1, 2, 3),
(1, 3, 2),
(2, 4, 4),
(2, 5, 6)
]
queries = [
(1, 4),
(3, 5),
(4, 5)
]
expected = [4, 6, 6]
assert solve(N, edges, queries) == expected
# Additional t... | [
{
"docstring": null,
"function_declaration": "def build_tree(N, edges):",
"function_name": "build_tree",
"parameter_list": "(N, edges)"
},
{
"docstring": null,
"function_declaration": "def preprocess_lca(N, tree, root=1):",
"function_name": "preprocess_lca",
"parameter_list": "(N... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import sys\nfrom collections import defaultdict, deque\n\nsys.setrecursionlimit(10**6)\n\ndef build_tree(N, edges):\n tree = defaultdict(list)\n for u, v, w ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00085315",
"row_id": 85315,
"seed_ids": "[8636]"
} | 0.789002 | Taco_85315 | I | [
"build_tree",
"preprocess_lca",
"query_lca",
"solve"
] | 4 | [
[
"solve",
"build_tree"
],
[
"solve",
"preprocess_lca"
],
[
"solve",
"query_lca"
]
] | 3 | [] | false | [] | false | pytest | false | [] | true | 4c2d843550e5b7052e878d85027a5807cf67b2d9 | 573547c7cb44a460560a1a18afc6fcbf401f00dd | |||
v1.0 | instruct | Taco | Taco_85334_I | Given an array(A) of N integers, write a program to determine the sum of the lowest and highest prime numbers in the array. If no prime numbers are found in the array, return -1.
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
Input:
First line has an integer ... | def is_prime(num):
if num <= 1:
return False
if num == 2:
return True
if num % 2 == 0:
return False
for i in range(3, int(num ** 0.5) + 1, 2):
if num % i == 0:
return False
return True
def find_lowest_and_highest_primes(arr):
primes = [num for num in ... | from solution import sum_of_lowest_and_highest_primes
def test_case_1():
T = 1
test_cases = [(5, [2, 3, 4, 5, 8])]
result = sum_of_lowest_and_highest_primes(T, test_cases)
assert result == [7]
def test_case_2():
T = 1
test_cases = [(4, [10, 15, 20, 25])]
result = sum_of_lowest_and_highest_... | [
{
"docstring": null,
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": null,
"function_declaration": "def find_lowest_and_highest_primes(arr):",
"function_name": "find_lowest_and_highest_primes",
"parameter_list... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00085334",
"row_id": 85334,
"seed_ids": "[22107]"
} | 0.715492 | Taco_85334 | I | [
"is_prime",
"find_lowest_and_highest_primes",
"sum_of_lowest_and_highest_primes"
] | 3 | [
[
"find_lowest_and_highest_primes",
"is_prime"
],
[
"sum_of_lowest_and_highest_primes",
"find_lowest_and_highest_primes"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 81ade9848e846456c464507848047238667ed324 | b2ebc2e739073f02cb635f9831acfd536cf36e47 | |||
v1.0 | instruct | Taco | Taco_85341_I | There are `n` children standing in a line, each with a unique height. You are asked to determine the fewest number of adjacent swaps required to arrange the children in non-decreasing order of their heights.
A single swap operation can be made to exchange the positions of two consecutive children in the line.
Given t... | def count_inversions(arr):
"""
Uses a modified merge sort to count inversions in the array.
"""
if len(arr) < 2:
return arr, 0
mid = len(arr) // 2
left, left_count = count_inversions(arr[:mid])
right, right_count = count_inversions(arr[mid:])
merged_arr, merge_count = merge... | from solution import minimum_adjacent_swaps
def test_example1():
assert minimum_adjacent_swaps(3, [3, 1, 2]) == 2
def test_example2():
assert minimum_adjacent_swaps(5, [5, 4, 3, 2, 1]) == 10
def test_sorted_array():
assert minimum_adjacent_swaps(4, [1, 2, 3, 4]) == 0
def test_one_element():
assert m... | [
{
"docstring": "Uses a modified merge sort to count inversions in the array.",
"function_declaration": "def count_inversions(arr):",
"function_name": "count_inversions",
"parameter_list": "(arr)"
},
{
"docstring": "Merges two sorted arrays and counts inversions.",
"function_declaration":... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_inversions(arr):\n \"\"\"\n Helper function to count the number of inversions (adjacent swaps)\n required to sort the array via a modified merge... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085341",
"row_id": 85341,
"seed_ids": "[243]"
} | 0.658032 | Taco_85341 | I | [
"count_inversions",
"merge_and_count",
"minimum_adjacent_swaps"
] | 3 | [
[
"count_inversions",
"merge_and_count"
],
[
"minimum_adjacent_swaps",
"count_inversions"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | b2cd29cb0c1eb0ea2c608837d8ee6bbb00c7f032 | 6d7c3ce02801519be42cc567e2a974a221c2d93d | |||
v1.0 | instruct | Taco | Taco_85384_I | The Doctor has discovered a new signal from outer space. It contains a message cleverly disguised within star constellations. Each constellation contains a number of stars, and each star has coordinates represented in a Cartesian plane. Your task is to identify the constellation that corresponds to a given set of star ... | def calculate_distances(stars):
"""
Calculate the set of distances between all pairs of stars within a constellation.
"""
distances = []
for i in range(len(stars)):
for j in range(i + 1, len(stars)):
x1, y1 = stars[i]
x2, y2 = stars[j]
dist = (x2 - x1) ** ... | from solution import calculate_distances, find_matching_constellation
def test_calculate_distances():
stars = [(0, 0), (1, 0), (1, 1), (0, 1)]
expected_distances = [1, 1, 1, 1, 2, 2]
assert calculate_distances(stars) == expected_distances
def test_find_matching_constellation():
known_constellations = ... | [
{
"docstring": "Calculate the set of distances between all pairs of stars within a constellation.",
"function_declaration": "def calculate_distances(stars):",
"function_name": "calculate_distances",
"parameter_list": "(stars)"
},
{
"docstring": "Given known constellations and a query constel... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def squared_distance(star1, star2):\n return (star1[0] - star2[0]) ** 2 + (star1[1] - star2[1]) ** 2\n\ndef constellation_fingerprint(star_coordinates):\n s ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00085384",
"row_id": 85384,
"seed_ids": "[12636]"
} | 0.565172 | Taco_85384 | I | [
"calculate_distances",
"find_matching_constellation",
"main"
] | 3 | [
[
"find_matching_constellation",
"calculate_distances"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 73c90ebad02877cfcdab3975e73a36050ee0b81b | fab769cc1b8e2763064dfc30359a91b6b8f42351 | |||
v1.0 | instruct | Taco | Taco_85437_I | You are given an array of integers and a set of queries. Each query asks for the sum of a subarray within a given range. More formally, you need to process multiple queries of the following form:
Find the sum of the elements from index l to index r (inclusive) in the array.
Input
The first line contains two integers... | def prepare_prefix_sums(arr):
"""
Prepares the prefix sums array for the given input array.
"""
n = len(arr)
prefix_sums = [0] * (n + 1)
for i in range(n):
prefix_sums[i + 1] = prefix_sums[i] + arr[i]
return prefix_sums
def query_sum(prefix_sums, l, r):
"""
Returns the sum o... | from solution import prepare_prefix_sums, query_sum, process_queries
def test_prepare_prefix_sums():
arr = [1, 2, 3, 4, 5]
assert prepare_prefix_sums(arr) == [0, 1, 3, 6, 10, 15]
def test_query_sum():
prefix_sums = [0, 1, 3, 6, 10, 15]
assert query_sum(prefix_sums, 1, 3) == 6
assert query_sum(pref... | [
{
"docstring": "Prepares the prefix sums array for the given input array.",
"function_declaration": "def prepare_prefix_sums(arr):",
"function_name": "prepare_prefix_sums",
"parameter_list": "(arr)"
},
{
"docstring": "Returns the sum of the subarray from index l to index r.",
"function_d... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def preprocess_array(arr):\n \"\"\"\n Preprocesses the array to compute prefix sums.\n \"\"\"\n prefix_sums = [0] * (len(arr) + 1)\n for i in range(... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085437",
"row_id": 85437,
"seed_ids": "[4602]"
} | 0.666895 | Taco_85437 | I | [
"prepare_prefix_sums",
"query_sum",
"process_queries"
] | 3 | [
[
"process_queries",
"prepare_prefix_sums"
],
[
"process_queries",
"query_sum"
]
] | 2 | [
"process_queries"
] | false | [] | false | pytest | true | [] | true | ff45a61baf020a3101fe240a109eab0758febb9f | f90c27a988ee1fa80e4c38a129a566d7dee57074 | |||
v1.0 | instruct | Taco | Taco_85462_I | Given an array of integers `arr`, you need to find and return the maximum sum of any contiguous subarray of the array. A subarray is a contiguous part of an array.
Your task is to implement the function `maxSubArraySum` that takes an array `arr` as input and returns an integer representing the maximum sum of a contig... | from typing import List
def maxCrossingSum(arr: List[int], left: int, mid: int, right: int) -> int:
sum_left = float('-inf')
sum_temp = 0
for i in range(mid, left - 1, -1):
sum_temp += arr[i]
if sum_temp > sum_left:
sum_left = sum_temp
sum_right = float('-inf')
sum_tem... | from solution import maxSubArraySum
def test_maxSubArraySum_example1():
assert maxSubArraySum([-2,1,-3,4,-1,2,1,-5,4]) == 6
def test_maxSubArraySum_example2():
assert maxSubArraySum([1]) == 1
def test_maxSubArraySum_example3():
assert maxSubArraySum([5,4,-1,7,8]) == 23
def test_maxSubArraySum_single_neg... | [
{
"docstring": null,
"function_declaration": "def maxCrossingSum(arr, left, mid, right):",
"function_name": "maxCrossingSum",
"parameter_list": "(arr, left, mid, right)"
},
{
"docstring": null,
"function_declaration": "def maxSubArraySumUtil(arr, left, right):",
"function_name": "max... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from typing import List\n\ndef maxSubArraySum(arr: List[int]) -> int:\n def find_max_crossing_subarray(arr, low, mid, high):\n left_sum = float('-inf')\n... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085462",
"row_id": 85462,
"seed_ids": "[2193]"
} | 0.791322 | Taco_85462 | I | [
"maxCrossingSum",
"maxSubArraySumUtil",
"maxSubArraySum"
] | 3 | [
[
"maxSubArraySum",
"maxSubArraySumUtil"
],
[
"maxSubArraySumUtil",
"maxCrossingSum"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 71c784c25e7cfb26b9b2d7276fce849a5948bc05 | 99a5076a264c7c44a5d515c522ff383933301fe5 | |||
v1.0 | instruct | Taco | Taco_85467_I | Dominic is a passionate gardener who loves unique flowers. He grows flowers in his garden in specific patterns. The layout of his garden is represented as an N x M grid, where each cell can either contain a flower (represented by a 1) or be empty (represented by a 0). Dominic can replicate entire rows or columns to cre... | def max_unique_rows_and_columns(grid):
"""
Returns the maximum number of unique rows and columns that can be achieved by replicating existing rows or columns.
"""
n = len(grid)
m = len(grid[0])
unique_rows = {tuple(row) for row in grid}
unique_columns = {tuple(grid[i][j] for i in range(n)) ... | from solution import process_input_and_solve
def test_case_1():
input_str = "3 3\n101\n010\n100"
assert process_input_and_solve(input_str) == (3, 3)
def test_case_2():
input_str = "3 3\n111\n101\n111"
assert process_input_and_solve(input_str) == (2, 2)
def test_case_3():
input_str = "4 4\n1010\n0... | [
{
"docstring": "Returns the maximum number of unique rows and columns that can be achieved by replicating existing rows or columns.",
"function_declaration": "def max_unique_rows_and_columns(grid):",
"function_name": "max_unique_rows_and_columns",
"parameter_list": "(grid)"
},
{
"docstring":... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_unique_rows_cols(grid):\n n = len(grid)\n m = len(grid[0])\n \n # Using sets to count unique rows and cols\n unique_rows = set()\n unique... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085467",
"row_id": 85467,
"seed_ids": "[24800]"
} | 0.666575 | Taco_85467 | I | [
"max_unique_rows_and_columns",
"process_input_and_solve"
] | 2 | [
[
"process_input_and_solve",
"max_unique_rows_and_columns"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8c19682b024d4d8a1af1b57d940c25069f7ce5db | e295ee099b1b6d1a5cc69866a97835f44d0ca40f | |||
v1.0 | instruct | Taco | Taco_85470_I | Amy enjoys creating geometric patterns using matrices. Recently, she came across an intriguing problem. She has an N by N matrix filled with zeroes, and she wants to place '1's along both main diagonals (the principal diagonal and the secondary diagonal) of the matrix.
Can you help her create such a matrix for a give... | def create_diagonal_matrix(N):
"""
Create an N by N matrix with 1's on both the principal and secondary diagonals.
"""
matrix = [[0]*N for _ in range(N)]
for i in range(N):
matrix[i][i] = 1
matrix[i][N-1-i] = 1
return matrix
def generate_matrices(test_cases):
"""
Generat... | from solution import create_diagonal_matrix, generate_matrices, format_matrices, main
def test_create_diagonal_matrix():
expected = [
[1, 0, 1],
[0, 1, 0],
[1, 0, 1]
]
assert create_diagonal_matrix(3) == expected
expected = [
[1, 0, 0, 1],
[0, 1, 1, 0],
... | [
{
"docstring": "Create an N by N matrix with 1's on both the principal and secondary diagonals.",
"function_declaration": "def create_diagonal_matrix(N):",
"function_name": "create_diagonal_matrix",
"parameter_list": "(N)"
},
{
"docstring": "Generate matrices for each test case.",
"funct... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def create_diagonal_matrix(size):\n \"\"\"\n Creates an NxN matrix with 1s on both the main and secondary diagonals.\n \"\"\"\n matrix = [[0] * size fo... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085470",
"row_id": 85470,
"seed_ids": "[19698]"
} | 0.535384 | Taco_85470 | I | [
"create_diagonal_matrix",
"generate_matrices",
"format_matrices",
"main"
] | 4 | [
[
"generate_matrices",
"create_diagonal_matrix"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | bce5a833714d9cce044b036047828b3c335078f2 | 488831b8ae5626aaf69246ce14dcf21809528667 | |||
v1.0 | instruct | Taco | Taco_85471_I | A botany enthusiast is cataloging various tree species in a vast forest. Each species of tree can be represented by a string made up of lowercase letters, where each character signifies a distinctive attribute. He wants to identify the most unique tree species by finding a tree species that shares the fewest common att... | def longest_common_subsequence(X, Y):
m = len(X)
n = len(Y)
# Create a DP table to store lengths of longest common subsequence
# for subproblems
dp = [[None]*(n+1) for _ in range(m+1)]
# Build dp[m+1][n+1] in bottom up fashion
for i in range(m+1):
for j in range(n+1):
i... | from solution import most_unique_species
def test_basic():
assert most_unique_species(3, ["oak", "maple", "fir"]) == "fir"
def test_duplicate_species():
assert most_unique_species(4, ["oak", "oak", "oak", "maple"]) == "maple"
def test_single_species():
assert most_unique_species(1, ["pine"]) == "pine"
d... | [
{
"docstring": null,
"function_declaration": "def longest_common_subsequence(X, Y):",
"function_name": "longest_common_subsequence",
"parameter_list": "(X, Y)"
},
{
"docstring": null,
"function_declaration": "def most_unique_species(n, species_list):",
"function_name": "most_unique_s... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def longest_common_subsequence(X, Y):\n m = len(X)\n n = len(Y)\n\n # Create a DP table to store lengths of longest common subsequence\n # for subprobl... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00085471",
"row_id": 85471,
"seed_ids": "[15325]"
} | 0.639816 | Taco_85471 | I | [
"longest_common_subsequence",
"most_unique_species"
] | 2 | [
[
"most_unique_species",
"longest_common_subsequence"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e39caa7030fa1ce01586ff111d40b5b37f5c8deb | 4e460d201a9cd8983167eccef4ea2fed3ff243d2 | |||
v1.0 | instruct | Taco | Taco_85502_I | You are working as a part of a team to develop a new video game. In the game, there are various levels, and each level has a certain number of points associated with it. You want to create a feature that allows a player to skip certain levels to maximize the total points they can accumulate.
However, there is a constr... | def max_points(T, test_cases):
"""
Calculate the maximum points a player can accumulate with the given constraints.
Parameters:
T (int): The number of test cases.
test_cases (List[Tuple[int, List[int]]]): A list of tuples where each tuple contains:
- An integer N (the number of levels)
... | from solution import max_points
def test_single_level():
assert max_points(1, [(1, [5])]) == [5]
def test_two_levels():
assert max_points(1, [(2, [5, 8])]) == [8]
def test_three_levels():
assert max_points(1, [(3, [1, 2, 3])]) == [4]
def test_four_levels():
assert max_points(1, [(4, [4, 5, 6, 7])]) ... | [
{
"docstring": "Calculate the maximum points a player can accumulate with the given constraints.\n\nParameters:\nT (int): The number of test cases.\ntest_cases (List[Tuple[int, List[int]]]): A list of tuples where each tuple contains:\n - An integer N (the number of levels)\n - A list of N integers repres... | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_points(T, test_cases):\n def helper(points):\n N = len(points)\n if N == 0:\n return 0\n if N == 1:\n return ... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00085502",
"row_id": 85502,
"seed_ids": "[20506]"
} | 0.725173 | Taco_85502 | I | [
"max_points",
"prepare_input"
] | 2 | [
[
"prepare_input",
"max_points"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e45f9d8880d26c627013663f2319b834bf570f93 | dd987fc0bc2617c7d4d0421c29aa2f90039fa529 | |||
v1.0 | instruct | Taco | Taco_85515_I | Alice is participating in a treasure hunt on an island that consists of `n` areas, numbered from 1 to `n`. There are `m` bidirectional paths between the areas. Alice starts in area 1, and her goal is to visit each area at least once.
Each path has a ticket cost associated with it. To traverse a specific path, Alice ne... | from collections import defaultdict
def min_ticket_costs(n, m, paths):
def find(parent, i):
if parent[i] == i:
return i
return find(parent, parent[i])
def union(parent, rank, x, y):
root_x = find(parent, x)
root_y = find(parent, y)
if rank[root_... | def test_solve_treasure_hunt():
# Test case 1
assert solve_treasure_hunt(4, 4, [
(1, 2, 7),
(2, 3, 9),
(3, 4, 5),
(4, 1, 6)
]) == 3
# Test case 2
assert solve_treasure_hunt(5, 6, [
(1, 2, 4),
(1, 3, 10),
(2, 3, 1),
(2, 4, 6),
... | [
{
"docstring": null,
"function_declaration": "def min_ticket_costs(n, m, paths):",
"function_name": "min_ticket_costs",
"parameter_list": "(n, m, paths)"
},
{
"docstring": null,
"function_declaration": "def solve_treasure_hunt(n, m, edges_input):",
"function_name": "solve_treasure_hu... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import defaultdict\n\ndef min_ticket_costs(n, m, paths):\n def find(parent, i):\n if parent[i] == i:\n return i\n retu... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00085515",
"row_id": 85515,
"seed_ids": "[4531]"
} | 0.702792 | Taco_85515 | I | [
"min_ticket_costs",
"solve_treasure_hunt"
] | 2 | [
[
"solve_treasure_hunt",
"min_ticket_costs"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 9fc17cee3a76863b38f0da5f180b1ed3ca75fa43 | 1ea530cac5036b9073bab7a9ca66938ae3ba1d7d | |||
v1.0 | instruct | Taco | Taco_85535_I | A young programmer loves Fibonacci numbers and plays a game of coding challenges. In one of the challenges, he needs to compute the Nth number in the Fibonacci sequence efficiently. Knowing that the standard recursive approach is too slow for large N, he seeks help to implement it using matrix exponentiation for optima... | MOD = 1000000007
def matrix_mult(A, B):
"""Multiplies two 2x2 matrices A and B under modulo MOD."""
return [
[(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % MOD,
(A[0][0] * B[0][1] + A[0][1] * B[1][1]) % MOD],
[(A[1][0] * B[0][0] + A[1][1] * B[1][0]) % MOD,
(A[1][0] * B[0][1] + A[1... | from solution import fibonacci
def test_fibonacci_0():
assert fibonacci(0) == 0
def test_fibonacci_1():
assert fibonacci(1) == 1
def test_fibonacci_5():
assert fibonacci(5) == 5
def test_fibonacci_10():
assert fibonacci(10) == 55
def test_fibonacci_50():
assert fibonacci(50) == 12586269025 % 10... | [
{
"docstring": "Multiplies two 2x2 matrices A and B under modulo MOD.",
"function_declaration": "def matrix_mult(A, B):",
"function_name": "matrix_mult",
"parameter_list": "(A, B)"
},
{
"docstring": "Computes matrix raised to the power under modulo MOD.",
"function_declaration": "def mat... | [
0,
0,
0,
0,
0,
0,
0,
1
] | 1 | hard | 0.125 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "MOD = 1000000007\n\ndef matrix_multiply(A, B):\n return [\n [(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % MOD, (A[0][0] * B[0][1] + A[0][1] * B[1][1]) % MOD... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00085535",
"row_id": 85535,
"seed_ids": "[22141]"
} | 0.661993 | Taco_85535 | I | [
"matrix_mult",
"matrix_pow",
"fibonacci"
] | 3 | [
[
"fibonacci",
"matrix_pow"
],
[
"matrix_pow",
"matrix_mult"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 6fa2344b94290915f0ad49d08cf3560d75053886 | d0c8008712e25732a38f64352804bdeea570a53a | |||
v1.0 | instruct | Taco | Taco_85576_I | ### Problem Description
In a kingdom far away, a wise king posed a challenge to find the bravest warrior among his knights. The challenge involved a unique competition called "Sum of Squares".
Given a list of integers, each representing the attacks of different knights, the bravest knight is the one whose sum of the ... | def sum_of_squares_of_digits(n):
"""
Given an integer n, returns the sum of the squares of its digits.
"""
return sum(int(digit)**2 for digit in str(n))
def bravest_knight(attacks):
"""
Given a list of integers representing the attack values of knights, returns
the attack value of the brave... | from solution import sum_of_squares_of_digits, bravest_knight
def test_sum_of_squares_of_digits():
assert sum_of_squares_of_digits(31) == 10 # 3^2 + 1^2 = 9 + 1 = 10
assert sum_of_squares_of_digits(52) == 29 # 5^2 + 2^2 = 25 + 4 = 29
assert sum_of_squares_of_digits(49) == 97 # 4^2 + 9^2 = 16 + 81 = 97
... | [
{
"docstring": "Given an integer n, returns the sum of the squares of its digits.",
"function_declaration": "def sum_of_squares_of_digits(n):",
"function_name": "sum_of_squares_of_digits",
"parameter_list": "(n)"
},
{
"docstring": "Given a list of integers representing the attack values of k... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def sum_of_squares_of_digits(n):\n \"\"\"\n Returns the sum of the squares of the digits of the number n.\n \"\"\"\n return sum(int(digit) ** 2 for dig... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00085576",
"row_id": 85576,
"seed_ids": "[266]"
} | 0.59794 | Taco_85576 | I | [
"sum_of_squares_of_digits",
"bravest_knight"
] | 2 | [
[
"bravest_knight",
"sum_of_squares_of_digits"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 7b354e67b111ee261fece2377299a8c2b99483ec | abce43106457cf45d506d2d93a45b6905b75ac7b | |||
v1.0 | instruct | Taco | Taco_85588_I | You are given a list of integers. For each integer, if it is a factorial number, print it; otherwise, continue to the next integer. A factorial number is a number that can be written as n! (n factorial) for some non-negative integer n.
Constraints
* 1 \leq L \leq 10^6 (length of the list)
* 1 \leq a_i \leq 10^{18} (e... | def is_factorial_number(n):
"""
Determines if n is a factorial number.
"""
if n == 1:
return True
f = 1
i = 1
while f < n:
i += 1
f *= i
return f == n
def print_factorial_numbers(L, numbers):
"""
Prints all factorial numbers from the list in ascending ord... | import io
import sys
import pytest
from solution import is_factorial_number, print_factorial_numbers
def test_is_factorial_number():
assert is_factorial_number(1) == True
assert is_factorial_number(2) == True
assert is_factorial_number(6) == True
assert is_factorial_number(24) == True
assert is_fac... | [
{
"docstring": "Determines if n is a factorial number.",
"function_declaration": "def is_factorial_number(n):",
"function_name": "is_factorial_number",
"parameter_list": "(n)"
},
{
"docstring": "Prints all factorial numbers from the list in ascending order,\neach on a new line.",
"functi... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import sys\nimport math\n\ndef generate_factorial_numbers(up_to):\n \"\"\"\n Generates a set of factorial numbers up to a given limit 'up_to'.\n \"\"\"\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085588",
"row_id": 85588,
"seed_ids": "[15237]"
} | 0.581286 | Taco_85588 | I | [
"is_factorial_number",
"print_factorial_numbers"
] | 2 | [
[
"print_factorial_numbers",
"is_factorial_number"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 40d749e339db4f8c5a64ddaf1b3d76cbc348c2e7 | 5f4615033b73b6ad0e00c7d1041df5593e11a48c | |||
v1.0 | instruct | Taco | Taco_85600_I | Create a function that simulates a message-passing system in a social network. Each user can send messages to other users, and each user can be a part of multiple groups. A message sent to a group is received by all users in that group. Implement the following two functions:
1. `send_message(user, message)`: Send a me... | def send_message(user, message, users):
"""
Sends a direct message to the specified user.
"""
if user in users:
users[user].append(message)
return users
def send_group_message(group, message, users, groups):
"""
Sends a message to all users in the specified group.
"""
if gro... | import pytest
from solution import send_message, send_group_message, process_commands
def test_send_message():
users = {'Alice': [], 'Bob': []}
send_message('Alice', 'Hello, Alice!', users)
assert users['Alice'] == ['Hello, Alice!']
send_message('Bob', 'Hi Bob!', users)
assert users['Bob'] == ['Hi ... | [
{
"docstring": "Sends a direct message to the specified user.",
"function_declaration": "def send_message(user, message, users):",
"function_name": "send_message",
"parameter_list": "(user, message, users)"
},
{
"docstring": "Sends a message to all users in the specified group.",
"functi... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def send_message(users, user, message):\n \"\"\"\n Send a message directly to a particular user.\n \n :param users: Dictionary containing user messages... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085600",
"row_id": 85600,
"seed_ids": "[21985]"
} | 0.504044 | Taco_85600 | I | [
"send_message",
"send_group_message",
"process_commands"
] | 3 | [
[
"process_commands",
"send_group_message"
],
[
"process_commands",
"send_message"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 130f4ffd0864f78832a90ef35a1372e3ff5cb006 | 9c6bcba8d056de50ab11e28909182c3216f2cb1d | |||
v1.0 | instruct | Taco | Taco_85699_I | After a long day of working with HTML, Lisa wants to relax by playing a game. The game consists of a grid with `m` rows and `n` columns, where each cell contains either a `0` or a `1`. The objective of the game is to find the largest contiguous subgrid that contains only `1`s. Help Lisa determine the size of this large... | def maximal_rectangle(matrix):
if not matrix:
return 0
max_area = 0
m, n = len(matrix), len(matrix[0])
heights = [0] * n
for i in range(m):
for j in range(n):
if matrix[i][j] == 0:
heights[j] = 0
else:
heights[j] += 1
... | def test_maximal_rectangle():
assert maximal_rectangle([
[1, 1, 0, 0, 1],
[1, 1, 0, 1, 1],
[1, 1, 1, 1, 1],
[0, 0, 1, 1, 1]
]) == 6
def test_maximal_rectangle_single_row():
assert maximal_rectangle([
[1, 1, 1, 1]
]) == 4
assert maximal_rectangle([
[1,... | [
{
"docstring": null,
"function_declaration": "def maximal_rectangle(matrix):",
"function_name": "maximal_rectangle",
"parameter_list": "(matrix)"
},
{
"docstring": null,
"function_declaration": "def largest_rectangle_area(heights):",
"function_name": "largest_rectangle_area",
"pa... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def maximal_rectangle(matrix):\n if not matrix:\n return 0\n\n max_area = 0\n m, n = len(matrix), len(matrix[0])\n heights = [0] * n\n\n for ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00085699",
"row_id": 85699,
"seed_ids": "[5465]"
} | 0.615321 | Taco_85699 | I | [
"maximal_rectangle",
"largest_rectangle_area"
] | 2 | [
[
"maximal_rectangle",
"largest_rectangle_area"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 5a5f88bdcb1634f15b48ed288f94e7bb175a54d0 | e742a810d0ecc5b39e6deb617fea4a708164d353 | |||
v1.0 | instruct | Taco | Taco_85717_I | Dave is teaching his pet parrot, Polly, to recognize sequences in a given list of integers. Polly has learned to recognize a sequence if the elements in them are consecutively increasing in value by 1. For example, [2, 3, 4] and [7, 8, 9, 10] are valid sequences, but [1, 3, 4] is not.
You decide to help Dave by writin... | def is_correct_sequence(lst):
for i in range(1, len(lst)):
if lst[i] != lst[i - 1] + 1:
return "Incorrect sequence"
return "Correct sequence"
def check_polys_sequence(m, lst):
if m != len(lst):
return "Incorrect input length"
return is_correct_sequence(lst) | from solution import check_polys_sequence
def test_correct_sequence_1():
assert check_polys_sequence(4, [4, 5, 6, 7]) == "Correct sequence"
def test_correct_sequence_2():
assert check_polys_sequence(3, [1, 2, 3]) == "Correct sequence"
def test_incorrect_sequence_1():
assert check_polys_sequence(5, [3, 4,... | [
{
"docstring": null,
"function_declaration": "def is_correct_sequence(lst):",
"function_name": "is_correct_sequence",
"parameter_list": "(lst)"
},
{
"docstring": null,
"function_declaration": "def check_polys_sequence(m, lst):",
"function_name": "check_polys_sequence",
"parameter... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_correct_sequence(m, sequence):\n \"\"\"\n Determines if the given sequence is a correct sequence where each element is exactly 1 greater than the prev... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085717",
"row_id": 85717,
"seed_ids": "[25261]"
} | 0.711543 | Taco_85717 | I | [
"is_correct_sequence",
"check_polys_sequence"
] | 2 | [
[
"check_polys_sequence",
"is_correct_sequence"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 4a8073d657045906dd9d81dbf70066470666989f | 3315f92d24cd728864bebdcf75ada7a41c46209a | |||
v1.0 | instruct | Taco | Taco_85771_I | Yana has recently learned about prime numbers and how to check if a number is prime. She is now curious about a specific problem that involves finding intervals with the most prime numbers within a given range of integers.
Yana has an array of integers a of length n and q queries to process. Each query is of the form:... | def sieve_of_eratosthenes(n):
"""
Returns a boolean array 'is_prime' of size n+1 where is_prime[i] is True if 'i' is a prime number.
"""
is_prime = [True] * (n + 1)
is_prime[0] = is_prime[1] = False
p = 2
while (p * p <= n):
if (is_prime[p] == True):
for i in range(p * p,... | def test_sieve_of_eratosthenes():
from solution import sieve_of_eratosthenes
assert sieve_of_eratosthenes(10) == [False, False, True, True, False, True, False, True, False, False, False]
assert sieve_of_eratosthenes(5) == [False, False, True, True, False, True]
def test_preprocess_primes():
from soluti... | [
{
"docstring": "Returns a boolean array 'is_prime' of size n+1 where is_prime[i] is True if 'i' is a prime number.",
"function_declaration": "def sieve_of_eratosthenes(n):",
"function_name": "sieve_of_eratosthenes",
"parameter_list": "(n)"
},
{
"docstring": "Preprocess to find the prefix sum... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Check if n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00085771",
"row_id": 85771,
"seed_ids": "[23700]"
} | 0.643008 | Taco_85771 | I | [
"sieve_of_eratosthenes",
"preprocess_primes",
"find_prime_count_in_subarray",
"process_queries"
] | 4 | [
[
"preprocess_primes",
"sieve_of_eratosthenes"
],
[
"process_queries",
"find_prime_count_in_subarray"
],
[
"process_queries",
"preprocess_primes"
]
] | 3 | [
"process_queries"
] | false | [] | false | pytest | true | [] | true | 3ee69c5ccaad8ad35858d8dc35a2c87a3d64fb9d | b89b79890bc94d325f30e05fb124ef3c91d192c6 | |||
v1.0 | instruct | Taco | Taco_85802_I | You are managing a network of computers in a corporate office. Each computer in the network is represented as a node, and the connections between them are represented as edges. The network is represented by a graph where each edge has a weight associated with it, representing the cost of communication between the two c... | def find(parent, i):
if parent[i] == i:
return i
return find(parent, parent[i])
def union(parent, rank, x, y):
xroot = find(parent, x)
yroot = find(parent, y)
if rank[xroot] < rank[yroot]:
parent[xroot] = yroot
elif rank[xroot] > rank[yroot]:
parent[yroot] = xroot
... | from solution import minimum_communication_cost
def test_sample_input():
N, M = 4, 5
connections = [
[1, 2, 1],
[1, 3, 4],
[2, 3, 2],
[3, 4, 3],
[2, 4, 5]
]
assert minimum_communication_cost(N, M, connections) == 6
def test_no_edges():
N, M = 4, 0
connec... | [
{
"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)"
},
... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = f... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085802",
"row_id": 85802,
"seed_ids": "[16115]"
} | 0.795129 | Taco_85802 | I | [
"find",
"union",
"kruskalMST",
"minimum_communication_cost"
] | 4 | [
[
"kruskalMST",
"find"
],
[
"kruskalMST",
"union"
],
[
"minimum_communication_cost",
"kruskalMST"
],
[
"union",
"find"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | 508e2be1ea1480e5f2c53170478b3f43db089f52 | cc5c8515cef76526ae066714c65c49ae9cf73e57 | |||
v1.0 | instruct | Taco | Taco_85822_I | In a kingdom far away, there are several cities connected by roads that form a tree structure, i.e., there are exactly n-1 roads and any two cities are connected by exactly one path. The Kingdom's government wants to improve trade by designating a single city as the capital. Each city is associated with a number of goo... | def find_optimal_city(n, goods, roads):
from collections import defaultdict, deque
tree = defaultdict(list)
for u, v in roads:
tree[u].append(v)
tree[v].append(u)
subtree_size = [0] * (n + 1)
total_distance = [0] * (n + 1)
parent = [-1] * (n + 1)
def dfs(node):... | def test_example_case():
assert optimal_capital(5, [1, 2, 3, 4, 5], [(1, 2), (2, 3), (2, 4), (3, 5)]) == 3
def test_all_cities_produce_zero_goods():
assert optimal_capital(4, [0, 0, 0, 0], [(1, 2), (1, 3), (3, 4)]) == 1
def test_single_city():
assert optimal_capital(2, [10, 10], [(1, 2)]) == 1
def test_l... | [
{
"docstring": null,
"function_declaration": "def find_optimal_city(n, goods, roads):",
"function_name": "find_optimal_city",
"parameter_list": "(n, goods, roads)"
},
{
"docstring": null,
"function_declaration": "def optimal_capital(n, goods, roads):",
"function_name": "optimal_capit... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import sys\nfrom collections import defaultdict, deque\n\ndef find_capital(n, goods, roads):\n tree = defaultdict(list)\n \n for u, v in roads:\n t... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085822",
"row_id": 85822,
"seed_ids": "[9003]"
} | 0.724377 | Taco_85822 | I | [
"find_optimal_city",
"optimal_capital"
] | 2 | [
[
"optimal_capital",
"find_optimal_city"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | cf223322d57345af3a6b072a17f81b6e85ebc233 | 325e38264b2c6836b21db5c2eecf64e4a533f00a | |||
v1.0 | instruct | Taco | Taco_85848_I | Monocarp is participating in a marathon event organized in his hometown. The marathon route consists of several checkpoints, and each participant must go through a certain number of checkpoints to complete the marathon. Cherishing the number "2023", the organizers decided that the checkpoints must be passed in such a w... | def prime_factors(n):
factors = []
d = 2
while d * d <= n:
while (n % d) == 0:
factors.append(d)
n //= d
d += 1
if n > 1:
factors.append(n)
return factors
def get_indices_for_product(p):
factors = prime_factors(p)
if len(factors) < 2:
... | from solution import get_indices_for_product
def test_single_prime():
# only one factor, invalid case
assert get_indices_for_product(3) == -1
def test_multiple_factors():
# valid cases
assert get_indices_for_product(2023) == [7, 17, 17] or [1, 17, 2023]
assert get_indices_for_product(180) == [2, 2... | [
{
"docstring": null,
"function_declaration": "def prime_factors(n):",
"function_name": "prime_factors",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def get_indices_for_product(p):",
"function_name": "get_indices_for_product",
"parameter_list": "(p)"
... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_checkpoint_indices(p):\n \"\"\"\n Finds a set of checkpoint indices whose product equals p.\n Returns the indices in increasing order if possible... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085848",
"row_id": 85848,
"seed_ids": "[20997]"
} | 0.657473 | Taco_85848 | I | [
"prime_factors",
"get_indices_for_product",
"solve_marathons",
"main"
] | 4 | [
[
"get_indices_for_product",
"prime_factors"
],
[
"solve_marathons",
"get_indices_for_product"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | a03bf7dd34acb0f081d038921c02c26efcca7211 | 651fecbe278e50060c1816f75e3b15627b94ec75 | |||
v1.0 | instruct | Taco | Taco_85861_I | You are managing a parking lot system. The parking lot has a limited number of slots and time constraints for parking each vehicle. Your task is to handle the entry and exit of cars in the parking lot efficiently.
A car can park if there is an available slot. When a car enters, you need to record the current time and ... | from datetime import datetime, timedelta
def parse_time(time_str):
return datetime.strptime(time_str, "%H:%M")
def calculate_fee(start, end):
time_diff = end - start
total_hours = time_diff.total_seconds() / 3600
fee = (total_hours // 1 + (1 if total_hours % 1 > 0 else 0)) * 10
return int(fee)
de... | from solution import manage_parking_lot
def test_sample_case():
N = 3
M = 5
events = [
"entry 1234 10:00",
"entry 5678 10:30",
"entry 9101 11:00",
"exit 1234 13:45",
"exit 5678 14:15"
]
result = manage_parking_lot(N, M, events)
assert result == ["1234 40"... | [
{
"docstring": null,
"function_declaration": "def parse_time(time_str):",
"function_name": "parse_time",
"parameter_list": "(time_str)"
},
{
"docstring": null,
"function_declaration": "def calculate_fee(start, end):",
"function_name": "calculate_fee",
"parameter_list": "(start, e... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\nfrom datetime import datetime\n\ndef calculate_parking_fee(entry_time, exit_time):\n entry_dt = datetime.strptime(entry_time, '%H:%M')\n exit_dt... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085861",
"row_id": 85861,
"seed_ids": "[2634]"
} | 0.726519 | Taco_85861 | I | [
"parse_time",
"calculate_fee",
"manage_parking_lot"
] | 3 | [
[
"manage_parking_lot",
"calculate_fee"
],
[
"manage_parking_lot",
"parse_time"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | a4837ea22f007ee032731727be6211450ee7b3ec | 9727469183901a420f13628a7a0106430a3e81ee | |||
v1.0 | instruct | Taco | Taco_85907_I | In the fictional land of Codeen, there are M towns, connected by R bidirectional roads. Each road has a certain length. The ruler of Codeen, King Algorith, is planning to build a new highway system that further connects these towns. This new system must be built in such a way that it minimizes the total travel distance... | def find(parent, i):
if parent[i] == i:
return i
else:
return find(parent, parent[i])
def union(parent, rank, xroot, yroot):
if rank[xroot] < rank[yroot]:
parent[xroot] = yroot
elif rank[xroot] > rank[yroot]:
parent[yroot] = xroot
else:
parent[yroot] = xroot
... | def test_minimum_total_road_length():
M = 4
R = 3
existing_roads = [
(1, 2, 5),
(2, 3, 10),
(3, 4, 3)
]
K = 2
new_roads = [
(1, 3, 2),
(2, 4, 1)
]
assert minimum_total_road_length(M, existing_roads, K, new_roads) == 6
def test_case_with_no_new_roa... | [
{
"docstring": null,
"function_declaration": "def find(parent, i):",
"function_name": "find",
"parameter_list": "(parent, i)"
},
{
"docstring": null,
"function_declaration": "def union(parent, rank, xroot, yroot):",
"function_name": "union",
"parameter_list": "(parent, rank, xroo... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class UnionFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.rank = [0] * n\n\n def find(self, u):\n if self.parent[u... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00085907",
"row_id": 85907,
"seed_ids": "[9658]"
} | 0.679729 | Taco_85907 | I | [
"find",
"union",
"kruskal_mst",
"minimum_total_road_length"
] | 4 | [
[
"kruskal_mst",
"find"
],
[
"kruskal_mst",
"union"
],
[
"minimum_total_road_length",
"kruskal_mst"
]
] | 3 | [] | false | [] | false | pytest | false | [] | true | f80cb79807caeaa83a406c57f7b8abfcda7fbf2e | b462f0548a784b19de1088e2a3bc004a9b734aa0 | |||
v1.0 | instruct | Taco | Taco_85908_I | You are given an integer array and your task is to find out whether there is a way to split the array into two subsequences such that:
1. Each subsequence is strictly increasing, and
2. Each element from the original array belongs to exactly one of the two subsequences.
If it is possible to create such subsequences, ... | def split_to_increasing_subsequences(t, test_cases):
results = []
for i in range(t):
n, arr = test_cases[i]
if can_split(arr):
sub1, sub2 = generate_subsequences(arr)
results.append(f"YES\n{' '.join(map(str, sub1))}\n{' '.join(map(str, sub2))}")
else:
... | def split_to_increasing_subsequences(t, test_cases):
results = []
for i in range(t):
n, arr = test_cases[i]
if can_split(arr):
sub1, sub2 = generate_subsequences(arr)
results.append(f"YES\n{' '.join(map(str, sub1))}\n{' '.join(map(str, sub2))}")
else:
... | [
{
"docstring": null,
"function_declaration": "def split_to_increasing_subsequences(t, test_cases):",
"function_name": "split_to_increasing_subsequences",
"parameter_list": "(t, test_cases)"
},
{
"docstring": null,
"function_declaration": "def can_split(arr):",
"function_name": "can_s... | [
1,
1
] | 2 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def split_array_into_two_increasing_subsequences(t, test_cases):\n results = []\n \n for case in test_cases:\n n, arr = case\n if n < 2:\n ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00085908",
"row_id": 85908,
"seed_ids": "[18194]"
} | 0.740538 | Taco_85908 | I | [
"split_to_increasing_subsequences",
"can_split",
"generate_subsequences"
] | 3 | [
[
"split_to_increasing_subsequences",
"can_split"
],
[
"split_to_increasing_subsequences",
"generate_subsequences"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | 75a03783adb307583a6d3cd684ad0723e50cca9b | 849904cb383d4c311039782ba1f282ddc32e42e5 | |||
v1.0 | instruct | Taco | Taco_85932_I | Alice has developed an innovative sorting algorithm called 'HybridSort', which combines both merge sort and quicksort under specific conditions to optimize the sorting process. HybridSort works as follows:
1. If the size of the array is less than or equal to a given threshold `k`, it uses quicksort.
2. If the size of ... | def hybrid_sort(arr, k):
if len(arr) <= k:
quicksort(arr, 0, len(arr)-1)
else:
merge_sort(arr)
def quicksort(arr, low, high):
if low < high:
pi = partition(arr, low, high)
quicksort(arr, low, pi - 1)
quicksort(arr, pi + 1, high)
def partition(arr, low, high):
pi... | from solution import hybrid_sort_array
def test_hybrid_sort_example():
assert hybrid_sort_array(10, 3, [10, 7, 1, 8, 3, 5, 4, 2, 9, 6]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
def test_hybrid_sort_small_array():
assert hybrid_sort_array(5, 2, [5, 2, 3, 1, 4]) == [1, 2, 3, 4, 5]
def test_hybrid_sort_large_k():
... | [
{
"docstring": null,
"function_declaration": "def hybrid_sort(arr, k):",
"function_name": "hybrid_sort",
"parameter_list": "(arr, k)"
},
{
"docstring": null,
"function_declaration": "def quicksort(arr, low, high):",
"function_name": "quicksort",
"parameter_list": "(arr, low, high... | [
1,
1
] | 2 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def hybrid_sort(array, k):\n def quicksort(arr):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085932",
"row_id": 85932,
"seed_ids": "[8777]"
} | 0.598769 | Taco_85932 | I | [
"hybrid_sort",
"quicksort",
"partition",
"merge_sort",
"hybrid_sort_array"
] | 5 | [
[
"hybrid_sort",
"merge_sort"
],
[
"hybrid_sort",
"quicksort"
],
[
"hybrid_sort_array",
"hybrid_sort"
],
[
"quicksort",
"partition"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | a737a09e4d417ac3ec7220ace5ff8e30e0fb7112 | 1160d5d3e1ea83652c4a5ff6e86b02bf6540bccb | |||
v1.0 | instruct | Taco | Taco_85938_I | Alice has received a list of integers from her friend Bob. Bob claims that each integer in the list is a power of 2. Alice wants to verify Bob's claim and needs your help to check if all integers in the list are indeed powers of 2.
An integer n is a power of 2 if there exists an integer x such that n = 2^x. For examp... | def is_power_of_two(n):
return (n > 0) and (n & (n - 1)) == 0
def verify_bob_claim(t, integer_list):
for num in integer_list:
if not is_power_of_two(num):
return "NO"
return "YES" | from solution import is_power_of_two, verify_bob_claim
def test_is_power_of_two():
assert is_power_of_two(1) == True
assert is_power_of_two(2) == True
assert is_power_of_two(4) == True
assert is_power_of_two(8) == True
assert is_power_of_two(3) == False
assert is_power_of_two(6) == False
as... | [
{
"docstring": null,
"function_declaration": "def is_power_of_two(n):",
"function_name": "is_power_of_two",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def verify_bob_claim(t, integer_list):",
"function_name": "verify_bob_claim",
"parameter_list": "(t... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_power_of_two(n):\n \"\"\"\n Checks if a given integer n is a power of two.\n \"\"\"\n return (n > 0) and (n & (n - 1)) == 0\n\ndef check_powers_... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00085938",
"row_id": 85938,
"seed_ids": "[17594]"
} | 0.647293 | Taco_85938 | I | [
"is_power_of_two",
"verify_bob_claim"
] | 2 | [
[
"verify_bob_claim",
"is_power_of_two"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c82f4b6a5385d6af1fdb64d5ee21a99c65c0e231 | c2db7ae00fb99f2f04ea3fca3d6836a25a2f9e7a | |||
v1.0 | instruct | Taco | Taco_85974_I | You are given a list of integers. Your goal is to split the list into exactly three contiguous subarrays such that the sum of the elements in each subarray is a prime number. Determine whether such a division is possible.
-----Input-----
The first line contains a single integer $n$ ($3 \le n \le 1000$) — the number ... | def is_prime(num):
if num <= 1:
return False
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while (i * i <= num):
if num % i == 0 or num % (i + 2) == 0:
return False
i += 6
return True
def can_split_into_three_pri... | from solution import can_split_into_three_prime_sums
def test_example_1():
assert can_split_into_three_prime_sums(8, [2, 4, 5, 1, 2, 7, 3, 6]) == "NO"
def test_example_2():
assert can_split_into_three_prime_sums(5, [1, 1, 1, 1, 1]) == "NO"
def test_prime_splits_1():
assert can_split_into_three_prime_sums... | [
{
"docstring": null,
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": null,
"function_declaration": "def can_split_into_three_prime_sums(n, lst):",
"function_name": "can_split_into_three_prime_sums",
"parameter... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00085974",
"row_id": 85974,
"seed_ids": "[23089]"
} | 0.643834 | Taco_85974 | I | [
"is_prime",
"can_split_into_three_prime_sums"
] | 2 | [
[
"can_split_into_three_prime_sums",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 46266bf56b1ba29fc231199f2aa92f74200fdb55 | cec1dcbf3ed42c158b41341847033bef5aa8b157 | |||
v1.0 | instruct | Taco | Taco_85999_I | Sarah's startup is developing a new messaging platform, and she is trying to implement a feature for matching users based on shared interests. Each user has a unique ID and a list of interests. The goal is to find pairs of users who have at least one common interest. Sarah needs this functionality to be efficient, as t... | def find_matching_users(n, user_data):
from collections import defaultdict
interest_to_users = defaultdict(set)
for user_id, interests in user_data:
for interest in interests:
interest_to_users[interest].add(user_id)
pairs = set()
for users in interest_to_users.values()... | def test_matching_users():
# Test Case 1
n1 = 3
input1 = [
"1 hiking coding",
"2 cooking hiking",
"3 cooking",
]
expected_output1 = ["1 2", "2 3"]
assert matching_users(n1, input1) == expected_output1
# Test Case 2
n2 = 4
input2 = [
"1 tennis",
... | [
{
"docstring": null,
"function_declaration": "def find_matching_users(n, user_data):",
"function_name": "find_matching_users",
"parameter_list": "(n, user_data)"
},
{
"docstring": null,
"function_declaration": "def process_input(n, input_lines):",
"function_name": "process_input",
... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_matching_users(n, user_data):\n from collections import defaultdict\n \n interest_to_users = defaultdict(set)\n for user_id, interests in user... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00085999",
"row_id": 85999,
"seed_ids": "[18994]"
} | 0.581372 | Taco_85999 | I | [
"find_matching_users",
"process_input",
"matching_users"
] | 3 | [
[
"matching_users",
"find_matching_users"
],
[
"matching_users",
"process_input"
]
] | 2 | [
"process_input"
] | false | [] | false | pytest | false | [] | true | 378d55f8ec0fdb794f406e57241484a679c85290 | 85674fe70f594bafb275e9599ff577c4e7d59905 | |||
v1.0 | instruct | Taco | Taco_86021_I | You are given a binary tree consisting of $n$ nodes. The nodes are numbered from $1$ to $n$ with the root being node $1$. Each node has a unique integer value assigned to it.
You should process $q$ queries with it. Each query is one of two types:
"$1$ $u$ $x$" — update the value of node $u$ to $x$;
"$2$ $u$ $v$" — f... | from collections import defaultdict
import sys
sys.setrecursionlimit(200000)
class SegmentTree:
def __init__(self, values):
self.n = len(values)
self.tree = [0] * (2 * self.n)
self.build(values)
def build(self, values):
for i in range(self.n):
self.tree[self.n+i] =... | def test_binary_tree_queries():
n = 7
q = 5
node_values = [1, 2, 3, 4, 5, 6, 7]
edges = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7)]
queries = [[2, 4, 5], [1, 4, 10], [2, 4, 5], [2, 6, 7], [2, 1, 7]]
expected_result = [5, 10, 7, 7]
assert process_queries(n, q, node_values, edges, queri... | [] | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.children = []\n\ndef dfs_lca(node, parent, depth, parent_tracker, depth_t... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00086021",
"row_id": 86021,
"seed_ids": "[21156]"
} | 0.717586 | Taco_86021 | I | [
"find_lca_and_paths",
"depth_first_search",
"process_queries"
] | 3 | [
[
"process_queries",
"depth_first_search"
],
[
"process_queries",
"find_lca_and_paths"
]
] | 2 | [
"process_queries"
] | false | [
"SegmentTree"
] | true | pytest | false | [] | true | c1c80ea1d03b375793ee48250eb2997da6dd32e6 | 0a259498cbd5258cad826b72fddc41326e022c40 | |||
v1.0 | instruct | Taco | Taco_86058_I | Points: 20
The National Oceanographic and Atmospheric Administration (NOAA) is conducting research on seabed sediment composition to study historical climate patterns. Scientists analyze sediment samples, each documented as a sequence of mineral compositions. For data consistency, they need a mechanism to determine if ... | def is_harmonically_aligned(sequence):
"""
Determine if the sequence is harmonically aligned and, if not, suggest one possible position
where a single alteration could make it harmonically aligned.
"""
n = len(sequence)
if n < 3:
return "Aligned"
# Calculate the initial ratio
... | def test_is_harmonically_aligned_already_aligned():
assert is_harmonically_aligned([2, 4, 8, 16, 32]) == "Aligned"
def test_is_harmonically_aligned_single_change_needed():
assert is_harmonically_aligned([1, 3, 9, 10]) == "4"
def test_is_harmonically_aligned_cannot_be_aligned():
assert is_harmonically_alig... | [
{
"docstring": "Determine if the sequence is harmonically aligned and, if not, suggest one possible position\nwhere a single alteration could make it harmonically aligned.",
"function_declaration": "def is_harmonically_aligned(sequence):",
"function_name": "is_harmonically_aligned",
"parameter_list"... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_harmonically_aligned(sequence):\n \"\"\"\n Determine if the sequence is harmonically aligned and, if not, suggest one possible position\n where a s... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00086058",
"row_id": 86058,
"seed_ids": "[2307]"
} | 0.568614 | Taco_86058 | I | [
"is_harmonically_aligned",
"is_uniform_ratio",
"harmonically_aligned_results"
] | 3 | [
[
"harmonically_aligned_results",
"is_harmonically_aligned"
],
[
"is_harmonically_aligned",
"is_uniform_ratio"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | cf85c48edd57f7f9a98db5ecf50b25c1714c44b9 | e767135ef751c8d9917990182d21dc701ec09c73 | |||
v1.0 | instruct | Taco | Taco_86084_I | One popular problem-solving technique in competitive programming contests is using the sliding window technique. In this problem, you are given a list of integers and a window size. Your task is to compute the maximum sum of the elements inside the sliding window. It's a common problem that tests understanding of array... | def max_sum_in_window(arr, K):
"""
Compute the maximum sum of elements inside a sliding window of size K.
:param arr: List of integers
:param K: Size of the sliding window
:return: Maximum sum of any subarray of size K
"""
N = len(arr)
if N < K:
return None
# Initial su... | from solution import max_sum_in_window, get_max_sum
def test_max_sum_in_window():
assert max_sum_in_window([1, 3, -1, -3, 5, 3, 6, 7], 3) == 16
assert max_sum_in_window([1, 2, 3, 4, 5], 2) == 9
assert max_sum_in_window([-1, -2, -3, -4, -5], 2) == -3
assert max_sum_in_window([1, 3, 4, 6, 8, 3, 2], 1) ==... | [
{
"docstring": "Compute the maximum sum of elements inside a sliding window of size K.\n\n:param arr: List of integers\n:param K: Size of the sliding window\n:return: Maximum sum of any subarray of size K",
"function_declaration": "def max_sum_in_window(arr, K):",
"function_name": "max_sum_in_window",
... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_sum_subarray(arr, N, K):\n \"\"\"\n Finds the maximum sum of a subarray with length K.\n \"\"\"\n # Initial sum of the first window\n max_su... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00086084",
"row_id": 86084,
"seed_ids": "[21224]"
} | 0.705903 | Taco_86084 | I | [
"max_sum_in_window",
"process_input",
"get_max_sum"
] | 3 | [
[
"get_max_sum",
"max_sum_in_window"
],
[
"get_max_sum",
"process_input"
]
] | 2 | [
"process_input"
] | false | [] | false | pytest | true | [] | true | 371e7b6153c3c848902b0ce87d13b1902eeb3285 | 15a57e857486b731446298e7b13b0aa6d3be423d | |||
v1.0 | instruct | Taco | Taco_86115_I | You are required to implement a file compression utility. This utility needs to scan through a directory, compress all the files in it, and store the compressed files in a subdirectory named "compressed". Your goal is to use the Run-Length Encoding (RLE) algorithm for compression. This algorithm compresses sequences of... | import os
def rle_compress(content: str) -> str:
"""
Compresses a string using Run-Length Encoding (RLE).
"""
if not content:
return ""
compressed = []
last_char = content[0]
count = 1
for char in content[1:]:
if char == last_char:
count += 1
... | import os
import pytest
# Import the function from the solution code if it were in a file named solution.py
# from solution import compress_directory
def test_rle_compress():
assert rle_compress("AAAABBBCCDAA") == "A,4B,3C,2D,1A,2"
assert rle_compress("A") == "A,1"
assert rle_compress("") == ""
assert... | [
{
"docstring": "Compresses a string using Run-Length Encoding (RLE).",
"function_declaration": "def rle_compress(content):",
"function_name": "rle_compress",
"parameter_list": "(content)"
},
{
"docstring": "Compresses all text files in the given directory using the RLE algorithm.\nStores the... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import os\n\ndef rle_compress(content: str) -> str:\n \"\"\"\n Compresses a string using Run-Length Encoding (RLE).\n \"\"\"\n if not content:\n ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00086115",
"row_id": 86115,
"seed_ids": "[23689]"
} | 0.668292 | Taco_86115 | I | [
"rle_compress",
"compress_directory"
] | 2 | [
[
"compress_directory",
"rle_compress"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | d15be2a9b357e01310a05e67ea9638f617663680 | 4d28959ff22e4db5b83e2e760cb190f90db5f7cd | |||
v1.0 | instruct | Taco | Taco_86135_I | In an attempt to understand more complex graph structures, you're given an interesting task involving a weighted undirected graph. The graph is defined by N nodes and M edges, and each edge has an associated weight. The graph might not be connected initially, so your task is to transform this graph into a single connec... | import heapq
def find(parent, x):
if parent[x] != x:
parent[x] = find(parent, parent[x])
return parent[x]
def union(parent, rank, x, y):
rootX = find(parent, x)
rootY = find(parent, y)
if rootX != rootY:
if rank[rootX] > rank[rootY]:
parent[rootY] = rootX
e... | def test_fully_connected_graph():
assert min_weight_to_connect_graph(4, 3, [(1, 2, 1), (2, 3, 2), (3, 4, 3)]) == 0
def test_disconnected_graph():
assert min_weight_to_connect_graph(4, 2, [(1, 2, 1), (3, 4, 1)]) == "No"
def test_single_node():
assert min_weight_to_connect_graph(1, 0, []) == 0
def test_pos... | [
{
"docstring": null,
"function_declaration": "def find(parent, x):",
"function_name": "find",
"parameter_list": "(parent, x)"
},
{
"docstring": null,
"function_declaration": "def union(parent, rank, x, y):",
"function_name": "union",
"parameter_list": "(parent, rank, x, y)"
},
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\nfrom collections import defaultdict\n\ndef find(parent, i):\n while parent[i] != i:\n i = parent[i]\n return i\n\ndef union(parent, rank... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00086135",
"row_id": 86135,
"seed_ids": "[1773]"
} | 0.773204 | Taco_86135 | I | [
"find",
"union",
"min_weight_to_connect_graph"
] | 3 | [
[
"min_weight_to_connect_graph",
"find"
],
[
"min_weight_to_connect_graph",
"union"
],
[
"union",
"find"
]
] | 3 | [] | false | [] | false | pytest | false | [] | true | 749071cea1d21cc8c91654f3f7e09c65998e26d4 | a46bc4ab9a3de43a0f3127e36f06505355848062 | |||
v1.0 | instruct | Taco | Taco_86192_I | You are given a string containing digits '0'-'9' and lower-case letters 'a'-'z'. Each character can be mapped to a number based on its position in the character set; digits map to '0'-'9' and letters map to '10'-'35'. Your task is to find the minimum sum of the numbers you can obtain by partitioning the string into con... | def char_to_number(c):
if '0' <= c <= '9':
return ord(c) - ord('0')
elif 'a' <= c <= 'z':
return ord(c) - ord('a') + 10
def partition_and_sum(s):
# Sum individual values
return sum(char_to_number(c) for c in s)
def min_sum_partition(strings):
results = []
for s in strings:
... | from solution import char_to_number, partition_and_sum, min_sum_partition
def test_char_to_number():
assert char_to_number('0') == 0
assert char_to_number('5') == 5
assert char_to_number('9') == 9
assert char_to_number('a') == 10
assert char_to_number('m') == 22
assert char_to_number('z') == 35... | [
{
"docstring": null,
"function_declaration": "def char_to_number(c):",
"function_name": "char_to_number",
"parameter_list": "(c)"
},
{
"docstring": null,
"function_declaration": "def partition_and_sum(s):",
"function_name": "partition_and_sum",
"parameter_list": "(s)"
},
{
... | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def min_sum_partition(s):\n \"\"\"\n This function will return the minimum sum of the numbers obtained \n by partitioning the string into contiguous subst... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00086192",
"row_id": 86192,
"seed_ids": "[9882]"
} | 0.755897 | Taco_86192 | I | [
"char_to_number",
"partition_and_sum",
"min_sum_partition"
] | 3 | [
[
"min_sum_partition",
"partition_and_sum"
],
[
"partition_and_sum",
"char_to_number"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 584f91a4c8fecbe8dcd8045f3fa1f2c4cae4eb21 | 4118166ff34f410537f5e5cf6074538b366b0b05 | |||
v1.0 | instruct | Taco | Taco_86222_I | You are given an array of n integers and m queries. Each query asks for the minimum element present in a specific subarray. Your task is to efficiently determine the minimum value within the given range for each query.
### Input
- The first line contains two integers, n and m (1 ≤ n ≤ 5·10^4, 1 ≤ m ≤ 5·10^3) — the si... | def preprocess_min(arr):
"""
Preprocess the array using a Sparse Table to enable efficient range minimum queries.
"""
import math
n = len(arr)
log = math.ceil(math.log2(n))
st = [[0] * (log + 1) for _ in range(n)]
# Initializing Sparse Table
for i in range(n):
st[i][0] = ar... | from solution import solve
def test_example_1():
n = 8
m = 3
arr = [4, 2, 6, 1, 7, 5, 3, 8]
queries = [(1, 4), (2, 6), (3, 8)]
expected_output = [1, 1, 1]
assert solve(n, m, arr, queries) == expected_output
def test_example_2():
n = 5
m = 2
arr = [9, 7, 5, 6, 3]
queries = [(1, ... | [
{
"docstring": "Preprocess the array using a Sparse Table to enable efficient range minimum queries.",
"function_declaration": "def preprocess_min(arr):",
"function_name": "preprocess_min",
"parameter_list": "(arr)"
},
{
"docstring": null,
"function_declaration": "def range_minimum_query... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_minimums(n, m, array, queries):\n \"\"\"\n Returns a list of minimum values for each query range in the array.\n \n Parameters:\n n (int): ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00086222",
"row_id": 86222,
"seed_ids": "[23421]"
} | 0.683734 | Taco_86222 | I | [
"preprocess_min",
"range_minimum_query",
"process_queries",
"solve"
] | 4 | [
[
"process_queries",
"preprocess_min"
],
[
"process_queries",
"range_minimum_query"
],
[
"solve",
"process_queries"
]
] | 3 | [
"process_queries"
] | false | [] | false | pytest | true | [] | true | 45ba96aca3521292354f52bef32b8e181aa84e17 | 84ad7371913583e630c9c439ea0db95eb65c7bf7 | |||
v1.0 | instruct | Taco | Taco_86241_I | Given a number, find if it's a Happy Number.
A Happy Number is a number defined by the following process:
- Starting with any positive integer, replace the number by the sum of the squares of its digits.
- Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does ... | def is_happy_number(n):
def get_next(number):
total_sum = 0
while number > 0:
number, digit = divmod(number, 10)
total_sum += digit ** 2
return total_sum
seen = set()
while n != 1 and n not in seen:
seen.add(n)
n = get_next(n)
return ... | from solution import is_happy_number, happy_number_classifier
def test_is_happy_number():
assert is_happy_number(19) == True
assert is_happy_number(7) == True
assert is_happy_number(2) == False
assert is_happy_number(1) == True
assert is_happy_number(0) == False
def test_happy_number_classifier():... | [
{
"docstring": null,
"function_declaration": "def is_happy_number(n):",
"function_name": "is_happy_number",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def happy_number_classifier(T, numbers):",
"function_name": "happy_number_classifier",
"parameter_l... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_happy_number(n):\n \"\"\"\n Determines if a number n is a Happy Number.\n \"\"\"\n seen = set()\n while n != 1 and n not in seen:\n se... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00086241",
"row_id": 86241,
"seed_ids": "[8612]"
} | 0.577156 | Taco_86241 | I | [
"is_happy_number",
"happy_number_classifier"
] | 2 | [
[
"happy_number_classifier",
"is_happy_number"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 6c1dd24fa702f7318232260b97e3b5c45a6b70a0 | 3e52a3957ffb023bf77b7e5bb1d9aa7d078e0f2c | |||
v1.0 | instruct | Taco | Taco_86270_I | Problem statement
You are given an undirected graph with $N$ nodes and $M$ edges. Each edge has a weight associated with it. The graph is guaranteed to be connected.
The goal is to find the minimum possible cost to traverse the graph by visiting each node at least once. You can start and end at any node, and you are ... | import heapq
def minimum_spanning_tree_cost(graph, n):
"""
Prim's algorithm to find the minimum spanning tree (MST) cost in a connected undirected graph.
"""
visited = [False] * n
min_heap = [(0, 0)] # (cost, node)
total_cost = 0
while min_heap:
cost, u = heapq.heappop(min_heap)
... | import pytest
from solution import minimum_traversal_cost
def test_example_1():
N = 4
M = 5
edges = [
(1, 2, 3),
(2, 3, 4),
(3, 4, 5),
(4, 1, 6),
(2, 4, 2)
]
assert minimum_traversal_cost(N, M, edges) == 9
def test_example_2():
N = 3
M = 3
edges ... | [
{
"docstring": "Prim's algorithm to find the minimum spanning tree (MST) cost in a connected undirected graph.",
"function_declaration": "def minimum_spanning_tree_cost(graph, n):",
"function_name": "minimum_spanning_tree_cost",
"parameter_list": "(graph, n)"
},
{
"docstring": "Given N nodes... | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\n\ndef prim(N, adj):\n \"\"\"\n Uses Prim's algorithm to calculate the Minimum Spanning Tree (MST) for the given graph.\n This helps in obtai... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00086270",
"row_id": 86270,
"seed_ids": "[11939]"
} | 0.805618 | Taco_86270 | I | [
"minimum_spanning_tree_cost",
"minimum_traversal_cost"
] | 2 | [
[
"minimum_traversal_cost",
"minimum_spanning_tree_cost"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 782c9b44508bc27006c8e1e0cd10bf64c0221f40 | 206377f402a574c88d01a1c100a3f38af2877fec | |||
v1.0 | instruct | Taco | Taco_86276_I | A palindrome is a word, phrase, number, or other sequences of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalization). Write a function that takes a string as input and returns the longest palindromic substring within it. If there are multiple substrings of the same length... | def preprocess_string(s):
"""
Remove non-alphanumeric characters and convert to lowercase
"""
return ''.join(char.lower() for char in s if char.isalnum())
def longest_palindromic_substring(s):
"""
Returns the longest palindromic substring within the input string s.
"""
s = preprocess_st... | from solution import longest_palindromic_substring
def test_longest_palindromic_substring_basic():
assert longest_palindromic_substring("babad") == "bab" or longest_palindromic_substring("babad") == "aba"
assert longest_palindromic_substring("cbbd") == "bb"
assert longest_palindromic_substring("a") == "a"
... | [
{
"docstring": "Remove non-alphanumeric characters and convert to lowercase",
"function_declaration": "def preprocess_string(s):",
"function_name": "preprocess_string",
"parameter_list": "(s)"
},
{
"docstring": "Returns the longest palindromic substring within the input string s.",
"func... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def longest_palindromic_substring(s):\n \"\"\"\n Returns the longest palindromic substring within the input string s.\n Ignores non-alphanumeric character... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00086276",
"row_id": 86276,
"seed_ids": "[14758]"
} | 0.791733 | Taco_86276 | I | [
"preprocess_string",
"longest_palindromic_substring"
] | 2 | [
[
"longest_palindromic_substring",
"preprocess_string"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 0290ab0594437afa0359678584254765df67f3dd | db7e1dba67307c6f9b5a0613a8907ed7d86c429b | |||
v1.0 | instruct | Taco | Taco_86291_I | In a programming challenge, you are asked to analyze strings and find specific patterns within them. The task is to identify "word squares" in a given list of words. A word square is a special arrangement of words in grid form where the words read the same vertically and horizontally.
For instance, if you have a list ... | def is_word_square(words):
"""
Determines if the given list of words form a word square.
"""
n = len(words)
for i in range(n):
for j in range(n):
if j < len(words[i]) and i < len(words[j]):
if words[i][j] != words[j][i]:
return False
... | from solution import is_word_square, evaluate_word_squares, parse_input
def test_is_word_square():
assert is_word_square(["BALL", "AREA", "LEAD", "LADY"]) == True
assert is_word_square(["AREA", "LEAD", "BALL", "LARD"]) == False
assert is_word_square(["AB", "BA"]) == True
assert is_word_square(["AB", "C... | [
{
"docstring": "Determines if the given list of words form a word square.",
"function_declaration": "def is_word_square(words):",
"function_name": "is_word_square",
"parameter_list": "(words)"
},
{
"docstring": "Evaluates multiple datasets and returns a list indicating if a word square can b... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_word_square(words):\n \"\"\"\n Determines if the given list of words form a word square.\n \"\"\"\n n = len(words)\n for i in range(n):\n ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00086291",
"row_id": 86291,
"seed_ids": "[22809]"
} | 0.5975 | Taco_86291 | I | [
"is_word_square",
"evaluate_word_squares",
"parse_input"
] | 3 | [
[
"evaluate_word_squares",
"is_word_square"
]
] | 1 | [
"parse_input"
] | false | [] | false | pytest | true | [] | true | 8b75276d393e96caa892c822f9d805ceb4699622 | 3f623d9f7e724572dd2ea8bd11c0e7976c5c1861 | |||
v1.0 | instruct | Taco | Taco_86339_I | In the mystic land of Graphington, there are N cities connected by M roads. The cities are labeled from 1 to N. Some of these roads, however, have been damaged by recent storms and need to be repaired. Each road has a repair cost associated with it. The ruling council of Graphington needs to ensure that there is at lea... | from collections import defaultdict
import heapq
MOD = 1_000_000_007
def find_minimal_repair_cost_and_ways(n, m, edges):
parent = list(range(n))
size = [1] * n
def find(x):
if parent[x] != x:
parent[x] = find(parent[x])
return parent[x]
def union(x, y):
rootX = fi... | def test_solve_example_case():
input_str = "5 6\n1 2 3\n1 3 4\n4 2 5\n5 1 2\n2 3 7\n3 5 6\n"
assert solve_graphington(input_str) == (14, 1)
def test_small_disconnected_case():
input_str = "4 3\n1 2 1\n2 3 1\n3 4 1\n"
assert solve_graphington(input_str) == (3, 1)
def test_single_node():
input_str =... | [
{
"docstring": null,
"function_declaration": "def find_minimal_repair_cost_and_ways(n, m, edges):",
"function_name": "find_minimal_repair_cost_and_ways",
"parameter_list": "(n, m, edges)"
},
{
"docstring": null,
"function_declaration": "def solve_graphington(input_str):",
"function_n... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "MOD = 1000000007\n\ndef find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00086339",
"row_id": 86339,
"seed_ids": "[6440]"
} | 0.749818 | Taco_86339 | I | [
"find_minimal_repair_cost_and_ways",
"solve_graphington"
] | 2 | [
[
"solve_graphington",
"find_minimal_repair_cost_and_ways"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 8d2196a642ad9014770dff440fc70730e9b27339 | 1c7b38698956083c80ed295588cc6b54d8b13ed0 | |||
v1.0 | instruct | Taco | Taco_86443_I | A company wants to create a system to manage their employees and their hierarchical organization within different departments. The company structure follows a tree-like hierarchy where each employee might manage multiple subordinates but has exactly one direct supervisor except the top-most manager, who has no supervis... | from collections import defaultdict, deque
def find_furthest_node(start_node, graph, n):
"""
Performs a BFS from the start_node to find the furthest node from it and the distance to that node
"""
visited = [False] * (n + 1)
queue = deque([(start_node, 0)])
visited[start_node] = True
furthe... | from solution import find_diameter
def test_find_diameter_example1():
n = 5
connections = [(1, 2), (1, 3), (2, 4), (2, 5)]
assert find_diameter(n, connections) == 3
def test_find_diameter_example2():
n = 6
connections = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6)]
assert find_diameter(n, connectio... | [
{
"docstring": "Performs a BFS from the start_node to find the furthest node from it and the distance to that node",
"function_declaration": "def find_furthest_node(start_node, graph, n):",
"function_name": "find_furthest_node",
"parameter_list": "(start_node, graph, n)"
},
{
"docstring": "F... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import defaultdict, deque\n\ndef find_diameter(n, edges):\n graph = defaultdict(list)\n\n for u, v in edges:\n graph[u].append(v)\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00086443",
"row_id": 86443,
"seed_ids": "[4690]"
} | 0.648812 | Taco_86443 | I | [
"find_furthest_node",
"find_diameter"
] | 2 | [
[
"find_diameter",
"find_furthest_node"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 464c7dfff76625d8c42617246449e2473d6007db | 04b614882e4514e5b5d7cae627b4fd3ba7ddd374 | |||
v1.0 | instruct | Taco | Taco_86510_I | Write a program that takes an integer number `n` and determines if it is a "digit-sum prime" number. A "digit-sum prime" number is a number such that the sum of its digits is a prime number.
### Input
The input consists of a single integer number `n` (1 ≤ n < 10^5).
### Output
Output `"Yes"` if the number `n` is a ... | def is_prime(num):
"""
Determines if a number is prime.
"""
if num <= 1:
return False
if num == 2:
return True
if num % 2 == 0:
return False
for i in range(3, int(num**0.5) + 1, 2):
if num % i == 0:
return False
return True
def digit_sum(n):
... | from solution import is_digit_sum_prime
def test_example_1():
assert is_digit_sum_prime(41) == "Yes"
def test_example_2():
assert is_digit_sum_prime(42) == "No"
def test_edge_case_1():
assert is_digit_sum_prime(1) == "No"
def test_edge_case_2():
assert is_digit_sum_prime(99999) == "No"
def test_pri... | [
{
"docstring": "Determines if a number is prime.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Returns the sum of the digits of the number n.",
"function_declaration": "def digit_sum(n):",
"function_name": "d... | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is a prime number\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ... | trial_gpt4o_5 | {
"original_instruction": "",
"prompt_id": "00086510",
"row_id": 86510,
"seed_ids": "[636]"
} | 0.709441 | Taco_86510 | I | [
"is_prime",
"digit_sum",
"is_digit_sum_prime"
] | 3 | [
[
"is_digit_sum_prime",
"digit_sum"
],
[
"is_digit_sum_prime",
"is_prime"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 7b21708823567a8d924a9d7660b694f2815680cd | c098cc47ddc3a1d3f1c92c6df03547098e12d079 | |||
v1.0 | instruct | Taco | Taco_86583_I | Mike has a stack of plates, each with a different weight. He loves to perform transformations on the stack to make it more balanced. A stack is considered balanced if, for any two consecutive plates, the ratio of their weights is within a specified range.
Given the weights of the plates in a stack and a range $[L, U]$... | from itertools import permutations
def is_balanced(plates, L, U):
"""
Check if a given permutation of plates is balanced.
"""
for i in range(len(plates) - 1):
ratio = plates[i+1] / plates[i]
if not (L <= ratio <= U):
return False
return True
def balance_stack(n, m, weig... | from solution import balance_stack
def test_balance_stack_case_1():
assert balance_stack(3, 500, [2, 4, 8], 2, 2) == (2, 4, 8)
def test_balance_stack_case_2():
assert balance_stack(3, 500, [1, 100, 10], 1, 5) == "Not Possible"
def test_balance_stack_case_3():
assert balance_stack(4, 1000, [4, 1, 2, 8], 2... | [
{
"docstring": "Check if a given permutation of plates is balanced.",
"function_declaration": "def is_balanced(plates, L, U):",
"function_name": "is_balanced",
"parameter_list": "(plates, L, U)"
},
{
"docstring": "Determine if it is possible to reorder the plates such that the stack is balan... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from itertools import permutations\n\ndef is_balanced(plates, L, U):\n \"\"\"\n Check if a given permutation of plates is balanced.\n \"\"\"\n for i in... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00086583",
"row_id": 86583,
"seed_ids": "[12226]"
} | 0.555859 | Taco_86583 | I | [
"is_balanced",
"balance_stack"
] | 2 | [
[
"balance_stack",
"is_balanced"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 4516102dde5c892c9846f321adade158fda224e5 | f0c6ae8f32ff3f377b834c0ee6f70becab9b4fb1 | |||
v1.0 | instruct | Taco | Taco_86629_I | Leonardo loves both mathematics and programming. To combine his interests, he often invents problems that involve interesting numerical properties. Recently, he came up with a problem that involves balanced numbers.
A number is called balanced if the sum of its digits in the odd positions is equal to the sum of its di... | def is_balanced(number):
"""
Check if the given number is balanced.
A number is balanced if the sum of its digits in the odd positions is equal
to the sum of its digits in the even positions.
"""
num_str = str(number)
odd_sum = sum(int(num_str[i]) for i in range(0, len(num_str), 2))
even... | from solution import is_balanced, count_balanced_numbers
def test_is_balanced():
assert is_balanced(1234) == False
assert is_balanced(4321) == False
assert is_balanced(1111) == True
assert is_balanced(2222) == True
assert is_balanced(123456) == False
assert is_balanced(654321) == False
asse... | [
{
"docstring": "Check if the given number is balanced.\nA number is balanced if the sum of its digits in the odd positions is equal\nto the sum of its digits in the even positions.",
"function_declaration": "def is_balanced(number):",
"function_name": "is_balanced",
"parameter_list": "(number)"
},... | [
0,
0,
0,
1,
0
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_balanced_number(number):\n number_str = str(number)\n odd_sum = sum(int(number_str[i]) for i in range(0, len(number_str), 2))\n even_sum = sum(int(... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00086629",
"row_id": 86629,
"seed_ids": "[8486]"
} | 0.630133 | Taco_86629 | I | [
"is_balanced",
"count_balanced_numbers"
] | 2 | [
[
"count_balanced_numbers",
"is_balanced"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8508f042d124bf61ec052009cdd92fa9fc8c8be8 | f52e3314e9322053c73ef5ef82ebdd36cd112c05 | |||
v1.0 | instruct | Taco | Taco_86641_I | Given an unsorted array of integers, write a function that returns a new array containing all the prime numbers from the original array, sorted in descending order. A prime number is defined as a number greater than 1 that has no positive divisors other than 1 and itself. If there are no prime numbers in the given arra... | import math
def is_prime(num):
if num <= 1:
return False
for i in range(2, math.isqrt(num) + 1):
if num % i == 0:
return False
return True
def extractAndSortPrimes(arr):
primes = [num for num in arr if is_prime(num)]
primes.sort(reverse=True)
return primes | from solution import extractAndSortPrimes
def test_example_1():
assert extractAndSortPrimes([10, 15, 3, 7, 11, 18, 29]) == [29, 11, 7, 3]
def test_example_2():
assert extractAndSortPrimes([4, 6, 8, 10, 12]) == []
def test_no_primes():
assert extractAndSortPrimes([1, 4, 6, 8, 10, 12, 14, 15]) == []
def t... | [
{
"docstring": null,
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": null,
"function_declaration": "def extractAndSortPrimes(arr):",
"function_name": "extractAndSortPrimes",
"parameter_list": "(arr)"
}
] | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef is_prime(n):\n \"\"\" Returns True if n is a prime number, False otherwise \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00086641",
"row_id": 86641,
"seed_ids": "[3856]"
} | 0.613037 | Taco_86641 | I | [
"is_prime",
"extractAndSortPrimes"
] | 2 | [
[
"extractAndSortPrimes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 871105d1b546ecab7f1061da1f4031652081d35c | 1c823cc19e8b25cfda43d699e57b7c0b81c19e46 | |||
v1.0 | instruct | Taco | Taco_86675_I | **Fibonacci Spiral**
You are planning to create a wall art installation that uses the Fibonacci sequence to determine the size and arrangement of tiles. Each tile in the installation will be square, and the side length of each tile will correspond to a number in the Fibonacci sequence.
To summarize, the Fibonacci se... | def fibonacci(n):
"""
Generates the first n Fibonacci numbers.
"""
if n == 1:
return [0]
fib_sequence = [0, 1]
for i in range(2, n):
fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])
return fib_sequence
def fibonacci_spiral_area(n):
"""
Computes the total area... | import pytest
from solution import fibonacci, fibonacci_spiral_area, compute_areas
def test_fibonacci():
assert fibonacci(1) == [0]
assert fibonacci(2) == [0, 1]
assert fibonacci(3) == [0, 1, 1]
assert fibonacci(5) == [0, 1, 1, 2, 3]
def test_fibonacci_spiral_area():
assert fibonacci_spiral_area(1... | [
{
"docstring": "Generates the first n Fibonacci numbers.",
"function_declaration": "def fibonacci(n):",
"function_name": "fibonacci",
"parameter_list": "(n)"
},
{
"docstring": "Computes the total area covered by the first n Fibonacci numbers' tiles.",
"function_declaration": "def fibonac... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def fibonacci(n):\n \"\"\"\n Generates the first n Fibonacci numbers.\n \"\"\"\n if n == 1:\n return [0]\n fib_sequence = [0, 1]\n for i i... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00086675",
"row_id": 86675,
"seed_ids": "[8446]"
} | 0.545532 | Taco_86675 | I | [
"fibonacci",
"fibonacci_spiral_area",
"compute_areas"
] | 3 | [
[
"compute_areas",
"fibonacci_spiral_area"
],
[
"fibonacci_spiral_area",
"fibonacci"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | c8341b1b0d421f1455c0114e69e0879199121fc4 | 072f4c8a58c4867c6dc001efffd7ee0ef12714d7 | |||
v1.0 | instruct | Taco | Taco_86685_I | You are given an integer array `a` of length `n` and an integer `k`. Your task is to process `m` queries on it. Each query consists of two integers `l` and `r`, you need to find the minimum length of any subarray within the range `[l; r]` that contains at least `k` distinct elements. If there is no such subarray, the o... | def min_length_subarray_with_k_distinct(nums, k, queries):
from collections import defaultdict
def min_length_subarray(l, r, k):
window_start = l
min_length = float('inf')
freq = defaultdict(int)
distinct_count = 0
for window_end in range(l, r + 1):
if f... | def test_basic_example():
nums = [1, 2, 1, 3, 4, 2, 3, 1]
queries = [(1, 4), (2, 8), (3, 5)]
result = answer_queries(8, 3, nums, 3, queries)
assert result == [3, 3, 3]
def test_no_possible_subarray():
nums = [1, 2, 1, 1, 1]
queries = [(1, 5), (1, 4)]
result = answer_queries(5, 3, nums, 2, q... | [
{
"docstring": null,
"function_declaration": "def min_length_subarray_with_k_distinct(nums, k, queries):",
"function_name": "min_length_subarray_with_k_distinct",
"parameter_list": "(nums, k, queries)"
},
{
"docstring": null,
"function_declaration": "def answer_queries(n, k, nums, m, que... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def min_length_subarray_with_k_distinct(a, n, k, queries):\n results = []\n\n def min_length_for_query(l, r):\n min_length = float('inf')\n fre... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00086685",
"row_id": 86685,
"seed_ids": "[13207]"
} | 0.751262 | Taco_86685 | I | [
"min_length_subarray_with_k_distinct",
"answer_queries"
] | 2 | [
[
"answer_queries",
"min_length_subarray_with_k_distinct"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 1a59023e39ff088a13d7ea89153e9104e478a51d | c4670841cb4f81a9169794829a5bceed637891c4 | |||
v1.0 | instruct | Taco | Taco_86716_I | A local library is organizing a book exhibition where multiple authors will present their books. Each author has a particular time slot during which they will discuss their book collections. The exhibition must ensure that there is no overlap between any two authors' presentations, as it will cause confusion among the ... | def schedule_presentation(M, A, durations):
"""
Schedules the presentations for authors without overlapping time slots.
Parameters:
M (int): The total duration of the exhibition.
A (int): The number of authors.
durations (list of int): List of presentation durations each author ... | from solution import schedule_presentation, format_schedule
def test_sample_input_1():
M = 10
A = 3
durations = [3, 3, 4]
expected = [(0, 3), (3, 6), (6, 10)]
assert schedule_presentation(M, A, durations) == expected
def test_sample_input_2():
M = 5
A = 2
durations = [3, 3]
expecte... | [
{
"docstring": "Schedules the presentations for authors without overlapping time slots.\n\nParameters:\n M (int): The total duration of the exhibition.\n A (int): The number of authors.\n durations (list of int): List of presentation durations each author requires.\n\nReturns:\n list or str: \"No Sc... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def create_schedule(total_duration, num_authors, durations):\n \"\"\"\n Creates a schedule for authors' presentations ensuring no overlap.\n :param total_... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00086716",
"row_id": 86716,
"seed_ids": "[1674]"
} | 0.63518 | Taco_86716 | I | [
"schedule_presentation",
"format_schedule"
] | 2 | [
[
"format_schedule",
"schedule_presentation"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 921ae71915e88524067fea32c23d8814b226ab1d | 197a3bf78ce99688565938ea7104b14707b6bcbe | |||
v1.0 | instruct | Taco | Taco_86728_I | In a quiet town called Codeville, the local botanist, Alex, is working on growing a special kind of flower that only blooms under specific conditions. Alex has a rectangular grid garden with specific cells classified as 'fertile' or 'barren'. The garden is represented as a 2D grid of size N x M where each cell is eithe... | def maximalRectangle(matrix):
if not matrix:
return 0
def largestRectangleArea(heights):
stack = []
max_area = 0
heights.append(0)
for i in range(len(heights)):
while stack and heights[i] < heights[stack[-1]]:
h = heights[stack.po... | def test_largest_fertile_subrectangle():
grid1 = [
[1, 0, 1, 0, 0],
[1, 0, 1, 1, 1],
[1, 1, 1, 1, 1],
[1, 0, 0, 1, 0]
]
assert largest_fertile_subrectangle(4, 5, grid1) == 6
grid2 = [
[1, 1, 1],
[1, 1, 1],
[1, 1, 1]
]
assert largest_fertil... | [
{
"docstring": null,
"function_declaration": "def maximalRectangle(matrix):",
"function_name": "maximalRectangle",
"parameter_list": "(matrix)"
},
{
"docstring": null,
"function_declaration": "def largest_fertile_subrectangle(N, M, grid):",
"function_name": "largest_fertile_subrectan... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def maximalRectangle(matrix):\n if not matrix:\n return 0\n\n max_area = 0\n dp = [0] * len(matrix[0])\n\n for i in range(len(matrix)):\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00086728",
"row_id": 86728,
"seed_ids": "[24800]"
} | 0.635679 | Taco_86728 | I | [
"maximalRectangle",
"largest_fertile_subrectangle"
] | 2 | [
[
"largest_fertile_subrectangle",
"maximalRectangle"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 0201362b656187bfee656ea23eb592efed2a8643 | f293bad7cfdd0312ba3928ac67c64b0beb79d816 | |||
v1.0 | instruct | Taco | Taco_86745_I | Write a program to determine if a given number is a "Narcissistic number" or not. A number is considered narcissistic if the sum of its own digits each raised to the power of the number of digits is equal to the number itself.
For instance, 153 is a narcissistic number because \(1^3 + 5^3 + 3^3 = 153\).
------ Input... | def is_narcissistic_number(N):
digits = [int(d) for d in str(N)]
power = len(digits)
return sum(d**power for d in digits) == N
def check_narcissistic_numbers(T, numbers):
results = []
for number in numbers:
if is_narcissistic_number(number):
results.append("Yes")
else:
... | from solution import is_narcissistic_number, check_narcissistic_numbers
def test_is_narcissistic_number():
assert is_narcissistic_number(153) == True
assert is_narcissistic_number(9474) == True
assert is_narcissistic_number(123) == False
assert is_narcissistic_number(370) == True
assert is_narcissi... | [
{
"docstring": null,
"function_declaration": "def is_narcissistic_number(N):",
"function_name": "is_narcissistic_number",
"parameter_list": "(N)"
},
{
"docstring": null,
"function_declaration": "def check_narcissistic_numbers(T, numbers):",
"function_name": "check_narcissistic_number... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_narcissistic_number(N):\n \"\"\"\n Determine if a number is a narcissistic number.\n \"\"\"\n digits = [int(d) for d in str(N)]\n power = len... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00086745",
"row_id": 86745,
"seed_ids": "[8419]"
} | 0.618421 | Taco_86745 | I | [
"is_narcissistic_number",
"check_narcissistic_numbers"
] | 2 | [
[
"check_narcissistic_numbers",
"is_narcissistic_number"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | fe01daa4cbc5912a45a76b6e64f8f1eedf3d904a | b1337c0e0de7fb78d4187a45a24af0bf22b52864 | |||
v1.0 | instruct | Taco | Taco_86798_I | You are given a rectangular grid of size N x M. Each cell in the grid contains either a 0 or a 1. You need to find the size of the largest rectangle containing only 1s.
Write a function that takes in the grid as a list of lists of integers and returns the area of the largest rectangle containing only 1s.
-----Constra... | def maximalRectangle(matrix):
"""
Find the largest rectangle containing only 1s in a grid.
:param matrix: List of list of integers representing the grid
:return: Integer representing the area of the largest rectangle containing only 1s
"""
if not matrix:
return 0
# Preparation step:... | def test_maximalRectangle():
grid1 = [[1, 0, 1, 0, 0],
[1, 0, 1, 1, 1],
[1, 1, 1, 1, 1],
[1, 0, 0, 1, 0]]
assert maximalRectangle(grid1) == 6
grid2 = [[0, 1],
[1, 1]]
assert maximalRectangle(grid2) == 2
grid3 = [[0, 0],
[0, 0]]
a... | [
{
"docstring": "Find the largest rectangle containing only 1s in a grid.\n:param matrix: List of list of integers representing the grid\n:return: Integer representing the area of the largest rectangle containing only 1s",
"function_declaration": "def maximalRectangle(matrix):",
"function_name": "maximal... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def maximalRectangle(matrix):\n \"\"\"\n Find the largest rectangle containing only 1s in a grid.\n :param matrix: List of list of integers representing t... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00086798",
"row_id": 86798,
"seed_ids": "[18759]"
} | 0.752045 | Taco_86798 | I | [
"maximalRectangle",
"max_histogram_area"
] | 2 | [
[
"maximalRectangle",
"max_histogram_area"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 23cc6ef40b592f08fa80edd1ca763d0319d3991e | 8a571faaef83a6c01d4ed0da6db083b9fd2cc672 | |||
v1.0 | instruct | Taco | Taco_86817_I | Jane loves playing with arrays and has recently come across a fascinating problem. She wants to perform a series of operations on an array of integers where each operation either increments or decrements a subarray by a specific value. Additionally, after performing all the operations, Jane wants to determine the maxim... | def process_operations_and_find_extremes(T, cases):
results = []
for i in range(T):
N, array, Q, operations = cases[i]
for op in operations:
L, R, V = op
for j in range(L-1, R):
array[j] += V
# Finding the max and min values with their sm... | from solution import jane_array_operations
def test_example_case():
input_data = """2
5
1 2 3 4 5
2
1 3 2
2 5 -1
4
1 -1 0 2
3
1 2 3
2 4 -4
1 4 1"""
expected_output = """3 4
1 3
1 5
3 -3"""
assert jane_array_operations(input_data) == expected_output
def test_single_operation():
input_data = """1
4
... | [
{
"docstring": null,
"function_declaration": "def process_operations_and_find_extremes(T, cases):",
"function_name": "process_operations_and_find_extremes",
"parameter_list": "(T, cases)"
},
{
"docstring": null,
"function_declaration": "def parse_input(input_lines):",
"function_name"... | [
0,
0,
0,
0,
1
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def perform_operations(T, test_cases):\n results = []\n for t in range(T):\n N = test_cases[t][\"N\"]\n arr = test_cases[t][\"arr\"]\n Q... | trial_gpt4o_4 | {
"original_instruction": "",
"prompt_id": "00086817",
"row_id": 86817,
"seed_ids": "[13071]"
} | 0.718578 | Taco_86817 | I | [
"process_operations_and_find_extremes",
"parse_input",
"jane_array_operations"
] | 3 | [
[
"jane_array_operations",
"parse_input"
],
[
"jane_array_operations",
"process_operations_and_find_extremes"
]
] | 2 | [
"parse_input"
] | false | [] | false | pytest | true | [] | true | 0e14736ac5a7becf905919235b1d2705d387d42b | df2eebc7295136138087ba0a0e9817db9506d9dc | |||
v1.0 | instruct | Taco | Taco_86837_I | In a city, there are N intersections connected by M bidirectional roads. Each road has a specific travel time associated with it. The mayor wants to construct a new subway system comprising only one direct route, which can replace any one of the existing roads. The goal is to minimize the maximum travel time between an... | import heapq
# Using modified Dijkstra's algorithm to find the shortest paths
def dijkstra(n, graph, start):
dist = [float('inf')] * n
dist[start] = 0
pq = [(0, start)]
while pq:
current_dist, u = heapq.heappop(pq)
if current_dist > dist[u]:
continue
... | def test_parse_input():
input_str = "2\n4 4\n1 2 4\n2 3 5\n3 4 6\n4 1 7\n3 3\n1 2 3\n2 3 1\n3 1 2\n"
expected_output = [
(4, 4, [(1, 2, 4), (2, 3, 5), (3, 4, 6), (4, 1, 7)]),
(3, 3, [(1, 2, 3), (2, 3, 1), (3, 1, 2)])
]
assert parse_input(input_str) == expected_output
def test_min_max_tr... | [
{
"docstring": null,
"function_declaration": "def dijkstra(n, graph, start):",
"function_name": "dijkstra",
"parameter_list": "(n, graph, start)"
},
{
"docstring": null,
"function_declaration": "def min_max_travel_time(test_cases):",
"function_name": "min_max_travel_time",
"param... | [
0,
0,
1,
0
] | 1 | hard | 0.25 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\n\ndef dijkstra(n, graph, start):\n distances = [float('inf')] * (n + 1)\n distances[start] = 0\n pq = [(0, start)] # (distance, node)\n ... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00086837",
"row_id": 86837,
"seed_ids": "[10026]"
} | 0.755735 | Taco_86837 | I | [
"dijkstra",
"min_max_travel_time",
"parse_input",
"solve"
] | 4 | [
[
"min_max_travel_time",
"dijkstra"
],
[
"solve",
"min_max_travel_time"
],
[
"solve",
"parse_input"
]
] | 3 | [
"parse_input"
] | false | [] | false | pytest | false | [] | true | f0e8678adc6e87f0a215e3c15137109cae1032c6 | fb5a6794674f29ed067c5b267362058fc0e4e905 | |||
v1.0 | instruct | Taco | Taco_86994_I | Prime Number Sum in a Matrix
---------------------------
In this task, you will write a function that finds and sums all the prime numbers in a given m x n matrix. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
### Function Signature
```python
def prime_matrix... | from typing import List
def is_prime(n: int) -> bool:
"""Helper function to check if a number is prime."""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return False
re... | from solution import prime_matrix_sum
def test_prime_matrix_sum_basic():
matrix = [
[2, 3, 4],
[5, 6, 7],
[8, 9, 10]
]
assert prime_matrix_sum(matrix) == 17
def test_prime_matrix_sum_empty():
matrix = [
[]
]
assert prime_matrix_sum(matrix) == 0
def test_prime_m... | [
{
"docstring": "Helper function to check if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns the sum of all prime numbers in a given matrix.",
"function_declaration": "def prime_matrix_sum(mat... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from typing import List\n\ndef is_prime(num: int) -> bool:\n if num <= 1:\n return False\n if num == 2: # 2 is a prime number\n return True\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00086994",
"row_id": 86994,
"seed_ids": "[7706]"
} | 0.581178 | Taco_86994 | I | [
"is_prime",
"prime_matrix_sum"
] | 2 | [
[
"prime_matrix_sum",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 9e70803c6c7e7da358316ffd5bbec8d1339d15f6 | 718d2b4be44c75b03285678be9a1c74cd047b996 | |||
v1.0 | instruct | Taco | Taco_87007_I | Birds are migrating, and they take flight in groups. Each bird is represented by its energy level. The Bird Leader wants to know the group’s strength, which is defined as the sum of the maximum subarray in the energies. Additionally, the Bird Leader is curious if the group has any weak links, defined as the minimum ene... | def max_subarray_sum(arr):
"""
Returns the sum of the maximum subarray in the array.
"""
max_sum = current_sum = arr[0]
for num in arr[1:]:
current_sum = max(num, current_sum + num)
max_sum = max(max_sum, current_sum)
return max_sum
def min_energy(arr):
"""
Returns the m... | def test_max_subarray_sum():
assert max_subarray_sum([1, 2, 3, 4, 5]) == 15
assert max_subarray_sum([-2, 1, -3, 4, -1, 2, 1, -5, 4]) == 6
assert max_subarray_sum([-1, -2, -3]) == -1
assert max_subarray_sum([4, -1, 2, 1]) == 6
def test_min_energy():
assert min_energy([1, 2, 3, 4, 5]) == 1
assert... | [
{
"docstring": "Returns the sum of the maximum subarray in the array.",
"function_declaration": "def max_subarray_sum(arr):",
"function_name": "max_subarray_sum",
"parameter_list": "(arr)"
},
{
"docstring": "Returns the minimum energy in the list.",
"function_declaration": "def min_energ... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def kadane_algorithm(arr):\n \"\"\"\n Function to find the maximum subarray sum using Kadane's Algorithm.\n \"\"\"\n max_current = max_global = arr[0]\... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00087007",
"row_id": 87007,
"seed_ids": "[10676]"
} | 0.674267 | Taco_87007 | I | [
"max_subarray_sum",
"min_energy",
"bird_flight_analysis"
] | 3 | [
[
"bird_flight_analysis",
"max_subarray_sum"
],
[
"bird_flight_analysis",
"min_energy"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | 1c9d44ef6e96c571a30dfe915a45bcfe3939e7d1 | 0921dd76f8ebaa0299977895d5a01ca957e752b2 | |||
v1.0 | instruct | Taco | Taco_87049_I | You are hired to design a sorting algorithm for the local library. Given a number of books, each book is identified by its serial number and has a unique title. The library wants to sort books based on their titles. However, if two titles are the same, then they should be sorted by their serial numbers in ascending ord... | def sort_books(datasets):
sorted_books = []
for books in datasets:
books.sort(key=lambda x: (x[1], x[0]))
sorted_books.extend(books)
return sorted_books
def parse_input(input_list):
datasets = []
current_dataset = []
for line in input_list:
if line == '0':
if... | from solution import library_sort
def test_library_sort_case_1():
input_list = [
'3',
'123 Hamlet',
'456 RomeoAndJuliet',
'789 Hamlet',
'0'
]
expected_output = [
'123 Hamlet',
'789 Hamlet',
'456 RomeoAndJuliet'
]
assert library_sort(in... | [
{
"docstring": null,
"function_declaration": "def sort_books(datasets):",
"function_name": "sort_books",
"parameter_list": "(datasets)"
},
{
"docstring": null,
"function_declaration": "def parse_input(input_list):",
"function_name": "parse_input",
"parameter_list": "(input_list)"... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def sort_books(datasets):\n sorted_books = []\n for books in datasets:\n books.sort(key=lambda x: (x[1], x[0]))\n sorted_books.extend(books)\n ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00087049",
"row_id": 87049,
"seed_ids": "[1771]"
} | 0.5733 | Taco_87049 | I | [
"sort_books",
"parse_input",
"format_output",
"library_sort"
] | 4 | [
[
"library_sort",
"format_output"
],
[
"library_sort",
"parse_input"
],
[
"library_sort",
"sort_books"
]
] | 3 | [
"parse_input",
"format_output"
] | false | [] | false | pytest | true | [] | true | 0ec7b5fb1084e90b18b87817672bd6f1061c703c | 8c9f8eb3ca9ef4b615e83d606cf5b1b001e07d78 | |||
v1.0 | instruct | Taco | Taco_87084_I | A software company is developing an advanced file management system. One of the features they want to implement involves organizing files based on their extensions. Each file in their system is represented by a string in the format "filename.extension". The system needs to categorize the files and output the number of ... | def count_file_extensions(file_list):
"""
Count the number of files for each extension (case-insensitive).
Args:
file_list (list of str): List of filenames with extensions.
Returns:
dict: Dictionary with extensions as keys and their counts as values.
"""
extension_count = {}
for fi... | def test_count_file_extensions():
file_list = [
"report.docx",
"data.csv",
"SCRIPT.JS",
"image.PNG",
"photo.jpg"
]
assert count_file_extensions(file_list) == {
"docx": 1,
"csv": 1,
"js": 1,
"png": 1,
"jpg": 1
}
file_lis... | [
{
"docstring": "Count the number of files for each extension (case-insensitive).\n\nArgs:\nfile_list (list of str): List of filenames with extensions.\n\nReturns:\ndict: Dictionary with extensions as keys and their counts as values.",
"function_declaration": "def count_file_extensions(file_list):",
"fun... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def categorize_files_by_extension(n, files):\n \"\"\"\n Categorize files by their extensions and count the number of files\n for each extension in a case-... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087084",
"row_id": 87084,
"seed_ids": "[14406]"
} | 0.66323 | Taco_87084 | I | [
"count_file_extensions",
"organize_files_by_extension"
] | 2 | [
[
"organize_files_by_extension",
"count_file_extensions"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 0630fc2c5d2871740ea80c2581e792c3c746f9c5 | ac2043a674a88a05319b8ff819144ed6eca53030 | |||
v1.0 | instruct | Taco | Taco_87100_I | Write a function to identify whether a number is a "self-dividing number." A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.
Input: A lower and upper integer bound (inclusive)
Output: A lis... | def is_self_dividing(num):
"""
Check if a number is self-dividing.
:param num: int - input number to be checked
:return: bool - True if the number is self-dividing, False otherwise
"""
original_num = num
while num > 0:
digit = num % 10
# If the digit is 0 or the digit do... | from solution import is_self_dividing, self_dividing_numbers
def test_is_self_dividing():
assert is_self_dividing(128) == True
assert is_self_dividing(12) == True
assert is_self_dividing(102) == False
assert is_self_dividing(101) == False
assert is_self_dividing(1) == True
def test_self_dividing_n... | [
{
"docstring": "Check if a number is self-dividing.\n\n:param num: int - input number to be checked\n:return: bool - True if the number is self-dividing, False otherwise",
"function_declaration": "def is_self_dividing(num):",
"function_name": "is_self_dividing",
"parameter_list": "(num)"
},
{
... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_self_dividing(number):\n \"\"\"\n Check if a number is a self-dividing number.\n \"\"\"\n original = number\n while number > 0:\n digi... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00087100",
"row_id": 87100,
"seed_ids": "[16968]"
} | 0.616643 | Taco_87100 | I | [
"is_self_dividing",
"self_dividing_numbers"
] | 2 | [
[
"self_dividing_numbers",
"is_self_dividing"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8553ad6be2061fa28a8142f43b02e2402b6d5644 | d94eed58fbc855e9b499417a273a76454dde9d0c | |||
v1.0 | instruct | Taco | Taco_87106_I | Zara loves solving coding problems and puzzles. She has come across an interesting problem related to prime numbers and string permutations. Can you help Zara solve it?
- The problem states that for a given string $S$, she needs to determine if it is possible to rearrange the characters of $S$ to form a prime number.... | from itertools import permutations
def is_prime(num):
if num <= 1:
return False
if num == 2:
return True
if num % 2 == 0:
return False
for i in range(3, int(num**0.5) + 1, 2):
if num % i == 0:
return False
return True
def can_form_prime(S):
for perm ... | import pytest
from solution import is_prime, can_form_prime, process_test_cases
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(29) == True
assert is_prime(0) == False
assert is_prime(1) == False
def test_can_form_prime():
... | [
{
"docstring": null,
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": null,
"function_declaration": "def can_form_prime(S):",
"function_name": "can_form_prime",
"parameter_list": "(S)"
},
{
"docstring":... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import itertools\n\ndef is_prime(n):\n \"\"\" Check if a number is prime. \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087106",
"row_id": 87106,
"seed_ids": "[13285]"
} | 0.595966 | Taco_87106 | I | [
"is_prime",
"can_form_prime",
"process_test_cases"
] | 3 | [
[
"can_form_prime",
"is_prime"
],
[
"process_test_cases",
"can_form_prime"
]
] | 2 | [
"process_test_cases"
] | false | [] | false | pytest | true | [] | true | 607e91e3a26881d2bad2e2382d17bfde12344253 | 8999342b92c10df58a2fa72a924bb37bf076bce3 | |||
v1.0 | instruct | Taco | Taco_87166_I | Marcela is interested in counting the number of palindromic substrings within a given string. A palindromic string is a string that reads the same forwards and backwards. She defines a substring to be a contiguous sequence of characters within a string. For example, in the string "racecar", "racecar", "aceca", "cec", a... | def count_palindromic_substrings(s):
"""
Counts and returns the number of palindromic substrings in a given string.
"""
n = len(s)
count = 0
for i in range(n):
# Count odd length palindromes with center at i
count += count_palindromes_around_center(s, i, i)
# Count even l... | from solution import count_palindromic_substrings
def test_single_character():
assert count_palindromic_substrings("a") == 1
assert count_palindromic_substrings("z") == 1
def test_two_characters():
assert count_palindromic_substrings("aa") == 3
assert count_palindromic_substrings("ab") == 2
def test_... | [
{
"docstring": "Counts and returns the number of palindromic substrings in a given string.",
"function_declaration": "def count_palindromic_substrings(s):",
"function_name": "count_palindromic_substrings",
"parameter_list": "(s)"
},
{
"docstring": "Expand around center to count palindromes."... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_palindromic_substrings(s):\n \"\"\"\n Counts and returns the number of palindromic substrings in a given string.\n \"\"\"\n n = len(s)\n c... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00087166",
"row_id": 87166,
"seed_ids": "[139]"
} | 0.780711 | Taco_87166 | I | [
"count_palindromic_substrings",
"count_palindromes_around_center"
] | 2 | [
[
"count_palindromic_substrings",
"count_palindromes_around_center"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2c3a958fdffb5a8b5f4f39adbdcfae539081e48e | dd67c94cf808d39d19f9426098dd98fc852f69a8 | |||
v1.0 | instruct | Taco | Taco_87208_I | ## Problem Statement
You are given an integer array `arr` of length `N` and an integer `K`. Your task is to determine if it is possible to split the array `arr` into exactly `K` contiguous non-empty subarrays such that the sum of elements in each subarray is a power of two. If it is possible, return "YES", otherwise r... | def is_power_of_two(n):
"""
Helper function to check if a given number n is a power of two.
"""
return (n & (n - 1)) == 0 and n != 0
def split_array_into_power_of_two_sums(N, K, arr):
"""
Determines if it is possible to split the array 'arr' of length 'N' into exactly 'K' contiguous
non-em... | from solution import split_array_into_power_of_two_sums
def test_example1():
N, K = 5, 3
arr = [1, 2, 4, 8, 16]
assert split_array_into_power_of_two_sums(N, K, arr) == "NO"
def test_example2():
N, K = 6, 2
arr = [3, 1, 2, 2, 5, 8]
assert split_array_into_power_of_two_sums(N, K, arr) == "NO"
d... | [
{
"docstring": "Helper function to check if a given number n is a power of two.",
"function_declaration": "def is_power_of_two(n):",
"function_name": "is_power_of_two",
"parameter_list": "(n)"
},
{
"docstring": "Determines if it is possible to split the array 'arr' of length 'N' into exactly... | [
0,
0,
0,
1,
0
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_power_of_two(n):\n \"\"\"\n Check if a number is a power of two.\n \"\"\"\n return n > 0 and (n & (n - 1)) == 0\n\ndef can_split_into_k_subarray... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00087208",
"row_id": 87208,
"seed_ids": "[24879]"
} | 0.691409 | Taco_87208 | I | [
"is_power_of_two",
"split_array_into_power_of_two_sums"
] | 2 | [
[
"split_array_into_power_of_two_sums",
"is_power_of_two"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2f3e1ce2246c3a7edc2b690020e0487cf9604c95 | 7791c93e287f4c84c4d10dd18e28de57d1df4138 | |||
v1.0 | instruct | Taco | Taco_87222_I | ------Read problems statements in Hindi,
Mandarin chinese
, Russian and Vietnamese as well. ------
A binary tree is a tree data structure in which each node has at most two children, referred to as the left child and the right child. You are given a binary tree with $N$ nodes. Each node is numbered from $1$ to $N$ an... | from collections import defaultdict
class TreeNode:
def __init__(self, value):
self.value = value
self.children = []
self.min_value = value
self.max_value = value
def build_tree(N, values, edges):
tree = [TreeNode(values[i]) for i in range(N)]
for u, v in edges:
tre... | from solution import process_test_cases
def test_example_case():
T = 1
test_cases = [
(5, [1, 3, 7, 4, 6], [(1, 2), (1, 3), (3, 4), (3, 5)])
]
expected = [
[6, 0, 3, 0, 0]
]
assert process_test_cases(T, test_cases) == expected
def test_single_node():
T = 1
test_cases = ... | [] | [
0,
0,
0,
0,
0,
1,
0,
0,
1,
1
] | 3 | hard | 0.3 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_subtree_extremes(values, edges):\n from collections import defaultdict, deque\n import sys\n \n # Build the tree\n tree = defaultdict(list)... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00087222",
"row_id": 87222,
"seed_ids": "[2897]"
} | 0.710862 | Taco_87222 | I | [
"build_tree",
"dfs",
"solve",
"process_test_cases"
] | 4 | [
[
"process_test_cases",
"solve"
],
[
"solve",
"build_tree"
],
[
"solve",
"dfs"
]
] | 3 | [
"process_test_cases"
] | false | [
"TreeNode"
] | true | pytest | true | [] | true | a8f4d49e719271a8a707bb84ad491b69d37e1eb0 | 4ea31a5956377c82f2abb77d5b78b8d1ddeb055a | |||
v1.0 | instruct | Taco | Taco_87246_I | Peter is preparing for a hiking trip in the land of Graphonia, which is a country represented by an undirected graph with `n` nodes and `m` edges. Each node in Graphonia is identified by an integer from 1 to n. Peter wants to discover all the important nodes in Graphonia. An important node is defined as a node that, if... | from collections import defaultdict
def find_important_nodes(n, m, edges):
def dfs(v, parent):
nonlocal time
visited[v] = True
discovery[v] = low[v] = time
time += 1
children = 0
for to in graph[v]:
if to == parent:
continue
i... | def test_important_nodes():
assert important_nodes(7, 6, [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7)]) == [2, 3, 4, 5, 6]
assert important_nodes(2, 1, [(1, 2)]) == [-1]
assert important_nodes(4, 4, [(1, 2), (2, 3), (3, 4), (4, 1)]) == [-1]
assert important_nodes(5, 4, [(1, 2), (2, 3), (3, 4), (4, 5)... | [
{
"docstring": null,
"function_declaration": "def find_important_nodes(n, m, edges):",
"function_name": "find_important_nodes",
"parameter_list": "(n, m, edges)"
},
{
"docstring": null,
"function_declaration": "def important_nodes(n, m, edges):",
"function_name": "important_nodes",
... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_important_nodes(n, m, edges):\n from collections import defaultdict, deque\n \n def build_graph():\n for u, v in edges:\n graph... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087246",
"row_id": 87246,
"seed_ids": "[13841]"
} | 0.643046 | Taco_87246 | I | [
"find_important_nodes",
"important_nodes"
] | 2 | [
[
"important_nodes",
"find_important_nodes"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 406a24bade04d44ea7e4f2bbc0f3d5e9c64fc9c5 | 29c8556abb64c5b24f7a4670edea7cd5e39fb78d | |||
v1.0 | instruct | Taco | Taco_87274_I | Create a program that reads an integer n (1 <= n <= 100) representing the number of elements in a list, followed by n integers (each between -1000 and 1000). The program should output the sum of all prime numbers in the list. If there are no prime numbers, the program should output 0.
Input
The input consists of mult... | def is_prime(num):
"""
Determines if a number is prime.
"""
if num <= 1:
return False
for i in range(2, int(num ** 0.5) + 1):
if num % i == 0:
return False
return True
def sum_of_primes(n, elements):
"""
Returns the sum of prime numbers in a list of n element... | from solution import is_prime, sum_of_primes, process_input
def test_is_prime():
# Test prime numbers
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(5) == True
assert is_prime(13) == True
# Test non-prime numbers
assert is_prime(1) == False
assert is_prime(4) == F... | [
{
"docstring": "Determines if a number is prime.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Returns the sum of prime numbers in a list of n elements.",
"function_declaration": "def sum_of_primes(n, elements):"... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(num):\n \"\"\"\n Determines if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) + 1... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00087274",
"row_id": 87274,
"seed_ids": "[13003]"
} | 0.617006 | Taco_87274 | I | [
"is_prime",
"sum_of_primes",
"process_input"
] | 3 | [
[
"process_input",
"sum_of_primes"
],
[
"sum_of_primes",
"is_prime"
]
] | 2 | [
"process_input"
] | false | [] | false | pytest | true | [] | true | cebbd743a1f246688f28c0acf632faf3495b89ba | 0164a60387786532c283e6e9e549100d12e34fcd |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.