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_60224_C
from typing import List def largest_integer(numbers: List[int]) -> str: """ Write a function, `largest_integer`, that takes a list of non-negative integers and returns the largest integer that can be formed by concatenating the integers together. >>> largest_integer([10, 2]) '210' >>> large...
from typing import List from functools import cmp_to_key def compare(x, y): if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def largest_integer(numbers: List[int]) -> str: # Convert all the integers to strings str_numbers = list(map(str, numbers)) ...
from solution import largest_integer def test_largest_integer_basic(): assert largest_integer([10, 2]) == "210" assert largest_integer([3, 30, 34, 5, 9]) == "9534330" def test_largest_integer_single_element(): assert largest_integer([5]) == "5" def test_largest_integer_duplicate_elements(): assert la...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def largest_integer(numbers):", "function_name": "largest_integer", "parameter_list": "(numbers)" } ]
[ 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 typing import List\nfrom functools import cmp_to_key\n\ndef compare(x, y):\n if x + y > y + x:\n return -1\n elif x + y < y + x:\n return ...
trial_gpt4o_0
{ "original_instruction": "Write a function, `largest_integer`, that takes a list of non-negative integers and returns the largest integer that can be formed by concatenating the integers together. \n\nFor example, given `[50, 2, 1, 9]`, the largest integer would be `95021`.\n\nFunction Signature \n`def largest_inte...
0.726903
Taco_60224
C
[ "compare", "largest_integer" ]
2
[ [ "largest_integer", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e94306a5dac51657fd6b3d8ef073152bcb76a8c9
6fdf0d9a4ed4034a4ef78a90e362ae95da8774e8
v1.0
complete
Taco
Taco_60219_C
def max_sum_weights(input_string: str) -> List[int]: """ Determine the maximum possible sum of weights of two books that Bob can achieve for each test case. >>> max_sum_weights("3\n3\n1 2 4\n4\n5 1 2 9\n5\n7 5 12 8 10\n") [6, 14, 22] >>> max_sum_weights("1\n2\n1 2\n") [3] >>> max_sum_weights("1\...
def max_sum_of_two_books(test_cases): results = [] for books in test_cases: # Sort the books weights weights = sorted(books) # The maximum sum of two books will be the sum of the two heaviest books results.append(weights[-1] + weights[-2]) return results # Helper function to...
import pytest from solution import max_sum_weights def test_example_cases(): input_data = "3\n3\n1 2 4\n4\n5 1 2 9\n5\n7 5 12 8 10\n" expected_output = [6, 14, 22] assert max_sum_weights(input_data) == expected_output def test_single_case_min_books(): input_data = "1\n2\n1 2\n" expected_output = [...
[ { "docstring": null, "function_declaration": "def max_sum_of_two_books(test_cases):", "function_name": "max_sum_of_two_books", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", "param...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_sum_of_two_books(t, test_cases):\n \"\"\"\n Determine the maximum possible sum of weights of two books for each test case.\n \n Parameters:\n ...
trial_gpt4o_1
{ "original_instruction": "Bob is organizing his library, which contains $n$ books. Each book has a positive integer weight $w_i$. Bob wants to move exactly two books at a time into a box, such that the sum of the weights of these two books is maximized. Each book can be moved into the box only once.\n\nDetermine the...
0.6058
Taco_60219
C
[ "max_sum_of_two_books", "parse_input", "max_sum_weights" ]
3
[ [ "max_sum_weights", "max_sum_of_two_books" ], [ "max_sum_weights", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
0db5ad2370c322fd0a8e25d55e6c69adde54df07
32a911839c71b4823cb3c3ee7b4e3b757de6d2e6
v1.0
complete
Taco
Taco_60063_C
from typing import List def twist_sort(arr: List[int]) -> List[int]: """Sorts the array using the Twist Sort algorithm. The Twist Sort algorithm sorts pairs of adjacent elements and iteratively merges these pairs. Args: arr (List[int]): A list of n integers to be sorted. Returns: ...
def twist_sort(arr): """ Sorts the array using the Twist Sort algorithm. """ n = len(arr) if n < 2: return arr[:] # Step 1: Sort adjacent pairs sorted_pairs = [] for i in range(0, n - 1, 2): if arr[i] > arr[i + 1]: sorted_pairs.append((arr[i + 1], arr[i])...
from solution import twist_sort def test_twist_sort_basic(): assert twist_sort([4, 3, 2, 8, 1, 5]) == [1, 2, 3, 4, 5, 8] def test_twist_sort_with_odd_elements(): assert twist_sort([10, 7, 5, 2, 9]) == [2, 5, 7, 9, 10] def test_twist_sort_single_element(): assert twist_sort([1]) == [1] def test_twist_sor...
[ { "docstring": "Sorts the array using the Twist Sort algorithm.", "function_declaration": "def twist_sort(arr):", "function_name": "twist_sort", "parameter_list": "(arr)" }, { "docstring": "Merges two sorted pairs into one.", "function_declaration": "def _merge(pair1, pair2):", "func...
[ 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 twist_sort(arr):\n \"\"\"\n Sorts the array using the Twist Sort algorithm.\n \"\"\"\n n = len(arr)\n if n < 2:\n return arr[:]\n \n ...
trial_gpt4o_0
{ "original_instruction": "Problem statement:\n\nYou are given the task of developing a new sorting algorithm named \"Twist Sort\". This algorithm sorts an array of n integers in a unique way. Instead of sorting the entire array, Twist Sort sorts pairs of adjacent elements and iteratively merges these pairs.\n\nHere'...
0.657183
Taco_60063
C
[ "twist_sort", "_merge" ]
2
[ [ "twist_sort", "_merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
876eabe8eb89731c8461f69c779b9e785952f9c8
f6f738146c6c92c866e7d603c4e96511c282152f
v1.0
complete
Taco
Taco_60171_C
from typing import List def minimum_moves_to_deliver_package(grid: List[str], n: int, m: int) -> int: """ Determine the minimum number of moves required for the drone to reach the destination, or return -1 if it's impossible. Arguments: grid: List of strings representing the warehouse layout. ...
from collections import deque def minimum_moves_to_deliver_package(grid, n, m): """ Determine the minimum number of moves required for the drone to reach the destination, or return -1 if it's impossible. Arguments: grid: List of strings representing the warehouse layout. n: Number of rows ...
def test_minimum_moves_to_deliver_package(): # Test Case 1 layout = [ ".....", ".***.", ".....", ".***.", ".....", ] assert execute_minimum_moves(5, 5, layout) == 8 # Test Case 2 layout = [ ".***", "*...", "....", ] ass...
[ { "docstring": "Determine the minimum number of moves required for the drone to reach the destination,\nor return -1 if it's impossible.\n\nArguments:\ngrid: List of strings representing the warehouse layout.\nn: Number of rows in the grid.\nm: Number of columns in the grid.\n\nReturns:\nint: Minimum number of ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef minimum_moves_to_deliver_package(grid, n, m):\n \"\"\"\n Determine the minimum number of moves required for the drone to...
trial_gpt4o_0
{ "original_instruction": "You are tasked to develop a drone delivery system for a warehouse. The warehouse layout is represented as a grid with `n` rows and `m` columns. Each cell in the grid can either be empty or contain an obstacle. A drone can move between adjacent cells (up, down, left, right) if there's no obs...
0.575156
Taco_60171
C
[ "minimum_moves_to_deliver_package", "execute_minimum_moves" ]
2
[ [ "execute_minimum_moves", "minimum_moves_to_deliver_package" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b706925ae0868ee7c78b467bc0818b3b763b4fbf
4ec49eccc27cbf284b063d85bad6b5a91bcdc19c
v1.0
complete
Taco
Taco_60343_C
def rotate_matrix_90_degrees(matrix): """ Rotates a given matrix 90 degrees clockwise. :param matrix: A list of lists representing the matrix. :return: A list of lists representing the rotated matrix. """ pass def transform_input(input_str): """ Transforms the input string into the...
def rotate_matrix_90_degrees(matrix): """ Rotates a given matrix 90 degrees clockwise. :param matrix: A list of lists representing the matrix. :return: A list of lists representing the rotated matrix. """ if not matrix: return [] n, m = len(matrix), len(matrix[0]) rotated_ma...
from solution import rotate_matrix_90_degrees, transform_input, matrix_rotation def test_rotate_matrix_90_degrees(): assert rotate_matrix_90_degrees([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) == [[9, 5, 1], [10, 6, 2], [11, 7, 3], [12, 8, 4]] assert rotate_matrix_90_degrees([[1]]) == [[1]] assert rotat...
[ { "docstring": "Rotates a given matrix 90 degrees clockwise.\n\n:param matrix: A list of lists representing the matrix.\n:return: A list of lists representing the rotated matrix.", "function_declaration": "def rotate_matrix_90_degrees(matrix):", "function_name": "rotate_matrix_90_degrees", "paramete...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_matrix_90_clockwise(matrix):\n \"\"\"\n Rotates the given matrix 90 degrees clockwise and returns the rotated matrix.\n \n :param matrix: Li...
trial_gpt4o_2
{ "original_instruction": "Implement a function for matrix rotation.\n\nInput Format:\nFirst line contains two integers n and m denoting the dimensions of the matrix (n rows and m columns).\nNext n lines contain m space-separated integers each representing matrix elements.\n\nOutput Format:\nPrint the matrix after ro...
0.599882
Taco_60343
C
[ "rotate_matrix_90_degrees", "transform_input", "matrix_rotation" ]
3
[ [ "matrix_rotation", "rotate_matrix_90_degrees" ], [ "matrix_rotation", "transform_input" ] ]
2
[]
false
[]
false
pytest
true
[]
true
70fb31dd59c55c7d20ff714db7eac2f8fd94f8fc
8acb527eeb4c23981abab852c637fe2af21c616c
v1.0
complete
Taco
Taco_60280_C
from typing import List, Tuple, Union def minimum_cost_to_connect_all_districts(n: int, m: int, edges: List[Tuple[int, int, int]]) -> Union[int, str]: """ Determines the minimum cost to connect all districts under given constraints, or determine if it’s impossible. Args: n : int : The number of distr...
def find(parent, i): while parent[i] != i: i = parent[i] return i def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent[root_y] = root_x else: ...
import pytest from solution import minimum_cost_to_connect_all_districts def test_sample_input_1(): n, m, e = 4, 2, 5 edges = [(0, 1, 10), (0, 2, 6), (0, 3, 5), (1, 2, 15), (2, 3, 4)] assert minimum_cost_to_connect_all_districts(n, m, edges) == 19 def test_sample_input_2(): n, m, e = 4, 1, 4 edges...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 1, 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 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\...
trial_gpt4o_2
{ "original_instruction": "**Connection Network Optimization**\n\nYou are tasked with designing an optimal network for a new city. The city administration has a unique requirement: they want the entire city to be interconnected, but they want to minimize the overall cost of laying down the roads that form the network...
0.668588
Taco_60280
C
[ "find", "union", "minimum_cost_to_connect_all_districts" ]
3
[ [ "minimum_cost_to_connect_all_districts", "find" ], [ "minimum_cost_to_connect_all_districts", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
a2d41b14ec344722956e3db5ac07c655da90602e
9a5e814b61046f1bf08817325c0143e437ac46e4
v1.0
complete
Taco
Taco_60191_C
from typing import List, Tuple def is_perfect_circle(flight_points: List[Tuple[int, int]]) -> str: """ Determine if the given points form a perfect circle centered at the origin. Args: flight_points: A list of tuples containing the coordinates of the flight points. Returns: str: "YES" if the point...
import math def is_perfect_circle(flight_points): distances = [math.sqrt(x**2 + y**2) for x, y in flight_points] return all(abs(d - distances[0]) < 1e-6 for d in distances) def check_circular_paths(test_cases): results = [] for points in test_cases: if is_perfect_circle(points): re...
import pytest from solution import main def test_sample_inputs(): input_str = "2\n4\n1 1\n-1 -1\n-1 1\n1 -1\n3\n0 2\n2 2\n-2 -2" expected_output = "YES\nNO" assert main(input_str) == expected_output def test_all_points_same_distance(): input_str = "1\n4\n3 4\n-3 -4\n-3 4\n3 -4" expected_output = "...
[ { "docstring": null, "function_declaration": "def is_perfect_circle(flight_points):", "function_name": "is_perfect_circle", "parameter_list": "(flight_points)" }, { "docstring": null, "function_declaration": "def check_circular_paths(test_cases):", "function_name": "check_circular_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 math\n\ndef is_perfect_circle(points):\n \"\"\"\n Given a list of points, determines if all points lie on a circle centered at the origin.\n \"\"\"...
trial_gpt4o_2
{ "original_instruction": "A park ranger is tracking the migration of a certain bird species. The birds migrate according to a pattern defined by \"flight points\", which are specific coordinates in a 2D plane that the birds touch upon during their journey. \n\nThe ranger has observed and recorded these flight points...
0.579131
Taco_60191
C
[ "is_perfect_circle", "check_circular_paths", "parse_input", "main" ]
4
[ [ "check_circular_paths", "is_perfect_circle" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
e807c423e739862ff17871c1db710707f0b5c05d
fdf2176c614512ce4b60421622de57765dfb91be
v1.0
complete
Taco
Taco_60377_C
def can_split_into_equal_halves(n: int, arr: List[int]) -> str: """ Determines if the array can be rearranged to have equal sums in its two halves. >>> can_split_into_equal_halves(4, [1, 1, 2, 2]) == "YES" >>> can_split_into_equal_halves(5, [1, 2, 3, 4, 5]) == "NO" >>> can_split_into_equal_halves(6, [3,...
from itertools import combinations def can_split_into_equal_halves(n, arr): """ Determines if the array can be rearranged to have equal sums in its two halves. """ if n % 2 != 0: return "NO" half = n // 2 total_sum = sum(arr) if total_sum % 2 != 0: return "NO" ...
from solution import can_split_into_equal_halves, process_input def test_can_split_into_equal_halves(): assert can_split_into_equal_halves(4, [1, 1, 2, 2]) == "YES" assert can_split_into_equal_halves(5, [1, 2, 3, 4, 5]) == "NO" assert can_split_into_equal_halves(6, [3, 3, 3, 3, 6, 6]) == "YES" assert c...
[ { "docstring": "Determines if the array can be rearranged to have equal sums in its two halves.", "function_declaration": "def can_split_into_equal_halves(n, arr):", "function_name": "can_split_into_equal_halves", "parameter_list": "(n, arr)" }, { "docstring": "Determines if any subset of nu...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef can_split_into_equal_halves(n, arr):\n \"\"\"\n Determines if the array can be rearranged to have equal sums in its...
trial_gpt4o_0
{ "original_instruction": "Given a list of n integers, you have to determine if you can rearrange the list so that the sum of the first half of the list is equal to the sum of the second half. If the number of elements in the list is odd, it is not possible to split the list into two equal halves, so the answer shoul...
0.621873
Taco_60377
C
[ "can_split_into_equal_halves", "sum_possible", "process_input" ]
3
[ [ "can_split_into_equal_halves", "sum_possible" ], [ "process_input", "can_split_into_equal_halves" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
16df54d6f3b69288444b6a91d1b8b16c36ae2718
a5bbb0a7129bd749d1277ea24c723e4a8e32310f
v1.0
complete
Taco
Taco_60137_C
def paint_hex_grid(n: int, m: int, edges: List[Tuple[int, int]]) -> str: """ Determines whether it is possible to paint a hexagonal grid such that no two adjacent hexagons have the same color. If it is possible, returns "Possible" followed by a configuration string of length n where each character is eith...
def is_bipartite(graph, n): color = [-1] * n def bfs(source): queue = [source] color[source] = 0 while queue: node = queue.pop(0) for neighbor in graph[node]: if color[neighbor] == -1: color[neighbor] = 1 - color[node] ...
from solution import paint_hex_grid def test_example_1(): n = 6 m = 7 edges = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 5), (4, 6), (5, 6)] result = paint_hex_grid(n, m, edges) assert result.startswith("Possible") def test_example_2(): n = 4 m = 5 edges = [(1, 2), (2, 3), (3, 1), (1, 4), (3...
[ { "docstring": null, "function_declaration": "def is_bipartite(graph, n):", "function_name": "is_bipartite", "parameter_list": "(graph, n)" }, { "docstring": null, "function_declaration": "def paint_hex_grid(n, m, edges):", "function_name": "paint_hex_grid", "parameter_list": "(n...
[ 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_bipartite(graph, n):\n \"\"\"\n Function to check if the given graph can be colored with 2 colors\n \"\"\"\n color = [-1] * n\n for start in ...
trial_gpt4o_4
{ "original_instruction": "Problem Statement\n\nAlex is a digital artist who enjoys working with hexagonal grids. He wants to create a program that can help him fill these grids with colors. Each hexagon in the grid can be painted either \"red\" or \"blue\". The grid is represented by an arrangement of nodes, with ea...
0.583015
Taco_60137
C
[ "is_bipartite", "paint_hex_grid" ]
2
[ [ "paint_hex_grid", "is_bipartite" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bb329ce21349a711868a2912bda29d76b6785161
bbea12a113c4e000c122836f345b9fb9190a4ca5
v1.0
complete
Taco
Taco_60385_C
def parse_input(data: str): """Parses the input data and returns it in a structured format. >>> parse_input("3 2\n1 500\n2 1000\n3 300\n5 1 100\n3 2 250\n0 0") [ ([(1, 500), (2, 1000), (3, 300)], [(5, 1, 100), (3, 2, 250)]) ] """ def compute_planks(inventory: List[Tuple[int, int]], orders: ...
def parse_input(data): lines = data.strip().split('\n') index = 0 result = [] while index < len(lines): I, J = map(int, lines[index].split()) if I == 0 and J == 0: break index += 1 inventory = [] for i in range(I): wi, li = map(int...
def test_parse_input(): data = "3 2\n1 500\n2 1000\n3 300\n5 1 100\n3 2 250\n0 0" expected_output = [ ([(1, 500), (2, 1000), (3, 300)], [(5, 1, 100), (3, 2, 250)]) ] assert parse_input(data) == expected_output def test_compute_planks(): inventory = [(1, 500), (2, 1000), (3, 300)] orders...
[ { "docstring": null, "function_declaration": "def parse_input(data):", "function_name": "parse_input", "parameter_list": "(data)" }, { "docstring": null, "function_declaration": "def compute_planks(inventory, orders):", "function_name": "compute_planks", "parameter_list": "(inven...
[ 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 calculate_wood_planks(inventory, orders):\n \"\"\"\n Given the inventory and orders, calculate the number of wood planks necessary\n to fulfill each o...
trial_gpt4o_5
{ "original_instruction": "FurniCo is a company that sells handcrafted furniture. They receive orders for some pieces of furniture which need to be made from specific wood planks available in their inventory. Each piece of furniture is made from one or more types of wood, and each piece must use exactly the specified...
0.579069
Taco_60385
C
[ "parse_input", "compute_planks", "get_wood_planks", "format_output" ]
4
[ [ "get_wood_planks", "compute_planks" ], [ "get_wood_planks", "parse_input" ] ]
2
[ "parse_input", "format_output" ]
false
[]
false
pytest
false
[]
true
1e3fc268eddba02dcf6834924cbc7ebc807cffb4
e169ac5afedd95029b6e3074b683d1b0168f524e
v1.0
complete
Taco
Taco_60313_C
from typing import List, Tuple def find_employees_on_date(P: int, W: int, projects: List[Tuple[str, str, str]], work_periods: List[Tuple[str, str, str, str]], Q: int, queries: List[str]) -> List[List[str]]: """ Given projects and work periods, find the employee IDs working on projects on specific dates. ...
import datetime from collections import defaultdict def parse_date(date_str): return datetime.datetime.strptime(date_str, '%Y-%m-%d').date() def find_employees_on_date(P, W, projects, work_periods, Q, queries): project_periods = {} for project in projects: project_id, start_str, end_str = projec...
import pytest from solution import find_employees_on_date def test_single_project_single_period(): assert find_employees_on_date( 2, 4, [["P1", "2023-01-01", "2023-12-31"], ["P2", "2024-01-01", "2024-12-31"]], [["E1", "P1", "2023-01-10", "2023-01-20"], ["E2", "P1", "2023-01-15", "2023-02-1...
[ { "docstring": null, "function_declaration": "def parse_date(date_str):", "function_name": "parse_date", "parameter_list": "(date_str)" }, { "docstring": null, "function_declaration": "def find_employees_on_date(P, W, projects, work_periods, Q, queries):", "function_name": "find_empl...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import datetime\nfrom collections import defaultdict\n\n\ndef parse_date(date_str):\n return datetime.datetime.strptime(date_str, '%Y-%m-%d').date()\n\n\ndef fi...
trial_gpt4o_0
{ "original_instruction": "In a software company, there are several projects, each with a unique project ID. Each project has a starting and ending date, represented as strings in the format \"YYYY-MM-DD\". There are also several employees, each working on one or more projects during given time periods, also specifie...
0.640153
Taco_60313
C
[ "parse_date", "find_employees_on_date" ]
2
[ [ "find_employees_on_date", "parse_date" ] ]
1
[]
false
[]
false
pytest
true
[]
true
169b6c89cc7f40f3e7f25d8ddae7fed3cb622e24
ebc48af914f768dc5d2d8b6777f79ccbd57f7c1b
v1.0
complete
Taco
Taco_60362_C
def schedule_tournament(n: int): """ Schedules a sports tournament with n players where no pair plays more than once. Each player plays in every round. Args: n: int - Number of players (2 ≤ n ≤ 100) Returns: - If possible, return "YES" followed by the tournament schedule with n/2 lines. ...
def schedule_tournament(n): if n % 2 != 0 or n < 2 or n > 100: return ("NO",) rounds = [] players = list(range(1, n + 1)) for i in range(n - 1): round_matches = [] for j in range(n // 2): player1 = players[j] player2 = players[n - 1 - j] ...
from solution import schedule_tournament, format_schedule_tournament def test_schedule_tournament_4(): assert format_schedule_tournament(4) == "YES\n1 4 2 3\n1 3 4 2\n1 2 3 4" def test_schedule_tournament_6(): assert format_schedule_tournament(6) == "YES\n1 6 2 5 3 4\n1 5 6 4 2 3\n1 4 5 3 6 2\n1 3 4 2 5 6\n1 ...
[ { "docstring": null, "function_declaration": "def schedule_tournament(n):", "function_name": "schedule_tournament", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def format_schedule_tournament(n):", "function_name": "format_schedule_tournament", "parame...
[ 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 schedule_tournament(n):\n if n % 2 != 0:\n return \"NO\"\n \n schedule = []\n \n players = list(range(1, n + 1))\n \n for i in rang...
trial_gpt4o_1
{ "original_instruction": "There is a sports tournament with n players. Each player can play against only one other player in each round. You are tasked with scheduling the matches in such a way that each player gets to play in every round. Moreover, no player should play against the same player more than once throug...
0.700268
Taco_60362
C
[ "schedule_tournament", "format_schedule_tournament" ]
2
[ [ "format_schedule_tournament", "schedule_tournament" ] ]
1
[]
false
[]
false
pytest
true
[]
true
44f2e1ece622aec6cb6e8ff01774ad15a4469d6d
834842d0aa66d10513e7c8d6c0f9d5ed8dafe013
v1.0
complete
Taco
Taco_60383_C
def find_largest_sum(grid): """ Finds the greatest sum of any contiguous subgrid within the given grid. Uses dynamic programming approach similar to Kadane's algorithm for 2D arrays. >>> grid = [ ... [1, 2, -1, -4, -20], ... [-8, -3, 4, 2, 1], ... [3, 8, 10, 1, 3], ... [-4, ...
def find_largest_sum(grid): """ Finds the greatest sum of any contiguous subgrid within the given grid. Uses dynamic programming approach similar to Kadane's algorithm for 2D arrays. """ if not grid or not grid[0]: return 0 rows, cols = len(grid), len(grid[0]) max_sum = float('-inf'...
from solution import find_largest_sum def test_find_largest_sum_basic(): grid = [ [1, 2, -1, -4, -20], [-8, -3, 4, 2, 1], [3, 8, 10, 1, 3], [-4, -1, 1, 7, -6] ] assert find_largest_sum(grid) == 29 def test_find_largest_sum_single_element(): grid = [ [1] ] ...
[ { "docstring": "Finds the greatest sum of any contiguous subgrid within the given grid.\nUses dynamic programming approach similar to Kadane's algorithm for 2D arrays.", "function_declaration": "def find_largest_sum(grid):", "function_name": "find_largest_sum", "parameter_list": "(grid)" }, { ...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def kadane(arr):\n \"\"\"\n Helper function to find the maximum sum of any contiguous subarray in a 1D array.\n \"\"\"\n max_sum = current_sum = arr[0]...
trial_gpt4o_1
{ "original_instruction": "- You have been provided with a grid filled with numbers. Your task is to write a function `find_largest_sum(grid)` that finds the greatest sum of any contiguous subgrid within the given grid. A subgrid is defined as a rectangular section of the grid.\n\nGiven a grid as follows:\n```\ngrid ...
0.64198
Taco_60383
C
[ "find_largest_sum", "kadane" ]
2
[ [ "find_largest_sum", "kadane" ] ]
1
[]
false
[]
false
pytest
true
[]
true
60b79fea824bfb6d9f533ac14c643a5f6e4ae7aa
2b74593a93133998914f795dc391cd9ae9ca97b5
v1.0
complete
Taco
Taco_60500_C
def robovac_path(w, h, n, obstacles): """ Given the dimensions of the room, the number of obstacles and their positions, this function returns the path taken by the RoboVac. Args: w (int): Width of the room. h (int): Height of the room. n (int): Number of obstacles. obstacles (list ...
def robovac_path(w, h, n, obstacles): """ Given the dimensions of the room, the number of obstacles and their positions, this function returns the path taken by the RoboVac. Args: w (int): Width of the room. h (int): Height of the room. n (int): Number of obstacles. obstacles (list of t...
def test_robovac_path_no_obstacles(): w, h = 4, 3 n = 0 obstacles = [] result = robovac_path(w, h, n, obstacles) expected = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (4, 1), (4, 2), (4, 3), (3, 3), (2, 3), (1, 3), (0, 3), (0, 2), (0, 1)] for i in range(len(expected)): assert result[i] == ...
[ { "docstring": "Given the dimensions of the room, the number of obstacles and their positions,\nthis function returns the path taken by the RoboVac.\n\nArgs:\nw (int): Width of the room.\nh (int): Height of the room.\nn (int): Number of obstacles.\nobstacles (list of tuples): List containing the coordinates of ...
[ 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 clean_room(w, h, n, obstacles):\n directions = [(1, 0), (0, 1), (-1, 0), (0, -1)] # right, up, left, down\n obstacles_set = set(obstacles)\n x, y = 0...
trial_gpt4o_1
{ "original_instruction": "You have been hired to design the control system for an autonomous vacuum cleaner, RoboVac, that operates in a rectangular room. RoboVac moves in straight lines and changes direction only when it encounters an obstacle or the boundary of the room. The room may contain multiple stationary ob...
0.664118
Taco_60500
C
[ "robovac_path", "print_robovac_path" ]
2
[ [ "print_robovac_path", "robovac_path" ] ]
1
[]
false
[]
false
pytest
false
[]
true
ee5b08fe2483925d73755958bc2154317ac62bc5
e36a24219372ba9194bb18b4901ecf9c4a3c4699
v1.0
complete
Taco
Taco_60480_C
def find_possible_k_m_pairs(n): """ Given an integer n, this function returns all pairs (k, m) such that k * m = n. If no such pairs exist, it returns an empty list. >>> find_possible_k_m_pairs(12) [(1, 12), (2, 6), (3, 4), (4, 3), (6, 2), (12, 1)] >>> find_possible_k_m_pairs(15) [(1, 1...
def find_possible_k_m_pairs(n): """ Given an integer n, this function returns all pairs (k, m) such that k * m = n. If no such pairs exist, it returns an empty list. """ pairs = [] for k in range(1, int(n**0.5) + 1): if n % k == 0: pairs.append((k, n // k)) if k !...
from solution import find_possible_k_m_pairs, solve def test_find_possible_k_m_pairs_with_12(): assert find_possible_k_m_pairs(12) == [(1, 12), (2, 6), (3, 4), (4, 3), (6, 2), (12, 1)] def test_find_possible_k_m_pairs_with_15(): assert find_possible_k_m_pairs(15) == [(1, 15), (3, 5), (5, 3), (15, 1)] def tes...
[ { "docstring": "Given an integer n, this function returns all pairs (k, m) such that k * m = n.\nIf no such pairs exist, it returns an empty list.", "function_declaration": "def find_possible_k_m_pairs(n):", "function_name": "find_possible_k_m_pairs", "parameter_list": "(n)" }, { "docstring"...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_bridge_pairs(t, cases):\n \"\"\"\n Find all possible pairs (k, m) such that k * m = n for a given number of planks n.\n \n Parameters:\n t ...
trial_gpt4o_1
{ "original_instruction": "A wealthy eccentric has decided to build an elaborate network of bridges in his grand estate. He has $n$ wooden planks available and wants to use them to construct $k$ identical bridges. Each bridge is made up of exactly $m$ planks. The eccentric wants to use all $n$ planks and ensure the b...
0.637334
Taco_60480
C
[ "find_possible_k_m_pairs", "solve" ]
2
[ [ "solve", "find_possible_k_m_pairs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c091bb8efd695d00f78ec006f74e9f088c4f8556
2c2331511756a603ee5e45fa8d6da05b6ffc82ef
v1.0
complete
Taco
Taco_60476_C
from typing import List def min_rounds_return_to_initial(N: int, K: int, positions: List[int]) -> int: """ Determine the smallest number of rounds required for all runners to return to their initial positions. >>> min_rounds_return_to_initial(3, 5, [1, 3, 5]) 5 >>> min_rounds_return_to_initial(4, 6, [2...
import math from functools import reduce def gcd(a, b): while b: a, b = b, a % b return a def lcm(x, y): return x * y // gcd(x, y) def min_rounds_return_to_initial(N, K, positions): def steps_to_return(pos, K): # Since it's a circle, if pos is at a[i] it should return after K steps. ...
def test_case_1(): assert min_rounds_return_to_initial(3, 5, [1, 3, 5]) == 5 def test_case_2(): assert min_rounds_return_to_initial(4, 6, [2, 4, 6, 1]) == 6 def test_case_3(): assert min_rounds_return_to_initial(5, 7, [1, 2, 3, 4, 5]) == 7 def test_case_4(): assert min_rounds_return_to_initial(4, 12,...
[ { "docstring": null, "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def lcm(x, y):", "function_name": "lcm", "parameter_list": "(x, y)" }, { "docstring": null, "function_dec...
[ 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": "import math\nfrom functools import reduce\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(x, y):\n return x * y // gcd(x, y)\n...
trial_gpt4o_0
{ "original_instruction": "You are managing a relay race track, where N runners are numbered 1 through N and arranged in a circle. The runners are initially positioned at coordinates on the track denoted by an array a, where a[i] is the starting position of the i-th runner, and all ai are distinct integers such that ...
0.648337
Taco_60476
C
[ "gcd", "lcm", "min_rounds_return_to_initial", "main" ]
4
[ [ "lcm", "gcd" ], [ "min_rounds_return_to_initial", "lcm" ] ]
2
[]
false
[]
false
pytest
false
[]
true
fb6e947a424e0e2c47333f836873cb12d5cfaaae
85888ee35bcff94fda6ef7e7c178e37da8958790
v1.0
complete
Taco
Taco_60577_C
from typing import List def rotate_matrix_90(matrix: List[List[int]]) -> List[List[int]]: """ Rotates the given matrix 90 degrees clockwise. >>> rotate_matrix_90([ ... [1, 2, 3], ... [4, 5, 6], ... [7, 8, 9] ... ]) [ [7, 4, 1], [8, 5, 2], [9, 6, 3] ]...
def rotate_matrix_90(matrix): """ Rotates the given matrix 90 degrees clockwise. """ return [list(reversed(col)) for col in zip(*matrix)] def max_submatrix_sum(matrix, n): """ Finds the maximum sum of an NxN submatrix within the given matrix. """ r = len(matrix) c = len(matrix[0]) ...
from solution import rotate_matrix_90, max_submatrix_sum, sherlockAndMaxSum def test_rotate_matrix_90(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] rotated_matrix = rotate_matrix_90(matrix) expected_matrix = [ [7, 4, 1], [8, 5, 2], [9, 6, 3] ] a...
[ { "docstring": "Rotates the given matrix 90 degrees clockwise.", "function_declaration": "def rotate_matrix_90(matrix):", "function_name": "rotate_matrix_90", "parameter_list": "(matrix)" }, { "docstring": "Finds the maximum sum of an NxN submatrix within the given matrix.", "function_de...
[ 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 rotate_matrix_90_degrees_clockwise(matrix):\n \"\"\"\n Rotates the given matrix by 90 degrees clockwise.\n \"\"\"\n return [list(reversed(row)) for...
trial_gpt4o_1
{ "original_instruction": "Watson presents Sherlock with a matrix of integers. Sherlock needs to find a submatrix of size NxN within the given matrix such that the sum of its elements is the largest possible. \n\nHowever, to make things more interesting for Sherlock, Watson allows the matrix to be rotated 90 degrees ...
0.527611
Taco_60577
C
[ "rotate_matrix_90", "max_submatrix_sum", "sherlockAndMaxSum" ]
3
[ [ "sherlockAndMaxSum", "max_submatrix_sum" ], [ "sherlockAndMaxSum", "rotate_matrix_90" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ddd197c37a5a5ed6972582a96e8dafb255355d04
72724dc861066b361533ef19c0646ca6ef64e3e7
v1.0
complete
Taco
Taco_60635_C
def find_earliest_chat_room(N: int, chat_room_data: List[Tuple[int, int]]) -> int: """ Identifies and returns the chat room with the earliest (oldest) last active timestamp. Args: N (int): Number of chat rooms the employee is part of. chat_room_data (List[Tuple[int, int]]): List of tuples where eac...
def earliest_chat_room(chat_rooms): """ Returns the chat room id with the earliest last active timestamp. In case of ties, returns the smallest chat room id among the tied ones. Args: chat_rooms (list of tuples): a list where each tuple contains two integers, ci...
import pytest from solution import find_earliest_chat_room def test_single_chat_room(): assert find_earliest_chat_room(1, [(101, 1610000000)]) == 101 def test_multiple_chat_rooms(): assert find_earliest_chat_room(3, [(101, 1610000000), (102, 1610005000), (103, 1609999999)]) == 103 def test_tie_on_timestamp()...
[ { "docstring": "Returns the chat room id with the earliest last active timestamp.\nIn case of ties, returns the smallest chat room id among the tied ones.\n\nArgs:\nchat_rooms (list of tuples): a list where each tuple contains two integers,\n ci (chat room id) and ti (last active tim...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_earliest_chat_room(rooms):\n \"\"\"\n Finds the chat room with the earliest last active timestamp.\n \n Parameters:\n rooms (list of tuple)...
trial_gpt4o_2
{ "original_instruction": "A company has decided to revamp its internal communication platform and make some changes to its chat system. The system consists of multiple chat rooms, each identified by an integer id. Employees can join multiple chat rooms and each chat room tracks activity based on the last active time...
0.535237
Taco_60635
C
[ "earliest_chat_room", "find_earliest_chat_room" ]
2
[ [ "find_earliest_chat_room", "earliest_chat_room" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f82c652978610c059a61c68a448905c0b1341811
11a8c8bf231e2a1bf8675cf011ea5f0389640386
v1.0
complete
Taco
Taco_60744_C
def organize_books(T: int, test_cases: List[Tuple[int, List[str]]]) -> List[str]: """ Organize a list of book IDs by sorting them based on sum of digits, number of digits, and lexicographical order. >>> organize_books(2, [(3, ["103", "002", "21"]), (4, ["123", "234", "345", "456"])]) ["002 21 103", "123 234...
def sum_of_digits(s): return sum(int(d) for d in s) def custom_sort_book_ids(book_ids): return sorted(book_ids, key=lambda x: (sum_of_digits(x), len(x), x)) def organize_books(T, test_cases): results = [] for i in range(T): N = test_cases[i][0] book_ids = test_cases[i][1] sorte...
from solution import organize_books def test_organize_books_case1(): T = 2 test_cases = [ (3, ["103", "002", "21"]), (4, ["123", "234", "345", "456"]) ] assert organize_books(T, test_cases) == [ "002 21 103", "123 234 345 456" ] def test_organize_books_case2(): ...
[ { "docstring": null, "function_declaration": "def sum_of_digits(s):", "function_name": "sum_of_digits", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def custom_sort_book_ids(book_ids):", "function_name": "custom_sort_book_ids", "parameter_list": "(book...
[ 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 digit_sum(x):\n return sum(int(c) for c in x)\n\ndef custom_sort(book_ids):\n return sorted(book_ids, key=lambda x: (digit_sum(x), len(x), x))\n\ndef sor...
trial_gpt4o_2
{ "original_instruction": "The school library wants to organize its books such that it’s easy to find the right book by its unique ID number. For this, they decided to sort all books using a custom sorting algorithm based on the digits of the IDs.\n\nThe sorting algorithm works as follows:\n1. A book ID is considered...
0.571021
Taco_60744
C
[ "sum_of_digits", "custom_sort_book_ids", "organize_books" ]
3
[ [ "custom_sort_book_ids", "sum_of_digits" ], [ "organize_books", "custom_sort_book_ids" ] ]
2
[]
false
[]
false
pytest
true
[]
true
13e2ad6d15f0296e35ef7fc3b03cc012d99d6f23
52ae5488259401710591dd80dda8caac656bc145
v1.0
complete
Taco
Taco_60676_C
def is_prime(num: int) -> bool: """ Helper function to check if a number is a prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(17) == True >>> is_prime(18) == False """ def can_be_expressed_as_sum_of_two_primes(n: int) -> str: """ ...
def is_prime(num): """ Helper function to check if a number is a prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def...
from solution import can_be_expressed_as_sum_of_two_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_expressed_as_sum_of_two_primes_yes(): assert can_be_expr...
[ { "docstring": "Helper function to check if a number is a prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns \"YES\" if n can be expressed as the sum of two prime numbers.\nOtherwise, returns \"NO\".", ...
[ 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 <= 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": "Design a function that checks if a given integer number can be expressed as the sum of two prime numbers.\n\nInput\n\nAn integer number n (1 ≤ n ≤ 10^9).\n\nOutput\n\nPrint \"YES\" if n can be expressed as the sum of two prime numbers. Otherwise, print \"NO\".\n\nExamples\n\nInput\n\n34\n\n...
0.807243
Taco_60676
C
[ "is_prime", "can_be_expressed_as_sum_of_two_primes" ]
2
[ [ "can_be_expressed_as_sum_of_two_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
257184b3a5058e58fbee91bf3c3849604f783761
8c34a788abde79e36c3aa579ee85d82a6118158f
v1.0
complete
Taco
Taco_60512_C
def main(input_str: str) -> str: """ Given an input string that describes the number of test cases, and for each test case, the number of houses and roads, followed by the connecting roads and their lengths, determine the minimum total length of the roads that need to be decorated. Args: ...
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...
from solution import main def test_single_case(): input_str = "1\n4 5\n1 2 3\n2 3 4\n3 4 5\n4 1 2\n1 3 7\n" output_str = "9" assert main(input_str) == output_str def test_multiple_cases(): input_str = "3\n4 5\n1 2 3\n2 3 4\n3 4 5\n4 1 2\n1 3 7\n5 7\n1 2 1\n2 3 2\n3 4 3\n4 5 4\n1 5 5\n1 3 6\n2 4 7\n3 3...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\n\ndef union(parent, rank, x, y):\n root_x =...
trial_gpt4o_2
{ "original_instruction": "In a small village, there are n houses connected by m roads. Each road connects exactly two houses bidirectionally and has a certain length. The houses and roads form a connected graph.\n\nThe village head has decided to celebrate the village's anniversary by decorating the houses and roads...
0.608217
Taco_60512
C
[ "find", "union", "kruskal_minimum_spanning_tree", "minimum_roads_to_decorate", "process_input", "main" ]
6
[ [ "kruskal_minimum_spanning_tree", "find" ], [ "kruskal_minimum_spanning_tree", "union" ], [ "minimum_roads_to_decorate", "kruskal_minimum_spanning_tree" ], [ "union", "find" ] ]
4
[ "process_input" ]
false
[]
false
pytest
true
[]
true
0f9ac24189a74fb68f4feb213bb0fdbf97bcfb34
af389b2e146256c511fceaec0050faad933ed69f
v1.0
complete
Taco
Taco_60661_C
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def insert(root, key): if root is None: return TreeNode(key) if key < root.val: root.left = insert(root.left, key) else: root.right = insert(root.right, key) ...
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def insert(root, key): if root is None: return TreeNode(key) if key < root.val: root.left = insert(root.left, key) else: root.right = insert(root.right, key) ...
from solution import calculate_sums def test_single_element(): assert calculate_sums([(1, [1])]) == [1] def test_multiple_elements_linear(): assert calculate_sums([(5, [10, 20, 30, 40, 50])]) == [150] def test_multiple_elements_bst(): assert calculate_sums([(3, [5, 3, 8])]) == [16] def test_empty(): ...
[]
[ 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, key):\n self.left = None\n self.right = None\n self.val = key\n\ndef insert(root, key):\n if root i...
trial_gpt4o_2
{ "original_instruction": "Alex is learning about data structures and especially interested in binary trees. After studying the theory, he decided to implement binary search trees (BST) and test their properties. A binary search tree is a binary tree where each node has a key greater than all the keys in its left sub...
0.532393
Taco_60661
C
[ "insert", "sum_bst", "calculate_sums" ]
3
[ [ "calculate_sums", "insert" ], [ "calculate_sums", "sum_bst" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
2794a321f025e560d1e1cabea095945381e87cdf
e64a972ac9bb9feaa8632fa09aa22e06bdfb90ea
v1.0
complete
Taco
Taco_60870_C
def can_form_prime(N: int) -> bool: """ Given a positive integer N, check if it is possible to rearrange its digits to form a prime number. The resulting number must be a prime and must not have leading zeroes. >>> can_form_prime(13) True >>> can_form_prime(41) True >>> can_form_prime(...
from itertools import permutations 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 can_fo...
from solution import can_form_prime def test_can_form_prime_13(): assert can_form_prime(13) == True def test_can_form_prime_41(): assert can_form_prime(41) == True def test_can_form_prime_15(): assert can_form_prime(15) == False def test_can_form_prime_30(): assert can_form_prime(30) == False def t...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def can_form_prime(N):", "function_name": "can_form_prime", "parameter_list": "(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": "from itertools import permutations\n\ndef 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:...
trial_gpt4o_0
{ "original_instruction": "Given a positive integer N, check if it is possible to rearrange its digits to form a prime number. The resulting number must be a prime and must not have leading zeroes.\n\nReturn true if and only if at least one such rearrangement exists.\n\nExample 1:\nInput: 13\nOutput: true\n\nExample ...
0.744132
Taco_60870
C
[ "is_prime", "can_form_prime" ]
2
[ [ "can_form_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6c8e271f35f0d86789f96367defde3e143b2e788
0a81e3f74409f5daa23a233b9e0ea25f328d5de4
v1.0
complete
Taco
Taco_60803_C
def maximalRectangle(matrix: List[List[int]]) -> int: """You are given a binary matrix of size N x M, where each cell contains either a 0 or a 1. Find and return the largest rectangular sub-matrix that contains only 1s. >>> maximalRectangle([ ... [1, 0, 1, 1], ... [1, 0, 1, 1], ... ...
def maximalRectangle(matrix): if not matrix or not matrix[0]: return 0 N, M = len(matrix), len(matrix[0]) max_area = 0 heights = [0] * M for i in range(N): for j in range(M): heights[j] = heights[j] + 1 if matrix[i][j] == 1 else 0 max_area = max(max_area, large...
from solution import maximalRectangle def test_maximalRectangle_regular_case(): matrix = [ [1, 0, 1, 1], [1, 0, 1, 1], [1, 1, 1, 1], [1, 0, 0, 1] ] assert maximalRectangle(matrix) == 6 def test_maximalRectangle_all_zeros(): matrix = [ [0, 0, 0], [0, 0, 0...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "paramete...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximalRectangle(matrix):\n if not matrix or not matrix[0]:\n return 0\n\n N, M = len(matrix), len(matrix[0])\n max_area = 0\n heights = [0]...
trial_gpt4o_0
{ "original_instruction": "You are given a binary matrix of size N x M, where each cell contains either a 0 or a 1. The task is to find and return the largest rectangular sub-matrix that contains only 1s. \n\nInput Format:\n- The first line contains two integers N and M, representing the number of rows and columns in...
0.622623
Taco_60803
C
[ "maximalRectangle", "largestRectangleArea" ]
2
[ [ "maximalRectangle", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2139fcf08e22ee23df098eeb738d0ffd0570241a
7f686b6535240cd2d2940c0e36d6b4e7a2e26c64
v1.0
complete
Taco
Taco_60855_C
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def insert_into_bst(root, val): if not root: return TreeNode(val) if val < root.val: root.left = insert_into_bst(root.left, val) else: root.right = insert_into_bst(root...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def insert_into_bst(root, val): if not root: return TreeNode(val) if val < root.val: root.left = insert_into_bst(root.left, val) else: root.right = insert_into_bst(root...
import pytest from solution import TreeNode, insert_into_bst, build_bst_from_list, inorder_traversal, kth_smallest_element, process_input def test_kth_smallest_element(): # Test with given examples root = build_bst_from_list([5, 3, 8, 1, 4]) assert kth_smallest_element(root, 1) == 1 assert kth_smallest...
[]
[ 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, key):\n self.left = None\n self.right = None\n self.val = key\n\ndef insert(root, key):\n if root i...
trial_gpt4o_2
{ "original_instruction": "Given a binary search tree (BST), you need to find the k-th smallest element in the BST.\n\nA binary search tree is a binary tree in which for each node:\n\n- The left subtree of a node contains only nodes with keys less than the node's key.\n- The right subtree of a node contains only node...
0.539732
Taco_60855
C
[ "insert_into_bst", "build_bst_from_list", "inorder_traversal", "kth_smallest_element", "process_input" ]
5
[ [ "build_bst_from_list", "insert_into_bst" ], [ "kth_smallest_element", "inorder_traversal" ], [ "process_input", "build_bst_from_list" ], [ "process_input", "kth_smallest_element" ] ]
4
[ "process_input" ]
false
[ "TreeNode" ]
true
pytest
true
[]
true
72bb0429f0856b8fc242a12ef5d8ec18a958de86
4f0a58328fefa01e1a7dea629aab5e1544a71b4a
v1.0
complete
Taco
Taco_60658_C
from typing import List, Tuple def find_shortest_paths(n: int, m: int, d: int, roads: List[Tuple[int, int, int]], queries: List[Tuple[int, int]]) -> List[int]: """ Find the shortest path distance between each pair of cities that does not exceed d miles. Parameters: n (int): The number of cities. m (int...
import heapq from collections import defaultdict def dijkstra(n, graph, start): """ Perform Dijkstra's algorithm to find shortest paths from a start node. """ distances = [float('inf')] * n distances[start] = 0 pq = [(0, start)] heapq.heapify(pq) while pq: current_distance, current...
def test_example1(): n, m, d = 4, 5, 6 roads = [(1, 2, 2), (2, 3, 2), (3, 4, 2), (4, 1, 2), (1, 3, 6)] queries = [(1, 3), (1, 4), (2, 4)] expected = [4, 2, 4] assert find_shortest_paths(n, m, d, roads, queries) == expected def test_example2(): n, m, d = 3, 2, 3 roads = [(1, 2, 2), (2, 3, 2)...
[ { "docstring": "Perform Dijkstra's algorithm to find shortest paths from a start node. ", "function_declaration": "def dijkstra(n, graph, start):", "function_name": "dijkstra", "parameter_list": "(n, graph, start)" }, { "docstring": null, "function_declaration": "def find_shortest_paths(...
[ 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 heapq\n\ndef shortest_path_within_limit(n, m, d, roads, queries):\n graph = {i: [] for i in range(1, n + 1)}\n for u, v, l in roads:\n graph[u]...
trial_gpt4o_2
{ "original_instruction": "In a fantasy land, there are n cities connected by m two-way roads. Each road connects two different cities and has a certain length in miles. The king of this land arranges a grand festival in one of the cities and wants citizens from all other cities to travel to the festival city with th...
0.759935
Taco_60658
C
[ "dijkstra", "find_shortest_paths" ]
2
[ [ "find_shortest_paths", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1d3bb8952bc7c4a4a5b365e88661a3f3ec9e747f
adc97ee3ae32561308b74e21d1832a29162871eb
v1.0
complete
Taco
Taco_61453_C
def is_palindrome(s: str) -> bool: """ Check if a given string s is a palindrome. """ def palindrome_decomposition(s: str) -> List[List[str]]: """ Find all possible palindrome decompositions of a given string s. """ def decompose_string(s: str) -> List[List[str]]: """ Generate all possible palindrome deco...
def is_palindrome(s): """ Check if a given string s is a palindrome. """ return s == s[::-1] def palindrome_decomposition(s): """ Find all possible palindrome decompositions of a given string s. The function returns a list of lists, where each list represents a decomposition. """ de...
from solution import decompose_string def test_aab(): result = decompose_string("aab") expected_result = [['a', 'a', 'b'], ['aa', 'b']] assert sorted(result) == sorted(expected_result) def test_racecar(): result = decompose_string("racecar") expected_result = [['r', 'a', 'c', 'e', 'c', 'a', 'r'], ...
[ { "docstring": "Check if a given string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Find all possible palindrome decompositions of a given string s.\nThe function returns a list of lists, w...
[ 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 is_palindrome(s):\n \"\"\"\n Checks if a given string s is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef palindrome_decompositions(s):\n \...
trial_gpt4o_6
{ "original_instruction": "Palindrome Decomposition\n\nA **palindrome** is a string that reads the same backward as forward (e.g., \"madam\", \"racecar\"). Given a string, its **palindrome decomposition** is a way of breaking the string into contiguous substrings such that each substring is a palindrome. Your objecti...
0.803034
Taco_61453
C
[ "is_palindrome", "palindrome_decomposition", "decompose_string" ]
3
[ [ "decompose_string", "palindrome_decomposition" ], [ "palindrome_decomposition", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
275c20c6c3d7da7d91f3481b350e44564d4814f0
06c09aefed0c23f49cf68ffddf7eb17b2ec98472
v1.0
complete
Taco
Taco_61278_C
def is_prime(num: int) -> bool: """ Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(18) False """ def special_sort(n: int, sequence: List[int]) -> List[int]: """ Rearrange the sequence such that all prime...
def is_prime(num): if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def special_sort(n, sequence): primes = [num for num in sequence i...
from solution import is_prime, special_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(18) == False assert is_prime(-5) == False assert is_prime(0) == False assert is_prime(1) == Fals...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def special_sort(n, sequence):", "function_name": "special_sort", "parameter_list": "(n, sequence)" } ]
[ 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 sieve_of_eratosthenes(max_number):\n is_prime = [True for _ in range(max_number+1)]\n p = 2\n while (p * p <= max_number):\n if (is_prime[p] ==...
trial_gpt4o_1
{ "original_instruction": "Arya is learning about prime numbers and came up with a sequence of integers. She wants to know if this sequence can be arranged into a special format. Specifically, she wants to rearrange the sequence such that all prime numbers appear first in ascending order, followed by all non-prime nu...
0.722822
Taco_61278
C
[ "is_prime", "special_sort" ]
2
[ [ "special_sort", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
65acabc47d2042288b8832e413cc8b0517f915b0
d79e7d2a336e25067feedc850cc35a881f9139d9
v1.0
complete
Taco
Taco_61307_C
from typing import List, Tuple def landsville_connectivity(t: int, cases: List[Tuple[int, int, List[Tuple[int, int]]]]) -> List[str]: """ Determines if parks are fully connected and the minimal number of pathways required. >>> landsville_connectivity(2, [(5, 4, [(1, 2), (2, 3), (3, 4), (4, 5)]), (4, 2, [(1, 2)...
from collections import defaultdict def is_connected(P, pathways): graph = defaultdict(list) for u, v in pathways: graph[u].append(v) graph[v].append(u) visited = [False] * (P + 1) def dfs(node): stack = [node] while stack: curr = stack.pop() ...
from solution import landsville_connectivity def test_landsville_sample(): t = 2 cases = [ (5, 4, [(1, 2), (2, 3), (3, 4), (4, 5)]), (4, 2, [(1, 2), (3, 4)]) ] expected = ["YES 4", "NO"] assert landsville_connectivity(t, cases) == expected def test_all_connected_with_extra_paths():...
[ { "docstring": null, "function_declaration": "def is_connected(P, pathways):", "function_name": "is_connected", "parameter_list": "(P, pathways)" }, { "docstring": null, "function_declaration": "def min_pathways_to_connect(P):", "function_name": "min_pathways_to_connect", "parame...
[ 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_connected(P, pathways):\n from collections import deque, defaultdict\n \n if P == 1:\n return True\n \n graph = defaultdict(list)\n ...
trial_gpt4o_1
{ "original_instruction": "Landsville is a town with several parks, each uniquely numbered from 1 to P. Emily is responsible for managing the connectivity between these parks through pathways. A pathway can only connect two parks directly. Landsville undergoes frequent construction, so the connectivity between parks ...
0.582855
Taco_61307
C
[ "is_connected", "min_pathways_to_connect", "solve", "landsville_connectivity" ]
4
[ [ "landsville_connectivity", "solve" ], [ "solve", "is_connected" ], [ "solve", "min_pathways_to_connect" ] ]
3
[]
false
[]
false
pytest
true
[]
true
23a26e47c388db69b0bc78455dcee82bedfb31f9
5bcb48d0c140121e56280001f2dc11af25cfd0ba
v1.0
complete
Taco
Taco_61390_C
from typing import List, Tuple def shortest_travel_time(n: int, m: int, roads: List[Tuple[int, int, int]], k: int, critical_pairs: List[Tuple[int, int]]) -> List[int]: """ Compute the shortest travel time for each critical pair. >>> shortest_travel_time(4, 4, [(1, 2, 4), (2, 3, 3), (3, 4, 2), (1, 4, 10)], 3, [...
import heapq def dijkstra(n, graph, source): dist = [float('inf')] * (n + 1) dist[source] = 0 pq = [(0, source)] while pq: current_distance, u = heapq.heappop(pq) if current_distance > dist[u]: continue for v, weight in graph[u]: di...
def test_example_1(): n, m = 4, 4 roads = [ (1, 2, 4), (2, 3, 3), (3, 4, 2), (1, 4, 10) ] k = 3 critical_pairs = [ (1, 3), (2, 4), (1, 4) ] expected = [7, 5, 9] assert shortest_travel_time(n, m, roads, k, critical_pairs) == expected...
[ { "docstring": null, "function_declaration": "def dijkstra(n, graph, source):", "function_name": "dijkstra", "parameter_list": "(n, graph, source)" }, { "docstring": null, "function_declaration": "def shortest_travel_time(n, m, roads, k, critical_pairs):", "function_name": "shortest_...
[ 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 dijkstra(n, adj, src):\n dist = [float(\"inf\")] * (n + 1)\n dist[src] = 0\n pq = [(0, src)] # (distance, node)\n \n while pq:\...
trial_gpt4o_2
{ "original_instruction": "In a small town, there is a network of roads connecting various houses. The town consists of n houses, numbered from 1 to n, and m roads, each connecting two houses bidirectionally. Each road has a positive integer weight representing the time it takes to travel between the two houses. Resi...
0.715703
Taco_61390
C
[ "dijkstra", "shortest_travel_time" ]
2
[ [ "shortest_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
ed0fcee164bfe06d9c02b584953f96e405cd1c8f
c79ce54453f673b098dce15781732a503b6b6940
v1.0
complete
Taco
Taco_61585_C
def detect_language(word: str) -> str: """ Determine if a string is written in English or not. >>> detect_language("hello") == "English" >>> detect_language("こんにちは") == "Not English" >>> detect_language("world") == "English" >>> detect_language("你好") == "Not English" """ def process_stream(...
def detect_language(word): """ Returns whether the word is in English or not. """ if all('a' <= char <= 'z' or 'A' <= char <= 'Z' for char in word): return "English" return "Not English" def process_stream(stream): """ Processes a stream of words and outputs "English" or "Not Englis...
from solution import detect_language, process_stream def test_detect_language_english(): assert detect_language("hello") == "English" assert detect_language("world") == "English" assert detect_language("HELLO") == "English" assert detect_language("WoRLd") == "English" def test_detect_language_non_engl...
[ { "docstring": "Returns whether the word is in English or not.", "function_declaration": "def detect_language(word):", "function_name": "detect_language", "parameter_list": "(word)" }, { "docstring": "Processes a stream of words and outputs \"English\" or \"Not English\"\nfor each word until...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef detect_language(stream):\n \"\"\"\n Detect if each word in the stream is English or not.\n A word is considered English if it contains on...
trial_gpt4o_2
{ "original_instruction": "Problem Statement:\nYou are tasked with implementing a simple language detector for a text processing system. The system processes a stream of character strings. You need to determine if a string is written in English or not. For simplicity, assume that a string is in English if it contains...
0.556009
Taco_61585
C
[ "detect_language", "process_stream" ]
2
[ [ "process_stream", "detect_language" ] ]
1
[]
false
[]
false
pytest
true
[]
true
db4f43a374dd935ec9fbd6bfb9f79ccbcfa2d0b5
7f82dfb18364c3e54dafebdb8ef08e4af6a521b5
v1.0
complete
Taco
Taco_61648_C
def longest_palindromic_substring_length(s: str) -> int: """ Returns the length of the longest palindromic substring in the given string s. >>> longest_palindromic_substring_length("racecar") 7 >>> longest_palindromic_substring_length("abcdefgh") 1 """ pass def longest_palindromic_subst...
def longest_palindromic_substring_length(s): """ Returns the length of the longest palindromic substring in the given string s. """ n = len(s) if n == 0: return 0 # Initialize a table to store lengths of palindromic substrings dp = [[0] * n for _ in range(n)] max_length...
from solution import longest_palindromic_substring_length_from_input def test_longest_palindromic_substring_length_1(): assert longest_palindromic_substring_length_from_input(7, "racecar") == 7 def test_longest_palindromic_substring_length_2(): assert longest_palindromic_substring_length_from_input(8, "abcdef...
[ { "docstring": "Returns the length of the longest palindromic substring in the given string s.", "function_declaration": "def longest_palindromic_substring_length(s):", "function_name": "longest_palindromic_substring_length", "parameter_list": "(s)" }, { "docstring": null, "function_decl...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_palindromic_substring(n, s):\n \"\"\"\n Returns the length of the longest palindromic substring in the given string.\n \n Args:\n n : in...
trial_gpt4o_2
{ "original_instruction": "Palindromania is a small town that celebrates palindromes with great enthusiasm. A string is called a palindrome if it reads the same backward as forward. One fascinating game in Palindromania involves substrings of a given string. Given a string, the task is to determine the length of the ...
0.770143
Taco_61648
C
[ "longest_palindromic_substring_length", "longest_palindromic_substring_length_from_input" ]
2
[ [ "longest_palindromic_substring_length_from_input", "longest_palindromic_substring_length" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cc5f60b4af2ca30d7fccc24a392b6fa94a021350
4f5d5527dbad3fe811f6bcc4bfcac5b33995299b
v1.0
complete
Taco
Taco_61422_C
def max_product_bitwise(arr): """ Returns the maximum product of any two distinct elements in the array using bitwise operations. """ def solve(test_cases): """ Processes multiple test cases and returns a list of results for each test case. """ def parse_input(input_string): """ Parses...
def max_product_bitwise(arr): """ Returns the maximum product of any two distinct elements in the array using bitwise operations. """ # Initialize first and second largest elements first_largest = second_largest = 0 for num in arr: if num > first_largest: second_largest ...
def test_max_product_bitwise(): input_string = "2\n5\n4 7 2 8 1\n3\n3 6 9\n" expected_output = "56\n54" assert process_input(input_string) == expected_output def test_max_product_bitwise_single_case(): input_string = "1\n4\n1 2 3 4\n" expected_output = "12" assert process_input(input_string) ==...
[ { "docstring": "Returns the maximum product of any two distinct elements in the array using bitwise operations.", "function_declaration": "def max_product_bitwise(arr):", "function_name": "max_product_bitwise", "parameter_list": "(arr)" }, { "docstring": "Processes multiple test cases and re...
[ 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_product_bitwise(arr):\n \"\"\"\n Returns the maximum product of any two distinct elements in the array using bitwise operations.\n \"\"\"\n # I...
trial_gpt4o_0
{ "original_instruction": "Alex is a software engineer who loves bitwise operations. He recently encountered a problem that he couldn't solve, and he needs your help.\n\nProblem is:\n\nGiven an array of integers, find the maximum product of any two distinct elements in the array using only bitwise operations.\n\nFor ...
0.638779
Taco_61422
C
[ "max_product_bitwise", "solve", "parse_input", "process_input" ]
4
[ [ "process_input", "parse_input" ], [ "process_input", "solve" ], [ "solve", "max_product_bitwise" ] ]
3
[ "parse_input", "process_input" ]
false
[]
false
pytest
false
[]
true
56438e80bf067774f5d8ad61fe7094ee0d440fe1
2007e0462ac46cce49d4a1b719e7b0ab25426627
v1.0
complete
Taco
Taco_61593_C
def optimal_bakery_placement(N: int, M: int, roads: List[Tuple[int, int]]) -> int: """ Determine the optimal placement of specified new bakeries to minimize the maximum distance any resident has to travel to get to their nearest bakery. Args: - N: Number of towns. - M: Number of new bakeries to be ...
from collections import deque def find_max_distance_from_bakeries(n, bakeries, roads): def bfs(start): visited = [-1] * n queue = deque([(start, 0)]) visited[start] = 0 while queue: node, dist = queue.popleft() for neighbor in graph[node]: if ...
from solution import optimal_bakery_placement def test_example_1(): assert optimal_bakery_placement(5, 2, [(1, 2), (1, 3), (3, 4), (3, 5)]) == 1 def test_example_2(): assert optimal_bakery_placement(6, 1, [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6)]) == 3 def test_standard_case(): assert optimal_bakery_place...
[ { "docstring": null, "function_declaration": "def find_max_distance_from_bakeries(n, bakeries, roads):", "function_name": "find_max_distance_from_bakeries", "parameter_list": "(n, bakeries, roads)" }, { "docstring": null, "function_declaration": "def optimal_bakery_placement(N, M, roads_...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef bfs_farthest_distance_from_any_node(graph, n):\n \"\"\"Finds the farthest distance from any node in the graph.\"\"\"\n \...
trial_gpt4o_1
{ "original_instruction": "A famous bakery chain is expanding its reach and opening a specific number of new bakeries across various towns in a new region. The towns are interconnected by a set of roads such that there is always a path from any town to any other town. The bakery chain wants to minimize the maximum di...
0.586953
Taco_61593
C
[ "find_max_distance_from_bakeries", "optimal_bakery_placement" ]
2
[ [ "optimal_bakery_placement", "find_max_distance_from_bakeries" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9c25d894113255d2503cad1260bf7cb1951a057d
110bc7cd2e23ec06b4735857c9b6799aa8489ac6
v1.0
complete
Taco
Taco_61164_C
def shortest_path_in_grid(t, test_cases): """Determine the shortest path from the top-left corner to the bottom-right corner of a grid moving through empty cells only. Args: t (int): Number of test cases. test_cases (List[Tuple[int, int, List[str]]]): List of test cases. Each test case contains...
from collections import deque def shortest_path_in_grid(t, test_cases): def bfs(grid, n, m): directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(0, 0, 0)]) # (row, col, distance) visited = [[False] * m for _ in range(n)] visited[0][0] = True while queue: ...
def test_shortest_path_case_1(): input_data = "2\n3 4\n....\n.*..\n....\n4 4\n*..*\n.*.*\n.*.*\n*..*" expected_output = "5\n-1" assert solution(input_data) == expected_output def test_shortest_path_case_2(): input_data = "1\n1 2\n.." expected_output = "1" assert solution(input_data) == expected...
[ { "docstring": null, "function_declaration": "def shortest_path_in_grid(t, test_cases):", "function_name": "shortest_path_in_grid", "parameter_list": "(t, test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", ...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path_in_grid(t, test_cases):\n results = []\n for case in test_cases:\n n, m, grid = case\n if gr...
trial_gpt4o_3
{ "original_instruction": "You are given a grid with $n$ rows and $m$ columns. Each cell contains a character that is either '.' (representing an empty cell) or '*' (representing a blocked cell). You need to determine the the shortest path from the top-left corner of the grid $(1,1)$ to the bottom-right corner $(n,m)...
0.704678
Taco_61164
C
[ "shortest_path_in_grid", "parse_input", "solution" ]
3
[ [ "solution", "parse_input" ], [ "solution", "shortest_path_in_grid" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
16654b2b48d0627995acbeac93cc352e35efad46
9af68f8c2ffa44e9c22fffca6273bab15b442523
v1.0
complete
Taco
Taco_61505_C
def preprocess_array(arr): """ Preprocess the array to create a prefix sum array. >>> preprocess_array([1, 2, 3, 4, 5]) [0, 1, 3, 6, 10, 15] """ pass def range_sum(prefix_sum, l, r): """ Compute the sum of elements from index l to index r using the prefix sum array. >>> range_sum([0...
def preprocess_array(arr): """ Preprocess the array to create a prefix sum array. """ n = len(arr) prefix_sum = [0] * (n + 1) for i in range(n): prefix_sum[i + 1] = prefix_sum[i] + arr[i] return prefix_sum def range_sum(prefix_sum, l, r): """ Compute the sum of elements from...
from solution import preprocess_array, range_sum, answer_queries def test_preprocess_array(): arr = [1, 2, 3, 4, 5] result = preprocess_array(arr) expected = [0, 1, 3, 6, 10, 15] assert result == expected def test_range_sum(): prefix_sum = [0, 1, 3, 6, 10, 15] assert range_sum(prefix_sum, 0, 1...
[ { "docstring": "Preprocess the array to create a prefix sum array.", "function_declaration": "def preprocess_array(arr):", "function_name": "preprocess_array", "parameter_list": "(arr)" }, { "docstring": "Compute the sum of elements from index l to index r using the prefix sum array.", "...
[ 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 sum_of_elements(n, q, array, queries):\n \"\"\"\n Computes the sum of elements from index l to r for each query.\n\n Parameters:\n n (int): Size of...
trial_gpt4o_2
{ "original_instruction": "You are given an array of integers and multiple queries. Each query consists of two integers, $l$ and $r$. The task is to compute and print the sum of elements from index $l$ to index $r$ (inclusive) for each query.\n\nThe array is 0-indexed.\n\nConstraints\n\n* $1 \\leq n \\leq 100,000$\n*...
0.613533
Taco_61505
C
[ "preprocess_array", "range_sum", "answer_queries" ]
3
[ [ "answer_queries", "preprocess_array" ], [ "answer_queries", "range_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ea473b3f8145eefd95571647534c4ecc47e9c823
93210ad8b69eced50b3a047a8c3638aee25ef23d
v1.0
complete
Taco
Taco_61064_C
def parse_input(data): """ Parses the input data to extract the grid dimensions and grid content. Args: data (str): The input data as a single string. Returns: tuple: A tuple containing the grid dimensions and the grid as a list of lists. >>> data = "5 5\nA..*.\n.....\n.....\n.*.....
def parse_input(data): lines = data.strip().split('\n') n, m = map(int, lines[0].split()) grid = [list(line) for line in lines[1:n+1]] return n, m, grid def find_positions(grid): initial_positions = {} target_positions = {} for i in range(len(grid)): for j in range(len(grid[0])): ...
def test_parse_input(): data = "5 5\nA..*.\n.....\n.....\n.*...\n...a.\n" n, m, grid = parse_input(data) assert n == 5 assert m == 5 assert grid == [['A', '.', '.', '*', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '*',...
[ { "docstring": null, "function_declaration": "def parse_input(data):", "function_name": "parse_input", "parameter_list": "(data)" }, { "docstring": null, "function_declaration": "def find_positions(grid):", "function_name": "find_positions", "parameter_list": "(grid)" }, { ...
[ 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 collections import deque\n\ndef find_path(start, end, grid, n, m):\n # Directions in the order of UP, DOWN, LEFT, RIGHT\n directions = [(-1, 0, 'UP'), (...
trial_gpt4o_8
{ "original_instruction": "Monocarp is managing a warehouse and needs to move several items from the initial location to target locations. The warehouse is represented as a grid with dimensions n x m. Each cell in the grid is either empty or contains an item. Monocarp can move the items UP, DOWN, LEFT, or RIGHT. An i...
0.615169
Taco_61064
C
[ "parse_input", "find_positions", "generate_moves", "solve_monocarp" ]
4
[ [ "solve_monocarp", "find_positions" ], [ "solve_monocarp", "generate_moves" ], [ "solve_monocarp", "parse_input" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
5099678ac4590f0b3519379de5b6066e3d12a459
29f793412d2f26c050663e73cccbe2242eed3442
v1.0
complete
Taco
Taco_61259_C
def generate_sequence(N, K): """ Generates a sequence of length N where each element is the sum of the last K elements in the sequence. The first K elements are all 1. :param N: Length of the sequence :param K: Number of elements to sum for generating the next element in the sequence :retur...
def generate_sequence(N, K): """ Generates a sequence of length N where each element is the sum of the last K elements in the sequence. The first K elements are all 1. :param N: Length of the sequence :param K: Number of elements to sum for generating the next element in the sequence :retur...
import pytest from solution import generate_sequence, generate_sequences, process_input def test_generate_sequence_basic(): assert generate_sequence(5, 2) == [1, 1, 2, 3, 5] assert generate_sequence(7, 3) == [1, 1, 1, 3, 5, 9, 17] def test_generate_sequence_k_equals_n(): assert generate_sequence(3, 3) == ...
[ { "docstring": "Generates a sequence of length N where each element is the sum of the last K elements in the sequence.\nThe first K elements are all 1.\n\n:param N: Length of the sequence\n:param K: Number of elements to sum for generating the next element in the sequence\n:return: The generated sequence as a l...
[ 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 generate_sequence(N, K):\n \"\"\"\n Generates a sequence of length N where each element is the sum of the last K elements in the sequence.\n The first...
trial_gpt4o_0
{ "original_instruction": "In the kingdom of Westeros, Tyrion Lannister, the clever dwarf, loves to play with numbers. He has a magical number sequence generator. The generator takes two integer inputs `N` and `K` and generates a sequence of length `N` where each element is the sum of the last `K` elements in the seq...
0.678642
Taco_61259
C
[ "generate_sequence", "generate_sequences", "process_input" ]
3
[ [ "generate_sequences", "generate_sequence" ], [ "process_input", "generate_sequences" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
67999755c3f5e662dce395deb3d142eeec003951
f16e5601d289de6e22664fa0fc338ee482696a6d
v1.0
complete
Taco
Taco_61325_C
def is_prime(n): """ Returns True if the number n is prime, otherwise False. """ # Implement the function here def sum_of_non_prime_numbers(arr): """ Returns the sum of non-prime numbers in the array. """ # Implement the function here def process_test_cases(test_cases): """ Giv...
def is_prime(n): """ Returns True if the number n is prime, otherwise False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import is_prime, sum_of_non_prime_numbers, 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(1) == False assert is_prime(0) == False...
[ { "docstring": "Returns True if the number n is prime, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of non-prime numbers in the array.", "function_declaration": "def sum_of_non_prime...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n This function checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**...
trial_gpt4o_1
{ "original_instruction": "Given an integer array of size N, you have to find out the sum of all elements in the array that are not prime numbers. It's guaranteed that the array size N will be between 1 and 1000, and each element in the array will be between 1 and 10000.\n\n-----Input-----\nThe first line of input co...
0.678229
Taco_61325
C
[ "is_prime", "sum_of_non_prime_numbers", "process_test_cases" ]
3
[ [ "process_test_cases", "sum_of_non_prime_numbers" ], [ "sum_of_non_prime_numbers", "is_prime" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
a7a6a6f4c9c26e6e054eb4f6f8e6798896c9f8f1
47c0aadfcd6f7a1c560b90d930810caaab9564a9
v1.0
complete
Taco
Taco_61803_C
def binary_parity_tree(n: int, arr: List[int]) -> List[int]: """ Build a Binary Parity Tree (BPT) and return its inorder traversal. Given a list of integers, this function constructs a Binary Parity Tree according to the rules where all even numbers are on the left subtree, and all odd numbers are ...
class Node: def __init__(self, value): self.value = value self.left = None self.right = None def insert(root, value): if not root: return Node(value) if value % 2 == 0: if not root.left: root.left = Node(value) else: insert(root.left, ...
from solution import binary_parity_tree def test_example_1(): n = 5 arr = [2, 3, 4, 1, 5] assert binary_parity_tree(n, arr) == [2, 4, 3, 1, 5] def test_single_element(): n = 1 arr = [2] assert binary_parity_tree(n, arr) == [2] def test_all_even(): n = 3 arr = [4, 6, 2] assert bina...
[]
[ 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.125
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0):\n self.val = val\n self.left = None\n self.right = None\n\ndef insert...
trial_gpt4o_8
{ "original_instruction": "In the distant land of Numerovia, there exists a peculiar numerical tree called the Binary Parity Tree (BPT). The BPT is a binary tree where each node holds a single integer value. In this tree, the word \"parity\" refers to whether a number is even or odd. The Binary Parity Tree comes with...
0.645246
Taco_61803
C
[ "insert", "inorder_traversal", "build_bpt", "binary_parity_tree" ]
4
[ [ "binary_parity_tree", "build_bpt" ], [ "build_bpt", "inorder_traversal" ], [ "build_bpt", "insert" ] ]
3
[]
false
[ "Node" ]
true
pytest
true
[]
true
d824969f4afb87efea6c8d605f813c084d0d7c38
9ef0dfa1a986ff6c04876b5c52297a948bfd1c6f
v1.0
complete
Taco
Taco_61653_C
def check_expressions(expressions: List[str]) -> List[str]: """ Check if each mathematical expression in the list is valid. Args: expressions (List[str]): List of strings, where each string represents a mathematical expression. Returns: List[str]: List of results for each expression, where eac...
def is_valid_expression(expression): """ Checks if a mathematical expression is valid. Returns 'Valid', 'Invalid', or 'Division by zero'. """ operators = set('+-*/') try: prev_char = None for char in expression: if char not in '0123456789' and char not in operators: ...
import pytest from solution import check_expressions def test_valid_expressions(): assert check_expressions(["3+5", "10-2*3", "7/2", "14/2", "9+3-4", "6*7/8"]) == ["Valid", "Valid", "Valid", "Valid", "Valid", "Valid"] def test_invalid_expressions(): assert check_expressions(["5+*7", "5//2", "*/2", "a+3", "3a+...
[ { "docstring": "Checks if a mathematical expression is valid.\nReturns 'Valid', 'Invalid', or 'Division by zero'.", "function_declaration": "def is_valid_expression(expression):", "function_name": "is_valid_expression", "parameter_list": "(expression)" }, { "docstring": "Checks a list of mat...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef validate_expression(expression):\n \"\"\"\n Validates a mathematical expression.\n \n Args:\n expression (str): The mathematical ex...
trial_gpt4o_2
{ "original_instruction": "You are given a list of strings, where each string represents a mathematical expression containing positive integers and the operators `+`, `-`, `*`, `/`. Check if each expression is mathematically valid, which means it contains proper operations between integers, and there is no division b...
0.635912
Taco_61653
C
[ "is_valid_expression", "check_expressions" ]
2
[ [ "check_expressions", "is_valid_expression" ] ]
1
[]
false
[]
false
pytest
true
[]
true
629e509d9f9e12b4f065c8e427a40d7644402738
3bede8a8b257ce8b361c74b0f584082cc6ef212b
v1.0
complete
Taco
Taco_61913_C
def maxPrimeCount(K: int, arr: List[int]) -> int: """ Given an array of integers and a window size K, find the maximum number of prime numbers in any subarray of size K. Example 1: >>> maxPrimeCount(3, [1, 3, 7, 6, 13, 19, 18, 22]) 2 Example 2: >>> maxPrimeCount(2, [11, 15, 8,...
from math import isqrt 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) ==...
from solution import maxPrimeCount def test_example1(): K = 3 arr = [1, 3, 7, 6, 13, 19, 18, 22] assert maxPrimeCount(K, arr) == 2 def test_example2(): K = 2 arr = [11, 15, 8, 5, 33, 7, 2] assert maxPrimeCount(K, arr) == 2 def test_single_element(): K = 1 arr = [1, 3, 7, 6, 13, 19, 18...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Function to find the maximum number of prime numbers in any \nsubarray of size K.", "function_declarati...
[ 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_prime(n):\n \"\"\"\n Check if a number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_4
{ "original_instruction": "Given an array of integers and a window size K, the task is to find the maximum number of prime numbers in any subarray of size K. \n\nExample 1:\nInput:\nK = 3\narr = [1, 3, 7, 6, 13, 19, 18, 22]\nOutput:\n2\nExplanation:\nThe subarrays of size 3 are:\n[1, 3, 7], [3, 7, 6], [7, 6, 13], [6,...
0.669478
Taco_61913
C
[ "is_prime", "maxPrimeCount" ]
2
[ [ "maxPrimeCount", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
893427628b648738fafd5abf7603bfe35cd11b2a
f6f5ad311ff99f9caee60369ab6c3a46c9639b02
v1.0
complete
Taco
Taco_61708_C
def island_hopper(sx, sy, tx, ty, n, teleport_list): """ Determine the minimum time required for the player to move from the starting point to the target point, either through normal movement or by using the teleportation points optimally. sx: int : starting x coordinate sy: int : starting y coordinate...
from collections import deque def min_time_to_target(sx, sy, tx, ty, teleport_points): def bfs(): queue = deque([(sx, sy, 0)]) visited = set() visited.add((sx, sy)) while queue: x, y, time = queue.popleft() if (x, y) == (tx, ty): ...
from solution import island_hopper def test_island_hopper_example(): assert island_hopper(0, 0, 10, 10, 3, ["1 1 8 8", "2 2 3 3", "6 6 10 5"]) == 6 def test_island_hopper_no_teleportations(): assert island_hopper(0, 0, 5, 5, 0, []) == 10 def test_island_hopper_direct_teleport(): assert island_hopper(...
[ { "docstring": null, "function_declaration": "def min_time_to_target(sx, sy, tx, ty, teleport_points):", "function_name": "min_time_to_target", "parameter_list": "(sx, sy, tx, ty, teleport_points)" }, { "docstring": null, "function_declaration": "def island_hopper(sx, sy, tx, ty, n, tele...
[ 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": "from heapq import heappop, heappush\nimport sys\n\ndef min_time_to_reach(sx, sy, tx, ty, teleport_list):\n points = [(sx, sy), (tx, ty)]\n for t in teleport_...
trial_gpt4o_5
{ "original_instruction": "A famous game developer has designed a new game called \"Island Hopper\". In this game, players start on an island located at point (sx, sy) and need to reach a target island located at (tx, ty) on a 2-D coordinate plane. There are several teleportation points on the plane that can help pla...
0.570418
Taco_61708
C
[ "min_time_to_target", "island_hopper" ]
2
[ [ "island_hopper", "min_time_to_target" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6de783972705bb4e3e6d6eae6b3c783ee7fba784
e5394525826ba31872ac4e19ae3923484d23ac9f
v1.0
complete
Taco
Taco_61360_C
def unique_elements_and_frequencies(test_cases): """ Given a list of test cases, each containing an array of integers, this function returns the number of unique elements in the sorted array and the frequencies of each unique element in sorted order. Args: test_cases (List[Tuple[int, List[int]]]): A l...
def unique_elements_and_frequencies(test_cases): results = [] for case in test_cases: N, array = case sorted_array = sorted(array) frequencies = {} for num in sorted_array: if num in frequencies: frequencies[num] += 1 else: ...
def test_unique_elements_and_frequencies(): input_data = "2\n5\n4 5 4 2 2\n6\n1 1 1 1 1 1" expected_output = "3\n2 2 1\n1\n6" assert solve_problem(input_data) == expected_output def test_single_element_array(): input_data = "1\n1\n10" expected_output = "1\n1" assert solve_problem(input_data) ==...
[ { "docstring": null, "function_declaration": "def unique_elements_and_frequencies(test_cases):", "function_name": "unique_elements_and_frequencies", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def process_input(input_data):", "function_name": "pr...
[ 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 Counter\n\ndef unique_elements_and_frequencies(test_cases):\n results = []\n for case in test_cases:\n N, arr = case\n ...
trial_gpt4o_2
{ "original_instruction": "Maria is preparing for a coding competition and she practices by solving various types of problems. One day, she encounters a problem about sorting arrays. The problem is related to the uniqueness and frequency of array elements after sorting them. She finds it interesting and decides to ch...
0.742932
Taco_61360
C
[ "unique_elements_and_frequencies", "process_input", "format_output", "solve_problem" ]
4
[ [ "solve_problem", "format_output" ], [ "solve_problem", "process_input" ], [ "solve_problem", "unique_elements_and_frequencies" ] ]
3
[ "process_input", "format_output" ]
false
[]
false
pytest
false
[]
true
ea025362b09cb8834d406525cdb2c9691d34d340
4b0b87446a5972b65f2d84e24509e37f61287f09
v1.0
complete
Taco
Taco_61169_C
def minimum_transfer_time(n: int, m: int, edges: List[Tuple[int, int, int]], start: int, end: int) -> int: """ Compute the minimum transfer time between two specific computers in the network. >>> minimum_transfer_time(5, 6, [(1, 2, 2), (1, 3, 4), (2, 3, 1), (2, 4, 7), (3, 5, 3), (4, 5, 1)], 1, 5) 6 """ ...
import heapq def dijkstra(n, edges, start, end): # Create an adjacency list adj = {i: [] for i in range(1, n + 1)} for u, v, w in edges: adj[u].append((v, w)) adj[v].append((u, w)) # Priority queue to store (weight, node) pq = [(0, start)] distances = {i: float('inf') for i...
def test_example_case(): n = 5 m = 6 edges = [ (1, 2, 2), (1, 3, 4), (2, 3, 1), (2, 4, 7), (3, 5, 3), (4, 5, 1) ] start = 1 end = 5 result = minimum_transfer_time(n, m, edges, start, end) assert result == 6 def test_no_path_case(): 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 minimum_transfer_time(n, m, edges, start, end):", "function_name": "minimum...
[ 0, 0, 1, 1 ]
2
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef minimum_transfer_time(n, m, edges, start, end):\n \"\"\"\n Returns the minimum transfer time between two computers using Dijkstra's Algor...
trial_gpt4o_4
{ "original_instruction": "Given a large network of computers, we want to perform data transfer between two computers through the shortest possible path. The network is represented as an undirected graph, where nodes denote computers and edges denote direct communication links between them. Each edge has a weight rep...
0.59491
Taco_61169
C
[ "dijkstra", "minimum_transfer_time" ]
2
[ [ "minimum_transfer_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
fdd20a842783533529a563cd0ccba0ae172349e0
463f7b8cb579ddb7f202720849e4c565b837be6f
v1.0
complete
Taco
Taco_61413_C
def hybrid_sort(arr, T): """ Sorts the array `arr` using the HybridSort algorithm. Parameters: arr (list): The array to be sorted. T (int): The threshold value to decide between QuickSort and InsertionSort. Returns: list: The sorted array. """ pass def quick_sort(arr): ...
def hybrid_sort(arr, T): """ Sorts the array `arr` using the HybridSort algorithm. Parameters: arr (list): The array to be sorted. T (int): The threshold value to decide between QuickSort and InsertionSort. Returns: list: The sorted array. """ if len(arr) <= T: retu...
from solution import hybrid_sort, quick_sort, insertion_sort def test_hybrid_sort(): assert hybrid_sort([12, 4, 5, 6, 7, 3, 1, 15], 4) == [1, 3, 4, 5, 6, 7, 12, 15] assert hybrid_sort([4, 3, 2, 10, 12, 1, 5, 6], 3) == [1, 2, 3, 4, 5, 6, 10, 12] def test_quick_sort(): assert quick_sort([3, 6, 8, 10, 1, 2, ...
[ { "docstring": "Sorts the array `arr` using the HybridSort algorithm.\n\nParameters:\narr (list): The array to be sorted.\nT (int): The threshold value to decide between QuickSort and InsertionSort.\n\nReturns:\nlist: The sorted array.", "function_declaration": "def hybrid_sort(arr, T):", "function_name...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def hybrid_sort(arr, T):\n \"\"\"\n Sorts the array `arr` using the HybridSort algorithm.\n \n Parameters:\n arr (list): The array to be sorted.\n ...
trial_gpt4o_0
{ "original_instruction": "You are working as an engineer for a company that designs and implements advanced sorting algorithms. Your team has come up with a hybrid sorting algorithm named HybridSort, which combines the properties of QuickSort and InsertionSort. Your task is to implement this HybridSort algorithm.\n\...
0.591274
Taco_61413
C
[ "hybrid_sort", "quick_sort", "insertion_sort" ]
3
[ [ "hybrid_sort", "insertion_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
10e51f0e6a744780d778668c2683c4edb2d0ecbc
8bb19b907f52f020813bdf9157294df182c3102e
v1.0
complete
Taco
Taco_61140_C
def num_distinct_islands(grid): """ Counts the number of distinct islands in the given grid. An island is a group of connected 1s (connected horizontally or vertically). >>> num_distinct_islands([[1, 1, 0], [0, 1, 0], [1, 0, 0]]) 2 >>> num_distinct_islands([[1, 1, 0], [0, 1, 0], [1, 1, 0]]) ...
def num_distinct_islands(grid): def dfs(x, y, direction): if x < 0 or x >= len(grid) or y < 0 or y >= len(grid[0]) or grid[x][y] != 1: return [] grid[x][y] = -1 shape.append(direction) dfs(x + 1, y, 'D') dfs(x - 1, y, 'U') dfs(x, y + 1, 'R') dfs(x,...
from solution import num_distinct_islands_from_input, read_input_to_test_cases def test_example_1(): input_str = "1\n3 3\n1 1 0\n0 1 0\n1 0 0\n" t, test_cases = read_input_to_test_cases(input_str) results = num_distinct_islands_from_input(t, test_cases) expected = [2] assert results == expected de...
[ { "docstring": null, "function_declaration": "def num_distinct_islands(grid):", "function_name": "num_distinct_islands", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def num_distinct_islands_from_input(t, test_cases):", "function_name": "num_distinct_is...
[ 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 num_distinct_islands(grid):\n def dfs(x, y, origin_x, origin_y, path):\n if x < 0 or x >= len(grid) or y < 0 or y >= len(grid[0]) or grid[x][y] == 0:...
trial_gpt4o_2
{ "original_instruction": "You are given an integer matrix `grid` with `m` rows and `n` columns. Each element of the matrix represents a value in the grid, where `1` denotes land and `0` denotes water. The grid is completely surrounded by water.\n\nYou need to count the number of distinct islands in the grid. An isla...
0.572456
Taco_61140
C
[ "num_distinct_islands", "num_distinct_islands_from_input", "read_input_to_test_cases" ]
3
[ [ "num_distinct_islands_from_input", "num_distinct_islands" ] ]
1
[ "read_input_to_test_cases" ]
false
[]
false
pytest
true
[]
true
f965715ef8ff4c7c05caf1677d15df3bd5a97c07
9c1b0651d57be8a025f54880f9855133f42ca2dd
v1.0
complete
Taco
Taco_62039_C
def calculate_power_value(arr): """ Calculate the power value for the given array of integers by summing the digits repeatedly until a single-digit result is obtained. Args: arr (List[int]): A list of integers representing the mural array. Returns: int: The power value of the mural array. ...
def digit_sum(n): """ Calculate the sum of digits of a given integer. """ return sum(int(digit) for digit in str(n)) def calculate_power_value(arr): """ Calculate the power value for the given array of integers. """ # Step 1: Calculate the digit sum of each element in the array. dig...
from solution import calculate_power_value def test_example1(): assert calculate_power_value([987, 123, 456]) == 9 def test_example2(): assert calculate_power_value([1, 2, 3, 4, 5]) == 6 def test_all_zero(): assert calculate_power_value([0, 0, 0, 0, 0]) == 0 def test_single_digit_elements(): assert ...
[ { "docstring": "Calculate the sum of digits of a given integer.", "function_declaration": "def digit_sum(n):", "function_name": "digit_sum", "parameter_list": "(n)" }, { "docstring": "Calculate the power value for the given array of integers.", "function_declaration": "def calculate_powe...
[ 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 digit_sum(n):\n \"\"\"\n Calculate the sum of digits of a given integer.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef calculate_pow...
trial_gpt4o_0
{ "original_instruction": "The troglodytes are a secluded group of people living in the vast caverns of the mountainous region. They have developed a unique way of creating murals depicting their history, using a set of simple operations on arrays of numbers.\n\nIn particular, they perform a series of operations to d...
0.570001
Taco_62039
C
[ "digit_sum", "calculate_power_value" ]
2
[ [ "calculate_power_value", "digit_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0238c847a5c9e27f88b35e61160a3cd05a16e598
5b7ac1a8330614b6c5656d74c10d3c57cc44674a
v1.0
complete
Taco
Taco_61690_C
from typing import List, Tuple def handle_queries(n: int, q: int, logs: List[str], queries: List[str]) -> List[int]: """ Handle multiple queries about the number of vehicles that have visited a given depot within a particular date range. Args: n (int): Number of movement logs. q (int): Number...
from collections import defaultdict from datetime import datetime def parse_log_entries(n, log_entries): """ Parse log_entries into a dictionary grouped by depot number with each value being a list of dates (in string format). """ depot_movements = defaultdict(list) for log in log_entries: ...
from solution import handle_queries, extract_input def test_handle_queries(): input_data = """5 3 1 2023-01-01 2 2023-01-02 1 2023-01-03 3 2023-01-02 1 2023-01-04 1 2023-01-01 2023-01-04 ...
[ { "docstring": "Parse log_entries into a dictionary grouped by depot number with \neach value being a list of dates (in string format).", "function_declaration": "def parse_log_entries(n, log_entries):", "function_name": "parse_log_entries", "parameter_list": "(n, log_entries)" }, { "docstri...
[ 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 count_vehicles_in_depot_range(n, q, movements, queries):\n \"\"\"\n Returns the number of unique vehicles that have visited the specified depot within th...
trial_gpt4o_2
{ "original_instruction": "A transportation company needs to track the movement of their fleet of vehicles across multiple depots. Each vehicle can move from one depot to another in a specified order. All movements are logged and operations managers need a tool to extract specific data about vehicle movements. \n\nYo...
0.569652
Taco_61690
C
[ "parse_log_entries", "count_vehicles", "handle_queries", "extract_input" ]
4
[ [ "handle_queries", "count_vehicles" ], [ "handle_queries", "parse_log_entries" ] ]
2
[ "handle_queries" ]
false
[]
false
pytest
true
[]
true
b3fc3bc959fbce3a4d10dba6d602c9f90b08f855
b2cba2ff73ce6d82bd044f8dc27a34a11292895a
v1.0
complete
Taco
Taco_61971_C
def min_steps_grid(N: int, M: int, grid: List[List[str]], S_x: int, S_y: int) -> int: """ Calculate the minimum number of cells the visitor must cross to exit the maze from any of the sides. >>> min_steps_grid(5, 5, [ ['.', '.', '.', '.', '.'], ['.', '/', '.', '/', '.'], ['.', '.', '.', ...
from collections import deque def min_steps_to_exit(grid, start_x, start_y): N = len(grid) M = len(grid[0]) directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] # Right, Down, Left, Up # BFS initialization queue = deque([(start_x, start_y, 0)]) # store (current_x, current_y, steps) visited = ...
from solution import min_steps_grid def test_min_steps_to_exit(): grid = [ ['.', '.', '.', '.', '.'], ['.', '/', '.', '/', '.'], ['.', '.', '.', '.', '.'], ['/', '.', '/', '.', '/'], ['.', '.', '.', '.', '.'] ] assert min_steps_grid(5, 5, grid, 2, 2) == 2 def test_m...
[ { "docstring": null, "function_declaration": "def min_steps_to_exit(grid, start_x, start_y):", "function_name": "min_steps_to_exit", "parameter_list": "(grid, start_x, start_y)" }, { "docstring": null, "function_declaration": "def min_steps_grid(N, M, grid, S_x, S_y):", "function_nam...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef is_valid(x, y, N, M):\n return 0 <= x < N and 0 <= y < M\n\ndef min_steps_to_exit(N, M, grid, S_x, S_y):\n directions = ...
trial_gpt4o_3
{ "original_instruction": "In an amusement park, there is a fun house with a maze of mirrors. The mirrors are aligned perfectly vertical or horizontal, forming a rectangular grid with $N$ rows and $M$ columns. Each cell in the grid is either a clear path (represented by '.') or contains a mirror (represented by '/')....
0.655511
Taco_61971
C
[ "min_steps_to_exit", "min_steps_grid" ]
2
[ [ "min_steps_grid", "min_steps_to_exit" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d10caead8a917c00ca34093bf59aa192071dbd20
967e96a72fe34a50e09ca012e293a50bd304f85c
v1.0
complete
Taco
Taco_61806_C
def organize_departments(test_cases): """Organize employees into departments such that each department has at least one manager and no department contains more than three employees. If it's not possible to organize all employees according to the rules, return "Impossible". :param test_cases: List...
def organize_departments(test_cases): result = [] for case in test_cases: N, employees = case managers = [emp for emp in employees if emp[1] == 1] non_managers = [emp for emp in employees if emp[1] == 0] if len(managers) == 0: result.append("Impossible") ...
from solution import organize_departments, parse_input, serialize_output, solution def test_example_case_1(): input_data = "3\n4\nabc123 1\nxyz456 0\nlmn789 0\npqr012 1\n6\nmgr05 1\nemp99 0\nemp01 0\nmgr22 1\nemp11 0\nemp33 0\n3\nempA 0\nempB 0\nempC 0" expected_output = "abc123 xyz456 lmn789\npqr012\nmgr05 em...
[ { "docstring": null, "function_declaration": "def organize_departments(test_cases):", "function_name": "organize_departments", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_data):", "function_name": "parse_input", "paramet...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def organize_employees(T, test_cases):\n result = []\n for case in test_cases:\n N, employees = case\n managers = [emp for emp in employees if ...
trial_gpt4o_8
{ "original_instruction": "You are given a list of employees in a company. Each employee record is represented by an employee ID and a boolean value that indicates whether the employee is a manager or not. Your task is to organize these employees into departments such that each department has at least one manager and...
0.718846
Taco_61806
C
[ "organize_departments", "parse_input", "serialize_output", "solution" ]
4
[ [ "solution", "organize_departments" ], [ "solution", "parse_input" ], [ "solution", "serialize_output" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
52db507359d58198316793d117f44e1656e6f5ed
cc1d24a961781ff04024d37a4694f50c209c6c65
v1.0
complete
Taco
Taco_62186_C
def min_cost_to_form_lcs(N: int, M: int, P: List[int], Q: List[int]) -> int: """ Calculate the minimum cost to make the longest common subsequence of P and Q. >>> min_cost_to_form_lcs(4, 5, [1, 3, 4, 1], [1, 2, 3, 4, 1]) 4 >>> min_cost_to_form_lcs(3, 3, [1, 2, 3], [4, 5, 6]) 0 """ def test_exam...
def lcs_length(P, Q): N = len(P) M = len(Q) dp = [[0] * (M+1) for _ in range(N+1)] for i in range(1, N+1): for j in range(1, M+1): if P[i-1] == Q[j-1]: dp[i][j] = dp[i-1][j-1] + 1 else: dp[i][j] = max(dp[i-1][j], dp[i][j-1]) r...
from solution import min_cost_to_form_lcs def test_example_case(): assert min_cost_to_form_lcs(4, 5, [1, 3, 4, 1], [1, 2, 3, 4, 1]) == 4 def test_no_common_elements(): assert min_cost_to_form_lcs(3, 3, [1, 2, 3], [4, 5, 6]) == 0 def test_some_common_elements(): assert min_cost_to_form_lcs(5, 6, [1, 2, 3,...
[ { "docstring": null, "function_declaration": "def lcs_length(P, Q):", "function_name": "lcs_length", "parameter_list": "(P, Q)" }, { "docstring": null, "function_declaration": "def min_cost_to_form_lcs(N, M, P, Q):", "function_name": "min_cost_to_form_lcs", "parameter_list": "(N,...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def lcs_length(P, Q):\n N = len(P)\n M = len(Q)\n lcs_table = [[0]*(M+1) for _ in range(N+1)]\n \n for i in range(1, N+1):\n for j in range(1...
trial_gpt4o_1
{ "original_instruction": "You are given a sequence of integers P_1, P_2, ..., P_N and Q_1, Q_2, ..., Q_M. You are to find a common subsequence R that is both subsequence of P and Q, and perform the following operations:\n\nOperations:\n- Add an integer at the end of R.\n- Remove the last integer of R.\n- Reverse R.\...
0.61031
Taco_62186
C
[ "lcs_length", "min_cost_to_form_lcs" ]
2
[ [ "min_cost_to_form_lcs", "lcs_length" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9963abd852a599511b7314a348cf38a8e3498088
53d243553f8252006a5345e69e2adf2a452b05ad
v1.0
complete
Taco
Taco_61681_C
import re import ast def evaluate_alpha_lang(expression: str) -> list: """ Evaluate an expression containing AlphaLang operations and return the resulting list. >>> evaluate_alpha_lang("repeat([1, 2], 3)") [1, 2, 1, 2, 1, 2] >>> evaluate_alpha_lang("merge([1, 2, 3], [4, 5, 6, 7])") [1, 4, 2, 5, 3, ...
import re import ast def repeat(lst, n): return lst * n def merge(lst1, lst2): merged = [] i = 0 while i < len(lst1) and i < len(lst2): merged.append(lst1[i]) merged.append(lst2[i]) i += 1 if i < len(lst1): merged.extend(lst1[i:]) if i < len(lst2): merge...
import pytest from solution import evaluate_alpha_lang def test_repeat(): assert evaluate_alpha_lang("repeat([1, 2], 3)") == [1, 2, 1, 2, 1, 2] assert evaluate_alpha_lang("repeat([0], 5)") == [0, 0, 0, 0, 0] assert evaluate_alpha_lang("repeat([], 10)") == [] def test_merge(): assert evaluate_alpha_lan...
[ { "docstring": null, "function_declaration": "def repeat(lst, n):", "function_name": "repeat", "parameter_list": "(lst, n)" }, { "docstring": null, "function_declaration": "def merge(lst1, lst2):", "function_name": "merge", "parameter_list": "(lst1, lst2)" }, { "docstring...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef repeat(x, n):\n return x * n\n\ndef merge(x, y):\n result = []\n len_x, len_y = len(x), len(y)\n for i in range(max(len_x, len_y)):\n ...
trial_gpt4o_2
{ "original_instruction": "Alice and Bob are collaboratively developing a new language called AlphaLang, which heavily relies on the manipulation of lists of integers. In AlphaLang, there are pre-defined functions that perform various operations on these integer lists. These functions include:\n\n- repeat(x,n): Creat...
0.541759
Taco_61681
C
[ "repeat", "merge", "slice", "evaluate_alpha_lang" ]
4
[ [ "evaluate_alpha_lang", "merge" ], [ "evaluate_alpha_lang", "repeat" ], [ "evaluate_alpha_lang", "slice" ] ]
3
[]
false
[]
false
pytest
true
[]
true
6c4f16849b5b81b3ea5cb9916ae915690be4a4ea
67542497a6ca8f83b6cb182798c6ec6ec5b146c4
v1.0
complete
Taco
Taco_62859_C
def is_prime(n: int) -> bool: """ Checks if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(29) True """ def smallest_sum_of_primes(target: int) -> int: """ Finds the smallest number greater tha...
def is_prime(n): """ Checks 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 return T...
from solution import smallest_sum_of_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(9) == False assert is_prime(29) == True def test_smallest_sum_of_primes_example_1(): asser...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Finds the smallest number greater than or equal to the given target that can be expressed as the sum of two prime numbers.", ...
[ 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 math\n\ndef is_prime(n):\n \"\"\"Helper function to check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n == 2 or n == 3:\n ...
trial_gpt4o_4
{ "original_instruction": "Write a function to find the smallest number that is greater than or equal to the given target and can be expressed as the sum of two prime numbers. \n\nExample 1:\nInput: target = 10\nOutput: 10\nExplanation: 10 = 3 + 7, and both 3 and 7 are prime.\n\nExample 2:\nInput: target = 17\nOutput...
0.721559
Taco_62859
C
[ "is_prime", "smallest_sum_of_primes" ]
2
[ [ "smallest_sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f45f261010234a2d5c75c72ecb3b02de6494440e
b9e5f4b6fba276506cd39c4d22668f4054ad9346
v1.0
complete
Taco
Taco_62589_C
def bookstore_analysis(n: int, log_entries: List[Tuple[int, int]]) -> int: """ Given a list of log entries, return the length of the longest sequence of books that are repeatedly viewed together by users. >> bookstore_analysis(8, [(1, 5), (1, 6), (1, 7), (2, 5), (2, 6), (...
from collections import defaultdict def longest_sequence_viewed_together(log_entries): # Step 1: Parse the logs into a dictionary by user user_views = defaultdict(list) for user_id, book_id in log_entries: user_views[user_id].append(book_id) # Step 2: Extract sequences and store in sequenc...
def test_bookstore_analysis_basic(): assert bookstore_analysis(8, [(1, 5), (1, 6), (1, 7), (2, 5), (2, 6), (2, 8), (3, 7), (3, 6)]) == 2 def test_bookstore_analysis_all_single(): assert bookstore_analysis(4, [(1, 1), (2, 2), (3, 3), (4, 4)])...
[ { "docstring": null, "function_declaration": "def longest_sequence_viewed_together(log_entries):", "function_name": "longest_sequence_viewed_together", "parameter_list": "(log_entries)" }, { "docstring": null, "function_declaration": "def bookstore_analysis(n, log_entries):", "functi...
[ 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": "from collections import defaultdict\n\ndef longest_sequence_viewed_together(log_entries):\n # Step 1: Parse the logs into a dictionary by user\n user_views =...
trial_gpt4o_0
{ "original_instruction": "A popular online bookstore maintains logs of books viewed by users. Each log entry contains the user ID and the book ID. The bookstore wants to analyze browsing patterns to recommend related books to users based on popular sequential views.\n\nGiven a list of log entries, identify the longe...
0.545942
Taco_62589
C
[ "longest_sequence_viewed_together", "bookstore_analysis" ]
2
[ [ "bookstore_analysis", "longest_sequence_viewed_together" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0f92e5159dd5991b60bda81f8cb47a6fb6767fd8
d941987de24aed8b652e8ded5e10a33ea0ebede1
v1.0
complete
Taco
Taco_62580_C
from collections import deque def find_shortest_path(R: int, C: int, grid: List[str], Sr: int, Sc: int, Dr: int, Dc: int) -> int: """ Impelement the Breadth-First Search (BFS) algorithm to find the length of the shortest path between two given points on the map. The path can only be formed by moving up, down,...
from collections import deque def bfs_shortest_path(grid, start, end): R, C = len(grid), len(grid[0]) directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(start[0], start[1], 0)]) # row, col, distance visited = set() visited.add((start[0], start[1])) while queue: r...
from solution import find_shortest_path def test_case_1(): R, C = 3, 3 grid = [ "..#", ".#.", "..." ] Sr, Sc, Dr, Dc = 0, 0, 2, 2 assert find_shortest_path(R, C, grid, Sr, Sc, Dr, Dc) == 4 def test_case_2(): R, C = 3, 3 grid = [ "###", ".##", ...
[ { "docstring": null, "function_declaration": "def bfs_shortest_path(grid, start, end):", "function_name": "bfs_shortest_path", "parameter_list": "(grid, start, end)" }, { "docstring": null, "function_declaration": "def find_shortest_path(R, C, grid, Sr, Sc, Dr, Dc):", "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": "from collections import deque\n\ndef shortest_path(R, C, grid, sr, sc, dr, dc):\n def is_valid(x, y):\n return 0 <= x < R and 0 <= y < C and grid[x][y] =...
trial_gpt4o_4
{ "original_instruction": "You are working on a top-down 2D game where characters can move around a grid map. Each cell in the map can be either a passable terrain represented by ‘.’ or an obstacle represented by ‘#’. One of the game features is a pathfinding function that allows the characters to find the shortest p...
0.645513
Taco_62580
C
[ "bfs_shortest_path", "find_shortest_path" ]
2
[ [ "find_shortest_path", "bfs_shortest_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d6fe1d5d8b43bf172277f1da9f2e54e00c50db0e
a68db754968cc970ac4269dc11f8db75a70f4cd5
v1.0
complete
Taco
Taco_62348_C
def can_partition(nums, k, max_sub_sum): """ Checks if it is possible to partition the list of integers into k non-empty subsets such that no subset's sum exceeds max_sub_sum. """ pass def min_max_partition(nums, k): """ Finds the minimum possible value of the maximum sum among the subsets into...
def can_partition(nums, k, max_sub_sum): current_sum = 0 partitions = 1 # We need at least one partition for num in nums: if current_sum + num > max_sub_sum: partitions += 1 current_sum = num if partitions > k: return False else: ...
def test_can_partition(): assert can_partition([1, 2, 3, 4, 5], 2, 9) == True assert can_partition([1, 2, 3, 4, 5], 2, 7) == False assert can_partition([10, 20, 30, 40], 2, 60) == True assert can_partition([10, 20, 30, 40], 2, 30) == False def test_min_max_partition(): assert min_max_partition(...
[ { "docstring": null, "function_declaration": "def can_partition(nums, k, max_sub_sum):", "function_name": "can_partition", "parameter_list": "(nums, k, max_sub_sum)" }, { "docstring": null, "function_declaration": "def min_max_partition(nums, k):", "function_name": "min_max_partition...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_min_max_diff(t, test_cases):\n \"\"\"\n Finds the minimum possible value of the maximum difference between the sums of integers in any two subsets.\...
trial_gpt4o_9
{ "original_instruction": "You are given $n$ integers and a positive number $k$. Your task is to arrange these integers into $k$ non-empty subsets such that the maximum difference between the sum of integers in any two subsets is minimized. You need to find that minimum possible value.\n\n------Input------\n\nThe fir...
0.647183
Taco_62348
C
[ "can_partition", "min_max_partition", "minimum_max_difference", "main" ]
4
[ [ "min_max_partition", "can_partition" ], [ "minimum_max_difference", "min_max_partition" ] ]
2
[]
false
[]
false
pytest
false
[]
true
21a59b89b3e69802d95526859a0a2caad996f863
0f19ed41a181c20fd8379b798ec026faad18eea7
v1.0
complete
Taco
Taco_62582_C
def solve(T: int, cases: List[Tuple[int, int, List[List[int]]]]) -> List[int]: """ Determine if the grid can be rearranged to form a magic matrix with minimal swaps. A magic matrix has all rows and columns containing the exact same set of elements. Args: T (int): Number of test cases. cases...
def is_magic_matrix(n, m, grid): """ This function checks if the grid is already a magic matrix. """ sorted_first_row = sorted(grid[0]) sorted_first_column = sorted(grid[i][0] for i in range(n)) # Check if all rows have the same sorted elements as the first row for row in grid: ...
from solution import solve def test_cases(): T = 3 cases = [ (2, 2, [ [1, 2], [2, 1] ]), (3, 3, [ [1, 2, 3], [3, 1, 2], [2, 3, 1] ]), (2, 3, [ [1, 2, 3], [3, 2, 1] ]), ] ...
[ { "docstring": "This function checks if the grid is already a magic matrix.", "function_declaration": "def is_magic_matrix(n, m, grid):", "function_name": "is_magic_matrix", "parameter_list": "(n, m, grid)" }, { "docstring": null, "function_declaration": "def min_swaps_to_magic_matrix(n,...
[ 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_swaps_to_magic_matrix(test_cases):\n \"\"\"\n Given a list of test cases where each test case is a grid, returns the minimum number of swaps\n req...
trial_gpt4o_7
{ "original_instruction": "Alex is a collector of rare stones and keeps his collection in a special grid. One day, he decided to rearrange his stones such that the grid forms a \"magic matrix\". A grid is considered a magic matrix if all its rows and columns contain the exact same set of elements (including repetitio...
0.653393
Taco_62582
C
[ "is_magic_matrix", "min_swaps_to_magic_matrix", "solve" ]
3
[ [ "min_swaps_to_magic_matrix", "is_magic_matrix" ], [ "solve", "min_swaps_to_magic_matrix" ] ]
2
[]
false
[]
false
pytest
true
[]
true
977caf8523fd6817d07fd55642e7a955f0fb5495
0e8176402bcc68c907db5a02c6e3d339679501d0
v1.0
complete
Taco
Taco_62349_C
def count_vowels(t: int, strings: list) -> list: """ Counts the number of vowels in a given list of strings. Args: t: An integer indicating the number of test cases. strings: A list of strings, each containing up to 100 characters. Returns: A list of integers where each integer represents ...
def count_vowels(t, strings): """ Counts vowels in a list of strings. Args: t (int): Number of test cases strings (list of str): List of strings Returns: list of int: List of vowel counts for each string """ vowels = set('aeiouAEIOU') result = [] for s in strings: ...
from solution import count_vowels def test_count_vowels_single_string(): assert count_vowels(1, ['Hello']) == [2] def test_count_vowels_multiple_strings(): assert count_vowels(3, ['Hello', 'world', 'AEIOU']) == [2, 1, 5] def test_count_vowels_empty_string(): assert count_vowels(1, ['']) == [0] def test_...
[ { "docstring": "Counts vowels in a list of strings.\n\nArgs:\nt (int): Number of test cases\nstrings (list of str): List of strings\n\nReturns:\nlist of int: List of vowel counts for each string", "function_declaration": "def count_vowels(t, strings):", "function_name": "count_vowels", "parameter_li...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_vowels(t, lst):\n \"\"\"\n Counts the number of vowels in each string in the input list.\n\n Parameters:\n t (int): number of test cases\n ...
trial_gpt4o_2
{ "original_instruction": "You are tasked with counting the number of vowels in string(s) provided in the input.\n\n------ Input ------\n\nAn integer t, 1≤t≤50, denoting the number of testcases, followed by t lines, each containing a single string s with a length of up to 100 characters. The string consists of lowerc...
0.907113
Taco_62349
C
[ "count_vowels", "get_vowel_counts" ]
2
[ [ "get_vowel_counts", "count_vowels" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5f0d4e1410447f60f42835b29939b3141d8e29cf
2cdb65a5adef6253632c74809651bc0cd41a544f
v1.0
complete
Taco
Taco_62879_C
def is_prime(num): """ Helper function to determine if a number is prime. """ # Implementation needed here def sum_of_primes(N): """ Returns the sum of the first N prime numbers. Args: N (int): The number of prime numbers to sum. Returns: int: The sum of the first N pr...
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 sum_of_primes(N): """ ...
def test_sum_of_primes(): assert sum_of_primes(1) == 2 assert sum_of_primes(2) == 5 assert sum_of_primes(3) == 10 assert sum_of_primes(5) == 28 assert sum_of_primes(10) == 129 assert sum_of_primes(20) == 639 def test_large_N(): assert sum_of_primes(100) == 24133 assert sum_of_primes(100...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of the first N prime numbers.", "function_declaration": "def sum_of_primes(N):", "function_name": "sum_of_primes", "paramet...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_0
{ "original_instruction": "Given an integer N, you need to return the sum of the first N prime numbers. A prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. For example, the first few prime numbers are 2, 3, 5, 7, 11, etc.\nExample 1:\nInput:\nN=3\nOutput:\n10\nExpla...
0.807395
Taco_62879
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4bed291b7d9e283ec71c6aaeeba263bb0ae57ed1
17daf2aaab42e47b2fe61b6ac35babfb82e72b35
v1.0
complete
Taco
Taco_62555_C
def is_palindrome(s: str) -> bool: """ Check if the given string s is a palindrome. >>> is_palindrome("a") == True >>> is_palindrome("aba") == True >>> is_palindrome("abc") == False >>> is_palindrome("racecar") == True >>> is_palindrome("") == True """ def generate_subsequences(string: ...
def is_palindrome(s): """ Check if the given string s is a palindrome. """ return s == s[::-1] def generate_subsequences(string): """ Generate all subsequences of the given string. """ subsequences = set() def backtrack(index, path): if index == len(string): sub...
from solution import is_palindrome, generate_subsequences, find_palindromic_subsequences def test_is_palindrome(): assert is_palindrome("a") == True assert is_palindrome("aba") == True assert is_palindrome("abc") == False assert is_palindrome("racecar") == True assert is_palindrome("") == True # A...
[ { "docstring": "Check if the given string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Generate all subsequences of the given string.", "function_declaration": "def generate_subsequences...
[ 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_palindrome(s):\n return s == s[::-1]\n\ndef generate_subsequences(s):\n subsequences = set()\n n = len(s)\n for i in range(1, 1 << n):\n ...
trial_gpt4o_4
{ "original_instruction": "Given a string of lowercase letters, return all the distinct subsequences of the string that are palindromes. A subsequence is a sequence derived from another sequence by deleting some or no elements without changing the order of the remaining elements.\n\nExample:\n\nInput: \"abca\"\nOutpu...
0.793445
Taco_62555
C
[ "is_palindrome", "generate_subsequences", "find_palindromic_subsequences" ]
3
[ [ "find_palindromic_subsequences", "generate_subsequences" ], [ "find_palindromic_subsequences", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ae5cc5eefdf77a01365a8fb05c2498bfbd11312d
7241af19e9626314092a0bdfc7e29610f2621a60
v1.0
complete
Taco
Taco_62855_C
from typing import List, Tuple def shortest_path(n: int, m: int, edges: List[Tuple[int, int, int]]) -> int: """Find the shortest path length from node 1 to node n under the given constraints that a beetle will only move to a neighboring node if the sum of the current path length and the distance to the ne...
import heapq import math def is_prime(n): """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 ...
from solution import shortest_path def test_example(): n = 5 m = 5 edges = [ (1, 2, 4), (2, 3, 6), (3, 5, 8), (1, 4, 10), (4, 5, 12) ] assert shortest_path(n, m, edges) == -1 def test_no_prime_lengths(): n = 3 m = 3 edges = [ (1, 2, 6), ...
[ { "docstring": "Function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def shortest_path(n, m, edges):", "function_name": "shortest_path", "paramet...
[ 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": "import heapq\nimport math\n\ndef is_prime(n):\n \"\"\"Function to check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_0
{ "original_instruction": "In a large forest, there is a network of n nodes connected by m undirected edges, forming a connected graph. A special type of beetle starts its journey from node 1 and can traverse the graph through edges.\n\nHowever, this beetle has an unusual travelling habit. Whenever it reaches a node,...
0.594672
Taco_62855
C
[ "is_prime", "shortest_path" ]
2
[ [ "shortest_path", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2780d739c5a08048b04ed677a1a5a5158033d7fe
0aad0ea4c64de8f3d4813d6ef9ab2c0ba12591f5
v1.0
complete
Taco
Taco_63019_C
from itertools import permutations def is_prime(num: int) -> bool: """ Checks if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def can_form_prime(n: int) -> str: """ Determines if any permutation of the digits of n is a prime number. >>> can_form_prime(197)...
from itertools import permutations def is_prime(num): """ Checks 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: ...
from solution import can_form_prime def test_sample_input_197(): assert can_form_prime(197) == "YES" def test_sample_input_123(): assert can_form_prime(123) == "NO" def test_single_digit_prime(): assert can_form_prime(3) == "YES" def test_single_digit_non_prime(): assert can_form_prime(4) == "NO" d...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Determines if any permutation of the digits of n is a prime number.", "function_declaration": "def can_form_prime(n):", ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef is_prime(num):\n \"\"\"\n Returns True if num is a prime number, otherwise False.\n \"\"\"\n if num <= 1:\n ...
trial_gpt4o_1
{ "original_instruction": "Raghav is fascinated by prime numbers and often spends time discovering interesting properties about them. One day, while analyzing certain series of numbers, he came across a unique problem. He discovered that some numbers can be transformed into prime numbers by rearranging their digits. ...
0.697814
Taco_63019
C
[ "is_prime", "can_form_prime" ]
2
[ [ "can_form_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b749a82ceb9ea4274527804171ef6c1e70149451
19f789234cc2ea5bb8b7d9392737f6314f76e1c0
v1.0
complete
Taco
Taco_62742_C
def validate_scores(scores): """ Validate if scores for a participant follow the rules: scores must stay the same or increase. """ def check_all_participants(participants_scores): """ Check if all participants' scores are valid. """ def main(input_lines): """ Validate the scores of all...
def validate_scores(scores): """ Validate if scores for a participant follow the rules: scores must stay the same or increase. """ return all(scores[i] <= scores[i+1] for i in range(len(scores) - 1)) def check_all_participants(participants_scores): """ Check if all participants' scores are vali...
import pytest from solution import validate_scores, check_all_participants, main def test_validate_scores_increasing(): assert validate_scores([5, 10, 15]) == True def test_validate_scores_same(): assert validate_scores([8, 8, 10, 12]) == True def test_validate_scores_decreasing(): assert validate_scores...
[ { "docstring": "Validate if scores for a participant follow the rules: scores must stay the same or increase.", "function_declaration": "def validate_scores(scores):", "function_name": "validate_scores", "parameter_list": "(scores)" }, { "docstring": "Check if all participants' scores are va...
[ 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 validate_scores(participants_scores):\n \"\"\"\n Takes a list of lists, with each inner list representing a participant's sequential event scores.\n R...
trial_gpt4o_2
{ "original_instruction": "The new task for you is to manage a competition in ChefLand, where various participants will compete in different events. Each participant is required to participate in a series of events, and their final ranking will depend upon their cumulative performance across all events. The competiti...
0.56518
Taco_62742
C
[ "validate_scores", "check_all_participants", "main" ]
3
[ [ "check_all_participants", "validate_scores" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5aedf144e709e6c7a1e2db118c13b9699339dd0f
5f49ae6727ba0be7bf298bed27a2cf55e29695b0
v1.0
complete
Taco
Taco_63105_C
def filter_primes(numbers: List[int]) -> List[int]: """ Returns a list of prime numbers from the given list of numbers. Prime numbers are integers greater than 1 that have no divisors other than 1 and themselves. Examples: >>> filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) [2, 3, 5, 7] >>> fil...
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n == 2: return True # 2 is a prime number if n % 2 == 0: return False # Eliminate even numbers greater than 2 for i in range(3, int(n**0.5) + 1, 2): if ...
from solution import filter_primes def test_filter_primes_with_primes_and_non_primes(): assert filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] assert filter_primes([11, 12, 13, 14, 15, 16]) == [11, 13] assert filter_primes([17, 18, 19, 20, 21, 22, 23]) == [17, 19, 23] assert filter_primes([...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given list of numbers.", "function_declaration": "def filte...
[ 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 if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n*...
trial_gpt4o_2
{ "original_instruction": "Create a method that takes a list of integer numbers and returns a new list that contains only the prime numbers from the original list.\n\nPrime numbers are integers greater than 1 that have no divisors other than 1 and themselves.\n\nExamples:\n```python\nfilter_primes([2, 3, 4, 5, 6, 7, ...
0.685897
Taco_63105
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bedd6031bafcc927abdb3c03de73dbcded3c416d
d43486c2d40b92f19ce7b1b22012da0cc9cdc610
v1.0
complete
Taco
Taco_63129_C
def is_pangram(sentence): """ Check if a given sentence is a pangram. >>> is_pangram("The quick brown fox jumps over the lazy dog") == True >>> is_pangram("Hello world") == False >>> is_pangram("Pack my box with five dozen liquor jugs") == True >>> is_pangram("") == False >>> is_pangram("abcdefg...
def is_pangram(sentence): """ Check if a given sentence is a pangram. :param sentence: str :return: bool """ alphabet_set = set('abcdefghijklmnopqrstuvwxyz') sentence_set = set(sentence.lower()) return alphabet_set.issubset(sentence_set) def check_pangrams(sentences): """ Determ...
from solution import is_pangram, check_pangrams def test_is_pangram(): assert is_pangram("The quick brown fox jumps over the lazy dog") == True assert is_pangram("Hello world") == False assert is_pangram("Pack my box with five dozen liquor jugs") == True assert is_pangram("") == False assert is_pan...
[ { "docstring": "Check if a given sentence is a pangram.\n:param sentence: str\n:return: bool", "function_declaration": "def is_pangram(sentence):", "function_name": "is_pangram", "parameter_list": "(sentence)" }, { "docstring": "Determine if each sentence in the list is a pangram.\n:param se...
[ 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_pangram(sentence):\n \"\"\"\n Determines if a sentence is a pangram.\n \n Parameters:\n sentence (str): The sentence to check.\n \n Ret...
trial_gpt4o_1
{ "original_instruction": "Chef is learning about pangrams and he wants to test his knowledge. A pangram is a sentence that contains every letter of the alphabet at least once.\n\nYou are given a set of sentences. For each sentence, you need to determine whether it is a pangram or not.\n\n-----Input-----\n- The first...
0.560064
Taco_63129
C
[ "is_pangram", "check_pangrams" ]
2
[ [ "check_pangrams", "is_pangram" ] ]
1
[]
false
[]
false
pytest
true
[]
true
425054fff3ff63a9c58669a337ae8ea0f5f9ce52
80851b1513299c33c6d97c368f6f2fc1a71a631d
v1.0
complete
Taco
Taco_62430_C
def rotate_matrix_90_degrees_clockwise(matrix: List[List[int]]) -> List[List[int]]: """ Rotates the given NxN matrix 90 degrees clockwise. :param matrix: List of lists, where each sublist represents a row in the matrix. :return: Rotated matrix as a list of lists. """ pass def read_matrix_and_r...
def rotate_matrix_90_degrees_clockwise(matrix): """ Rotates the given NxN matrix 90 degrees clockwise. :param matrix: List of lists, where each sublist represents a row in the matrix. :return: Rotated matrix as a list of lists. """ N = len(matrix) rotated_matrix = [[0] * N for _ in rang...
from solution import read_matrix_and_rotate, rotate_matrix_90_degrees_clockwise def test_rotate_3x3_matrix(): input_matrix = [ "3", "1 2 3", "4 5 6", "7 8 9" ] expected_output = [ "7 4 1", "8 5 2", "9 6 3" ] assert read_matrix_and_rotate(input...
[ { "docstring": "Rotates the given NxN matrix 90 degrees clockwise.\n\n:param matrix: List of lists, where each sublist represents a row in the matrix.\n:return: Rotated matrix as a list of lists.", "function_declaration": "def rotate_matrix_90_degrees_clockwise(matrix):", "function_name": "rotate_matrix...
[ 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 rotate_matrix_90_degrees_clockwise(matrix):\n \"\"\"\n Rotates the given NxN matrix 90 degrees clockwise.\n \n :param matrix: List of lists, where ...
trial_gpt4o_0
{ "original_instruction": "A unique square matrix of integers is given. The task is to rotate the matrix 90 degrees clockwise.\n\nINPUT\n\nThe first line contains an integer N, representing the size of the matrix (NxN). \nThe next N lines contain N space-separated integers each, representing the elements of the matri...
0.546593
Taco_62430
C
[ "rotate_matrix_90_degrees_clockwise", "read_matrix_and_rotate" ]
2
[ [ "read_matrix_and_rotate", "rotate_matrix_90_degrees_clockwise" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7e261bbbecbba5b6ee9093fbbae514b3e8c79266
093c4777d7f625d881165e89746cd272399ab9d3
v1.0
complete
Taco
Taco_62999_C
def minimum_swaps_to_sort(arr: List[int]) -> int: """ Determine the minimum number of swap operations required to transform a sequence into a non-decreasing sequence. >>> minimum_swaps_to_sort([3, 1, 2]) 2 >>> minimum_swaps_to_sort([5, 4, 3, 2, 1]) 10 >>> minimum_swaps_to_sort([1, 2, 3, 4]) ...
def merge_sort_and_count(arr, temp_arr, left, right): if left >= right: return 0 mid = (left + right) // 2 inv_count = merge_sort_and_count(arr, temp_arr, left, mid) inv_count += merge_sort_and_count(arr, temp_arr, mid + 1, right) inv_count += merge_and_count(arr, temp_arr, left, mid, right...
from solution import minimum_swaps_to_sort def test_case_1(): assert minimum_swaps_to_sort([3, 1, 2]) == 2 def test_case_2(): assert minimum_swaps_to_sort([5, 4, 3, 2, 1]) == 10 def test_case_3(): assert minimum_swaps_to_sort([1, 2, 3, 4]) == 0 def test_case_4(): assert minimum_swaps_to_sort([2, 3, ...
[ { "docstring": null, "function_declaration": "def merge_sort_and_count(arr, temp_arr, left, right):", "function_name": "merge_sort_and_count", "parameter_list": "(arr, temp_arr, left, right)" }, { "docstring": null, "function_declaration": "def merge_and_count(arr, temp_arr, left, mid, r...
[ 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 min_swaps_to_sorted(arr):\n \"\"\"\n Returns the minimum number of swap operations required to transform the given array \n into a non-decreasing sequ...
trial_gpt4o_3
{ "original_instruction": "Ringo loves playing with number sequences in his yellow submarine. He recently came across an interesting sequence of integers and would like to transform it into a non-decreasing sequence using the minimum number of swap operations. A swap operation allows you to choose two indices i and j...
0.644159
Taco_62999
C
[ "merge_sort_and_count", "merge_and_count", "minimum_swaps_to_sort" ]
3
[ [ "merge_sort_and_count", "merge_and_count" ], [ "minimum_swaps_to_sort", "merge_sort_and_count" ] ]
2
[]
false
[]
false
pytest
true
[]
true
aa7703d928c8a024d498640fededc3ca11a3784c
7dd1df82f113ca955dcbbb6ac76ac9cdc0f8f09e
v1.0
complete
Taco
Taco_62387_C
def select_portals(n: int, p: int, edges: List[Tuple[int, int, int]], m: int) -> List[Tuple[int, int, int]]: """ Select `m` portals to keep within the network such that all locations remain reachable, while minimizing the maximum teleportation time among the selected portals. Parameters: n (int):...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent...
import pytest from solution import select_portals def test_example_1(): n = 4 p = 5 edges = [ (1, 2, 5), (1, 3, 4), (2, 3, 2), (3, 4, 3), (2, 4, 7) ] m = 3 result = select_portals(n, p, edges, m) assert len(result) == 3 assert sorted(result) == [(...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "# This solution employs Kruskal's Algorithm to find the Minimum Spanning Tree (MST)\n# and then selectively adds edges until the desired number of edges m is reach...
trial_gpt4o_2
{ "original_instruction": "Fantasy Land is a magical place with a network of n transportation portals, which allow wizards to teleport instantly between locations. Each portal is bidirectional and connects a pair of locations with a certain teleportation time. All teleportation times are positive integers.\n\nThe Cou...
0.534917
Taco_62387
C
[ "find", "union", "select_portals" ]
3
[ [ "select_portals", "find" ], [ "select_portals", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
c4e6cde8490e69404dbc2ea07d8b54578d18ece5
ab3db0c9cbd23a00da68589c0dc9b3f152088f62
v1.0
complete
Taco
Taco_62692_C
def is_magic_square(matrix, n): """ Check whether the given n x n matrix is a magic square. Args: matrix (List[List[int]]): 2D list representing the magical square elements. n (int): Size of the matrix, an odd positive integer. Returns: int or str: The magic constant if the square is ...
def is_magic_square(matrix, n): magic_constant = sum(matrix[0]) # Check rows for row in matrix: if sum(row) != magic_constant: return "NOT MAGIC" # Check columns for col in range(n): if sum(matrix[row][col] for row in range(n)) != magic_constant: ret...
def test_is_magic_square(): assert magic_square(3, [8, 1, 6, 3, 5, 7, 4, 9, 2]) == 15 assert magic_square(5, [17, 24, 1, 8, 15, 23, 5, 7, 14, 16, 4, 6, 13, 20, 22, 10, 12, 19, 21, 3, 11, 18, 25, 2, 9]) == 65 assert magic_square(5, [11, 18, 25, 2, 9, 17, 24, 1, 8, 15, 23, 5, 7, 14, 16, 4, 6, 13, 20, 22, 10, ...
[ { "docstring": null, "function_declaration": "def is_magic_square(matrix, n):", "function_name": "is_magic_square", "parameter_list": "(matrix, n)" }, { "docstring": null, "function_declaration": "def magic_square(n, data):", "function_name": "magic_square", "parameter_list": "(n...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_magic_square(n, matrix):\n # Calculate the magic constant (sum of any row/column/diagonal)\n magic_constant = n * (n**2 + 1) // 2\n \n # Check r...
trial_gpt4o_2
{ "original_instruction": "A Magical Square\n\nIn a land far away, there exists a magical square of numbers which holds incredible significance in rituals. Each number in the magical square not only influences the power of the ritual but also follows certain mathematical properties. A magical square is a square matri...
0.699372
Taco_62692
C
[ "is_magic_square", "magic_square" ]
2
[ [ "magic_square", "is_magic_square" ] ]
1
[]
false
[]
false
pytest
false
[]
true
e4613885bcea11e314daf596c7b8d84879c1be19
c797ba3e69a8414099e99482e58a50a984f9894e
v1.0
complete
Taco
Taco_63251_C
def is_palindrome(number): """ Check if a number is a palindrome. """ def sieve_of_eratosthenes(limit): """ Generates a list of prime numbers up to 'limit' using the Sieve of Eratosthenes. """ def palindromic_primes_in_range(a, b): """ Find palindromic primes within the given range [a,...
def is_palindrome(number): """ Check if a number is a palindrome. """ return str(number) == str(number)[::-1] def sieve_of_eratosthenes(limit): """ Generates a list of prime numbers up to 'limit' using the Sieve of Eratosthenes. """ is_prime = [True] * (limit + 1) p = 2 while p ...
from solution import is_palindrome, sieve_of_eratosthenes, palindromic_primes_in_range def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(11) == True assert is_palindrome(1) == True assert is_palindrome(10) == False def test_sieve_of...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(number):", "function_name": "is_palindrome", "parameter_list": "(number)" }, { "docstring": "Generates a list of prime numbers up to 'limit' using the Sieve of Eratosthenes.", "function_declar...
[ 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_palindrome(num):\n return str(num) == str(num)[::-1]\n\ndef is_prime(num):\n if num <= 1:\n return False\n if num == 2:\n return True...
trial_gpt4o_4
{ "original_instruction": "Sarah loves palindromic numbers (numbers that read the same forward and backward) and primes (numbers greater than 1 that have no divisors other than 1 and themselves). She wonders if it's possible to find such numbers within a given range. Help Sarah by writing a program that can determine...
0.687272
Taco_63251
C
[ "is_palindrome", "sieve_of_eratosthenes", "palindromic_primes_in_range" ]
3
[ [ "palindromic_primes_in_range", "is_palindrome" ], [ "palindromic_primes_in_range", "sieve_of_eratosthenes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ad317cc0c4e618a198738747e52681dc69376108
7c953b9b2806ecea4cd8838b70f20733c5ce51fb
v1.0
complete
Taco
Taco_63128_C
def is_prime(n: int) -> bool: """ Check if a number n is a prime number. >>> is_prime(1) False >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True """ def filter_primes(numbers: List[int]) -> List[int]: """ Given a list of integers, return a ...
def is_prime(n): """ Check 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_prime, filter_primes def test_is_prime(): assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert is_prime(13) assert not is_prime(15) assert is_prime(29) assert not is_prime(30) assert is_prime(101) ...
[ { "docstring": "Check if a number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given a list of integers, return a list with only the prime numbers.", "function_declaration": "def filter_primes(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(n):\n \"\"\"\n Checks if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_2
{ "original_instruction": "## Description\nDesign a function that takes a list of integers as input and returns a new list that contains only the prime numbers from the original list.\n- A prime number is a natural number greater than 1 that is not a product of two smaller natural numbers.\n- Implement an efficient a...
0.758434
Taco_63128
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8765168043218575f37745fb06e9eedc463c41c5
0631be1aaddd5779a446adacd5e231a85e5d8519
v1.0
complete
Taco
Taco_62800_C
def preprocess_segments(data_points, k): """Preprocess the data points into k segments and sort each segment.""" pass def compute_prefix_sums(sorted_data_points): """Compute prefix sums for the sorted data points to facilitate range queries.""" pass def range_query(prefix_sums, left, right): """Co...
def preprocess_segments(data_points, k): """ Preprocess the data points into k segments and sort each segment. """ # Calculate segment size segment_size = len(data_points) // k remainder = len(data_points) % k segments = [] index = 0 for i in range(k): size = segmen...
def test_preprocess_segments(): data_points = [5, 2, 9, 1, 7, 3] k = 3 expected_segments = [[2, 5], [1, 9], [3, 7]] assert preprocess_segments(data_points, k) == expected_segments def test_compute_prefix_sums(): sorted_data_points = [1, 2, 3, 5, 7, 9] expected_prefix_sums = [0, 1, 3, 6, 11, 18,...
[ { "docstring": "Preprocess the data points into k segments and sort each segment.", "function_declaration": "def preprocess_segments(data_points, k):", "function_name": "preprocess_segments", "parameter_list": "(data_points, k)" }, { "docstring": "Compute prefix sums for the sorted data poin...
[ 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 range_query(n, k, q, data_points, queries):\n \"\"\"\n Divides data points into k segments, sorts each segment, and processes range queries.\n \"\"\"\...
trial_gpt4o_2
{ "original_instruction": "You work as a software engineer at a company that handles a lot of data collections. Your data team has a collection of n data points and they want you to help them organize the data in a way that allows them to quickly find specific ranges of data points.\n\nYou decide to implement a range...
0.597494
Taco_62800
C
[ "preprocess_segments", "compute_prefix_sums", "range_query", "range_query_solution" ]
4
[ [ "range_query_solution", "compute_prefix_sums" ], [ "range_query_solution", "preprocess_segments" ], [ "range_query_solution", "range_query" ] ]
3
[]
false
[]
false
pytest
false
[]
true
ae739952282799de2e2db1cb97a9deff6c50e3d4
f29039fdc9f1ced878c6b6e1054257576b34f6d6
v1.0
complete
Taco
Taco_62906_C
def maximal_rectangle(matrix: List[List[int]]) -> int: """ Find the largest rectangle containing only ones in the given matrix and return its area. >>> maximal_rectangle([ ... [1, 0, 1, 0, 0], ... [1, 0, 1, 1, 1], ... [1, 1, 1, 1, 1], ... [1, 0, 0, 1, 0] ... ]) 6 >>> maximal_rectangl...
def maximal_rectangle(matrix): if not matrix or not matrix[0]: return 0 n = len(matrix) m = len(matrix[0]) max_area = 0 heights = [0] * m for row in matrix: for i in range(m): heights[i] = heights[i] + 1 if row[i] == 1 else 0 max_area = max(max_area, largest_r...
from solution import maximal_rectangle def test_maximal_rectangle_case_1(): matrix = [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0] ] assert maximal_rectangle(matrix) == 6 def test_maximal_rectangle_case_2(): matrix = [ [0, 1, 1, 0], ...
[ { "docstring": null, "function_declaration": "def maximal_rectangle(matrix):", "function_name": "maximal_rectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largest_rectangle_area(heights):", "function_name": "largest_rectangle_area", "pa...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximal_rectangle(matrix):\n if not matrix:\n return 0\n\n max_area = 0\n n = len(matrix)\n m = len(matrix[0])\n heights = [0] * (m + 1)\...
trial_gpt4o_2
{ "original_instruction": "# Story&Task\nYou are given a rectangular matrix of size n x m that contains only ones and zeroes. Find the largest rectangle (containing only ones) and return its area.\n\n# Input/Output\n- `[input]` 2D integer array `matrix`\n The array of integers representing the matrix. The values are...
0.747224
Taco_62906
C
[ "maximal_rectangle", "largest_rectangle_area" ]
2
[ [ "maximal_rectangle", "largest_rectangle_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5130c52aae885ed2bb95d0f26158a996693dccf6
3e744d17ea2b91a32c74a11e9164b6aa21378cc7
v1.0
complete
Taco
Taco_62571_C
import math from itertools import permutations def calculate_distance(point1, point2): """Calculate the Euclidean distance between two points in a 2D plane.""" return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2) def get_minimum_distance(n, locations): """ Given the number of...
from itertools import permutations import math def calculate_distance(point1, point2): """ Calculate the Euclidean distance between two points in a 2D plane. """ return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2) def get_minimum_distance(n, locations): """ Given the ...
import pytest from solution import logistics_company def test_example_case(): input_data = "4\n0 2\n2 2\n2 0\n0 0" assert logistics_company(input_data) == 8 def test_two_locations(): input_data = "2\n1 1\n1 0" result = logistics_company(input_data) expected = round( calculate_distance((0, ...
[ { "docstring": "Calculate the Euclidean distance between two points in a 2D plane.", "function_declaration": "def calculate_distance(point1, point2):", "function_name": "calculate_distance", "parameter_list": "(point1, point2)" }, { "docstring": "Given the number of delivery locations and th...
[ 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": "from itertools import permutations\nimport math\n\ndef calculate_distance(x1, y1, x2, y2):\n return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)\n\ndef minimum_to...
trial_gpt4o_7
{ "original_instruction": "A logistics company needs to optimize the delivery routes for its fleet of trucks. Each truck starts from a central warehouse (point 0) and makes deliveries to multiple locations represented as points on a 2D plane. The objective is to minimize the total distance traveled by each truck.\n\n...
0.608831
Taco_62571
C
[ "calculate_distance", "get_minimum_distance", "logistics_company" ]
3
[ [ "get_minimum_distance", "calculate_distance" ], [ "logistics_company", "get_minimum_distance" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b9fbf8711c2b6e37f2f0b7dd643fc9f2397ecd58
b65d042556688d73872714e52135ad1280482477
v1.0
complete
Taco
Taco_63474_C
def filter_primes(input_list): """ Filters and returns the list with only the prime numbers from the original list. A prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. >>> filter_primes([4, 5, 6, 7, 8]) # returns [5, 7] >>> filter_primes([2, 3, 5...
def is_prime(n): """ Determines whether a given 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 ...
from solution import filter_primes def test_filter_primes_with_mixed_list(): assert filter_primes([4, 5, 6, 7, 8]) == [5, 7] def test_filter_primes_with_all_prime_numbers(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_with_no_prime_numbers(): assert filter_primes([4,...
[ { "docstring": "Determines whether a given number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters the prime numbers from the input list.", "function_declaration": "def filter_primes(input_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(n):\n \"\"\"\n Determines whether a given number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_0
{ "original_instruction": "Write a function that takes a list of integers as input and returns the list with only the prime numbers from the original list. A prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. For example, 2, 3, 5, 7, and 11 are prime numbers.\n\nFor ...
0.649821
Taco_63474
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
aa2ddca8d34f7cd3dd99c19c7c19fe03de801721
15997aed172dbcde9ef6690d783e2cb819cd81e2
v1.0
complete
Taco
Taco_63404_C
def solve_fibonacci_cases(test_cases: List[int]) -> List[int]: """ Chris is fascinated by Fibonacci numbers and has recently come across a new challenge. He wants to write a program that generates the nth Fibonacci number efficiently. The Fibonacci sequence is defined as follows: F(0) = 0 F(1) = 1 ...
MOD = 10**9 + 7 def matrix_multiply(A, B, mod=MOD): """ Multiplies two 2x2 matrices A and B under modulo. """ return [ [(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % mod, (A[0][0] * B[0][1] + A[0][1] * B[1][1]) % mod], [(A[1][0] * B[0][0] + A[1][1] * B[1][0]) % mod, (A[1][0] * B[0][1] + A[1...
from solution import solve_fibonacci_cases def test_single_case(): assert solve_fibonacci_cases([0]) == [0] def test_base_cases(): assert solve_fibonacci_cases([0, 1]) == [0, 1] def test_small_cases(): assert solve_fibonacci_cases([10]) == [55] assert solve_fibonacci_cases([2, 3, 4]) == [1, 2, 3] de...
[ { "docstring": "Multiplies two 2x2 matrices A and B under modulo.", "function_declaration": "def matrix_multiply(A, B, mod=MOD):", "function_name": "matrix_multiply", "parameter_list": "(A, B, mod=MOD)" }, { "docstring": "Computes the power of a matrix to the nth power under modulo.", "f...
[ 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 fibonacci_modulo(n, MOD=10**9 + 7):\n \"\"\"\n Computes the nth Fibonacci number modulo MOD.\n \"\"\"\n if n == 0:\n return 0\n if n == 1...
trial_gpt4o_7
{ "original_instruction": "Chris is fascinated by Fibonacci numbers and has recently come across a new challenge. He wants to write a program that generates the nth Fibonacci number efficiently. The Fibonacci sequence is defined as follows: \n\n\\[ F(0) = 0 \\] \n\\[ F(1) = 1 \\] \n\\[ F(n) = F(n-1) + F(n-2) \\text...
0.768064
Taco_63404
C
[ "matrix_multiply", "matrix_power", "fibonacci_mod", "solve_fibonacci_cases" ]
4
[ [ "fibonacci_mod", "matrix_power" ], [ "matrix_power", "matrix_multiply" ], [ "solve_fibonacci_cases", "fibonacci_mod" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8703b6bf102d89987c98178933c2a3dd7cdbd457
af695c5f2e1aa8fe9d73332c203919cf17dc966d
v1.0
complete
Taco
Taco_62679_C
def can_place_tetromino(grid, tetromino, pos_x, pos_y): """ Checks if a given tetromino can be placed on the grid at the specified position without overlapping any filled cells. :param grid: List of strings representing the grid :param tetromino: List of tuples representing the relative positions o...
def can_place_tetromino(grid, tetromino, pos_x, pos_y): """ Checks if a given tetromino can be placed on the grid at the specified position without overlapping any filled cells. :param grid: List of strings representing the grid :param tetromino: List of tuples representing the relative positions o...
from solution import tetris_fit_checker def test_tetris_fit_checker_simple_yes(): n = 5 m = 5 grid = [ '.....', '.....', '.....', '.....', '.....' ] t = 4 tetromino = [(0, 0), (0, 1), (1, 0), (1, 1)] x = 2 y = 2 assert tetris_fit_checker(n, m,...
[ { "docstring": "Checks if a given tetromino can be placed on the grid at the specified position without overlapping any filled cells.\n\n:param grid: List of strings representing the grid\n:param tetromino: List of tuples representing the relative positions of the tetromino cells\n:param pos_x: Integer represen...
[ 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 can_place_tetromino(n, m, grid, t, tetromino_positions, x, y):\n for delta_r, delta_c in tetromino_positions:\n new_r = x + delta_r\n new_c = ...
trial_gpt4o_5
{ "original_instruction": "In the popular game of \"Tetris,\" players manipulate various shapes (tetrominoes) to complete and clear lines on a grid. One important aspect of the game is determining whether a newly spawned tetromino can be placed on the grid without any overlaps with existing blocks.\n\nWrite a program...
0.595881
Taco_62679
C
[ "can_place_tetromino", "tetris_fit_checker" ]
2
[ [ "tetris_fit_checker", "can_place_tetromino" ] ]
1
[]
false
[]
false
pytest
true
[]
true
507907d53cc68bb296a19f10abbcc27367894912
ec87f909fc48adb146f800372776ae278b423f18
v1.0
complete
Taco
Taco_63632_C
def find_min_movements_to_destination(input_string: str) -> int: """ In a 2D grid of size n x m, guide the robot to reach the destination (dr, dc) from the initial position (sr, sc). Determine the minimum number of movements required or if it's impossible. >>> input_string = "5 5\n1 1\n5 5\n.....\n...
from collections import deque def min_movements(n, m, sr, sc, dr, dc, grid): """ Function to find the minimum number of movements required for the robot to reach the destination (dr, dc) from (sr, sc). Return -1 if it is impossible. """ # Converting positions from 1-based index to 0-based index ...
from solution import find_min_movements_to_destination def test_sample_case(): input_string = """5 5 1 1 5 5 ..... .*... ..... ...*. .....""" assert find_min_movements_to_destination(input_string) == 8 def test_no_possible_path(): input_string = """3 3 1 1 3 3 ..* .*. *..""" assert find_min_movements_...
[ { "docstring": "Function to find the minimum number of movements required for the robot to reach the destination (dr, dc) from (sr, sc).\nReturn -1 if it is impossible.", "function_declaration": "def min_movements(n, m, sr, sc, dr, dc, grid):", "function_name": "min_movements", "parameter_list": "(n...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_moves(n, m, sr, sc, dr, dc, grid):\n # Convert input positions to 0-indexed.\n sr -= 1\n sc -= 1\n dr -= 1\n ...
trial_gpt4o_3
{ "original_instruction": "In a 2D grid of size n x m, you are given the initial position of a robot starting at (sr, sc). The robot can only move up, down, left, or right, but cannot move onto blocked cells (denoted by '*'). Open cells are represented by '.'.\n\nYour objective is to guide the robot to reach a destin...
0.704782
Taco_63632
C
[ "min_movements", "find_min_movements_to_destination" ]
2
[ [ "find_min_movements_to_destination", "min_movements" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3216159c3bf0c410ec7e14a15ba904f80d5113e0
c51c2aedcabd75c58f65fd18faa25a24db80848b
v1.0
complete
Taco
Taco_63555_C
def next_palindrome(n: int) -> int: """ Finds the smallest palindrome greater than or equal to the given number. >>> next_palindrome(121) 121 >>> next_palindrome(123) 131 """ def find_next_palindromes(numbers: List[int]) -> List[int]: """ For each input number, find the smallest palindrome ...
def next_palindrome(n): """ Finds the smallest palindrome greater than or equal to the given number. """ def is_palindrome(x): s = str(x) return s == s[::-1] while not is_palindrome(n): n += 1 return n def find_next_palindromes(numbers): results = [] for num...
from solution import next_palindrome, find_next_palindromes def test_next_palindrome_exact_palindrome(): assert next_palindrome(121) == 121 def test_next_palindrome_non_palindrome(): assert next_palindrome(123) == 131 def test_find_next_palindromes_single(): assert find_next_palindromes([132]) == [141] ...
[ { "docstring": "Finds the smallest palindrome greater than or equal to the given number.", "function_declaration": "def next_palindrome(n):", "function_name": "next_palindrome", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def find_next_palindromes(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_palindrome(num):\n \"\"\"\n Helper function to check if a number is a palindrome.\n \"\"\"\n return str(num) == str(num)[::-1]\n\ndef next_palin...
trial_gpt4o_2
{ "original_instruction": "In a coding competition, Alice and Bob are having fun with palindromes. A palindrome is a string that reads the same forward and backward. Alice has a special interest in numbers that form palindromes.\n\nAlice is given an integer and she wants to find out the smallest palindrome greater th...
0.685495
Taco_63555
C
[ "next_palindrome", "find_next_palindromes" ]
2
[ [ "find_next_palindromes", "next_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d4316c71b792c9eee4989b701caf34cc295496c3
2815af3c9700598d65f39a1bae3ccca30c9cbc39
v1.0
complete
Taco
Taco_63485_C
from typing import List def maximalRectangle(matrix: List[List[int]]) -> int: """ This function calculates the area of the largest rectangle consisting only of 1's in a binary matrix. >>> maximalRectangle([[1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0]]) 6 >>> maximal...
def largestRectangleArea(heights): """ This function calculates the area of the largest rectangle in a histogram given by heights. """ stack = [] max_area = 0 heights.append(0) # Add a zero height to flush out remaining rectangles for i, h in enumerate(heights): while stack and heig...
import pytest from solution import maximalRectangle def test_example_case(): grid = [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0] ] assert maximalRectangle(grid) == 6 def test_all_zeros(): grid = [ [0, 0], [0, 0] ] assert m...
[ { "docstring": "This function calculates the area of the largest rectangle in a histogram given by heights.", "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "parameter_list": "(heights)" }, { "docstring": "This function calculates the a...
[ 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 \"\"\"\n Returns the area of the largest rectangle containing only 1's in a binary matrix.\n \"\"\"\n if not matrix:\n ...
trial_gpt4o_2
{ "original_instruction": "You are given a rectangular grid of size n x m. Each cell in the grid contains either a 0 or a 1. A cell containing a 1 is considered to be a part of a building, and a cell containing a 0 is considered to be open land. Your goal is to find the largest rectangular area consisting entirely of...
0.710448
Taco_63485
C
[ "largestRectangleArea", "maximalRectangle" ]
2
[ [ "maximalRectangle", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
true
[]
true
012e353d905eab99f6fb7148bd1ed5893ecf6031
35ea65ce29a8c35397f11d015b42cb9a8b567490
v1.0
complete
Taco
Taco_63578_C
def find_minimized_max_pages(n: int, pages: List[int], k: int) -> int: """ Given an array of positive integers representing the number of pages in different notebooks, and a positive integer k, which represents the number of students, divide the notebooks among the k students in such a way that the m...
def is_valid_distribution(pages, n, k, max_pages_per_student): required_students = 1 current_pages = 0 for i in range(n): if current_pages + pages[i] > max_pages_per_student: required_students += 1 current_pages = pages[i] if required_students > k: ...
from solution import find_minimized_max_pages def test_example_case(): assert find_minimized_max_pages(4, [12, 34, 67, 90], 2) == 113 def test_single_student_multiple_notebooks(): assert find_minimized_max_pages(3, [10, 20, 30], 1) == 60 def test_single_notebook_multiple_students(): assert find_minimized...
[ { "docstring": null, "function_declaration": "def is_valid_distribution(pages, n, k, max_pages_per_student):", "function_name": "is_valid_distribution", "parameter_list": "(pages, n, k, max_pages_per_student)" }, { "docstring": null, "function_declaration": "def find_minimized_max_pages(...
[ 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_valid_distribution(pages, n, k, max_pages_per_student):\n required_students = 1\n current_pages = 0\n\n for i in range(n):\n if current_page...
trial_gpt4o_0
{ "original_instruction": "Given an array of positive integers representing the number of pages in different notebooks, and a positive integer k, which represents the number of students, divide the notebooks among the k students in such a way that the maximum number of pages assigned to a student is minimized. Each s...
0.642079
Taco_63578
C
[ "is_valid_distribution", "find_minimized_max_pages" ]
2
[ [ "find_minimized_max_pages", "is_valid_distribution" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dbc2b474b0c6b9d60b244ccf6ede2bf4965fe419
1f2477a24b6a1d35cbd0f6b204d31e076df36226
v1.0
complete
Taco
Taco_63144_C
from typing import List def lcm(a, b): """ Helper function to compute least common multiple (LCM) of two numbers. """ pass # Replace this with your implementation def lcm_multiple(numbers): """ Helper function to compute LCM of multiple numbers. """ pass # Replace this with your implementation def ...
from math import gcd from functools import reduce def lcm(a, b): return a * b // gcd(a, b) def lcm_multiple(numbers): return reduce(lcm, numbers, 1) def count_simultaneous_arrivals(D, bus_times): """ Returns the number of times all buses arrive at the central station simultaneously in a day. ...
from solution import main def test_sample_cases(): test_cases = [ (60, [15, 20]), # Sample Input 1 (100, [30, 40, 50]) # Sample Input 2 ] results = main(test_cases) assert results == [2, 1] def test_one_bus(): test_cases = [ (60, [15]), # Each 15 minutes in an hour, 5 in...
[ { "docstring": null, "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def lcm_multiple(numbers):", "function_name": "lcm_multiple", "parameter_list": "(numbers)" }, { "docstring":...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom functools import reduce\n\ndef gcd(a, b):\n \"\"\"Returns the Greatest Common Divisor of a and b using the Euclidean algorithm.\"\"\"\n whi...
trial_gpt4o_6
{ "original_instruction": "The city of Algoland is planning a new public transportation system. The project involves rotating buses servicing multiple routes. Each bus follows a circular route which it completes in a fixed amount of time. The transportation department wants to analyze the synchronization of bus arriv...
0.553907
Taco_63144
C
[ "lcm", "lcm_multiple", "count_simultaneous_arrivals", "main" ]
4
[ [ "count_simultaneous_arrivals", "lcm_multiple" ], [ "lcm_multiple", "lcm" ] ]
2
[]
false
[]
false
pytest
true
[]
true
55a0ee78af22856d7d483abaaf19b91702424eb2
e40eafe32105de2c82abb7860b011f54b6caced3
v1.0
complete
Taco
Taco_63429_C
def check_bst(nodes_data: List[Tuple[int, int, int]]) -> str: """ Check if a given binary tree is a Binary Search Tree (BST). >>> check_bst([(10, -1, -1)]) == "YES" >>> check_bst([(10, -1, 1), (20, -1, -1)]) == "YES" >>> check_bst([(10, 1, -1), (5, -1, -1)]) == "YES" >>> check_bst([(10, 1, 2), (5, -...
class TreeNode: def __init__(self, value, left=-1, right=-1): self.value = value self.left = left self.right = right def is_bst_helper(tree, node_idx, min_val, max_val): if node_idx == -1: return True node = tree[node_idx] if not (min_val < node.value < max_val): ...
from solution import check_bst def test_single_node(): assert check_bst([(10, -1, -1)]) == "YES" def test_two_nodes_right_child(): assert check_bst([(10, -1, 1), (20, -1, -1)]) == "YES" def test_two_nodes_left_child(): assert check_bst([(10, 1, -1), (5, -1, -1)]) == "YES" def test_three_nodes_valid_bst(...
[]
[ 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, value, left, right):\n self.value = value\n self.left = left\n self.right = right\n\ndef is_bst_util(n...
trial_gpt4o_1
{ "original_instruction": "Marcus is learning about binary trees and wants to write a program to check if a given binary tree is a Binary Search Tree (BST). A BST is defined as a binary tree in which for each node:\n\n- The value of all the nodes in the left subtree is less than the value of the current node.\n- The ...
0.607921
Taco_63429
C
[ "is_bst_helper", "is_bst", "build_tree", "check_bst" ]
4
[ [ "check_bst", "build_tree" ], [ "check_bst", "is_bst" ], [ "is_bst", "is_bst_helper" ] ]
3
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
3d25c4e4f9fe4ae15994c78cd3a6d2dcde7cafdd
1ab4933044e58e45a1189adec6d800135de92db4
v1.0
complete
Taco
Taco_62990_C
from typing import List, Tuple def min_toll_fees(n: int, edges: List[Tuple[int, int, int]], queries: List[Tuple[int, int]]) -> List[int]: """ Compute the minimum toll fee for each query regarding the travel from city a to city b. Args: n (int): the number of cities. edges (List[Tuple[int, int, int]]): ...
import sys from collections import defaultdict import heapq def create_graph(n, edges): graph = defaultdict(list) for u, v, w in edges: graph[u].append((v, w)) graph[v].append((u, w)) return graph def dijkstra(graph, start, end): heap = [(0, start)] visited = set() min_cost = {...
from solution import min_toll_fees def test_example_case(): n = 5 edges = [ (1, 2, 3), (1, 3, 4), (2, 4, 5), (2, 5, 6) ] queries = [ (1, 4), (4, 5), (3, 5) ] expected = [8, 11, 13] assert min_toll_fees(n, edges, queries) == expected d...
[ { "docstring": null, "function_declaration": "def create_graph(n, edges):", "function_name": "create_graph", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def dijkstra(graph, start, end):", "function_name": "dijkstra", "parameter_list": "(graph, ...
[ 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 sys\nfrom collections import defaultdict, deque\n\n# Function to build the tree as a graph\ndef build_tree(n, edges):\n graph = defaultdict(list)\n fo...
trial_gpt4o_1
{ "original_instruction": "There is a road network between several cities, represented as a tree with $n$ nodes (cities) and $n-1$ edges (roads). All roads are bidirectional. Each road has a given toll fee associated with it. The toll fee between the $i$-th city and the $j$-th city is represented by an integer $c(i, ...
0.649744
Taco_62990
C
[ "create_graph", "dijkstra", "min_toll_fees" ]
3
[ [ "min_toll_fees", "create_graph" ], [ "min_toll_fees", "dijkstra" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ec48a8fa056e2974db6a1940dbf3e113b5d46fae
a74e0f0890013a67bee3bfe9c2ddc4922ae13ecc
v1.0
complete
Taco
Taco_63595_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(adjacency_list): if not adjacency_list: return None nodes = {} for val, left, right in adjacency_list: if val not in nodes: ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(adjacency_list): if not adjacency_list: return None nodes = {} for val, left, right in adjacency_list: if val not in nodes: ...
import pytest from solution import rearrange_tree def test_rearrange_tree(): input_tree = [(5, 2, 3), (2, 0, 0), (3, 4, 0), (4, 0, 0)] expected_output = [(14, 2, 7), (2, 0, 0), (7, 4, 0), (4, 0, 0)] assert rearrange_tree(input_tree) == expected_output def test_single_node_tree(): input_tree = [(1, 0, ...
[]
[ 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": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_6
{ "original_instruction": "You are given a binary tree where each node contains a positive integer value. Your task is to rearrange the tree such that each node in the tree contains the sum of its original value and the original values of all its descendant nodes (i.e., all nodes in its subtree).\n\nA subtree of a no...
0.600129
Taco_63595
C
[ "build_tree", "tree_to_adjacency_list", "update_subtree_sum", "rearrange_tree" ]
4
[ [ "rearrange_tree", "build_tree" ], [ "rearrange_tree", "tree_to_adjacency_list" ], [ "rearrange_tree", "update_subtree_sum" ] ]
3
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
5e0525203801a1f249c989c1f4b88e70f06476ac
2ce3e0ad9c99498724afe601694761fc5bcc4f80
v1.0
complete
Taco
Taco_63905_C
def solve(input_string: str) -> int: """ Returns the maximum sum of a contiguous subsequence in the given sequence. >>> solve("-2 1 -3 4 -1 2 1 -5 4") 6 >>> solve("-1 -2 -3 -4") -1 >>> solve("5") 5 >>> solve("-5") -5 >>> solve("1 2 3 4 5") 15 >>> solve("-2 -3 4 -1 -2 1 5 -3") 7 ...
def max_subarray_sum(sequence): """ Returns the maximum sum of a contiguous subsequence in the given sequence. """ max_current = max_global = sequence[0] for num in sequence[1:]: max_current = max(num, max_current + num) if max_current > max_global: max_global = max_...
from solution import solve def test_example_case(): assert solve("-2 1 -3 4 -1 2 1 -5 4") == 6 def test_all_negative_numbers(): assert solve("-1 -2 -3 -4") == -1 def test_single_element(): assert solve("5") == 5 assert solve("-5") == -5 def test_all_positive_numbers(): assert solve("1 2 3 4 5") ...
[ { "docstring": "Returns the maximum sum of a contiguous subsequence in the given sequence.", "function_declaration": "def max_subarray_sum(sequence):", "function_name": "max_subarray_sum", "parameter_list": "(sequence)" }, { "docstring": null, "function_declaration": "def solve(input_str...
[ 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 max_subarray_sum(sequence):\n \"\"\"\n Given a sequence of integers, return the maximum sum of a contiguous subsequence.\n \"\"\"\n # Convert the s...
trial_gpt4o_1
{ "original_instruction": "You are given a sequence of numbers, and you need to find a contiguous subsequence which, when its elements are summed, yields the highest possible value. You need to implement a function that returns this maximum sum.\n\n**Input**\n\nA single line that contains space-separated integers rep...
0.630947
Taco_63905
C
[ "max_subarray_sum", "solve" ]
2
[ [ "solve", "max_subarray_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4b4177c2bca0ffa8014656b4a6157ba64225f76d
744b296933cc267e4dae720c09f309c381561fc3
v1.0
complete
Taco
Taco_63798_C
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6...
from solution import find_three_primes_sum def test_case_1(): assert find_three_primes_sum(23) == "YES" def test_case_2(): assert find_three_primes_sum(7) == "NO" def test_case_3(): assert find_three_primes_sum(10) == "YES" def test_case_4(): assert find_three_primes_sum(18) == "YES" def test_case_...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Determine if the number n can be expressed as the sum of three distinct primes.", "function_declaration": "def find_three_...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.111
{ "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_9
{ "original_instruction": "Given a positive integer $n$, you are required to find out if $n$ can be expressed as a sum of three distinct prime numbers.\n\nConstraints\n\n$1 \\leq n \\leq 5000$\n\nInput Format\n\nFirst and only line of the input will contain an integer $n$.\n\nOutput Format\n\nOutput \"YES\" if $n$ ca...
0.779
Taco_63798
C
[ "is_prime", "find_three_primes_sum" ]
2
[ [ "find_three_primes_sum", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
368faf07ee0cbfa481647aa4a76d023ffe2daaee
151d2789aa75d1e40efaffcb0f9b4c9be7f15e2f
v1.0
complete
Taco
Taco_63643_C
class TreeNode: def __init__(self, data): self.data = data self.left = None self.right = None class DoublyLinkedListNode: def __init__(self, data): self.data = data self.prev = None self.next = None def convertToSortedDLL(root: TreeNode) -> DoublyLinkedListNode:...
class TreeNode: def __init__(self, data): self.data = data self.left = None self.right = None class DoublyLinkedListNode: def __init__(self, data): self.data = data self.prev = None self.next = None def bst_insert(root, key): if root is None: return ...
import pytest def test_convert_single_node(): values = [10] bst_root = build_bst_from_list(values) dll_head = convertToSortedDLL(bst_root) assert print_dll(dll_head) == [10] def test_convert_multiple_nodes(): values = [4, 2, 1, 3, 6, 5, 7] bst_root = build_bst_from_list(values) dll_head = ...
[]
[ 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, data):\n self.data = data\n self.left = None\n self.right = None\n\nclass DoublyLinkedListNode:\n d...
trial_gpt4o_0
{ "original_instruction": "Given a binary search tree (BST) of N nodes, your task is to complete the function convertToSortedDLL() that converts the BST into a sorted doubly linked list (in-place). The left pointer of the tree node should act as a previous pointer in the doubly linked list and the right pointer shoul...
0.441918
Taco_63643
C
[ "bst_insert", "convertToSortedDLL", "print_dll", "build_bst_from_list" ]
4
[ [ "build_bst_from_list", "bst_insert" ] ]
1
[]
false
[ "TreeNode", "DoublyLinkedListNode" ]
true
pytest
false
[]
true
f6dbf5737b2334751acd15454be59f9db2fcb8d6
242fd1bc62ddc8cb3072e4545d4fe2f786059613
v1.0
complete
Taco
Taco_63590_C
def find_minimized_max_distance(n: int, distances: List[int]) -> int: """ Given a list of distances between various points, divide them into clusters such that the maximum distance within any cluster is minimized. Args: n (int): the number of distances distances (List[int]): the list of distanc...
def can_partition(distances, max_distance): current_sum = 0 for distance in distances: if current_sum + distance <= max_distance: current_sum += distance else: if distance > max_distance: return False current_sum = distance return True def...
import pytest from solution import find_minimized_max_distance def test_case_1(): n = 6 distances = [1, 5, 2, 4, 8, 3] assert find_minimized_max_distance(n, distances) == 8 def test_case_2(): n = 4 distances = [1, 2, 3, 100] assert find_minimized_max_distance(n, distances) == 100 def test_cas...
[ { "docstring": null, "function_declaration": "def can_partition(distances, max_distance):", "function_name": "can_partition", "parameter_list": "(distances, max_distance)" }, { "docstring": null, "function_declaration": "def find_minimized_max_distance(n, distances):", "function_name...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def minimized_max_distance(n, distances):\n \"\"\"\n Divides the list of distances into clusters such that the maximum distance within any cluster is minimiz...
trial_gpt4o_9
{ "original_instruction": "Your task is to develop a program that helps in clustering a list of distances. Given a list of distances between various points, you need to divide them into clusters such that the maximum distance within any cluster is minimized. The clusters must maintain the order of the distances as in...
0.663022
Taco_63590
C
[ "can_partition", "find_minimized_max_distance" ]
2
[ [ "find_minimized_max_distance", "can_partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
67666c7a9e5e945ec96668eb00031145210cd701
9a94ddff58a62de221a2a460f9e8acb81f0efed6
v1.0
complete
Taco
Taco_63616_C
from typing import List, Tuple def can_make_all_elements_equal(test_cases: List[Tuple[int, List[int]]]) -> List[str]: """ Determine if you can make all integers in the given lists equal in some number of operations. In one operation, you can pick any two integers from the list and replace each of the...
def can_make_all_elements_equal(test_cases): def gcd(x, y): while y: x, y = y, x % y return x results = [] for case in test_cases: n, arr = case if n == 1: results.append("YES") continue common_gcd = arr[0] for num in arr[...
from solution import can_make_all_elements_equal def test_example_cases(): test_cases = [ (4, [3, 3, 6, 12]), (2, [5, 10]), (3, [30, 60, 90]), ] assert can_make_all_elements_equal(test_cases) == ["YES", "YES", "YES"] def test_single_element(): test_cases = [ (1, [1]), ...
[ { "docstring": null, "function_declaration": "def can_make_all_elements_equal(test_cases):", "function_name": "can_make_all_elements_equal", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", "parameter_list"...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_make_all_equal(t, test_cases):\n results = []\n for i in range(t):\n n = test_cases[i][0]\n a = test_cases[i][1]\n \n if ...
trial_gpt4o_2
{ "original_instruction": "You are given a list of integers. In one operation, you can pick any two integers from the list and replace each of them with their average. The new values should still be integers. The task is to determine if you can make all integers in the list equal in some number of operations.\n\nFor ...
0.619922
Taco_63616
C
[ "can_make_all_elements_equal", "solve" ]
2
[ [ "solve", "can_make_all_elements_equal" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0750f355a882103d6fc3ca1fb16cc28064578001
a06004a63964b92cd0b08f271da54b2ee595c7d5
v1.0
complete
Taco
Taco_63807_C
def solve_maze(N: int, M: int, maze_lines: List[str], start_end_positions: Tuple[int, int, int, int]) -> int: """ Determine the minimum number of steps required to move from the start position (Sx, Sy) to the end position (Ex, Ey) in a maze represented by a 2D grid. >>> solve_maze(5, 5, [".....", ".###.", "..#....
from collections import deque def min_steps(maze, Sx, Sy, Ex, Ey): N = len(maze) M = len(maze[0]) if maze[Sx][Sy] == '#' or maze[Ex][Ey] == '#': return -1 directions = [(0, 1), (0, -1), (1, 0), (-1, 0)] visited = [[False] * M for _ in range(N)] queue = deque([(Sx, Sy, 0)]) ...
def test_min_steps_in_clear_path(): maze = [ ".....", ".....", ".....", ".....", "....." ] result = solve_maze(5, 5, maze, (0, 0, 4, 4)) assert result == 8 def test_min_steps_with_obstacles(): maze = [ ".....", ".###.", "..#..", ...
[ { "docstring": null, "function_declaration": "def min_steps(maze, Sx, Sy, Ex, Ey):", "function_name": "min_steps", "parameter_list": "(maze, Sx, Sy, Ex, Ey)" }, { "docstring": null, "function_declaration": "def solve_maze(N, M, maze_lines, start_end_positions):", "function_name": "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": "from collections import deque\n\ndef min_steps(maze, Sx, Sy, Ex, Ey):\n N = len(maze)\n M = len(maze[0])\n \n if maze[Sx][Sy] == '#' or maze[Ex][Ey] ==...
trial_gpt4o_0
{ "original_instruction": "A programming competition is being held where participants are to solve a maze game. The maze is represented by a 2D grid where empty cells are represented by a dot `.` and obstacles are represented by a hash sign `#`. The goal is to find the minimum number of steps required to move from th...
0.644756
Taco_63807
C
[ "min_steps", "solve_maze" ]
2
[ [ "solve_maze", "min_steps" ] ]
1
[]
false
[]
false
pytest
false
[]
true
d7f4ef81d069f02db829da0962e1fae9c6109693
7edae871ab0fa89477794e3b2278b32604ca3db2
v1.0
complete
Taco
Taco_63788_C
from typing import List def largest_odd_submatrix_area(matrix: List[List[int]]) -> int: """ Write a program that finds the largest rectangular sub-matrix with elements that are all odd numbers within a given matrix. >>> parse_input("4 5\n1 -3 5 7 2\n4 -1 -3 5 9\n1 3 7 2 4\n2 4 9 11 13") [[1, -3, 5, 7, 2], ...
def largest_odd_submatrix_area(matrix): n = len(matrix) m = len(matrix[0]) # Convert the matrix into a 0/1 matrix where 1 represents odd number and 0 represents even number bin_matrix = [[1 if matrix[i][j] % 2 != 0 else 0 for j in range(m)] for i in range(n)] max_area = 0 # Store the maxi...
from solution import largest_odd_submatrix_area, parse_input def test_single_element_matrix(): matrix = parse_input("1 1\n1") assert largest_odd_submatrix_area(matrix) == 1 matrix = parse_input("1 1\n2") assert largest_odd_submatrix_area(matrix) == 0 def test_all_odd_matrix(): matrix = parse_i...
[ { "docstring": null, "function_declaration": "def largest_odd_submatrix_area(matrix):", "function_name": "largest_odd_submatrix_area", "parameter_list": "(matrix)" }, { "docstring": "Helper function to determine the largest rectangle area in histogram. ", "function_declaration": "def lar...
[ 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 largest_odd_submatrix(matrix):\n def is_odd(x):\n return x % 2 != 0\n\n n = len(matrix)\n m = len(matrix[0])\n \n odd_matrix = [[is_odd(m...
trial_gpt4o_2
{ "original_instruction": "Write a program that finds the largest rectangular sub-matrix with elements that are all odd numbers within a given matrix. The size of the matrix is provided, and the program should identify the largest rectangle (by area) where all elements are odd numbers.\n\n\nInput\n\nThe input consist...
0.589367
Taco_63788
C
[ "largest_odd_submatrix_area", "largest_rectangle_area", "parse_input" ]
3
[ [ "largest_odd_submatrix_area", "largest_rectangle_area" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
f0b3d09aab0ab44b7f6dc89923492c26377dafa2
6bfd0ef01d29ff8a9d3fa86a7be7b67c6d6becb1
v1.0
complete
Taco
Taco_62979_C
def solve(T: int, test_cases: list) -> list: """ Given an integer array of length N, determine if it is possible to select a subset of the elements such that their sum is a prime number. Args: T: int - the number of test cases test_cases: list - a list of tuples where each tuple contains two e...
from itertools import combinations def is_prime(n): 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 has_prime_sum_subset(arr): for r in rang...
from solution import solve def test_sample_input_1(): T = 3 test_cases = [(4, [1, 2, 3, 4]), (3, [10, 15, 20]), (5, [2, 3, 5, 7, 11])] expected = ["YES", "NO", "YES"] assert solve(T, test_cases) == expected def test_all_single_element_prime(): T = 1 test_c...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def has_prime_sum_subset(arr):", "function_name": "has_prime_sum_subset", "parameter_list": "(arr)" }, { ...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef is_prime(num):\n \"\"\"\n Returns True if num is a prime number, else returns False.\n \"\"\"\n if num <= 1:\...
trial_gpt4o_8
{ "original_instruction": "Given an integer array of length N, determine if it is possible to select a subset of the elements such that their sum is a prime number.\n\n------ Input Format ------ \n\n- The first line of input will contain a single integer T, denoting the number of test cases.\n- Each test case consist...
0.613581
Taco_62979
C
[ "is_prime", "has_prime_sum_subset", "solve" ]
3
[ [ "has_prime_sum_subset", "is_prime" ], [ "solve", "has_prime_sum_subset" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f77559014224722f6838546b74717e251cc4a055
9ad92f59eb8c6bfed4322df784683392cf324671
v1.0
complete
Taco
Taco_64110_C
import math from functools import reduce def reverse_digits(n: int) -> int: """ Reverse the digits of an integer. >>> reverse_digits(321) 123 >>> reverse_digits(987) 789 >>> reverse_digits(100) 1 """ pass def gcd_of_list(lst: List[int]) -> int: """Find the greatest common divis...
import math from functools import reduce def reverse_digits(n): return int(str(n)[::-1]) def gcd_of_list(lst): return reduce(math.gcd, lst) def solve_puzzle(test_cases): results = [] for case in test_cases: L, nums = case original_nums = [reverse_digits(num) for num in nums] g...
from solution import reverse_digits, gcd_of_list, solve_puzzle def test_reverse_digits(): assert reverse_digits(321) == 123 assert reverse_digits(987) == 789 assert reverse_digits(100) == 1 def test_gcd_of_list(): assert gcd_of_list([123, 134, 932]) == 1 assert gcd_of_list([789, 654]) == 3 ass...
[ { "docstring": null, "function_declaration": "def reverse_digits(n):", "function_name": "reverse_digits", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def gcd_of_list(lst):", "function_name": "gcd_of_list", "parameter_list": "(lst)" }, { "docst...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.111
{ "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 reverse_number(num):\n \"\"\"\n Reverses the digits of an integer.\n \"\"\"\n return int(str(...
trial_gpt4o_8
{ "original_instruction": "Danielle has a special math puzzle for her friend Alex. She is giving a list of numbers and wants Alex to find the greatest common divisor (GCD) of all these numbers. However, Danielle added a twist: she encrypted the list by reversing the digits of each number before giving it to Alex. Ale...
0.627416
Taco_64110
C
[ "reverse_digits", "gcd_of_list", "solve_puzzle" ]
3
[ [ "solve_puzzle", "gcd_of_list" ], [ "solve_puzzle", "reverse_digits" ] ]
2
[]
false
[]
false
pytest
true
[]
true
671128a866736be94a8c25378c53497b303772fa
68111101d18b9bcfedc029b592120fe0490e5c1d
v1.0
complete
Taco
Taco_64122_C
def chess_position_to_coords(position): """ Convert a chess position in standard notation to coordinates. 'a1' -> (0, 0) 'h8' -> (7, 7) >>> chess_position_to_coords("a1") (0, 0) >>> chess_position_to_coords("h8") (7, 7) >>> chess_position_to_coords("d4") (3, 3) >>> chess_posi...
def chess_position_to_coords(position): """ Convert a chess position in standard notation to coordinates. 'a1' -> (0, 0) 'h8' -> (7, 7) """ col = ord(position[0]) - ord('a') row = int(position[1]) - 1 return (col, row) def min_king_moves(start, end): """ Calculate the minimum nu...
def test_chess_position_to_coords(): assert chess_position_to_coords("a1") == (0, 0) assert chess_position_to_coords("h8") == (7, 7) assert chess_position_to_coords("d4") == (3, 3) assert chess_position_to_coords("b2") == (1, 1) def test_min_king_moves(): assert min_king_moves("a1", "b3") == 2 ...
[ { "docstring": "Convert a chess position in standard notation to coordinates.\n'a1' -> (0, 0)\n'h8' -> (7, 7)", "function_declaration": "def chess_position_to_coords(position):", "function_name": "chess_position_to_coords", "parameter_list": "(position)" }, { "docstring": "Calculate the mini...
[ 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 position_to_coords(position):\n \"\"\"\n Converts a chess position in standard notation to 0-indexed coordinates.\n \"\"\"\n file, rank = position\...
trial_gpt4o_2
{ "original_instruction": "# Task\nImplement a function that calculates the minimum number of steps required for a king to move from one position to another on an 8x8 chessboard. The king can move horizontally, vertically, or diagonally all by one square per move.\n\n## Input/Output\n- `[input]` string `start`\n\n T...
0.629074
Taco_64122
C
[ "chess_position_to_coords", "min_king_moves" ]
2
[ [ "min_king_moves", "chess_position_to_coords" ] ]
1
[]
false
[]
false
pytest
false
[]
true
edb3dd6dc35878c12b065beb2da97127f16ada06
c30890a0d2dd61794906a7611877e241a7b966d6
v1.0
complete
Taco
Taco_63799_C
def rotate_matrix_90_degrees_clockwise(matrix): """ Rotates the given n*m matrix 90 degrees clockwise. Parameters: matrix (list of list of int): 2D list representing the matrix to be rotated. Returns: list of list of int: The rotated matrix. """ pass def rotate_matrix(matrix):...
def rotate_matrix_90_degrees_clockwise(matrix): """ Rotates the given n*m matrix 90 degrees clockwise. Parameters: matrix (list of list of int): 2D list representing the matrix to be rotated. Returns: list of list of int: The rotated matrix. """ n = len(matrix) m = len(matr...
from solution import rotate_matrix_90_degrees_clockwise, rotate_matrix def test_rotate_square_matrix(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] expected_output = [ [7, 4, 1], [8, 5, 2], [9, 6, 3] ] assert rotate_matrix_90_degrees_clockwise(matrix...
[ { "docstring": "Rotates the given n*m matrix 90 degrees clockwise.\n\nParameters:\nmatrix (list of list of int): 2D list representing the matrix to be rotated.\n\nReturns:\nlist of list of int: The rotated matrix.", "function_declaration": "def rotate_matrix_90_degrees_clockwise(matrix):", "function_nam...
[ 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 rotate_matrix_90_clockwise(matrix):\n \"\"\"\n Rotates a given n*m matrix 90 degrees clockwise.\n \n Args:\n matrix (list of list of int): The o...
trial_gpt4o_1
{ "original_instruction": "Given a matrix of size n*m, implement a function that rotates the matrix 90 degrees clockwise.\n\nInput:\nThe first line contains two integers n and m, representing the number of rows and columns of the matrix.\nThe next n lines contain m integers each, representing the elements of the matr...
0.565276
Taco_63799
C
[ "rotate_matrix_90_degrees_clockwise", "rotate_matrix" ]
2
[ [ "rotate_matrix", "rotate_matrix_90_degrees_clockwise" ] ]
1
[]
false
[]
false
pytest
true
[]
true
219a1a0d867d24de6877d1d8af46921b0ee646d5
28ae54e26c4a03016eb996ef1504812081071d95
v1.0
complete
Taco
Taco_64020_C
def rotate_array(arr, k): """ Rotates the array `arr` to the right by `k` steps in-place. >>> arr = [1, 2, 3, 4, 5] >>> rotate_array(arr, 2) >>> arr [4, 5, 1, 2, 3] >>> arr = [1, 2, 3, 4, 5] >>> rotate_array(arr, 0) >>> arr [1, 2, 3, 4, 5] >>> arr = [1, 2, 3, 4, 5] >>> ro...
def rotate_array(arr, k): """ Rotates the array `arr` to the right by `k` steps in-place. """ n = len(arr) k = k % n # In case k is larger than n reverse(arr, 0, n - 1) reverse(arr, 0, k - 1) reverse(arr, k, n - 1) def reverse(arr, start, end): """ Reverses the elements of `arr...
from solution import rotate_array def test_rotate_array_sample(): arr = [1, 2, 3, 4, 5] rotate_array(arr, 2) assert arr == [4, 5, 1, 2, 3] def test_rotate_array_no_rotation(): arr = [1, 2, 3, 4, 5] rotate_array(arr, 0) assert arr == [1, 2, 3, 4, 5] def test_rotate_array_full_rotation(): a...
[ { "docstring": "Rotates the array `arr` to the right by `k` steps in-place.", "function_declaration": "def rotate_array(arr, k):", "function_name": "rotate_array", "parameter_list": "(arr, k)" }, { "docstring": "Reverses the elements of `arr` from index `start` to index `end` in-place.", ...
[ 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 rotate_array(arr, k):\n \"\"\"\n Rotates the array `arr` to the right by `k` steps in-place.\n \"\"\"\n n = len(arr)\n k = k % n # In case k is...
trial_gpt4o_0
{ "original_instruction": "----- Statement -----\n\nGiven an array `arr` of integers and an integer `k`, rotate the array to the right by `k` steps, where `k` is non-negative. You are required to perform the rotation in-place with O(1) extra space complexity.\n\n-----Input-----\nThe first line contains two integers n...
0.646726
Taco_64020
C
[ "rotate_array", "reverse" ]
2
[ [ "rotate_array", "reverse" ] ]
1
[]
false
[]
false
pytest
true
[]
true
02c449c6a2a6a0acd27ef4a632bc664e75f08894
8877fc8d41d8ef0915af43fc2cf280c977716d49
v1.0
complete
Taco
Taco_62947_C
class TreeNode: def __init__(self, value): self.value = value self.children = [] def build_tree(node_values, edges): nodes = [TreeNode(value) for value in node_values] for u, v in edges: nodes[u-1].children.append(nodes[v-1]) nodes[v-1].children.append(nodes[u-1]) ...
class TreeNode: def __init__(self, value): self.value = value self.children = [] def build_tree(node_values, edges): nodes = [TreeNode(value) for value in node_values] for u, v in edges: nodes[u-1].children.append(nodes[v-1]) nodes[v-1].children.append(nodes[u-1]) ...
def test_example_case(): n = 5 node_values = [1, 0, 1, 1, 0] edges = [(1, 2), (1, 3), (2, 4), (2, 5)] assert max_subtree_sum(n, node_values, edges) == 3 def test_single_node_tree(): n = 1 node_values = [1] edges = [] assert max_subtree_sum(n, node_values, edges) == 1 def test_all_zeros...
[]
[ 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, value=0):\n self.value = value\n self.children = []\n\ndef build_tree(values, edges):\n nodes = {i: TreeNo...
trial_gpt4o_1
{ "original_instruction": "In a binary tree, each node contains either a value of 0 or 1. Given a binary tree, you need to perform the following operations:\n\n1. For each node, find the sum of values of the nodes in its subtree (including the node itself).\n2. Find and return the maximum sum among all subtrees.\n\nI...
0.623254
Taco_62947
C
[ "build_tree", "subtree_sum", "max_subtree_sum" ]
3
[ [ "max_subtree_sum", "build_tree" ], [ "max_subtree_sum", "subtree_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
fe115e003a5cc20b3a659562cdee01f3cc52c898
5983a1c9c0e4d18e0851f9e29f5b0b8a1f704cff
v1.0
complete
Taco
Taco_63604_C
def largest_prime_factor(n: int) -> int: """ Returns the largest prime factor of a given integer. >>> largest_prime_factor(10) 5 >>> largest_prime_factor(15) 5 >>> largest_prime_factor(21) 7 >>> largest_prime_factor(29) 29 >>> largest_prime_factor(49) 7 """ def largestPrimeFactors(numbers: ...
def largest_prime_factor(n): if n <= 1: return 1 max_prime = -1 while n % 2 == 0: max_prime = 2 n //= 2 for i in range(3, int(n**0.5) + 1, 2): while n % i == 0: max_prime = i n //= i if n > 2: max_prime = n return max_prime def lar...
from solution import largestPrimeFactors def test_largest_prime_factors_single_elements(): assert largestPrimeFactors([10]) == [5] assert largestPrimeFactors([15]) == [5] assert largestPrimeFactors([21]) == [7] assert largestPrimeFactors([29]) == [29] assert largestPrimeFactors([49]) == [7] ass...
[ { "docstring": null, "function_declaration": "def largest_prime_factor(n):", "function_name": "largest_prime_factor", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def largestPrimeFactors(numbers):", "function_name": "largestPrimeFactors", "parameter_li...
[ 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 largest_prime_factor(n):\n if n <= 1:\n return n\n\n max_prime = -1\n\n while n % 2 == 0:\n max_prime = 2\n n //= 2\n\n for i ...
trial_gpt4o_2
{ "original_instruction": "You are given a list of integers and your task is to find the largest prime factor for each integer in the list. The list can have up to 10^5 integers, each ranging from 1 to 10^9. After determining the largest prime factor for each number, output them in the same order they were given.\n\n...
0.830028
Taco_63604
C
[ "largest_prime_factor", "largestPrimeFactors" ]
2
[ [ "largestPrimeFactors", "largest_prime_factor" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b653784b8edc69878c2c55ae0a283e41192feb04
69cf8a5bbc1aa87d46f8b8b0eed9b479f2ddfd43