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
complete
Taco
Taco_11929_C
def check_overlap(n: int, segments_A: List[Tuple[int, int]], m: int, segments_B: List[Tuple[int, int]]) -> Tuple[str, int, int]: """ Determines whether there is an overlap between segments from two parks and identifies the overlapping segment. Args: n (int): Number of reserved segments for the first park. ...
def find_overlap(segment_list_1, segment_list_2): """ Determines whether there is an overlap between segments from two parks and identifies the overlapping segment. Args: segment_list_1 (list of tuples): List of tuples where each tuple represents a segment in the first park. segment_list_2 (list of...
from solution import check_overlap def test_no_overlap(): assert check_overlap(2, [(5, 10), (15, 20)], 1, [(21, 25)]) == ("NO OVERLAP",) def test_overlap_case_1(): assert check_overlap(3, [(1, 5), (10, 15), (20, 25)], 2, [(3, 8), (16, 19)]) == ("OVERLAP", 3, 5) def test_overlap_case_2(): assert check_ove...
[ { "docstring": "Determines whether there is an overlap between segments from two parks and identifies the overlapping segment.\n\nArgs:\nsegment_list_1 (list of tuples): List of tuples where each tuple represents a segment in the first park.\nsegment_list_2 (list of tuples): List of tuples where each tuple repr...
[ 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 check_overlap(reservations_park1, reservations_park2):\n \"\"\"\n Determine if there is an overlap between two sets of reserved segments.\n \n rese...
trial_gpt4o_4
{ "original_instruction": "Two local parks are connected by a continuous hiking trail. Due to the high demand for walking trails, each park has decided to reserve certain portions of the trail for exclusive use by their visitors. Your task is to ensure that the reserved sections do not overlap.\n\nEach park provides ...
0.563549
Taco_11929
C
[ "find_overlap", "check_overlap" ]
2
[ [ "check_overlap", "find_overlap" ] ]
1
[]
false
[]
false
pytest
true
[]
true
40b6db4b4d950598376cfd0b96b25d999c758b97
a58a3064f6daa5a502ccf8cebf4d5711b15b55c5
v1.0
complete
Taco
Taco_11820_C
def find_shortest_path(n: int, m: int, edges: List[Tuple[int, int, int]], a: int, b: int) -> int: """ Calculate the shortest path between two locations in a city represented as a graph. Args: n (int): Total number of intersections. m (int): Total number of streets. edges (List[...
import heapq from collections import defaultdict, deque def dijkstra(n, edges, start, end): graph = defaultdict(list) for u, v, t in edges: graph[u].append((v, t)) graph[v].append((u, t)) min_heap = [(0, start)] shortest_path = {i: float('inf') for i in range(1, n + 1)} sho...
from solution import find_shortest_path def test_example_case(): n = 5 m = 6 edges = [ (1, 2, 4), (1, 3, 2), (2, 3, 2), (2, 4, 1), (3, 5, 5), (4, 5, 3) ] a = 1 b = 5 assert find_shortest_path(n, m, edges, a, b) == 7 def test_no_path(): n ...
[ { "docstring": null, "function_declaration": "def dijkstra(n, edges, start, end):", "function_name": "dijkstra", "parameter_list": "(n, edges, start, end)" }, { "docstring": null, "function_declaration": "def find_shortest_path(n, m, edges, a, b):", "function_name": "find_shortest_pa...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef shortest_travel_time(n, m, streets, a, b):\n graph = {}\n \n # Build the graph\n for u, v, t in streets:\n if u not in graph...
trial_gpt4o_1
{ "original_instruction": "Imagine you are developing a simplified driving navigation system. Your task is to calculate the shortest path between two locations in a city represented as a graph, where intersections are nodes and streets are edges. Each street has a travel time associated with it.\n\nGiven the total nu...
0.705337
Taco_11820
C
[ "dijkstra", "find_shortest_path" ]
2
[ [ "find_shortest_path", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
75536e4366129235f32d205c5f3333aed0295760
cb14c602db7672f6dbe2e0023277566eb2023931
v1.0
complete
Taco
Taco_11804_C
def minimum_weight_one_cycle(n: int, edges: List[Tuple[int, int, int]]) -> int: """ Given an undirected graph with n nodes and m edges, each edge having a positive weight, find the minimum weight required to connect all the nodes in the graph with exactly one cycle. Args: n (int): The number of n...
import sys from heapq import heappop, heappush def find(parent, u): if parent[u] != u: parent[u] = find(parent, parent[u]) return parent[u] def union(parent, rank, u, v): root_u = find(parent, u) root_v = find(parent, v) if root_u != root_v: if rank[root_u] > rank[root_v]: ...
from solution import minimum_weight_one_cycle def test_sample(): n = 4 edges = [ (1, 2, 1), (2, 3, 2), (3, 4, 3), (4, 1, 4), (1, 3, 5) ] assert minimum_weight_one_cycle(n, edges) == 10 def test_single_additional_edge(): n = 3 edges = [ (1, 2, 1),...
[ { "docstring": null, "function_declaration": "def find(parent, u):", "function_name": "find", "parameter_list": "(parent, u)" }, { "docstring": null, "function_declaration": "def union(parent, rank, u, v):", "function_name": "union", "parameter_list": "(parent, rank, u, v)" }, ...
[ 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": "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_9
{ "original_instruction": "You are given an undirected graph with N nodes and M edges. Each edge has a positive weight. The goal is to find the minimum weight required to connect all the nodes in the graph in such a way that there is exactly one cycle in the resulting subgraph.\n\n-----Constraints-----\n- 2 ≤ N ≤ 100...
0.699163
Taco_11804
C
[ "find", "union", "minimum_weight_one_cycle", "main" ]
4
[ [ "minimum_weight_one_cycle", "find" ], [ "minimum_weight_one_cycle", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e4712cdaabb6ad95efc1a7912e8823c88e993768
20a42b822247d036d023d5a5ac9a66721054311d
v1.0
complete
Taco
Taco_11623_C
from typing import List, Tuple def minimized_maximum_travel_time(n: int, m: int, p: int, bus_stops: List[int], streets: List[Tuple[int, int, int]]) -> int: """ Determine the minimized maximum travel time between any two bus stops. Parameters: n (int): The number of intersections. m (int): The ...
import heapq def dijkstra(n, graph, start): """ Use Dijkstra's algorithm to find the shortest path from start to all other nodes. """ min_heap = [(0, start)] dist = {i: float('inf') for i in range(1, n + 1)} dist[start] = 0 while min_heap: current_distance, u = heapq.heappop(mi...
import pytest from solution import minimized_maximum_travel_time def test_example_1(): n, m, p = 5, 6, 3 bus_stops = [1, 3, 5] streets = [ (1, 2, 3), (2, 3, 2), (3, 4, 4), (4, 5, 1), (2, 5, 5), (5, 1, 2) ] assert minimized_maximum_travel_time(n, m, p,...
[ { "docstring": "Use Dijkstra's algorithm to find the shortest path from start to all other nodes.", "function_declaration": "def dijkstra(n, graph, start):", "function_name": "dijkstra", "parameter_list": "(n, graph, start)" }, { "docstring": null, "function_declaration": "def minimized_...
[ 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": "import heapq\nimport sys\nfrom collections import defaultdict\n\ndef dijkstra(graph, start):\n \"\"\" Finds the shortest paths from the start node to all other ...
trial_gpt4o_4
{ "original_instruction": "In the small town of Pathville, there are n intersections connected by m one-way streets such that it's possible to reach any intersection from any other intersection using the streets. \n\nEach street has an associated time t which indicates the time it takes to travel from one intersectio...
0.61435
Taco_11623
C
[ "dijkstra", "minimized_maximum_travel_time" ]
2
[ [ "minimized_maximum_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
25835e07eeae9901469d5c7de6c1b391f34b3d20
702b22f58185019c141b7ec7460f7dcb96f4291d
v1.0
complete
Taco
Taco_12152_C
from typing import List, Tuple def has_cycle_dfs(node, visited, rec_stack, graph): """Helper function to perform DFS and detect cycle in the graph.""" visited[node] = True rec_stack[node] = True for neighbour in graph[node]: if not visited[neighbour]: if has_cycle_dfs(neighbour...
from collections import defaultdict def has_cycle_dfs(node, visited, rec_stack, graph): visited[node] = True rec_stack[node] = True for neighbour in graph[node]: if not visited[neighbour]: if has_cycle_dfs(neighbour, visited, rec_stack, graph): return True e...
from solution import solve def test_case_1(): test_cases = [ (4, 4, [(1, 2), (2, 3), (3, 4), (4, 2)]), (5, 4, [(1, 2), (2, 3), (3, 4), (4, 5)]) ] assert solve(test_cases) == ["YES", "NO"] def test_case_2(): test_cases = [ (3, 3, [(1, 2), (2, 3), (3, 1)]), (6, 5, [(1, 2)...
[ { "docstring": null, "function_declaration": "def has_cycle_dfs(node, visited, rec_stack, graph):", "function_name": "has_cycle_dfs", "parameter_list": "(node, visited, rec_stack, graph)" }, { "docstring": null, "function_declaration": "def contains_cycle(n, edges):", "function_name"...
[ 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 has_cycle(n, edges):\n from collections import defaultdict\n \n def dfs(node, visited, rec_stack):\n visited[node] = True\n rec_stack[no...
trial_gpt4o_2
{ "original_instruction": "Alex, the software developer, enjoys solving puzzles in graphs. He found a directed graph with `n` nodes and `m` directed edges. Each edge connects two nodes `u` and `v`, and represents a one-way path from `u` to `v`. Alex suspects that there might be closed loops in the graph and wants to ...
0.660688
Taco_12152
C
[ "has_cycle_dfs", "contains_cycle", "solve" ]
3
[ [ "contains_cycle", "has_cycle_dfs" ], [ "solve", "contains_cycle" ] ]
2
[]
false
[]
false
pytest
true
[]
true
130ee7a3cb80e972412176f8d5b116b4585119b3
b68c88111645c617f471f5bbddd7683abbf44afd
v1.0
complete
Taco
Taco_12295_C
def can_produce_batch(r: int, g: int, b: int) -> str: """ Function to check if we can produce widgets of three colors red, green, blue such that no two consecutive widgets are of the same color. :param r: int - Number of red widgets :param g: int - Number of green widgets :param b: int - Number...
def can_produce_batch(r, g, b): """ Function to check if we can produce widgets of three colors red, green, blue such that no two consecutive widgets are of the same color. :param r: int - Number of red widgets :param g: int - Number of green widgets :param b: int - Number of blue widgets ...
def test_can_produce_batch_possible(): assert can_produce_batch(2, 2, 2) == "Possible" assert can_produce_batch(5, 5, 5) == "Possible" assert can_produce_batch(3, 4, 2) == "Possible" assert can_produce_batch(1, 1, 1) == "Possible" assert can_produce_batch(1, 2, 1) == "Possible" def test_can_produce...
[ { "docstring": "Function to check if we can produce widgets of three colors red, green, blue\nsuch that no two consecutive widgets are of the same color.\n\n:param r: int - Number of red widgets\n:param g: int - Number of green widgets\n:param b: int - Number of blue widgets\n:return: str - \"Possible\" or \"Im...
[ 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 can_produce_without_consecutive_same_color(n, batches):\n result = []\n for r, g, b in batches:\n max_widget = max(r, g, b)\n rest_widgets ...
trial_gpt4o_2
{ "original_instruction": "A factory produces different types of widgets in three colors: red, green, and blue. Each batch of production must follow a schedule such that no two widgets of the same color are produced consecutively. The factory is facing a challenge where the production manager needs to ensure that wid...
0.642035
Taco_12295
C
[ "can_produce_batch", "check_batches" ]
2
[ [ "check_batches", "can_produce_batch" ] ]
1
[]
false
[]
false
pytest
false
[]
true
7b1e8423a739647663660f50e397c5a1eb82e48b
94c5cfc9201fe7f0fb8643c3fc9ca69a736441c6
v1.0
complete
Taco
Taco_12038_C
import heapq from typing import List, Tuple def can_delivery_be_made(n: int, m: int, roads: List[Tuple[int, int, int, int]], deliveries: List[Tuple[int, int, int, int]]) -> List[str]: """ Determine if a set of delivery conditions can be satisfied. Each delivery condition specifies the required load to be trans...
import heapq def can_delivery_be_made(n, m, roads, deliveries): # Create adjacency list for the graph graph = [[] for _ in range(n + 1)] for u, v, L, T in roads: graph[u].append((v, L, T)) graph[v].append((u, L, T)) results = [] for a, b, R, M in deliveries: results.app...
from solution import can_delivery_be_made def test_single_path(): n = 4 m = 4 roads = [ (1, 2, 10, 5), (2, 3, 10, 3), (3, 4, 5, 2), (1, 3, 15, 10), ] deliveries = [ (1, 4, 5, 10), (1, 4, 15, 10), ] assert can_delivery_be_made(n, m, roads, deli...
[ { "docstring": null, "function_declaration": "def can_delivery_be_made(n, m, roads, deliveries):", "function_name": "can_delivery_be_made", "parameter_list": "(n, m, roads, deliveries)" }, { "docstring": null, "function_declaration": "def dijkstra(graph, start, end, n, R, M):", "func...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef can_delivery_be_made(n, m, roads, deliveries):\n # Create adjacency list for the graph\n graph = [[] for _ in range(n + 1)]\n for u, v...
trial_gpt4o_0
{ "original_instruction": "In an ancient kingdom, the king wishes to organize the delivery of resources between various cities. There are **n** cities and **m** direct roads connecting some pairs of cities. Along each road, the king has noted two values: the maximum load capacity of the road and the minimum time requ...
0.692799
Taco_12038
C
[ "can_delivery_be_made", "dijkstra" ]
2
[ [ "can_delivery_be_made", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
62b96048fae7dfc98827eeda940789b1fe7adf38
413282400ef00ee8b6a9a2a4aa8949cffbb0e04c
v1.0
complete
Taco
Taco_12210_C
def is_prime(num): """Check if a number is prime.""" pass def tech_sort(nums): """Perform TechSort on the list of numbers. >>> tech_sort([13, 5, 3, 4, 8, 10, 11]) [3, 5, 11, 4, 8, 10, 13] >>> tech_sort([22, 3, 14, 17]) [22, 3, 14, 17] """ pass def process_input(T, test_cases): ...
def is_prime(num): if num < 2: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def tech_sort(nums): prime_indices = [i for i, num in enumerate(nums)...
from solution import process_input def test_tech_sort_example_case(): input_data = [ (7, 13, 5, 3, 4, 8, 10, 11), (4, 22, 3, 14, 17) ] expected_output = [ [3, 5, 11, 4, 8, 10, 13], [22, 3, 14, 17] ] assert process_input(2, input_data) == expected_output def test_tec...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def tech_sort(nums):", "function_name": "tech_sort", "parameter_list": "(nums)" }, { "docstring": nul...
[ 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 \"\"\"Check if a number is prime.\"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0...
trial_gpt4o_2
{ "original_instruction": "In Techland, people use a unique sorting mechanism known as TechSort for their lists. TechSort operates differently from traditional sorting algorithms. The mechanism works as follows:\n\n1) Identify all the prime numbers in the list.\n2) Sort these prime numbers in ascending order and plac...
0.603767
Taco_12210
C
[ "is_prime", "tech_sort", "process_input" ]
3
[ [ "process_input", "tech_sort" ], [ "tech_sort", "is_prime" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
f015056a2d142db90315b149deff7d99ab907228
e5f1d7c2b1f517a4b7368abc472ff66d64d0cc2d
v1.0
complete
Taco
Taco_12911_C
def robHouses(nums): """ Given an array of n integers representing the amount of money at each house, determine the maximum amount of money the thief can rob without triggering the alarm. The houses are arranged in a circle, and the thief cannot rob consecutive houses. Examples: >>> robHouses([2, 3...
def robHouses(nums): if len(nums) == 1: return nums[0] return max(rob_linear(nums[:-1]), rob_linear(nums[1:])) def rob_linear(nums): prev, curr = 0, 0 for num in nums: prev, curr = curr, max(curr, prev + num) return curr
from solution import robHouses def test_example_1(): assert robHouses([2, 3, 2]) == 3 def test_example_2(): assert robHouses([1, 2, 3, 1]) == 4 def test_example_3(): assert robHouses([1, 2, 3]) == 3 def test_single_house(): assert robHouses([5]) == 5 def test_two_houses(): assert robHouses([1, ...
[ { "docstring": null, "function_declaration": "def robHouses(nums):", "function_name": "robHouses", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def rob_linear(nums):", "function_name": "rob_linear", "parameter_list": "(nums)" } ]
[ 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 robHouses(nums):\n if len(nums) == 1:\n return nums[0]\n\n return max(rob_linear(nums[:-1]), rob_linear(nums[1:]))\n\ndef rob_linear(nums):\n p...
trial_gpt4o_0
{ "original_instruction": "Given an array of n integers, where the i-th integer represents the amount of money present at the i-th house. Houses are arranged in a circle. A thief plans to rob houses, but cannot rob consecutive houses due to an alarm system. As the houses are arranged in a circle, the first and last h...
0.562623
Taco_12911
C
[ "robHouses", "rob_linear" ]
2
[ [ "robHouses", "rob_linear" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6eac44d00d7c978c6c1dfb6096348e61d15ac07f
db66db27f47e813fd704cde3d9c7abfbed808dc6
v1.0
complete
Taco
Taco_12686_C
def min_moves_to_identical(n, seq1, seq2): """ You are given two sequences of n integers each such that the sequences are permutations of each other. You can perform the following operations any number of times to make these sequences identical: 1. Choose any element from the first sequence and mo...
def min_moves_to_identical(n, seq1, seq2): """ Parameters: n (int): The length of the sequences. seq1 (list): The first sequence of integers. seq2 (list): The second sequence of integers. Returns: int: The minimum number of moves required to make the sequences identical. """ # creat...
from solution import min_moves_to_identical def test_example1(): assert min_moves_to_identical(3, [1, 2, 3], [3, 2, 1]) == 4 def test_example2(): assert min_moves_to_identical(5, [5, 4, 3, 2, 1], [1, 2, 3, 4, 5]) == 8 def test_no_moves(): assert min_moves_to_identical(3, [1, 2, 3], [1, 2, 3]) == 0 def t...
[ { "docstring": "Parameters:\nn (int): The length of the sequences.\nseq1 (list): The first sequence of integers.\nseq2 (list): The second sequence of integers.\n\nReturns:\nint: The minimum number of moves required to make the sequences identical.", "function_declaration": "def min_moves_to_identical(n, seq...
[ 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_moves_to_make_sequences_identical(n, seq1, seq2):\n # Create a dictionary to store the positions of elements in seq2 for quick lookup\n position_in_s...
trial_gpt4o_4
{ "original_instruction": "You are given two sequences of $n$ integers each such that the sequences are permutations of each other. You can perform the following operations any number of times to make these sequences identical:\n\n1. Choose any element from the first sequence and move it to the end, shifting all subs...
0.64742
Taco_12686
C
[ "min_moves_to_identical", "binary_search" ]
2
[ [ "min_moves_to_identical", "binary_search" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e3aaf3398b1d33706b1d35928be7efd7b9304b46
8f84dbc2b421d2c5b268f0967b477b3d7173722d
v1.0
complete
Taco
Taco_12382_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def isCousins(root: TreeNode, x: int, y: int) -> bool: """ Determine if two nodes in a binary tree are cousins (i.e., at the same level with different parents). ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def find_depth_and_parent(node, val, depth=0, parent=None): if node is None: return None, None if node.val == val: return depth, parent left_resul...
from solution import TreeNode, isCousins def test_isCousins_true(): root = TreeNode(1) root.left = TreeNode(2) root.right = TreeNode(3) root.left.left = TreeNode(4) root.right.right = TreeNode(5) assert isCousins(root, 4, 5) == True def test_isCousins_false_same_parent(): root = TreeNode(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": "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 isCousi...
trial_gpt4o_2
{ "original_instruction": "## Task\n\nGiven a binary tree, write a function to determine if two nodes are cousins. In a binary tree, cousins are nodes that are at the same level, but have different parents.\n\n### Input\n\n- The root node of the binary tree.\n- Two integer values representing the nodes to be checked ...
0.599455
Taco_12382
C
[ "find_depth_and_parent", "isCousins" ]
2
[ [ "isCousins", "find_depth_and_parent" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
7e6723fd937fa8cf40be7ec8130fbb5ba1e70ca0
2e016c55ac1f8d470f617d06d949784fc8d39ec1
v1.0
complete
Taco
Taco_13068_C
def palindromeIndex(s: str) -> int: """ 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. Args: s (...
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": "Palindrome Index\n\nGiven 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.\n\nFunction Description\n\n...
0.827573
Taco_13068
C
[ "is_palindrome", "palindromeIndex" ]
2
[ [ "palindromeIndex", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d7a3a771cd640728f35746dc3797e2f38c59d623
65fb315e5dd8d473b8263e5f1c579e24dcacfff1
v1.0
complete
Taco
Taco_12760_C
import math def lcm(a, b): return abs(a * b) // math.gcd(a, b) def smallest_common_multiple(a: int, b: int, c: int, x: int) -> int: """ Determine the smallest common multiple of three given numbers greater than a specified number x. The common multiple must be divisible by all three numbers. >>> ...
import math def lcm(a, b): return abs(a * b) // math.gcd(a, b) def smallest_common_multiple(a, b, c, x): multiple = lcm(lcm(a, b), c) if x % multiple == 0: return x + multiple else: return ((x // multiple) + 1) * multiple
from solution import smallest_common_multiple def test_example_1(): assert smallest_common_multiple(4, 5, 6, 10) == 60 def test_example_2(): assert smallest_common_multiple(3, 7, 9, 20) == 63 def test_example_3(): assert smallest_common_multiple(2, 3, 5, 50) == 60 def test_example_4(): assert smalle...
[ { "docstring": null, "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def smallest_common_multiple(a, b, c, x):", "function_name": "smallest_common_multiple", "parameter_list": "(a, b, c,...
[ 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 math import gcd\n\ndef lcm(a, b):\n \"\"\"Calculate the least common multiple of a and b.\"\"\"\n return a * b // gcd(a, b)\n\ndef smallest_common_multi...
trial_gpt4o_2
{ "original_instruction": "Write a program to determine the smallest common multiple of three given numbers greater than a specified number `x`. The common multiple must be divisible by all three numbers.\n\nExample 1:\nInput: a = 4, b = 5, c = 6, x = 10\nOutput: 60\nExplanation: The smallest common multiple of 4, 5,...
0.674276
Taco_12760
C
[ "lcm", "smallest_common_multiple" ]
2
[ [ "smallest_common_multiple", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
267cf075c5e5bcfdf1c8a5f8457711e0487f3ce6
6af69ee1dab76b611827b3c7d07f741c4585155a
v1.0
complete
Taco
Taco_12612_C
def reverse_number(n: int) -> int: """ Returns the reverse of the given number n. >>> reverse_number(123) == 321 >>> reverse_number(1200) == 21 >>> reverse_number(1) == 1 """ def is_palindrome(n: int) -> bool: """ Checks if the given number n is a palindrome. >>> is_palindrome(121) ...
def reverse_number(n): """ Returns the reverse of the given number n. """ return int(str(n)[::-1]) def is_palindrome(n): """ Checks if the given number n is a palindrome. """ s = str(n) return s == s[::-1] def steps_to_palindrome(n): """ Determines the number of steps requi...
from solution import reverse_number, is_palindrome, steps_to_palindrome def test_reverse_number(): assert reverse_number(123) == 321 assert reverse_number(1200) == 21 assert reverse_number(1) == 1 def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False as...
[ { "docstring": "Returns the reverse of the given number n.", "function_declaration": "def reverse_number(n):", "function_name": "reverse_number", "parameter_list": "(n)" }, { "docstring": "Checks if the given number n is a palindrome.", "function_declaration": "def is_palindrome(n):", ...
[ 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 reverse_number(n):\n \"\"\"\n Returns the reverse of the given number n.\n \"\"\"\n return int(str(n)[::-1])\n\ndef is_palindrome(n):\n \"\"\"\n...
trial_gpt4o_0
{ "original_instruction": "Problem\n\nLet's play a game with numbers called \"Reverse-Sum Palindrome\". The rules of the game are as follows:\n\n1. Given an integer number, obtain its reverse by reversing its digits.\n2. Add the original number and its reverse together.\n3. Check if the sum is a palindrome (a number ...
0.698668
Taco_12612
C
[ "reverse_number", "is_palindrome", "steps_to_palindrome" ]
3
[ [ "steps_to_palindrome", "is_palindrome" ], [ "steps_to_palindrome", "reverse_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6fc2474203fbf38fb93e41f7a56c7f0e7163a9b2
78995da336a83570b29d8f0e007bcc28dbfab234
v1.0
complete
Taco
Taco_13006_C
def min_palindrome_partition(s: str) -> int: """ Given a string consisting of lowercase Latin letters, find the minimum number of palindromic substrings into which it can be split. >>> min_palindrome_partition("aab") 2 >>> min_palindrome_partition("racecarannakayak") 3 >>> min_palindrome_partit...
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": "Вам дана строка, состоящая из строчных букв латинского алфавита. Необходимо разбить эту строку на минимальное количество подстрок, которые будут палиндромами.\n\nПалиндром — это строка, которая читается одинаково слева направо и справа налево. \n\nНапример, строка \"racecar\" является палин...
0.777912
Taco_13006
C
[ "is_palindrome", "min_palindrome_partition", "generate_partitions" ]
3
[ [ "generate_partitions", "is_palindrome" ], [ "generate_partitions", "min_palindrome_partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2c15df2d5c4319d13fffb5064eb7c2b0ac70100d
da02cc45704b5580f58e066eee7c140f2e43b254
v1.0
complete
Taco
Taco_13605_C
def largest_rectangle_of_H(grid: List[str]) -> int: """Find the area of the largest rectangle consisting entirely of 'H's within the given grid. >>> largest_rectangle_of_H([ "TTTTT", "THHHH", "THHTT", "THHHH" ]) 6 >>> largest_rectangle_of_H([ "HHH", "...
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": "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.\n\nKillua presents Gon with a 2D grid of dimensions `n x m` filled with either 'H' (Hunter) or...
0.589262
Taco_13605
C
[ "calculate_max_histogram_area", "largest_rectangle_of_H" ]
2
[ [ "largest_rectangle_of_H", "calculate_max_histogram_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
208d75e4ea1d22e779df3b8372dba8869056953c
1076c484479414f3665f1002971a5d9bfea28f62
v1.0
complete
Taco
Taco_13434_C
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. >>> smallest_palindrome(120) 121 >>> smallest_palindrome(...
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": "# Task\n\nGiven an **_integer_ n** , *Find the smallest integer m* , Such That ,\n\n# Conditions :\n\n* **_m_** is *greater than or equal to n* .\n\n* **_m_** is a **_palindrome_** .\n\n___\n\n# Notes\n\n* The **_parameter (n)_** passed to the function is a *positive integer* .\n___\n# Inpu...
0.774694
Taco_13434
C
[ "is_palindrome", "smallest_palindrome" ]
2
[ [ "smallest_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f5cc2246a5bf6650eb3143b301613a9a67569da4
5b70b7822780323d6715795112227595b6c6584a
v1.0
complete
Taco
Taco_12604_C
def is_prime(n: int) -> str: """ Determines if a given number n is a prime number. Returns "Prime" if the number is prime, and "Not Prime" otherwise. >>> is_prime(29) "Prime" >>> is_prime(14) "Not Prime" >>> is_prime(1) "Not Prime" >>> is_prime(2) "Prime" >>> is_prime(17) "Prime" >>> is_...
def is_prime(n): """ Determines if a given number n is a prime number. Returns "Prime" if the number is prime, and "Not Prime" otherwise. """ if n <= 1: return "Not Prime" if n == 2: return "Prime" if n % 2 == 0: return "Not Prime" limit = int(n ** 0.5) + 1 ...
from solution import is_prime, check_prime_numbers def test_is_prime(): assert is_prime(29) == "Prime" assert is_prime(14) == "Not Prime" assert is_prime(1) == "Not Prime" assert is_prime(2) == "Prime" assert is_prime(17) == "Prime" assert is_prime(18) == "Not Prime" assert is_prime(19) == ...
[ { "docstring": "Determines if a given number n is a prime number.\nReturns \"Prime\" if the number is prime, and \"Not Prime\" otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given a list of numbers, returns a l...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if a given number n is a prime number.\n Returns \"Prime\" if the number is prime, and \"Not Prime\" otherwise.\n ...
trial_gpt4o_0
{ "original_instruction": "Design a program that takes a sequence of positive integers and determines if they are prime numbers. A prime number is a number that is only divisible by 1 and itself. The input consists of multiple datasets where each row contains one integer. The end of the input is indicated by a single...
0.85804
Taco_12604
C
[ "is_prime", "check_prime_numbers" ]
2
[ [ "check_prime_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
703fa178604146d9f198e41810d504fda6502dfb
d0403835ae59431fc119b6f4862af73d5db959b3
v1.0
complete
Taco
Taco_13414_C
from typing import List def check_prime_numbers(nums: List[int]) -> List[bool]: """ Given a list of integers, return a list of booleans indicating whether each integer in the list is a prime number or not. >>> check_prime_numbers([2, 3, 4, 5, 10, 17]) == [True, True, False, True, False, True] >>> chec...
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": "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.\n\nFunction Signature:\n```python\ndef check_prime_numbers(nums: List[int]) -> List[bool]:\n```\n\n**Input:**\n\n- List of integers, `nums`, with ...
0.834562
Taco_13414
C
[ "is_prime", "check_prime_numbers" ]
2
[ [ "check_prime_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3343eaf37511d3055151544b91be08cd943349b6
84e2f2da371a26c48e92dea4dca9b7a5c86c6ac5
v1.0
complete
Taco
Taco_13332_C
from typing import List, Tuple def max_non_overlapping_plot_area(plots: List[Tuple[int, int, int, int]]) -> int: """ Find the maximum area of any non-overlapping plot. >>> max_non_overlapping_plot_area([(1, 1, 4, 4), (2, 2, 5, 5)]) == 0 >>> max_non_overlapping_plot_area([(1, 1, 4, 4), (5, 5, 8, 8)]) == 9 ...
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": "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 ma...
0.576771
Taco_13332
C
[ "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
6563f45c94e9140fee14c825c644127b3d88b65f
556f287d50906369b6435b4dc738a9175697837b
v1.0
complete
Taco
Taco_13643_C
from typing import List def restore_ip_addresses(s: str) -> List[str]: """ Given a string containing only digits, return all possible valid IP addresses that can be formed by inserting dots between the digits. Each segment of the IP address must be a valid segment, which means it is an integer between 0 an...
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": "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, ...
0.614372
Taco_13643
C
[ "is_valid_segment", "restore_ip_addresses" ]
2
[ [ "restore_ip_addresses", "is_valid_segment" ] ]
1
[]
false
[]
false
pytest
true
[]
true
eec963c8fc13775566dcd5d119d129bf53e3c51f
2603e014903aca8a7011eea3362a8c307a3bbd02
v1.0
complete
Taco
Taco_12583_C
def minimum_cost_to_connect_towns(n: int, m: int, roads: List[List[int]]) -> int: """ Find the minimum cost required to ensure that the entire kingdom is connected. If it's impossible to connect all towns, return -1. >>> minimum_cost_to_connect_towns(4, 5, [[1, 2, 3], [2, 3, 4], [3, 4, 1], [4, 1, 2], [...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yr...
def test_minimum_cost_to_connect_towns_case1(): n = 4 m = 5 roads = [ [1, 2, 3], [2, 3, 4], [3, 4, 1], [4, 1, 2], [1, 3, 5] ] assert minimum_cost_to_connect_towns(n, m, roads) == 6 def test_minimum_cost_to_connect_towns_case2(): n = 3 m = 1 roads ...
[ { "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(parent, i):\n if parent[i] != i:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(parent, rank, x, y):\n root_x = fin...
trial_gpt4o_1
{ "original_instruction": "In a faraway kingdom, there are n towns connected by m bidirectional roads. Each road has a non-negative weight, representing the travel cost. The kingdom's ruler wants to ensure that there's always a route, possibly indirect, between any two towns. You are asked to find the minimum cost re...
0.669717
Taco_12583
C
[ "find", "union", "minimum_cost_to_connect_towns" ]
3
[ [ "minimum_cost_to_connect_towns", "find" ], [ "minimum_cost_to_connect_towns", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
611d576be41a2352ae7f6cee8a38ad8496f22aeb
a94b82ea9ab52b7c0e3aba48e64ecf63478a30c7
v1.0
complete
Taco
Taco_13441_C
from typing import List, Tuple def minimum_road_network(n: int, m: int, roads: List[Tuple[int, int, int]]) -> int: """ Find the total length of the shortest road network that connects all the villages together. If it is not possible to connect all the villages, return "Impossible". >>> minimum_road_n...
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": "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...
0.693114
Taco_13441
C
[ "find", "union", "kruskal", "minimum_road_network" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_road_network", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
1fbcfeb0da33f2b2f73cfd5509b6e5c97d97f44e
ffdb35ff3a0ee595a727f1c3bcecaf57d79a7c83
v1.0
complete
Taco
Taco_13336_C
from typing import List, Tuple def solve(n: int, m: int, edges: List[Tuple[int, int]], queries: List[Tuple[int, int]]) -> List[str]: """ Determine if there is a path between two cities for given queries. Args: n: An integer representing the number of cities. m: An integer representing the number of roa...
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": "-----Input-----\nThe 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...
0.723941
Taco_13336
C
[ "find_connected_components", "solve" ]
2
[ [ "solve", "find_connected_components" ] ]
1
[]
false
[]
false
pytest
true
[]
true
76c9aeddab1acdb8174f60e5868fd0e8e1faf316
282afdcccd35dc51c56baab48ec8899a5add1da4
v1.0
complete
Taco
Taco_13736_C
from typing import List def find_lis_prime_length(n: int, array: List[int]) -> int: """ Given an array of positive integers, find the length of the longest increasing subsequence (LIS) such that the sum of the elements in this subsequence is a prime number. An increasing subsequence is a subsequence where...
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": "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:\n\nGiven an array of positive integers, find the length of the longest increasing subsequence (LIS) suc...
0.646355
Taco_13736
C
[ "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
5fcc869da681f862d2b7789d7bb126cd4343572a
233eb5d0f9ae00074e9cd3a42d233b7c3801fff5
v1.0
complete
Taco
Taco_12872_C
def reverse_number(num): """ Helper function to reverse the digits of a number. """ return int(str(num)[::-1]) def nth_number_in_sequence(start, x, n): """ Given the starting number `start`, the increment `x`, and the position `n`, this function returns the `n`-th number in the sequence. ...
def reverse_number(num): """ Helper function to reverse the digits of a number. """ return int(str(num)[::-1]) def nth_number_in_sequence(start, x, n): """ Given the starting number `start`, the increment `x`, and the position `n`, this function returns the `n`-th number in the sequence. ...
import pytest from solution import nth_number_in_sequence, process_test_cases def test_reverse_number(): assert reverse_number(123) == 321 assert reverse_number(98765) == 56789 assert reverse_number(1000) == 1 assert reverse_number(5005) == 5005 def test_nth_number_in_sequence(): assert nth_number...
[ { "docstring": "Helper function to reverse the digits of a number.", "function_declaration": "def reverse_number(num):", "function_name": "reverse_number", "parameter_list": "(num)" }, { "docstring": "Given the starting number `start`, the increment `x`, and the position `n`,\nthis function ...
[ 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 reverse_number(y):\n \"\"\"\n Returns the number obtained by reversing the digits of y.\n \"\"\"\n return int(str(y)[::-1])\n\ndef nth_sequence_num...
trial_gpt4o_2
{ "original_instruction": "Given a sequence of numbers where each number in the sequence (except the first) is formed by reversing the digits of the previous number and adding `x`. Your task is to determine the `n`-th number in the sequence for different sets of test cases.\n\nThe sequence `b` is defined as:\n- `b1 =...
0.674502
Taco_12872
C
[ "reverse_number", "nth_number_in_sequence", "process_test_cases" ]
3
[ [ "nth_number_in_sequence", "reverse_number" ], [ "process_test_cases", "nth_number_in_sequence" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
2a6283275153aad20e0f891a13fbd0d2558f5a48
70178337305d17c7e6982ccd22a12585f6073f06
v1.0
complete
Taco
Taco_14083_C
def findLargestSubmatrix(n: int, m: int, matrix: List[List[int]]) -> int: """ Determine the length of the longest contiguous submatrix of 1s in a binary matrix. >>> findLargestSubmatrix(4, 5, [ ... [1, 0, 1, 0, 0], ... [1, 0, 1, 1, 1], ... [1, 1, 1, 1, 1], ... [1, 0, 0, 1, 0]]) 6 >>> fin...
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": "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.\n\nIn other words, yo...
0.556792
Taco_14083
C
[ "maximalRectangle", "findLargestSubmatrix" ]
2
[ [ "findLargestSubmatrix", "maximalRectangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cb98d903065829e4368df018c02ced04c501fc0c
a571c318d34416f19727ab253c5effcea9f11725
v1.0
complete
Taco
Taco_13039_C
def formatted_histogram(input_str: str) -> str: """ 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 ...
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": "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 represent...
0.57412
Taco_13039
C
[ "histogram", "read_input", "formatted_histogram" ]
3
[ [ "formatted_histogram", "histogram" ], [ "formatted_histogram", "read_input" ] ]
2
[ "read_input" ]
false
[]
false
pytest
true
[]
true
5f7712119a40a910f3f1310e74fbd4b821f7f107
2d0c4f44fa0ed4c908a3ebc2dfccd448cedbcc1b
v1.0
complete
Taco
Taco_14126_C
from typing import List def is_interesting(title: str) -> str: """ 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". ...
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": "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 determ...
0.648464
Taco_14126
C
[ "is_interesting", "process_titles" ]
2
[ [ "process_titles", "is_interesting" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cd5f05616b22d6b1785e1bbd0fbe26b06b576b07
a7e0853b776de2bc93de81b984cbc475bc62ecfd
v1.0
complete
Taco
Taco_14029_C
def is_magic_garden(n: int, garden: List[List[int]]) -> bool: """ 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. >>> is_magic_garden(3, [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) True >>> is_magic_garden...
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": "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 rul...
0.540367
Taco_14029
C
[ "is_magic_garden", "min_swaps_to_magic_garden" ]
2
[ [ "min_swaps_to_magic_garden", "is_magic_garden" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0ec8ae8091cb1ac6f73ac5f6e0bc27ad81817847
1eb1b3cbbac656c24509427c8245e85abf6f53a2
v1.0
complete
Taco
Taco_14132_C
def compare_classifiers(matrix1: List[int], matrix2: List[int]) -> str: """ Compare two classifiers based on their confusion matrices and return the index of the classifier with the higher F1-score, or "Equal" if they have the same F1-score. >>> compare_classifiers([50, 10, 15, 25], [45, 10, 10, 35]) '2' ...
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": "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 ...
0.562078
Taco_14132
C
[ "calculate_f1", "compare_classifiers" ]
2
[ [ "compare_classifiers", "calculate_f1" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4684b52adfc0e15d4d0dcfd5feaa4f4577c1d0e6
f64cae0318b2375c6ae7af907a4dcfe0852cbdaa
v1.0
complete
Taco
Taco_13766_C
def find_prime_product_modulo(L, R, arr, primes_set, P): """ Find the product of all prime numbers in the subarray A[L...R] modulo P. Parameters: L (int): The starting index of the subarray (1-based indexing). R (int): The ending index of the subarray (1-based indexing). arr (List[int]): T...
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": "You are given an array $\\text{A}$ of size $\\text{N}$. You are asked to answer $\\text{Q}$ queries.\n\nEach query contains two integers $\\text{L}$ and $\\text{R}$.\n\nFor each query, you need to find the product of all the prime numbers in the subarray $\\text{A}[L...R]$. As the product c...
0.608754
Taco_13766
C
[ "is_prime", "find_prime_product_modulo", "find_primes_in_array" ]
3
[ [ "find_primes_in_array", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0d6c54b2d740719aa4dd090bf1b14c2d9606fa21
56681b8a38511121701f6cb1911e3b763287bf73
v1.0
complete
Taco
Taco_14351_C
def is_prime(num): """ Helper function to check if a number is prime. """ pass def smallest_prime_greater_equal(N): """ Finds the smallest prime number P that is greater than or equal to N. >>> smallest_prime_greater_equal(10) 11 >>> smallest_prime_greater_equal(14) 17 ...
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": "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:\n\nGiven an integer N, you need to find the smallest prime number P such that P is greater than or equal to N. \n...
0.822297
Taco_14351
C
[ "is_prime", "smallest_prime_greater_equal" ]
2
[ [ "smallest_prime_greater_equal", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
867082b9ee57b6618c804feedaa6c7c5289162a7
581720664fdded082331db326e77bf8032e6d26b
v1.0
complete
Taco
Taco_14152_C
def optimized_quicksort(arr): """ Sort an input list of integers using the optimized Quicksort algorithm with the median-of-three pivot strategy. 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. H...
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": "Problem Description:\nThe 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 w...
0.568197
Taco_14152
C
[ "median_of_three", "partition", "quicksort", "optimized_quicksort" ]
4
[ [ "optimized_quicksort", "quicksort" ], [ "partition", "median_of_three" ], [ "quicksort", "partition" ] ]
3
[]
false
[]
false
pytest
true
[]
true
33a70f3c74f051868712c150c6a8ecc977855b9f
8e409e88307c3c94b35f8d269efeb04b6a33ef47
v1.0
complete
Taco
Taco_14040_C
class Node: def __init__(self, val=0, next=None): self.val = val self.next = next def reverseKGroup(head, k): """ Reverse the nodes of the list k at a time and return the modified list. """ # Function to reverse a linked list def reverseLinkedList(head, k): new_head, ptr = N...
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": "**Reversing Nodes in K-Group**\n\nGiven 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 sho...
0.581277
Taco_14040
C
[ "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
a01f06af055a274ecaea616c1c9eb2691742ea45
3c9dd09f1292076be07810d428204316bfea102b
v1.0
complete
Taco
Taco_13235_C
from typing import List, Tuple def solution(N: int, M: int, edges: List[Tuple[int, int, int]], Q: int, queries: List[Tuple[int, int]]) -> List[int]: """ You are given an undirected connected graph with N nodes and M edges. Each edge has an integer weight. Perform Q queries on this graph, with each query conta...
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": "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...
0.74123
Taco_13235
C
[ "dfs", "lca_preprocess", "find_lca", "solution" ]
4
[ [ "lca_preprocess", "dfs" ], [ "solution", "find_lca" ], [ "solution", "lca_preprocess" ] ]
3
[]
false
[]
false
pytest
false
[]
true
29e5605d6ebb42cba0db1861d25322531f6178b1
5a2e1155cb70711ba4fae75593b9a34b50ed0c39
v1.0
complete
Taco
Taco_14355_C
from typing import List, Tuple def tree_diameter(n: int, edges: List[Tuple[int, int]]) -> int: """ Determine the diameter (length of the longest path between any two nodes) of a given tree. Args: n (int): The number of nodes in the tree. edges (List[Tuple[int, int]]): A list of edges where each ed...
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": "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.\n\nThe diameter...
0.6821
Taco_14355
C
[ "bfs_farthest_node", "tree_diameter" ]
2
[ [ "tree_diameter", "bfs_farthest_node" ] ]
1
[]
false
[]
false
pytest
false
[]
true
536fb4646f89704df8fd965636d55a89d9e001af
75f866528eb3504afd3036146a49319cac56b17e
v1.0
complete
Taco
Taco_14631_C
def countPalindromicNumbers(M: int, N: int) -> int: """ Determine the total count of numbers X within the range [M, N] such that their binary representation is a palindrome. >>> countPalindromicNumbers(5, 10) 3 >>> countPalindromicNumbers(10, 15) 1 """
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": "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 th...
0.711775
Taco_14631
C
[ "is_binary_palindrome", "countPalindromicNumbers" ]
2
[ [ "countPalindromicNumbers", "is_binary_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d3ee9f875b2bbfdd256a3b8527629f97e8732e95
9b2647c8bd54a65115c4a7e3569a4560453e7846
v1.0
complete
Taco
Taco_14222_C
def generate_factorials(limit): """ Generate all factorials less than or equal to a given limit. >>> generate_factorials(10) {1, 2, 6} """ factorials = set() i = 1 fact = 1 while fact <= limit: factorials.add(fact) i += 1 fact *= i return factorials MAX_VAL =...
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": "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 multip...
0.580632
Taco_14222
C
[ "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
9a235dc2aa88c0718016375438953358de18190e
c40124d01ec58102b6b0d4e64335ecde3b91aaf5
v1.0
complete
Taco
Taco_14141_C
def is_prime(n: int) -> bool: """ Check if a number is a prime number. Args: n (int): The number to check Returns: bool: True if the number is prime, False otherwise Examples: >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True """ ...
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": "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.\n\nThe...
0.747655
Taco_14141
C
[ "is_prime", "custom_sort" ]
2
[ [ "custom_sort", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8c8dc5ac0a58b8510650b28951b263a14bc0a54c
8a380ae6eebe9aa8e31514a90bf5337207679c54
v1.0
complete
Taco
Taco_14460_C
def max_consecutive_primes(n: int, segments: List[int]) -> int: """ Find the maximum number of consecutive house segments that contain a prime number of houses. >>> max_consecutive_primes(5, [7, 4, 6, 5, 13]) 2 >>> max_consecutive_primes(3, [2, 3, 5]) 3 >>> max_consecutive_primes(4, [8, 10, 4, 6]) 0 ...
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": "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 continu...
0.589587
Taco_14460
C
[ "is_prime", "max_consecutive_primes" ]
2
[ [ "max_consecutive_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
660a242e1a0860987a13b20e8f0c307a363ca4ba
6696d3bb911603bd986c7d9ebc85f002e3067dd6
v1.0
complete
Taco
Taco_14265_C
def max_water_flow(n: int, m: int, S: int, T: int, pipes: List[Tuple[int, int, int]]) -> int: """ Compute the maximum possible amount of water that can be sent from reservoir S to reservoir T in a network of reservoirs and pipes with given capacities. >>> max_water_flow(4, 5, 1, 4, [(1,2,10), (2,3,5), ...
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": "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 representi...
0.678259
Taco_14265
C
[ "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
33cf604f26cf36f928182b528da4c92914dd0ebc
a3760e8a43f8df0c716ed7d79ba09476be3ee267
v1.0
complete
Taco
Taco_14378_C
def game_of_life(grid): """ Computes the next state of the grid based on the Game of Life rules. Arguments: grid -- A 2D integer array (list of lists) where each cell contains either 1 (live cell) or 0 (dead cell). Returns: A 2D integer array representing the state of the grid after o...
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": "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:\n1. Any live cell with fewer than two live neighbors ...
0.538827
Taco_14378
C
[ "game_of_life", "count_live_neighbors" ]
2
[ [ "game_of_life", "count_live_neighbors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
38574f824d0e784d31f8462700f4cace2cfd5a03
21d005d0f01dada7fd0993322b23c8d544c45165
v1.0
complete
Taco
Taco_14291_C
def who_wins(W: int, H: int, Ax: int, Ay: int, Bx: int, By: int, Dx: int, Dy: int, board: List[str]) -> str: """ Determine who reaches the destination first in a grid-based board game. >>> who_wins(4, 4, 0, 0, 3, 0, 3, 3, ["....", ".#..", ".#..", "...."]) == "Bob" >>> who_wins(5, 5, 0, 0, 0, 4, 4, 0, [".......
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": "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, ...
0.609437
Taco_14291
C
[ "bfs", "who_wins" ]
2
[ [ "who_wins", "bfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2b6c86dee38ae1221773f92bd8fca8f379f1f1ec
4231dc1de1298c4c003f8379188519019d2387f9
v1.0
complete
Taco
Taco_14556_C
def is_palindromic(num): """ Check if the number is palindromic. >>> is_palindromic(121) True >>> is_palindromic(1331) True >>> is_palindromic(123) False >>> is_palindromic(1) True >>> is_palindromic(22) True """ def count_palindromic_numbers(L, R): """ Count the number of palin...
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": "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 num...
0.692332
Taco_14556
C
[ "is_palindromic", "count_palindromic_numbers", "solve" ]
3
[ [ "count_palindromic_numbers", "is_palindromic" ], [ "solve", "count_palindromic_numbers" ] ]
2
[]
false
[]
false
pytest
true
[]
true
dba7d337a4ac59980933676b0f85b1801867cdee
529aeacf67168c1384bd6b2abd87edea637b4d44
v1.0
complete
Taco
Taco_14701_C
def count_valid_fire_starts(grid, n, m): """ Determine the number of valid initial fire positions such that the fire consumes all open spaces. Args: grid (List[List[str]]): The urban area grid with '.' representing open spaces and '#' representing buildings. n (int): The height of the grid. ...
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": "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, ...
0.591129
Taco_14701
C
[ "count_valid_fire_starts", "solve" ]
2
[ [ "solve", "count_valid_fire_starts" ] ]
1
[]
false
[]
false
pytest
false
[]
true
28c68af6311c2ee7dc114d9fd49a6ca74a6a15ed
7ac62c6075bf6cfb9f7f34e300c2be723af4cfaf
v1.0
complete
Taco
Taco_14817_C
import math from typing import List def min_h(N: int) -> int: """ Return the minimum value of h(a, b) over all pairs of integers (a, b) such that 1 ≤ a, b ≤ N. """ pass def count_pairs_with_min_h(N: int) -> int: """ Return the total number of pairs (a, b) for which h(a, b) = min_h(N). """ pass...
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": "For two integers a and b where 1 ≤ a, b ≤ N, let h(a, b) = |a - b| + gcd(a, b) + lcm(a, b).\n\nFor 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.\n\nYour task is to find the total number of such pairs (a, b) f...
0.65353
Taco_14817
C
[ "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
2dc590bf98914e200a945d232e9803a006f33a8d
1218a5419037d4a3ee2790b1513fa658c6ec4568
v1.0
complete
Taco
Taco_14503_C
from typing import List, Tuple def min_changes_to_non_decreasing(n: int, heights: List[int]) -> int: """Returns the minimum number of changes required to make the flower heights non-decreasing. Args: n (int): The number of flowers. heights (List[int]): The list of integers denoting 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": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.\n\nChef 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,...
0.596904
Taco_14503
C
[ "min_changes_to_non_decreasing", "solve", "parse_input" ]
3
[ [ "solve", "min_changes_to_non_decreasing" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
afed5f293b92ddec9b83a1bc590cfb44e6878429
a805856f8fe47939113cc46c4563fc9137138767
v1.0
complete
Taco
Taco_14796_C
def is_prime(n: int) -> bool: """ Check if a given number n is prime. Args: n (int): The number to check for primality. Returns: bool: True if n is prime, False otherwise. Examples: >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(19) True """ ...
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": "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.\n\nYour task is to 1) **filt...
0.771641
Taco_14796
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ce059ad8840a0436139b08173e65bf79571fdde1
5dab45d886040aed09c5452e769315be6a29b032
v1.0
complete
Taco
Taco_14857_C
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. Examples: >>> distinct_soup_types([("...
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": "**Soup Distinction**\n\nIn 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.\n\n--...
0.617175
Taco_14857
C
[ "distinct_soup_types", "count_soup_types_from_input" ]
2
[ [ "count_soup_types_from_input", "distinct_soup_types" ] ]
1
[]
false
[]
false
pytest
false
[]
true
813d046c8f2a7acd0af10f432b782f696fed13c3
f55866ed13447cef7d92908b97fcea2e5702925d
v1.0
complete
Taco
Taco_14877_C
def number_of_connected_components(input_string: str) -> int: """ Determines the number of connected components in the network. Parameters: input_string (str): The input data as a string. The first line contains two integers N and M. Each of the next M lines contains two int...
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": "Problem\n\nIn 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 ...
0.553727
Taco_14877
C
[ "find_connected_components", "number_of_connected_components" ]
2
[ [ "number_of_connected_components", "find_connected_components" ] ]
1
[]
false
[]
false
pytest
false
[]
true
322bab1daae44ba0babf209d644aacd99cc60360
b5047e4f313d59226515c17fbc529b1c2519fd21
v1.0
complete
Taco
Taco_15377_C
def is_prime(n): """ Check if the given number is a prime number. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False """ def sort_primes(deck): """ Takes a list of integers representing a deck of cards and sorts only the prime number cards in non-decreasing order, whil...
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": "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 c...
0.698157
Taco_15377
C
[ "is_prime", "sort_primes" ]
2
[ [ "sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bd7b2c2638e7e015b73f8752b74aa9db7ea18f5b
c82c38376166f76d647128c7d65f3ddb4847258c
v1.0
complete
Taco
Taco_15104_C
def is_prime(n): """Helper function to check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True """ # Your code here pass def count_primes(arr): """ Returns the number of prime numbers in the array. >>> count_primes([2, 3, 4, 5, 6, 7, ...
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": "Write a function that takes an array of positive integers and returns the number of prime numbers in the array.\n\n### Example\n\n```python\ncount_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4 # The prime numbers are 2, 3, 5, 7\ncount_primes([2, 3, 5, 7, 11, 13, 17, 19, 23]) == 9 # All number...
0.799415
Taco_15104
C
[ "is_prime", "count_primes" ]
2
[ [ "count_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
516c4eda45c8f3527542ef469d1b3b4bb2c01020
9e7e6eda3be9ad3fa86f6652cac15e1b5e8313c1
v1.0
complete
Taco
Taco_15001_C
def restore_ip_addresses(s: str) -> List[str]: """ Generate 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, restore it by returning all possible valid IPv4 addresses that c...
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": "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...
0.598812
Taco_15001
C
[ "is_valid_octet", "restore_ip_addresses" ]
2
[ [ "restore_ip_addresses", "is_valid_octet" ] ]
1
[]
false
[]
false
pytest
true
[]
true
779b3a1f66bf2f84e2e050bf63424b90e4ec600f
0a7ce7be20d2e15a4d12590b85c4dcbf84b77fe5
v1.0
complete
Taco
Taco_14836_C
from typing import List, Tuple def max_path_sum_in_tree(N: int, node_values: List[int], edges: List[Tuple[int, int, int]]) -> int: """ Find the maximum sum of node values on any path in the tree. >>> max_path_sum_in_tree(5, [4, 5, 6, 3, 2], [(1, 2, 3), (2, 3, 2), (3, 4, 4), (4, 5, 1)]) == 20 >>> max_path_s...
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": "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 anoth...
0.621604
Taco_14836
C
[ "dfs", "max_path_sum_in_tree", "main" ]
3
[ [ "max_path_sum_in_tree", "dfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fc3ed68c7169f51e5625bbc4723304d2ebef851f
05df6ba8cd64fe83151c42fd826a655afb1f414b
v1.0
complete
Taco
Taco_14881_C
def sum_of_squares_of_digits(n: int) -> int: """ Calculate the sum of squares of digits of a given number. """ # Your code here def is_sequence_ending_in_1(k: int) -> bool: """ Determine if the sequence starting with k ends in 1. """ # Your code here def process_test_cases(test_cases: ...
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": "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 ...
0.545
Taco_14881
C
[ "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
9bb701c1cef4bb21d9cecbab60a8754563327f16
08116ce5a9bec1a3d822a2d30ba8efcf78a5a52d
v1.0
complete
Taco
Taco_15374_C
def shift_letter(c: str) -> str: """ Shifts a single character forward by one in the alphabet, wrapping 'z' to 'a' and 'Z' to 'A'. Non-alphabetic characters remain unchanged. >>> shift_letter('a') 'b' >>> shift_letter('z') 'a' >>> shift_letter('A') 'B' >>> shift_letter('Z') ...
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": "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.\n\n------ Input ------\n\n...
0.730492
Taco_15374
C
[ "shift_letter", "shift_text", "transform_strings" ]
3
[ [ "shift_text", "shift_letter" ], [ "transform_strings", "shift_text" ] ]
2
[]
false
[]
false
pytest
true
[]
true
45396b80d8052ed319865857444d9f03f1a7af15
300ccd4b4c3e7426c559f4f40701e09b555a0dda
v1.0
complete
Taco
Taco_14976_C
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 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": "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 ind...
0.612725
Taco_14976
C
[ "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
b911f1ffc29049c568b53f9316c52462d03c5c8e
db378a9070f8ec22b3babd9b7d0016ae7aa28828
v1.0
complete
Taco
Taco_15056_C
def sieve(N): """ Sieve of Eratosthenes algorithm to find all prime numbers up to N. Args: N (int): The upper limit to find prime numbers. Returns: List[int]: A list of all prime numbers up to N. """ primes = [True] * (N + 1) p = 2 while p * p <= N: if primes[p]: ...
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": "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.\n\nInput Format\nThe first line contains a single integer T, denoting the number of test cases...
0.62825
Taco_15056
C
[ "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
a47c7aa8453f248b4698bae186e9351be237f984
a8d29efec620895d81a55c0c68e62e8b261d0d0c
v1.0
complete
Taco
Taco_15383_C
def solve_network_routing(T: int, test_cases: List[Tuple[int, int, List[Tuple[int, int]]]]) -> List[str]: """ Determine the minimal number of additional communication channels required to ensure that every server can reach every other server. Args: T: The number of test cases. test_cases: A lis...
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": "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 d...
0.57366
Taco_15383
C
[ "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
ec03cd77254a394b1062d77653ad3cae522fea10
f76fecb6f3c41d4de32e9105947102cef97b608b
v1.0
complete
Taco
Taco_15016_C
def minimize_max_time(n, edges, k): """ 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 venu...
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": "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 ...
0.640455
Taco_15016
C
[ "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
3fe5584e61686714e4eec24a15e6a61be1c306c6
df9fd22a1fe4c95621bd2cd69be4398445fba300
v1.0
complete
Taco
Taco_14843_C
def solve_and_print_sudoku(board): """ Solve and print the Sudoku puzzle. The input board is a 9x9 grid containing integers from 0 to 9, where 0 represents an empty cell. The function should fill the empty cells with digits from 1 to 9 such that each row, each column, and each of the nine 3x3 sub-grids ...
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": "Implement a Sudoku Solver\n\nSudoku 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 al...
0.60331
Taco_14843
C
[ "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
d8a719821e892306dd2440431e76be5be9c99ba4
c805f92074fdbcd1758ae2dc42bed17b2447f681
v1.0
complete
Taco
Taco_15467_C
class TreeNode: def __init__(self, val=0): self.val = val self.left = None self.right = None def sum_of_deepest_leaves(node_count: int, edge_list: List[str]) -> int: """ Given the number of nodes in a binary tree and the edges list with parent, child and direction, find the sum of t...
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": "Given a binary tree, find the sum of the values of all the nodes that are the deepest leaves of the tree.\n\n-----Input:-----\n- The first line contains the number of nodes N.\n- Each of the next N lines contains three integers $p, c, d$ representing:\n - $p$: the value of a parent node.\n...
0.586264
Taco_15467
C
[ "deepestLeavesSum", "sum_of_deepest_leaves" ]
2
[ [ "sum_of_deepest_leaves", "deepestLeavesSum" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
e3550448fd762a6f0aca8088e2204c1f486cd02a
aadf1e5e908060921a5372cc1cb2d1899426cc11
v1.0
complete
Taco
Taco_15518_C
from typing import List def find_x_to_equalize_sequence(sequences: List[List[int]]) -> List[str]: """ Determine if you can make all elements of the sequence equal by adding or subtracting the same integer `x` to all elements of the sequence zero or more times, and find the value of `x`. >>> find_x_to_equalize_...
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": "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 a...
0.635681
Taco_15518
C
[ "find_x_to_equalize_sequence", "gcd" ]
2
[ [ "find_x_to_equalize_sequence", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ded50119388ebd228c6b712409aa8f31ff990e20
b395a5bbf5a5bd5698923e34ad9b9f27a1a078dc
v1.0
complete
Taco
Taco_15571_C
def max_non_interfering_towers(n, towers): """ Given the locations and ranges of various communication towers, determine the maximum number of non-interfering towers that can be activated simultaneously. >>> max_non_interfering_towers(5, [(1,2),(3,1),(4,1),(6,2),(8,1)]) 3 >>> max_non_interferi...
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": "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 w...
0.518929
Taco_15571
C
[ "max_non_interfering_towers", "read_input_and_solve" ]
2
[ [ "read_input_and_solve", "max_non_interfering_towers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
30533ea3cad77f07192e65d2b13fbe12870ea5f7
4574be4be1cb8eab197b2ca7929b30d2b74cc1d3
v1.0
complete
Taco
Taco_15872_C
def can_read_perfect_square_pages(T: int, test_cases: List[Tuple[int, List[int]]]) -> List[str]: """ Function to determine if there exists a group of consecutive books whose total number of pages is a perfect square. Args: T (int): The number of test cases test_cases (list): List containing tu...
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": "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 squ...
0.547212
Taco_15872
C
[ "is_perfect_square", "can_read_perfect_square_pages" ]
2
[ [ "can_read_perfect_square_pages", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a0823c55cafb3a03e201daaacc34f02ddae1cfc6
4f31ba834e401b40183513219fe5a6ed123390e5
v1.0
complete
Taco
Taco_16074_C
def is_prime_product(a: int, b: int) -> str: """ Given a range [a, b], multiply all numbers between a and b (inclusive) and determine if the resulting product is a prime number. >>> is_prime_product(2, 3) "Not prime" >>> is_prime_product(2, 5) "Not prime" >>> is_prime_product(3, 3) "Prime" ...
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": "**Sum of range multiplication**\n\nDebra 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.\n\nHo...
0.781271
Taco_16074
C
[ "is_prime", "is_prime_product" ]
2
[ [ "is_prime_product", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a86b164ea83a1e2a5ea8069e03a7448f224f03cc
7cd7f21009bb06ba4b075ffd695f05ee4b3c681c
v1.0
complete
Taco
Taco_15130_C
def largest_rectangle_area(input_str: str) -> int: """ Given an input string representing the grid, return the area of the largest rectangle containing only '1's. >>> largest_rectangle_area("4 5\n1 0 1 0 0\n1 0 1 1 1\n1 1 1 1 1\n1 0 0 1 0") 6 >>> largest_rectangle_area("1 2\n0 1") 1 >>> largest_...
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": "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 cel...
0.689741
Taco_15130
C
[ "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
ab6fd0d32582861f2db81fc8cdef553de6949147
0b92d663692c1c847903c8c4dd6329cda880f93b
v1.0
complete
Taco
Taco_15315_C
def maximum_electricity(n: int, m: int, s: int, t: int, edges: List[Tuple[int, int, int]]) -> int: """ Determine the maximum amount of electricity that can be sent from station 's' to station 't' in a city. >>> maximum_electricity(4, 5, 1, 4, [(1, 2, 100), (1, 3, 50), (2, 3, 50), (2, 4, 50), (3, 4, 50)]) == 100...
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": "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 stat...
0.580923
Taco_15315
C
[ "bfs_capacity", "edmonds_karp", "maximum_electricity" ]
3
[ [ "edmonds_karp", "bfs_capacity" ], [ "maximum_electricity", "edmonds_karp" ] ]
2
[]
false
[]
false
pytest
false
[]
true
e51c0e27708160f9c54fc5542ad9ccb7e1561432
a5e8c9a36621bb8776facb1d47c27e7bd0c039db
v1.0
complete
Taco
Taco_15953_C
def is_cluster(n: int, k: int, d: int, positions_t0: List[Tuple[int, int]], positions_t1: List[Tuple[int, int]]) -> str: """Determine if there exists at least one cluster of size at least k at t_1. Args: n (int): the number of birds k (int): the minimum cluster size d (int): the distance threshold ...
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": "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.\n\n...
0.58418
Taco_15953
C
[ "find_clusters", "is_cluster" ]
2
[ [ "is_cluster", "find_clusters" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e160ba99a9e48f1a3e0ed6b68b65d44a36d6cd95
e3cd0ff542c0984b7ae18c5297ca6b1753b4d268
v1.0
complete
Taco
Taco_15788_C
def is_prime(n: int) -> bool: """ Checks if a number n is a prime number. >>> is_prime(17) == True >>> is_prime(6) == False """ def is_sum_prime(coin_values: List[int]) -> bool: """ Returns True if the sum of coin values is a prime number, False otherwise. >>> is_sum_prime([2, 3, 5, 7])...
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": "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.\n\nA prime number is defined as a number greater than 1 that has no divisors other than 1 and...
0.747981
Taco_15788
C
[ "is_prime", "is_sum_prime" ]
2
[ [ "is_sum_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
16b59677d589e3bdad8f457943a8331a75a05780
09161e9b3d301bbd1c27c3eaa9a42bd6c2fe8e8f
v1.0
complete
Taco
Taco_15846_C
def generate_calendar(d, w, s): """ Generates the Zog calendar as a list of strings, each representing a week. """ pass def print_calendar(d, w, s): """ Prints the Zog calendar for a given year in the required format. """ pass # Example usage: # print_calendar(15, 7, 3) # Example Test...
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": "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...
0.560522
Taco_15846
C
[ "generate_calendar", "print_calendar" ]
2
[ [ "print_calendar", "generate_calendar" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0a076655558a54eda7720d5e97ba022e6735be12
dd5f4ce9dbb4650ee794e5b2664ed0bee3150e8f
v1.0
complete
Taco
Taco_15725_C
class TreeNode: def __init__(self, val): self.val = val self.left = None self.right = None def is_balanced_trees(test_cases: List[List[Tuple[int, int]]]) -> List[str]: """ Determine if a binary tree is height-balanced. Parameters: test_cases (List[List[Tuple[int, int]]]...
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": "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.\n\n-----Input-----\n\nThe first line contains a single integer $t$ ($1 ...
0.6854
Taco_15725
C
[ "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
7cf4821be3e79a348bba04eadd2c9c17e8f44555
160910ade9e17b42dbc123569b0812728f2f4a10
v1.0
complete
Taco
Taco_15900_C
from typing import List def is_perfect_square(x: int) -> bool: """ Check if a number is a perfect square. >>> is_perfect_square(1) True >>> is_perfect_square(4) True >>> is_perfect_square(9) True >>> is_perfect_square(2) False >>> is_perfect_square(10) False """ pass...
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": "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.\n\n(Note: A perfect square is an integer that is the square of an integer. For e...
0.651861
Taco_15900
C
[ "is_perfect_square", "count_special_pairs" ]
2
[ [ "count_special_pairs", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b8470f20611ac7194ab6c05e29bc4ce8924f7cc0
3411f09511ad0ccd1952b807e8b9b4445ecc692e
v1.0
complete
Taco
Taco_16296_C
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. """ def prime_numbers_up_to_n(n): """ Generates a list of prime numbers up to and including n. Args: n (int): Th...
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": "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 ...
0.753874
Taco_16296
C
[ "is_prime", "prime_numbers_up_to_n" ]
2
[ [ "prime_numbers_up_to_n", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
86aad364b4ff0beaf2d189e8333f04ea35a6d173
6947892ad0c93ac07ee96c3e2c65b75f2016e1c9
v1.0
complete
Taco
Taco_15403_C
from typing import List def findLongestUniqueConcat(words: List[str]) -> str: """ Given an array of strings words, 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 indivi...
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": "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.\n\nIf there are multiple longest string...
0.715428
Taco_15403
C
[ "is_unique", "findLongestUniqueConcat" ]
2
[ [ "findLongestUniqueConcat", "is_unique" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bce75b4991dd63b6faadf84a1d85d8492a7cece1
e0a571284dd3a0d98cfcfa02b6c6700526c2ff61
v1.0
complete
Taco
Taco_15724_C
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). """ pass def closest_points(points: List[Tuple[int, int]], K: int) -> List[Tuple[int, int]]: """ Returns the top K closest points to the...
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": "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...
0.710345
Taco_15724
C
[ "euclidean_distance", "closest_points" ]
2
[ [ "closest_points", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
false
[]
true
aa977a193dfe87a9c16c6bd6e150a3703e959b73
876df1562599ea0eb9c9f9ff577b146b3f9d42f6
v1.0
complete
Taco
Taco_15870_C
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') Examples: >>> determine_trend([10, 20, 30, ...
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": "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...
0.726132
Taco_15870
C
[ "determine_trend", "analyze_sales_data" ]
2
[ [ "analyze_sales_data", "determine_trend" ] ]
1
[]
false
[]
false
pytest
false
[]
true
a75902ed3774c79bbdf451cc77abf4634adb6f56
b738f3e1c658c9a33b122524875107848c5f3980
v1.0
complete
Taco
Taco_16423_C
def count_unsolved_problems(M: int, P: int, programmers: List[Tuple[int, List[int]]]) -> int: """ Identify the number of unsolved problems in a coding contest. >>> count_unsolved_problems(3, 5, [(2, [1, 3]), (2, [2, 3]), (1, [5])]) 2 >>> count_unsolved_problems(3, 5, [(2, [1, 3]), (2, [2, 3]), (2, [4, 5...
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": "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.\n\n-----Constraints-----\n- All values in input a...
0.593535
Taco_16423
C
[ "count_unsolved_problems", "read_input_and_count_unsolved" ]
2
[ [ "read_input_and_count_unsolved", "count_unsolved_problems" ] ]
1
[]
false
[]
false
pytest
false
[]
true
972c7c6bd779e231f0f153dd1268b805953d838f
d7bde879756c34b930b91a7decebcb3c45842d95
v1.0
complete
Taco
Taco_15538_C
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 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": "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.\n\nThe board is defined as a grid where each cell can either be empty (denoted b...
0.619588
Taco_15538
C
[ "process_moves", "game_from_input" ]
2
[ [ "game_from_input", "process_moves" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0c37c17f73cc87377c6fa6ce47aa3e67402f1722
061e44a78245dc00c8f0bc9134646ff60c3bcf27
v1.0
complete
Taco
Taco_15697_C
def has_path(graph, start, end, visited): # Determine if there exists a path from start to end node in the graph pass def find_paths(graph, queries): # For each pair of start and end nodes, determine if a path exists pass def main(): import sys input = sys.stdin.read data = input().strip()...
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": "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...
0.630221
Taco_15697
C
[ "has_path", "find_paths", "main" ]
3
[ [ "find_paths", "has_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
18d199f17d9148f24a8fdc749bd96e8da89a3f8d
45c94c4f4fb3593786dd1f7b9cd8bb9ebf1b06d1
v1.0
complete
Taco
Taco_15969_C
from typing import List def is_prime(n: int) -> bool: """ Checks if a number n is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(18) False >>> is_prime(-5) False >>> is_prime(0) False >>> is_...
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": "Given a list of integers, you need to determine the sum of all the prime numbers present in the list.\n\n------ Input ------\n\nThe 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 represe...
0.760474
Taco_15969
C
[ "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
faf4d802c259daccdf09c0a98cfd542e633267e2
15e4c66ca26094a3049885cbcc584a741c201680
v1.0
complete
Taco
Taco_16202_C
from typing import List from math import gcd from functools import reduce def lcm(a: int, b: int) -> int: """ Calculate the Least Common Multiple (LCM) of two numbers. """ return a * b // gcd(a, b) def find_synchronized_duration(durations: List[int]) -> int: """ Given a list of traffic light d...
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": "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 sw...
0.52745
Taco_16202
C
[ "lcm", "find_synchronized_duration", "main" ]
3
[ [ "find_synchronized_duration", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5f8c98dce2f28eb2b427447e8cfc919ec53374fd
bf5410d475710238aa2743427866acbc3ea59173
v1.0
complete
Taco
Taco_15905_C
from typing import List, Tuple def max_path_sum(matrix: List[List[int]]) -> int: """ Find the maximum possible score achievable by moving from the top-left to the bottom-right of the matrix, only moving right or down. >>> max_path_sum([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 29 >>> max_path_sum([[1, 1, 1, 1],...
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": "Parsa and Ali have a large matrix of size $n \\times m$. Each cell of this matrix contains a positive integer.\n\nThey 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:\n\n1. They can only move righ...
0.663897
Taco_15905
C
[ "max_path_sum", "solve", "parse_input", "main" ]
4
[ [ "solve", "max_path_sum" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
05465c90424f82cf4b43626f496fbec1c7c46f0b
7288752310d8a079fa0e9a3651a3663260b38dab
v1.0
complete
Taco
Taco_16333_C
def max_sum_submatrix(matrix): """ Returns the maximum sum of elements of any submatrix of the given matrix. >>> max_sum_submatrix([[1]]) 1 >>> max_sum_submatrix([ [1, 2, 3], [4, 5, 6] ]) 21 >>> max_sum_submatrix([ [-1, -2, 3], [4, 5, -6] ]) 9 >>> max_sum_...
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": "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.\n\nDefine the sum of a subma...
0.62061
Taco_16333
C
[ "max_sum_submatrix", "kadane" ]
2
[ [ "max_sum_submatrix", "kadane" ] ]
1
[]
false
[]
false
pytest
false
[]
true
73ab598e8bb9b98e59adbe1a3a2315370d572235
8a3b86c140acbc223546f22f8581b86b07abbc3e
v1.0
complete
Taco
Taco_15851_C
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 """ pass de...
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": "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.\n\nThe company receives a list of requests...
0.564632
Taco_15851
C
[ "sort_requests", "process_requests" ]
2
[ [ "process_requests", "sort_requests" ] ]
1
[]
false
[]
false
pytest
true
[]
true
067cd572260b5de936941a5184dce63095e5ab56
19dfbfc4e3705a91c70ef5fa88508b105d47d0c3
v1.0
complete
Taco
Taco_16331_C
from typing import List, Tuple def max_gold_on_shortest_path(n: int, roads: List[Tuple[int, int]], gold: List[int], queries: List[Tuple[int, int, int]]) -> List[int]: """ Calculate the maximum amount of gold on the shortest path between two houses u and v that lie within the interval [u, v]. >>> n = 5 >>>...
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": "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 hous...
0.567374
Taco_16331
C
[ "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
a91132220a5ee1db02034fa426fedd8e34f4ddf3
ae6047fea0f89c1c6adf61cb3a6bbf4b1373bba2
v1.0
complete
Taco
Taco_16657_C
def sum_of_digits(n: int) -> int: """ Returns the sum of the digits of the number n. """ pass def smallest_divisible_number(m: int) -> int: """ Returns the smallest number greater than or equal to m that is divisible by the sum of its digits. """ pass def process_numbers(t: int, number...
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": "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.\n\nFor 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 di...
0.67665
Taco_16657
C
[ "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
733f878d1d9eb0908c28c3da432e0308c1ad1ab6
1ae3203d82d6c8c7596bcc32a8ccf5edae2d8fc7
v1.0
complete
Taco
Taco_16769_C
def minimum_adjacent_swaps(heights: List[int]) -> int: """ Given a list of student heights, find the minimum number of adjacent swaps required to arrange them in non-decreasing order. >>> minimum_adjacent_swaps([4, 3, 2, 1, 5, 6]) 6 >>> minimum_adjacent_swaps([1, 2, 3, 4, 5, 6]) 0 >>> minimum_ad...
def count_inversions(arr): # Helper function to merge two halves and count inversions def merge_and_count(arr, temp_arr, left, mid, right): i = left # Starting index for left subarray j = mid + 1 # Starting index for right subarray k = left # Starting index to be sorted inv...
from solution import minimum_adjacent_swaps def test_example(): assert minimum_adjacent_swaps([4, 3, 2, 1, 5, 6]) == 6 def test_sorted_list(): assert minimum_adjacent_swaps([1, 2, 3, 4, 5, 6]) == 0 def test_reversed_list(): assert minimum_adjacent_swaps([6, 5, 4, 3, 2, 1]) == 15 def test_mixed_list_1():...
[ { "docstring": null, "function_declaration": "def count_inversions(arr):", "function_name": "count_inversions", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def minimum_adjacent_swaps(heights):", "function_name": "minimum_adjacent_swaps", "parameter_...
[ 0, 0, 0, 0, 0, 1, 0, 1, 1, 1 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_inversions(arr):\n \"\"\"\n Uses the merge sort algorithm to count inversions in the array.\n \"\"\"\n def merge_count_split_inv(arr, temp_ar...
trial_gpt4o_9
{ "original_instruction": "You are given a sequence of integers representing the heights of students in a line. All the students are required to rearrange themselves in non-decreasing order of their heights. However, the rearrangement must be done using the minimum number of adjacent swaps.\n\nWrite a function that t...
0.597266
Taco_16769
C
[ "count_inversions", "minimum_adjacent_swaps" ]
2
[ [ "minimum_adjacent_swaps", "count_inversions" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3d0796181702c0ae5991861fa447003e560f1cd4
feb485716aaafd44ec9464b126d2ada119e3917e
v1.0
complete
Taco
Taco_16653_C
def process_input(input_data: str) -> str: """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'. Args: input_data (str): The input data as ...
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": "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\".\n\n### Input\nThe first line contains two integers V (1 ≤ V ≤ 1000) and ...
0.618307
Taco_16653
C
[ "dfs", "detect_cycle", "process_input" ]
3
[ [ "detect_cycle", "dfs" ], [ "process_input", "detect_cycle" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
dd41491b3577437a865bcc2937e749796e3fbe04
a13a26663be66ca16132fa6c32b29a3a1b624127
v1.0
complete
Taco
Taco_15417_C
def parse_properties(n, properties_data): """ Parse the list of property data into a list of dictionaries. >>> parse_properties(3, ["300000 3 2 1500", "400000 4 3 2000", "250000 2 1 1200"]) [{"price": 300000, "bedrooms": 3, "bathrooms": 2, "size": 1500}, {"price": 400000, "bedrooms": 4, "bathroom...
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": "Create a program to analyze real estate data and identify properties that meet specific criteria.\n\nYou 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...
0.549422
Taco_15417
C
[ "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
c287c70dee9a4f9d9e70d0cc1267f71314f515f1
1e7f16a5defe6d1f3c0a1ddfc899e0e1fac0b49e
v1.0
complete
Taco
Taco_16628_C
def compress_method_a(s: str) -> str: """ Compress the string using method A. >>> compress_method_a("aaabb") "a3b2" >>> compress_method_a("aabbcc") "a2b2c2" >>> compress_method_a("abcd") "a1b1c1d1" """ # implementation def compress_method_b(s: str) -> str: """ ...
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": "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 ...
0.653043
Taco_16628
C
[ "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
5663f3f335494e2387abb5bfa08a57c94bfe7d46
eba174f848118107aa450f2cfc9fe8b0c79ca404
v1.0
complete
Taco
Taco_16597_C
def next_power_of_p(x, p): """ Calculate the smallest power of p greater than or equal to x. >>> next_power_of_p(5, 2) 8 >>> next_power_of_p(9, 2) 16 >>> next_power_of_p(1, 3) 1 >>> next_power_of_p(10, 3) 27 >>> next_power_of_p(25, 5) 25 >>> next_power_of_p(26, 5) 125 >>> next_power_...
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": "You are given an integer array $a_1, a_2, \\ldots, a_n$ and an integer $p$.\n\nIn one step you can either:\n\n- Choose any element $a_i$ and increase $a_i$ to the smallest power of $p$ that is greater than or equal to $a_i$.\n- Or choose two indices $i$ and $j$ such that $a_i \\ge a_j$ and ...
0.569365
Taco_16597
C
[ "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
79e3e11f306b21a6c57dc9b0fb9d3ae4425a1cef
063ba0a91ae9e3659d298015f06b8b7c0be003f3
v1.0
complete
Taco
Taco_16405_C
def parse_file_system(file_system_str): """ Parse the file system input string and return a dictionary representing the file system. >>> parse_file_system("folderA/\n file1.ext 50\n file2.ext 30\n subfolderA/\n file3.ext 20\n subfolderB/\n file4.ext 10") {'folderA/': [('file1.ext', 50), ('file...
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": "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 recurs...
0.71473
Taco_16405
C
[ "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
2640fbf4db34de826716a349ee88f68b67a00af9
3254034370dddb0184094720af5bcff6e3badc61
v1.0
complete
Taco
Taco_15672_C
def find(parent, i): """A utility function to find the set of an element i (uses path compression technique)""" if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): """A function that does union of two sets of x and y (uses union by rank)""" ...
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": "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 dur...
0.662201
Taco_15672
C
[ "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
ffd5d0f005d1355a27300bc5c6788f800223ff7d
0b62866bad8f63a7d3c513bb6a3110ac10db047f
v1.0
complete
Taco
Taco_16853_C
def findNthFibonacci(N: int) -> int: """ Calculate the Nth Fibonacci number using matrix exponentiation. >>> findNthFibonacci(5) == 5 >>> findNthFibonacci(10) == 55 >>> findNthFibonacci(1) == 1 >>> findNthFibonacci(2) == 1 >>> findNthFibonacci(20) == 6765 >>> findNthFibonacci(50) == 12586...
def multiply_matrices(mat1, mat2): """Multiplies two 2x2 matrices.""" return [ [ mat1[0][0] * mat2[0][0] + mat1[0][1] * mat2[1][0], mat1[0][0] * mat2[0][1] + mat1[0][1] * mat2[1][1] ], [ mat1[1][0] * mat2[0][0] + mat1[1][1] * mat2[1][0], ma...
def test_findNthFibonacci(): assert findNthFibonacci(5) == 5 assert findNthFibonacci(10) == 55 assert findNthFibonacci(1) == 1 assert findNthFibonacci(2) == 1 assert findNthFibonacci(20) == 6765 assert findNthFibonacci(50) == 12586269025 assert findNthFibonacci(0) == 0 def test_large_N(): ...
[ { "docstring": "Multiplies two 2x2 matrices.", "function_declaration": "def multiply_matrices(mat1, mat2):", "function_name": "multiply_matrices", "parameter_list": "(mat1, mat2)" }, { "docstring": "Raises the matrix to the power using efficient matrix exponentiation.", "function_declara...
[ 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 matrix_mult(A, B):\n \"\"\"\n Multiplies two 2x2 matrices A and B.\n \"\"\"\n return [\n [A[0][0]*B[0][0] + A[0][1]*B[1][0], A[0][0]*B[0][1]...
trial_gpt4o_2
{ "original_instruction": "Calculate the Nth Fibonacci number using matrix exponentiation.\n\nExample 1:\nInput:\nN = 5\nOutput:\n5\nExplanation:\nThe Fibonacci sequence is 0, 1, 1, 2, 3, 5...\nSo, the 5th Fibonacci number is 5.\n\nExample 2:\nInput:\nN = 10\nOutput:\n55\nExplanation:\nThe Fibonacci sequence is 0, 1,...
0.828528
Taco_16853
C
[ "multiply_matrices", "matrix_exponentiation", "findNthFibonacci" ]
3
[ [ "findNthFibonacci", "matrix_exponentiation" ], [ "matrix_exponentiation", "multiply_matrices" ] ]
2
[]
false
[]
false
pytest
false
[]
true
1f16580191abd92cf46ee6e93d98e56b6534035c
13933e8adba0b2bc28be01aab4acccba99953907
v1.0
complete
Taco
Taco_16377_C
def max_non_overlapping_tasks(tasks: List[Tuple[int, int]]) -> int: """ Returns the maximum number of non-overlapping tasks that can be scheduled. >>> max_non_overlapping_tasks([(1, 2), (2, 3), (3, 4)]) == 3 >>> max_non_overlapping_tasks([(1, 3), (2, 4), (3, 5), (6, 8)]) == 3 >>> max_non_overlappin...
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": "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.\n\nWrite a program to help Tina maximize the number of tasks she can schedule withou...
0.622443
Taco_16377
C
[ "max_non_overlapping_tasks", "scheduling_algorithm" ]
2
[ [ "scheduling_algorithm", "max_non_overlapping_tasks" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ef9256b0dc805f0f659dc8ebc57137c9434af210
5780cf4063bc213b4c1655e5e964a9bd8020b749
v1.0
complete
Taco
Taco_16669_C
def is_prime(num): """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(10) False >>> is_prime(29) True """ # implementation here def first_n_primes(n): """ Given an integer n, return the first n prime ...
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 first_n_primes(n): pri...
from solution import is_prime, first_n_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(29) == True def test_first_n_primes(): assert first_n_primes(1) == [2...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def first_n_primes(n):", "function_name": "first_n_primes", "parameter_list": "(n)" } ]
[ 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 if num <= 3:\n ...
trial_gpt4o_1
{ "original_instruction": "Given an integer n, print the first n prime numbers in ascending order.\n\nConstraints\n\n* 1 ≤ n ≤ 1000\n\nInput\n\nThe input contains a single integer n.\n\nOutput\n\nOutput the first n prime numbers in ascending order, each on a new line.\n\nExample\n\nInput\n\n10\n\nOutput\n\n2\n3\n5\n7...
0.824597
Taco_16669
C
[ "is_prime", "first_n_primes" ]
2
[ [ "first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ba7daa551c867af36a966ba5cdcc7062b6af2168
f8c4d4b6f4735a7380fcd7f7965e88dc640f41fd
v1.0
complete
Taco
Taco_16896_C
def transform_list(numbers): """ Transforms the list according to the given rules and returns the resulting list. - If a number is divisible by 3, replace it with "Fizz". - If a number is divisible by 5, replace it with "Buzz". - If a number is divisible by both 3 and 5, replace it with "FizzBuzz". ...
def is_prime(n): """Helper function to check if a number is prime.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def transform_list(numbers)...
from solution import transform_list def test_empty_list(): assert transform_list([]) == [] def test_only_primes(): assert transform_list([2, 3, 5, 7, 11]) == ["Prime", "Fizz", "Buzz", "Prime", "Prime"] def test_fizz_buzz_fizzbuzz(): assert transform_list([3, 5, 15]) == ["Fizz", "Buzz", "FizzBuzz"] def t...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Transforms the list according to the given rules.", "function_declaration": "def transform_list(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 \"\"\"Helper function to check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if...
trial_gpt4o_0
{ "original_instruction": "You are given a list of integers. Your task is to transform the list according to the following rules and return the resulting list:\n\n1. If a number is divisible by 3, replace it with \"Fizz\".\n2. If a number is divisible by 5, replace it with \"Buzz\".\n3. If a number is divisible by bo...
0.619049
Taco_16896
C
[ "is_prime", "transform_list" ]
2
[ [ "transform_list", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3a16dd15cbaac8f63d16e3b0af8944d3b23ee584
856f7f9ad481de1c3c31f424b498d02242714b66
v1.0
complete
Taco
Taco_16963_C
from typing import List from math import gcd from functools import reduce def lcm(a: int, b: int) -> int: """Helper function to return the least common multiple of two integers""" return a * b // gcd(a, b) def find_lcm_of_intersections(cycle_times: List[int]) -> int: """Returns the least amount of time af...
from math import gcd from functools import reduce def lcm(a, b): """ Helper function to return the least common multiple of two integers """ return a * b // gcd(a, b) def find_lcm_of_intersections(cycle_times): """ Returns the least amount of time after which all traffic lights will simul...
from solution import find_lcm_of_intersections def test_example1(): assert find_lcm_of_intersections([4, 6, 8]) == 24 def test_example2(): assert find_lcm_of_intersections([5, 10]) == 10 def test_single_intersection(): assert find_lcm_of_intersections([7]) == 7 def test_multiple_prime_cycles(): asse...
[ { "docstring": "Helper function to return the least common multiple of two integers", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the least amount of time after which all traffic lights will \nsimultaneously show gre...
[ 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 math import gcd\nfrom functools import reduce\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\ndef find_time_for_green_lights(num_intersections, cycle_time...
trial_gpt4o_2
{ "original_instruction": "A city is developing a new traffic system to manage congestion at its busiest intersections. The plan involves using a system of traffic lights that operate on cycles, and each intersection has a predetermined cycle time. An intersection's cycle time is the total time it takes for the traff...
0.560348
Taco_16963
C
[ "lcm", "find_lcm_of_intersections" ]
2
[ [ "find_lcm_of_intersections", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5e89c800b21134df2767344abc02bedb82a7ce88
1a2ddc57918d8eb4d7998b335305c898f86c44cf