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_13006_I
Вам дана строка, состоящая из строчных букв латинского алфавита. Необходимо разбить эту строку на минимальное количество подстрок, которые будут палиндромами. Палиндром — это строка, которая читается одинаково слева направо и справа налево. Например, строка "racecar" является палиндромом, а строка "hello" — нет. На...
def is_palindrome(s): return s == s[::-1] def min_palindrome_partition(s): n = len(s) dp = [[0 for _ in range(n)] for _ in range(n)] cut = [0 for _ in range(n)] for i in range(n): min_cut = i for j in range(i + 1): if s[j:i + 1] == s[j:i + 1][::-1]: min_...
from solution import min_palindrome_partition, generate_partitions def test_min_palindrome_partition(): assert min_palindrome_partition("aab") == 2 assert min_palindrome_partition("racecarannakayak") == 3 assert min_palindrome_partition("banana") == 2 assert min_palindrome_partition("aba") == 1 ass...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def min_palindrome_partition(s):", "function_name": "min_palindrome_partition", "parameter_list": "(s)"...
[ 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 min_palindrome_partitions(s):\n \"\"\"\n Returns the minimum number of palindromic substrings the string s can be split into and one of the possible spli...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00013006", "row_id": 13006, "seed_ids": "[24157]" }
0.271724
Taco_13006
I
[ "is_palindrome", "min_palindrome_partition", "generate_partitions" ]
3
[ [ "generate_partitions", "is_palindrome" ], [ "generate_partitions", "min_palindrome_partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
63eb9ebd61a384c1424045fa8d6ca6099dc4304f
da02cc45704b5580f58e066eee7c140f2e43b254
v1.0
instruct
Taco
Taco_13039_I
A sports competition recorded the times taken by participants to complete a 100-meter race. Create a program that processes this time data, categorizes it into performance ranges, and outputs a histogram. The performance ranges are divided in 5-second increments, and each range is represented by the number of participa...
def histogram(times): """ Generate a histogram of the times based on predefined ranges """ # Define ranges ranges = [ (10, 15), (15, 20), (20, 25), (25, 30), (30, 35), (35, 40), (40, 45), (45, 50) ] # Initialize histogram d...
from solution import formatted_histogram def test_histogram_basic(): input_str = "8\n12.5\n17.8\n22.4\n18.9\n29.0\n32.1\n45.5\n41.3" expected_output = "10-14:-\n15-19:--\n20-24:-\n25-29:-\n30-34:-\n35-39:\n40-44:-\n45-49:-" assert formatted_histogram(input_str) == expected_output def test_histogram_edge_t...
[ { "docstring": "Generate a histogram of the times based on predefined ranges", "function_declaration": "def histogram(times):", "function_name": "histogram", "parameter_list": "(times)" }, { "docstring": "Read and parse the input string into a list of times", "function_declaration": "def...
[ 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 generate_histogram(n, times):\n ranges = [\"10-14:\", \"15-19:\", \"20-24:\", \"25-29:\", \"30-34:\", \"35-39:\", \"40-44:\", \"45-49:\"]\n counts = [0] ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013039", "row_id": 13039, "seed_ids": "[9394]" }
0.599951
Taco_13039
I
[ "histogram", "read_input", "formatted_histogram" ]
3
[ [ "formatted_histogram", "histogram" ], [ "formatted_histogram", "read_input" ] ]
2
[ "read_input" ]
false
[]
false
pytest
true
[]
true
f7cf7095ae4fdc74c65d85f58b445e88d32a4a1d
2d0c4f44fa0ed4c908a3ebc2dfccd448cedbcc1b
v1.0
instruct
Taco
Taco_13068_I
Palindrome Index Given a string of lowercase letters, determine the index of a character that can be removed to make the string a palindrome. If the string is already a palindrome, return `-1`. If there is more than one valid answer, return the smallest index. Function Description Complete the `palindromeIndex` func...
def is_palindrome(s): return s == s[::-1] def palindromeIndex(s): if is_palindrome(s): return -1 start, end = 0, len(s) - 1 while start < end: if s[start] != s[end]: if is_palindrome(s[start+1:end+1]): return start elif is_palindrome(s[start:end...
from solution import palindromeIndex def test_palindrome_index(): assert palindromeIndex("aaab") == 3 assert palindromeIndex("baa") == 0 assert palindromeIndex("aaa") == -1 assert palindromeIndex("abca") == 1 assert palindromeIndex("racecarx") == 7 assert palindromeIndex("xyzyx") == -1 asse...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def palindromeIndex(s):", "function_name": "palindromeIndex", "parameter_list": "(s)" } ]
[ 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 palindromeIndex(s):\n \"\"\"\n Determine the index of a character that can be removed to make the string a palindrome.\n If the string is already a pa...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013068", "row_id": 13068, "seed_ids": "[11432]" }
0.758374
Taco_13068
I
[ "is_palindrome", "palindromeIndex" ]
2
[ [ "palindromeIndex", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f7172f10d87c1221ec09c0dbbb88e72431e110f8
65fb315e5dd8d473b8263e5f1c579e24dcacfff1
v1.0
instruct
Taco
Taco_13106_I
In an ancient kingdom, the citizens communicate using a special numerical code. This code consists of sequences of digits from 0 to 9. However, not all sequences are valid; a valid sequence follows these specific rules: - The sequence must start with a non-zero digit. - The length of the sequence must be a prime number...
def is_prime(n): """ Helper function to check if a number is prime """ 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 r...
from solution import is_valid_sequence def test_valid_sequence(): assert is_valid_sequence("239") == "VALID" assert is_valid_sequence("1234567") == "VALID" def test_starts_with_zero(): assert is_valid_sequence("012345") == "INVALID" def test_non_prime_length(): assert is_valid_sequence("1234") == "IN...
[ { "docstring": "Helper function to check if a number is prime ", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Checks if the sequence adheres to the kingdom's rules:\n- Must start with a non-zero digit.\n- Length must be a...
[ 0, 0, 0, 0, 0, 0, 1, 0, 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(n):\n \"\"\"\n Determines if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00013106", "row_id": 13106, "seed_ids": "[7288]" }
0.697355
Taco_13106
I
[ "is_prime", "is_valid_sequence" ]
2
[ [ "is_valid_sequence", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
80a4ceefb0ae300e8e868783e708bae21edbc8bc
26055e885a506d093c8f9bc0fb5de41cf5ddd096
v1.0
instruct
Taco
Taco_13225_I
You are given an array of $n$ integers and an integer $k$. Determine if there exist two distinct elements in the array whose difference is exactly $k$. -----Input----- The first line contains two integers $n$ ($2 \leq n \leq 10^5$) and $k$ ($0 \leq k \leq 10^9$). The second line contains $n$ integers $a_1, a_2, \ldo...
def has_pair_with_difference(arr, k): """ Determines if there exist two distinct elements in the array whose difference is exactly k. """ elements = set() for num in arr: if (num + k) in elements or (num - k) in elements: return "YES" elements.add(num) return "NO" # ...
from solution import check_pair_with_difference def test_example_case_1(): assert check_pair_with_difference(5, 4, [1, 5, 9, 13, 17]) == "YES" def test_example_case_2(): assert check_pair_with_difference(4, 100, [1, 2, 3, 4]) == "NO" def test_no_difference_k(): assert check_pair_with_difference(3, 0, [1,...
[ { "docstring": "Determines if there exist two distinct elements in the array whose difference is exactly k.", "function_declaration": "def has_pair_with_difference(arr, k):", "function_name": "has_pair_with_difference", "parameter_list": "(arr, k)" }, { "docstring": null, "function_decla...
[ 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 has_pairs_with_difference_k(arr, k):\n \"\"\"\n Determines if there exist two distinct elements in the array whose difference is exactly k.\n \n Pa...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013225", "row_id": 13225, "seed_ids": "[25233]" }
0.740156
Taco_13225
I
[ "has_pair_with_difference", "check_pair_with_difference" ]
2
[ [ "check_pair_with_difference", "has_pair_with_difference" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7961afdef1007d30beafb0e8af182587d32530c0
54c78b79470307b5d9d559bc07dcb0e1383a3885
v1.0
instruct
Taco
Taco_13235_I
You are given an undirected connected graph with N nodes and M edges. Each edge has an integer weight. You are asked to perform Q queries on this graph. Each query contains two nodes u and v, and you are required to find the weight of the minimum weight edge in the unique path between u and v. ### Constraints - 2 ≤ N ...
def dfs(graph, node, parent, depth, parent_edge_weight, depth_list, parent_list, min_edge_weight_list): depth_list[node] = depth parent_list[node] = parent min_edge_weight_list[node] = parent_edge_weight for neighbor, weight in graph[node]: if neighbor != parent: dfs(graph, neighbor...
def test_solution_sample_input(): N = 5 M = 4 edges = [(1, 2, 3), (2, 3, 7), (3, 4, 2), (4, 5, 5)] Q = 3 queries = [(1, 3), (2, 4), (1, 5)] expected_output = [3, 2, 2] assert solution(N, M, edges, Q, queries) == expected_output def test_solution_small_input(): N = 3 M = 2 ...
[ { "docstring": null, "function_declaration": "def dfs(graph, node, parent, depth, parent_edge_weight, depth_list, parent_list, min_edge_weight_list):", "function_name": "dfs", "parameter_list": "(graph, node, parent, depth, parent_edge_weight, depth_list, parent_list, min_edge_weight_list)" }, {...
[ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\nimport sys\ninput = sys.stdin.read\n\ndef preprocess_tree(N, edges):\n adj = defaultdict(list)\n for u, v, w in e...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00013235", "row_id": 13235, "seed_ids": "[16416]" }
0.826109
Taco_13235
I
[ "dfs", "lca_preprocess", "find_lca", "solution" ]
4
[ [ "lca_preprocess", "dfs" ], [ "solution", "find_lca" ], [ "solution", "lca_preprocess" ] ]
3
[]
false
[]
false
pytest
false
[]
true
e133b178b25c1f85195915e919080593e715c032
5a2e1155cb70711ba4fae75593b9a34b50ed0c39
v1.0
instruct
Taco
Taco_13332_I
Alice owns a large rectangular field where she plants crops in distinct rectangular plots. Each plot is defined by four integers (x1, y1, x2, y2) where (x1, y1) is the coordinate of the top-left corner of the plot, and (x2, y2) is the coordinate of the bottom-right corner of the plot. To make the field more manageable,...
def area(plot): """ Calculate the area of a rectangular plot defined by top-left and bottom-right corners. """ x1, y1, x2, y2 = plot return (x2 - x1) * (y2 - y1) def overlaps(plot1, plot2): """ Check if two plots overlap. """ x1, y1, x2, y2 = plot1 x3, y3, x4, y4 = plot2 ...
from solution import max_non_overlapping_plot_area def test_single_plot(): plots = [(1, 1, 4, 4)] assert max_non_overlapping_plot_area(plots) == 9 def test_no_overlap(): plots = [(1, 1, 4, 4), (5, 5, 7, 7)] assert max_non_overlapping_plot_area(plots) == 9 def test_overlap(): plots = [(1, 1, 4, 4)...
[ { "docstring": "Calculate the area of a rectangular plot defined by top-left \nand bottom-right corners.", "function_declaration": "def area(plot):", "function_name": "area", "parameter_list": "(plot)" }, { "docstring": "Check if two plots overlap.", "function_declaration": "def overlaps...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List, Tuple\n\ndef max_non_overlapping_plot_area(plots: List[Tuple[int, int, int, int]]) -> int:\n def is_overlapping(plot1, plot2):\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00013332", "row_id": 13332, "seed_ids": "[1445]" }
0.602767
Taco_13332
I
[ "area", "overlaps", "max_non_overlapping_plot_area" ]
3
[ [ "max_non_overlapping_plot_area", "area" ], [ "max_non_overlapping_plot_area", "overlaps" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5f287aaea7dd5a3f037f9a3798b28312ef4c1565
556f287d50906369b6435b4dc738a9175697837b
v1.0
instruct
Taco
Taco_13336_I
-----Input----- The first line of input consists of two integers $N$ and $M$, where $1 \le N \le 10000$ is the number of cities, and $0 \le M \le 100000$ is the number of roads. The next $M$ lines each contain two distinct integers $x$ and $y$ which represent a direct road between city $x$ and city $y$. Following thi...
from collections import defaultdict, deque def find_connected_components(n, edges): # Initialize graph graph = defaultdict(list) for x, y in edges: graph[x].append(y) graph[y].append(x) # To keep track of visited cities visited = [False] * (n + 1) components = [-1] * (n + 1...
from solution import solve def test_example_case(): n = 5 m = 4 edges = [(0, 1), (1, 2), (3, 4), (0, 4)] queries = [(0, 2), (1, 3), (2, 4)] assert solve(n, m, edges, queries) == ["yes", "yes", "yes"] def test_two_disconnected_components(): n = 6 m = 4 edges = [(0, 1), (1, 2), (3, 4), (...
[ { "docstring": null, "function_declaration": "def find_connected_components(n, edges):", "function_name": "find_connected_components", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def solve(n, m, edges, queries):", "function_name": "solve", "par...
[ 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_parent(parent, i):\n if parent[i] == i:\n return i\n else:\n return find_parent(parent, parent[i])\n\ndef union(parent, rank, x, y):\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013336", "row_id": 13336, "seed_ids": "[22559]" }
0.7892
Taco_13336
I
[ "find_connected_components", "solve" ]
2
[ [ "solve", "find_connected_components" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8ec7d7c14e423969ffcb82a4bd35b348884dae6e
282afdcccd35dc51c56baab48ec8899a5add1da4
v1.0
instruct
Taco
Taco_13374_I
You are responsible for distributing supplies to various locations for a logistics company. Each supply unit has a certain weight and value, and your task is to maximize the value of supplies delivered within a given weight limit. You need to solve this problem by writing a program based on the 0/1 knapsack problem. Y...
def knapsack(n, W, items): # Initialize a matrix to keep track of maximum value at each weight limit dp = [[0] * (W + 1) for _ in range(n + 1)] # Fill the dp array for i in range(1, n + 1): wi, vi = items[i - 1] for w in range(W + 1): if wi > w: dp[i][w] ...
from solution import transport_supplies def test_single_dataset(): data = "4 5\n2 3\n1 2\n3 4\n2 2\n0 0" expected = [7] assert transport_supplies(data) == expected def test_multiple_datasets(): data = "4 5\n2 3\n1 2\n3 4\n2 2\n3 8\n3 8\n5 2\n7 10\n1 100\n100 1000\n0 0" expected = [7, 10, 1000] ...
[ { "docstring": null, "function_declaration": "def knapsack(n, W, items):", "function_name": "knapsack", "parameter_list": "(n, W, items)" }, { "docstring": null, "function_declaration": "def parse_input(data):", "function_name": "parse_input", "parameter_list": "(data)" }, { ...
[ 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 knapsack(n, W, items):\n dp = [0] * (W + 1)\n \n for i in range(n):\n weight, value = items[i]\n for w in range(W, weight - 1, -1):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013374", "row_id": 13374, "seed_ids": "[12032]" }
0.681164
Taco_13374
I
[ "knapsack", "parse_input", "transport_supplies" ]
3
[ [ "transport_supplies", "knapsack" ], [ "transport_supplies", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
737b64661fe89011dd95f11824ee92a3baa09445
309e33b05443665d39f47576b8742944e0d797b0
v1.0
instruct
Taco
Taco_13414_I
Given a list of integers, write a function that returns a list of booleans indicating whether each integer in the list is a prime number or not. Function Signature: ```python def check_prime_numbers(nums: List[int]) -> List[bool]: ``` **Input:** - List of integers, `nums`, with length `n` (1 ≤ n ≤ 10^5). **Output:*...
from typing import List import math def is_prime(n: int) -> bool: """ Helper function to check if a number is a prime number. """ 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 == ...
from solution import check_prime_numbers def test_check_prime_numbers_all_primes(): assert check_prime_numbers([2, 3, 5, 7, 11, 13]) == [True, True, True, True, True, True] def test_check_prime_numbers_with_non_primes(): assert check_prime_numbers([1, 2, 3, 4, 5, 15, 18, 19]) == [False, True, True, False, Tru...
[ { "docstring": "Helper function to check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of booleans indicating whether each integer in the input list `nums` is a prime number....
[ 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 typing import List\n\ndef is_prime(n: int) -> bool:\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013414", "row_id": 13414, "seed_ids": "[14033]" }
0.815179
Taco_13414
I
[ "is_prime", "check_prime_numbers" ]
2
[ [ "check_prime_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
40586dbfe0358b17f84042880ef13a9ac1e3140d
84e2f2da371a26c48e92dea4dca9b7a5c86c6ac5
v1.0
instruct
Taco
Taco_13415_I
In a land far away, there exists a peculiar set of numbers called "Magical Numbers." A number is said to be magical if the sum of its digits is divisible by a given integer `d`. Given a range of integers from `l` to `r` (inclusive), find the count of magical numbers within that range. If there are none, return `-1`. ...
def digit_sum(n): """ Returns the sum of the digits of a number n. """ return sum(int(digit) for digit in str(n)) def count_magical_numbers(l, r, d): """ Returns the count of magical numbers in the range [l, r] where the sum of its digits is divisible by d. If there are no magical numb...
from solution import digit_sum, count_magical_numbers, process_test_cases def test_digit_sum(): assert digit_sum(123) == 6 assert digit_sum(49) == 13 assert digit_sum(0) == 0 assert digit_sum(999) == 27 def test_count_magical_numbers(): assert count_magical_numbers(1, 10, 3) == 3 assert count_...
[ { "docstring": "Returns the sum of the digits of a number n.", "function_declaration": "def digit_sum(n):", "function_name": "digit_sum", "parameter_list": "(n)" }, { "docstring": "Returns the count of magical numbers in the range [l, r] where \nthe sum of its digits is divisible by d.\nIf t...
[ 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 sum_of_digits(n):\n \"\"\"\n Returns the sum of the digits of a number n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef count_magica...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013415", "row_id": 13415, "seed_ids": "[5692]" }
0.638721
Taco_13415
I
[ "digit_sum", "count_magical_numbers", "process_test_cases", "main" ]
4
[ [ "count_magical_numbers", "digit_sum" ], [ "process_test_cases", "count_magical_numbers" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
39c426ffe62717951039805cea15a70cdaae70eb
2989cdc00bc8e45665ae454f83f2845f179e8874
v1.0
instruct
Taco
Taco_13434_I
# Task Given an **_integer_ n** , *Find the smallest integer m* , Such That , # Conditions : * **_m_** is *greater than or equal to n* . * **_m_** is a **_palindrome_** . ___ # Notes * The **_parameter (n)_** passed to the function is a *positive integer* . ___ # Input >> Output Examples ``` smallestPalindrome...
def is_palindrome(number): """ Checks if the given number is a palindrome. """ return str(number) == str(number)[::-1] def smallest_palindrome(n): """ Finds the smallest palindrome number which is greater than or equal to n. """ while not is_palindrome(n): n += 1 return n
from solution import smallest_palindrome def test_smallest_palindrome(): assert smallest_palindrome(120) == 121 assert smallest_palindrome(321) == 323 assert smallest_palindrome(99) == 99 assert smallest_palindrome(12321) == 12321 assert smallest_palindrome(123) == 131 assert smallest_palindrom...
[ { "docstring": "Checks if the given number is a palindrome.", "function_declaration": "def is_palindrome(number):", "function_name": "is_palindrome", "parameter_list": "(number)" }, { "docstring": "Finds the smallest palindrome number which is greater than or equal to n.", "function_decl...
[ 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 smallest_palindrome(n):\n \"\"\"\n Returns the smallest palindrome number that is greater than or equal to n.\n \"\"\"\n def is_palindrome(x):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013434", "row_id": 13434, "seed_ids": "[1167]" }
0.78459
Taco_13434
I
[ "is_palindrome", "smallest_palindrome" ]
2
[ [ "smallest_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6f1eac2c0ea6d59582ddce9299af4b0bafde2031
5b70b7822780323d6715795112227595b6c6584a
v1.0
instruct
Taco
Taco_13441_I
There is a land with n villages connected by m bidirectional roads. Each road has a certain length. The villagers want to construct a new type of transportation system, wherein each village can reach every other village directly or indirectly (i.e., through a series of roads), but they want to minimize the cost of cons...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) 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_...
def test_minimum_road_network(): assert minimum_road_network(4, 5, [(1, 2, 3), (2, 3, 1), (3, 4, 2), (4, 1, 4), (1, 3, 5)]) == 6 assert minimum_road_network(3, 3, [(1, 2, 1), (2, 3, 2), (3, 1, 4)]) == 3 assert minimum_road_network(3, 1, [(1, 2, 1)]) == "Impossible" assert minimum_road_network(2, 1, [(1,...
[ { "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 ]
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.pare...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013441", "row_id": 13441, "seed_ids": "[12433]" }
0.721424
Taco_13441
I
[ "find", "union", "kruskal", "minimum_road_network" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_road_network", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
4fac2ce36f061c3c94bce86855d8ddc7f979d249
ffdb35ff3a0ee595a727f1c3bcecaf57d79a7c83
v1.0
instruct
Taco
Taco_13457_I
Alice is working with binary trees. She needs to determine the maximum depth (or height) of a binary tree, defined as the number of nodes along the longest path from the root node down to the farthest leaf node. Given a binary tree, your task is to calculate its maximum depth. ------ Input Format ------ - The first l...
class Node: def __init__(self): self.left = None self.right = None def create_tree_tree_structure(n, children): nodes = [None] + [Node() for _ in range(n)] for i in range(1, n + 1): left, right = children[i - 1] if left != -1: nodes[i].left = nodes[left] ...
def test_sample_input_1(): input_str = "5\n2 3\n-1 -1\n-1 4\n-1 -1\n-1 -1" assert parse_input_and_find_max_depth(input_str) == 3 def test_single_node(): input_str = "1\n-1 -1" assert parse_input_and_find_max_depth(input_str) == 1 def test_linear_tree(): input_str = "3\n2 -1\n3 -1\n-1 -1" asser...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self):\n self.left = None\n self.right = None\n\ndef build_tree(nodes_info):\n n = len(nodes_info)\n if n == ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013457", "row_id": 13457, "seed_ids": "[1838]" }
0.58261
Taco_13457
I
[ "create_tree_tree_structure", "max_depth", "binary_tree_max_depth", "parse_input_and_find_max_depth" ]
4
[ [ "binary_tree_max_depth", "create_tree_tree_structure" ], [ "binary_tree_max_depth", "max_depth" ], [ "parse_input_and_find_max_depth", "binary_tree_max_depth" ] ]
3
[ "parse_input_and_find_max_depth" ]
false
[ "Node" ]
true
pytest
false
[]
true
1193c9a0a42fef390e2898af7a6286108490f05e
5ca2245f9fadd9c20cf96df0d04dbf4009f17f82
v1.0
instruct
Taco
Taco_13523_I
In the technologically advanced city of Algoburg, there is a unique system of underground tunnels connecting the city's neighborhoods. The city comprises N neighborhoods connected by M bidirectional tunnels. Unfortunately, the tunnels require maintenance. Due to budget constraints, the city council wants to repair onl...
MOD = 1000000007 def find_min_cost(N, M, tunnels, Q, reserved): import heapq parent = list(range(N + 1)) rank = [0] * (N + 1) def find(x): if parent[x] != x: parent[x] = find(parent[x]) # path compression return parent[x] def union(x, y): rootX = find(x) ...
from solution import algoburg_tunnel def test_example_criteria(): N = 4 M = 5 tunnels = [ (1, 2, 4), (2, 3, 5), (3, 4, 6), (1, 4, 7), (2, 4, 3) ] Q = 2 reserved = [2, 3] assert algoburg_tunnel(N, M, tunnels, Q, reserved) == (0, 1) def test_single_tun...
[ { "docstring": null, "function_declaration": "def find_min_cost(N, M, tunnels, Q, reserved):", "function_name": "find_min_cost", "parameter_list": "(N, M, tunnels, Q, reserved)" }, { "docstring": null, "function_declaration": "def algoburg_tunnel(N, M, tunnels, Q, reserved_idxs):", "...
[ 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.143
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_minimum_cost_and_ways(n, m, tunnels, reserved_indices):\n MOD = 1_000_000_007\n\n # Create adjacency list for the graph\n adj_list = [[] for _ in...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00013523", "row_id": 13523, "seed_ids": "[20651]" }
0.650216
Taco_13523
I
[ "find_min_cost", "algoburg_tunnel" ]
2
[ [ "algoburg_tunnel", "find_min_cost" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0d5e215f38f927ba9fe48e29d3e9e7f485c9bc88
d91f85d4082ee3c627ba18650de8400eb02215d0
v1.0
instruct
Taco
Taco_13605_I
After successfully passing the Hunter Exam, Gon wants to continue honing his skills. One challenge that catches his attention is a pattern recognition problem presented by a fellow friend, Killua. Killua presents Gon with a 2D grid of dimensions `n x m` filled with either 'H' (Hunter) or 'T' (Training ground). The goa...
def calculate_max_histogram_area(heights): stack = [] max_area = 0 index = 0 while index < len(heights): if not stack or heights[stack[-1]] <= heights[index]: stack.append(index) index += 1 else: top_of_stack = stack.pop() area = (heights[...
from solution import largest_rectangle_of_H def test_largest_rectangle_of_1(): grid = [ "TTTTT", "THHHH", "THHTT", "THHHH" ] assert largest_rectangle_of_H(grid) == 6 def test_largest_rectangle_of_2(): grid = [ "HHH", "HTH", "HHH" ] assert...
[ { "docstring": null, "function_declaration": "def calculate_max_histogram_area(heights):", "function_name": "calculate_max_histogram_area", "parameter_list": "(heights)" }, { "docstring": null, "function_declaration": "def largest_rectangle_of_H(grid):", "function_name": "largest_rec...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_rectangle_area(grid):\n def max_histogram_area(heights):\n stack = []\n max_area = 0\n index = 0\n \n while index < l...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00013605", "row_id": 13605, "seed_ids": "[19626]" }
0.594596
Taco_13605
I
[ "calculate_max_histogram_area", "largest_rectangle_of_H" ]
2
[ [ "largest_rectangle_of_H", "calculate_max_histogram_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
78e657571aab16551cb4d7bff704552bb67c8075
1076c484479414f3665f1002971a5d9bfea28f62
v1.0
instruct
Taco
Taco_13643_I
Given a string containing only digits, return all possible valid IP addresses that can be formed by inserting dots between the digits. You cannot reorder or remove any digits. Each segment of the IP address must be a valid segment, which means it is an integer between 0 and 255, inclusive, and no segment should contain...
from typing import List def is_valid_segment(segment: str) -> bool: # A valid segment must not start with '0' if it has multiple digits and must be between 0 and 255 return len(segment) == 1 or (segment[0] != '0' and 0 <= int(segment) <= 255) def restore_ip_addresses(s: str) -> List[str]: result = [] ...
from solution import restore_ip_addresses def test_example_1(): s = "25525511135" assert set(restore_ip_addresses(s)) == set(["255.255.11.135", "255.255.111.35"]) def test_example_2(): s = "0000" assert set(restore_ip_addresses(s)) == set(["0.0.0.0"]) def test_example_3(): s = "101023" assert...
[ { "docstring": null, "function_declaration": "def is_valid_segment(segment):", "function_name": "is_valid_segment", "parameter_list": "(segment)" }, { "docstring": null, "function_declaration": "def restore_ip_addresses(s):", "function_name": "restore_ip_addresses", "parameter_li...
[ 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 typing import List\n\ndef is_valid(segment: str) -> bool:\n \"\"\"\n Check if the segment is a valid IP address segment.\n \"\"\"\n if len(segment...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013643", "row_id": 13643, "seed_ids": "[16808]" }
0.614401
Taco_13643
I
[ "is_valid_segment", "restore_ip_addresses" ]
2
[ [ "restore_ip_addresses", "is_valid_segment" ] ]
1
[]
false
[]
false
pytest
true
[]
true
211e2cfe416f9f7aab093b56b2d54ed3f1578eea
2603e014903aca8a7011eea3362a8c307a3bbd02
v1.0
instruct
Taco
Taco_13698_I
-----Input----- The input contains a single integer $n$ ($1 \le n \le 100$). -----Output----- Output the sum of all prime numbers from 1 to $n$ (inclusive). -----Example----- Input 10 Output 17
def is_prime(num): """ Returns True if num is a prime number, otherwise False. """ if num < 2: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def sum_primes_up_to(n): """ Returns the sum of all prime numbers fro...
from solution import sum_primes_up_to def test_sum_primes_up_to_10(): assert sum_primes_up_to(10) == 17 # Primes are 2, 3, 5, 7 def test_sum_primes_up_to_1(): assert sum_primes_up_to(1) == 0 # No prime numbers between 1 to 1 def test_sum_primes_up_to_2(): assert sum_primes_up_to(2) == 2 # Primes are 2...
[ { "docstring": "Returns True if num is a prime number, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers from 1 to n (inclusive).", "function_declaration": "def s...
[ 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 if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n return False\n retu...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013698", "row_id": 13698, "seed_ids": "[14708]" }
0.700994
Taco_13698
I
[ "is_prime", "sum_primes_up_to" ]
2
[ [ "sum_primes_up_to", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
687c7bcf63d2a92627269e5654a51129acca625c
15a8334829aa26a5cca4b070f870e49a08e05702
v1.0
instruct
Taco
Taco_13736_I
Nina is experimenting with arrays in her coding class. She wants her students to learn about finding subsequences that meet certain criteria. She presents them with the following problem: Given an array of positive integers, find the length of the longest increasing subsequence (LIS) such that the sum of the elements ...
from itertools import combinations from math import isqrt 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, isqrt(num) + 1, 2): if num % i == 0: return False return True def longest_incr...
from solution import find_lis_prime_length def test_sample_input_0(): assert find_lis_prime_length(6, [10, 22, 9, 33, 21, 50]) == 2 def test_sample_input_1(): assert find_lis_prime_length(5, [8, 3, 10, 7, 15]) == 2 def test_short_array(): assert find_lis_prime_length(3, [2, 3, 5]) == 2 def test_no_prime...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def longest_increasing_subsequence_with_prime_sum(arr):", "function_name": "longest_increasing_subsequence_with_p...
[ 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": "from math import sqrt\n\ndef is_prime(num):\n if num <= 1:\n return False\n for i in range(2, int(sqrt(num)) + 1):\n if num % i == 0:\n ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00013736", "row_id": 13736, "seed_ids": "[23652]" }
0.756665
Taco_13736
I
[ "is_prime", "longest_increasing_subsequence_with_prime_sum", "find_lis_prime_length" ]
3
[ [ "find_lis_prime_length", "longest_increasing_subsequence_with_prime_sum" ], [ "longest_increasing_subsequence_with_prime_sum", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
560314a61144ae2f02d6a07630531c4eaabbea12
233eb5d0f9ae00074e9cd3a42d233b7c3801fff5
v1.0
instruct
Taco
Taco_13757_I
You are given a binary tree with N nodes labeled from 1 to N. Each node has a value associated with it. Your task is to find the length of the longest path in the tree such that the sum of the values of the nodes on that path is maximized. ------ Input Format ------ - The first line of input contains a single intege...
from collections import defaultdict, deque def longest_max_sum_path(N, node_values, edges): # Build adjacency list adj_list = defaultdict(list) for u, v in edges: adj_list[u].append(v) adj_list[v].append(u) # Helper function for finding longest path using BFS def bfs(start_node...
import pytest from solution import longest_path_in_tree, parse_input, format_output def test_sample_case_1(): input_str = "2\n5\n1 2 3 4 5\n1 2\n1 3\n3 4\n3 5\n3\n5 10 20\n1 2\n1 3" T, test_cases = parse_input(input_str) result = longest_path_in_tree(T, test_cases) assert result == [3, 2] def test_cas...
[ { "docstring": null, "function_declaration": "def longest_max_sum_path(N, node_values, edges):", "function_name": "longest_max_sum_path", "parameter_list": "(N, node_values, edges)" }, { "docstring": null, "function_declaration": "def longest_path_in_tree(T, test_cases):", "function_...
[ 0, 0, 0, 1 ]
1
hard
0.25
{ "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 build_tree(values, edges):\n nodes = [TreeNode(v)...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00013757", "row_id": 13757, "seed_ids": "[20306]" }
0.702019
Taco_13757
I
[ "longest_max_sum_path", "longest_path_in_tree", "parse_input", "format_output" ]
4
[ [ "longest_path_in_tree", "longest_max_sum_path" ] ]
1
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
a9ea1c262fbde5f172937beb834e065ae1db1517
3ad14a95061a89cb72c282402a7f56114bb805d0
v1.0
instruct
Taco
Taco_13766_I
You are given an array $\text{A}$ of size $\text{N}$. You are asked to answer $\text{Q}$ queries. Each query contains two integers $\text{L}$ and $\text{R}$. For each query, you need to find the product of all the prime numbers in the subarray $\text{A}[L...R]$. As the product can be very large, output the result mod...
import math 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 find_prime_product_modulo(L, ...
from solution import find_prime_product_modulo, find_primes_in_array def test_find_prime_product_modulo(): P = 2000003 N = 6 arr = [2, 3, 6, 7, 5, 4] primes_set = find_primes_in_array(arr) queries = [(2, 5), (1, 3), (3, 6)] expected_outputs = [105, 6, 35] for i, (L, R) in enumerate(queries...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def find_prime_product_modulo(L, R, arr, primes_set, P):", "function_name": "find_prime_product_modulo", "paramet...
[ 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_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_2
{ "original_instruction": "", "prompt_id": "00013766", "row_id": 13766, "seed_ids": "[17246]" }
0.655939
Taco_13766
I
[ "is_prime", "find_prime_product_modulo", "find_primes_in_array" ]
3
[ [ "find_primes_in_array", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b26e94a6b02da47afc9167273b5d595445d5392c
56681b8a38511121701f6cb1911e3b763287bf73
v1.0
instruct
Taco
Taco_13824_I
A mythical city is thriving in the middle of a desert, heavily guarded by a circle of magical towers. Each tower has a certain energy level and is placed at specific coordinates on a 2D plane. The city plans to connect these towers with magical beams so that they form a single interconnected structure, minimizing the t...
import math from heapq import heappush, heappop def prim_minimum_spanning_tree(towers): """ Uses Prim's algorithm to find the minimum total energy required to connect all towers. """ n = len(towers) if n == 1: return 0 # Priority queue to select the edge with the minimum weight ...
def test_prim_minimum_spanning_tree(): assert prim_minimum_spanning_tree([(0, 0, 10), (0, 1, 10), (1, 0, 10)]) == 2 assert prim_minimum_spanning_tree([(0, 0, 10), (1, 0, 20), (0, 1, 30), (1, 1, 40)]) == 3 def test_minimum_total_energy(): assert minimum_total_energy(2, [ ...
[ { "docstring": "Uses Prim's algorithm to find the minimum total energy required to connect all towers.", "function_declaration": "def prim_minimum_spanning_tree(towers):", "function_name": "prim_minimum_spanning_tree", "parameter_list": "(towers)" }, { "docstring": null, "function_declar...
[ 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 calculate_distance(x1, y1, x2, y2):\n return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)\n\ndef prim_minimum_spanning_tree(n, towers...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013824", "row_id": 13824, "seed_ids": "[13571]" }
0.655523
Taco_13824
I
[ "prim_minimum_spanning_tree", "minimum_total_energy", "parse_input", "solve" ]
4
[ [ "minimum_total_energy", "prim_minimum_spanning_tree" ], [ "solve", "minimum_total_energy" ], [ "solve", "parse_input" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
a828cafbb7a0f79756d6e25902a9d70ea44fdffb
f4dfc6726f546a54d2399b3bd951bb27665b27a9
v1.0
instruct
Taco
Taco_14029_I
A magical forest is known for its unique plants arranged in a perfect square garden with rows and columns. Each plant in the garden has a unique height. A mythical gardener wants your help to maintain the magic of the forest by ensuring that the heights of the plants follow a particular rule: the height of any plant mu...
def is_magic_garden(n, garden): """ Checks if the given garden adheres to the rule that each plant's height should be less than the plant height directly to its right and directly below. """ # Checking each plant except the last row and last column for i in range(n): for j in range(n): ...
def test_is_magic_garden(): assert is_magic_garden(3, [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == True assert is_magic_garden(3, [[3, 1, 2], [6, 4, 5], [9, 7, 8]]) == False assert is_magic_garden(2, [[1, 2], [3, 4]]) == True def test_min_swaps_to_magic_garden(): assert min_swaps_to_magic_garden(3, [[1, 2, 3]...
[ { "docstring": "Checks if the given garden adheres to the rule that each plant's height \nshould be less than the plant height directly to its right and directly below.", "function_declaration": "def is_magic_garden(n, garden):", "function_name": "is_magic_garden", "parameter_list": "(n, garden)" ...
[ 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_magic_garden(n, garden):\n \"\"\"\n Checks if the given garden adheres to the rule that each plant's height \n should be less than the plant height...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00014029", "row_id": 14029, "seed_ids": "[16807]" }
0.613474
Taco_14029
I
[ "is_magic_garden", "min_swaps_to_magic_garden" ]
2
[ [ "min_swaps_to_magic_garden", "is_magic_garden" ] ]
1
[]
false
[]
false
pytest
false
[]
true
de7d6226584489de53160ec2f9abf5dff2642434
1eb1b3cbbac656c24509427c8245e85abf6f53a2
v1.0
instruct
Taco
Taco_14040_I
**Reversing Nodes in K-Group** Given a linked list, reverse the nodes of the list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. **Constra...
class Node: def __init__(self, val=0, next=None): self.val = val self.next = next def reverseKGroup(head, k): def reverseLinkedList(head, k): new_head, ptr = None, head while k: next_node = ptr.next ptr.next = new_head new_head = ptr ...
def test_reverse_nodes_in_k_group(): assert reverse_nodes_in_k_group(8, 3, [1, 2, 3, 4, 5, 6, 7, 8]) == [3, 2, 1, 6, 5, 4, 7, 8] assert reverse_nodes_in_k_group(5, 2, [1, 2, 3, 4, 5]) == [2, 1, 4, 3, 5] assert reverse_nodes_in_k_group(4, 4, [1, 2, 3, 4]) == [4, 3, 2, 1] assert reverse_nodes_in_k_group(6...
[]
[ 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 ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef reverseKGroup(head, k):\n # Helper function ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014040", "row_id": 14040, "seed_ids": "[5471]" }
0.71362
Taco_14040
I
[ "reverseKGroup", "createLinkedList", "printLinkedList", "reverse_nodes_in_k_group" ]
4
[ [ "reverse_nodes_in_k_group", "createLinkedList" ], [ "reverse_nodes_in_k_group", "printLinkedList" ], [ "reverse_nodes_in_k_group", "reverseKGroup" ] ]
3
[]
false
[ "Node" ]
true
pytest
false
[]
true
ea8d27a94b303d7734a3345a9c97f9c1dae38d9d
3c9dd09f1292076be07810d428204316bfea102b
v1.0
instruct
Taco
Taco_14083_I
You are given a binary matrix of size $n \times m$. Your task is to determine the length of the longest contiguous submatrix (rectangular sub-section) that contains only `1`s. Contiguity means that you need to look for rectangles of 1s that are continuous in the grid. In other words, you need to find the largest subma...
def maximalRectangle(matrix): if not matrix or not matrix[0]: return 0 n = len(matrix) m = len(matrix[0]) height = [0] * (m + 1) max_area = 0 for row in matrix: for i in range(m): if row[i] == 1: height[i] += 1 else: heigh...
from solution import findLargestSubmatrix def test_case_1(): matrix = [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0] ] assert findLargestSubmatrix(4, 5, matrix) == 6 def test_case_2(): matrix = [ [1, 1, 1], [1, 1, 1], [1, 1,...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def findLargestSubmatrix(n, m, matrix):", "function_name": "findLargestSubmatrix", "par...
[ 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 maximalRectangle(matrix):\n if not matrix:\n return 0\n \n n, m = len(matrix), len(matrix[0])\n max_area = 0\n heights = [0] * m\n \n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014083", "row_id": 14083, "seed_ids": "[23835]" }
0.677472
Taco_14083
I
[ "maximalRectangle", "findLargestSubmatrix" ]
2
[ [ "findLargestSubmatrix", "maximalRectangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6d08e321cd27741796cc603abbb599977e5fa199
a571c318d34416f19727ab253c5effcea9f11725
v1.0
instruct
Taco
Taco_14087_I
You are given a list of `n` integers and `m` queries. Each query is described by a pair of integers `l` and `r` (1 ≤ l ≤ r ≤ n). The answer to the query `l, r` is the sum of the integers from index `l` to `r` in the list. Write a program that can handle up to `m` queries efficiently. Input: The first line contains an ...
def preprocess(arr): """ Preprocess the array to calculate the prefix sums. :param arr: List of integers. :return: List of prefix sums. """ prefix_sums = [0] * (len(arr) + 1) for i in range(1, len(arr) + 1): prefix_sums[i] = prefix_sums[i - 1] + arr[i - 1] return prefix_sums...
from solution import preprocess, sum_range, process_queries def test_preprocess(): assert preprocess([1, 2, 3, 4, 5]) == [0, 1, 3, 6, 10, 15] assert preprocess([-1, -2, -3, -4, -5]) == [0, -1, -3, -6, -10, -15] assert preprocess([0, 0, 0]) == [0, 0, 0, 0] def test_sum_range(): prefix_sums = preprocess...
[ { "docstring": "Preprocess the array to calculate the prefix sums.\n\n:param arr: List of integers.\n:return: List of prefix sums.", "function_declaration": "def preprocess(arr):", "function_name": "preprocess", "parameter_list": "(arr)" }, { "docstring": "Calculate the sum of the integers 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": "def preprocess_sum_array(arr):\n \"\"\"\n Preprocess the given array to create a prefix sum array for efficient query handling.\n \n Args:\n - arr (...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014087", "row_id": 14087, "seed_ids": "[15168]" }
0.692503
Taco_14087
I
[ "preprocess", "sum_range", "process_queries" ]
3
[ [ "process_queries", "preprocess" ], [ "process_queries", "sum_range" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
109667aa9472af39fd4223dea74a40ae60cb61dc
2066d28fc8e7fb980fcbf58a9ce9548241ca705a
v1.0
instruct
Taco
Taco_14126_I
Ram is very fond of reading and he has a special way of categorizing books based on their titles. He considers a book title "interesting" if it can be rearranged to form a palindrome. A palindrome is a sequence that reads the same forward and backward. Given Q book titles, help Ram determine whether each title can be r...
def is_interesting(title): """ Determines if a book title can be rearranged to form a palindrome. Args: title (str): The book title. Returns: str: "INTERESTING" if the title can be rearranged to form a palindrome, otherwise "NOT INTERESTING". """ from collections import Counter...
from solution import is_interesting, process_titles def test_is_interesting(): assert is_interesting("civic") == "INTERESTING" assert is_interesting("ivicc") == "INTERESTING" assert is_interesting("hello") == "NOT INTERESTING" assert is_interesting("aabbccdd") == "INTERESTING" assert is_interesting...
[ { "docstring": "Determines if a book title can be rearranged to form a palindrome.\n\nArgs:\ntitle (str): The book title.\n\nReturns:\nstr: \"INTERESTING\" if the title can be rearranged to form a palindrome, otherwise \"NOT INTERESTING\".", "function_declaration": "def is_interesting(title):", "functio...
[ 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_interesting(title):\n \"\"\"\n Determines if a book title can be rearranged to form a palindrome.\n \n Args:\n title (str): The book title.\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00014126", "row_id": 14126, "seed_ids": "[22909]" }
0.751501
Taco_14126
I
[ "is_interesting", "process_titles" ]
2
[ [ "process_titles", "is_interesting" ] ]
1
[]
false
[]
false
pytest
true
[]
true
20c7d988a4319c59d9f861db834c45b5ffb584cd
a7e0853b776de2bc93de81b984cbc475bc62ecfd
v1.0
instruct
Taco
Taco_14132_I
You are a data scientist working on a project that requires you to evaluate the accuracy of various classifiers. You have implemented two classifiers and obtained their confusion matrices based on test datasets. A confusion matrix for a binary classifier is a 2x2 matrix that summarizes the performance of a classificati...
def calculate_f1(tp, fn, fp, tn): precision = tp / (tp + fp) if (tp + fp) != 0 else 0 recall = tp / (tp + fn) if (tp + fn) != 0 else 0 if precision + recall == 0: return 0 return 2 * (precision * recall) / (precision + recall) def compare_classifiers(matrix1, matrix2): tp1, fn1, fp1, tn1 = ...
from solution import compare_classifiers def test_compare_classifiers_case1(): matrix1 = [50, 10, 15, 25] matrix2 = [45, 10, 10, 35] assert compare_classifiers(matrix1, matrix2) == "2" def test_compare_classifiers_case2(): matrix1 = [30, 20, 10, 40] matrix2 = [30, 20, 10, 40] assert compare_cl...
[ { "docstring": null, "function_declaration": "def calculate_f1(tp, fn, fp, tn):", "function_name": "calculate_f1", "parameter_list": "(tp, fn, fp, tn)" }, { "docstring": null, "function_declaration": "def compare_classifiers(matrix1, matrix2):", "function_name": "compare_classifiers"...
[ 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 calculate_f1(tp, fn, fp, tn):\n precision = tp / (tp + fp) if (tp + fp) != 0 else 0\n recall = tp / (tp + fn) if (tp + fn) != 0 else 0\n if precision ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00014132", "row_id": 14132, "seed_ids": "[18249]" }
0.518304
Taco_14132
I
[ "calculate_f1", "compare_classifiers" ]
2
[ [ "compare_classifiers", "calculate_f1" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6294f01aa89af00d7665a4f48f02b7dc52bb1b13
f64cae0318b2375c6ae7af907a4dcfe0852cbdaa
v1.0
instruct
Taco
Taco_14141_I
Alice loves playing with numbers and she recently discovered the concept of a prime number. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Alice decided to create a coding puzzle that involves prime numbers in a different way. The puzzle requires sorting number...
def is_prime(n): """ Check if a number is a prime number. """ 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 re...
from solution import is_prime, custom_sort def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(19) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(97) == True ...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Sort the array such that all prime numbers appear before all non-prime numbers.\nPrime numbers should be sorted in ascend...
[ 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_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014141", "row_id": 14141, "seed_ids": "[23132]" }
0.676217
Taco_14141
I
[ "is_prime", "custom_sort" ]
2
[ [ "custom_sort", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f55e4141997a2970a6d22b924a9f893f8678e156
8a380ae6eebe9aa8e31514a90bf5337207679c54
v1.0
instruct
Taco
Taco_14152_I
Problem Description: The Quicksort algorithm is a widely used sorting algorithm due to its average-case time complexity of O(n log n) and its relatively simple implementation. However, sometimes it can perform poorly if the pivot selection strategy is not carefully chosen, leading to the worst-case time complexity of O...
def median_of_three(arr, low, mid, high): """ Returns the index of the median value among arr[low], arr[mid], and arr[high]. """ if (arr[low] - arr[mid]) * (arr[high] - arr[low]) >= 0: return low elif (arr[mid] - arr[low]) * (arr[high] - arr[mid]) >= 0: return mid else: r...
from solution import optimized_quicksort def test_optimized_quicksort(): arr = [3, 1, 2, 5, 4] optimized_quicksort(arr) assert arr == [1, 2, 3, 4, 5] arr = [10, -1, 3, 2] optimized_quicksort(arr) assert arr == [-1, 2, 3, 10] arr = [] optimized_quicksort(arr) assert arr == [] ...
[ { "docstring": "Returns the index of the median value among arr[low], arr[mid], and arr[high].", "function_declaration": "def median_of_three(arr, low, mid, high):", "function_name": "median_of_three", "parameter_list": "(arr, low, mid, high)" }, { "docstring": null, "function_declaratio...
[ 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 median_of_three(arr, low, mid, high):\n if arr[low] > arr[mid]:\n arr[low], arr[mid] = arr[mid], arr[low]\n if arr[mid] > arr[high]:\n arr[...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014152", "row_id": 14152, "seed_ids": "[18416]" }
0.576159
Taco_14152
I
[ "median_of_three", "partition", "quicksort", "optimized_quicksort" ]
4
[ [ "optimized_quicksort", "quicksort" ], [ "partition", "median_of_three" ], [ "quicksort", "partition" ] ]
3
[]
false
[]
false
pytest
true
[]
true
a37292a0bc71657f2c643a4c17d91cd9e1e699de
8e409e88307c3c94b35f8d269efeb04b6a33ef47
v1.0
instruct
Taco
Taco_14222_I
In a faraway galaxy, there is a planet called "Algorithma" where the citizens use strange symbols as currency. Each symbol has a positive integer value associated with it. One day, a famous mathematician Prof. Factorial, discovered a special property about these symbols that if you multiply the values of contiguous sub...
import math def generate_factorials(limit): factorials = set() i = 1 fact = 1 while fact <= limit: factorials.add(fact) i += 1 fact *= i return factorials MAX_VAL = 10**6 factorials = generate_factorials(MAX_VAL) def is_subarray_product_factorial(arr): n = len(arr) ...
from solution import check_test_cases def test_case_1(): test_cases = [ (6, [1, 2, 6, 24, 3, 4]), (5, [3, 4, 7, 8, 9]) ] result = check_test_cases(test_cases) assert result == ["YES", "NO"] def test_case_2(): test_cases = [ (3, [1, 1, 2]), (4, [5, 10, 25, 120]) ...
[ { "docstring": null, "function_declaration": "def generate_factorials(limit):", "function_name": "generate_factorials", "parameter_list": "(limit)" }, { "docstring": null, "function_declaration": "def is_subarray_product_factorial(arr):", "function_name": "is_subarray_product_factori...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef generate_factorials(limit):\n factorials = set()\n i = 1\n fact = 1\n while fact <= limit:\n factorials.add(fact)\n i ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00014222", "row_id": 14222, "seed_ids": "[16379]" }
0.602964
Taco_14222
I
[ "generate_factorials", "is_subarray_product_factorial", "check_test_cases" ]
3
[ [ "check_test_cases", "is_subarray_product_factorial" ] ]
1
[ "check_test_cases" ]
false
[]
false
pytest
true
[]
true
bf94dfd2caf6161c4d4d49f2198165048ca6e64e
c40124d01ec58102b6b0d4e64335ecde3b91aaf5
v1.0
instruct
Taco
Taco_14265_I
A research laboratory is developing an intelligent system to manage the city’s water distribution in a more efficient way. The city’s water distribution network consists of `n` water reservoirs (nodes) and `m` directed pipes (edges) between them. Each pipe has a specific capacity representing the maximum amount of wate...
from collections import deque def bfs_capacity_path(capacity, source, sink, parent): visited = [False] * len(capacity) queue = deque([source]) visited[source] = True while queue: u = queue.popleft() for v, cap in enumerate(capacity[u]): if not visited[v] and cap > 0: #...
from solution import max_water_flow def test_example_case(): n = 4 m = 5 S = 1 T = 4 pipes = [(1, 2, 10), (2, 3, 5), (3, 4, 10), (1, 3, 10), (2, 4, 5)] assert max_water_flow(n, m, S, T, pipes) == 15 def test_small_case(): n = 2 m = 1 S = 1 T = 2 pipes = [(1, 2, 10)] ass...
[ { "docstring": null, "function_declaration": "def bfs_capacity_path(capacity, source, sink, parent):", "function_name": "bfs_capacity_path", "parameter_list": "(capacity, source, sink, parent)" }, { "docstring": null, "function_declaration": "def edmonds_karp(n, capacity, source, sink):"...
[ 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 collections import deque, defaultdict\n\ndef bfs(source, sink, parent, graph):\n visited = set()\n queue = deque([source])\n visited.add(source)\n\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014265", "row_id": 14265, "seed_ids": "[18477]" }
0.649868
Taco_14265
I
[ "bfs_capacity_path", "edmonds_karp", "max_water_flow" ]
3
[ [ "edmonds_karp", "bfs_capacity_path" ], [ "max_water_flow", "edmonds_karp" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9e4a33e2069e87899923da98921061dd3680e1ce
a3760e8a43f8df0c716ed7d79ba09476be3ee267
v1.0
instruct
Taco
Taco_14291_I
Alice and Bob are playing a game on a grid-based board. The board is a rectangular grid of cells, each of which can be either empty or contain a wall. The players can move up, down, left, or right, but they cannot move through walls. Each player starts at a specified position on the board, and their goal is to navigate...
from collections import deque def bfs(start_x, start_y, destination_x, destination_y, board, W, H): # Directions for moving up, down, left, right directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(start_x, start_y, 0)]) # (x, y, distance) visited = set((start_x, start_y)) while q...
import pytest from solution import who_wins def test_case_1(): W, H = 4, 4 Ax, Ay = 0, 0 Bx, By = 3, 0 Dx, Dy = 3, 3 board = [ "....", ".#..", ".#..", "...." ] assert who_wins(W, H, Ax, Ay, Bx, By, Dx, Dy, board) == "Bob" def test_case_2(): W, H = 5, 5 ...
[ { "docstring": null, "function_declaration": "def bfs(start_x, start_y, destination_x, destination_y, board, W, H):", "function_name": "bfs", "parameter_list": "(start_x, start_y, destination_x, destination_y, board, W, H)" }, { "docstring": null, "function_declaration": "def who_wins(W,...
[ 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 deque\n\ndef bfs(start_x, start_y, grid, W, H, destination):\n queue = deque()\n queue.append((start_x, start_y, 0))\n visited = s...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014291", "row_id": 14291, "seed_ids": "[10045]" }
0.735138
Taco_14291
I
[ "bfs", "who_wins" ]
2
[ [ "who_wins", "bfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
11bfbd90c46654b0a207dca585aa7a59df94239b
4231dc1de1298c4c003f8379188519019d2387f9
v1.0
instruct
Taco
Taco_14351_I
Gianna loves to solve number puzzles involving prime numbers. She recently came across a puzzle that interested her and decided to share it with you. The puzzle goes as follows: Given an integer N, you need to find the smallest prime number P such that P is greater than or equal to N. A prime number is a natural num...
def is_prime(num): """ Helper function to 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 F...
from solution import is_prime, smallest_prime_greater_equal 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(37) == True assert is_prime(39) == False def test_smallest_prime_greater_equal(): as...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Finds the smallest prime number P that is greater than or equal to N.", "function_declaration": "def sm...
[ 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 Helper function to check if num is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014351", "row_id": 14351, "seed_ids": "[2655]" }
0.608574
Taco_14351
I
[ "is_prime", "smallest_prime_greater_equal" ]
2
[ [ "smallest_prime_greater_equal", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f0fdd8183ce868b2f5b3b3849d22a3ce92fdc20c
581720664fdded082331db326e77bf8032e6d26b
v1.0
instruct
Taco
Taco_14355_I
Alice has recently started learning about tree data structures, and she finds them fascinating. She learned that a tree with n nodes has exactly n-1 edges and is connected. To test her understanding, she decided to focus on a specific problem: finding the diameter of a tree. The diameter (or width) of a tree is the le...
from collections import deque def bfs_farthest_node(adj_list, start): n = len(adj_list) distances = [-1] * n queue = deque([start]) distances[start] = 0 farthest_node = start max_distance = 0 while queue: current = queue.popleft() for neighbor in adj_list[current]: ...
def test_tree_diameter(): assert tree_diameter(5, [(1, 2), (1, 3), (2, 4), (2, 5)]) == 3 assert tree_diameter(3, [(1, 2), (2, 3)]) == 2 assert tree_diameter(4, [(1, 2), (2, 3), (3, 4)]) == 3 assert tree_diameter(6, [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6)]) == 5 assert tree_diameter(7, [(1, 2), (1, 3...
[ { "docstring": null, "function_declaration": "def bfs_farthest_node(adj_list, start):", "function_name": "bfs_farthest_node", "parameter_list": "(adj_list, start)" }, { "docstring": null, "function_declaration": "def tree_diameter(n, edges):", "function_name": "tree_diameter", "p...
[ 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_farthest_node(start, graph):\n \"\"\"\n Performs BFS from the start node and returns the farthest node...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014355", "row_id": 14355, "seed_ids": "[11826]" }
0.711799
Taco_14355
I
[ "bfs_farthest_node", "tree_diameter" ]
2
[ [ "tree_diameter", "bfs_farthest_node" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b03c20664212721f8e5ab4c032e115686dbdbb71
75f866528eb3504afd3036146a49319cac56b17e
v1.0
instruct
Taco
Taco_14378_I
You are given an integer array representing the initial state of a grid, where each cell contains either '1' or '0'. Each '1' represents a live cell, and each '0' represents a dead cell. The grid evolves according to the following rules: 1. Any live cell with fewer than two live neighbors dies, as if caused by under-po...
def game_of_life(grid): """ Computes the next state of the grid based on the Game of Life rules. """ N = len(grid) next_state = [[0] * N for _ in range(N)] for r in range(N): for c in range(N): live_neighbors = count_live_neighbors(grid, r, c, N) ...
from solution import game_of_life def test_game_of_life(): grid = [ [0, 1, 0], [0, 0, 1], [1, 1, 1] ] expected_output = [ [0, 0, 0], [1, 0, 1], [0, 1, 1] ] assert game_of_life(grid) == expected_output def test_game_of_life_all_dead(): grid = [ ...
[ { "docstring": "Computes the next state of the grid based on the Game of Life rules.", "function_declaration": "def game_of_life(grid):", "function_name": "game_of_life", "parameter_list": "(grid)" }, { "docstring": "Counts the live neighbors of a given cell in the grid.", "function_decl...
[ 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 get_live_neighbors(grid, row, col):\n live_neighbors = 0\n directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]\n n = l...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014378", "row_id": 14378, "seed_ids": "[1193]" }
0.6778
Taco_14378
I
[ "game_of_life", "count_live_neighbors" ]
2
[ [ "game_of_life", "count_live_neighbors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
54fca5d287020462c426a2edfd3a11e70ba6618c
21d005d0f01dada7fd0993322b23c8d544c45165
v1.0
instruct
Taco
Taco_14460_I
In a small town, there is a single route consisting of n house segments connected by bidirectional roads. Each segment is represented by an integer value, indicating the number of houses in that segment. Since the route is a loop, feel free to start the counting from any segment and continue counting along the route un...
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 max_consecutive_primes(n...
from solution import max_consecutive_primes def test_example_1(): assert max_consecutive_primes(5, [7, 4, 6, 5, 13]) == 2 def test_example_2(): assert max_consecutive_primes(3, [2, 3, 5]) == 3 def test_example_3(): assert max_consecutive_primes(4, [8, 10, 4, 6]) == 0 def test_single_prime(): assert ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def max_consecutive_primes(n, segments):", "function_name": "max_consecutive_primes", "parameter_list": "(n, ...
[ 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_prime(num):\n if num < 2:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n return False\n retur...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014460", "row_id": 14460, "seed_ids": "[10929]" }
0.572187
Taco_14460
I
[ "is_prime", "max_consecutive_primes" ]
2
[ [ "max_consecutive_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bb8dd6f61589c1d50508acb6e34ecb278e482980
6696d3bb911603bd986c7d9ebc85f002e3067dd6
v1.0
instruct
Taco
Taco_14503_I
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Chef has retired and decided to spend his time with his favorite hobby, gardening. He is particularly interested in arranging flowers in a straight line along his garden path. Each flower has a specific height, and Chef wants the heights of ...
def min_changes_to_non_decreasing(n, heights): """ Returns the minimum number of changes required to make the flower heights non-decreasing. """ # Create a list of tuples (height, original_position) indexed_heights = list(enumerate(heights)) # Sort based on heights indexed_heights.sort(...
from solution import min_changes_to_non_decreasing, solve, parse_input def test_min_changes_to_non_decreasing(): assert min_changes_to_non_decreasing(4, [3, 1, 4, 2]) == 2 assert min_changes_to_non_decreasing(5, [1, 2, 3, 4, 5]) == 0 assert min_changes_to_non_decreasing(3, [3, 2, 1]) == 2 assert min_ch...
[ { "docstring": "Returns the minimum number of changes required to make the flower heights non-decreasing.", "function_declaration": "def min_changes_to_non_decreasing(n, heights):", "function_name": "min_changes_to_non_decreasing", "parameter_list": "(n, heights)" }, { "docstring": null, ...
[ 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 min_changes_to_non_decreasing(flowers):\n \"\"\"\n Function to determine the minimum number of changes required \n to make the flower heights array in...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00014503", "row_id": 14503, "seed_ids": "[15109]" }
0.72336
Taco_14503
I
[ "min_changes_to_non_decreasing", "solve", "parse_input" ]
3
[ [ "solve", "min_changes_to_non_decreasing" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
453c58e37419761dc15a9aaa62719bb00e362476
a805856f8fe47939113cc46c4563fc9137138767
v1.0
instruct
Taco
Taco_14556_I
Alice is interested in palindromic numbers and wants to know how many palindromic numbers exist in a given range [L, R]. A number is considered palindromic if it reads the same backward as forward, such as 121 or 1331. Your task is to write a program that determines how many palindromic numbers are there between L and ...
def is_palindromic(num): """ Check if the number is palindromic. """ return str(num) == str(num)[::-1] def count_palindromic_numbers(L, R): """ Count the number of palindromic numbers in the range [L, R]. """ count = 0 for num in range(L, R + 1): if is_palindromic(num): ...
from solution import is_palindromic, count_palindromic_numbers, solve def test_is_palindromic(): assert is_palindromic(121) == True assert is_palindromic(1331) == True assert is_palindromic(123) == False assert is_palindromic(1) == True assert is_palindromic(22) == True def test_count_palindromic_...
[ { "docstring": "Check if the number is palindromic.", "function_declaration": "def is_palindromic(num):", "function_name": "is_palindromic", "parameter_list": "(num)" }, { "docstring": "Count the number of palindromic numbers in the range [L, R].", "function_declaration": "def count_pali...
[ 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_palindromic(n):\n \"\"\"\n Check if a number is palindromic.\n \"\"\"\n str_n = str(n)\n return str_n == str_n[::-1]\n\ndef count_palindromic...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014556", "row_id": 14556, "seed_ids": "[20475]" }
0.722981
Taco_14556
I
[ "is_palindromic", "count_palindromic_numbers", "solve" ]
3
[ [ "count_palindromic_numbers", "is_palindromic" ], [ "solve", "count_palindromic_numbers" ] ]
2
[]
false
[]
false
pytest
true
[]
true
36c79ea59ae519676cea88fcf082c312f7933bda
529aeacf67168c1384bd6b2abd87edea637b4d44
v1.0
instruct
Taco
Taco_14631_I
Alicia loves palindromic numbers, especially in their binary forms. She finds them fascinating and enjoys deciphering these patterns. Her teacher gave her a new challenge. For a given range of values from M to N, Alicia has to determine the total count of numbers X within that range such that their binary representatio...
def is_binary_palindrome(num): """ Check if the binary representation of a number is a palindrome. """ binary_rep = bin(num)[2:] return binary_rep == binary_rep[::-1] def countPalindromicNumbers(M, N): """ Count the number of integers between M and N (inclusive) whose binary representations...
from solution import countPalindromicNumbers def test_example_1(): assert countPalindromicNumbers(5, 10) == 3 # Binary palindromic numbers are 5, 7, 9 def test_example_2(): assert countPalindromicNumbers(10, 15) == 1 # Binary palindromic number is 15 def test_single_number_palindrome(): assert countPal...
[ { "docstring": "Check if the binary representation of a number is a palindrome.", "function_declaration": "def is_binary_palindrome(num):", "function_name": "is_binary_palindrome", "parameter_list": "(num)" }, { "docstring": "Count the number of integers between M and N (inclusive) whose bin...
[ 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_binary_palindrome(num):\n binary_rep = bin(num)[2:] # get binary representation without '0b' prefix\n return binary_rep == binary_rep[::-1]\n\ndef co...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014631", "row_id": 14631, "seed_ids": "[20386]" }
0.660006
Taco_14631
I
[ "is_binary_palindrome", "countPalindromicNumbers" ]
2
[ [ "countPalindromicNumbers", "is_binary_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
949fbe56fe4e54aa3132a6f9c934065d2f0a15fe
9b2647c8bd54a65115c4a7e3569a4560453e7846
v1.0
instruct
Taco
Taco_14701_I
You are given a grid-based urban area of size N x M (1 ≤ N, M ≤ 500). Each cell in this grid can either be an open space (represented by '.') or a building (represented by '#'). Fire can break out in any one of the open spaces, and it spreads to its four adjacent cells (north, south, east, west) any time they are also ...
def count_valid_fire_starts(grid, n, m): MOD = 1000000007 def dfs(x, y, visited): if x < 0 or y < 0 or x >= n or y >= m or grid[x][y] == '#' or visited[x][y]: return visited[x][y] = True dfs(x + 1, y, visited) dfs(x - 1, y, visited) dfs(x, y + 1, visited) ...
def test_example(): from io import StringIO import sys sys.stdin = StringIO(''' 3 3 ... .#. ... 4 4 .... .##. .##. .... 0 0 ''') solve() def test_single_open_space(): from io import StringIO import sys sys.stdin = StringIO(''' 2 3 .#....
[ { "docstring": null, "function_declaration": "def count_valid_fire_starts(grid, n, m):", "function_name": "count_valid_fire_starts", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", "parameter_list": "()" ...
[ 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": "MOD = 1000000007\n\ndef valid_fire_positions(grid, n, m):\n def dfs(x, y, visited):\n stack = [(x, y)]\n while stack:\n i, j = stack.po...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00014701", "row_id": 14701, "seed_ids": "[7573]" }
0.63512
Taco_14701
I
[ "count_valid_fire_starts", "solve" ]
2
[ [ "solve", "count_valid_fire_starts" ] ]
1
[]
false
[]
false
pytest
false
[]
true
36d40e57f14b8d5629ce81f703b0ceacc75c41c3
7ac62c6075bf6cfb9f7f34e300c2be723af4cfaf
v1.0
instruct
Taco
Taco_14796_I
Write a function that takes a list of integers and returns a new list containing only the elements that are prime numbers. A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers other than 1 and itself. Your task is to 1) **filter out non-prime numbers** from...
def is_prime(n): """ Check if a given number n 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 return True def filter_primes(numbers): ...
from solution import filter_primes, is_prime 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(10) == False assert is_prime(11) == True assert is_prime(15) == False assert is_prime(17) == Tru...
[ { "docstring": "Check if a given number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filter the list of numbers and return only those which are prime.", "function_declaration": "def filter_primes(numbers...
[ 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 Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014796", "row_id": 14796, "seed_ids": "[2309]" }
0.676696
Taco_14796
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
919198af95619caecd23ea66d46520cf398dd679
5dab45d886040aed09c5452e769315be6a29b032
v1.0
instruct
Taco
Taco_14817_I
For two integers a and b where 1 ≤ a, b ≤ N, let h(a, b) = |a - b| + gcd(a, b) + lcm(a, b). For a positive integer N, let min_h(N) denote the minimum value of h(a, b) over all pairs of integers (a, b) such that 1 ≤ a, b ≤ N. Your task is to find the total number of such pairs (a, b) for which h(a, b) = min_h(N). ---...
import math def min_h(N): if N == 1: return 1 # edge case as only one pair (1, 1) # Minimum h occurs when a=gcd(min(a, b)) is 1, and # the lcm of a and b will be a * b/ gcd(a, b) which simplifies to b if a is 1 # min_h(N) = 2 for any N >= 1 cause h(1,1) = |1-1| + gcd(1,1) + lcm(1,1) = 0 + 1 + ...
from solution import process_test_cases def test_single_case_N_1(): assert process_test_cases(1, [1]) == [1] def test_single_case_N_2(): assert process_test_cases(1, [2]) == [3] def test_single_case_N_3(): assert process_test_cases(1, [3]) == [5] def test_single_case_N_5(): assert process_test_cases...
[ { "docstring": null, "function_declaration": "def min_h(N):", "function_name": "min_h", "parameter_list": "(N)" }, { "docstring": null, "function_declaration": "def count_pairs_with_min_h(N):", "function_name": "count_pairs_with_min_h", "parameter_list": "(N)" }, { "docst...
[ 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\n\ndef h(a, b):\n \"\"\"\n Calculate h(a, b) = |a - b| + gcd(a, b) + lcm(a, b)\n \"\"\"\n gcd_ab = math.gcd(a, b)\n lcm_ab = (a * b) // ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014817", "row_id": 14817, "seed_ids": "[12221]" }
0.734185
Taco_14817
I
[ "min_h", "count_pairs_with_min_h", "process_test_cases" ]
3
[ [ "process_test_cases", "count_pairs_with_min_h" ], [ "process_test_cases", "min_h" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
716bec10c9b06e4d40ea0cf2d7c0bcee99752339
1218a5419037d4a3ee2790b1513fa658c6ec4568
v1.0
instruct
Taco
Taco_14836_I
You are given a tree with N nodes and N-1 edges. Each node contains a value, and each edge has a certain weight. You need to find the maximum sum of the node values on any path in the tree. A path in this context is defined as any sequence of nodes starting from one node and ending at another, while passing through int...
from collections import defaultdict def dfs(node, parent, values, tree, max_path_sum): current_sum = values[node - 1] local_sum = values[node - 1] for neighbor, weight in tree[node]: if neighbor != parent: sum_from_neighbor = dfs(neighbor, node, values, tree, max_path_sum) i...
from solution import max_path_sum_in_tree def test_example_1(): N = 5 node_values = [4, 5, 6, 3, 2] edges = [(1, 2, 3), (2, 3, 2), (3, 4, 4), (4, 5, 1)] assert max_path_sum_in_tree(N, node_values, edges) == 20 def test_example_2(): N = 3 node_values = [1, 2, 3] edges = [(1, 2, 1), (1, 3, 2...
[ { "docstring": null, "function_declaration": "def dfs(node, parent, values, tree, max_path_sum):", "function_name": "dfs", "parameter_list": "(node, parent, values, tree, max_path_sum)" }, { "docstring": null, "function_declaration": "def max_path_sum_in_tree(N, node_values, edges):", ...
[ 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 dfs(node, parent, values, tree, max_path_sum):\n current_sum = values[node - 1]\n local_sum = values[node - 1]\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00014836", "row_id": 14836, "seed_ids": "[16085]" }
0.779721
Taco_14836
I
[ "dfs", "max_path_sum_in_tree", "main" ]
3
[ [ "max_path_sum_in_tree", "dfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0c56864c90cace70426e0f9abe0fe567842375ab
05df6ba8cd64fe83151c42fd826a655afb1f414b
v1.0
instruct
Taco
Taco_14843_I
Implement a Sudoku Solver Sudoku is a logic-based, combinatorial number-placement puzzle. The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 sub-grids that compose the grid (also called "boxes", "blocks", or "regions") contain all of the digits from 1 to 9. The puzz...
def is_valid(board, row, col, num): # Check if number exists in row for x in range(9): if board[row][x] == num: return False # Check if number exists in column for x in range(9): if board[x][col] == num: return False # Check if number exists ...
import pytest from solution import solve_and_print_sudoku def test_sudoku_solver(): board = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6],...
[ { "docstring": null, "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": null, "function_declaration": "def solve_sudoku(board):", "function_name": "solve_sudoku", "parameter_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 solve_sudoku(board):\n \"\"\"\n Solves the given Sudoku puzzle using backtracking.\n The board is a 2D list of integers representing the Sudoku grid.\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014843", "row_id": 14843, "seed_ids": "[9436]" }
0.714596
Taco_14843
I
[ "is_valid", "solve_sudoku", "find_empty_location", "print_board", "solve_and_print_sudoku" ]
5
[ [ "solve_and_print_sudoku", "solve_sudoku" ], [ "solve_sudoku", "find_empty_location" ], [ "solve_sudoku", "is_valid" ] ]
3
[]
false
[]
false
pytest
true
[]
true
80639d8608898226298e21993ff211019a45aad6
c805f92074fdbcd1758ae2dc42bed17b2447f681
v1.0
instruct
Taco
Taco_14857_I
**Soup Distinction** In a local culinary contest, chefs are evaluated based on the soups they prepare. Each soup is characterized by its name and type. There are two types of soup: "creamy" and "broth". You need to determine how many different types of soups have been prepared. -----Input----- The first line of inpu...
def distinct_soup_types(soup_data): """ Determines the number of different types of soups. Parameters: soup_data (list of tuples): A list where each tuple contains a soup name and its type. Returns: int: The number of different soup types. """ soup_types = set() for _, soup...
def test_distinct_soup_types(): assert distinct_soup_types([("tomato", "creamy"), ("chickenbroth", "broth"), ("mushroom", "creamy"), ("minestrone", "broth"), ("carrot", "creamy")]) == 2 assert distinct_soup_types([("lentil", "broth"), ("pumpkin", "creamy"), ("beefbroth", "broth"...
[ { "docstring": "Determines the number of different types of soups.\n\nParameters:\nsoup_data (list of tuples): A list where each tuple contains a soup name and its type.\n\nReturns:\nint: The number of different soup types.", "function_declaration": "def distinct_soup_types(soup_data):", "function_name"...
[ 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 count_soup_types(soups):\n \"\"\"\n Returns the number of different types of soups prepared.\n \n :param soups: List of tuples (name, type)\n :r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014857", "row_id": 14857, "seed_ids": "[17955]" }
0.607663
Taco_14857
I
[ "distinct_soup_types", "count_soup_types_from_input" ]
2
[ [ "count_soup_types_from_input", "distinct_soup_types" ] ]
1
[]
false
[]
false
pytest
false
[]
true
e0f8d8aa014f667521e2a8adf7e2ac5a81be96cd
f55866ed13447cef7d92908b97fcea2e5702925d
v1.0
instruct
Taco
Taco_14877_I
Problem In a network communication system, we have N servers connected by direct communication channels. Each server has a unique ID from 1 to N. Some servers may be directly connected to each other by a bidirectional communication channel, which allows them to directly send and receive messages without having to rout...
def find_connected_components(n, edges): """ Finds the number of connected components in a network of servers. Parameters: n (int): Number of servers. edges (List[Tuple[int, int]]): List of bidirectional communication channels between servers. Returns: int: Number of connected comp...
def test_number_of_connected_components_basic(): input_data = "5 3\n1 2\n2 3\n4 5" assert number_of_connected_components(input_data) == 2 def test_number_of_connected_components_all_connected(): input_data = "6 5\n1 2\n2 3\n3 4\n4 5\n5 6" assert number_of_connected_components(input_data) == 1 def test...
[ { "docstring": "Finds the number of connected components in a network of servers.\n\nParameters:\nn (int): Number of servers.\nedges (List[Tuple[int, int]]): List of bidirectional communication channels between servers.\n\nReturns:\nint: Number of connected components.", "function_declaration": "def find_co...
[ 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_connected_components(n, edges):\n \"\"\"\n Returns the number of connected components in the network of servers.\n \"\"\"\n from collections i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014877", "row_id": 14877, "seed_ids": "[16560]" }
0.6821
Taco_14877
I
[ "find_connected_components", "number_of_connected_components" ]
2
[ [ "number_of_connected_components", "find_connected_components" ] ]
1
[]
false
[]
false
pytest
false
[]
true
e8fd2589218a0169c70094d11c048488ebfc4239
b5047e4f313d59226515c17fbc529b1c2519fd21
v1.0
instruct
Taco
Taco_14881_I
Isabella is fascinated with a new sequence problem. She has discovered a sequence where each term \( S_n \) is generated based on an initial term \( S_1 \) and subsequent terms follow a particular rule. Given the initial term \( S_1 = k \), the next term is generated by splitting the current term into its digits, summi...
def sum_of_squares_of_digits(n): """ Function to calculate the sum of squares of digits of a given number. """ return sum(int(digit) ** 2 for digit in str(n)) def is_sequence_ending_in_1(k): """ Determines if the sequence starting with k ends in 1. """ seen_numbers = set() while k !...
from solution import is_sequence_ending_in_1, process_test_cases def test_is_sequence_ending_in_1(): assert is_sequence_ending_in_1(19) == True assert is_sequence_ending_in_1(2) == False assert is_sequence_ending_in_1(7) == True assert is_sequence_ending_in_1(1) == True assert is_sequence_ending_in...
[ { "docstring": "Function to calculate the sum of squares of digits of a given number.", "function_declaration": "def sum_of_squares_of_digits(n):", "function_name": "sum_of_squares_of_digits", "parameter_list": "(n)" }, { "docstring": "Determines if the sequence starting with k ends in 1.", ...
[ 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 split_and_square_sum(n):\n \"\"\" Helper function to split the integer into digits and return the sum of squares of its digits. \"\"\"\n return sum(int(d...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014881", "row_id": 14881, "seed_ids": "[22769]" }
0.682134
Taco_14881
I
[ "sum_of_squares_of_digits", "is_sequence_ending_in_1", "process_test_cases" ]
3
[ [ "is_sequence_ending_in_1", "sum_of_squares_of_digits" ], [ "process_test_cases", "is_sequence_ending_in_1" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
1be6b83a153fa0b5ca0e115a5396ede7b0144067
08116ce5a9bec1a3d822a2d30ba8efcf78a5a52d
v1.0
instruct
Taco
Taco_14976_I
You are given an array of integers where each integer represents the height of a building. Suppose you have to answer several queries where each query gives you two indices (left and right) in the array and asks you to determine the maximum building height in the range between these two indices (inclusive). Write a pr...
def preprocess_heights(heights): """ Preprocess the heights array to support efficient range maximum queries. Uses a sparse table data structure for O(1) range maximum queries with O(n log n) preprocessing. :param heights: List of integers representing the heights of the buildings. :return: Spa...
def test_preprocess_heights(): heights = [1, 5, 4, 3, 8, 6] sparse_table = preprocess_heights(heights) assert sparse_table[0][0] == 1 assert sparse_table[1][0] == 5 assert sparse_table[2][0] == 4 assert sparse_table[3][0] == 3 assert sparse_table[4][0] == 8 assert sparse_table[5][0] == 6...
[ { "docstring": "Preprocess the heights array to support efficient range maximum queries.\nUses a sparse table data structure for O(1) range maximum queries with O(n log n) preprocessing.\n\n:param heights: List of integers representing the heights of the buildings.\n:return: Sparse table for range maximum queri...
[ 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_building_heights(building_heights):\n \"\"\"\n Preprocess the building heights for fast query responses.\n Constructs a 2D array for suppor...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014976", "row_id": 14976, "seed_ids": "[22352]" }
0.724885
Taco_14976
I
[ "preprocess_heights", "range_max_query", "process_queries" ]
3
[ [ "process_queries", "preprocess_heights" ], [ "process_queries", "range_max_query" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
acfce06b585e12ae53b8f8ac1645676784fd9e0d
db378a9070f8ec22b3babd9b7d0016ae7aa28828
v1.0
instruct
Taco
Taco_15001_I
Write a function that generates all possible valid IPv4 addresses from a given string of digits. An IPv4 address consists of four octets (numbers between 0 and 255), separated by periods. Given a string `s` of digits, your task is to restore it by returning all possible valid IPv4 addresses that can be formed by insert...
def is_valid_octet(octet): """ Check if the octet is a valid segment of an IP address """ if len(octet) == 0 or len(octet) > 3: return False if len(octet) > 1 and octet[0] == '0': return False if int(octet) > 255: return False return True def restore_ip_addresses(s): """...
from solution import restore_ip_addresses def test_restore_ip_addresses_case1(): assert restore_ip_addresses("25525511135") == ["255.255.11.135", "255.255.111.35"] def test_restore_ip_addresses_case2(): assert restore_ip_addresses("0000") == ["0.0.0.0"] def test_restore_ip_addresses_case3(): assert resto...
[ { "docstring": "Check if the octet is a valid segment of an IP address ", "function_declaration": "def is_valid_octet(octet):", "function_name": "is_valid_octet", "parameter_list": "(octet)" }, { "docstring": "Generate all possible valid IPv4 addresses from the given string ", "function_...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def restore_ip_addresses(s):\n def is_valid(octet):\n # An octet is valid if it is between 0 and 255 and has no leading zeros unless it is '0'\n r...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00015001", "row_id": 15001, "seed_ids": "[10747]" }
0.530267
Taco_15001
I
[ "is_valid_octet", "restore_ip_addresses" ]
2
[ [ "restore_ip_addresses", "is_valid_octet" ] ]
1
[]
false
[]
false
pytest
true
[]
true
47564468bccdc6c022ee89172d802d967f8406fa
0a7ce7be20d2e15a4d12590b85c4dcbf84b77fe5
v1.0
instruct
Taco
Taco_15016_I
Erika is planning to organize an international programming contest. She has several venues across different cities of her country, which are connected by roads. Each road can have different travel times depending on the time of day. She wants to select a set of venues such that the maximum time required to travel betwe...
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_simple_case(): from solution import minimize_max_time n = 6 edges = [ (1-1, 2-1, 4), (2-1, 3-1, 5), (3-1, 4-1, 6), (4-1, 5-1, 2), (5-1, 6-1, 3), ] k = 3 assert minimize_max_time(n, edges, k) == 4 def test_case_one_connection(): from solu...
[ { "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, 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": "from heapq import heappush, heappop\n\ndef find_minimized_max_travel_time(n, edges, k):\n def prim_mst(adj_list):\n min_cost = [float('inf')] * n\n ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00015016", "row_id": 15016, "seed_ids": "[15751]" }
0.700904
Taco_15016
I
[ "find", "union", "kruskal", "minimize_max_time", "solve" ]
5
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimize_max_time", "kruskal" ], [ "solve", "minimize_max_time" ], [ "union", "find" ] ]
5
[]
false
[]
false
pytest
true
[]
true
b1aab9c52a45c33ba0cca51c9db13438319e8ecd
df9fd22a1fe4c95621bd2cd69be4398445fba300
v1.0
instruct
Taco
Taco_15056_I
Given an integer N, you need to find the sum of all prime numbers less than or equal to N which also fall within a given range [L, R]. If no such primes exist within the specified range, return 0. Input Format The first line contains a single integer T, denoting the number of test cases. Each test case consists of thr...
def sieve(N): primes = [True] * (N + 1) p = 2 while p * p <= N: if primes[p]: for i in range(p * p, N + 1, p): primes[i] = False p += 1 prime_numbers = [p for p in range(2, N + 1) if primes[p]] return prime_numbers def sum_of_primes_in_range(N, L, R): ...
from solution import process_test_cases, sum_of_primes_in_range def test_case_1(): assert sum_of_primes_in_range(10, 2, 5) == 10 def test_case_2(): assert sum_of_primes_in_range(11, 3, 11) == 26 def test_case_3(): assert sum_of_primes_in_range(15, 10, 20) == 24 def test_case_4(): assert sum_of_prime...
[ { "docstring": null, "function_declaration": "def sieve(N):", "function_name": "sieve", "parameter_list": "(N)" }, { "docstring": null, "function_declaration": "def sum_of_primes_in_range(N, L, R):", "function_name": "sum_of_primes_in_range", "parameter_list": "(N, L, R)" }, ...
[ 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 sieve_of_eratosthenes(n):\n \"\"\"\n Generates a list of boolean values that indicate whether numbers are prime\n up to the integer n.\n \"\"\"\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00015056", "row_id": 15056, "seed_ids": "[1068]" }
0.625851
Taco_15056
I
[ "sieve", "sum_of_primes_in_range", "process_test_cases" ]
3
[ [ "process_test_cases", "sum_of_primes_in_range" ], [ "sum_of_primes_in_range", "sieve" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
d9b88caef88a6adf4d34b24f385aa1fae69623c0
a8d29efec620895d81a55c0c68e62e8b261d0d0c
v1.0
instruct
Taco
Taco_15104_I
Write a function that takes an array of positive integers and returns the number of prime numbers in the array. ### Example ```python count_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4 # The prime numbers are 2, 3, 5, 7 count_primes([2, 3, 5, 7, 11, 13, 17, 19, 23]) == 9 # All numbers in the list are prime count_prime...
def is_prime(n): """Helper function to check if a number is prime.""" 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 re...
from solution import count_primes, is_prime 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(17) == True def test_count_primes(): assert count_primes([2, 3, 4, 5, 6,...
[ { "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 number of prime numbers in the array.\n\nParameters:\narr (list): list of positive integers\n\nRetu...
[ 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 Helper function that checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00015104", "row_id": 15104, "seed_ids": "[17209]" }
0.818162
Taco_15104
I
[ "is_prime", "count_primes" ]
2
[ [ "count_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6cd52a99a1d07b6a51e86b5b8611de8a67299c5c
9e7e6eda3be9ad3fa86f6652cac15e1b5e8313c1
v1.0
instruct
Taco
Taco_15130_I
Marauders are planning a grand heist in the city, and they have assigned two infiltrators, I1 and I2, to find the best entry and exit routes. The city map can be represented as a grid of cells where each cell can have a value of '0' or '1'. A cell with value '1' allows movement, while a cell with value '0' is an obstac...
def maximal_rectangle(matrix): if not matrix: return 0 n = len(matrix[0]) heights = [0] * (n + 1) max_area = 0 for row in matrix: for i in range(n): if row[i] == 0: heights[i] = 0 else: heights[i] += 1 stack = [-1] ...
from solution import largest_rectangle_area def test_example(): input_str = "4 5\n1 0 1 0 0\n1 0 1 1 1\n1 1 1 1 1\n1 0 0 1 0" assert largest_rectangle_area(input_str) == 6 def test_small_grid(): input_str = "1 2\n0 1" assert largest_rectangle_area(input_str) == 1 def test_single_row(): input_str ...
[ { "docstring": null, "function_declaration": "def maximal_rectangle(matrix):", "function_name": "maximal_rectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_list": "(inp...
[ 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 maximalRectangle(matrix):\n if not matrix:\n return 0\n\n def maximal_histogram_area(heights):\n stack = []\n max_area = 0\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00015130", "row_id": 15130, "seed_ids": "[20791]" }
0.65182
Taco_15130
I
[ "maximal_rectangle", "parse_input", "largest_rectangle_area" ]
3
[ [ "largest_rectangle_area", "maximal_rectangle" ], [ "largest_rectangle_area", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
6bd65425a1d478f8d92dd71a63ca1627c4a95651
0b92d663692c1c847903c8c4dd6329cda880f93b
v1.0
instruct
Taco
Taco_15303_I
Imagine you are working with a system of connected computers in a network. Each computer needs periodic updates and these updates can be transmitted from one computer to another directly if there is a direct cable connection between them. However, setting up direct cable connections between every pair of computers is n...
def find_parent(parent, i): if parent[i] == i: return i return find_parent(parent, parent[i]) def union(parent, rank, x, y): xroot = find_parent(parent, x) yroot = find_parent(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: ...
def test_find_parent_and_union(): parent = [0, 1, 2, 3, 4] rank = [0, 0, 0, 0, 0] union(parent, rank, 0, 1) assert find_parent(parent, 0) == find_parent(parent, 1) union(parent, rank, 1, 2) assert find_parent(parent, 0) == find_parent(parent, 2) def test_connected_components(): n1 = 5 e...
[ { "docstring": null, "function_declaration": "def find_parent(parent, i):", "function_name": "find_parent", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank...
[ 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(parent, i):\n if parent[i] == i:\n return i\n return find_parent(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = fin...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00015303", "row_id": 15303, "seed_ids": "[9202]" }
0.698595
Taco_15303
I
[ "find_parent", "union", "connected_components", "min_connections_to_make_connected", "process_input" ]
5
[ [ "connected_components", "find_parent" ], [ "connected_components", "union" ], [ "min_connections_to_make_connected", "connected_components" ], [ "process_input", "min_connections_to_make_connected" ], [ "union", "find_parent" ] ]
5
[ "process_input" ]
false
[]
false
pytest
false
[]
true
ffaaa8d5fac15468ec0d84c0a0b2607f41e2f37d
612f445ac2240517496d8fc516aabfb52cf5b49e
v1.0
instruct
Taco
Taco_15315_I
A city has n electric stations and m power lines connecting them. Each power line has a certain capacity c, representing the maximum amount of electricity that can flow through the power line. The goal is to determine the maximum amount of electricity that can be sent from station s to station t. You are given n, m, ...
from collections import deque def bfs_capacity(capacity, source, sink, parent): visited = [False] * len(capacity) queue = deque([source]) visited[source] = True while queue: node = queue.popleft() for adj, cap in enumerate(capacity[node]): if not visited[adj] and cap > 0: ...
def test_example_1(): n, m, s, t = 4, 5, 1, 4 edges = [(1, 2, 100), (1, 3, 50), (2, 3, 50), (2, 4, 50), (3, 4, 50)] assert maximum_electricity(n, m, s, t, edges) == 100 def test_example_2(): n, m, s, t = 6, 7, 1, 6 edges = [(1, 2, 100), (1, 3, 50), (2, 4, 100), (3, 4, 50), (2, 5, 50), (4, 6, 75), (...
[ { "docstring": null, "function_declaration": "def bfs_capacity(capacity, source, sink, parent):", "function_name": "bfs_capacity", "parameter_list": "(capacity, source, sink, parent)" }, { "docstring": null, "function_declaration": "def edmonds_karp(n, edges, source, sink):", "functi...
[ 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 defaultdict, deque\n\ndef bfs_capacity(graph, src, tgt, capacity, parent):\n visited = set()\n queue = deque([src])\n visited.add(...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00015315", "row_id": 15315, "seed_ids": "[24011]" }
0.693105
Taco_15315
I
[ "bfs_capacity", "edmonds_karp", "maximum_electricity" ]
3
[ [ "edmonds_karp", "bfs_capacity" ], [ "maximum_electricity", "edmonds_karp" ] ]
2
[]
false
[]
false
pytest
false
[]
true
a83826e5a7e58242c78e2dc869d3c59a12dcedc2
a5e8c9a36621bb8776facb1d47c27e7bd0c039db
v1.0
instruct
Taco
Taco_15374_I
Write a program to perform a specific text transformation on a given string. The transformation involves shifting each letter of the string forward by one position in the alphabet, wrapping around from 'z' to 'a'. Non-alphabetic characters should remain unchanged. ------ Input ------ The first line of the input conta...
def shift_letter(c): """ Shifts a single character forward by one in the alphabet, wrapping 'z' to 'a' and 'Z' to 'A'. Non-alphabetic characters remain unchanged. """ if 'a' <= c <= 'z': return chr((ord(c) - ord('a') + 1) % 26 + ord('a')) elif 'A' <= c <= 'Z': return chr((ord(c) ...
from solution import shift_letter, shift_text, transform_strings def test_shift_letter(): assert shift_letter('a') == 'b' assert shift_letter('z') == 'a' assert shift_letter('A') == 'B' assert shift_letter('Z') == 'A' assert shift_letter('!') == '!' assert shift_letter(' ') == ' ' def test...
[ { "docstring": "Shifts a single character forward by one in the alphabet, wrapping 'z' to 'a' and 'Z' to 'A'.\nNon-alphabetic characters remain unchanged.", "function_declaration": "def shift_letter(c):", "function_name": "shift_letter", "parameter_list": "(c)" }, { "docstring": "Shifts each...
[ 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 shift_text(text):\n \"\"\"\n Shifts each letter of the given text forward by one position in the alphabet,\n wrapping around from 'z' to 'a'. Non-alph...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00015374", "row_id": 15374, "seed_ids": "[914]" }
0.772916
Taco_15374
I
[ "shift_letter", "shift_text", "transform_strings" ]
3
[ [ "shift_text", "shift_letter" ], [ "transform_strings", "shift_text" ] ]
2
[]
false
[]
false
pytest
true
[]
true
25a5647116a851c59cef4c636caf1d2688664fba
300ccd4b4c3e7426c559f4f40701e09b555a0dda
v1.0
instruct
Taco
Taco_15377_I
Riley loves card games and owns a special deck of cards, each card having a different integer written on it. Riley wants to sort the cards in non-decreasing order. However, there's a twist. Riley is only interested in sorting those cards whose values are prime numbers, while the non-prime cards should remain in their o...
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 sort_primes(deck): primes = [num for n...
from solution import sort_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False def test_sort_primes_basic(): assert sort_primes([7, 4, 10, 3, 18, 11, 2]) == [2, 4, 10, 3,...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def sort_primes(deck):", "function_name": "sort_primes", "parameter_list": "(deck)" } ]
[ 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 if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00015377", "row_id": 15377, "seed_ids": "[19450]" }
0.596559
Taco_15377
I
[ "is_prime", "sort_primes" ]
2
[ [ "sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6992f41e7e03c1807f6256f978a06febfcf11b6f
c82c38376166f76d647128c7d65f3ddb4847258c
v1.0
instruct
Taco
Taco_15383_I
You are working on a project to optimize the network routing within a large distributed system. The system consists of multiple servers connected together by bidirectional communication channels. Each server can communicate directly with any other server it's connected to. Your goal is to determine the minimal number o...
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 root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif rank[root_x] < ...
def test_case1(): T = 2 test_cases = [ (4, 2, [(1, 2), (2, 3)]), (5, 3, [(1, 2), (2, 3), (4, 5)]) ] expected_results = [ "Case #1: 1", "Case #2: 1" ] results = solve_network_routing(T, test_cases) assert results == expected_results def test_single_s...
[ { "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, 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_min_additional_channels(num_cases, cases):\n def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00015383", "row_id": 15383, "seed_ids": "[963]" }
0.630693
Taco_15383
I
[ "find", "union", "solve_network_routing", "process_input" ]
4
[ [ "process_input", "solve_network_routing" ], [ "solve_network_routing", "find" ], [ "solve_network_routing", "union" ], [ "union", "find" ] ]
4
[ "process_input" ]
false
[]
false
pytest
false
[]
true
f20cfb924edf27f4d6f283a80ed355b42d0c1d5f
f76fecb6f3c41d4de32e9105947102cef97b608b
v1.0
instruct
Taco
Taco_15403_I
Given an array of strings words, you need to find the longest string that can be formed by concatenating different words from the list without repeating any character. Each word must be taken as a whole and cannot be broken into individual characters. If there are multiple longest strings with the same length, return ...
from itertools import combinations def is_unique(s): return len(s) == len(set(s)) def findLongestUniqueConcat(words): n = len(words) longest = "" # Iterate over all possible combinations of the words for i in range(1, n+1): for combo in combinations(words, i): combined_wor...
from solution import findLongestUniqueConcat def test_example1(): assert findLongestUniqueConcat(["un", "iq", "ue"]) in ["uniq", "iquei", "uqnie"] def test_example2(): assert findLongestUniqueConcat(["cha", "r", "act", "ers"]) == "characters" or "actersrcha" def test_example3(): assert findLongestUniqueC...
[ { "docstring": null, "function_declaration": "def is_unique(s):", "function_name": "is_unique", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def findLongestUniqueConcat(words):", "function_name": "findLongestUniqueConcat", "parameter_list": "(words)" ...
[ 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 is_unique_concat(concat):\n \"\"\"\n Function to check if all characters in the concatenated string are unique\n \"\"\"\n return len(set(concat)) =...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00015403", "row_id": 15403, "seed_ids": "[17710]" }
0.67253
Taco_15403
I
[ "is_unique", "findLongestUniqueConcat" ]
2
[ [ "findLongestUniqueConcat", "is_unique" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a02d4ef3ac1165a85ab7eba436b8c48153868c0c
e0a571284dd3a0d98cfcfa02b6c6700526c2ff61
v1.0
instruct
Taco
Taco_15417_I
Create a program to analyze real estate data and identify properties that meet specific criteria. You have a list of properties, each with various attributes such as price, number of bedrooms, number of bathrooms, and size. Your task is to write a program that filters properties based on given conditions and calculate...
def parse_properties(n, properties_data): properties = [] for data in properties_data: price, bedrooms, bathrooms, size = map(int, data.split()) properties.append({ "price": price, "bedrooms": bedrooms, "bathrooms": bathrooms, "size": size ...
from solution import analyze_real_estate, parse_properties, parse_conditions, filter_properties, average_price def test_parse_properties(): properties_data = [ "300000 3 2 1500", "400000 4 3 2000", "250000 2 1 1200" ] expected = [ {"price": 300000, "bedrooms": 3, "bathrooms"...
[ { "docstring": null, "function_declaration": "def parse_properties(n, properties_data):", "function_name": "parse_properties", "parameter_list": "(n, properties_data)" }, { "docstring": null, "function_declaration": "def parse_conditions(m, conditions_data):", "function_name": "parse...
[ 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 filter_properties(properties, conditions):\n def matches_conditions(property):\n for attribute, operator, value in conditions:\n property_...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00015417", "row_id": 15417, "seed_ids": "[18242]" }
0.570789
Taco_15417
I
[ "parse_properties", "parse_conditions", "filter_properties", "average_price", "analyze_real_estate" ]
5
[ [ "analyze_real_estate", "average_price" ], [ "analyze_real_estate", "filter_properties" ], [ "analyze_real_estate", "parse_conditions" ], [ "analyze_real_estate", "parse_properties" ] ]
4
[]
false
[]
false
pytest
true
[]
true
7974dd4035bb08566cd9c7c26e5cbe2e561e4e9c
1e7f16a5defe6d1f3c0a1ddfc899e0e1fac0b49e
v1.0
instruct
Taco
Taco_15467_I
Given a binary tree, find the sum of the values of all the nodes that are the deepest leaves of the tree. -----Input:----- - The first line contains the number of nodes N. - Each of the next N lines contains three integers $p, c, d$ representing: - $p$: the value of a parent node. - $c$: the value of a child node....
class TreeNode: def __init__(self, val=0): self.val = val self.left = None self.right = None def deepestLeavesSum(edges): from collections import defaultdict, deque if not edges: return 0 tree = defaultdict(TreeNode) for p, c, d in edges: if p not in tree:...
from solution import sum_of_deepest_leaves def test_sample_input(): node_count = 6 edge_list = [ "1 2 0", "1 3 1", "2 4 0", "2 5 1", "3 6 0", "3 7 1" ] assert sum_of_deepest_leaves(node_count, edge_list) == 22 def test_single_node(): node_count = 1 ...
[]
[ 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 TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef build_tree(edges):\n nodes = {}\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00015467", "row_id": 15467, "seed_ids": "[21231]" }
0.680454
Taco_15467
I
[ "deepestLeavesSum", "sum_of_deepest_leaves" ]
2
[ [ "sum_of_deepest_leaves", "deepestLeavesSum" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
948d114b45c0ba4a2e5ea167e72439db75a2d05b
aadf1e5e908060921a5372cc1cb2d1899426cc11
v1.0
instruct
Taco
Taco_15518_I
You are given a sequence of integers, and you need to determine if you can make all elements of the sequence equal by adding the same integer `x` to all elements of the sequence or subtracting the same integer `x` from all elements of the sequence zero or more times. If it's possible, you also need to find the value of...
def find_x_to_equalize_sequence(sequences): results = [] for sequence in sequences: n = sequence[0] elements = sequence[1:] min_elem = min(elements) diffs = [elem - min_elem for elem in elements] gcd_diff = 0 for diff in diffs: gcd_diff = gcd(gcd_dif...
from solution import find_x_to_equalize_sequence def test_single_sequence(): assert find_x_to_equalize_sequence([[5, 1, 5, 7, 9, 13]]) == ["YES 2"] def test_all_elements_equal(): assert find_x_to_equalize_sequence([[4, 7, 7, 7, 7]]) == ["YES 0"] assert find_x_to_equalize_sequence([[3, -1, -1, -1]]) == ["Y...
[ { "docstring": null, "function_declaration": "def find_x_to_equalize_sequence(sequences):", "function_name": "find_x_to_equalize_sequence", "parameter_list": "(sequences)" }, { "docstring": null, "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": ...
[ 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 can_make_equal(seq):\n min_val, max_val = min(seq), max(seq)\n\n if min_val == max_val:\n return True, 0\n\n differences = set()\n for num i...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00015518", "row_id": 15518, "seed_ids": "[1150]" }
0.798862
Taco_15518
I
[ "find_x_to_equalize_sequence", "gcd" ]
2
[ [ "find_x_to_equalize_sequence", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3b26b7f022d9ad3a78d154870a3a879c5ad3524d
b395a5bbf5a5bd5698923e34ad9b9f27a1a078dc
v1.0
instruct
Taco
Taco_15538_I
In this problem, you are required to process a board game configuration input and determine the sequence of player moves, ultimately printing the updated state of the board after performing all the valid moves. The board is defined as a grid where each cell can either be empty (denoted by a '.'), occupied by a token b...
def process_moves(R, C, initial_board, moves): """ Processes the moves on the board and returns the final state of the board. :param R: number of rows :param C: number of columns :param initial_board: list of strings representing the initial state of the board :param moves: list of tuples, ...
def test_process_moves(): input_str = "3 3\n...\n...\n...\n4\nX 0 0\nO 1 1\nX 0 1\nO 0 0\n" expected_output = "XX.\n.O.\n...\n" assert game_from_input(input_str) == expected_output.strip() input_str = "2 2\n..\n..\n3\nX 0 0\nO 0 1\nX 1 1\n" expected_output = "XO\n.X\n" assert game_from_input(in...
[ { "docstring": "Processes the moves on the board and returns the final state of the board.\n\n:param R: number of rows\n:param C: number of columns\n:param initial_board: list of strings representing the initial state of the board\n:param moves: list of tuples, each containing a character ('X' or 'O') and two i...
[ 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 process_moves(R, C, initial_board, moves):\n \"\"\"\n Processes the moves on the board and returns the final state of the board.\n \n :param R: num...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00015538", "row_id": 15538, "seed_ids": "[11189]" }
0.697947
Taco_15538
I
[ "process_moves", "game_from_input" ]
2
[ [ "game_from_input", "process_moves" ] ]
1
[]
false
[]
false
pytest
false
[]
true
ea558925e907a141f4f3b93c41f8c54c726243df
061e44a78245dc00c8f0bc9134646ff60c3bcf27
v1.0
instruct
Taco
Taco_15571_I
ByteLand recently started a new telecommunications project. The project involves setting up communication towers at various locations. Each communication tower has a specific range that defines the area it can cover. Additionally, due to the frequency constraints, certain towers interfere with each other if they are in...
def max_non_interfering_towers(n, towers): # Sort towers based on their end position (xi + ri) towers.sort(key=lambda tower: tower[0] + tower[1]) # Initialize variables to keep track of the maximum number of non-interfering towers max_towers = 0 last_end = -float('inf') # Iterate over ...
import pytest from solution import max_non_interfering_towers def test_example_case(): n = 5 towers = [(1,2),(3,1),(4,1),(6,2),(8,1)] assert max_non_interfering_towers(n, towers) == 3 def test_non_interfering_towers(): n = 3 towers = [(1,0),(3,0),(5,0)] assert max_non_interfering_towers(n, tow...
[ { "docstring": null, "function_declaration": "def max_non_interfering_towers(n, towers):", "function_name": "max_non_interfering_towers", "parameter_list": "(n, towers)" }, { "docstring": null, "function_declaration": "def read_input_and_solve():", "function_name": "read_input_and_so...
[ 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 max_non_interfering_towers(n, towers):\n # Sort towers based on their end position (xi + ri)\n towers.sort(key=lambda tower: tower[0] + tower[1])\n \n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00015571", "row_id": 15571, "seed_ids": "[19668]" }
0.616289
Taco_15571
I
[ "max_non_interfering_towers", "read_input_and_solve" ]
2
[ [ "read_input_and_solve", "max_non_interfering_towers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a9a4b7466a3356f7bc2b347c255b713f682beee9
4574be4be1cb8eab197b2ca7929b30d2b74cc1d3
v1.0
instruct
Taco
Taco_15655_I
You are given a binary tree where each node has a value and may have a left and/or right child. The tree is represented as follows using indices in level-order traversal (i.e., breadth-first traversal): - The value of the root node is given as an integer. - Each subsequent pair of integers represents the indices of t...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(node_vals, children_indices): if not node_vals: return None nodes = [TreeNode(val) for val in node_vals] child_index_it = iter(childre...
from solution import solve def test_example_case(): n = 5 node_vals = [1, 2, 3, 4, 5] children_indices = [2, 3, -1, -1, 4, 5, -1, -1] assert solve(n, node_vals, children_indices) == 9 def test_single_node(): n = 1 node_vals = [1] children_indices = [-1, -1] assert solve(n, node_vals, c...
[]
[ 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 build_t...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00015655", "row_id": 15655, "seed_ids": "[15726]" }
0.638566
Taco_15655
I
[ "build_tree", "deepest_level_sum", "solve" ]
3
[ [ "solve", "build_tree" ], [ "solve", "deepest_level_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
9dd1c8fee7e750be331e956557f2f38c0ba25b27
9fb069813c2f2a08b8fda6c453faee7d48bea448
v1.0
instruct
Taco
Taco_15672_I
A railway company is planning a maintenance schedule for its tracks. The railway network can be represented as a graph with stations as vertices and tracks as edges. Each track has a length, and the goal is to minimize the total maintenance cost by ensuring all stations remain connected during the maintenance. You are...
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[yroot]...
import pytest from solution import minimum_spanning_tree def test_case_1(): n = 4 m = 5 tracks = [ (1, 2, 4), (1, 3, 3), (2, 3, 1), (2, 4, 2), (3, 4, 5) ] assert minimum_spanning_tree(n, m, tracks) == 6 def test_case_2(): n = 3 m = 3 tracks = [ ...
[ { "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, 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 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 root_x = find(parent, x)\...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00015672", "row_id": 15672, "seed_ids": "[2408]" }
0.7957
Taco_15672
I
[ "find", "union", "krushkal_mst", "minimum_spanning_tree" ]
4
[ [ "krushkal_mst", "find" ], [ "krushkal_mst", "union" ], [ "minimum_spanning_tree", "krushkal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
b3d8fdd5810f83601e18431e7bcfd15881748771
0b62866bad8f63a7d3c513bb6a3110ac10db047f
v1.0
instruct
Taco
Taco_15697_I
Given a directed graph with nodes and edges, your task is to determine if there exists a path from a given start node to a given end node. The graph is represented as an adjacency list. For each pair of start and end nodes provided, output 'YES' if there is a path from the start node to the end node, and 'NO' otherwise...
def has_path(graph, start, end, visited): if start == end: return True visited.add(start) for neighbor in graph.get(start, []): if neighbor not in visited: if has_path(graph, neighbor, end, visited): return True return False def find_paths(graph, queries...
from solution import has_path, find_paths def test_single_path(): graph = { 1: [2], 2: [3], 3: [4] } assert find_paths(graph, [(1, 4)]) == ["YES"] assert find_paths(graph, [(4, 1)]) == ["NO"] def test_multiple_paths(): graph = { 1: [2, 3], 2: [3], 3:...
[ { "docstring": null, "function_declaration": "def has_path(graph, start, end, visited):", "function_name": "has_path", "parameter_list": "(graph, start, end, visited)" }, { "docstring": null, "function_declaration": "def find_paths(graph, queries):", "function_name": "find_paths", ...
[ 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": "def find_path(graph, start, end, visited):\n if start == end:\n return True\n visited.add(start)\n \n for neighbor in graph.get(start, []):\n ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00015697", "row_id": 15697, "seed_ids": "[3328]" }
0.686156
Taco_15697
I
[ "has_path", "find_paths", "main" ]
3
[ [ "find_paths", "has_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
91cda10b5b86d0d2a3a4a34aa8b8e56ba60e64ea
45c94c4f4fb3593786dd1f7b9cd8bb9ebf1b06d1
v1.0
instruct
Taco
Taco_15724_I
The search and rescue team uses a GPS tracking system to mark locations of possible survivors in a disaster site. Each marked point is given in the form (x, y), and the distance from the origin (0, 0) to each point represents how urgent it is to check that point. The closer the point to the origin, the higher the prior...
import heapq from typing import List, Tuple def euclidean_distance(point: Tuple[int, int]) -> float: """ Returns the Euclidean distance of a point from the origin (0, 0). """ return point[0]**2 + point[1]**2 def closest_points(points: List[Tuple[int, int]], K: int) -> List[Tuple[int, int]]: """ ...
def test_closest_points_example(): points = [(1, 2), (2, 2), (3, 3), (-1, -1), (0, 0)] K = 3 assert closest_points(points, K) == [(0, 0), (-1, -1), (1, 2)] def test_closest_points_all_same_distance(): points = [(1, 1), (-1, -1), (1, -1), (-1, 1)] K = 2 assert closest_points(points, K) == [(-1, ...
[ { "docstring": "Returns the Euclidean distance of a point from the origin (0, 0).", "function_declaration": "def euclidean_distance(point):", "function_name": "euclidean_distance", "parameter_list": "(point)" }, { "docstring": "Returns the top K closest points to the origin (0, 0) based on E...
[ 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": "import heapq\nfrom math import sqrt\n\ndef k_closest_points(N, K, coordinates):\n \"\"\"\n Returns the `K` closest points to the origin based on the Euclidea...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00015724", "row_id": 15724, "seed_ids": "[19284]" }
0.71928
Taco_15724
I
[ "euclidean_distance", "closest_points" ]
2
[ [ "closest_points", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
false
[]
true
3437813fa01e7c0f0618d67fbf7a3e3f6e169659
876df1562599ea0eb9c9f9ff577b146b3f9d42f6
v1.0
instruct
Taco
Taco_15725_I
You are given a binary tree and you need to determine if it is height-balanced. A height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1. -----Input----- The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of ...
class TreeNode: def __init__(self, val): self.val = val self.left = None self.right = None def is_balanced(root): def check_height(node): if not node: return 0, True left_height, left_balanced = check_height(node.left) right_height, right_balanced = c...
import pytest from solution import is_balanced_trees def test_is_balanced_trees(): test_cases = [ ([], "YES"), # Empty tree ([(1, 2), (1, 3)], "YES"), # Balanced tree ([(1, 2), (1, 3), (2, 4)], "YES"), # Balanced tree ([(1, 2), (2, 3), (3, 4), (4, 5)], "NO"), # Unbalanced tree ...
[]
[ 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):\n self.val = val\n self.left = None\n self.right = None\n\ndef is_balanced(root):\n def check...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00015725", "row_id": 15725, "seed_ids": "[4]" }
0.736396
Taco_15725
I
[ "is_balanced", "build_tree", "is_balanced_trees" ]
3
[ [ "is_balanced_trees", "build_tree" ], [ "is_balanced_trees", "is_balanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
dc13fe479fc883a8b39aa31336a39d95763900b8
160910ade9e17b42dbc123569b0812728f2f4a10
v1.0
instruct
Taco
Taco_15788_I
In a game, a player collects coins with different values and stores them in a bag. The player has a special rule: if the total value of coins collected has a prime number sum, they receive a bonus. A prime number is defined as a number greater than 1 that has no divisors other than 1 and itself. For example, 2, 3, 5, ...
def is_prime(n): """ Checks if a number n is a prime number. """ 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 ...
from solution import is_sum_prime def test_sum_prime(): assert is_sum_prime([2, 3, 5, 7]) == True assert is_sum_prime([1, 2, 3]) == False assert is_sum_prime([11, 13, 17]) == True assert is_sum_prime([4, 6, 8]) == False assert is_sum_prime([3, 3, 3, 3]) == False assert is_sum_prime([7, 11, 13, ...
[ { "docstring": "Checks if a number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns True if the sum of coin values is a prime number, False otherwise.", "function_declaration": "def is_sum_p...
[ 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 is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00015788", "row_id": 15788, "seed_ids": "[20571]" }
0.620508
Taco_15788
I
[ "is_prime", "is_sum_prime" ]
2
[ [ "is_sum_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8f10ce5aadbbfc0cb950515fd46ecffb81ff8fd1
09161e9b3d301bbd1c27c3eaa9a42bd6c2fe8e8f
v1.0
instruct
Taco
Taco_15846_I
In a galaxy far, far away, a certain planet called Zog has a unique calendar system. Their year consists of `d` days, and a week has `w` days. The residents of Zog want to figure out how the calendar for any given year would look, given the start day of the year. The days of the week on Zog are represented by integers ...
def generate_calendar(d, w, s): """ Generates the Zog calendar as a list of strings, each representing a week. """ calendar = [] week = ['.'] * (s - 1 if s > 1 else 0) for day in range(1, d + 1): week.append(str(day)) if len(week) == w: calendar.append(' '.join(w...
from solution import generate_calendar, print_calendar def test_generate_calendar_example(): d, w, s = 15, 7, 3 expected_output = [ ". . 1 2 3 4 5", "6 7 8 9 10 11 12", "13 14 15 . . . ." ] assert generate_calendar(d, w, s) == expected_output def test_generate_calendar_full_wee...
[ { "docstring": "Generates the Zog calendar as a list of strings, each representing a week.", "function_declaration": "def generate_calendar(d, w, s):", "function_name": "generate_calendar", "parameter_list": "(d, w, s)" }, { "docstring": "Prints the Zog calendar for a given year in the requi...
[ 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 calendar(d, w, s):\n \"\"\"\n Prints the calendar for the given year on planet Zog.\n \n Parameters:\n d (int): The number of days in the year.\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00015846", "row_id": 15846, "seed_ids": "[25353]" }
0.696627
Taco_15846
I
[ "generate_calendar", "print_calendar" ]
2
[ [ "print_calendar", "generate_calendar" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5c8ffa3337de377a0730608b6e27e77f2657e7e3
dd5f4ce9dbb4650ee794e5b2664ed0bee3150e8f
v1.0
instruct
Taco
Taco_15851_I
A company is handling a large number of user requests and wants to improve the efficiency of their request processing system. They decide to prioritize certain requests based on multiple criteria. To aid in this task, they use a specific algorithm. The company receives a list of requests, each characterized by two int...
def sort_requests(requests): """ Sorts requests first by priority in descending order, then by duration in ascending order. Args: requests (list of tuple): List of tuples where each tuple contains (priority, duration) Returns: list of tuple: Sorted list of requests """ return s...
from solution import sort_requests, process_requests def test_sort_requests(): assert sort_requests([(1, 5), (2, 2), (2, 1)]) == [(2, 1), (2, 2), (1, 5)] assert sort_requests([(3, 4), (4, 1), (4, 3), (2, 2)]) == [(4, 1), (4, 3), (3, 4), (2, 2)] assert sort_requests([(2, 2), (2, 3), (2, 1), (3, 2)]) == [(3,...
[ { "docstring": "Sorts requests first by priority in descending order, then by duration in ascending order.\n\nArgs:\nrequests (list of tuple): List of tuples where each tuple contains (priority, duration)\n\nReturns:\nlist of tuple: Sorted list of requests", "function_declaration": "def sort_requests(reques...
[ 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 sort_requests(requests):\n \"\"\"\n Sort the list of requests by priority (descending) and duration (ascending).\n \n :param requests: List of tupl...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00015851", "row_id": 15851, "seed_ids": "[7854]" }
0.579504
Taco_15851
I
[ "sort_requests", "process_requests" ]
2
[ [ "process_requests", "sort_requests" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fb63aa72a0bd4dbff962fa93f598da2f0c9b51f9
19dfbfc4e3705a91c70ef5fa88508b105d47d0c3
v1.0
instruct
Taco
Taco_15870_I
A company wants to analyze the sales patterns of its products over several months. Each product has monthly sales data represented as a sequence of integers. They want to detect trends in the sales data such as increasing, decreasing, or fluctuating patterns. Write a program that determines the trend pattern for each p...
def determine_trend(sales_data): """ Determines the trend of sales data. Parameters: sales_data (list of int): List of sales data across months Returns: str: The trend of the sales data ('increasing', 'decreasing', 'fluctuating') """ increasing = all(earlier < later for earlier...
def test_determine_trend(): assert determine_trend([10, 20, 30, 40, 50]) == "increasing" assert determine_trend([50, 40, 30, 20, 10]) == "decreasing" assert determine_trend([10, 20, 20, 30, 40]) == "fluctuating" assert determine_trend([20, 15, 10, 5]) == "decreasing" assert determine_trend([1, 2, 3,...
[ { "docstring": "Determines the trend of sales data.\n\nParameters:\nsales_data (list of int): List of sales data across months\n\nReturns:\nstr: The trend of the sales data ('increasing', 'decreasing', 'fluctuating')", "function_declaration": "def determine_trend(sales_data):", "function_name": "determi...
[ 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 detect_trend(sales_data):\n trends = []\n for data in sales_data:\n months = data[0]\n sales = data[1:]\n \n is_increasing = ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00015870", "row_id": 15870, "seed_ids": "[2552]" }
0.558731
Taco_15870
I
[ "determine_trend", "analyze_sales_data" ]
2
[ [ "analyze_sales_data", "determine_trend" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2b8a41bc3dd6a872e3c635b6e6347a25a48398bb
b738f3e1c658c9a33b122524875107848c5f3980
v1.0
instruct
Taco
Taco_15872_I
John is an avid reader who loves to maintain a balanced reading routine. He likes to read one book at a time, start to finish, without leaving any pages unread. However, he has a peculiar habit: he reads books such that the total number of pages he reads in a session should be a perfect square number. Given a stack of...
import math def is_perfect_square(x): """ Helper function to determine if a number is a perfect square. """ if x < 0: return False root = int(math.isqrt(x)) return root * root == x def can_read_perfect_square_pages(T, test_cases): """ Function to determine if there exists a gro...
from solution import can_read_perfect_square_pages def test_single_case_perfect_square(): assert can_read_perfect_square_pages(1, [(5, [4, 16, 20, 1, 25])]) == ["Yes"] def test_single_case_no_perfect_square(): assert can_read_perfect_square_pages(1, [(3, [2, 8, 10])]) == ["No"] def test_multiple_cases_mixed_...
[ { "docstring": "Helper function to determine if a number is a perfect square.", "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_square", "parameter_list": "(x)" }, { "docstring": "Function to determine if there exists a group of consecutive books whose total...
[ 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\n\ndef is_perfect_square(x):\n s = int(math.sqrt(x))\n return s * s == x\n\ndef find_consecutive_books_with_perfect_square_pages(T, test_cases):\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00015872", "row_id": 15872, "seed_ids": "[9198]" }
0.712358
Taco_15872
I
[ "is_perfect_square", "can_read_perfect_square_pages" ]
2
[ [ "can_read_perfect_square_pages", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d590d89296712d32f16e9c730a80df67553bed7d
4f31ba834e401b40183513219fe5a6ed123390e5
v1.0
instruct
Taco
Taco_15900_I
You are given an array A of integers of length N. Your task is to find the number of "special pairs" in the array. A pair (i, j) is considered special if and only if i < j and A[i] * A[j] is a perfect square. (Note: A perfect square is an integer that is the square of an integer. For example, 1, 4, 9, 16, and 25 are p...
import math def is_perfect_square(x): s = int(math.sqrt(x)) return s * s == x def count_special_pairs(A): n = len(A) special_pairs_count = 0 for i in range(n): for j in range(i + 1, n): if is_perfect_square(A[i] * A[j]): special_pairs_count += 1 return speci...
from solution import count_special_pairs, is_perfect_square import math def test_is_perfect_square(): assert is_perfect_square(1) == True assert is_perfect_square(4) == True assert is_perfect_square(9) == True assert is_perfect_square(2) == False assert is_perfect_square(10) == False def test_coun...
[ { "docstring": null, "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_square", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def count_special_pairs(A):", "function_name": "count_special_pairs", "parameter_list": "(A)" ...
[ 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 count_special_pairs(arr):\n \"\"\"\n This function takes an array of integers and returns the count of \"special pairs\".\n A special pair is defined ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00015900", "row_id": 15900, "seed_ids": "[24023]" }
0.701017
Taco_15900
I
[ "is_perfect_square", "count_special_pairs" ]
2
[ [ "count_special_pairs", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f55af8f0491cc3cfbbcfeaaaec4cd82b9207e343
3411f09511ad0ccd1952b807e8b9b4445ecc692e
v1.0
instruct
Taco
Taco_15905_I
Parsa and Ali have a large matrix of size $n \times m$. Each cell of this matrix contains a positive integer. They want to achieve the highest score possible by moving from the top-left corner of the matrix to the bottom-right corner, following these rules: 1. They can only move right or down at each step. 2. They wa...
def max_path_sum(matrix): n = len(matrix) m = len(matrix[0]) dp = [[0] * m for _ in range(n)] dp[0][0] = matrix[0][0] for i in range(1, n): dp[i][0] = dp[i-1][0] + matrix[i][0] for j in range(1, m): dp[0][j] = dp[0][j-1] + matrix[0][j] for i in range(1, n): fo...
from solution import max_path_sum, solve, parse_input def test_max_path_sum(): assert max_path_sum([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 29 assert max_path_sum([[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 7 assert max_path_sum([[1]]) == 1 assert max_path_sum([[1, 2], [1, 1]]) == 4 def ...
[ { "docstring": null, "function_declaration": "def max_path_sum(matrix):", "function_name": "max_path_sum", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", "parameter_list": "(test_cases)" }, { ...
[ 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 max_path_sum_in_matrix(matrix):\n n = len(matrix)\n m = len(matrix[0])\n \n # Create a DP table with the same dimensions as the matrix\n dp = [[...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00015905", "row_id": 15905, "seed_ids": "[7107]" }
0.724493
Taco_15905
I
[ "max_path_sum", "solve", "parse_input", "main" ]
4
[ [ "solve", "max_path_sum" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
5ef7cc84982f470a0c6c4277e4f3727cec81e515
7288752310d8a079fa0e9a3651a3663260b38dab
v1.0
instruct
Taco
Taco_15953_I
A group of researchers are studying the migration patterns of birds across a region represented as a 2D plane. They have recorded the positions of n birds at time t_0 and time t_1. Your task is to determine whether the birds have formed any clusters at the end of the observation period. A cluster is defined as a subse...
import math def find_clusters(n, k, d, positions_t1): def distance(p1, p2): return math.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2) def dfs(node, visited, positions, threshold): stack = [node] cluster = [] while stack: curr = stack.pop() if not vis...
from solution import is_cluster def test_cluster_1(): n = 5 k = 3 d = 10 positions_t0 = [(0, 0), (10, 0), (0, 10), (10, 10), (20, 20)] positions_t1 = [(1, 1), (2, 2), (3, 3), (4, 4), (50, 50)] result = is_cluster(n, k, d, positions_t0, positions_t1) assert result == "YES" def test_cluster_...
[ { "docstring": null, "function_declaration": "def find_clusters(n, k, d, positions_t1):", "function_name": "find_clusters", "parameter_list": "(n, k, d, positions_t1)" }, { "docstring": null, "function_declaration": "def is_cluster(n, k, d, positions_t0, positions_t1):", "function_na...
[ 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 distance(p1, p2):\n \"\"\"\n Calculate the Euclidean distance between two points p1 and p2.\n \"\"\"\n return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00015953", "row_id": 15953, "seed_ids": "[20358]" }
0.633709
Taco_15953
I
[ "find_clusters", "is_cluster" ]
2
[ [ "is_cluster", "find_clusters" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ecf132b6ab30d46cfdadd11539b8f1e9010d3e0f
e3cd0ff542c0984b7ae18c5297ca6b1753b4d268
v1.0
instruct
Taco
Taco_15969_I
Given a list of integers, you need to determine the sum of all the prime numbers present in the list. ------ Input ------ The input will start with an integer T, the number of test cases. For each test case, the input will consist of a single line with space-separated integers representing the list. ------ Output --...
def is_prime(n): """ Checks if a number n 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 return True def sum_of_primes(numbers): "...
from solution import is_prime, sum_of_primes, 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(17) == True assert is_prime(18) == False assert is_prime(-5) == False assert is_prime(0) == False asser...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the list.", "function_declaration": "def sum_of_primes(numbers):", "function_na...
[ 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 \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00015969", "row_id": 15969, "seed_ids": "[6579]" }
0.669266
Taco_15969
I
[ "is_prime", "sum_of_primes", "process_test_cases" ]
3
[ [ "process_test_cases", "sum_of_primes" ], [ "sum_of_primes", "is_prime" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
3b8e3fc6785cc4eed833af1161d91538fc0d2cbf
15e4c66ca26094a3049885cbcc584a741c201680
v1.0
instruct
Taco
Taco_15990_I
You are asked to design a logistics system for delivering packages. Each package has to be delivered to a specific destination within a predetermined time limit. Each destination can be reached directly from other destinations, but the travel time between destinations can vary. The main goal is to determine whether all...
import sys import heapq def dijkstra(graph, start, D): """ Performs Dijkstra's algorithm to find the shortest path from start to all other nodes in the graph. :param graph: Dictionary representation of graph where key is node and value is list of tuples (neighbor, travel time) ...
def test_example1(): D = 5 E = 5 connections = [(1, 2, 3), (1, 3, 5), (2, 4, 2), (3, 5, 2), (4, 5, 3)] P = 3 packages = [(1, 4, 5), (2, 5, 6), (1, 5, 8)] assert can_deliver_all_packages(D, E, connections, P, packages) == "YES" def test_example2(): D = 4 E = 4 connections = [(1, ...
[ { "docstring": "Performs Dijkstra's algorithm to find the shortest path from start to \nall other nodes in the graph.\n\n:param graph: Dictionary representation of graph where key is node and \n value is list of tuples (neighbor, travel time)\n:param start: Starting node for Dijkstra's algorithm\n:...
[ 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\nimport heapq\n\ndef dijkstra(graph, start, D):\n \"\"\"\n Performs Dijkstra's algorithm to find the shortest path from start to \n all other n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00015990", "row_id": 15990, "seed_ids": "[4336]" }
0.691529
Taco_15990
I
[ "dijkstra", "can_deliver_all_packages" ]
2
[ [ "can_deliver_all_packages", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
8a4290202bce172af8c13cf47bf7d18167c90652
502339cae0cb84695379148e80a4f8d0834619fe
v1.0
instruct
Taco
Taco_16074_I
**Sum of range multiplication** Debra loves playing with numbers and is currently fascinated by the concept of multiplication of numbers within a given range. She has come up with a game where she multiplies all numbers within a certain range and checks if they form a prime number. However, Debra needs your help to v...
def is_prime(n): """ Helper function to check if a number is prime """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def is_prime_product(a, b): """ Given a range [a, b], multiply all numbers between a and b (incl...
from solution import is_prime_product def test_is_prime_product_prime(): assert is_prime_product(3, 3) == "Prime" # 3 is prime assert is_prime_product(7, 7) == "Prime" # 7 is prime def test_is_prime_product_not_prime(): assert is_prime_product(2, 3) == "Not prime" # 2 * 3 = 6, not prime assert is_p...
[ { "docstring": "Helper function to check if a number is prime ", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given a range [a, b], multiply all numbers between a and b (inclusive) and determine if the resulting product i...
[ 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 \"\"\" Helper function to check if a number is prime \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00016074", "row_id": 16074, "seed_ids": "[10169]" }
0.685105
Taco_16074
I
[ "is_prime", "is_prime_product" ]
2
[ [ "is_prime_product", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8a4be75f073ca7d77148a72f9dc4bf36ae351a54
7cd7f21009bb06ba4b075ffd695f05ee4b3c681c
v1.0
instruct
Taco
Taco_16171_I
The kingdom of Primeville is building a new reservoir to supply water to the entire nation. The design of the reservoir consists of multiple tanks connected by pipes. To ensure a proper and efficient water distribution system, the engineers must determine the best order of filling these tanks. Each tank i (1 ≤ i ≤ n)...
from collections import deque, defaultdict def fill_tanks(n, m, tank_data, dependencies): # Parse tank capacities and requirements capacities = [0] * n requirements = [0] * n for i in range(n): capacities[i], requirements[i] = tank_data[i] # Create adjacency list and indegree arra...
def test_no_cycles(): n = 4 m = 2 tank_data = [(10, 4), (8, 5), (6, 2), (7, 3)] dependencies = [(1, 2), (3, 4)] min_deps, fill_order = fill_tanks(n, m, tank_data, dependencies) assert min_deps == 0 assert set(fill_order) == {1, 2, 3, 4} def test_with_cycles(): n = 3 m = 3 ...
[ { "docstring": null, "function_declaration": "def fill_tanks(n, m, tank_data, dependencies):", "function_name": "fill_tanks", "parameter_list": "(n, m, tank_data, dependencies)" }, { "docstring": null, "function_declaration": "def optimal_tank_fill_sequence(n, m, tank_data, dependencies)...
[ 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 find_filling_order(n, m, capacities, requirements, dependencies):\n from collections import deque, defaultdict\n \n # Create graph and indegree list t...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00016171", "row_id": 16171, "seed_ids": "[24919]" }
0.621149
Taco_16171
I
[ "fill_tanks", "optimal_tank_fill_sequence" ]
2
[ [ "optimal_tank_fill_sequence", "fill_tanks" ] ]
1
[]
false
[]
false
pytest
false
[]
true
733e5bb7242122c8a2ff406032e91b8c6a410d90
d7738f606618585a733f7081a1633d0d3082c0bf
v1.0
instruct
Taco
Taco_16202_I
The city traffic management system wants to improve the efficiency of traffic lights at multiple intersections. They have a plan to synchronize lights based on traffic flow patterns. For a given set of traffic light durations at multiple intersections, they want to ensure that the lights switch at the same time as ofte...
from math import gcd from functools import reduce def lcm(a, b): """ Calculate the Least Common Multiple (LCM) of two numbers. """ return a * b // gcd(a, b) def find_synchronized_duration(durations): """ Given a list of traffic light durations, find the smallest duration that synchronizes all ...
from solution import main def test_example_1(): assert main(3, [6, 8, 12]) == 24 def test_example_2(): assert main(2, [4, 5]) == 20 def test_example_3(): assert main(4, [2, 3, 7, 11]) == 462 def test_single_duration(): assert main(1, [5]) == 5 def test_same_durations(): assert main(3, [5, 5, 5]...
[ { "docstring": "Calculate the Least Common Multiple (LCM) of two numbers.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Given a list of traffic light durations, find the smallest duration that synchronizes all traffic lights...
[ 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 gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\ndef synchronize_lights(durations):\n n =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016202", "row_id": 16202, "seed_ids": "[9905]" }
0.617074
Taco_16202
I
[ "lcm", "find_synchronized_duration", "main" ]
3
[ [ "find_synchronized_duration", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b1cc6f11fac5b498b947a64ec01473100fecb323
bf5410d475710238aa2743427866acbc3ea59173
v1.0
instruct
Taco
Taco_16281_I
You are given a connected undirected graph with `n` vertices and `m` edges. Each vertex has a unique ID ranging from 1 to n. Your task is to determine whether it's possible to color the graph using exactly `k` distinct colors such that no two adjacent vertices share the same color. If such a coloring is possible, outp...
def is_valid_coloring(graph, colors, v, c): for i in range(len(graph)): if graph[v][i] == 1 and colors[i] == c: return False return True def graph_coloring_util(graph, m, colors, v, k): if v == m: return True for c in range(1, k + 1): if is_valid_coloring(graph,...
from solution import graph_coloring def test_graph_coloring_possible_3_colors(): n, m, k = 3, 3, 3 edges = [(1, 2), (2, 3), (3, 1)] result = graph_coloring(n, m, k, edges) assert result != -1 assert len(set(result)) == 3 def test_graph_coloring_possible_3_colors_5_vertices(): n, m, k = 5, 4, 3...
[ { "docstring": null, "function_declaration": "def is_valid_coloring(graph, colors, v, c):", "function_name": "is_valid_coloring", "parameter_list": "(graph, colors, v, c)" }, { "docstring": null, "function_declaration": "def graph_coloring_util(graph, m, colors, v, k):", "function_na...
[ 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 graph_coloring(n, m, k, edges):\n def is_valid(vertex, color):\n for neighbor in adj[vertex]:\n if colors[neighbor] == color:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016281", "row_id": 16281, "seed_ids": "[19908]" }
0.639553
Taco_16281
I
[ "is_valid_coloring", "graph_coloring_util", "graph_coloring" ]
3
[ [ "graph_coloring", "graph_coloring_util" ], [ "graph_coloring_util", "is_valid_coloring" ] ]
2
[]
false
[]
false
pytest
true
[]
true
bd6eff5be81ef9f6532a82aeb983ff573f393e1b
1efbba15176b656b71886471b1340eca20d5f027
v1.0
instruct
Taco
Taco_16296_I
Johnny is learning about prime numbers and their properties. He recently discovered that any positive integer greater than 1 either is a prime number or can be factored into prime numbers. He wants to write a program that takes an integer n as input and returns the list of prime numbers up to and including n. However, ...
def is_prime(num): """ Determines if a number is prime. Args: num (int): Number to check for primality. Returns: bool: True if num is prime, False otherwise. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: retur...
from solution import is_prime, prime_numbers_up_to_n 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(6) == False assert is_prime(7) == True assert is_prime(10) == False def test_prime_numbers_...
[ { "docstring": "Determines if a number is prime.\nArgs:\nnum (int): Number to check for primality.\n\nReturns:\nbool: True if num is prime, False otherwise.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Generates a l...
[ 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 Helper function to determine if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00016296", "row_id": 16296, "seed_ids": "[2072]" }
0.658172
Taco_16296
I
[ "is_prime", "prime_numbers_up_to_n" ]
2
[ [ "prime_numbers_up_to_n", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
910c1b043c70ae41179b79e0a24c6b94798a435e
6947892ad0c93ac07ee96c3e2c65b75f2016e1c9
v1.0
instruct
Taco
Taco_16331_I
In an ancient village, there are n houses and n-1 bidirectional roads such that there is a unique path between any two houses. Each house has a specific amount of gold stored in it which is represented by an array gold[] of size n, where gold[i] indicates the amount of gold at the i-th house. The village head assigns ...
from collections import defaultdict, deque def preprocess_tree(n, roads): adj_list = defaultdict(list) for u, v in roads: adj_list[u].append(v) adj_list[v].append(u) return adj_list def bfs_shortest_path(adj_list, n, start, end): visited = [False] * (n + 1) parent = [-1] * (n + 1) ...
def test_max_gold_on_shortest_path(): n = 5 q = 3 roads = [ (1, 2), (1, 3), (2, 4), (2, 5) ] gold = [10, 20, 15, 25, 30] queries = [ (2, 3, 4), (1, 5, 3), (3, 4, 2) ] expected_output = [20, 30, 25] assert max_gold_on_shorte...
[ { "docstring": null, "function_declaration": "def preprocess_tree(n, roads):", "function_name": "preprocess_tree", "parameter_list": "(n, roads)" }, { "docstring": null, "function_declaration": "def bfs_shortest_path(adj_list, n, start, end):", "function_name": "bfs_shortest_path", ...
[ 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 collections import defaultdict, deque\n\ndef bfs(tree, start, n):\n \"\"\"\n Perform BFS to find the max gold in the shortest path\n \"\"\"\n visi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016331", "row_id": 16331, "seed_ids": "[8609]" }
0.754262
Taco_16331
I
[ "preprocess_tree", "bfs_shortest_path", "build_subtree_gold", "max_gold_on_shortest_path" ]
4
[ [ "max_gold_on_shortest_path", "bfs_shortest_path" ], [ "max_gold_on_shortest_path", "build_subtree_gold" ], [ "max_gold_on_shortest_path", "preprocess_tree" ] ]
3
[]
false
[]
false
pytest
false
[]
true
b7f881f0db4a4e903ec48c65662ddb35adc24d9b
ae6047fea0f89c1c6adf61cb3a6bbf4b1373bba2
v1.0
instruct
Taco
Taco_16333_I
A matrix \(A\) of size \(n \times m\) contains non-negative integers. A submatrix of \(A\) is any matrix that can be obtained by deleting some (possibly zero) rows and some (possibly zero) columns from \(A\), but leaving at least one row and one column. Define the sum of a submatrix as the sum of all elements in the s...
def max_sum_submatrix(matrix): """ Returns the maximum sum of elements of any submatrix of the given matrix. """ n = len(matrix) m = len(matrix[0]) # To keep track of maximum sum submatrix max_sum = float('-inf') # Loop through each column as the start column for left in range(m): ...
def test_max_sum_submatrix_single_element(): matrix = [[1]] assert max_sum_submatrix(matrix) == 1 def test_max_sum_submatrix_entire_matrix(): matrix = [ [1, 2, 3], [4, 5, 6] ] assert max_sum_submatrix(matrix) == 21 def test_max_sum_submatrix_mixed_values(): matrix = [ [...
[ { "docstring": "Returns the maximum sum of elements of any submatrix of the given matrix.", "function_declaration": "def max_sum_submatrix(matrix):", "function_name": "max_sum_submatrix", "parameter_list": "(matrix)" }, { "docstring": "Helper function to find maximum sum subarray using Kadan...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_submatrix_sum(matrix):\n \"\"\"\n Calculate the maximum sum of any submatrix in a given matrix.\n \n Parameters:\n matrix (List[List[int]]):...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00016333", "row_id": 16333, "seed_ids": "[21360]" }
0.620254
Taco_16333
I
[ "max_sum_submatrix", "kadane" ]
2
[ [ "max_sum_submatrix", "kadane" ] ]
1
[]
false
[]
false
pytest
false
[]
true
bcccfc0ff9315d65c3c70bb996428ed27415fe51
8a3b86c140acbc223546f22f8581b86b07abbc3e
v1.0
instruct
Taco
Taco_16377_I
Tina is working on a scheduling algorithm for her company's tasks. Each task has a specific start and end time, and Tina needs to calculate the maximum number of non-overlapping tasks that can be scheduled. Write a program to help Tina maximize the number of tasks she can schedule without any of them overlapping. ---...
def max_non_overlapping_tasks(tasks): """ Returns the maximum number of non-overlapping tasks that can be scheduled. """ # Sort the tasks based on end times tasks.sort(key=lambda x: x[1]) count = 0 last_end_time = 0 for start, end in tasks: if start >= last_end_time: ...
from solution import max_non_overlapping_tasks, scheduling_algorithm def test_max_non_overlapping_tasks(): assert max_non_overlapping_tasks([(1, 2), (2, 3), (3, 4)]) == 3 assert max_non_overlapping_tasks([(1, 3), (2, 4), (3, 5), (6, 8)]) == 3 assert max_non_overlapping_tasks([(1, 5), (2, 3), (4, 6), (7, 8)...
[ { "docstring": "Returns the maximum number of non-overlapping tasks that can be scheduled.", "function_declaration": "def max_non_overlapping_tasks(tasks):", "function_name": "max_non_overlapping_tasks", "parameter_list": "(tasks)" }, { "docstring": null, "function_declaration": "def sch...
[ 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_non_overlapping_tasks(tasks):\n tasks = sorted(tasks, key=lambda x: x[1]) # Sort tasks by end time\n count = 0\n last_end_time = 0\n \n for...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016377", "row_id": 16377, "seed_ids": "[16765]" }
0.677689
Taco_16377
I
[ "max_non_overlapping_tasks", "scheduling_algorithm" ]
2
[ [ "scheduling_algorithm", "max_non_overlapping_tasks" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6b6ed7b2c0c8000cec175b3dfa5c68643bd066ab
5780cf4063bc213b4c1655e5e964a9bd8020b749
v1.0
instruct
Taco
Taco_16405_I
A company is developing a file system simulation. The file system has a hierarchical structure where each folder can contain files and subfolders. Each file has a certain size associated with it, while folders don't have sizes but instead contain the sizes of all files and subfolders recursively inside them. We need to...
def parse_file_system(file_system_str): lines = file_system_str.strip().split("\n") file_system = {} current_path = [] for line in lines: indent_level = (len(line) - len(line.lstrip())) // 2 line = line.strip() if line.endswith("/"): # It's a folder ...
import pytest from solution import file_system_size_queries def test_file_system_size_queries_basic(): file_system = """folderA/ file1.ext 50 file2.ext 30 subfolderA/ file3.ext 20 subfolderB/ file4.ext 10""" queries = ["folderA/", "folderA/subfolderA/"] result = file_system_size_queries...
[ { "docstring": null, "function_declaration": "def parse_file_system(file_system_str):", "function_name": "parse_file_system", "parameter_list": "(file_system_str)" }, { "docstring": null, "function_declaration": "def calculate_folder_size(file_system, folder_path):", "function_name":...
[ 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 parse_file_system(file_system_str):\n lines = file_system_str.strip().split(\"\\n\")\n file_system = {}\n current_path = []\n \n for line in lin...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00016405", "row_id": 16405, "seed_ids": "[19136]" }
0.646039
Taco_16405
I
[ "parse_file_system", "calculate_folder_size", "file_system_size_queries" ]
3
[ [ "file_system_size_queries", "calculate_folder_size" ], [ "file_system_size_queries", "parse_file_system" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e5f2ccddfc3e04218e50ca9c15624a2f68cfef86
3254034370dddb0184094720af5bcff6e3badc61
v1.0
instruct
Taco
Taco_16420_I
You are a game developer working on a puzzle game where players can form different types of shapes using square tiles. One of the shapes that players can create is a rectangle. However, you want to implement a feature that detects only the largest rectangle that consists of `1`s in a given 2D grid of `0`s and `1`s. To ...
def maximalRectangle(matrix): if not matrix or not matrix[0]: return 0 max_area = 0 dp = [0] * len(matrix[0]) for row in matrix: for idx, val in enumerate(row): dp[idx] = dp[idx] + 1 if val == '1' else 0 max_area = max(max_area, largestRectangleArea(dp)) ...
from solution import maximalRectangle def test_maximalRectangle(): matrix = [ ['1', '0', '1', '0', '0'], ['1', '0', '1', '1', '1'], ['1', '1', '1', '1', '1'], ['1', '0', '0', '1', '0'] ] assert maximalRectangle(matrix) == 6 matrix = [ ['0', '0', '0'], ['...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "paramete...
[ 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 or not matrix[0]:\n return 0\n \n max_area = 0\n dp = [0] * len(matrix[0])\n \n for row in m...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00016420", "row_id": 16420, "seed_ids": "[23361]" }
0.704341
Taco_16420
I
[ "maximalRectangle", "largestRectangleArea" ]
2
[ [ "maximalRectangle", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
true
[]
true
665ed1da737cf54e7a5336a57a7e9481b2c34585
a6d22d4c8b7bbb2ce75f83f0526b42527582076a
v1.0
instruct
Taco
Taco_16423_I
There are M programmers participating in a coding contest. Each programmer works on a certain number of problems, but there could be some problems that remain unsolved by anyone. Your task is to identify the number of such unsolved problems. -----Constraints----- - All values in input are integers. - 1 \leq M \leq 100...
def count_unsolved_problems(M, P, programmers): solved_problems = set() for programmer in programmers: problems = programmer[1] solved_problems.update(problems) unsolved_problems = P - len(solved_problems) return unsolved_problems def read_input_and_count_unsolved(): impor...
def test_count_unsolved_problems_case1(): M = 3 P = 5 programmers = [ (2, [1, 3]), (2, [2, 3]), (1, [5]) ] assert count_unsolved_problems(M, P, programmers) == 1 # Problem 4 is unsolved def test_count_unsolved_problems_all_solved(): M = 3 P = 5 programmers = [ ...
[ { "docstring": null, "function_declaration": "def count_unsolved_problems(M, P, programmers):", "function_name": "count_unsolved_problems", "parameter_list": "(M, P, programmers)" }, { "docstring": null, "function_declaration": "def read_input_and_count_unsolved():", "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 count_unsolved_problems(M, P, programmers):\n \"\"\"\n Returns the number of problems that remain unsolved by anyone.\n\n :param M: Number of programm...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00016423", "row_id": 16423, "seed_ids": "[19865]" }
0.713232
Taco_16423
I
[ "count_unsolved_problems", "read_input_and_count_unsolved" ]
2
[ [ "read_input_and_count_unsolved", "count_unsolved_problems" ] ]
1
[]
false
[]
false
pytest
false
[]
true
05c55ee9bebffe035227a05bf94daf3e98f41a05
d7bde879756c34b930b91a7decebcb3c45842d95
v1.0
instruct
Taco
Taco_16439_I
You are a newly appointed architect of a futuristic city, Neoterica. As part of an infrastructure project, you are responsible for laying down a series of roads that connect various pivotal locations throughout the city. The city has a total of $N$ locations, and you are provided with $M$ potential roads that could be ...
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]: p...
from solution import min_cost_and_length_to_connect_locations def test_example(): assert min_cost_and_length_to_connect_locations(4, 5, [(1, 2, 4), (1, 3, 1), (1, 4, 3), (2, 3, 2), (3, 4, 5)]) == 6 def test_single_edge(): assert min_cost_and_length_to_connect_locations(2, 1, [(1, 2, 10)]) == 10 def test_mult...
[ { "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, 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": "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_4
{ "original_instruction": "", "prompt_id": "00016439", "row_id": 16439, "seed_ids": "[16417]" }
0.766337
Taco_16439
I
[ "find", "union", "min_cost_and_length_to_connect_locations" ]
3
[ [ "min_cost_and_length_to_connect_locations", "find" ], [ "min_cost_and_length_to_connect_locations", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8ca077e5ecab374849b6d5684eff4cc9c2437f71
37dd120e77e07a1b2a3e9fc506be741641dc0630
v1.0
instruct
Taco
Taco_16495_I
Given an input string representation of the inorder and postorder traversal of a binary tree, reconstruct the original binary tree and return its root. The input consists of two parts: 1. An inorder traversal of the tree (comma-separated values). 2. A postorder traversal of the tree (comma-separated values). These two...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def buildTreeFromInorderPostorder(inorder, postorder): if not inorder: return None root_val = postorder.pop() root = TreeNode(root_val) inorder_index...
from solution import reconstructTree, treeToList, TreeNode def test_example1(): s = "9,3,15,20,7 9,15,7,20,3" expected_output = [3, 9, 20, None, None, 15, 7] root = reconstructTree(s) assert treeToList(root) == expected_output def test_example2(): s = "2,1,3 2,3,1" expected_output = [1, 2, 3] ...
[]
[ 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": "# Definition for a binary tree node.\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00016495", "row_id": 16495, "seed_ids": "[8582]" }
0.571285
Taco_16495
I
[ "buildTreeFromInorderPostorder", "reconstructTree", "treeToList" ]
3
[ [ "reconstructTree", "buildTreeFromInorderPostorder" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
734df262d63f59f45c545b840039bee424dd4760
d9ba0807e424f79ccb0382c7ebfffc3b31556cad
v1.0
instruct
Taco
Taco_16522_I
Anna is building a file storage system for a small startup. Each file in the system can be identified by a unique ID and is stored in memory as a binary tree, where each node represents a chunk of data. Each chunk has an integer value, representing the size of data it holds. Anna wants to implement an algorithm to al...
class TreeNode: def __init__(self, node_id, data_size): self.node_id = node_id self.data_size = data_size self.children = [] def build_tree(n, edges, data_sizes): nodes = {i + 1: TreeNode(i + 1, data_sizes[i]) for i in range(n)} for parent_id, child_id in edges: nodes[p...
def test_calculate_subtree_data_sum(): assert calculate_subtree_data_sum(7, [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7)], [10, 5, 15, 2, 3, 20, 25], 2) == 10 assert calculate_subtree_data_sum(7, [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7)], [10, 5, 15, 2, 3, 20, 25], 3) == 60 assert calculate_subtre...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, node_id, data_size):\n self.node_id = node_id\n self.data_size = data_size\n self.children = []\n\ndef...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00016522", "row_id": 16522, "seed_ids": "[11775]" }
0.616691
Taco_16522
I
[ "build_tree", "subtree_sum", "calculate_subtree_data_sum" ]
3
[ [ "calculate_subtree_data_sum", "build_tree" ], [ "calculate_subtree_data_sum", "subtree_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
043afe83b70e6be47cf2d2b5bb2fd224880744e1
9f6294a28e93cca9644cd21132da569ee852167f
v1.0
instruct
Taco
Taco_16588_I
A city has a rectangular grid of $N$ x $M$ intersections. Each intersection can be either a building (represented by 1) or an empty space (represented by 0). The city wants to construct a rectangular park in the empty space on the grid. The park cannot include any intersections with buildings. Help the city determine t...
def largestRectangleArea(heights): stack = [] max_area = 0 heights.append(0) # Sentinel to pop all remaining elements in stack for i in range(len(heights)): while stack and heights[stack[-1]] > heights[i]: h = heights[stack.pop()] w = i if not stack else i - stack[-1] - ...
from solution import maxRectangle def test_sample_input(): grid = [ [1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 0], [0, 1, 1, 1, 0] ] assert maxRectangle(grid) == 6 def test_all_zeros(): grid = [ [0, 0, 0], [0, 0, 0], [0, 0, 0] ] asser...
[ { "docstring": null, "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "parameter_list": "(heights)" }, { "docstring": null, "function_declaration": "def maxRectangle(grid):", "function_name": "maxRectangle", "parameter_list": ...
[ 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 largest_rectangle_area(heights):\n stack = []\n max_area = 0\n index = 0\n \n while index < len(heights):\n if not stack or heights[stack...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016588", "row_id": 16588, "seed_ids": "[4380]" }
0.636127
Taco_16588
I
[ "largestRectangleArea", "maxRectangle" ]
2
[ [ "maxRectangle", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4a40a8b349cba5a575eb66727c2e77ddcd175e07
28fd53163ea542a3f82d55a9061529197cd199cf
v1.0
instruct
Taco
Taco_16597_I
You are given an integer array $a_1, a_2, \ldots, a_n$ and an integer $p$. In one step you can either: - Choose any element $a_i$ and increase $a_i$ to the smallest power of $p$ that is greater than or equal to $a_i$. - Or choose two indices $i$ and $j$ such that $a_i \ge a_j$ and switch their values (make $a_i = a_j...
import math def next_power_of_p(x, p): """ Calculate the smallest power of p greater than or equal to x. """ power = 0 while p ** power < x: power += 1 return p ** power def min_steps_to_powers(arr, p): """ Calculate the minimum number of steps required to make all elements in ...
def test_next_power_of_p(): assert next_power_of_p(5, 2) == 8 assert next_power_of_p(9, 2) == 16 assert next_power_of_p(1, 3) == 1 assert next_power_of_p(10, 3) == 27 assert next_power_of_p(25, 5) == 25 assert next_power_of_p(26, 5) == 125 assert next_power_of_p(100, 5) == 125 def test_min_...
[ { "docstring": "Calculate the smallest power of p greater than or equal to x.", "function_declaration": "def next_power_of_p(x, p):", "function_name": "next_power_of_p", "parameter_list": "(x, p)" }, { "docstring": "Calculate the minimum number of steps required to make all elements in the l...
[ 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\n\ndef min_steps_to_powers(t, test_cases):\n results = []\n \n for i in range(t):\n n, p = test_cases[i][0]\n a = test_cases[i][...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016597", "row_id": 16597, "seed_ids": "[24761]" }
0.688104
Taco_16597
I
[ "next_power_of_p", "min_steps_to_powers", "process_test_cases" ]
3
[ [ "min_steps_to_powers", "next_power_of_p" ], [ "process_test_cases", "min_steps_to_powers" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
false
[]
true
f4287363ccb5219895aa5d4de8d308f7e6b9b163
063ba0a91ae9e3659d298015f06b8b7c0be003f3
v1.0
instruct
Taco
Taco_16628_I
Pam is analyzing different ways to compress strings, and she has come up with two different methods. The first method, method A, compresses a string by replacing each sequence of the same character with that character followed by the count of that sequence (for example, `"aaabb"` becomes `"a3b2"`). The second method, m...
def compress_method_a(s): """ Compress the string using method A. """ if not s: return "" compressed = [] count = 1 for i in range(1, len(s)): if s[i] == s[i - 1]: count += 1 else: compressed.append(s[i - 1] + str(count)) count = ...
from solution import compress_method_a, compress_method_b, compare_compression_methods def test_compress_method_a(): assert compress_method_a("aaabb") == "a3b2" assert compress_method_a("aabbcc") == "a2b2c2" assert compress_method_a("abcd") == "a1b1c1d1" assert compress_method_a("") == "" assert co...
[ { "docstring": "Compress the string using method A.", "function_declaration": "def compress_method_a(s):", "function_name": "compress_method_a", "parameter_list": "(s)" }, { "docstring": "Compress the string using method B.", "function_declaration": "def compress_method_b(s):", "func...
[ 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 compress_method_a(s):\n \"\"\"\n Compresses a string using method A.\n \"\"\"\n compressed = []\n i = 0\n length = len(s)\n while i < leng...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00016628", "row_id": 16628, "seed_ids": "[7488]" }
0.654961
Taco_16628
I
[ "compress_method_a", "compress_method_b", "compare_compression_methods" ]
3
[ [ "compare_compression_methods", "compress_method_a" ], [ "compare_compression_methods", "compress_method_b" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5291fdb46e8e4b4d565cb4c52a8af714a44b10c4
eba174f848118107aa450f2cfc9fe8b0c79ca404
v1.0
instruct
Taco
Taco_16646_I
Read problems statements in Mandarin Chinese, Russian, and Vietnamese as well. You are given a list of integers. Determine if there exist three numbers in the list that can form the sides of a triangle with a positive area. ------ Input ------ The first line contains a single integer T denoting the number of test c...
def can_form_triangle(arr): arr.sort() for i in range(len(arr) - 2): if arr[i] + arr[i + 1] > arr[i + 2]: return "YES" return "NO" def solve(triangle_list): results = [] for triangle_data in triangle_list: N, arr = triangle_data results.append(can_form_triangle(a...
import pytest from solution import can_form_triangle, solve, parse_input, main def test_can_form_triangle(): assert can_form_triangle([1, 2, 3, 4]) == "YES" assert can_form_triangle([10, 20, 30]) == "NO" assert can_form_triangle([6, 1, 6, 9, 8]) == "YES" assert can_form_triangle([2, 2, 2]) == "YES" ...
[ { "docstring": null, "function_declaration": "def can_form_triangle(arr):", "function_name": "can_form_triangle", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def solve(triangle_list):", "function_name": "solve", "parameter_list": "(triangle_list)" ...
[ 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 can_form_triangle(sides):\n sides.sort()\n n = len(sides)\n for i in range(n - 2):\n if sides[i] + sides[i + 1] > sides[i + 2]:\n re...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016646", "row_id": 16646, "seed_ids": "[6813]" }
0.615285
Taco_16646
I
[ "can_form_triangle", "solve", "parse_input", "main" ]
4
[ [ "solve", "can_form_triangle" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
c9701fd560368d494afbef82f98258c822b3c96a
3e80e490b44a896205494b72412772ba40cc3ff4
v1.0
instruct
Taco
Taco_16653_I
Given an undirected, unweighted graph G with V vertices and E edges, determine if the graph contains a cycle. If the graph contains at least one cycle, output "Cycle detected", otherwise output "No cycle detected". ### Input The first line contains two integers V (1 ≤ V ≤ 1000) and E (0 ≤ E ≤ 1000), representing the n...
def dfs(graph, vertex, visited, parent): visited[vertex] = True for neighbor in graph[vertex]: if not visited[neighbor]: if dfs(graph, neighbor, visited, vertex): return True elif neighbor != parent: return True return False def detect_cycle(V, edges)...
from solution import process_input, detect_cycle def test_detect_cycle_1(): input_data = "5 5\n1 2\n2 3\n3 4\n4 5\n2 5" assert process_input(input_data) == "Cycle detected" def test_detect_cycle_2(): input_data = "4 3\n1 2\n2 3\n3 4" assert process_input(input_data) == "No cycle detected" def test_de...
[ { "docstring": null, "function_declaration": "def dfs(graph, vertex, visited, parent):", "function_name": "dfs", "parameter_list": "(graph, vertex, visited, parent)" }, { "docstring": null, "function_declaration": "def detect_cycle(V, edges):", "function_name": "detect_cycle", "p...
[ 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(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(paren...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016653", "row_id": 16653, "seed_ids": "[18069]" }
0.626456
Taco_16653
I
[ "dfs", "detect_cycle", "process_input" ]
3
[ [ "detect_cycle", "dfs" ], [ "process_input", "detect_cycle" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
ba1e560871e0e27810444499b5e6bea3d90bc8d3
a13a26663be66ca16132fa6c32b29a3a1b624127
v1.0
instruct
Taco
Taco_16657_I
In this problem, you are to determine the smallest number greater than or equal to a given number 'm' that is divisible by the sum of its digits. For example, for m = 18, the sum of the digits of 18 is 9 (1 + 8). Since 18 is divisible by 9, the output is 18. For m = 21, the sum of the digits of 21 is 3 (2 + 1). Since ...
def sum_of_digits(n): """ Returns the sum of the digits of the number n. """ return sum(int(digit) for digit in str(n)) def smallest_divisible_number(m): """ Returns the smallest number greater than or equal to m that is divisible by the sum of its digits. """ while True: if m %...
from solution import sum_of_digits, smallest_divisible_number, process_numbers def test_sum_of_digits(): assert sum_of_digits(18) == 9 assert sum_of_digits(21) == 3 assert sum_of_digits(23) == 5 assert sum_of_digits(105) == 6 def test_smallest_divisible_number(): assert smallest_divisible_number(1...
[ { "docstring": "Returns the sum of the digits of the number n.", "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": "Returns the smallest number greater than or equal to m that is divisible by the sum of its digits.", ...
[ 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 sum_of_digits(n):\n \"\"\"\n Returns the sum of the digits of the number n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef smallest_d...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00016657", "row_id": 16657, "seed_ids": "[18558]" }
0.751694
Taco_16657
I
[ "sum_of_digits", "smallest_divisible_number", "process_numbers" ]
3
[ [ "process_numbers", "smallest_divisible_number" ], [ "smallest_divisible_number", "sum_of_digits" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b10a7ffa3f89ca664f3d1b25159630dc4f87177d
1ae3203d82d6c8c7596bcc32a8ccf5edae2d8fc7