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_94032_C
def calculate_largest_rectangle_area(R: int, C: int, grid: List[str]) -> int: """ Given a grid of cells, find the largest rectangle of contiguous filled cells and return its area. >>> calculate_largest_rectangle_area(4, 5, ["1 0 1 0 0", "1 0 1 1 1", "1 1 1 1 1", "1 0 0 1 0"]) 6 >>> calculate_largest_rectang...
def maximalRectangle(matrix): if not matrix: return 0 max_area = 0 n = len(matrix[0]) height = [0] * (n + 1) for row in matrix: for i in range(n): height[i] = height[i] + 1 if row[i] == 1 else 0 stack = [-1] for i in range(n + 1): while heig...
from solution import calculate_largest_rectangle_area def test_case_1(): R, C = 4, 5 grid = [ "1 0 1 0 0", "1 0 1 1 1", "1 1 1 1 1", "1 0 0 1 0" ] assert calculate_largest_rectangle_area(R, C, grid) == 6 def test_case_2(): R, C = 2, 2 grid = [ "1 1", ...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def calculate_largest_rectangle_area(R, C, grid):", "function_name": "calculate_largest_rec...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximalRectangle(matrix):\n if not matrix:\n return 0\n \n max_area = 0\n dp = [0] * len(matrix[0])\n \n for row in matrix:\n f...
trial_gpt4o_1
{ "original_instruction": "You are given a matrix representing a grid of cells in a game. Each cell can be either empty or filled. The grid forms a board where you need to find the largest rectangle of contiguous filled cells and return its area.\n\nInput\n\nThe first line contains two integers, R and C, representing...
0.730151
Taco_94032
C
[ "maximalRectangle", "calculate_largest_rectangle_area" ]
2
[ [ "calculate_largest_rectangle_area", "maximalRectangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
89f4a188fcfbb4ec8e98774f54ab99d8a3e28729
dcde5351774ed3c7465f15fa2084164bb5c59323
v1.0
complete
Taco
Taco_93834_C
def sum_range(arr, l, r): """ Returns the sum of the elements from index l to r (inclusive). >>> sum_range([1, 2, 3, 4, 5], 1, 3) == 6 >>> sum_range([1, 2, 3, 4, 5], 2, 5) == 14 >>> sum_range([1, 2, 3, 4, 5], 1, 5) == 15 """ def increment(arr, x, y): """ Increment each element in the ar...
def sum_range(arr, l, r): """ Returns the sum of the elements from index l to r (inclusive). """ return sum(arr[l-1:r]) def increment(arr, x, y): """ Increment each element in the array from index x to index y (inclusive) by 1. """ for i in range(x-1, y): arr[i] += 1 def proces...
from solution import sum_range, increment, process_queries def test_sum_range(): arr = [1, 2, 3, 4, 5] assert sum_range(arr, 1, 3) == 6 assert sum_range(arr, 2, 5) == 14 assert sum_range(arr, 1, 5) == 15 def test_increment(): arr = [1, 2, 3, 4, 5] increment(arr, 2, 4) assert arr == [1, 3, ...
[ { "docstring": "Returns the sum of the elements from index l to r (inclusive).", "function_declaration": "def sum_range(arr, l, r):", "function_name": "sum_range", "parameter_list": "(arr, l, r)" }, { "docstring": "Increment each element in the array from index x to index y (inclusive) by 1....
[ 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 process_queries(n, arr, queries):\n results = []\n array = arr\n \n for query in queries:\n q_parts = query.split()\n if q_parts[0] =...
trial_gpt4o_3
{ "original_instruction": "Given an array of $N$ integers and two types of queries, perform the operations as described:\n\nsum_range l r: Report the sum of the elements from index l to index r (inclusive).\nincrement x y: Increment each element in the array from index x to index y (inclusive) by 1.\n\nInput Format\n...
0.6698
Taco_93834
C
[ "sum_range", "increment", "process_queries" ]
3
[ [ "process_queries", "increment" ], [ "process_queries", "sum_range" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
fbe376869a167e8f3f21a9c32ce304e3b165eec1
6e97c194d406bd7feb8967f5d4a7e185e8faf13d
v1.0
complete
Taco
Taco_93898_C
def initialize_shelves(m: int, n: int) -> List[List[int]]: """ Initialize the shelves with `m` shelves each having `n` positions. >>> initialize_shelves(2, 3) [[0, 0, 0], [0, 0, 0]] """ def add_book(shelves: List[List[int]], s: int, p: int, b: int) -> None: """ Adds a book with `b` ID to the sh...
def initialize_shelves(m, n): return [[0] * n for _ in range(m)] def add_book(shelves, s, p, b): shelves[s-1][p-1] = b def get_book(shelves, s, p): return shelves[s-1][p-1] def manage_books(m, n, operations): shelves = initialize_shelves(m, n) results = [] for operation in operations: ...
from solution import initialize_shelves, add_book, get_book, manage_books def test_initialize_shelves(): shelves = initialize_shelves(2, 5) assert shelves == [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] def test_add_book(): shelves = initialize_shelves(2, 5) add_book(shelves, 1, 2, 101) assert shelves == [[...
[ { "docstring": null, "function_declaration": "def initialize_shelves(m, n):", "function_name": "initialize_shelves", "parameter_list": "(m, n)" }, { "docstring": null, "function_declaration": "def add_book(shelves, s, p, b):", "function_name": "add_book", "parameter_list": "(shel...
[ 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 manage_books(m, n, operations):\n shelves = [[0] * n for _ in range(m)]\n results = []\n\n for operation in operations:\n op = operation[0]\n ...
trial_gpt4o_2
{ "original_instruction": "Emma is an avid reader and loves collecting books. She groups her books on shelves in a manner that each shelf can hold exactly `n` books placed in a single row. Emma wants to perform specific operations on her shelves which involve either adding a book or removing a book from specific posi...
0.555479
Taco_93898
C
[ "initialize_shelves", "add_book", "get_book", "manage_books" ]
4
[ [ "manage_books", "add_book" ], [ "manage_books", "get_book" ], [ "manage_books", "initialize_shelves" ] ]
3
[]
false
[]
false
pytest
true
[]
true
dd4ae1a7e4e77775a8f1c42cabc72f325e84e6f2
3d62b34eeacde26f2da3d85e06bba91a111c88cf
v1.0
complete
Taco
Taco_94136_C
def min_cost_to_provide_water(N, M, pipes): """ Calculate the minimum cost to connect all houses with water pipes. Return the minimal cost or -1 if it's impossible. Parameters: N (int): The number of houses M (int): The number of possible pipes pipes (List[Tuple[int, int, int]]): A list of tupl...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): rootX = find(parent, x) rootY = find(parent, y) if rootX != rootY: if rank[rootX] > rank[rootY]: parent[rootY] ...
from solution import min_cost_to_provide_water def test_example_case(): N = 4 M = 5 pipes = [ (1, 2, 1), (2, 3, 4), (3, 4, 2), (4, 1, 3), (1, 3, 5) ] assert min_cost_to_provide_water(N, M, pipes) == 6 def test_no_connections(): N = 3 M = 0 pipes ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n rootX = find(parent, x)\n...
trial_gpt4o_1
{ "original_instruction": "A village is planning to build a network of water pipes to ensure every house has access to water. The village consists of N houses connected by M possible pipes. Each pipe can be installed to connect two houses and has a cost associated with it. Due to budget constraints, they need to mini...
0.590942
Taco_94136
C
[ "find", "union", "min_cost_to_provide_water" ]
3
[ [ "min_cost_to_provide_water", "find" ], [ "min_cost_to_provide_water", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e6307202da7a13c456f27dfe0715fc14a86071ae
51044b802bc8901b846c14b1059727d325024603
v1.0
complete
Taco
Taco_94348_C
def is_prime(n: int) -> bool: """ Checks if a number n is a prime number. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(11) == True >>> is_prime(15) == False >>> is_prime(29) == True """ def smallest_prime_greater_than(m: int) -> int: ...
def is_prime(n): """ Checks if a number n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import is_prime, smallest_prime_greater_than def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(15) == False assert is_prime(29) == True def test_smallest_prime_greater_than(): ass...
[ { "docstring": "Checks if a number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the smallest prime number greater than m.", "function_declaration": "def smallest_prime_greater_than(m):",...
[ 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 math\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:\n return False\...
trial_gpt4o_2
{ "original_instruction": "Aisha is fascinated by prime numbers and their unique properties. Recently, she encountered a problem and now she wants you to solve it for her. Given a positive integer, $m$, she wants to find the smallest prime number greater than $m$.\n\nInput Format\n\nA single integer denoting $m$.\n\n...
0.819878
Taco_94348
C
[ "is_prime", "smallest_prime_greater_than" ]
2
[ [ "smallest_prime_greater_than", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
02d856e9f1d01275196b9dcfb63c869f39a3cf56
e571526c760c31f120de17df0d9e507332d064c9
v1.0
complete
Taco
Taco_94458_C
def is_prime(n: int) -> bool: """ Determine if the given number is a prime number. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(1) == False """ def can_split_to_alternating_prime_seq(T: int, test_cases: List[Tuple[int, List[in...
def is_prime(n): if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def can_split_to_alternating_prime_seq(T, test_cases): results = [] for i in range(T): N = test_cases[i][0] sequence = test_cases[i][1] ...
def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False def test_can_split_to_alternating_prime_seq(): test_cases = [ (6, [3, 2, 5, 11, 7, 13]), (4, [4, 6, 8, 10]), (5, ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def can_split_to_alternating_prime_seq(T, test_cases):", "function_name": "can_split_to_alternating_prime_seq", "...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\...
trial_gpt4o_0
{ "original_instruction": "Sara is fascinated by numbers and sequences. She recently discovered a special sequence called \"Alternating Prime Sequence\". In an Alternating Prime Sequence, every pair of consecutive numbers has different parity (one is odd and the other is even) and both numbers in the pair are prime.\...
0.719795
Taco_94458
C
[ "is_prime", "can_split_to_alternating_prime_seq" ]
2
[ [ "can_split_to_alternating_prime_seq", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
5ba551821e03aca53077e5553bd765e02105bfb9
3b3ee22b305c1019a861f226778d791b7abb0daa
v1.0
complete
Taco
Taco_94378_C
def min_edges_to_connect_all_nodes(n: int, m: int, edges: List[Tuple[int, int]]) -> int: """ You are given a forest graph with `n` nodes and `m` edges. A forest is an undirected graph with no cycles. Your task is to determine the minimum number of edges required to convert the forest into a single connecte...
def find_connected_components(n, edges): """ Find the number of connected components in the forest graph. """ from collections import defaultdict, deque graph = defaultdict(list) for u, v in edges: graph[u].append(v) graph[v].append(u) visited = [False] * (n + 1) ...
from solution import min_edges_to_connect_all_nodes def test_case_1(): assert min_edges_to_connect_all_nodes(6, 3, [(1, 2), (2, 3), (4, 5)]) == 2 def test_case_2(): assert min_edges_to_connect_all_nodes(5, 0, []) == 4 def test_case_3(): assert min_edges_to_connect_all_nodes(4, 3, [(1, 2), (2, 3), (3, 4)]...
[ { "docstring": "Find the number of connected components in the forest graph.", "function_declaration": "def find_connected_components(n, edges):", "function_name": "find_connected_components", "parameter_list": "(n, edges)" }, { "docstring": "Calculate the minimum number of edges required to...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_connected_components(n, edges):\n \"\"\"\n Find the number of connected components in the forest graph.\n \"\"\"\n from collections import def...
trial_gpt4o_0
{ "original_instruction": "You are given a forest graph with $n$ nodes and $m$ edges. A forest is an undirected graph with no cycles. Your task is to determine the minimum number of edges required to convert the forest into a single connected tree.\n\nIn other words, you need to connect all the nodes into one connect...
0.620898
Taco_94378
C
[ "find_connected_components", "min_edges_to_connect_all_nodes" ]
2
[ [ "min_edges_to_connect_all_nodes", "find_connected_components" ] ]
1
[]
false
[]
false
pytest
true
[]
true
58b564178404cc6b2d09b125b4091f55b575416e
42e0bec6fa1928b09bc6781faaa32a3ab10e29c7
v1.0
complete
Taco
Taco_94479_C
def minimum_cost_to_connect_houses(n: int, pipes: List[List[int]]) -> int: """ Write a function that finds the minimum cost to provide water to all houses. If it is impossible to connect all houses, return -1. >>> minimum_cost_to_connect_houses(4, [[1, 2, 1], [2, 3, 4], [3, 4, 2], [1, 4, 3]]) 6 >>> min...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif rank[root_x] < ...
from solution import minimum_cost_to_connect_houses def test_example_case(): n = 4 pipes = [[1, 2, 1], [2, 3, 4], [3, 4, 2], [1, 4, 3]] assert minimum_cost_to_connect_houses(n, pipes) == 6 def test_disconnected_graph(): n = 3 pipes = [[1, 2, 5]] assert minimum_cost_to_connect_houses(n, pipes) ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def minimum_cost_to_connect_houses(n, pipes):\n \"\"\"\n Given n houses and a list of pipes with their costs, this function returns the minimum\n cost req...
trial_gpt4o_1
{ "original_instruction": "Write a function `minimum_cost_to_connect_houses(n, pipes)` that finds the minimum cost to provide water to all houses. There are `n` houses and `m` pipes where each `pipe[i] = [house1, house2, cost]` denotes a pipe that can connect house1 and house2 with a cost. You need to construct a net...
0.601506
Taco_94479
C
[ "find", "union", "minimum_cost_to_connect_houses" ]
3
[ [ "minimum_cost_to_connect_houses", "find" ], [ "minimum_cost_to_connect_houses", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8d414b05b73848ee2a631b2ca38a4417cc145549
7106286666cb8a05ea1cb887139ebd271a63737a
v1.0
complete
Taco
Taco_94475_C
def longest_common_palindromic_subsequence(seq1, seq2) -> int: """ Returns the length of the Longest Common Palindromic Subsequence (LCPS) of the given two sequences. >>> longest_common_palindromic_subsequence([1, 2, 3, 4], [3, 2, 1, 3]) == 3 >>> longest_common_palindromic_subsequence([1, 2, 3], [4, 5, 6]) ...
def lcs(X, Y): """ Helper function to find the length of Longest Common Subsequence (LCS) of sequences X and Y. """ n = len(X) m = len(Y) L = [[0] * (m + 1) for i in range(n + 1)] for i in range(n + 1): for j in range(m + 1): if i == 0 or j == 0: L[i]...
from solution import longest_common_palindromic_subsequence def test_case_1(): assert longest_common_palindromic_subsequence([1, 2, 3, 4], [3, 2, 1, 3]) == 3 def test_case_2(): assert longest_common_palindromic_subsequence([1, 2, 3], [4, 5, 6]) == 0 def test_case_3(): assert longest_common_palindromic_su...
[ { "docstring": "Helper function to find the length of Longest Common Subsequence (LCS) of sequences X and Y.", "function_declaration": "def lcs(X, Y):", "function_name": "lcs", "parameter_list": "(X, Y)" }, { "docstring": "Returns the length of the Longest Common Palindromic Subsequence (LCP...
[ 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 lcps_length(n, seq1, m, seq2):\n \"\"\"\n Returns the length of the longest common palindromic subsequence of seq1 and seq2.\n \"\"\"\n # Create a ...
trial_gpt4o_1
{ "original_instruction": "Petya loves palindromic sequences. He often plays with two sequences of numbers and tries to find common subsequences that form palindromes. Given two sequences of numbers, Petya wants to find the longest common palindromic subsequence (LCPS) between them. A subsequence is obtained by delet...
0.704253
Taco_94475
C
[ "lcs", "longest_common_palindromic_subsequence" ]
2
[ [ "longest_common_palindromic_subsequence", "lcs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0e32161f1573d4142ebc5579ed10933838dc0c8d
544d29162274b7f9c0b37094e2fc38a6ec59ff22
v1.0
complete
Taco
Taco_94702_C
from typing import List def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. """ def prime_factors(n: int) -> List[int]: """ Helper function to get the prime factors of a number. """ def sum_of_digits(n: int) -> int: """ Helper function to sum the digits of a number. """ def ...
def is_prime(n): """ Helper function to check if a number is prime. """ if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def prime_factors(n): """ Helper function to get the prime factors of a number. """ ...
from solution import smith_number def test_smith_number(): assert smith_number(22) == "Smith !!" assert smith_number(58) == "Smith !!" assert smith_number(85) == "Smith !!" def test_not_smith_number(): assert smith_number(13) == "Not !!" assert smith_number(29) == "Not !!" assert smith_number(...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Helper function to get the prime factors of a number.", "function_declaration": "def prime_factors(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 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_1
{ "original_instruction": "____\n\n# Definition\n\n**_Smith number_** is a composite number whose sum of digits is equal to the sum of the digits of its prime factors (excluding 1) written in radix 10.\n\n____\n\n# Task\n\n**_Given_** a number, **_Find if it is a Smith number or not_**.\n____\n\n# Warm-up (Highly rec...
0.731415
Taco_94702
C
[ "is_prime", "prime_factors", "sum_of_digits", "smith_number" ]
4
[ [ "smith_number", "is_prime" ], [ "smith_number", "prime_factors" ], [ "smith_number", "sum_of_digits" ] ]
3
[]
false
[]
false
pytest
true
[]
true
908c61ada8b7b66a592d3ddc7c0df0f103f081af
86d24f6800df58f7fe0f9552f6e89d8a8b6df978
v1.0
complete
Taco
Taco_94728_C
def find_k_for_sum_x(n: int, x: int) -> int: """ Determines if x can be written as the sum of the first k primes for some k. If possible, finds the smallest possible k such that the sum of the first k prime numbers equals x. >>> find_k_for_sum_x(20, 17) == 4 >>> find_k_for_sum_x(100, 41) == 6 >>> fi...
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def find_k_for_sum_x(n, x): primes = [] ...
from solution import find_k_for_sum_x def test_example_1(): assert find_k_for_sum_x(20, 17) == 4 def test_example_2(): assert find_k_for_sum_x(100, 41) == 6 def test_example_3(): assert find_k_for_sum_x(50, 30) == -1 def test_small_x(): assert find_k_for_sum_x(10, 2) == 1 def test_large_n_small_x()...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def find_k_for_sum_x(n, x):", "function_name": "find_k_for_sum_x", "parameter_list": "(n, x)" } ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_8
{ "original_instruction": "The kingdom of Asyncum has a new fascination with prime numbers. The citizens have a peculiar interest in creating interesting sequences from primes. Recently, they started generating sequences where each element is the sum of the first $k$ prime numbers. Given an integer $n$, Asyncum wants...
0.672707
Taco_94728
C
[ "is_prime", "find_k_for_sum_x" ]
2
[ [ "find_k_for_sum_x", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cd5ae61f6c26e5ba62317d868510376131c7f1a5
6e861295ab2b16a991eccc0bfc1c1c5cd1ffd623
v1.0
complete
Taco
Taco_94446_C
def simplify_skyline(buildings): """ Simplify the skyline silhouette by merging overlapping buildings while maintaining the highest height at any given x-coordinate. :param buildings: A list of tuples (left, right, height) representing the buildings. :return: A list of tuples (left, right, height) repr...
def simplify_skyline(buildings): """ This function simplifies the skyline silhouette by merging overlapping buildings while maintaining the highest height at any given x-coordinate. :param buildings: A list of tuples (left, right, height) representing the buildings. :return: A list of tuples (...
import pytest from solution import process_skyline_input def test_example_1(): input_data = "3\n1 3 4\n2 5 3\n6 8 5" expected_output = [(1, 5, 4), (6, 8, 5)] assert process_skyline_input(input_data) == expected_output def test_example_2(): input_data = "4\n1 2 1\n2 4 2\n3 5 3\n5 6 1" expected_outp...
[ { "docstring": "This function simplifies the skyline silhouette by merging overlapping buildings while \nmaintaining the highest height at any given x-coordinate.\n\n:param buildings: A list of tuples (left, right, height) representing the buildings.\n:return: A list of tuples (left, right, height) representing...
[ 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": "def merge_buildings(buildings):\n \"\"\"\n Merges overlapping or touching buildings and returns the simplified skyline silhouette.\n \"\"\"\n events = ...
trial_gpt4o_6
{ "original_instruction": "Real estate companies often provide developers with outlines of properties represented as buildings with varying heights. These heights are presented by skyline silhouettes, where each outline has multiple buildings with peak heights. \n\nImagine a cityscape represented by a list of buildin...
0.482609
Taco_94446
C
[ "simplify_skyline", "process_skyline_input" ]
2
[ [ "process_skyline_input", "simplify_skyline" ] ]
1
[]
false
[]
false
pytest
true
[]
true
87c67cb85100a9a007225881eae712eba0216329
18a2d3e63ae3ed6b2901266d1fe84f9ff5a33a80
v1.0
complete
Taco
Taco_94738_C
def rotate_matrix_90_clockwise(matrix): """ Rotates the given N x N matrix 90 degrees clockwise. Args: matrix (List[List[int]]): The N x N matrix to rotate. Returns: List[List[int]]: The rotated matrix. >>> rotate_matrix_90_clockwise([ ... [1, 2, 3], ... [4, 5, 6], ... ...
def rotate_matrix_90_clockwise(matrix): """ Rotates the given N x N matrix 90 degrees clockwise. """ N = len(matrix) rotated_matrix = [[0] * N for _ in range(N)] for i in range(N): for j in range(N): rotated_matrix[j][N-1-i] = matrix[i][j] return rotated_matrix ...
from solution import rotate_matrix_90_clockwise def test_rotate_3x3_matrix(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] rotated = rotate_matrix_90_clockwise(matrix) expected = [ [7, 4, 1], [8, 5, 2], [9, 6, 3] ] assert rotated == expected def ...
[ { "docstring": "Rotates the given N x N matrix 90 degrees clockwise.", "function_declaration": "def rotate_matrix_90_clockwise(matrix):", "function_name": "rotate_matrix_90_clockwise", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def solve_input(input_dat...
[ 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_matrix_90_clockwise(matrix):\n \"\"\"\n Rotates the given N x N matrix 90 degrees clockwise.\n \"\"\"\n N = len(matrix)\n rotated_matrix ...
trial_gpt4o_0
{ "original_instruction": "You are given an N x N matrix filled with integers. Write a function to rotate the matrix 90 degrees clockwise.\n\n------ Input Format ------\n\n- First line contains a single integer T, the number of test cases. Then the test cases follow.\n- Each test case contains N+1 lines of input.\n- ...
0.5929
Taco_94738
C
[ "rotate_matrix_90_clockwise", "solve_input", "format_output", "rotate_matrices" ]
4
[ [ "rotate_matrices", "format_output" ], [ "rotate_matrices", "solve_input" ], [ "solve_input", "rotate_matrix_90_clockwise" ] ]
3
[ "solve_input", "format_output" ]
false
[]
false
pytest
true
[]
true
9678675645adcdfdfca4b6aa1da7efe41eb5c1fe
0313cbf5fa74f392b31ff4c6a405472f45acca62
v1.0
complete
Taco
Taco_94238_C
def can_split_into_increasing_subarrays(t: int, cases: List[Tuple[int, List[int]]]) -> List[str]: """ Determine if a sequence of distinct integers can be split into three contiguous strictly increasing subarrays for each test case. Args: t (int): Number of test cases. cases (List[Tuple[int, Lis...
def can_split_into_increasing_subarrays(t, cases): results = [] for i in range(t): n = cases[i][0] heights = cases[i][1] if n < 3: results.append("NO") continue peak_count = 0 peak_position = [] # Find peaks in th...
def test_can_split_into_increasing_subarrays(): cases = [ (5, [1, 2, 3, 4, 5]), (7, [1, 3, 2, 5, 6, 7, 4]), (4, [1, 3, 2, 4]), (9, [1, 2, 1, 3, 4, 2, 5, 6, 7]) ] expected = ["NO", "YES", "NO", "YES"] assert can_split_into_increasing_subarrays(4, cases) == expected def te...
[ { "docstring": null, "function_declaration": "def can_split_into_increasing_subarrays(t, cases):", "function_name": "can_split_into_increasing_subarrays", "parameter_list": "(t, cases)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", "par...
[ 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 can_divide_into_three_increasing_subarrays(n, heights):\n left = [1] * n\n right = [1] * n\n\n for i in range(1, n):\n if heights[i] > heights[...
trial_gpt4o_3
{ "original_instruction": "You are given a sequence of distinct integers representing the heights of people standing in a line from left to right. The task is to determine if it's possible to break this sequence into three contiguous subarrays such that each subarray is strictly increasing.\n\n-----Input-----\n\nThe ...
0.668889
Taco_94238
C
[ "can_split_into_increasing_subarrays", "solve" ]
2
[ [ "solve", "can_split_into_increasing_subarrays" ] ]
1
[]
false
[]
false
pytest
false
[]
true
239fed2a51a90f9b88ae1e1dd7efb301dbfee509
6e43878a8053845812f04d304f03a1c0aafeafa4
v1.0
complete
Taco
Taco_94123_C
def max_path_sum(n: int, nodes: List[Union[int, None]]) -> int: """ Calculate the maximum path sum in a given binary tree. Args: n (int): The number of nodes in the binary tree. nodes (List[Union[int, None]]): The values of the nodes in level-order (BFS) traversal of the tree. Returns: ...
from typing import List, Union class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nodes: List[Union[int, None]]) -> TreeNode: if not nodes: return None from collections import deque it = it...
from solution import max_path_sum def test_case_1(): assert max_path_sum(5, [1, -2, 3, None, -1]) == 4 def test_case_2(): assert max_path_sum(3, [-10, 9, 20, None, None, 15, 7]) == 42 def test_case_3(): assert max_path_sum(1, [1]) == 1 def test_case_4(): assert max_path_sum(7, [1, 2, 3, 4, 5, 6, 7])...
[]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List, Union\n\nclass TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef bui...
trial_gpt4o_6
{ "original_instruction": "### Binary Tree Maximum Path Sum\n\nYou are given a binary tree where each node contains an integer value. Find the maximum path sum. A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can be part of one or tw...
0.594114
Taco_94123
C
[ "build_tree", "max_path_sum" ]
2
[ [ "max_path_sum", "build_tree" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
376656facc9698b657122d629ce735bb9ecd0367
e482b201d9bb415e5c248c22eb98fd5fcdefb27a
v1.0
complete
Taco
Taco_94715_C
def cleaning_robot_moves(n: int, m: int, grid: List[str]) -> str: """ Determines the sequence of moves the robotic vacuum cleaner should take to clean all reachable cells in a 2D grid. The grid is represented as a list of strings where: - '.' represents a cleanable cell - '#' represents a wall ...
from collections import deque MOVE_UP = 'U' MOVE_DOWN = 'D' MOVE_LEFT = 'L' MOVE_RIGHT = 'R' DIR_VECTORS = [(0, 1, MOVE_RIGHT), (1, 0, MOVE_DOWN), (0, -1, MOVE_LEFT), (-1, 0, MOVE_UP)] def bfs_cleaning_route(n, m, grid, start): queue = deque([start]) visited = set() visited.add(start) moves = [] p...
def test_4x4_grid(): n, m = 4, 4 grid = [ "S...", ".#..", "..#.", "...." ] output = cleaning_robot_moves(n, m, grid) assert set(output).issubset({'U', 'D', 'L', 'R'}) assert len(output) >= 12 def test_no_cleanable_cells(): n, m = 2, 2 grid = [ "S#...
[ { "docstring": null, "function_declaration": "def bfs_cleaning_route(n, m, grid, start):", "function_name": "bfs_cleaning_route", "parameter_list": "(n, m, grid, start)" }, { "docstring": null, "function_declaration": "def cleaning_robot_moves(n, m, grid):", "function_name": "cleanin...
[ 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": "from collections import deque\n\ndef robot_cleaner(n, m, grid):\n # Directions represent movement: up, right, down, left\n directions = {'U': (-1, 0), 'R': (...
trial_gpt4o_9
{ "original_instruction": "A software company is developing a robotic vacuum cleaner. The robot moves on a 2D grid, where each cell can be either cleanable or a wall. The robot starts in a specific cell and must clean all reachable cleanable cells while avoiding walls.\n\nThe robot can move in four directions: up, do...
0.647352
Taco_94715
C
[ "bfs_cleaning_route", "cleaning_robot_moves" ]
2
[ [ "cleaning_robot_moves", "bfs_cleaning_route" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1b5396323af9af41f3bcd27bdb0cc800b61fa5e3
a5d80dbb77c3919e139d03fc9b98a042ecebd010
v1.0
complete
Taco
Taco_94351_C
def find_largest_rectangle_area(input_str: str) -> int: """Finds the largest rectangle containing only 1's in a 2D grid from the input string and returns its area. >>> find_largest_rectangle_area("4 4\n1 0 1 0\n1 0 1 1\n1 1 1 1\n0 0 1 0") 4 >>> find_largest_rectangle_area("1 4\n1 1 1 0") 3 ...
def maximalRectangle(matrix): if not matrix: return 0 max_area = 0 n = len(matrix) m = len(matrix[0]) heights = [0] * (m + 1) for row in matrix: for i in range(m): if row[i] == 0: heights[i] = 0 else: heights[i] += row[i] ...
import pytest from solution import find_largest_rectangle_area def test_sample_input_1(): input_str = "4 4\n1 0 1 0\n1 0 1 1\n1 1 1 1\n0 0 1 0" assert find_largest_rectangle_area(input_str) == 4 def test_single_row(): input_str = "1 4\n1 1 1 0" assert find_largest_rectangle_area(input_str) == 3 def t...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_list": "(input...
[ 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_histogram_area(heights):\n # Compute the maximum area of histogram\n stack = []\n max_area = 0\n index = 0\n\n while index < len(heights):\n...
trial_gpt4o_2
{ "original_instruction": "You are given a 2D grid of integers where each cell contains either a 0 or a 1. The grid has N rows and M columns. You need to find the largest rectangle containing only 1's and return its area. \n\n------ Input Format ------ \n\n- The first line of input will contain two space-separated in...
0.765927
Taco_94351
C
[ "maximalRectangle", "parse_input", "find_largest_rectangle_area" ]
3
[ [ "find_largest_rectangle_area", "maximalRectangle" ], [ "find_largest_rectangle_area", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
d8602751bd0709fb6215b1357bd9f0fcef0ae0af
7bb5e181af1e0b84f6d27df5ac9733509fc49df0
v1.0
complete
Taco
Taco_94673_C
def is_palindrome(number: int) -> bool: """ Check if a number is a palindrome. >>> is_palindrome(121) True >>> is_palindrome(123) False >>> is_palindrome(454) True >>> is_palindrome(567) False >>> is_palindrome(898) True >>> is_palindrome(0) True """ def ...
def is_palindrome(number): """ Check if a number is a palindrome. """ str_num = str(number) return str_num == str_num[::-1] def count_palindromic_plates(n, plates): """ Count the number of palindromic license plates. Args: n: The number of license plates. plates: List of in...
import pytest from solution import is_palindrome, count_palindromic_plates def test_is_palindrome(): assert is_palindrome(121) assert not is_palindrome(123) assert is_palindrome(454) assert not is_palindrome(567) assert is_palindrome(898) assert is_palindrome(0) def test_count_palindromic_plat...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(number):", "function_name": "is_palindrome", "parameter_list": "(number)" }, { "docstring": "Count the number of palindromic license plates.\n\nArgs:\nn: The number of license plates.\nplates: Lis...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_palindromic_plates(n, plates):\n \"\"\"\n Returns the count of palindromic license plate numbers in the list.\n \n Args:\n n : int : numbe...
trial_gpt4o_2
{ "original_instruction": "A group of friends decided to play a game during a long car trip. The game consists of spotting license plates and noting down their numbers. However, there is a twist in the game: they are only interested in palindromic numbers, which are numbers that read the same backward as forward (e.g...
0.681226
Taco_94673
C
[ "is_palindrome", "count_palindromic_plates" ]
2
[ [ "count_palindromic_plates", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bd512a8729ae7c87b2bc688d85211fb97ee492fb
4dac9030fa8a8abfcc6900e743a5ed9af7d45e7d
v1.0
complete
Taco
Taco_94911_C
def get_primes_up_to_100() -> List[int]: """ Generate a list of prime numbers up to 100 >>> get_primes_up_to_100() [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] """ def maximize_beauty(T: int, test_cases: List[Tuple[int, List[int]]]) -> List[List[i...
def get_primes_up_to_100(): """ Function to generate a list of prime numbers up to 100 """ sieve = [True] * 101 sieve[0] = sieve[1] = False for start in range(2, int(101**0.5) + 1): if sieve[start]: for multiple in range(start*start, 101, start): sieve[multipl...
import pytest from solution import maximize_beauty def test_get_primes_up_to_100(): from solution import get_primes_up_to_100 assert get_primes_up_to_100() == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] def test_maximize_beauty_sample_input(): T = 2 ...
[ { "docstring": "Function to generate a list of prime numbers up to 100", "function_declaration": "def get_primes_up_to_100():", "function_name": "get_primes_up_to_100", "parameter_list": "()" }, { "docstring": "Function to maximize the total beauty of the array", "function_declaration": ...
[ 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 \"\"\" Helper function to check if a number is prime. \"\"\"\n if num < 2:\n return False\n for i in range(2, int(num**0.5) + ...
trial_gpt4o_1
{ "original_instruction": "You are given an array of $N$ integers. The beauty of an array is defined as the sum of all the distinct prime numbers that appear in the array. Your task is to modify the array such that the total beauty is maximized. You can change any element of the array to any other integer value with ...
0.619824
Taco_94911
C
[ "get_primes_up_to_100", "maximize_beauty" ]
2
[ [ "maximize_beauty", "get_primes_up_to_100" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f92dc73e57de22914aff7cd89d49471acd3afd1b
a73ab73bf02e25662902a64c212357c219d454c4
v1.0
complete
Taco
Taco_94857_C
from typing import List, Tuple def safe_cracking(): """ Helps Limak to find the correct 4-digit combination of a safe lock within 15 queries. - Each guess is a 4-digit integer. - After each guess, receives two integers `a` and `b`: - `a`: Number of digits in the correct position. - `b`: Nu...
import itertools # The main function which tries to guess the combination def safe_cracking(): possible_combinations = [str(x).zfill(4) for x in range(1000, 10000)] queries = 15 for _ in range(queries): guess = possible_combinations.pop(0) print(guess) a, b = map(int, input().split(...
from solution import is_valid_guess def test_is_valid_guess(): assert is_valid_guess('1234', '1243', 2, 2) == True assert is_valid_guess('1234', '5678', 0, 0) == True assert is_valid_guess('1234', '4321', 0, 4) == True assert is_valid_guess('1234', '1234', 4, 0) == True assert is_valid_guess('1234'...
[ { "docstring": null, "function_declaration": "def safe_cracking():", "function_name": "safe_cracking", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def is_valid_guess(guess, combination, a, b):", "function_name": "is_valid_guess", "parameter_list": "(gu...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_combination():\n import itertools\n from sys import stdin, stdout\n\n possible_combinations = [\"{:04d}\".format(x) for x in range(1000, 10000)]\...
trial_gpt4o_6
{ "original_instruction": "This is a problem about safe-cracking. Limak is trying to open a safe that requires a 4-digit combination to unlock. You have to help him find the correct combination.\n\nA 4-digit combination means an integer from the interval [1000, 9999].\n\nYou can ask up to 15 queries about the digits ...
0.526773
Taco_94857
C
[ "safe_cracking", "is_valid_guess" ]
2
[ [ "safe_cracking", "is_valid_guess" ] ]
1
[]
false
[]
false
pytest
true
[]
true
646a8a93b45109db19c61463000492e3bbc6095f
21db6fff2374a14ae7efbb30c12471c7ca2ac7dd
v1.0
complete
Taco
Taco_94542_C
class ListNode: def __init__(self, x): self.val = x self.next = None def is_circular_linked_list(head): """ Function to check if a linked list is circular. :param head: ListNode, the head of the linked list :return: True if the linked list is circular, False otherwise """ #...
class ListNode: def __init__(self, x): self.val = x self.next = None def is_circular_linked_list(head): """ Function to check if a linked list is circular. :param head: ListNode, the head of the linked list :return: True if the linked list is circular, False otherwise """ i...
def test_is_circular_linked_list(): # Test case 1: Non-circular list head = create_linked_list([1, 2, 3, 4, 5]) assert not is_circular_linked_list(head), "Error in test case 1: Non-circular list" # Test case 2: Circular list head = create_linked_list([7, 8, 9]) current = head while curr...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class ListNode:\n def __init__(self, value=0):\n self.value = value\n self.next = None\n\ndef is_circular_linked_list(head):\n \"\"\"\n Dete...
trial_gpt4o_2
{ "original_instruction": "You are given a linked list of integers. The linked list is considered circular if the last node points to the first node. Your task is to determine if a given linked list is circular or not.\n\n-----Input-----\n\nThe first line contains one integer $t$ ($1 \\le t \\le 100$) — the number of...
0.473597
Taco_94542
C
[ "is_circular_linked_list", "create_linked_list", "check_circular_linked_lists" ]
3
[ [ "check_circular_linked_lists", "create_linked_list" ], [ "check_circular_linked_lists", "is_circular_linked_list" ] ]
2
[]
false
[ "ListNode" ]
true
pytest
false
[]
true
e047a38638cfcabf2c7c92a720ff5b7928d22b5c
1d92afe797c023cba58bec300e92fa0074cc72ed
v1.0
complete
Taco
Taco_95180_C
def filter_primes(input_list): """ Returns a new list containing only the prime numbers from the original list. >>> filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] >>> filter_primes([4, 6, 8, 9, 10]) == [] >>> filter_primes([2, 3, 4, 5, 10, 13, 15]) == [2, 3, 5, 13] >>> filter_primes([]) == ...
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 filter_primes(input_list): """ Returns a new list containing only the pr...
from solution import filter_primes def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_no_primes(): assert filter_primes([4, 6, 8, 9, 10]) == [] def test_filter_primes_mixed_numbers(): assert filter_primes([2, 3, 4, 5, 10, 13, 15]) == [2,...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list containing only the prime numbers from the original list.", "function_declaration": "def filter_primes(input_list):", "function_...
[ 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_0
{ "original_instruction": "Create a function that accepts a list of integers and returns a new list containing only the prime numbers from the original list.\n\nThe function takes a list of integers (input_list) as a parameter and should filter out the prime numbers.\n\nFor example, given the list [2, 3, 4, 5, 10, 13...
0.656315
Taco_95180
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d392b37dba240e98f5512b959056164deee39721
3ebe1576220a0e028b01ff3038121521378c1986
v1.0
complete
Taco
Taco_94699_C
from typing import List, Tuple def process_tree(n: int, edges: List[Tuple[int, int]], operations: List[Tuple[int, ...]]) -> List[int]: """Process a tree with given operations and return results of queries. Args: n (int): The number of nodes in the tree. edges (List[Tuple[int, int]]): A list of the...
from collections import defaultdict import sys sys.setrecursionlimit(200000) def dfs(node, parent, adj, start, end, timer, flat_tree): timer[0] += 1 start[node] = timer[0] flat_tree[timer[0]] = node for neighbor in adj[node]: if neighbor != parent: dfs(neighbor, node, adj, star...
def test_process_tree_example(): n = 5 edges = [(1, 2), (1, 3), (2, 4), (2, 5)] operations = [ (1, 2, 10), (2, 4), (1, 1, 5), (2, 3) ] assert process_tree(n, edges, operations) == [10, 5] def test_process_tree_single_node(): n = 1 edges = [] operations = ...
[ { "docstring": null, "function_declaration": "def dfs(node, parent, adj, start, end, timer, flat_tree):", "function_name": "dfs", "parameter_list": "(node, parent, adj, start, end, timer, flat_tree)" }, { "docstring": null, "function_declaration": "def process_tree(n, edges, operations):...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\nclass Tree:\n def __init__(self, n):\n self.n = n\n self.graph = defaultdict(list)\n self.val...
trial_gpt4o_1
{ "original_instruction": "Consider a tree (an undirected graph with no cycles) consisting of `n` nodes. Each node of the tree has a value assigned to it. Initially, all nodes have a value of 0. There are `q` operations of two types:\n\n1. Update: Add a given value `x` to all nodes in the subtree rooted at node `u`.\...
0.558598
Taco_94699
C
[ "dfs", "process_tree" ]
2
[ [ "process_tree", "dfs" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1a68227eeb95e8e1b52a93cee44d06ce801e10e6
1207c9944bb3935e815216fca7379321a8b0df1d
v1.0
complete
Taco
Taco_94568_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nodes): """ Builds a tree from a list of node tuples where each tuple contains (val, left, right) """ if not nodes: return None tree_no...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nodes): if not nodes: return None tree_nodes = [None] * (len(nodes) + 1) for i, (val, left, right) in enumerate(nodes, 1): if tree_...
import pytest from solution import solve def test_single_node_tree(): assert solve([[(3, -1, -1)]]) == [3] def test_simple_tree(): assert solve([[(1, 2, 3), (2, -1, -1), (3, -1, -1)]]) == [4] def test_complex_tree(): nodes = [(5, 2, 3), (3, -1, -1), (4, 4, 5), (-10, -1, -1), (20, -1, -1)] assert solv...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_0
{ "original_instruction": "Alice has recently learned about binary trees in her data structures class. She is given a binary tree and she would like to find out the maximum sum of values from the root node to any leaf node in this tree. Write a program to help Alice find this maximum sum.\n\n-----Input-----\n- The fi...
0.632895
Taco_94568
C
[ "build_tree", "max_path_sum", "solve" ]
3
[ [ "solve", "build_tree" ], [ "solve", "max_path_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
9f3857e7d41ea0c3164defd138068b7992b968d9
2221e6482bf0eaafaeb23674a78d21c89f08a7fd
v1.0
complete
Taco
Taco_94836_C
def build_prefix_sum(heights, N): """ Builds a prefix sum matrix for the given heights matrix. Args: heights (List[List[int]]): A 2D list representing the heights of buildings. N (int): The side length of the grid. Returns: List[List[int]]: A 2D list representing the prefix sum matrix. ...
def build_prefix_sum(heights, N): prefix_sum = [[0] * (N + 1) for _ in range(N + 1)] for i in range(1, N + 1): for j in range(1, N + 1): prefix_sum[i][j] = ( heights[i-1][j-1] + prefix_sum[i-1][j] + prefix_sum[i][j-1] - pre...
from solution import build_prefix_sum, get_building_view_score, compute_building_view_scores def test_single_element_grid(): N = 1 Q = 1 heights = [[5]] queries = [(1, 1, 1, 1)] results = compute_building_view_scores(N, Q, heights, queries) assert results == [5] def test_3x3_grid(): N = 3 ...
[ { "docstring": null, "function_declaration": "def build_prefix_sum(heights, N):", "function_name": "build_prefix_sum", "parameter_list": "(heights, N)" }, { "docstring": null, "function_declaration": "def get_building_view_score(prefix_sum, r1, c1, r2, c2):", "function_name": "get_bu...
[ 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 compute_building_view_scores(N, Q, heights, queries):\n # Precompute the prefix sums\n prefix_sums = [[0] * (N + 1) for _ in range(N + 1)]\n for i in ...
trial_gpt4o_1
{ "original_instruction": "The city of Borgonia is known for its perfectly straight streets and excellent city planning. Recently, the city has been divided into a grid of square blocks, each block measuring 1 unit by 1 unit. The blocks are numbered from 1 to N, arranged in an N x N grid, starting from the top-left b...
0.568718
Taco_94836
C
[ "build_prefix_sum", "get_building_view_score", "compute_building_view_scores" ]
3
[ [ "compute_building_view_scores", "build_prefix_sum" ], [ "compute_building_view_scores", "get_building_view_score" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0716a46235aaafd48eeae5b0da6b21704e166bd9
901879894d5d2c0356c0709267b2c54769999778
v1.0
complete
Taco
Taco_95145_C
def shortest_path(grid: List[List[int]], start: Tuple[int, int], end: Tuple[int, int]) -> Union[int, str]: """ Determine the shortest path for a robot to travel from a starting point to a delivery point on a grid. Parameters: grid (List[List[int]]): A 2D list representing the grid of city streets (1 fo...
from collections import deque def shortest_path(grid, start, end): m, n = len(grid), len(grid[0]) sx, sy = start dx, dy = end directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] queue = deque([(sx, sy, 0)]) visited = set() visited.add((sx, sy)) while queue: x, y, distance = queue...
from solution import shortest_path def test_shortest_path_case_1(): grid = [ [1, 1, 1, 0, 1], [1, 0, 1, 1, 1], [1, 0, 0, 1, 1], [1, 1, 1, 0, 1], [1, 1, 1, 1, 1] ] start = (0, 0) end = (4, 4) assert shortest_path(grid, start, end) == 8 def test_shortest_path_...
[ { "docstring": null, "function_declaration": "def shortest_path(grid, start, end):", "function_name": "shortest_path", "parameter_list": "(grid, start, end)" }, { "docstring": null, "function_declaration": "def solve_rds_cases():", "function_name": "solve_rds_cases", "parameter_l...
[ 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(grid, start, goal):\n \"\"\"\n Finds the shortest path from start to goal in the given grid.\n :param g...
trial_gpt4o_3
{ "original_instruction": "A company named Robotic Delivery Services (RDS) specializes in delivering parcels using autonomous robots. Each robot moves on a grid of city streets, represented by a 2D matrix where the value at each cell indicates whether that cell is passable (1 for passable, 0 for impassable). Each rob...
0.690659
Taco_95145
C
[ "shortest_path", "solve_rds_cases" ]
2
[ [ "solve_rds_cases", "shortest_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
72240db28674e9ffc80530ff7d1c1e64960bff57
d9f267f4273b81a8eacea949ec5c94da1701cd6d
v1.0
complete
Taco
Taco_94651_C
from collections import defaultdict, deque def bfs(graph, source, sink, parent): """ Helper function for BFS traversal in Edmonds-Karp algorithm """ # <Implement the BFS traversal here> pass def edmonds_karp(n: int, edges: List[Tuple[int, int, int]]) -> int: """ Determine the maximum flow in a given d...
from collections import deque, defaultdict def bfs(graph, source, sink, parent): visited = set() queue = deque([source]) visited.add(source) while queue: u = queue.popleft() for v, capacity in graph[u].items(): if v not in visited and capacity > 0: queue.ap...
def test_edmonds_karp(): edges = [ (1, 2, 100), (1, 3, 100), (2, 3, 1), (2, 4, 100), (3, 4, 100) ] assert edmonds_karp(4, edges) == 200 def test_no_path(): edges = [ (1, 2, 100), (2, 3, 100) ] assert edmonds_karp(4, edges) == 0 def test_s...
[ { "docstring": null, "function_declaration": "def bfs(graph, source, sink, parent):", "function_name": "bfs", "parameter_list": "(graph, source, sink, parent)" }, { "docstring": null, "function_declaration": "def edmonds_karp(n, edges):", "function_name": "edmonds_karp", "paramet...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef bfs(graph, source, sink, parent):\n visited = set()\n queue = deque([source])\n visited.add(source)\n\n ...
trial_gpt4o_0
{ "original_instruction": "Write a program that determines the maximum flow in a given directed network graph \\( G = (V, E) \\) using the Edmonds-Karp algorithm. The graph represents a network of pipes where each edge \\( (u, v) \\) has a flow capacity \\( c(u, v) \\). The source vertex is always labeled as \\( 1 \\...
0.552202
Taco_94651
C
[ "bfs", "edmonds_karp" ]
2
[ [ "edmonds_karp", "bfs" ] ]
1
[]
false
[]
false
pytest
false
[]
true
3a5222f8ed695ffa32247ab1bdbf7d4966f4a6d5
006bf99b40ee94ea9c28289c0acab292064cf7c8
v1.0
complete
Taco
Taco_95232_C
def count_set_bits(x): """ Count the number of set bits (1s) in the binary representation of an integer. >>> count_set_bits(0) == 0 >>> count_set_bits(1) == 1 >>> count_set_bits(7) == 3 >>> count_set_bits(12) == 2 """ pass def min_operations_to_zero(arr): """ Returns the minimum...
def count_set_bits(x): """ Count the number of set bits (1s) in the binary representation of an integer. """ return bin(x).count('1') def min_operations_to_zero(arr): """ Returns the minimum number of operations required to reduce all elements in the list to 0. """ operations = 0 fo...
def test_count_set_bits(): assert count_set_bits(0) == 0 assert count_set_bits(1) == 1 assert count_set_bits(7) == 3 assert count_set_bits(12) == 2 def test_min_operations_to_zero_example_cases(): assert min_operations_to_zero([5, 7, 12]) == 7 # 5(2) + 7(3) + 12(2) = 7 assert min_operations_to_...
[ { "docstring": "Count the number of set bits (1s) in the binary representation of an integer.", "function_declaration": "def count_set_bits(x):", "function_name": "count_set_bits", "parameter_list": "(x)" }, { "docstring": "Returns the minimum number of operations required to reduce all elem...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_set_bits(x):\n \"\"\"\n Count the number of set bits (1s) in the binary representation of an integer.\n \"\"\"\n return bin(x).count('1')\n\n...
trial_gpt4o_0
{ "original_instruction": "You are given a list of integers. You can perform the following operations on the list:\n\n1. Select any contiguous subarray.\n2. Flip all the bits of each element in the subarray (i.e., change all 1s to 0s and all 0s to 1s).\n\nFor example, consider the list [5, 7, 12], where 5 in binary i...
0.691879
Taco_95232
C
[ "count_set_bits", "min_operations_to_zero", "solve" ]
3
[ [ "min_operations_to_zero", "count_set_bits" ], [ "solve", "min_operations_to_zero" ] ]
2
[]
false
[]
false
pytest
true
[]
true
592a8bf740f22bd28815f32116d6efab9723e616
e4f4a728ce2d07311ef845e4564e4572963f0c4d
v1.0
complete
Taco
Taco_95338_C
def count_paths(n: int, m: int, traps: List[Tuple[int, int]]) -> int: """ Count the number of possible paths Masha can take to reach the bottom-right corner of the grid without stepping on any traps. :param n: Number of rows in the grid. :param m: Number of columns in the grid. :param traps: List of tup...
def count_paths(n, m, traps): MOD = 1000000007 # Initialize the grid with False meaning no trap grid = [[False] * m for _ in range(n)] # Place the traps on the grid for x, y in traps: grid[x - 1][y - 1] = True # Initialize the dp array dp = [[0] * m for _ in range(n)] ...
def test_example_1(): input_string = "3 3\n1\n2 2" expected_output = 2 assert count_paths_from_input_string(input_string) == expected_output def test_example_2(): input_string = "3 3\n0" expected_output = 6 assert count_paths_from_input_string(input_string) == expected_output def test_no_traps...
[ { "docstring": null, "function_declaration": "def count_paths(n, m, traps):", "function_name": "count_paths", "parameter_list": "(n, m, traps)" }, { "docstring": null, "function_declaration": "def count_paths_from_input_string(input_string):", "function_name": "count_paths_from_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": "MOD = 1000000007\n\ndef count_paths(n, m, traps):\n # Create the grid\n grid = [[1] * m for _ in range(n)]\n \n # Mark the traps on the grid\n for x...
trial_gpt4o_3
{ "original_instruction": "Masha is playing a game where she has to move from the top-left corner to the bottom-right corner of a grid with `n` rows and `m` columns. She can only move right or down at each step. Additionally, there are certain cells in the grid designated as traps. If Masha steps on a trap, the game ...
0.708492
Taco_95338
C
[ "count_paths", "count_paths_from_input_string" ]
2
[ [ "count_paths_from_input_string", "count_paths" ] ]
1
[]
false
[]
false
pytest
false
[]
true
afa28a92ab4a78ab275abbb7b91085c5f7b2365e
0aab151bd29e4368fcfa5f63a35bcdb810d8120c
v1.0
complete
Taco
Taco_95555_C
def minimizedMaxProcessingLoad(servers: int, files: List[int]) -> int: """ Distribute the files across the servers in a manner that minimizes the maximum processing load on any server. >>> minimizedMaxProcessingLoad(3, [10, 20, 30, 40, 50]) 60 >>> minimizedMaxProcessingLoad(1, [10, 20, 30, 40, 50]) ...
def canDistributeLoad(load, servers, files): count = 0 current_load = 0 for file in files: if current_load + file <= load: current_load += file else: count += 1 current_load = file if current_load > load: return False ...
from solution import minimizedMaxProcessingLoad def test_small_input(): assert minimizedMaxProcessingLoad(3, [10, 20, 30, 40, 50]) == 60 def test_one_server(): assert minimizedMaxProcessingLoad(1, [10, 20, 30, 40, 50]) == 150 def test_equal_load(): assert minimizedMaxProcessingLoad(3, [10, 10, 10, 10, 10...
[ { "docstring": null, "function_declaration": "def canDistributeLoad(load, servers, files):", "function_name": "canDistributeLoad", "parameter_list": "(load, servers, files)" }, { "docstring": null, "function_declaration": "def minimizedMaxProcessingLoad(servers, files):", "function_n...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def canDistributeLoad(load, servers, files):\n count = 0\n current_load = 0\n \n for file in files:\n if current_load + file <= load:\n ...
trial_gpt4o_0
{ "original_instruction": "A software company wants to optimize the loading of files on their cloud platform. They have multiple servers, each with a different processing power. Each file to be uploaded requires a certain amount of processing power. The goal is to distribute the files across the servers in a manner t...
0.54993
Taco_95555
C
[ "canDistributeLoad", "minimizedMaxProcessingLoad", "main" ]
3
[ [ "minimizedMaxProcessingLoad", "canDistributeLoad" ] ]
1
[]
false
[]
false
pytest
true
[]
true
403143a4c0d831d04e719126434025c33b308ea6
dad3bb193e5cd260284d13ee2de92cb88b5b97a6
v1.0
complete
Taco
Taco_95639_C
def solve(test_cases: List[Tuple[int, int]]) -> List[int]: """ Given a list of test cases with integers N and M, find the smallest prime number greater than N and add it to the sum of the digits of M. Args: test_cases (List[Tuple[int, int]]): A list of tuples where each tuple contains two integers N a...
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 next_prime(n): if n <= 1: return 2 prime = n + 1 while not i...
from solution import solve def test_case_1(): assert solve([(10, 123)]) == [17] def test_case_2(): assert solve([(17, 456)]) == [34] def test_case_3(): assert solve([(1, 1000000000)]) == [2 + 1] # Prime after 1 is 2, Sum of digits of 1000000000 is 1 def test_case_4(): assert solve([(10, 0)]) == [11...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def next_prime(n):", "function_name": "next_prime", "parameter_list": "(n)" }, { "docstring": null, "...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if the given number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ret...
trial_gpt4o_8
{ "original_instruction": "------Read problems statements in Hindi,\nMandarin chinese\n, Russian and Vietnamese as well. ------\n\nTara loves playing with numbers, especially arranging them in interesting patterns. One day, she stumbled upon an interesting pattern using prime numbers. She challenges you to write a pr...
0.62955
Taco_95639
C
[ "is_prime", "next_prime", "sum_of_digits", "solve" ]
4
[ [ "next_prime", "is_prime" ], [ "solve", "next_prime" ], [ "solve", "sum_of_digits" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e16b6340d8ca972ffe11da942e11ae4091a49676
da46344f5221ff022997417141dff02a3d6f3251
v1.0
complete
Taco
Taco_95430_C
def find_hello_path(N: int, M: int, grid: List[str]) -> str: """ Determine if there's a path through the matrix that spells out the word "HELLO". You can start from any cell and move either horizontally, vertically, or diagonally in any of the 8 possible directions. The same cell cannot be used more than o...
def is_path_for_hello(matrix, N, M): def dfs(x, y, idx): if idx == len(word): return True # Mark the current cell as visited temp = matrix[x][y] matrix[x][y] = None # Define the 8 possible directions directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1...
import pytest from solution import find_hello_path def test_path_exists(): N, M = 3, 4 grid = [ "HAPE", "ELLO", "KXYZ" ] assert find_hello_path(N, M, grid) == "YES" def test_no_path_exists(): N, M = 3, 3 grid = [ "HAP", "ELX", "XYZ" ] ...
[ { "docstring": null, "function_declaration": "def is_path_for_hello(matrix, N, M):", "function_name": "is_path_for_hello", "parameter_list": "(matrix, N, M)" }, { "docstring": null, "function_declaration": "def find_hello_path(N, M, grid):", "function_name": "find_hello_path", "p...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid(x, y, N, M):\n return 0 <= x < N and 0 <= y < M\n\ndef search(matrix, word, x, y, index, visited):\n if index == len(word):\n return True...
trial_gpt4o_3
{ "original_instruction": "You are given a matrix of characters of size N x M. You need to determine if there's a path through the matrix that spells out the word \"HELLO\". You can start from any cell and you are allowed to move either horizontally, vertically, or diagonally in any of the 8 possible directions. The ...
0.61411
Taco_95430
C
[ "is_path_for_hello", "find_hello_path" ]
2
[ [ "find_hello_path", "is_path_for_hello" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a172e54c9bebaee6e3318bce4354bf4f70effada
4b51c486694bb4a7fb2cdd0e0b381ab54af3680d
v1.0
complete
Taco
Taco_95753_C
from typing import List def compute_gcd(a: int, b: int) -> int: return math.gcd(a, b) def max_gcd_after_removal(N: int, A: List[int]) -> int: """ Given a sequence of N positive integers, find the maximum possible GCD after removing exactly one integer. >>> max_gcd_after_removal(5, [12, 15, 18, 24, 30]) ...
import math from typing import List def compute_gcd(a: int, b: int) -> int: return math.gcd(a, b) def max_gcd_after_removal(N: int, A: List[int]) -> int: if N == 2: return max(A) prefix_gcd = [0] * (N + 1) suffix_gcd = [0] * (N + 1) for i in range(1, N + 1): prefix_gcd[i]...
import pytest from solution import compute_gcd, max_gcd_after_removal def test_compute_gcd(): assert compute_gcd(12, 15) == 3 assert compute_gcd(18, 24) == 6 assert compute_gcd(0, 5) == 5 assert compute_gcd(0, 0) == 0 def test_max_gcd_example_case(): assert max_gcd_after_removal(5, [12, 15, 18, 24...
[ { "docstring": null, "function_declaration": "def compute_gcd(a, b):", "function_name": "compute_gcd", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def max_gcd_after_removal(N, A):", "function_name": "max_gcd_after_removal", "parameter_list": "(N, A...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom functools import reduce\n\ndef max_gcd_after_removing_one(N, A):\n \"\"\"\n Returns the maximum GCD after removing exactly one integer from...
trial_gpt4o_2
{ "original_instruction": "You are given a sequence `A` of `N` positive integers. You are allowed to remove exactly one integer from the sequence. After removing one integer, you want to know the maximum possible Greatest Common Divisor (GCD) of the remaining integers.\n\nWrite a function that takes the sequence `A` ...
0.706625
Taco_95753
C
[ "compute_gcd", "max_gcd_after_removal" ]
2
[ [ "max_gcd_after_removal", "compute_gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c1466f9dc8ea6cd9db29a2aa9b7f68482a32bcb3
1d862b616dc591f619a0694a565d104c72846e40
v1.0
complete
Taco
Taco_95543_C
def kruskal_mst(districts: int, rail_lines: List[Tuple[int, int, int]]) -> int: """ Find the total travel time of the minimum spanning tree of a city. The city consists of distinct districts connected by rail lines with given travel times. Args: districts (int): Number of districts in the city. ...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: p...
def test_kruskal_mst(): districts = 4 rail_lines = [ (1, 2, 10), (2, 3, 15), (3, 4, 4), (4, 1, 6), (1, 3, 5) ] assert kruskal_mst(districts, rail_lines) == 19 def test_example_2(): districts = 3 rail_lines = [ (1, 2, 5), (2, 3, 4), ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 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 find_mst_total_cost(districts, rail_lines, edges):\n \"\"\"\n Uses Kruskal's algorithm to find the minimum spanning tree total travel time\n for the r...
trial_gpt4o_4
{ "original_instruction": "You are responsible for designing an efficient rail network for a newly developed city. The city consists of several distinct districts connected by a series of rail lines. Each district is represented as a node, and each direct rail line between two districts is represented as an edge with...
0.571661
Taco_95543
C
[ "find", "union", "kruskal_mst", "calculate_minimum_spanning_tree" ]
4
[ [ "calculate_minimum_spanning_tree", "kruskal_mst" ], [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
b64daec82d9f3b5896935507b27c32df40e4e334
8cf935579a3d00b78ebd328464c4c192d59b7fb0
v1.0
complete
Taco
Taco_95621_C
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def is_tree_balanced_from_level_order(level_order: str) -> bool: """ Determines whether a given binary tree represented in level-order format is balanced. A binary tree is balanced if, for every n...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def is_balanced(root): def check(node): if node is None: return 0, True left_height, left_balanced = check(node.left) right_height, right_balanced = check(node.righ...
from solution import is_tree_balanced_from_level_order def test_balanced_tree(): assert is_tree_balanced_from_level_order("1 2 3 4 5 # #") == True def test_unbalanced_tree(): assert is_tree_balanced_from_level_order("1 2 3 4 # # 5 6") == False def test_single_node_tree(): assert is_tree_balanced_from_lev...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef insert_...
trial_gpt4o_2
{ "original_instruction": "A: Binary Tree Balance\n\nBrian is learning about binary trees and is particularly interested in balanced binary trees. A binary tree is considered balanced if, for every node in the tree, the height of its left and right subtrees differ by at most one. Brian wants to write a program that d...
0.767732
Taco_95621
C
[ "is_balanced", "build_tree", "is_tree_balanced_from_level_order" ]
3
[ [ "is_tree_balanced_from_level_order", "build_tree" ], [ "is_tree_balanced_from_level_order", "is_balanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
de4ae671aa24b7e77e4e3f5dd244eb381cac596b
bd9eabdaf1420e11c01adcdc884af2316e001920
v1.0
complete
Taco
Taco_95728_C
from typing import List def max_path_sum_in_grid(test_cases: List[List[List[int]]]) -> List[int]: """ Find the maximum sum of numbers collected along any path from the top-left corner to the bottom-right corner of a grid. The path is only allowed to move either to the right or down. Params: -----...
def max_path_sum_in_grid(test_cases): results = [] for grid in test_cases: n = len(grid) # Create a DP table to store the maximum sums dp = [[0] * n for _ in range(n)] # Initialize the top-left corner of the DP table dp[0][0] = grid[0][0] # ...
def test_max_path_sum_in_grid(): test_cases = [ [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ], [ [1, 2], [1, 1] ] ] assert max_path_sum_in_grid(test_cases) == [29, 4] def test_parse_input_string(): input_string = "2\n3\n1...
[ { "docstring": null, "function_declaration": "def max_path_sum_in_grid(test_cases):", "function_name": "max_path_sum_in_grid", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input_string(input_string):", "function_name": "parse_input_strin...
[ 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 max_path_sum_in_grid(test_cases):\n results = []\n \n for grid in test_cases:\n n = len(grid)\n # Create a DP table to store the maximum...
trial_gpt4o_0
{ "original_instruction": "Panda, fond of solving puzzles, comes across a large grid of numbers while traveling. The grid is a square matrix of size NxN, filled with non-negative integers. Panda is curious about the paths through this matrix from the top-left corner (1,1) to the bottom-right corner (N,N). However, th...
0.624743
Taco_95728
C
[ "max_path_sum_in_grid", "parse_input_string", "max_path_sum" ]
3
[ [ "max_path_sum", "max_path_sum_in_grid" ], [ "max_path_sum", "parse_input_string" ] ]
2
[]
false
[]
false
pytest
false
[]
true
18e0b41f16568f463fb194218dc7eca41a558b3e
7e53d143b8e9de64b1710dc0858553bd8fbef8a5
v1.0
complete
Taco
Taco_95431_C
from typing import List def find_prime_palindromes(inputs: List[int]) -> List[int]: """ Function to find the smallest Prime Palindrome Number (PPN) which is greater than or equal to each number in the provided list of inputs. A Prime Palindrome Number (PPN) is a number that: 1. Is a prime number. ...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i +...
from solution import find_prime_palindromes def test_sample_inputs(): inputs = [31, 45, 90, 0] expected_outputs = [101, 101, 101] assert find_prime_palindromes(inputs) == expected_outputs def test_single_inputs(): inputs = [4, 31, 45, 90] expected_outputs = [5, 101, 101, 101] assert find_prime...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Helper function to check if a number is a palindrome.", "function_declaration": "def is_palindrome(n):", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return ...
trial_gpt4o_0
{ "original_instruction": "A famous mathematician once discovered a fascinating property related to prime numbers and palindromes. He defined a special type of number called a \"Prime Palindrome Number\" (PPN). A PPN is a number that satisfies both of the following conditions:\n1. The number is a prime number.\n2. Th...
0.645092
Taco_95431
C
[ "is_prime", "is_palindrome", "find_smallest_ppn_greater_equal", "find_prime_palindromes" ]
4
[ [ "find_prime_palindromes", "find_smallest_ppn_greater_equal" ], [ "find_smallest_ppn_greater_equal", "is_palindrome" ], [ "find_smallest_ppn_greater_equal", "is_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
12c85a5f6a9d4832df0f0a80ee00540837f6687b
db7bd28c6160293f8634a5f990547fa50f9b39a5
v1.0
complete
Taco
Taco_95154_C
def next_reminder(current_time_str: str, slots: List[str]) -> str: """ Determine the next available reminder time slot for a given user. The user’s schedule is provided as a list of strings, each string denoting a day and time slot in the format 'Day HH:MM'. Args: current_time_str (str): Current t...
from datetime import datetime, timedelta def parse_time_string(time_str): days_of_week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] day, time = time_str.split() day_index = days_of_week.index(day) hour, minute = map(int, time.split(':')) return day_index, hour, m...
from solution import next_reminder def test_simple_case(): assert next_reminder("Thursday 16:35", ["Monday 14:00", "Wednesday 09:00", "Thursday 18:00", "Saturday 12:00", "Sunday 16:45"]) == "Thursday 18:00" def test_next_week_case(): assert next_reminder("Friday 20:00", ["Tuesday 08:00", "Friday 19:00", "Mond...
[ { "docstring": null, "function_declaration": "def parse_time_string(time_str):", "function_name": "parse_time_string", "parameter_list": "(time_str)" }, { "docstring": null, "function_declaration": "def next_reminder(current_time_str, slots):", "function_name": "next_reminder", "...
[ 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 datetime import datetime, timedelta\n\ndef get_next_reminder_time(current_time, N, schedule):\n # Days mapping to enable comparison\n days_to_num = {\n ...
trial_gpt4o_1
{ "original_instruction": "You are working on a mobile phone application which allows users to set reminders. One of the key functions of the app is to determine the next available reminder time slot for a given user. Each user has a predefined schedule where they can set reminders, and this schedule repeats weekly.\...
0.590809
Taco_95154
C
[ "parse_time_string", "next_reminder" ]
2
[ [ "next_reminder", "parse_time_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bdfdbecbbb1512ba5853aa8b99eff8624c3df272
fad9282f0c949e3d9e859d5cb096f6c00a372a4c
v1.0
complete
Taco
Taco_96148_C
def solve_magic_forest(input_data): """ Determine if it's possible to assign energies to the trees such that each connection (pathway) between any two trees conveys the same amount of magical energy. >>> solve_magic_forest([(4, 4), (1, 2), (2, 3), (3, 4), (4, 1), (0, 0)]) ['Possible'] >>> sol...
def is_possible(n, m, connections): if m == 0: return "Possible" from collections import defaultdict degrees = defaultdict(int) for u, v in connections: degrees[u] += 1 degrees[v] += 1 for degree in degrees.values(): if degree % 2 != 0: return "I...
def test_possible_case(): input_data = [ (4, 4), (1, 2), (2, 3), (3, 4), (4, 1), (0, 0) ] output = solve_magic_forest(input_data) assert output == ["Possible"] def test_impossible_case(): input_data = [ (3, 2), (2, 3), (1, 2), ...
[ { "docstring": null, "function_declaration": "def is_possible(n, m, connections):", "function_name": "is_possible", "parameter_list": "(n, m, connections)" }, { "docstring": null, "function_declaration": "def solve_magic_forest(input_data):", "function_name": "solve_magic_forest", ...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_possible_to_distribute_energy(n, m, connections):\n from collections import deque\n \n def is_bipartite(graph, n):\n color = [-1] * n\n ...
trial_gpt4o_3
{ "original_instruction": "In a far-off land, a magical forest is filled with a wide variety of enchanted trees. Each tree has its own unique level of magical energy, and these trees are linked to each other in a vast network of connections. The forest is maintained by a group of wise wizards who have established a s...
0.492871
Taco_96148
C
[ "is_possible", "solve_magic_forest" ]
2
[ [ "solve_magic_forest", "is_possible" ] ]
1
[]
false
[]
false
pytest
false
[]
true
a6ed24ddf472ab635775df7b9f30e90d6c9243c6
8fc1c64e2f7e98b7322a9e3964bb3c03e183e20c
v1.0
complete
Taco
Taco_96149_C
def robot_min_steps(grid_str: str) -> int: """ Determine the minimum steps required for a robot to move from the top-left corner of the grid (1, 1) to the bottom-right corner (N, M). The robot can only move up, down, left, or right and cannot move through blocked cells. Parameters: grid_str (s...
from collections import deque def min_steps(grid, n, m): directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] start = (0, 0) end = (n-1, m-1) if grid[0][0] == '#' or grid[n-1][m-1] == '#': return -1 queue = deque([(start, 0)]) visited = set([start]) while queue: (current_x...
import pytest from solution import robot_min_steps def test_example_case(): input_str = "5 6\n....#.\n.#..#.\n.#...#\n#..#..\n......" assert robot_min_steps(input_str) == 9 def test_unreachable_case(): input_str = "3 3\n.#.\n###\n.#." assert robot_min_steps(input_str) == -1 def test_blocked_start(): ...
[ { "docstring": null, "function_declaration": "def min_steps(grid, n, m):", "function_name": "min_steps", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def robot_min_steps(grid_str):", "function_name": "robot_min_steps", "parameter_list": "(grid...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_steps(N, M, grid):\n \"\"\"\n Calculates the minimum number of steps required for a robot to move from (1, 1) to (N,...
trial_gpt4o_1
{ "original_instruction": "You are given a grid of size $N \\times M$ with some cells blocked. You need to determine the minimum steps required for a robot to move from the top-left corner of the grid (1, 1) to the bottom-right corner (N, M). The robot can only move up, down, left, or right and cannot move through bl...
0.639586
Taco_96149
C
[ "min_steps", "robot_min_steps" ]
2
[ [ "robot_min_steps", "min_steps" ] ]
1
[]
false
[]
false
pytest
true
[]
true
570ea93aac1403489b242a8e2539fabf6f89164d
b9ebeca90183f7390687c93066b884df4a7594e9
v1.0
complete
Taco
Taco_96268_C
from typing import List def is_prime(num: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def filter_primes(numbers: List[int]) -> List[int]: """ Filter the list and return only prime numbers. >>> filter_primes([10, 15, 17, 23, 25, ...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def filter_primes(numb...
from solution import is_prime, filter_primes 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(19) == True assert is_prime(1) == False assert is_prime(0) == Fals...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Filter the list and return only prime numbers.", "function_declaration": "def filter_primes(numbers):", "function_name...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Determine whether a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n re...
trial_gpt4o_1
{ "original_instruction": "As a software developer, you are tasked with writing a filter function to process a list of numbers and return only the prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.\n\nYour function should receive a list of integers ...
0.753237
Taco_96268
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ac665ff66da0ffefd2514de24646e9beb5383950
2cc0b58de36eb0476db6697f3628888e675419ae
v1.0
complete
Taco
Taco_95894_C
def minimize_max_abs_difference(t: int, test_cases: List[Tuple[int, List[int]]]) -> str: """ Polycarp wants to rearrange the array such that the absolute difference between any two adjacent elements is minimized. If there are multiple valid arrangements, return the one that is lexicographically smallest. ...
def rearrange_array(t, test_cases): results = [] for i in range(t): n = test_cases[i][0] a = sorted(test_cases[i][1]) results.append(a) return results def format_results(results): return '\n'.join(' '.join(map(str, result)) for result in results) # Function to execute solution ...
def test_minimize_max_abs_difference(): # Test case 1 t, test_cases = 2, [(4, [10, 1, 3, 7]), (3, [4, 2, 5])] expected = "1 3 7 10\n2 4 5" assert minimize_max_abs_difference(t, test_cases) == expected # Test case 2 t, test_cases = 1, [(5, [5, 4, 3, 2, 1])] expected = "1 2 3 4 5" assert ...
[ { "docstring": null, "function_declaration": "def rearrange_array(t, test_cases):", "function_name": "rearrange_array", "parameter_list": "(t, test_cases)" }, { "docstring": null, "function_declaration": "def format_results(results):", "function_name": "format_results", "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 rearrange_min_abs_diff(t, cases):\n results = []\n for i in range(t):\n n = cases[i][0]\n arr = sorted(cases[i][1])\n results.append...
trial_gpt4o_2
{ "original_instruction": "Polycarp has an array of $n$ integers $a_1, a_2, \\dots, a_n$. Polycarp wants to rearrange the array such that the absolute difference between any two adjacent elements is minimized. Your task is to help Polycarp find such an arrangement.\n\nAdditionally, if there are multiple valid arrange...
0.709711
Taco_95894
C
[ "rearrange_array", "format_results", "minimize_max_abs_difference" ]
3
[ [ "minimize_max_abs_difference", "format_results" ], [ "minimize_max_abs_difference", "rearrange_array" ] ]
2
[ "format_results" ]
false
[]
false
pytest
false
[]
true
49b2bc0130306b6a07bed02a681357f4d8a675d1
bf3de7eb32915bcddc1ec9319f32a102ff1cf6d1
v1.0
complete
Taco
Taco_96163_C
def is_prime(num: int) -> bool: """ Check if a number is prime. >>> is_prime(2) == True >>> is_prime(4) == False >>> is_prime(17) == True >>> is_prime(18) == False """ pass def is_palindrome(num: int) -> bool: """ Check if a number is a palindrome. >>> is_palindrome(121) == True ...
def is_prime(num): if num < 2: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def is_palindrome(num): return str(num) == str(num)[::-1] def smallest_prime_palindrome(N): while True: if is_palindrome(N) and is_prime(N...
import pytest from solution import solve, is_prime, is_palindrome, smallest_prime_palindrome def test_is_prime(): assert is_prime(2) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False def test_is_palindrome(): assert is_palindrome(121) == True assert i...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "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 is_palindrome(num):\n \"\"\"\n Checks if a number is a palindrome.\n \"\"\"\n return str(num) == str(num)[::-1]\n\ndef is_prime(num):\n \"\"\"\n...
trial_gpt4o_1
{ "original_instruction": "A prime number is a natural number greater than 1 that has no divisors other than 1 and itself. A palindrome is a number that reads the same backward as forward, such as 121 or 1331.\n\nYou are given an integer N. Your task is to find the smallest prime palindrome number greater than or equ...
0.657571
Taco_96163
C
[ "is_prime", "is_palindrome", "smallest_prime_palindrome", "solve" ]
4
[ [ "smallest_prime_palindrome", "is_palindrome" ], [ "smallest_prime_palindrome", "is_prime" ], [ "solve", "smallest_prime_palindrome" ] ]
3
[]
false
[]
false
pytest
true
[]
true
31117fef45743650795c3aa88addf319168ddbdd
d6ebb77a2cb780e151d5d61c247b5fc60f420efd
v1.0
complete
Taco
Taco_95886_C
def can_form_palindrome(s: str) -> str: """ Determine whether you can create a palindrome by removing exactly one character from the string `s`. >>> can_form_palindrome("abca") "YES" >>> can_form_palindrome("abc") "NO" """
def valid_palindrome_with_one_removal(s): def is_palindrome_range(i, j): return all(s[k] == s[j - k + i] for k in range(i, j // 2 + 1)) left, right = 0, len(s) - 1 while left < right: if s[left] != s[right]: # Check by removing either left character or right character ...
from solution import can_form_palindrome def test_can_form_palindrome(): assert can_form_palindrome("abca") == "YES" assert can_form_palindrome("abc") == "NO" assert can_form_palindrome("a") == "YES" assert can_form_palindrome("aa") == "YES" assert can_form_palindrome("racecar") == "YES" assert...
[ { "docstring": null, "function_declaration": "def valid_palindrome_with_one_removal(s):", "function_name": "valid_palindrome_with_one_removal", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome...
[ 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 valid_palindrome_with_one_removal(s):\n def is_palindrome_range(i, j):\n return all(s[k] == s[j - k + i] for k in range(i, j // 2 + 1))\n\n left, ...
trial_gpt4o_0
{ "original_instruction": "A palindrome is a string that reads the same forward and backward. Given a string `s`, you can remove at most one character from it. Your task is to determine whether you can create a palindrome by removing exactly one character from the string `s`.\n\n-----Input-----\nThe input will be a s...
0.807669
Taco_95886
C
[ "valid_palindrome_with_one_removal", "can_form_palindrome" ]
2
[ [ "can_form_palindrome", "valid_palindrome_with_one_removal" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a5f832db1cb4a75004eb557de6ddc806f288b6ce
fba1ffc2cc4906a22b70cbb22149b4668c275d05
v1.0
complete
Taco
Taco_95874_C
def balanced_roots_tree(N: int, edges: List[Tuple[int, int]]) -> None: """ Determine if it is possible to rearrange the tree to form a Balanced Roots Tree. If possible, print "YES" followed by the new parent-child relationships. If not, print "NO". Args: N : int : The number of nodes in the tr...
from collections import defaultdict, deque def build_tree(edges, N): tree = defaultdict(list) for u, v in edges: tree[u].append(v) tree[v].append(u) return tree def is_balanced(tree, node, parent): heights = [] for child in tree[node]: if child != parent: # avoid going back...
def test_balanced_roots_tree_balanced(): N = 7 edges = [ (1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7) ] balanced_roots_tree(N, edges) # expects "YES" and prints the tree def test_balanced_roots_tree_unbalanced(): N = 4 edges = [ (1, 2)...
[ { "docstring": null, "function_declaration": "def build_tree(edges, N):", "function_name": "build_tree", "parameter_list": "(edges, N)" }, { "docstring": null, "function_declaration": "def is_balanced(tree, node, parent):", "function_name": "is_balanced", "parameter_list": "(tree...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def check_balanced_tree(N, edges):\n from collections import defaultdict, deque\n if N == 1:\n return \"YES\", []\n\n # Cr...
trial_gpt4o_7
{ "original_instruction": "In a magical forest, there exists a special type of tree called the Roots Tree. The Roots Tree has a unique growth pattern where each node in the tree represents a magical root, and each edge between nodes represents a magical connection. \n\nTo enhance the forest's magic, a wizard wants to...
0.666099
Taco_95874
C
[ "build_tree", "is_balanced", "reorder_tree", "balanced_roots_tree" ]
4
[ [ "balanced_roots_tree", "build_tree" ], [ "balanced_roots_tree", "is_balanced" ], [ "balanced_roots_tree", "reorder_tree" ] ]
3
[]
false
[]
false
pytest
false
[]
true
bd207fcf461906c15f11b6af241442b1e85253f9
48b8f017e3a9e393cf29bd2b7940d6da5c070c94
v1.0
complete
Taco
Taco_96026_C
def check_projects(T: int, projects: List[Tuple[int, int, List[Tuple[int, int]]]]) -> List[str]: """ Determine if it is possible to complete all tasks for each project without cyclic dependencies. Args: T (int): The number of projects. projects (List[Tuple[int, int, List[Tuple[int, int]]]]): A...
from collections import defaultdict, deque def is_possible_to_complete_all_tasks(n, dependencies): """ Returns whether it is possible to complete all tasks without cyclic dependencies. """ graph = defaultdict(list) in_degree = [0] * (n + 1) for a, b in dependencies: graph[b].append...
from solution import check_projects def test_check_projects(): assert check_projects(2, [ (4, 2, [(1, 2), (3, 1)]), (3, 3, [(1, 2), (2, 3), (3, 1)]) ]) == ["Possible", "Impossible"] def test_no_dependencies(): assert check_projects(1, [(4, 0, [])]) == ["Possible"] def test_single_task(): ...
[ { "docstring": "Returns whether it is possible to complete all tasks without cyclic dependencies.", "function_declaration": "def is_possible_to_complete_all_tasks(n, dependencies):", "function_name": "is_possible_to_complete_all_tasks", "parameter_list": "(n, dependencies)" }, { "docstring":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef can_complete_tasks(num_projects, projects):\n results = []\n\n for project in projects:\n n, m, depe...
trial_gpt4o_2
{ "original_instruction": "You have been given several software projects to manage, each containing a list of tasks. Each task is represented by its dependencies, i.e., the tasks that need to be completed before it. The dependencies can be represented as a list of pairs (a, b), where 'a' depends on 'b' and must be do...
0.526858
Taco_96026
C
[ "is_possible_to_complete_all_tasks", "check_projects" ]
2
[ [ "check_projects", "is_possible_to_complete_all_tasks" ] ]
1
[]
false
[]
false
pytest
true
[]
true
260bc13a6fa88ba0d0a72099c4869b917752491a
d7954a0302b8e647d83998687104cca34f90ca9c
v1.0
complete
Taco
Taco_96159_C
def is_prime(n: int) -> bool: """ Helper function to determine if 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 >>> is_prime(15) False >>> is_prime(17) True """ def ...
def is_prime(n): """ Helper function to determine if 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 is_prime, sort_primes_before_non_primes def test_is_prime(): assert is_prime(1) == False assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(15) == False assert is_prime(17) == True def test_sort_...
[ { "docstring": "Helper function to determine if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Sort the array such that prime numbers appear before non-prime numbers\nwhile maintaining relative order ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n r...
trial_gpt4o_0
{ "original_instruction": "Given an array of integers, you are to sort the array such that all prime numbers appear before all non-prime numbers while maintaining the relative order of the primes and the non-primes. \n\nA prime number is an integer greater than 1 that has no positive divisors other than 1 and itself....
0.717821
Taco_96159
C
[ "is_prime", "sort_primes_before_non_primes" ]
2
[ [ "sort_primes_before_non_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
020350d6264473535d037d590e5ab7917ed2dd18
39d6dd61e79a9eff7d8e49bf6b39d1f657a50d2d
v1.0
complete
Taco
Taco_95497_C
import re def is_valid_palindrome(s: str) -> bool: """ Returns True if the string s is a valid palindrome when ignoring non-alphanumeric characters and case. """ pass def validate_palindromes(n: int, strings: List[str]) -> List[bool]: """ Returns a list of boolean values indicating if each str...
import re def is_valid_palindrome(s): """ Returns True if the string s is a valid palindrome when ignoring non-alphanumeric characters and case. """ # Use regex to filter out non-alphanumeric characters and convert to lowercase filtered_s = re.sub(r'[^A-Za-z0-9]', '', s).lower() # Check if the ...
from solution import validate_palindromes def test_validate_palindromes_example1(): assert validate_palindromes(3, ["A man, a plan, a canal, Panama!", "race a car", "No lemon, no melon"]) == [True, False, True] def test_validate_palindromes_example2(): assert validate_palindromes(2, ["Madam In Eden, I'm Adam"...
[ { "docstring": "Returns True if the string s is a valid palindrome when ignoring non-alphanumeric characters and case.", "function_declaration": "def is_valid_palindrome(s):", "function_name": "is_valid_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns a list of boolean values ...
[ 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 is_palindrome(s):\n \"\"\"\n Checks if the given string is a palindrome, considering only\n alphanumeric characters and ignoring case.\n ...
trial_gpt4o_1
{ "original_instruction": "Write a program that reads a list of strings and determines if each string in the list is a valid palindrome when ignoring non-alphanumeric characters and case. The program should return a list of boolean values indicating the validity of each string.\n\nConstraints\n\n* $1 \\leq n \\leq 10...
0.812515
Taco_95497
C
[ "is_valid_palindrome", "validate_palindromes" ]
2
[ [ "validate_palindromes", "is_valid_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9a2d8c5ed199cb7e3dac3e0c711b8c692c6a47e6
ed5f7d361d08cd8b358d6c9160d8ec541700341e
v1.0
complete
Taco
Taco_96062_C
def solution(n: int, q: int, array: List[int], queries: List[Tuple[int, int, int]]) -> List[int]: """ Perform a series of queries on an array. Each query can be one of two types: 1. "1 x y": Update the element at index x to y. 2. "2 x y": Find the sum of the elements from index x to index y (in...
class NumArray: def __init__(self, nums): self.n = len(nums) self.nums = nums self.bit = [0] * (self.n + 1) for i in range(self.n): self.add(i + 1, nums[i]) def add(self, index, value): while index <= self.n: self.bit[index] += value ...
import pytest from solution import solution def test_example_case(): n = 5 q = 5 array = [1, 2, 3, 4, 5] queries = [ (2, 1, 3), (1, 3, 10), (2, 1, 3), (2, 2, 5), (1, 5, 6) ] expected_output = [6, 13, 21] assert solution(n, q, array, queries) == expec...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class SegmentTree:\n def __init__(self, data):\n self.n = len(data)\n self.tree = [0] * (2 * self.n)\n self.build(data)\n \n def ...
trial_gpt4o_2
{ "original_instruction": "You are given an array of integers of length n, and you are required to perform a series of queries on this array. Each query can be one of two types:\n\n1. \"1 x y\": Update the element at index x to y.\n2. \"2 x y\": Find the sum of the elements from index x to index y (inclusive).\n\nWri...
0.656618
Taco_96062
C
[ "handle_queries", "solution" ]
2
[ [ "solution", "handle_queries" ] ]
1
[ "handle_queries" ]
false
[ "NumArray" ]
true
pytest
true
[]
true
88c752ce7629d1e095225a8b0161fd943ea4ea75
2dac590b8878724c0a14a061382b0cec82abd342
v1.0
complete
Taco
Taco_96526_C
def matrix_transformations(matrix, sequence): """ Perform a series of transformations on a given matrix according to a sequence of commands. The possible commands are: - "transpose": Transpose the matrix. - "rotate_clockwise": Rotate 90 degrees clockwise. - "rotate_counterclockwise": Rotate 90 ...
def transpose(matrix): return [list(row) for row in zip(*matrix)] def rotate_clockwise(matrix): return [list(row) for row in zip(*matrix[::-1])] def rotate_counterclockwise(matrix): return [list(row) for row in zip(*matrix)][::-1] def flip_horizontal(matrix): return [row[::-1] for row in matrix] def...
from solution import matrix_transformations def test_transpose(): matrix = [ [1, 2], [3, 4] ] sequence = ["transpose"] expected = [ [1, 3], [2, 4] ] assert matrix_transformations(matrix, sequence) == expected def test_rotate_clockwise(): matrix = [ [...
[ { "docstring": null, "function_declaration": "def transpose(matrix):", "function_name": "transpose", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def rotate_clockwise(matrix):", "function_name": "rotate_clockwise", "parameter_list": "(matrix)" }...
[ 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 transpose(matrix):\n return [list(row) for row in zip(*matrix)]\n\ndef rotate_clockwise(matrix):\n return [list(row) for row in zip(*matrix[::-1])]\n\nde...
trial_gpt4o_9
{ "original_instruction": "You are required to create a function named `matrix_transformations(matrix, sequence)` that will perform a series of transformations on a given matrix according to a sequence of commands.\n\nThe function will receive two arguments:\n- `matrix`: A 2D list of integers, where each sublist repr...
0.510178
Taco_96526
C
[ "transpose", "rotate_clockwise", "rotate_counterclockwise", "flip_horizontal", "flip_vertical", "matrix_transformations" ]
6
[ [ "matrix_transformations", "flip_horizontal" ], [ "matrix_transformations", "flip_vertical" ], [ "matrix_transformations", "rotate_clockwise" ], [ "matrix_transformations", "rotate_counterclockwise" ], [ "matrix_transformations", "transpose" ] ]
5
[]
false
[]
false
pytest
true
[]
true
feb277d08a41ce791f96d65d5a9050fd0b0a6ebb
a08ab2bdd442daadabd9171ebf452e1f3a449795
v1.0
complete
Taco
Taco_96091_C
def min_path_sum(matrix): """ Returns the minimum path sum from the top-left cell to the bottom-right cell of the matrix. You can only move right or down from a cell. """ def solve_min_path_sum(test_cases): """ Solve the minimum path sum for each test case provided in test_cases. """ def p...
def min_path_sum(matrix): """ Returns the minimum path sum from the top-left cell to the bottom-right cell of the matrix. You can only move right or down from a cell. """ n = len(matrix) dp = [[0]*n for _ in range(n)] dp[0][0] = matrix[0][0] for i in range(1, n): dp[i][...
def test_parse_input(): input_str = "2\n2\n1 2\n3 4\n3\n1 2 3\n4 5 6\n7 8 9" expected_output = [ [ [1, 2], [3, 4] ], [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] ] assert parse_input(input_str) == expected_output def tes...
[ { "docstring": "Returns the minimum path sum from the top-left cell to the bottom-right cell of the matrix.\nYou can only move right or down from a cell.", "function_declaration": "def min_path_sum(matrix):", "function_name": "min_path_sum", "parameter_list": "(matrix)" }, { "docstring": nul...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_path_sum(matrix):\n N = len(matrix)\n if N == 0:\n return 0\n \n # Create a DP table\n dp = [[0] * N for _ in range(N)]\n \n # ...
trial_gpt4o_4
{ "original_instruction": "You are given a matrix of size N x N where each cell contains an integer weight. You are required to find the minimum weight path sum from the top-left cell to the bottom-right cell of the matrix. You can only move right or down from a cell.\n\nInput:\n- The first line contains an integer T...
0.58991
Taco_96091
C
[ "min_path_sum", "solve_min_path_sum", "parse_input", "min_path_sum_driver" ]
4
[ [ "min_path_sum_driver", "parse_input" ], [ "min_path_sum_driver", "solve_min_path_sum" ], [ "solve_min_path_sum", "min_path_sum" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
3f04ef0d3324aed2dcc9ce698a2362d66ee118b6
1814eda5cab527863b26f7ccba03e1dac6285d95
v1.0
complete
Taco
Taco_96138_C
def process(input_str: str) -> str: """ Find the shortest path from the top-left corner to the bottom-right corner of the grid for each dataset. Grid dimensions range from 2x2 to 100x100. Each cell can either be empty (.) or blocked (#). Args: input_str (str): The input string containing multiple ...
def shortest_path(grid, n, m): from collections import deque # Directions (right, left, down, up) directions = [(0, 1), (0, -1), (1, 0), (-1, 0)] queue = deque([(0, 0, 1)]) # (row, col, path_length) while queue: r, c, length = queue.popleft() if r == n - 1 and c == m - 1: ...
from solution import process def test_no_path(): input_data = "2 2\n.#\n#.\n0 0" expected_output = "No path" assert process(input_data) == expected_output def test_short_path(): input_data = "2 3\n..#\n#..\n0 0" expected_output = "4" assert process(input_data) == expected_output def test_mult...
[ { "docstring": null, "function_declaration": "def shortest_path(grid, n, m):", "function_name": "shortest_path", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_list": "(inp...
[ 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_shortest_path(grid, n, m):\n # Directions for moving in the grid (right, down, left, up)\n directions = [(0, 1), (1,...
trial_gpt4o_1
{ "original_instruction": "You are given a grid with dimensions n x m. Each cell in the grid can either be empty (represented by '.') or blocked (represented by '#'). Your task is to find the shortest path from the top-left corner of the grid (0, 0) to the bottom-right corner of the grid (n-1, m-1). You can move up, ...
0.59556
Taco_96138
C
[ "shortest_path", "parse_input", "process" ]
3
[ [ "process", "parse_input" ], [ "process", "shortest_path" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
41ae34eab92a87be0e2839366634976cf38bb69e
33f4df1d1fd41bf7bd1e34f09fb9ba51a9c92215
v1.0
complete
Taco
Taco_96276_C
def longest_subarray_length(arr, N, K): """ Returns the length of the longest subarray with sum less than or equal to K. >>> longest_subarray_length([1, 2, 3, 4, 5], 5, 10) 4 >>> longest_subarray_length([3, 1, 2, 1, 1, 1, 1, 1], 8, 15) 8 >>> longest_subarray_length([], 0, 10) 0 >>> longe...
def longest_subarray_length(arr, N, K): """ Returns the length of the longest subarray with sum less than or equal to K. """ max_len = 0 current_sum = 0 start = 0 for end in range(N): current_sum += arr[end] while current_sum > K: current_sum -= arr[...
import pytest from solution import longest_subarray_length, solve, process_input def test_longest_subarray_length(): assert longest_subarray_length([1, 2, 3, 4, 5], 5, 10) == 4 assert longest_subarray_length([3, 1, 2, 1, 1, 1, 1, 1], 8, 15) == 8 assert longest_subarray_length([], 0, 10) == 0 assert lon...
[ { "docstring": "Returns the length of the longest subarray with sum less than or equal to K.", "function_declaration": "def longest_subarray_length(arr, N, K):", "function_name": "longest_subarray_length", "parameter_list": "(arr, N, K)" }, { "docstring": null, "function_declaration": "d...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_subarray_with_sum_at_most_k(test_cases):\n results = []\n for n, k, arr in test_cases:\n current_sum = 0\n start = 0\n max_l...
trial_gpt4o_1
{ "original_instruction": "*Professor X has decided to test his students on their ability to manipulate arrays. He requires them to solve the following problem:*\n\nGiven an array of N integers and an integer K, determine the length of the longest subarray in which the sum of its elements is less than or equal to K.\...
0.675704
Taco_96276
C
[ "longest_subarray_length", "solve", "process_input" ]
3
[ [ "solve", "longest_subarray_length" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
bc20e7e05a37ade210b536d960dcbb660567134e
8901d38678bbe3ae5c0dc469c634be48a596fa6e
v1.0
complete
Taco
Taco_96167_C
from typing import List def largest_k_divisible(nums: List[int]) -> int: """ Write a function that takes a list of integers as input and returns the largest integer `k` such that all integers in the list are divisible by `k` and `k` is greater than 1. >>> largest_k_divisible([4, 8, 16, 32]) 4 ...
import math from functools import reduce def gcd(a, b): """ Calculates the greatest common divisor of a and b. """ while b: a, b = b, a % b return a def gcd_of_list(numbers): """ Calculates the greatest common divisor (gcd) of a list of numbers. """ return reduce(gcd, numbe...
from solution import largest_k_divisible def test_all_multiples(): assert largest_k_divisible([4, 8, 16, 32]) == 4 def test_common_multiple(): assert largest_k_divisible([5, 10, 15, 20]) == 5 def test_no_common_divisor_greater_than_one(): assert largest_k_divisible([7, 11, 13, 17]) == -1 def test_all_pr...
[ { "docstring": "Calculates the greatest common divisor of a and b.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Calculates the greatest common divisor (gcd) of a list of numbers.", "function_declaration": "def gcd_of_li...
[ 1, 1 ]
2
easy
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 largest_divisor(arr):\n \"\"\"\n Returns the largest integer k such that all integers in the list are divisi...
trial_gpt4o_2
{ "original_instruction": "Write a function that takes a list of integers as input and returns the largest integer `k` such that all integers in the list are divisible by `k` and `k` is greater than 1.\n\n------ Input ------\nA single line containing space-separated integers.\n\n------ Output ------\nPrint a single...
0.748398
Taco_96167
C
[ "gcd", "gcd_of_list", "largest_k_divisible" ]
3
[ [ "gcd_of_list", "gcd" ], [ "largest_k_divisible", "gcd_of_list" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0c0be01d9def34dbc9b38e119a492cbf1a1d6327
fa2d242d1f8498e413b4c360acaebcd44bcb171a
v1.0
complete
Taco
Taco_96397_C
from typing import List, Tuple def minimal_cost_to_connect_all_cities(n: int, m: int, roads: List[Tuple[int, int, int]]) -> int: """ Calculates the minimal possible total cost to connect all the cities with King's Network. Parameters: n (int): Number of cities. m (int): Number of roads. roads ...
def find(parent, i): if parent[i] != i: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent...
from solution import minimal_cost_to_connect_all_cities def test_example1(): n = 4 m = 5 roads = [ (1, 2, 3), (1, 3, 1), (3, 2, 2), (2, 4, 4), (3, 4, 5) ] assert minimal_cost_to_connect_all_cities(n, m, roads) == 7 def test_example2(): n = 3 m = 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 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(paren...
trial_gpt4o_4
{ "original_instruction": "In a distant land, there is a kingdom called CoderLand. In CoderLand, there are n cities connected by m bidirectional roads. Each road has an associated cost. The cities are numbered from 1 to n, and they desperately need a reliable transportation system for their growing economy.\n\nThe Ki...
0.641036
Taco_96397
C
[ "find", "union", "kruskal", "minimal_cost_to_connect_all_cities" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimal_cost_to_connect_all_cities", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
9901dceb088b08b6eb43809318e3f3e4bfb873df
c35abf002c1744f1ed099a3920f52fe9a4310cdc
v1.0
complete
Taco
Taco_96388_C
def compare(a, b): """ Custom comparison function to sort the numbers in the desired order. """ if a + b > b + a: return -1 elif a + b < b + a: return 1 else: return 0 def largest_number(numbers): """ Arrange numbers to form the largest possible value when concatenated. ...
from functools import cmp_to_key def compare(a, b): if a + b > b + a: return -1 elif a + b < b + a: return 1 else: return 0 def largest_number(numbers): numbers = list(map(str, numbers)) numbers.sort(key=cmp_to_key(compare)) largest_num = ''.join(numbers) return lar...
from solution import process_test_cases def test_sample_input(): T = 3 test_cases = [ (3, [10, 2, 9]), (4, [3, 30, 34, 5]), (2, [12, 121]) ] expected_output = [ '9210', '534330', '12121' ] assert process_test_cases(T, test_cases) == expected_outpu...
[ { "docstring": null, "function_declaration": "def compare(a, b):", "function_name": "compare", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def largest_number(numbers):", "function_name": "largest_number", "parameter_list": "(numbers)" }, { ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_number(numbers):\n \"\"\"\n Given a list of integers, this function forms the largest possible number \n by concatenating the integers togethe...
trial_gpt4o_2
{ "original_instruction": "In a distant kingdom, there is a unique numerical system used for communicating emergencies. The system consists of N numbers, and they need to be processed by a special machine for sending alerts. The system has certain rules for combining these numbers optimally to form the largest possib...
0.686042
Taco_96388
C
[ "compare", "largest_number", "process_test_cases" ]
3
[ [ "largest_number", "compare" ], [ "process_test_cases", "largest_number" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
0ef6fe274f1ed890b07f513a46581f808b81065f
25734cf9a37777e383ad4d89231bf7babf35fad0
v1.0
complete
Taco
Taco_96643_C
def sieve_of_eratosthenes(n: int) -> List[int]: """ Implements the Sieve of Eratosthenes algorithm to find all prime numbers less than n. >>> sieve_of_eratosthenes(10) == [2, 3, 5, 7] >>> sieve_of_eratosthenes(2) == [] >>> sieve_of_eratosthenes(11) == [2, 3, 5, 7] """ def sum_of_primes_last_fou...
def sieve_of_eratosthenes(n): """ Implements the Sieve of Eratosthenes algorithm to find all prime numbers less than n. """ is_prime = [True] * n p = 2 while p * p < n: if is_prime[p]: for i in range(p * p, n, p): is_prime[i] = False p += 1 primes ...
from solution import sieve_of_eratosthenes, sum_of_primes_last_four_digits def test_sieve_of_eratosthenes(): assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] assert sieve_of_eratosthenes(2) == [] assert sieve_of_eratosthenes(11) == [2, 3, 5, 7] def test_sum_of_primes_last_four_digits(): assert sum_of_...
[ { "docstring": "Implements the Sieve of Eratosthenes algorithm to find all prime numbers less than n.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Calculates the sum of all primes less than n a...
[ 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 sum_of_last_four_digits_primes(n):\n \"\"\"\n Returns the last four digits of the sum of all prime numbers less than n.\n \"\"\"\n if n < 2:\n ...
trial_gpt4o_2
{ "original_instruction": "Create a function that generates a list of all prime numbers under a given number N using the Sieve of Eratosthenes algorithm and then find the sum of these prime numbers. Provide the last 4 digits of this sum.\n\nInput Format\nA single line containing an integer N.\n2 ≤ N ≤ 10^6\n\nOutput ...
0.663064
Taco_96643
C
[ "sieve_of_eratosthenes", "sum_of_primes_last_four_digits" ]
2
[ [ "sum_of_primes_last_four_digits", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5f8cabb6e69329d10a9505dc4c1ac9280b58e2f9
2833f92e21aa24682109b47c874fd66b3232ef15
v1.0
complete
Taco
Taco_96860_C
def count_palindromic_partitions(s: str) -> int: """ Given a string consisting of lowercase English letters, find out the number of ways to partition the string into contiguous substrings such that each substring is a palindrome. The result should be returned modulo 10^9 + 7. >>> count_palindromic_partitions("a...
MOD = 10**9 + 7 def is_palindrome(s): return s == s[::-1] def count_palindromic_partitions(s): n = len(s) dp = [0] * (n + 1) dp[0] = 1 for i in range(1, n + 1): for j in range(i): if is_palindrome(s[j:i]): dp[i] = (dp[i] + dp[j]) % MOD return dp[n]
from solution import count_palindromic_partitions def test_single_character(): assert count_palindromic_partitions("a") == 1 def test_two_same_characters(): assert count_palindromic_partitions("aa") == 2 def test_two_different_characters(): assert count_palindromic_partitions("ab") == 1 def test_example...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def count_palindromic_partitions(s):", "function_name": "count_palindromic_partitions", "parameter_list...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 10**9 + 7\n\ndef count_palindromic_partitions(s):\n n = len(s)\n \n # Dynamic programming table to store palindromic substrings\n dp = [[False] *...
trial_gpt4o_4
{ "original_instruction": "Given a string consisting of lowercase English letters, your task is to find out the number of ways to partition the string into contiguous substrings such that each substring is a palindrome. Since the number of ways can be large, return the result modulo $10^9 + 7$.\n\n------ Input ------...
0.734644
Taco_96860
C
[ "is_palindrome", "count_palindromic_partitions" ]
2
[ [ "count_palindromic_partitions", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b377da3921208af47f4355fd2cfeee6d9ae351c3
7cb23fbecf04b2a02c80ab73d06c6f2f48895926
v1.0
complete
Taco
Taco_96885_C
def max_non_overlapping_jobs(jobs): """ Determines the maximum number of non-overlapping jobs. >>> max_non_overlapping_jobs([(1, 3), (2, 4), (3, 5), (4, 6)]) 2 >>> max_non_overlapping_jobs([(1, 5), (2, 6), (6, 8), (4, 7), (5, 9), (8, 10)]) 3 """ def process_jobs_input(job_input): """ ...
def max_non_overlapping_jobs(jobs): """ Determines the maximum number of non-overlapping jobs. """ # Sort jobs by their end time jobs.sort(key=lambda job: job[1]) # Initialize count of non-overlapping jobs count = 0 last_end_time = 0 for job in jobs: start, end = jo...
from solution import process_jobs_input, max_non_overlapping_jobs def test_example_1(): job_input = [ 4, (1, 3), (2, 4), (3, 5), (4, 6) ] assert process_jobs_input(job_input) == 2 def test_example_2(): job_input = [ 6, (1, 5), (2, 6), ...
[ { "docstring": "Determines the maximum number of non-overlapping jobs.", "function_declaration": "def max_non_overlapping_jobs(jobs):", "function_name": "max_non_overlapping_jobs", "parameter_list": "(jobs)" }, { "docstring": "Processes input list into a format suitable for the max_non_overl...
[ 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_non_overlapping_jobs(jobs):\n \"\"\"\n Returns the maximum number of non-overlapping jobs from the given list of jobs.\n \"\"\"\n # Sort jobs b...
trial_gpt4o_1
{ "original_instruction": "You are given a list of jobs, each defined by a start time and an end time. Your goal is to determine the maximum number of non-overlapping jobs that can be scheduled.\n\nA job is represented by a pair of integers $(S, E)$, where $S$ is the start time and $E$ is the end time $(1 \\le S < E ...
0.570678
Taco_96885
C
[ "max_non_overlapping_jobs", "process_jobs_input" ]
2
[ [ "process_jobs_input", "max_non_overlapping_jobs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6415a86a812e415ee1734d7ac4a448b7b16e847f
17f2543ffe63cfab20420b413aba965f3fbc0a96
v1.0
complete
Taco
Taco_96660_C
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def build_tree(nodes): """ Build a binary tree from a given list of nodes in the format: [(node, left_child, right_child), ...] Nodes are given in level ord...
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def build_tree(nodes): if not nodes: return None node_map = {val: TreeNode(val) for val, _, _ in nodes if val != -1} for parent, left, right in...
from solution import TreeNode, build_tree, unique_traversal, process_test_cases, solution def test_build_tree(): nodes = [(1, 2, 3), (2, -1, -1), (3, 4, 5), (4, -1, -1), (5, -1, -1)] root = build_tree(nodes) assert root.value == 1 assert root.left.value == 2 assert root.right.value == 3 assert ...
[]
[ 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": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef build_tree(node_info):\n if not no...
trial_gpt4o_8
{ "original_instruction": "**Problem Statement:**\n\nShivam is learning about binary trees and traversal techniques. To test his understanding, his instructor gives him a binary tree and asks him to perform a unique traversal. The traversal to be performed is a combination of preorder and inorder traversal.\n\nHe has...
0.582455
Taco_96660
C
[ "build_tree", "unique_traversal", "process_test_cases", "solution" ]
4
[ [ "process_test_cases", "build_tree" ], [ "process_test_cases", "unique_traversal" ], [ "solution", "process_test_cases" ] ]
3
[ "process_test_cases" ]
false
[ "TreeNode" ]
true
pytest
true
[]
true
9d52e2e118c1147aa1cce08a86461d53c406faf3
3b133349f51ffad4389fd98842e055b1ae499306
v1.0
complete
Taco
Taco_96532_C
def can_escape_dungeon(N, levels, M, moves): """ Determine if the adventurers can find a path to the exit. Each dataset has the following format: - N: number of levels in the dungeon. - levels: a list of tuples, each containing: - R, C: dimensions of the grid. - grid_line...
from collections import deque def parse_input(): dungeons = [] while True: N = int(input()) if N == 0: break levels = [] for _ in range(N): R, C = map(int, input().split()) grid = [input().strip() for _ in range(R)] levels.append((...
def test_single_level_move_right(): result = can_escape_dungeon( 1, [(3, 3, ["S..", ".#.", "..E"])], 3, [("R", 2), ("D", 2)] ) assert result == "YES" def test_multiple_levels_no_exit(): result = can_escape_dungeon( 2, [ (3, 3, ["S..", ".#U",...
[ { "docstring": null, "function_declaration": "def parse_input():", "function_name": "parse_input", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def find_start_exit(level):", "function_name": "find_start_exit", "parameter_list": "(level)" }, { "d...
[ 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 can_explore_dungeon(dungeons):\n def valid_cell(level, row, col):\n return 0 <= level < len(dungeons) and 0 <= row < len(dungeons[level]) and 0 <= co...
trial_gpt4o_1
{ "original_instruction": "A group of adventurers have ventured into a multi-leveled dungeon. Each level of the dungeon is represented as a grid of cells that can either be an empty cell, a wall, a staircase up, or a staircase down. The adventurers move through the dungeon following a set of given directions.\n\nThe ...
0.660523
Taco_96532
C
[ "parse_input", "find_start_exit", "move_adventurers", "can_escape_dungeon", "main" ]
5
[ [ "can_escape_dungeon", "find_start_exit" ], [ "can_escape_dungeon", "move_adventurers" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
41a77f3c12bdbedf737ad8c870d5931a68dab101
65e7f4bb5e842585ec13656d20c1d5f32f984ed0
v1.0
complete
Taco
Taco_96928_C
def unique_paths(grid): """ Calculate the number of unique paths from top-left corner to bottom-right corner in a grid. Obstacles are represented by 1, and walkable cells are represented by 0. Args: grid (List[List[int]]): A 2D list representing the grid. Returns: int: Number of unique pat...
def unique_paths(grid): n = len(grid) m = len(grid[0]) if grid[0][0] == 1 or grid[n-1][m-1] == 1: return 0 dp = [[0] * m for _ in range(n)] dp[0][0] = 1 for i in range(n): for j in range(m): if grid[i][j] == 1: dp[i][j] = 0 else: ...
from solution import forest_paths def test_sample_case_1(): data = [ "2", "3 3", "0 0 0", "0 1 0", "0 0 0", "2 2", "0 1", "1 0" ] assert forest_paths(data) == [2, 0] def test_no_path(): data = [ "1", "3 3", "0 1 0"...
[ { "docstring": null, "function_declaration": "def unique_paths(grid):", "function_name": "unique_paths", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def process_input_output(data):", "function_name": "process_input_output", "parameter_list": "(data...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def unique_paths_with_obstacles(grid):\n if not grid or grid[0][0] == 1:\n return 0\n \n n, m = len(grid), len(grid[0])\n dp = [[0] * m for _ in...
trial_gpt4o_2
{ "original_instruction": "Ravi is a forest guard and he has to patrol a rectangular grid-shaped forest. The forest is divided into cells, some of which may have obstacles (trees, rocks, etc.). Ravi starts his patrol from the top-left corner (0, 0) and aims to reach the bottom-right corner (n-1, m-1).\n\nRavi can onl...
0.600988
Taco_96928
C
[ "unique_paths", "process_input_output", "forest_paths" ]
3
[ [ "forest_paths", "process_input_output" ], [ "process_input_output", "unique_paths" ] ]
2
[ "process_input_output" ]
false
[]
false
pytest
true
[]
true
81e8eb0c207d3a486d90d4ed77581c5c913c53e6
b8fcb706d406555f01bdf0974c7a4af08d7beaaf
v1.0
complete
Taco
Taco_96506_C
from typing import List, Tuple def kruskal_mst(n: int, edges: List[Tuple[int, int, int]]) -> int: """ Calculate the minimum cost of constructing roads such that each pair of towns has one unique minimum cost path. Args: n (int): The number of towns. edges (List[Tuple[int, int, int]]): The list of ...
def kruskal_mst(n, edges): 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[xr...
def test_kruskal_mst(): test_cases = [ (4, 5, [(1, 2, 2), (1, 3, 5), (2, 3, 7), (2, 4, 8), (3, 4, 3)]), (4, 4, [(1, 2, 1), (2, 3, 1), (3, 4, 1), (1, 3, 2)]), (3, 3, [(1, 2, 4), (2, 3, 4), (1, 3, 2)]), (4, 5, [(1, 2, 3), (1, 3, 4), (1, 4, 5), (2, 3, 6), (3, 4, 7)]), (4, 0, [])...
[ { "docstring": null, "function_declaration": "def kruskal_mst(n, edges):", "function_name": "kruskal_mst", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def min_unique_path_costs(test_cases):", "function_name": "min_unique_path_costs", "parameter...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def minimum_unique_path_cost(n, m, edges):\n # Implementing Kruskal's Algorithm with Union-Find to find Minimum Spanning Tree (MST)\n ...
trial_gpt4o_2
{ "original_instruction": "In a certain kingdom, there are multiple towns connected by bidirectional roads. Each road has a travel cost associated with it. The kingdom has decided to implement a new policy for constructing roads to ensure that there is exactly one unique way to travel between any two towns following ...
0.66195
Taco_96506
C
[ "kruskal_mst", "min_unique_path_costs" ]
2
[ [ "min_unique_path_costs", "kruskal_mst" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1407bd1909704529464b62e103fa025ddf2c84ac
18eb364ef9bb8c9d0c362ab5c9fb837819aa0860
v1.0
complete
Taco
Taco_96944_C
from typing import List def is_prime(num: int) -> bool: """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...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return F...
from solution import nearest_prime def test_nearest_prime(): assert nearest_prime(10) == 11 assert nearest_prime(14) == 13 assert nearest_prime(30) == 29 assert nearest_prime(34) == 31 assert nearest_prime(1) == 2 assert nearest_prime(2) == 2 assert nearest_prime(3) == 3 def test_large_num...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the nearest prime number to n.\nIf there are two prime numbers equally close to n, returns the smal...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n r...
trial_gpt4o_0
{ "original_instruction": "#### Task:\n\nYour job is to implement a method `nearest_prime` in Ruby/Python/Crystal and `nearestPrime` in JavaScript/CoffeeScript, that takes one argument, `n`, and returns the nearest prime number to `n`. If there are two prime numbers equally close to `n`, return the smaller one.\n\n1....
0.812639
Taco_96944
C
[ "is_prime", "nearest_prime" ]
2
[ [ "nearest_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f418240187a4f9b8323182e0c527e0330c677ad6
240d28819c6ac529b199cc8c3c2cf7dce98b5e32
v1.0
complete
Taco
Taco_96902_C
def check_modified_palindromes(t: int, strings: List[str]) -> List[str]: """ For each string, determine if it can be a modified palindrome. >>> check_modified_palindromes(3, ['abca', 'racecar', 'hello']) ['YES', 'YES', 'NO'] >>> check_modified_palindromes(1, ['a']) ['YES'] >>> check_modified_pal...
def is_palindrome(s): return s == s[::-1] def is_modified_palindrome(s): left, right = 0, len(s) - 1 while left < right: if s[left] != s[right]: s_without_left = s[:left] + s[left + 1:] s_without_right = s[:right] + s[right + 1:] return is_palindrome(s_witho...
from solution import check_modified_palindromes def test_basic_cases(): assert check_modified_palindromes(3, ['abca', 'racecar', 'hello']) == ['YES', 'YES', 'NO'] def test_single_character(): assert check_modified_palindromes(1, ['a']) == ['YES'] def test_two_characters(): assert check_modified_palindr...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def is_modified_palindrome(s):", "function_name": "is_modified_palindrome", "parameter_list": "(s)" }...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_modified_palindrome(s):\n \"\"\"\n Checks if the given string can be a modified palindrome by removing at most one character.\n \"\"\"\n def is_...
trial_gpt4o_2
{ "original_instruction": "A palindrome is a string that reads the same forwards and backwards. However, due to potential typographical errors or variations in input, a modified palindrome is defined as a string where at most one character can be removed to make it a palindrome. For example, \"abca\" can become \"aca...
0.753654
Taco_96902
C
[ "is_palindrome", "is_modified_palindrome", "check_modified_palindromes" ]
3
[ [ "check_modified_palindromes", "is_modified_palindrome" ], [ "is_modified_palindrome", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
914c030f9dd4aaff33dbbdd0025d02b7d156cc75
c50270c177f632bf148c59707259dc6707beda7e
v1.0
complete
Taco
Taco_96647_C
def is_special_pattern_possible(grid, R, C): """ Determine if it is possible to transform the grid into a special pattern. A special pattern is a configuration where no two adjacent cells (horizontally or vertically) have the same value (i.e., it forms a checkerboard pattern). """ pass def solv...
def is_special_pattern_possible(grid, R, C): """ Determine if the grid can be transformed into the special pattern. A special pattern is a checkerboard pattern where no two adjacent cells have the same value. """ pattern1 = [[(r+c) % 2 for c in range(C)] for r in range(R)] pattern2 = [[(r+c+1) %...
def test_is_special_pattern_possible(): assert is_special_pattern_possible([[0, 1], [1, 0]], 2, 2) == True assert is_special_pattern_possible([[1, 1], [1, 0], [0, 1]], 3, 2) == False assert is_special_pattern_possible([[1, 0, 1], [0, 1, 0]], 2, 3) == True def test_solve_grids(): grids = [ (2, 2...
[ { "docstring": "Determine if the grid can be transformed into the special pattern.\nA special pattern is a checkerboard pattern where no two adjacent cells have the same value.", "function_declaration": "def is_special_pattern_possible(grid, R, C):", "function_name": "is_special_pattern_possible", "...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_transform_to_special_pattern(grids):\n results = []\n for grid in grids:\n R, C, matrix = grid\n pattern1 = [[(i + j) % 2 for j in rang...
trial_gpt4o_2
{ "original_instruction": "You are given a grid with R rows and C columns, where each cell has either a 0 or 1. The player can toggle any number of cells (change a cell from 0 to 1 or from 1 to 0) to form a special pattern. The special pattern is defined as a grid configuration in which no two adjacent cells (horizon...
0.624338
Taco_96647
C
[ "is_special_pattern_possible", "solve_grids", "parse_input", "main" ]
4
[ [ "solve_grids", "is_special_pattern_possible" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
0f0fb611d6449fee93a5fe9601b7b9a74125ecd7
18638a3119d9f35689ff3f3d7f5d328d63f4b55a
v1.0
complete
Taco
Taco_97070_C
def generate_spiral(n): """ Generate a n x n grid numbered in spiral order. Args: n (int): Size of the grid. Returns: List[List[int]]: The n x n grid numbered in spiral order. """ def find_position(n, num): """ Find the position (row, col) of a given number in the spi...
def generate_spiral(n): spiral = [[0] * n for _ in range(n)] left, right = 0, n - 1 top, bottom = 0, n - 1 num = 1 while left <= right and top <= bottom: for i in range(left, right + 1): spiral[top][i] = num num += 1 top += 1 for i in range(top, bott...
def test_generate_spiral(): expected_5x5 = [ [1, 2, 3, 4, 5], [16, 17, 18, 19, 6], [15, 24, 25, 20, 7], [14, 23, 22, 21, 8], [13, 12, 11, 10, 9] ] assert generate_spiral(5) == expected_5x5 def test_find_position(): assert find_position(5, 1) == (0, 0) assert ...
[ { "docstring": null, "function_declaration": "def generate_spiral(n):", "function_name": "generate_spiral", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def find_position(n, num):", "function_name": "find_position", "parameter_list": "(n, num)" }, ...
[ 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_rook_move(n, test_cases):\n \"\"\"\n Determines if a rook can move from position i to position j on an n x n spiral grid.\n\n Parameters:\n n (...
trial_gpt4o_2
{ "original_instruction": "Alice is playing a game on a $n \\times n$ grid, where $n$ is an odd integer. The grid cells are numbered from $1$ to $n^2$ in a spiral order. Starting from the top-left corner and moving inwards in a clockwise direction, the numbering proceeds until reaching the center of the grid.\n\nAlic...
0.605384
Taco_97070
C
[ "generate_spiral", "find_position", "can_rook_move", "rook_moves" ]
4
[ [ "can_rook_move", "find_position" ], [ "find_position", "generate_spiral" ], [ "rook_moves", "can_rook_move" ] ]
3
[]
false
[]
false
pytest
false
[]
true
6bb35fb6149f3ec6a23a2dd5b74312b3986d72f2
83f31a08d8a3a6201161ea7a3d373a36412b9c1d
v1.0
complete
Taco
Taco_96907_C
def minimal_highway_cost(n: int, m: int, highways: List[Tuple[int, int, int]]) -> int: """ Calculate the minimal total cost to construct the highways so that all stations are connected. >>> minimal_highway_cost(4, 5, [(1, 2, 5), (1, 3, 3), (4, 1, 6), (2, 4, 7), (3, 4, 4)]) 12 >>> minimal_highway_cost(4,...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank...
import pytest from solution import minimal_highway_cost def test_minimal_highway_cost_example(): n = 4 m = 5 highways = [ (1, 2, 5), (1, 3, 3), (4, 1, 6), (2, 4, 7), (3, 4, 4) ] assert minimal_highway_cost(n, m, highways) == 12 def test_minimal_highway_cost_...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 0, 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": "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 x_root =...
trial_gpt4o_5
{ "original_instruction": "The year is 3030 and space exploration has reached its peak. The Galactic Council has decided to create a space highway system connecting various space stations scattered across the galaxy. The Council's objective is to ensure that every space station is reachable from any other space stati...
0.668228
Taco_96907
C
[ "find", "union", "kruskal_mst", "minimal_highway_cost" ]
4
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "minimal_highway_cost", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
5c931f730e65661ea77f05b7b37514ce6c0d1bfe
b14c851dde35780c320a5e85acb9ed39e54866c0
v1.0
complete
Taco
Taco_96903_C
from typing import List def max_subgrid_sum(grid: List[List[int]]) -> int: """ Calculate the maximum sum of any subgrid in a given 2D grid. """ pass def max_subarray_sum(arr: List[int]) -> int: """ Calculate the maximum sum of any subarray using the Kadane's algorithm. """ pass def pr...
def max_subgrid_sum(grid): """ This function calculates the maximum sum of any subgrid in a given 2D grid. """ N = len(grid) M = len(grid[0]) max_sum = float('-inf') for left in range(M): temp = [0] * N for right in range(left, M): for i in rang...
import pytest from solution import max_subgrid_sum, max_subarray_sum, process_test_cases, parse_input def test_max_subgrid_sum(): grid = [ [1, 2], [-1, -3] ] assert max_subgrid_sum(grid) == 3 grid = [ [1, -2, 3], [4, 5, -6], [-7, 8, 9] ] assert max_subgr...
[ { "docstring": "This function calculates the maximum sum of any subgrid in a given 2D grid.", "function_declaration": "def max_subgrid_sum(grid):", "function_name": "max_subgrid_sum", "parameter_list": "(grid)" }, { "docstring": "Helper function to calculate the maximum sum of any subarray u...
[ 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 find_max_sum_subgrid(grid):\n def compute_kadane(arr):\n max_sum = float('-inf')\n current_sum = 0\n for num in arr:\n curre...
trial_gpt4o_4
{ "original_instruction": "You are given a grid of size N x M with each cell containing a number. You need to find the largest sum of numbers from any subgrid. A subgrid is defined as any rectangular part of the grid including any cell, all cells in one row, or all cells in the entire grid.\n\nInput Format:\nFirst li...
0.584937
Taco_96903
C
[ "max_subgrid_sum", "max_subarray_sum", "process_test_cases", "parse_input", "main" ]
5
[ [ "max_subgrid_sum", "max_subarray_sum" ], [ "process_test_cases", "max_subgrid_sum" ] ]
2
[ "process_test_cases", "parse_input" ]
false
[]
false
pytest
true
[]
true
e8df13834d7ef83bbd86f58ab109f0f76d32ed18
9f690154f150ddecad94993cb7a82e70b714c67a
v1.0
complete
Taco
Taco_96888_C
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent[root_y] = ro...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent[root_y] = ro...
import io import sys from solution import minimum_spanning_tree def test_example_case(): input_data = """4 5 1 2 1 2 3 4 3 4 5 4 1 6 1 3 3""" expected_output = 9 captured_output = io.StringIO() sys.stdin = io.StringIO(input_data) sys.stdout = captured_output import solution solution.main()...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(paren...
trial_gpt4o_9
{ "original_instruction": "You are given a forest represented as an undirected graph with N nodes (1 through N) and M edges. Each node in the graph represents a tree, and each edge represents a path between two trees. Each path has a weight associated with it representing the difficulty of traversing that path. \n\nY...
0.680748
Taco_96888
C
[ "find", "union", "minimum_spanning_tree", "main" ]
4
[ [ "minimum_spanning_tree", "find" ], [ "minimum_spanning_tree", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
7b3bef90d5f259bb8609f1f033b535e0833787d9
c71d2fcbdb160da2bcc72fe248c618abb83fb1bc
v1.0
complete
Taco
Taco_97300_C
import math from typing import List, Tuple def calculate_distance(tower1: Tuple[int, int], tower2: Tuple[int, int]) -> float: """ Function to calculate the Euclidean distance between two towers. >>> calculate_distance((0, 0), (0, 2)) 2.0 >>> calculate_distance((0, 0), (3, 4)) 5.0 >>> calcul...
import math def calculate_distance(tower1, tower2): """ Function to calculate the Euclidean distance between two towers. """ return math.sqrt((tower1[0] - tower2[0]) ** 2 + (tower1[1] - tower2[1]) ** 2) def min_max_distance(tower_coords): """ Function to find the minimum value of the maximum d...
def test_calculate_distance(): assert math.isclose(calculate_distance((0, 0), (0, 2)), 2.0, rel_tol=1e-9) assert math.isclose(calculate_distance((0, 0), (3, 4)), 5.0, rel_tol=1e-9) assert math.isclose(calculate_distance((2, 2), (5, 6)), 5.0, rel_tol=1e-9) def test_min_max_distance_example1(): assert mi...
[ { "docstring": "Function to calculate the Euclidean distance between two towers.", "function_declaration": "def calculate_distance(tower1, tower2):", "function_name": "calculate_distance", "parameter_list": "(tower1, tower2)" }, { "docstring": "Function to find the minimum value of the maxim...
[ 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": "import math\n\ndef distance(p1, p2):\n return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)\n\ndef find(parent, i):\n if parent[i] == i:\n re...
trial_gpt4o_1
{ "original_instruction": "The town of Algorithmsville has recently decided to build a network of communication towers to improve connectivity. Each tower can communicate with another tower if they are within a certain distance. The plan is to ensure that every pair of towers can communicate either directly or indire...
0.534797
Taco_97300
C
[ "calculate_distance", "min_max_distance", "main" ]
3
[ [ "min_max_distance", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2e1f0cea33eddf8d579283d9a419668f9e628f6b
a3ce2e062ace90dc741a3c1f18ebe0a5794476c3
v1.0
complete
Taco
Taco_97450_C
from typing import List def find_min_absolute_difference(n: int, array: List[int]) -> int: """ This function takes the number of elements in the array and the array itself, and returns the minimum absolute difference between the sum of two non-empty partitions of the array. >>> find_min_absolute_diffe...
def min_diff_partition(arr): """ This function takes a list of integers and returns the minimum absolute difference between the sum of two non-empty partitions of the array. """ total_sum = sum(arr) n = len(arr) # To find the subset with sum closest to total_sum / 2 dp = [0] * (tota...
from solution import find_min_absolute_difference def test_min_diff_partition_example_1(): assert find_min_absolute_difference(4, [3, 1, 4, 2]) == 0 def test_min_diff_partition_example_2(): assert find_min_absolute_difference(5, [1, 2, 3, 4, 5]) == 1 def test_min_diff_partition_single_element(): # As per...
[ { "docstring": "This function takes a list of integers and returns the minimum absolute difference\nbetween the sum of two non-empty partitions of the array.", "function_declaration": "def min_diff_partition(arr):", "function_name": "min_diff_partition", "parameter_list": "(arr)" }, { "docst...
[ 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 min_diff_partition(arr):\n \"\"\"\n This function takes a list of integers and returns the minimum absolute difference\n between the sum of two non-em...
trial_gpt4o_0
{ "original_instruction": "You are given an array of `n` integers. Divide this array into two non-empty parts such that the sum of the elements in the first part and the sum of the elements in the second part are as close as possible.\n\n-----Input-----\n\nThe first line of the input contains an integer `n` (2 ≤ n ≤ ...
0.795277
Taco_97450
C
[ "min_diff_partition", "find_min_absolute_difference" ]
2
[ [ "find_min_absolute_difference", "min_diff_partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c9dbd1feb2dc03a35d8e375ca5e807da7fa121ef
e355d44066cc5975f60c2c01c8daf4f7fdb15434
v1.0
complete
Taco
Taco_96986_C
def min_energy_to_exit(N, M, E, maze): """ Calculate the minimum energy required for Alice to reach the exit point in the maze. Args: N (int): Number of rows in the maze. M (int): Number of columns in the maze. E (int): Initial energy Alice has. maze (List[str]): The maze grid with 'S', 'E'...
from collections import deque def min_energy_to_exit(N, M, E, maze): def is_within_bounds(x, y): return 0 <= x < N and 0 <= y < M # Locate the start (S) and end (E) points start = end = None for i in range(N): for j in range(M): if maze[i][j] == 'S': start =...
def test_case_1(): maze_input = [ "4 4 10", "S..#", ".#.#", ".#.E", "...." ] solve(maze_input) def test_case_2(): maze_input = [ "3 3 2", "S#.", ".#E", "###" ] solve(maze_input) def test_case_3(): maze_input = [ ...
[ { "docstring": null, "function_declaration": "def min_energy_to_exit(N, M, E, maze):", "function_name": "min_energy_to_exit", "parameter_list": "(N, M, E, maze)" }, { "docstring": null, "function_declaration": "def solve(maze_input):", "function_name": "solve", "parameter_list": ...
[ 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_energy_to_exit(maze, N, M, E):\n \"\"\"\n Returns the minimum energy required to reach the exit or -1 if it's imposs...
trial_gpt4o_3
{ "original_instruction": "Alice is trapped in a maze of size N x M with various obstacles. The maze is described as a grid where each cell has one of the following values:\n\n- `S`: The starting point (Alice's current position).\n- `E`: The exit point.\n- `.`: An empty cell Alice can move to.\n- `#`: An obstacle tha...
0.619672
Taco_96986
C
[ "min_energy_to_exit", "solve" ]
2
[ [ "solve", "min_energy_to_exit" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4d9f7c480e09d41ad9e86513aec391f674db7560
46b9275d598768e4d6af02acfb6a4cb45e94f3e9
v1.0
complete
Taco
Taco_96840_C
from typing import List def min_stores(matrix: List[List[int]], requirements: List[int]) -> int: """ Given a 2D matrix representing the availability of items in various stores, and a requirement list specifying the quantity of each type of item needed, find the minimum number of stores that must be visite...
from itertools import combinations def can_fulfill_requirements(matrix, requirements, selected_stores): item_count = [0] * len(requirements) for store in selected_stores: for j in range(len(requirements)): item_count[j] += matrix[store][j] for i in range(len(requirements)): ...
from solution import min_stores def test_example_0(): matrix = [ [2, 0, 1], [1, 3, 1], [0, 3, 4] ] requirements = [1, 4, 2] assert min_stores(matrix, requirements) == 2 def test_example_1(): matrix = [ [2, 1, 1], [0, 0, 2], [3, 1, 1] ] requir...
[ { "docstring": null, "function_declaration": "def can_fulfill_requirements(matrix, requirements, selected_stores):", "function_name": "can_fulfill_requirements", "parameter_list": "(matrix, requirements, selected_stores)" }, { "docstring": null, "function_declaration": "def min_stores(ma...
[ 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 itertools import combinations\n\ndef min_stores(matrix, requirements):\n n = len(matrix)\n m = len(matrix[0])\n \n # Check all combinations of sto...
trial_gpt4o_2
{ "original_instruction": "Given a 2D matrix representing the availability of items in various stores, and a requirement list specifying the quantity of each type of item needed, find the minimum number of stores that must be visited to fulfill the requirement list. You do not need to buy all items from each store, o...
0.572005
Taco_96840
C
[ "can_fulfill_requirements", "min_stores" ]
2
[ [ "min_stores", "can_fulfill_requirements" ] ]
1
[]
false
[]
false
pytest
true
[]
true
353529f984dc2ab76c55416209521bb2e56e7449
b3441df884001f9f63062f4e8d33567ff2954df3
v1.0
complete
Taco
Taco_97587_C
from typing import List def maximum_extractions(s: str, target_words: List[str]) -> int: """ Given a string consisting of lowercase English letters and a list of target words, return the maximum number of times all the target words can be simultaneously extracted from the given string while maintaining...
from collections import Counter def can_extract(s, target_words): """ Checks if all target words can be extracted simultaneously from string s and returns how many times this extraction is possible. """ s_counter = Counter(s) target_counters = [Counter(word) for word in target_words] min_e...
from solution import maximum_extractions def test_basic_case(): s = "abacabacaba" target_words = ["ab", "ca", "ac"] assert maximum_extractions(s, target_words) == 2 def test_no_extractions_possible(): s = "abcdef" target_words = ["gh", "ij", "kl"] assert maximum_extractions(s, target_words) ==...
[ { "docstring": "Checks if all target words can be extracted simultaneously from string s\nand returns how many times this extraction is possible.", "function_declaration": "def can_extract(s, target_words):", "function_name": "can_extract", "parameter_list": "(s, target_words)" }, { "docstri...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef can_extract_once(s_counter, word_counter):\n for char, count in word_counter.items():\n if s_counter[char] < count...
trial_gpt4o_2
{ "original_instruction": "You are given a string consisting of lowercase English letters and some target words. Your task is to check how many times all the target words can be simultaneously extracted from the given string, maintaining their order each time. When a word is extracted, its letters are no longer avail...
0.740816
Taco_97587
C
[ "can_extract", "maximum_extractions" ]
2
[ [ "maximum_extractions", "can_extract" ] ]
1
[]
false
[]
false
pytest
true
[]
true
488552352f732ad50031d46f9281f51af23fc3ad
72b7f4a91b507167b35d56e6c41509f1554ebad6
v1.0
complete
Taco
Taco_97487_C
def organize_books(n: int, book_heights: List[int], m: int, shelf_capacities: List[int]) -> int: """ Sarah is an avid reader and loves collecting books. She has recently purchased several books and wants to organize them on her shelves. This function determines the maximum number of books that can be place...
def maximize_books_on_shelves(book_heights, shelf_capacities): """ Returns the maximum number of books that can be placed on the shelves. """ book_heights.sort() shelf_capacities.sort(reverse=True) total_books = 0 i = 0 for capacity in shelf_capacities: placed_books = 0...
from solution import organize_books def test_example_case(): assert organize_books(5, [4, 5, 3, 2, 8], 2, [3, 2]) == 5 def test_single_shelf(): assert organize_books(5, [4, 5, 3, 2, 8], 1, [4]) == 4 def test_shelves_with_lower_capacity(): assert organize_books(5, [4, 5, 3, 2, 8], 2, [2, 1]) == 3 def tes...
[ { "docstring": "Returns the maximum number of books that can be placed on the shelves.", "function_declaration": "def maximize_books_on_shelves(book_heights, shelf_capacities):", "function_name": "maximize_books_on_shelves", "parameter_list": "(book_heights, shelf_capacities)" }, { "docstrin...
[ 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 maximize_books_on_shelves(n, book_heights, m, shelf_capacities):\n # Sort the books in non-decreasing order of their heights.\n book_heights.sort()\n\n ...
trial_gpt4o_2
{ "original_instruction": "Sarah is an avid reader and loves collecting books. She has recently purchased several books and wants to organize them on her shelves. Sarah arranges her books in a very specific way: each book has a certain height, and she wants all the books on the same shelf to be sorted in non-decreasi...
0.663553
Taco_97487
C
[ "maximize_books_on_shelves", "organize_books" ]
2
[ [ "organize_books", "maximize_books_on_shelves" ] ]
1
[]
false
[]
false
pytest
true
[]
true
41f74d11ba2af4c109e3b24b0f7c0548b0d37e9e
801bb62af9589310c4f6086afd7c42ad4a22d0f0
v1.0
complete
Taco
Taco_97492_C
def max_non_overlapping_intervals(test_cases): """ For each test case, find the maximum number of non-overlapping intervals. Args: test_cases: List of tuples, where each tuple contains: an integer N (number of applicants) and a list of tuples of integers (start, end)...
def max_non_overlapping_intervals(test_cases): """ For each test case, find the maximum number of non-overlapping intervals. Args: test_cases: List of tuples, where each tuple contains: an integer N (number of applicants) and a list of tuples of integers (start, end)...
def test_max_non_overlapping_intervals(): data = "2\n3\n1 3\n2 4\n3 5\n4\n1 2\n2 3\n3 4\n4 5" expected_output = "2\n4" assert run_interview_scheduling(data) == expected_output def test_single_interval(): data = "1\n1\n0 5" expected_output = "1" assert run_interview_scheduling(data) == expected_...
[ { "docstring": "For each test case, find the maximum number of non-overlapping intervals.\n\nArgs:\ntest_cases: List of tuples, where each tuple contains:\n an integer N (number of applicants)\n and a list of tuples of integers (start, end) for each applicant's time slot.\n\nReturns:\nList...
[ 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 max_non_overlapping_intervals(t, cases):\n \"\"\"\n Determines the maximum number of non-overlapping intervals for each test case.\n \n Parameters:...
trial_gpt4o_1
{ "original_instruction": "A company has a system that schedules interviews for job applicants. Each applicant has a preferred time slot, but due to overlapping decisions, some applicants might have conflicts. Your task is to determine the maximum number of non-overlapping time slots that can be assigned to applicant...
0.585354
Taco_97492
C
[ "max_non_overlapping_intervals", "process_input", "process_output", "run_interview_scheduling" ]
4
[ [ "run_interview_scheduling", "max_non_overlapping_intervals" ], [ "run_interview_scheduling", "process_input" ], [ "run_interview_scheduling", "process_output" ] ]
3
[ "process_input" ]
false
[]
false
pytest
false
[]
true
42c981772f06a2d7d4addbc7aea0ce0403df7abf
a152fe9ae713785e5488fc54af8cc23a252838c4
v1.0
complete
Taco
Taco_97449_C
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def insert_level_order(arr, root, i, n): """Inserts nodes into the binary search tree in level order. Args: arr: List[int], the level order traversal of the BST. root: TreeNode, t...
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def insert_level_order(arr, root, i, n): if i < n: temp = TreeNode(arr[i]) root = temp root.left = insert_level_order(arr, root.left, 2 * i + 1, n) root.right = ins...
def test_single_node(): assert process_cases([(1, [10])]) == [10.0] def test_two_nodes(): assert process_cases([(2, [1, 3])]) == [2.0] def test_odd_number_of_nodes(): assert process_cases([(3, [3, 1, 4])]) == [3.0] def test_even_number_of_nodes(): assert process_cases([(4, [4, 2, 6, 1])]) == [3.0] d...
[]
[ 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 bst_median(t, test_cases):\n \"\"\"\n Given a number of test cases, and for each test case, a binary search tree with N nodes, \n the function returns...
trial_gpt4o_2
{ "original_instruction": "You are given a balanced binary search tree (BST) with N nodes. \n\nYour task is to find and print the median value of all the nodes in the BST. The median of a set of numbers is the middle number when the numbers are sorted in order. If there is an even number of elements, the median is th...
0.561498
Taco_97449
C
[ "insert_level_order", "in_order_traversal", "median_of_bst", "process_cases", "solve" ]
5
[ [ "median_of_bst", "in_order_traversal" ], [ "median_of_bst", "insert_level_order" ], [ "process_cases", "median_of_bst" ], [ "solve", "process_cases" ] ]
4
[ "process_cases" ]
false
[ "TreeNode" ]
true
pytest
false
[]
true
91b3f98dfb3a718b26e6aaaddf7719f2f6ed1c42
de327b9f1c33c121c940c906bafa13bfe2bb0c2c
v1.0
complete
Taco
Taco_97696_C
def nextPrime(N: int) -> int: """ Takes a positive integer N and returns the smallest prime number greater than N. Examples: >>> nextPrime(10) 11 >>> nextPrime(14) 17 >>> nextPrime(20) 23 """
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: return False i += ...
from solution import nextPrime def test_nextPrime_basic(): assert nextPrime(10) == 11 assert nextPrime(14) == 17 assert nextPrime(20) == 23 def test_nextPrime_edge_cases(): assert nextPrime(1) == 2 assert nextPrime(2) == 3 assert nextPrime(3) == 5 def test_nextPrime_large_number(): assert...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the smallest prime number greater than N.", "function_declaration": "def nextPrime(N):", "function_name": "ne...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_1
{ "original_instruction": "Ravi is a math enthusiast who likes to play with prime numbers. One day, he decided to combine his love for prime numbers and programming. He designed a challenge in which, given a positive integer `N`, he needs to find the smallest prime number greater than `N`. \n\nYour task is to create ...
0.718433
Taco_97696
C
[ "is_prime", "nextPrime" ]
2
[ [ "nextPrime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
06c36a0b7b0c9c99c117df94fed8237926ba9ae0
eb1dfe0579777a29ae0f6ba66ed8d0bbb79fc1c4
v1.0
complete
Taco
Taco_97613_C
def file_merge_operation(input_str: str) -> str: """ Implement a File Merge Operation. First line contains T - Number of test cases. Each test case contains two positive integers N and M followed by a list of N integers and a list of M integers. Output a single sorted list for each test case. ...
def merge_and_sort_arrays(test_cases): results = [] for case in test_cases: N, M, list1, list2 = case merged_list = list1 + list2 merged_list.sort() results.append(merged_list) return results def parse_input(input_str): input_lines = input_str.strip().split('\n') T =...
def test_file_merge_operation(): input_data = "2\n3 3\n12 11 5\n6 2 14\n4 4\n-1 0 1 0\n3 -4 2 5" expected_output = "2 5 6 11 12 14\n-4 -1 0 0 1 2 3 5" assert file_merge_operation(input_data) == expected_output def test_single_case_all_negative(): input_data = "1\n3 3\n-12 -11 -5\n-6 -2 -14" expecte...
[ { "docstring": null, "function_declaration": "def merge_and_sort_arrays(test_cases):", "function_name": "merge_and_sort_arrays", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "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 merge_sorted_lists(test_cases):\n \"\"\"\n Merges and sorts lists from given test cases.\n \n :param test_cases: List of tuples, each containing tw...
trial_gpt4o_2
{ "original_instruction": "Implement a File Merge Operation.\n\nInput:\n\nFirst line contains T - Number of test cases.\nEach test case contains two positive integers N and M followed by a list of N integers and a list of M integers.\n\nOutput:\n\nOutput a single sorted list for each test case.\n\nConstraints:\n\n1 ≤...
0.509732
Taco_97613
C
[ "merge_and_sort_arrays", "parse_input", "format_output", "file_merge_operation" ]
4
[ [ "file_merge_operation", "format_output" ], [ "file_merge_operation", "merge_and_sort_arrays" ], [ "file_merge_operation", "parse_input" ] ]
3
[ "parse_input", "format_output" ]
false
[]
false
pytest
false
[]
true
7d8f6ad636e3fdc360c2b6498828032cc4e59041
65335b06a13277f6d4e0ae330a64c2e48623364b
v1.0
complete
Taco
Taco_97534_C
def count_aesthetically_pleasing_recipes(n: int, m: int) -> int: """ Count the number of aesthetically pleasing recipes of length m that can be formed using n different ingredients, modulo 10^9+7. >>> count_aesthetically_pleasing_recipes(3, 2) 6 >>> count_aesthetically_pleasing_recipes(4, 3) 24...
MOD = 1000000007 def factorial(n): if n == 0 or n == 1: return 1 return n * factorial(n - 1) def count_aesthetically_pleasing_recipes(n, m): if m == 1: return n elif m > n: return 0 else: return (n * (factorial(n - 1) // factorial(n - m))) % MOD
from solution import count_aesthetically_pleasing_recipes def test_case_1(): assert count_aesthetically_pleasing_recipes(3, 2) == 6 def test_case_2(): assert count_aesthetically_pleasing_recipes(4, 3) == 24 def test_case_3(): assert count_aesthetically_pleasing_recipes(1, 1) == 1 def test_case_4(): ...
[ { "docstring": null, "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def count_aesthetically_pleasing_recipes(n, m):", "function_name": "count_aesthetically_pleasing_recipes", "par...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 1000000007\n\ndef aesthetically_pleasing_recipes(n, m):\n if m == 1:\n return n % MOD\n\n dp = [[0] * n for _ in range(m)]\n for i in range(n...
trial_gpt4o_1
{ "original_instruction": "Chef is interested in organizing a friendly competition among cooks. Each cook must prepare and submit a unique recipe. Each recipe is described using a distinct combination of ingredients. Every ingredient in a recipe is represented as a letter in the recipe string. Chef wants each recipe ...
0.560079
Taco_97534
C
[ "factorial", "count_aesthetically_pleasing_recipes" ]
2
[ [ "count_aesthetically_pleasing_recipes", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8b7ee341f4bf1e32ee7ef8130458d5efff6bd04e
67c70e471a79f98526a68e2816795e190706c3f7
v1.0
complete
Taco
Taco_96966_C
from typing import List, Tuple def build_and_solve(input_data: str) -> int: """ Determine the metropolis where the maximum distance to any other metropolis is minimized. Input: - input_data: A string consisting of the number of metropolises and the number of roads, followed by the co...
from collections import deque, defaultdict def find_best_metropolis(n, m, roads): if n == 1: return 1 # Build the graph using adjacency list graph = defaultdict(list) for u, v in roads: graph[u].append(v) graph[v].append(u) def bfs(start): distances = [-1] * (n...
def test_example_1(): assert build_and_solve("4 3\n1 2\n2 3\n2 4") == 2 def test_example_2(): assert build_and_solve("6 5\n1 2\n2 3\n3 4\n4 5\n4 6") == 3 def test_single_metropolis(): assert build_and_solve("1 0") == 1 def test_disjoint_graph(): # In case of a graph with multiple components, choose t...
[ { "docstring": null, "function_declaration": "def find_best_metropolis(n, m, roads):", "function_name": "find_best_metropolis", "parameter_list": "(n, m, roads)" }, { "docstring": null, "function_declaration": "def build_and_solve(input_data):", "function_name": "build_and_solve", ...
[ 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, defaultdict\n\ndef find_headquarter(n, m, roads):\n def bfs(start):\n distances = [-1] * (n + 1)\n distances[start]...
trial_gpt4o_4
{ "original_instruction": "In a faraway land called Metropolis, there are n metropolises connected by m bidirectional roads. Each metropolis has a unique index from 1 to n. The kingdom authorities are interested in strategic urban planning and want to build a new headquarter in a metropolis such that the maximum dist...
0.624752
Taco_96966
C
[ "find_best_metropolis", "build_and_solve" ]
2
[ [ "build_and_solve", "find_best_metropolis" ] ]
1
[]
false
[]
false
pytest
false
[]
true
15997eebf66fc92f758b56f7875aea0f32f8705e
6370943bc6cd42b261b01ad4e0a4cca6f50f9bd4
v1.0
complete
Taco
Taco_97208_C
def min_total_road_length(N: int, M: int, roads: List[Tuple[int, int, int]]) -> int: """ Determine whether it is possible to choose a subset of roads such that all buildings are connected and the total length of the chosen subset of roads is minimized. >>> min_total_road_length(4, 5, [(1, 2, 10), (1, 3...
def kruskal_mst(N, edges): """ Function to find the Minimum Spanning Tree (MST) using Kruskal's algorithm. """ # Helper function to find the root of the set in disjoint set def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) ...
def test_sample_1(): N = 4 M = 5 roads = [ (1, 2, 10), (1, 3, 6), (1, 4, 5), (2, 3, 4), (3, 4, 2) ] assert min_total_road_length(N, M, roads) == 11 def test_sample_2(): N = 4 M = 2 roads = [ (1, 2, 5), (3, 4, 10) ] assert m...
[ { "docstring": "Function to find the Minimum Spanning Tree (MST) using Kruskal's algorithm.", "function_declaration": "def kruskal_mst(N, edges):", "function_name": "kruskal_mst", "parameter_list": "(N, edges)" }, { "docstring": "Main function to find the minimum total length of the roads to...
[ 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 kruskal_mst(N, edges):\n \"\"\"\n Function to find the Minimum Spanning Tree (MST) using Kruskal's algorithm.\n \"\"\"\n # Helper function to find ...
trial_gpt4o_0
{ "original_instruction": "In the city of Gridland, there are N buildings and M roads connecting them. Each road has a certain length in meters. Your task is to determine whether it is possible to choose a subset of roads such that all buildings are connected (i.e., there is a path between any two buildings) and the ...
0.717078
Taco_97208
C
[ "kruskal_mst", "min_total_road_length" ]
2
[ [ "min_total_road_length", "kruskal_mst" ] ]
1
[]
false
[]
false
pytest
false
[]
true
8a950775c5624b24aef9a19b277c973ff9cc40fa
4ad63e20942b1e3abc598db81f3aaf0a15036ae0
v1.0
complete
Taco
Taco_97606_C
def merge(arr, l, m, r): """ Merges two subarrays of arr. First subarray is arr[l..m] Second subarray is arr[m+1..r] """ # Your code here def mergeSort(arr, l, r): """ Main function that sorts arr[l..r] using merge() """ # Your code here # Example usage arr = [12, 11, 13, 5, 6]...
def merge(arr, l, m, r): """ Merges two subarrays of arr. First subarray is arr[l..m] Second subarray is arr[m+1..r] """ n1 = m - l + 1 n2 = r - m # create temp arrays L = [0] * n1 R = [0] * n2 # Copy data to temp arrays L[] and R[] for i in range(n1): L[i] = ar...
from solution import mergeSort def test_mergeSort_example1(): arr = [12, 11, 13, 5, 6] mergeSort(arr, 0, len(arr) - 1) assert arr == [5, 6, 11, 12, 13] def test_mergeSort_example2(): arr = [38, 27, 43, 3, 9, 82] mergeSort(arr, 0, len(arr) - 1) assert arr == [3, 9, 27, 38, 43, 82] def test_mer...
[ { "docstring": "Merges two subarrays of arr.\nFirst subarray is arr[l..m]\nSecond subarray is arr[m+1..r]", "function_declaration": "def merge(arr, l, m, r):", "function_name": "merge", "parameter_list": "(arr, l, m, r)" }, { "docstring": "Main function that sorts arr[l..r] using merge()", ...
[ 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 merge(arr, left, mid, right):\n n1 = mid - left + 1\n n2 = right - mid\n \n # Create temp arrays\n L = [0] * n1\n R = [0] * n2\n \n # C...
trial_gpt4o_2
{ "original_instruction": "The task is to complete the merge() function which is used to implement Merge Sort. \nExample 1:\nInput:\nN = 5\narr[] = {12, 11, 13, 5, 6}\nOutput:\n5 6 11 12 13\nExample 2:\nInput:\nN = 6\narr[] = {38, 27, 43, 3, 9, 82}\nOutput:\n3 9 27 38 43 82\nYour Task: \nYou don't have to read input ...
0.576841
Taco_97606
C
[ "merge", "mergeSort" ]
2
[ [ "mergeSort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c6c2b3465d74d548409e21d2318bcb73a8dafe16
d98d5cd3a7feeef162ca6c0f7eab3456dd6325e9
v1.0
complete
Taco
Taco_97144_C
def is_magical_plant(growth_potentials): """ Determines if a plant is magical by checking if there exists at least one contiguous subarray whose sum is even. """ def enchanted_forest(n, plants): """ Processes a list of plants to determine if each is magical. n: int, number of plants ...
def is_magical_plant(growth_potentials): """ Determines if a plant is magical by checking if there exists at least one contiguous subarray whose sum is even. """ for potential in growth_potentials: if potential % 2 == 0: return "MAGICAL" return "NOT MAGICAL" def enchanted_fo...
from solution import enchanted_forest def test_example_case_1(): n = 3 plants = [ [1, 2, 3], [1, 3, 5, 7], [6, -2] ] assert enchanted_forest(n, plants) == ["MAGICAL", "NOT MAGICAL", "MAGICAL"] def test_all_odd_numbers(): n = 2 plants = [ [1, 3, 5], [7, 9...
[ { "docstring": "Determines if a plant is magical by checking if there exists at least one\ncontiguous subarray whose sum is even.", "function_declaration": "def is_magical_plant(growth_potentials):", "function_name": "is_magical_plant", "parameter_list": "(growth_potentials)" }, { "docstring...
[ 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_magical(plant_growth_potentials):\n \"\"\"\n Determines if a plant is magical by checking if there exists at least one contiguous subarray whose sum i...
trial_gpt4o_1
{ "original_instruction": "In a mystical land, there exists an enchanted forest with unique plants. Each plant has a unique growth potential, represented as a series of numbers. The land's guardian, Elara, has a task for a brave coder: to determine which plants can provide a sequence of growths hitherto unseen by any...
0.540103
Taco_97144
C
[ "is_magical_plant", "enchanted_forest" ]
2
[ [ "enchanted_forest", "is_magical_plant" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d27defb1d843c107068f43897812134a3e5be29f
fd4beefe3b5e4116a5011710f414b264bf499ec3
v1.0
complete
Taco
Taco_97396_C
from typing import List, Tuple def find_tree_diameter(n: int, edges: List[Tuple[int, int]]) -> int: """ Finds the diameter of the tree given nodes and edges. :param n: Number of nodes in the tree. :param edges: List of edges in the tree. :returns: The diameter of the tree. >>> find_tree_d...
from collections import deque def bfs_farthest_node(start, adj): """ Perform BFS to find the farthest node from the start node and its distance. :param start: The starting node for BFS. :param adj: The adjacency list representation of the graph. :returns: A tuple (farthest_node, max_distance)....
from solution import find_tree_diameter def test_find_tree_diameter_case_1(): n = 5 edges = [(1, 2), (1, 3), (2, 4), (2, 5)] assert find_tree_diameter(n, edges) == 3 def test_find_tree_diameter_case_2(): n = 4 edges = [(1, 2), (2, 3), (3, 4)] assert find_tree_diameter(n, edges) == 3 def test_...
[ { "docstring": "Perform BFS to find the farthest node from the start node and its distance.\n\n:param start: The starting node for BFS.\n:param adj: The adjacency list representation of the graph.\n:returns: A tuple (farthest_node, max_distance).", "function_declaration": "def bfs_farthest_node(start, adj):...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef calculate_tree_diameter(n, edges):\n if n == 1:\n return 0\n \n def bfs(start):\n dist = [...
trial_gpt4o_1
{ "original_instruction": "A group of friends is organizing a scavenger hunt in a park. Each location in the park where an item could be hidden is represented as a node in a tree. The nodes are connected by bidirectional paths, and there is exactly one path between any two nodes (i.e., the park is represented as a tr...
0.625593
Taco_97396
C
[ "bfs_farthest_node", "find_tree_diameter" ]
2
[ [ "find_tree_diameter", "bfs_farthest_node" ] ]
1
[]
false
[]
false
pytest
true
[]
true
46e83616624487c8501fbda719c62c42a8ecf3e8
6940f48c177a9da9e2d55274b7b4659c05f0bb87
v1.0
complete
Taco
Taco_97652_C
def is_palindrome(n: int) -> bool: """ Returns True if n is a palindrome, otherwise False. >>> is_palindrome(121) True >>> is_palindrome(1331) True >>> is_palindrome(123) False >>> is_palindrome(1) True >>> is_palindrome(22) True """ def count_palindromes_in_range(T: ...
def is_palindrome(n): """ Returns True if n is a palindrome, otherwise False. """ str_n = str(n) return str_n == str_n[::-1] def count_palindromes_in_range(T, ranges): """ For each range [L, R] in ranges, count the number of palindrome integers. Parameters: T (int): Number of t...
def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(1331) == True assert is_palindrome(123) == False assert is_palindrome(1) == True assert is_palindrome(22) == True def test_count_palindromes_in_range(): assert count_palindromes_in_range(2, [(1, 10), (100, 200)]) =...
[ { "docstring": "Returns True if n is a palindrome, otherwise False.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "For each range [L, R] in ranges, count the number of palindrome integers.\n\nParameters:\nT (int...
[ 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 is_palindrome(n):\n \"\"\"\n Checks if a given number n is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef count_palindromes(L, R):\n...
trial_gpt4o_9
{ "original_instruction": "Paul loves playing with numbers, and his current interest is in palindromes. He wants to know the number of palindrome integers within a given range [L, R] inclusive. \n\nA palindrome integer is a number that remains the same when its digits are reversed (e.g., 121, 1331).\n\nInput:\n\n- Th...
0.789871
Taco_97652
C
[ "is_palindrome", "count_palindromes_in_range", "main" ]
3
[ [ "count_palindromes_in_range", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
false
[]
true
3314c02dabce85560e2502d9c7aa24a2c9966cfc
e2b354c494b970038052b776f26a4cd5508d94cb
v1.0
complete
Taco
Taco_98149_C
def min_checks(T: int) -> int: """ Calculates the minimum number of checks required to achieve the given total amount T. Each check can endorse an amount that is a power of 2. >>> min_checks(23) 4 >>> min_checks(37) 3 >>> min_checks(1024) 1 >>> min_checks(0) 0 """ d...
def min_checks(T): """ Calculates the minimum number of checks required to achieve the given total amount T. Each check can endorse an amount that is a power of 2. """ checks = 0 while T > 0: highest_power_of_2 = 1 << (T.bit_length() - 1) T -= highest_power_of_2 checks +=...
from solution import min_checks, process_checks def test_min_checks(): assert min_checks(23) == 4 assert min_checks(37) == 3 assert min_checks(1024) == 1 assert min_checks(0) == 0 assert min_checks(1) == 1 assert min_checks(2) == 1 assert min_checks(3) == 2 # 2 + 1 assert min_checks(16...
[ { "docstring": "Calculates the minimum number of checks required to achieve the given total amount T.\nEach check can endorse an amount that is a power of 2.", "function_declaration": "def min_checks(T):", "function_name": "min_checks", "parameter_list": "(T)" }, { "docstring": "Processes mu...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_checks(total_amount):\n \"\"\"\n Return the minimum number of checks needed to endorse exactly the specified amount.\n Each check can only endorse...
trial_gpt4o_4
{ "original_instruction": "A wealthy philanthropist wants to support promising startups by providing seed funding. He decides to adopt a system where the total amount he will spend is determined by a sequence of checks. Each check can only endorse an integer value that is a power of 2 (e.g., 1, 2, 4, 8, 16, ...). How...
0.601207
Taco_98149
C
[ "min_checks", "process_checks" ]
2
[ [ "process_checks", "min_checks" ] ]
1
[]
false
[]
false
pytest
true
[]
true
04693d441e5f221ace0ca27d6d25a9be50ffa59d
02dbc6cc1a9b9c647ebb6aa1912cd3098b11a3a5
v1.0
complete
Taco
Taco_97888_C
def min_cost_to_connect_cities(n, m, roads): """ Find the minimum cost to connect all the cities using n-1 roads. n: int - number of cities m: int - number of potential roads roads: List[Tuple[int, int, int]] - list of tuples where each tuple contains three integers (u, v, w) ...
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 root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif r...
import pytest from solution import min_cost_to_connect_cities def test_example1(): assert min_cost_to_connect_cities(4, 5, [(1, 2, 1), (2, 3, 2), (3, 4, 3), (1, 3, 2), (1, 4, 3)]) == 6 def test_example2(): assert min_cost_to_connect_cities(3, 1, [(1, 2, 4)]) == -1 def test_single_city(): assert min_cost_...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, ran...
trial_gpt4o_1
{ "original_instruction": "The kingdom of Varantine has decided to build a new road network to connect its cities. The kingdom has n cities and needs to lay down exactly n-1 roads to ensure all cities are connected with the minimum total road length. Each road connects exactly two cities and has a certain length, and...
0.675055
Taco_97888
C
[ "find", "union", "min_cost_to_connect_cities" ]
3
[ [ "min_cost_to_connect_cities", "find" ], [ "min_cost_to_connect_cities", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e7ed1282fcca069c8a172b89c86f64d1a1484b9a
3cdd4297a9490363131d7154a5d30a3563bc48c9
v1.0
complete
Taco
Taco_97567_C
def is_prime(num): """ Returns True if num is a prime number, False otherwise.""" def organize_books(n, books): """ Organize books by placing prime ISBNs first, followed by non-prime ISBNs while maintaining the original order within each group. >>> organize_books(5, [3, 1, 4, 2, 5]) [3, 2, 5, 1, ...
def is_prime(num): """ Returns True if num is a prime number, False otherwise. """ 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...
from solution import organize_books def test_organize_books_example_1(): assert organize_books(5, [3, 1, 4, 2, 5]) == [3, 2, 5, 1, 4] def test_organize_books_example_2(): assert organize_books(6, [6, 3, 4, 7, 1, 5]) == [3, 7, 5, 6, 4, 1] def test_organize_books_single_prime(): assert organize_books(1, [2...
[ { "docstring": "Returns True if num is a prime number, False otherwise.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the list of books organized with prime ISBNs first,\nfollowed by non-prime ISBNs.", "f...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if num is a prime number, otherwise False.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n...
trial_gpt4o_2
{ "original_instruction": "Anton is a librarian and he wants to organize the books in his library. He has exactly n books and each book has a unique ISBN number ranging from 1 to n. To make the library more accessible, he wants to start by arranging the books in such a way that all the books with prime ISBN numbers a...
0.603271
Taco_97567
C
[ "is_prime", "organize_books" ]
2
[ [ "organize_books", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6ad9818625219db7f5fa90759e11f99ac996e357
be105e0aa71a5522fbb418d06abc67c3e00ff033
v1.0
complete
Taco
Taco_98273_C
from typing import List, Tuple def total_effectiveness(order: Tuple[int], matrix: List[List[int]]) -> int: """ Calculate the total effectiveness of a given order of scientists. """ total = 0 for i in range(len(order)): for j in range(len(order)): total += matrix[order[i]][order[...
from itertools import permutations def total_effectiveness(order, matrix): total = 0 for i in range(len(order)): for j in range(len(order)): total += matrix[order[i]][order[j]] return total def optimal_order(matrix): M = len(matrix) all_orders = permutations(range(M)) max_e...
import pytest from solution import solve, total_effectiveness, optimal_order def test_single_case(): T = 1 test_cases = [(3, [[1, 2, 3], [4, 5, 6], [7, 8, 9]])] expected = ["0 1 2"] assert solve(T, test_cases) == expected def test_multiple_cases(): T = 2 test_cases = [ (3, [[1, 2, 3], ...
[ { "docstring": null, "function_declaration": "def total_effectiveness(order, matrix):", "function_name": "total_effectiveness", "parameter_list": "(order, matrix)" }, { "docstring": null, "function_declaration": "def optimal_order(matrix):", "function_name": "optimal_order", "par...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef calculate_effectiveness_order(matrix, order):\n n = len(matrix)\n total_effectiveness = 0\n for i in range(n-1):...
trial_gpt4o_2
{ "original_instruction": "A team of M scientists is working in a well-organized research facility with state-of-the-art equipment. Each scientist can either collaborate or work independently on various projects. You're given an M x M matrix where the element at position (i, j) indicates the effectiveness of scientis...
0.587146
Taco_98273
C
[ "total_effectiveness", "optimal_order", "solve" ]
3
[ [ "optimal_order", "total_effectiveness" ], [ "solve", "optimal_order" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9353586b626a6223323761c9807837a2e82be036
210c42056d614ebb4503163f555cb1c4cfd48ff3
v1.0
complete
Taco
Taco_98293_C
def decode_message(encoded_message: str) -> str: """ Decode the encoded message by determining the correct shift value for each word. The correct shift value will make each word a valid English word, and the resulting decoded message should be properly formatted. >>> decode_message("ymj vznhp gwtbs...
from collections import Counter # Assuming a pre-defined set of valid English words ENGLISH_WORDS = set([ 'the', 'quick', 'brown', 'fox', 'jumps', 'over', 'lazy', 'dog', 'hello', 'world', 'this', 'is', 'an', 'example' # A comprehensive list would include all English words ]) def shift_char(c, shift): ...
from solution import decode_message def test_decode_message_example(): encoded_message = "ymj vznhp gwtbs ktc ozrux tajw ymj qfed itl" expected_decoded_message = "the quick brown fox jumps over the lazy dog" assert decode_message(encoded_message) == expected_decoded_message def test_decode_message_hello_w...
[ { "docstring": "Shift a character by given shift", "function_declaration": "def shift_char(c, shift):", "function_name": "shift_char", "parameter_list": "(c, shift)" }, { "docstring": null, "function_declaration": "def is_valid_word(word):", "function_name": "is_valid_word", "par...
[ 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 decode_word(encoded_word: str, shift: int) -> str:\n \"\"\"\n Decodes a single word by shifting its letters backward by the given shift amount.\n \"\"...
trial_gpt4o_2
{ "original_instruction": "You are given a string of words separated by spaces. Each word in the string is encoded by shifting each letter by a fixed number of positions in the alphabet. This fixed number is different for each word in the string. Your task is to decode the message by determining the correct shift val...
0.702425
Taco_98293
C
[ "shift_char", "is_valid_word", "decode_word", "decode_message" ]
4
[ [ "decode_message", "decode_word" ], [ "decode_word", "is_valid_word" ], [ "decode_word", "shift_char" ] ]
3
[]
false
[]
false
pytest
true
[]
true
13332dffd2d7397cd4fc5dd28e17bda2d07d65d1
4de11d6303eb57bc161d813b7ca5cc69fc21cf55
v1.0
complete
Taco
Taco_98137_C
def organize_events(n: int, event_list: List[str]) -> str: """ You are given the task of organizing a sequence of events such that each event's requirements are satisfied. The input starts with a single integer n (1 ≤ n ≤ 100), representing the number of events. Each of the following n lines contains ...
def find_event_sequence(n, events): from collections import defaultdict, deque # Step 1: Parse input and build the graph event_graph = defaultdict(list) indegree = {event: 0 for event in events} for event, precedents in events.items(): if precedents: for prerequisite in pre...
from solution import organize_events def test_simple_case(): n = 4 event_list = [ "EventA -", "EventB EventA", "EventC EventA", "EventD EventB EventC" ] assert organize_events(n, event_list) == 'EventA EventB EventC EventD' def test_impossible_case(): n = 3 even...
[ { "docstring": null, "function_declaration": "def find_event_sequence(n, events):", "function_name": "find_event_sequence", "parameter_list": "(n, events)" }, { "docstring": null, "function_declaration": "def organize_events(n, event_list):", "function_name": "organize_events", "...
[ 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, deque\n\ndef order_events(n, events):\n # Step 1: Create a graph and a dictionary to keep track of in-degrees\n graph = ...
trial_gpt4o_2
{ "original_instruction": "You are given the task of organizing a sequence of events such that each event's requirements are satisfied. Each event has a name and a list of preceding events that must be completed before it can start. Here's how you should handle this:\n\n-----Input-----\nThe input starts with a single...
0.519717
Taco_98137
C
[ "find_event_sequence", "organize_events" ]
2
[ [ "organize_events", "find_event_sequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dc19d3a9f54180e903d06f9ce6637b4853e3e004
cb34a33b4e6a448f2608eca8b125b258af2e8eb0
v1.0
complete
Taco
Taco_97669_C
def sum_of_digits(num: int) -> int: """ Helper function to calculate the sum of digits of a number. """ return sum(int(digit) for digit in str(num)) def sequence_of_sums(N: int, M: int) -> list: """ Generate the first M terms of the sequence where each term is the sum of digits of the previous term sta...
def sum_of_digits(num): """ Helper function to calculate the sum of digits of a number. """ return sum(int(digit) for digit in str(num)) def sequence_of_sums(N, M): """ Generate the first M terms of the sequence where each term is the sum of digits of the previous term starting from N. """ ...
from solution import sequence_of_sums def test_case_1(): assert sequence_of_sums(123, 5) == [6, 6, 6, 6, 6] def test_case_2(): assert sequence_of_sums(987654321, 3) == [45, 9, 9] def test_case_3(): assert sequence_of_sums(1, 1) == [1] def test_case_4(): assert sequence_of_sums(99999999, 2) == [72, 9...
[ { "docstring": "Helper function to calculate the sum of digits of a number.", "function_declaration": "def sum_of_digits(num):", "function_name": "sum_of_digits", "parameter_list": "(num)" }, { "docstring": "Generate the first M terms of the sequence where each term is the sum of digits of t...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_digits(num):\n \"\"\"\n Helper function to calculate the sum of digits of a number.\n \"\"\"\n return sum(int(digit) for digit in str(num))\...
trial_gpt4o_0
{ "original_instruction": "Given two integers N and M, output the first M terms of the sequence S where each term is the sum of digits of the previous term starting from N. \n\nFor example, if N is 123, the first term is the sum of digits of 123, which is 6. The second term is the sum of digits of 6, which is still 6...
0.727183
Taco_97669
C
[ "sum_of_digits", "sequence_of_sums" ]
2
[ [ "sequence_of_sums", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5c30be22931d2f0b1270084db25f250a20fd4ee1
f1e33f92e0588fb89f02a5a9408e5b92e51a523c
v1.0
complete
Taco
Taco_98342_C
def product_except_self(nums): """ Returns a list such that each element at index i is the product of all numbers in nums except nums[i]. >>> product_except_self([1, 2, 3]) [6, 3, 2] >>> product_except_self([4, 5, 6, 7]) [210, 168, 140, 120] >>> product_except_self([1, 1, 1, 1]) [1, 1, 1, 1]...
def product_except_self(nums): """ Returns a list such that each element at index i is the product of all numbers in nums except nums[i]. """ length = len(nums) left_products = [1] * length right_products = [1] * length result = [1] * length for i in range(1, length): l...
def test_product_except_self(): assert product_except_self([1, 2, 3]) == [6, 3, 2] assert product_except_self([4, 5, 6, 7]) == [210, 168, 140, 120] assert product_except_self([1, 1, 1, 1]) == [1, 1, 1, 1] assert product_except_self([-1, 1, 0, -3, 3]) == [0, 0, 9, 0, 0] assert product_except_self([2,...
[ { "docstring": "Returns a list such that each element at index i is the product of all numbers in nums except nums[i].", "function_declaration": "def product_except_self(nums):", "function_name": "product_except_self", "parameter_list": "(nums)" }, { "docstring": null, "function_declarat...
[ 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 product_except_self(arr):\n \"\"\"\n Given an array of integers, returns a new array such that each element at index `i` \n is the product of all the ...
trial_gpt4o_2
{ "original_instruction": "------ Input ------\n\nAli loves experimenting with numerical series. One day, he came across a problem and found it interesting. He has an array of $N$ integers and wants to create a new series of products. Each item in the new series is the product of all the numbers in the original array...
0.679179
Taco_98342
C
[ "product_except_self", "solve", "parse_input", "format_output", "main" ]
5
[ [ "solve", "product_except_self" ] ]
1
[ "parse_input", "format_output" ]
false
[]
false
pytest
false
[]
true
3c6cf4251e2e825d1be34904c6a40894d768388b
bb42306c92b9d15a5f2aa5d1dd82767a492f017f
v1.0
complete
Taco
Taco_98453_C
def minimize_path_sum_from_input(n: int, triangle_list: List[int]) -> int: """ Returns the minimum path sum from top to bottom in a given triangle. Args: n : int : the number of rows in the triangle triangle_list: List[int] : flattened list of integers representing the triangle Returns: ...
def minimize_path_sum(triangle): """ Returns the minimum path sum from top to bottom in a given triangle. :param triangle: List of lists of integers representing the triangle :return: Integer representing the minimum path sum """ # Start from the second last row and propagate the minimum pa...
from solution import minimize_path_sum_from_input def test_minimize_path_sum1(): n = 4 triangle_list = [2, 3, 4, 6, 5, 7, 4, 1, 8, 3] assert minimize_path_sum_from_input(n, triangle_list) == 11 def test_minimize_path_sum2(): n = 3 triangle_list = [1, 2, 3, 4, 5, 6] assert minimize_path_sum_fro...
[ { "docstring": "Returns the minimum path sum from top to bottom in a given triangle.\n\n:param triangle: List of lists of integers representing the triangle\n:return: Integer representing the minimum path sum", "function_declaration": "def minimize_path_sum(triangle):", "function_name": "minimize_path_s...
[ 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 minimize_path_sum(triangle):\n \"\"\"\n Returns the minimum path sum from top to bottom in a given triangle.\n \n :param triangle: List of lists of...
trial_gpt4o_0
{ "original_instruction": "Minimize Path Sum in Triangle\n\nProblem\n\nYou are given a triangle of integers where the first row has one element, the second row has two elements, and so on. Your task is to find the minimum path sum from the top to the bottom row, where each movement can go to either the adjacent numbe...
0.623705
Taco_98453
C
[ "minimize_path_sum", "minimize_path_sum_from_input" ]
2
[ [ "minimize_path_sum_from_input", "minimize_path_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7ab307c4252733e241343c99f41490687687e7ff
2e5ecffd399f40d062be86bc2578c2b831a004e5
v1.0
complete
Taco
Taco_98361_C
def unique_paths(m: int, n: int, grid: List[str]) -> int: """Given a grid of size MxN consisting of '.' (walkable cell) and '#' (non-walkable cell), find the number of unique paths from the top-left corner to the bottom-right corner. You can only move down or right at any point in time. You must ensure that paths d...
def num_ways(grid): M = len(grid) N = len(grid[0]) if grid[0][0] == '#' or grid[M-1][N-1] == '#': return 0 dp = [[0] * N for _ in range(M)] dp[0][0] = 1 for i in range(M): for j in range(N): if grid[i][j] == '#': dp[i][j] = 0 ...
from solution import unique_paths def test_case_1(): m, n = 3, 3 grid = [ "...", ".#.", "..." ] assert unique_paths(m, n, grid) == 2 def test_case_2(): m, n = 2, 2 grid = [ "..", ".." ] assert unique_paths(m, n, grid) == 2 def test_case_3(): ...
[ { "docstring": null, "function_declaration": "def num_ways(grid):", "function_name": "num_ways", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def unique_paths(m, n, grid):", "function_name": "unique_paths", "parameter_list": "(m, n, grid)" } ]
[ 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 unique_paths_in_grid(grid):\n \"\"\"\n Returns the number of unique paths from the top-left corner to the bottom-right corner\n in a grid marked with ...
trial_gpt4o_2
{ "original_instruction": "Given a grid of size MxN consisting of '.' (walkable cell) and '#' (non-walkable cell), find the number of unique paths from the top-left corner to the bottom-right corner. You can only move down or right at any point in time. \n\nYou must ensure that paths do not pass through cells marked ...
0.714007
Taco_98361
C
[ "num_ways", "unique_paths" ]
2
[ [ "unique_paths", "num_ways" ] ]
1
[]
false
[]
false
pytest
true
[]
true
94bc1a2cd7a2087f4d0a09c7a3200d5979a19a1f
28431b6b960074fabe4d46bca0530aa91eb61151
v1.0
complete
Taco
Taco_97939_C
def categorize_finishers(times): """ Categorizes participants into various time brackets and counts the number of participants in each bracket. :param times: List of finish times. :return: Dictionary with count of participants in each category. """ def marathon_results(m, n, times): """ ...
def categorize_finishers(times): """ Categorizes participants into various time brackets and counts the number of participants in each bracket. :param times: List of finish times. :return: Dictionary with count of participants in each category. """ brackets = { "Less than 2 hours": 0, ...
import pytest from solution import categorize_finishers, marathon_results def test_categorize_finishers(): times = [1.5, 3.2, 4.5, 2.9, 1.8] result = categorize_finishers(times) assert result["Less than 2 hours"] == 2 assert result["2 hours to 4 hours"] == 2 assert result["More than 4 hours"] == 1 ...
[ { "docstring": "Categorizes participants into various time brackets and counts the number of participants in each bracket.\n\n:param times: List of finish times.\n:return: Dictionary with count of participants in each category.", "function_declaration": "def categorize_finishers(times):", "function_name...
[ 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 categorize_finish_times(m, n, finish_times):\n \"\"\"\n Categorizes the finish times into the defined time brackets\n\n Parameters:\n m (int): Leng...
trial_gpt4o_1
{ "original_instruction": "A company organizes a marathon event every year and needs help to determine the number of participants who have completed the course within different time brackets. The marathon track is M kilometers long, and each participant's finish time (in hours) is recorded. Write a function that cate...
0.518313
Taco_97939
C
[ "categorize_finishers", "marathon_results" ]
2
[ [ "marathon_results", "categorize_finishers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fa8fb6dc32585de7f1f79eccaa5379c456d12c46
eb2b793a2535b30de521cb1fc49c64864afbc507
v1.0
complete
Taco
Taco_98335_C
def gcd(a, b): """ Find the greatest common divisor (GCD) of two numbers. >>> gcd(12, 15) 3 >>> gcd(10, 5) 5 >>> gcd(7, 3) 1 """ while b: a, b = b, a % b return a def can_reach(L, S, D): """ Determine if Mary can reach exactly position `D` using a combination of long and short j...
def gcd(a, b): while b: a, b = b, a % b return a def can_reach(L, S, D): # Find the greatest common divisor (GCD) of L and S g = gcd(L, S) # Check if D is divisible by the GCD of L and S return D % g == 0 def mary_jumps(T, test_cases): results = [] for L, S, D in test_cases: ...
from solution import mary_jumps def test_can_reach_cases(): T = 3 test_cases = [ (3, 5, 13), (4, 6, 11), (7, 2, 14) ] assert mary_jumps(T, test_cases) == ["YES", "NO", "YES"] def test_gcd_function(): from solution import gcd assert gcd(12, 15) == 3 assert gcd(10...
[ { "docstring": null, "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def can_reach(L, S, D):", "function_name": "can_reach", "parameter_list": "(L, S, D)" }, { "docstring": null,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_reach_position(L, S, D):\n from math import gcd\n \n # The solution is possible if and only if D is a multiple of the greatest common divisor of L...
trial_gpt4o_8
{ "original_instruction": "Mary is at position 0 on an infinite road with two types of jumps: a long jump, which covers `L` meters, and a short jump, which covers `S` meters. Mary wants to reach exactly position `D` using a sequence of these jumps. \n\nDetermine if Mary can reach exactly position `D` using a combinat...
0.602805
Taco_98335
C
[ "gcd", "can_reach", "mary_jumps" ]
3
[ [ "can_reach", "gcd" ], [ "mary_jumps", "can_reach" ] ]
2
[]
false
[]
false
pytest
true
[]
true
139aed2effd6ed59c26f08526d35cfc1e5304cff
dc6753936504423fd913b9e48f3a85cdad8677c7
v1.0
complete
Taco
Taco_98442_C
def rotate_array(arr, k): """ Rotates the array to the right by k steps. Parameters: arr (list): List of integers to rotate. k (int): Number of steps to rotate the array. Returns: list: The rotated array. >>> rotate_array([1, 2, 3, 4, 5, 6], 2) [5, 6, 1, 2, 3, 4] >>> r...
def rotate_array(arr, k): """ Rotates the array to the right by k steps. Parameters: arr (list): List of integers to rotate. k (int): Number of steps to rotate the array. Returns: list: The rotated array. """ n = len(arr) # In case k is greater than n k = k % n ...
from solution import rotate_array def test_rotate_array_example1(): assert rotate_array([1, 2, 3, 4, 5, 6], 2) == [5, 6, 1, 2, 3, 4] def test_rotate_array_example2(): assert rotate_array([-1, -100, 3, 99, 0], 3) == [3, 99, 0, -1, -100] def test_rotate_array_k_greater_than_n(): assert rotate_array([1, 2, ...
[ { "docstring": "Rotates the array to the right by k steps.\n\nParameters:\narr (list): List of integers to rotate.\nk (int): Number of steps to rotate the array.\n\nReturns:\nlist: The rotated array.", "function_declaration": "def rotate_array(arr, k):", "function_name": "rotate_array", "parameter_l...
[ 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 to the right by k steps.\n \n Parameters:\n arr (list): List of integers to rotate.\n k (i...
trial_gpt4o_0
{ "original_instruction": "Sam is working on a project where he needs to manipulate arrays frequently. One of the tasks requires him to rotate an array. Given an array of integers and a number k, rotate the array to the right by k steps. \n\n### Rotation Description\nTo rotate the array to the right by k steps means ...
0.675833
Taco_98442
C
[ "rotate_array", "reverse" ]
2
[ [ "rotate_array", "reverse" ] ]
1
[]
false
[]
false
pytest
true
[]
true
150cf3b8f009b7f1733d1004a662240fe1c8c723
7c871772bf8ae9350373720c2f5e07984c0b009a