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_52461_C
from typing import List def max_submatrix_sum(matrix: List[List[int]]) -> int: """ Returns the maximum sum of any submatrix within the given matrix. >>> max_submatrix_sum([ ... [1, 2, -1, -4, -20], ... [-8, -3, 4, 2, 1], ... [3, 8, 10, 1, 3], ... [-4, -1, 1, 7, -6] ... ]...
def max_submatrix_sum(matrix): """ Returns the maximum sum of any submatrix within the given matrix. """ if not matrix or not matrix[0]: return 0 N = len(matrix) M = len(matrix[0]) max_sum = float('-inf') # Apply Kadane's Algorithm in 2D for left in range(M): te...
def test_max_submatrix_sum(): matrix1 = [ [1, 2, -1, -4, -20], [-8, -3, 4, 2, 1], [3, 8, 10, 1, 3], [-4, -1, 1, 7, -6] ] assert max_submatrix_sum(matrix1) == 29 matrix2 = [ [-1, -2], [-3, -4] ] assert max_submatrix_sum(matrix2) == -1 matrix3 ...
[ { "docstring": "Returns the maximum sum of any submatrix within the given matrix.", "function_declaration": "def max_submatrix_sum(matrix):", "function_name": "max_submatrix_sum", "parameter_list": "(matrix)" }, { "docstring": "Helper function to find the maximum sum subarray in a 1D array."...
[ 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 max_sum_submatrix(matrix):\n \"\"\"\n Finds the submatrix with the maximum sum.\n \"\"\"\n def kadane(arr):\n max_sum = arr[0]\n curr...
trial_gpt4o_2
{ "original_instruction": "You are given a matrix of dimensions N x M, filled with integers. Your goal is to find the submatrix with the maximum sum. The submatrix should have at least one element. \n\nConstraints:\n\n* 1 \\≤ N, M \\≤ 100\n* -1000 ≤ matrix[i][j] ≤ 1000\n\nInput:\n\nThe input is given from Standard In...
0.63
Taco_52461
C
[ "max_submatrix_sum", "kadane" ]
2
[ [ "max_submatrix_sum", "kadane" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c2e33d65692d064ea0538522e60660fb3cbe0f85
b89cdd5a74a506f88a3b1ee416c6b0c7d893390d
v1.0
complete
Taco
Taco_52658_C
from typing import List, Tuple def minimumCommunicationDelay(n: int, connections: List[Tuple[int, int, int]]) -> int: """ Determine the minimum total communication delay to connect all computers. If it is impossible to connect all computers, return -1. Args: n (int): number of computers labeled from 1...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot]...
def test_minimum_communication_delay(): assert minimumCommunicationDelay(4, [[1, 2, 1], [2, 3, 2], [3, 4, 1], [1, 4, 4]]) == 4 assert minimumCommunicationDelay(4, [[1, 2, 3], [3, 4, 4]]) == -1 assert minimumCommunicationDelay(3, [[1, 2, 1], [2, 3, 1], [1, 3, 2]]) == 2 assert minimumCommunicationDelay(5,...
[ { "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 minimumCommunicationDelay(n, connections):\n \"\"\"\n Returns the minimum total communication delay to connect all computers or -1 if it's impossible.\n ...
trial_gpt4o_1
{ "original_instruction": "You are given a network of n computers labeled from 1 to n. Each computer is connected to other computers by bidirectional communication channels. You are provided with a list of connections where each connection is a tuple (a_i, b_i, t_i) representing a channel between computer a_i and com...
0.523047
Taco_52658
C
[ "find", "union", "minimumCommunicationDelay" ]
3
[ [ "minimumCommunicationDelay", "find" ], [ "minimumCommunicationDelay", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
8d9ab9a41827df7f86aa33ac4173c1556e6b5e91
af29233abcf4fba913c7a8b96de49e1681f7fd11
v1.0
complete
Taco
Taco_52670_C
def is_prime(num): """ Check if a number is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(11) == True >>> is_prime(25) == False """ def next_prime(n): """ Find the smallest prime number greater than n. >>> next_prime(10) == ...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6...
from solution import is_prime, next_prime 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(25) == False def test_next_prime(): assert next_prime(10) == 11 assert next_prime(14) == 17 asser...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Find the smallest prime number greater than n.", "function_declaration": "def next_prime(n):", "function_name": "next_...
[ 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 Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if ...
trial_gpt4o_0
{ "original_instruction": "Write a function that takes an integer `n` as input and returns the smallest integer which is both greater than `n` and a prime number.\n\nConstraints:\n\n- \\( 1 \\leq n \\leq 10^5 \\)\n\nInput\n\nInput is given from standard input in the following format:\n\n```\nn\n```\n\nOutput\n\nPrint...
0.836649
Taco_52670
C
[ "is_prime", "next_prime" ]
2
[ [ "next_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ef4a7e9d6862e1772348524ce2ed900d56b40288
2a888a61cb17cf040b3ad25f8ae4042a2089c239
v1.0
complete
Taco
Taco_52486_C
def compute_grade(average_score): """ Determine the letter grade based on the average score. >>> compute_grade(95) 'A' >>> compute_grade(85) 'B' >>> compute_grade(75) 'C' >>> compute_grade(65) 'D' >>> compute_grade(55) 'F' """ # Implement this function def g...
def compute_grade(average_score): """ Determines the grade based on the average_score. """ if average_score >= 90: return "A" elif average_score >= 80: return "B" elif average_score >= 70: return "C" elif average_score >= 60: return "D" else: retur...
def test_compute_grade(): assert compute_grade(95) == "A" assert compute_grade(85) == "B" assert compute_grade(75) == "C" assert compute_grade(65) == "D" assert compute_grade(55) == "F" def test_generate_report_card(): students_data = [ { "name": "Alice", "scores...
[ { "docstring": "Determines the grade based on the average_score.", "function_declaration": "def compute_grade(average_score):", "function_name": "compute_grade", "parameter_list": "(average_score)" }, { "docstring": "Generates report card for each student based on the input data.", "func...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def compute_average(scores):\n total_score = sum(scores)\n number_of_exams = len(scores)\n return total_score // number_of_exams\n\ndef determine_grade(av...
trial_gpt4o_2
{ "original_instruction": "You are tasked with creating a report card generator for a classroom. Each student has taken multiple exams and you need to compute their average score as well as determine their final grade based on the average.\n\nThe letter grade is assigned based on the following scale:\n- Average score...
0.742336
Taco_52486
C
[ "compute_grade", "generate_report_card" ]
2
[ [ "generate_report_card", "compute_grade" ] ]
1
[]
false
[]
false
pytest
false
[]
true
7bbc6b9a619172010582af859c3faa09b738cf05
500c226a0e23960d32a1048e18b715735e42d81c
v1.0
complete
Taco
Taco_52431_C
MOD = 1000000007 def matrix_mult(A, B, mod=MOD): return [ [ (A[0][0] * B[0][0] + A[0][1] * B[1][0]) % mod, (A[0][0] * B[0][1] + A[0][1] * B[1][1]) % mod, ], [ (A[1][0] * B[0][0] + A[1][1] * B[1][0]) % mod, (A[1][0] * B[0][1] + A[1][1] * B[1][1...
MOD = 1000000007 def matrix_mult(A, B, mod=MOD): return [ [ (A[0][0] * B[0][0] + A[0][1] * B[1][0]) % mod, (A[0][0] * B[0][1] + A[0][1] * B[1][1]) % mod, ], [ (A[1][0] * B[0][0] + A[1][1] * B[1][0]) % mod, (A[1][0] * B[0][1] + A[1][1] * B[1][1...
from solution import matrix_exponentiation def test_matrix_exponentiation_example1(): assert matrix_exponentiation(2, 3, 4, 5, 2) == (16, 21, 28, 37) def test_matrix_exponentiation_example2(): assert matrix_exponentiation(1, 1, 1, 0, 5) == (8, 5, 5, 3) def test_matrix_exponentiation_identity(): assert ma...
[ { "docstring": null, "function_declaration": "def matrix_mult(A, B, mod=MOD):", "function_name": "matrix_mult", "parameter_list": "(A, B, mod=MOD)" }, { "docstring": null, "function_declaration": "def matrix_pow(M, n, mod=MOD):", "function_name": "matrix_pow", "parameter_list": "...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 1000000007\n\ndef matrix_mult(A, B):\n \"\"\"\n Multiplies two 2x2 matrices A and B and returns the result modulo MOD.\n \"\"\"\n return [\n ...
trial_gpt4o_2
{ "original_instruction": "Fibonacci matrices are used in several areas of mathematics and algorithms, notably optimization.\n\nGiven a 2x2 matrix M with elements:\n```\nM = [a, b]\n [c, d]\n```\nYou can calculate the nth power of M, denoted as M^n. To raise this matrix to the nth power efficiently, use matrix exp...
0.635884
Taco_52431
C
[ "matrix_mult", "matrix_pow", "matrix_exponentiation" ]
3
[ [ "matrix_exponentiation", "matrix_pow" ], [ "matrix_pow", "matrix_mult" ] ]
2
[]
false
[]
false
pytest
true
[]
true
561253fc7a7085e4859ef5d33ca5921228f3f107
af6e3d3c19573f7001447beabafb6231a9a37f88
v1.0
complete
Taco
Taco_52621_C
def sum_of_squares_of_digits(n: int) -> int: """ Returns the sum of the squares of the digits of a given number n. >>> sum_of_squares_of_digits(19) 82 >>> sum_of_squares_of_digits(82) 68 >>> sum_of_squares_of_digits(68) 100 >>> sum_of_squares_of_digits(100) 1 """ pass def is...
def sum_of_squares_of_digits(n): """ Returns the sum of the squares of the digits of a given number n. """ return sum(int(digit) ** 2 for digit in str(n)) def is_happy_number(n): """ Determines if a number n is a happy number. """ seen = set() while n != 1 and n not in seen: ...
from solution import sum_of_squares_of_digits, is_happy_number, number_chains def test_sum_of_squares_of_digits(): assert sum_of_squares_of_digits(19) == 82 assert sum_of_squares_of_digits(82) == 68 assert sum_of_squares_of_digits(68) == 100 assert sum_of_squares_of_digits(100) == 1 def test_is_happy_...
[ { "docstring": "Returns the sum of the squares of the digits of a given number n.", "function_declaration": "def sum_of_squares_of_digits(n):", "function_name": "sum_of_squares_of_digits", "parameter_list": "(n)" }, { "docstring": "Determines if a number n is a happy number.", "function_...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_squares_of_digits(n):\n \"\"\"\n Returns the sum of the squares of the digits of a given number n.\n \"\"\"\n return sum(int(digit) ** 2 for...
trial_gpt4o_0
{ "original_instruction": "You have a group of friends who enjoy playing a game they created called \"Number Chains.\" The game works as follows: start with a non-negative integer n, and repeatedly sum the squares of its digits to form a new number until the process eventually results in the number 1, or it enters a ...
0.592261
Taco_52621
C
[ "sum_of_squares_of_digits", "is_happy_number", "number_chains" ]
3
[ [ "is_happy_number", "sum_of_squares_of_digits" ], [ "number_chains", "is_happy_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2a853b2829bba1ebea4741590936d1ca36371af1
e91d1cac8c8fe62e222ae2ca14c49a418f95349e
v1.0
complete
Taco
Taco_52688_C
def sieve(n): """Return a list of primes up to n using Sieve of Eratosthenes algorithm.""" pass def find_prime_pairs(n): """ Find all unique pairs of prime numbers (p, q) such that p < q and p + q = given even number n. >>> find_prime_pairs(10) 2 (3, 7) (5, 5) >>> find_prime_pairs(...
def sieve(n): """Return a list of primes up to n using Sieve of Eratosthenes algorithm.""" is_prime = [True] * (n + 1) p = 2 while p * p <= n: if is_prime[p]: for i in range(p * p, n + 1, p): is_prime[i] = False p += 1 return [p for p in range(2, n + 1) if...
from solution import find_prime_pairs def test_find_prime_pairs_case_10(capfd): find_prime_pairs(10) out, err = capfd.readouterr() assert out == "2\n(3, 7)\n(5, 5)\n" def test_find_prime_pairs_case_18(capfd): find_prime_pairs(18) out, err = capfd.readouterr() assert out == "2\n(5, 13)\n(7, 11)...
[ { "docstring": "Return a list of primes up to n using Sieve of Eratosthenes algorithm.", "function_declaration": "def sieve(n):", "function_name": "sieve", "parameter_list": "(n)" }, { "docstring": "Find all unique pairs of prime numbers (p, q) such that p < q and p + q = n.", "function_...
[ 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 sieve(n):\n \"\"\"\n Sieve of Eratosthenes to generate all prime numbers up to n.\n \"\"\"\n is_prime = [True] * (n + 1)\n is_prime[0], is_prime...
trial_gpt4o_1
{ "original_instruction": "Alyssa is studying prime numbers in her discrete mathematics class and has come across an interesting problem. She wants to create a program that finds all unique pairs of prime numbers (p, q) such that p < q and p + q = given even number n. \n\nYour task is to help Alyssa by writing a prog...
0.688617
Taco_52688
C
[ "sieve", "find_prime_pairs" ]
2
[ [ "find_prime_pairs", "sieve" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f4202d9cd086dadc420457c44f1f165b60bde0f7
02087b56d3d51e1d845a3ecb690eea0fc6bcca47
v1.0
complete
Taco
Taco_52738_C
def min_path_cost(matrix): """ Computes the minimum cost to move from the top-left to the bottom-right corner of the matrix only moving right or down. Args: matrix: List of List of int: A 2D list representing the cost matrix Returns: int: The minimum path cost from top-left to bott...
def min_path_cost(matrix): """ Computes the minimum cost to move from the top-left to the bottom-right corner of the matrix only moving right or down. """ if not matrix or not matrix[0]: return 0 m, n = len(matrix), len(matrix[0]) dp = [[0 for _ in range(n)] for _ in range(m)] ...
def test_min_path_cost(): matrix = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert min_path_cost(matrix) == 7 def test_min_path_cost_single_row(): matrix = [ [1, 2, 3] ] assert min_path_cost(matrix) == 6 def test_min_path_cost_single_column(): matrix = [ ...
[ { "docstring": "Computes the minimum cost to move from the top-left to the bottom-right corner\nof the matrix only moving right or down.", "function_declaration": "def min_path_cost(matrix):", "function_name": "min_path_cost", "parameter_list": "(matrix)" }, { "docstring": null, "functio...
[ 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_cost_path(m, n, matrix):\n # Create a 2D dp array\n dp = [[0] * n for _ in range(m)]\n \n # Initialize the starting point\n dp[0][0] = matri...
trial_gpt4o_4
{ "original_instruction": "Given an m x n matrix, where each element of the matrix represents the cost to step on that cell, find the minimum cost to go from the top-left cell to the bottom-right cell. You can only move right or down from a given cell.\n\nCreate a program that finds this minimum path cost.\n\n**Input...
0.649107
Taco_52738
C
[ "min_path_cost", "read_input_and_compute_min_cost" ]
2
[ [ "read_input_and_compute_min_cost", "min_path_cost" ] ]
1
[]
false
[]
false
pytest
false
[]
true
69931e5757e8c5146093a554ab1bab440d630de8
70eb79ec7b14292e2af5932e650bb4a36b78adb5
v1.0
complete
Taco
Taco_52828_C
def process_input_and_find_max_areas(input_data: str) -> List[int]: """ Processes the input data to find the maximum area of rectangular regions in the grid where all cells have the same height for multiple test cases. >>> process_input_and_find_max_areas("2\\n3 3\\n1 2 1\\n2 2 2\\n1 2 1\\n4 5\\n3 3 3...
def max_rect_area(grid, N, M): """ Function to find the maximum area of a rectangular region in the grid where all cells have the same height. """ max_area = 0 for height in range(101): # Since heights are between 0 and 100 # Transform the grid into a binary matrix where 1 represents cells ...
from solution import process_input_and_find_max_areas def test_case_1(): input_data = "2\n3 3\n1 2 1\n2 2 2\n1 2 1\n4 5\n3 3 3 3 3\n3 3 3 3 3\n3 3 3 3 3\n3 3 3 3 3" expected_output = [3, 20] assert process_input_and_find_max_areas(input_data) == expected_output def test_single_row(): input_data = "1\n...
[ { "docstring": "Function to find the maximum area of a rectangular region in the grid where all cells have the same height.", "function_declaration": "def max_rect_area(grid, N, M):", "function_name": "max_rect_area", "parameter_list": "(grid, N, M)" }, { "docstring": "Given a binary matrix,...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_area_same_height(grid):\n from collections import defaultdict\n max_area = 0\n n = len(grid)\n m = len(grid[0])\n heights = defaultdict(list...
trial_gpt4o_2
{ "original_instruction": "You are given a grid with N rows and M columns filled with non-negative integers. The grid represents a landscape where each cell has a height value.\n\nYour task is to find the maximum area of a rectangular region in the grid, such that all the cells in the region have the same height.\n\n...
0.68501
Taco_52828
C
[ "max_rect_area", "max_histogram_area", "largest_rectangle_area", "process_input_and_find_max_areas" ]
4
[ [ "max_histogram_area", "largest_rectangle_area" ], [ "max_rect_area", "max_histogram_area" ], [ "process_input_and_find_max_areas", "max_rect_area" ] ]
3
[]
false
[]
false
pytest
true
[]
true
f89c5b902bd4ec62ca4b8c3d0201ef0b1ca811f7
e08b192dc3fc0a9027b3e98c95169852d0727044
v1.0
complete
Taco
Taco_52671_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def sorted_array_to_bst(nums): """ Convert sorted array to balanced binary search tree. """ pass def inorder_traversal(root): """ Perform ino...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def sorted_array_to_bst(nums): """ Convert sorted array to balanced binary search tree. """ if not nums: return None mid = len(nums) // 2 ...
from solution import create_balanced_bst_and_inorder_traversal def test_example_case(): assert create_balanced_bst_and_inorder_traversal([3, 1, 4, 1, 5, 9, 2]) == [1, 1, 2, 3, 4, 5, 9] def test_single_element(): assert create_balanced_bst_and_inorder_traversal([1]) == [1] def test_two_elements(): assert ...
[]
[ 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": "class TreeNode:\n def __init__(self, key):\n self.left = None\n self.right = None\n self.val = key\n\ndef sorted_array_to_bst(nums):\n \...
trial_gpt4o_2
{ "original_instruction": "You are provided with an array of integers. Your task is to create a balanced binary tree from this array and then perform in-order traversal on the tree. \n\nA balanced binary tree is a binary tree in which the depth of the two subtrees of every node never differ by more than one. The in-o...
0.669056
Taco_52671
C
[ "sorted_array_to_bst", "inorder_traversal", "create_balanced_bst_and_inorder_traversal" ]
3
[ [ "create_balanced_bst_and_inorder_traversal", "inorder_traversal" ], [ "create_balanced_bst_and_inorder_traversal", "sorted_array_to_bst" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
01e0a76c96e63c09052ad38231a2cb3d2319e3c5
d8ae5d565c8ad4389d83665215902a1e803e7cc9
v1.0
complete
Taco
Taco_52700_C
def get_max_last_edge_weight_before_disconnect(n: int, m: int, edge_list: List[Tuple[int, int, int]]) -> int: """ Given a connected undirected graph G with n nodes and m edges, determine the maximum weight of an edge that could be the last edge picked before the graph becomes disconnected if two players (Al...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: parent[r...
def test_get_max_last_edge_weight_before_disconnect_example1(): n = 4 m = 5 edges = [ (1, 2, 3), (1, 3, 2), (2, 3, 1), (2, 4, 4), (3, 4, 5) ] result = get_max_last_edge_weight_before_disconnect(n, m, edges) assert result == 4 def test_get_max_last_edge_we...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nimport networkx as nx\n\ndef max_last_edge_weight(n, m, edges):\n \"\"\"\n Determines the maximum weight of an edge that could be\n the last...
trial_gpt4o_2
{ "original_instruction": "You are given a connected undirected graph G with n nodes and m edges. Each edge has a weight associated with it. Two players, Alice and Bob, are playing a game on this graph. They take turns choosing an edge and removing it from the graph. Alice always goes first. The player who makes the ...
0.630813
Taco_52700
C
[ "find", "union", "kruskal_mst_max_edge", "get_max_last_edge_weight_before_disconnect" ]
4
[ [ "get_max_last_edge_weight_before_disconnect", "kruskal_mst_max_edge" ], [ "kruskal_mst_max_edge", "find" ], [ "kruskal_mst_max_edge", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
07eda2c036263e4bb6710e30f9eb93661eb2fed8
e5890bac29610e75ed035d816f1d67cdc98f9dc5
v1.0
complete
Taco
Taco_52794_C
def max_values_for_orders(n, m, items, orders): """ Determine the maximum value of items that can be picked for each order without exceeding the weight capacity of the cart. Parameters: n (int): The number of items in the warehouse. m (int): The number of orders. items (List[Tuple[int...
def knapsack(values, weights, n, W): dp = [0] * (W + 1) for i in range(n): for w in range(W, weights[i] - 1, -1): dp[w] = max(dp[w], dp[w - weights[i]] + values[i]) return dp[W] def max_values_for_orders(n, m, items, orders): results = [] for k, w in orders: ...
from solution import main def test_example_case_1(): n, m = 5, 2 items = [(2, 3), (3, 4), (4, 5), (5, 6), (6, 7)] orders = [(3, 10), (2, 5)] result = main(n, m, items, orders) assert result == [12, 7] def test_single_item_case(): n, m = 1, 1 items = [(5, 10)] orders = [(1, 5)] resu...
[ { "docstring": null, "function_declaration": "def knapsack(values, weights, n, W):", "function_name": "knapsack", "parameter_list": "(values, weights, n, W)" }, { "docstring": null, "function_declaration": "def max_values_for_orders(n, m, items, orders):", "function_name": "max_value...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def knapsack_max_value(items, k, W):\n \"\"\"\n Calculate the maximum value of items that can be picked without exceeding the weight capacity.\n\n :param ...
trial_gpt4o_7
{ "original_instruction": "You are working on a warehouse management system where orders need to be fulfilled by picking items from shelves. The warehouse consists of multiple shelves, each containing multiple items. Each item has a specific weight and value. Given the weight capacity of a cart used for picking items...
0.621422
Taco_52794
C
[ "knapsack", "max_values_for_orders", "main" ]
3
[ [ "max_values_for_orders", "knapsack" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f6a91d4057bedb86be6fd17058b0ab184e14fa12
ade56476486662035d6ccf5981f6572b87986934
v1.0
complete
Taco
Taco_53003_C
def lcm(a, b): """ Function to compute the Least Common Multiple (LCM) of two numbers. """ return a * b // gcd(a, b) def smallestMultiple(n): """ Returns the smallest number that is divisible by all integers from 1 to n. """
from math import gcd def lcm(a, b): """ Function to compute the Least Common Multiple (LCM) of two numbers. """ return a * b // gcd(a, b) def smallestMultiple(n): """ Returns the smallest number that is divisible by all integers from 1 to n. """ multiple = 1 for i in range(1, n + 1...
from solution import smallestMultiple def test_smallestMultiple_1(): assert smallestMultiple(1) == 1 def test_smallestMultiple_2(): assert smallestMultiple(2) == 2 def test_smallestMultiple_3(): assert smallestMultiple(3) == 6 def test_smallestMultiple_4(): assert smallestMultiple(4) == 12 def test...
[ { "docstring": "Function to compute the Least Common Multiple (LCM) of two numbers.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the smallest number that is divisible by all integers from 1 to n.", "function_dec...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import gcd\n\ndef lcm(a, b):\n \"\"\"\n Compute the least common multiple of two numbers a and b.\n \"\"\"\n return a * b // gcd(a, b)\n\ndef...
trial_gpt4o_2
{ "original_instruction": "Design a function that calculates the smallest possible number that is divisibly by all integers from 1 to n (also known as the least common multiple of the set {1, 2, ..., n}).\n\nExample 1:\nInput:\nn = 5\nOutput: 60\nExplanation: The smallest number that is divisibly by all numbers from ...
0.717739
Taco_53003
C
[ "lcm", "smallestMultiple" ]
2
[ [ "smallestMultiple", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8537728c4cbad67114d7d5e675f4280efbac390a
2b27f35e5509c2f5ea729a1e1fefcfa9a533ba0e
v1.0
complete
Taco
Taco_52602_C
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def insert_level_order(arr, root, i, n): """ Helper function to insert nodes in the binary tree at the correct position in level order """ if i < n: temp = TreeNode(arr[i]) if arr[i] is no...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def insert_level_order(arr, root, i, n): if i < n: temp = TreeNode(arr[i]) if arr[i] is not None else None root = temp if temp is not None: root.left = insert_level...
import pytest from solution import TreeNode, sumEvenGrandparent, insert_level_order def test_sumEvenGrandparent_example_1(): arr = [6, 7, 8, 2, 7, 1, 3, 9, None, 1, 4, None, None, None, 5] assert sumEvenGrandparent(arr) == 18 def test_sumEvenGrandparent_example_2(): arr = [1, 2, 3, 4, 5, 6, 7] assert ...
[]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef insert_level_order(arr, root, i, n):\...
trial_gpt4o_0
{ "original_instruction": "Given a binary tree, write a function to calculate the sum of the nodes with even-valued grandparents. A node’s grandparent is the parent of its parent if it exists.\n\n-----Input-----\n\nThe input will be in the format of an array representation of a binary tree, where `None` represents a ...
0.583402
Taco_52602
C
[ "insert_level_order", "sumEvenGrandparent", "sumEvenGrandparentUtil" ]
3
[ [ "sumEvenGrandparent", "insert_level_order" ], [ "sumEvenGrandparent", "sumEvenGrandparentUtil" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
cbe79b1889bf6ce563895b91bbc5890c426c5091
036fad204d25c0567f09aa93b5ca50cf1933a230
v1.0
complete
Taco
Taco_53015_C
def is_palindrome(s: str) -> str: """Returns 'YES' if the string s is a palindrome, otherwise returns 'NO'. >>> is_palindrome("radar") == 'YES' >>> is_palindrome("hello") == 'NO' """ def check_palindromes(strings: List[str]) -> List[str]: """Takes a list of strings and returns a list of results...
def is_palindrome(s): """ Returns 'YES' if the string s is a palindrome, otherwise returns 'NO'. """ return 'YES' if s == s[::-1] else 'NO' def check_palindromes(strings): """ Takes a list of strings and returns a list of results ('YES' or 'NO') for each string. """ results = [] for...
from solution import is_palindrome, check_palindromes def test_is_palindrome(): assert is_palindrome("radar") == 'YES' assert is_palindrome("hello") == 'NO' assert is_palindrome("level") == 'YES' assert is_palindrome("world") == 'NO' assert is_palindrome("a") == 'YES' assert is_palindrome("") =...
[ { "docstring": "Returns 'YES' if the string s is a palindrome, otherwise returns 'NO'.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Takes a list of strings and returns a list of results ('YES' or 'NO') for eac...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Returns 'YES' if the string s is a palindrome, otherwise 'NO'.\n \"\"\"\n return \"YES\" if s == s[::-1] else \"NO\"\n...
trial_gpt4o_2
{ "original_instruction": "John loves palindromes for their symmetry. A palindrome is a word, number, phrase, or other sequences of characters which reads the same backward as forward.\n\nJohn has a list of N strings, and for each string, he wants to find out if it is a palindrome or not. Since John is busy reading a...
0.850351
Taco_53015
C
[ "is_palindrome", "check_palindromes" ]
2
[ [ "check_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ca455fd99a904b2cd0406bf4a58d0082b76cee41
5f971187ccb2f85227f40cdb24c17f7831ef10dd
v1.0
complete
Taco
Taco_52904_C
def is_prime(n: int) -> bool: """ Determine if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(11) True >>> is_prime(25) False >>> is_prime(1) False """ pass def sum_of_primes(numbers: tuple) -> int: """...
def is_prime(n): """ Determine if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def sum_of_primes(numbers): ...
from solution import sum_of_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(25) == False assert is_prime(1) == False def test_sum_of_primes_example1(): numbers = (3, 4, 2, 7,...
[ { "docstring": "Determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the given tuple of numbers.", "function_declaration": "def sum_of_primes(numbers):...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n ...
trial_gpt4o_0
{ "original_instruction": "Given a tuple of integers, your task is to return the sum of all elements that are prime numbers.\n\nExample 1:\nInput:\nnumbers = (3, 4, 2, 7, 8)\nOutput:\n12\nExplanation:\nThe prime numbers in the given tuple are 3, 2, and 7. Their sum is 3 + 2 + 7 = 12.\n\nExample 2:\nInput:\nnumbers = ...
0.766904
Taco_52904
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
27cf42087d6125893f4914253ed7f9059e9a02e8
3d8f3ea3d562f929b75aa7cd0cf7873f2f7d2dc1
v1.0
complete
Taco
Taco_52943_C
from typing import List def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. """ pass def filter_primes(numbers: List[int]) -> List[int]: """ Write a function that takes a list of integers as input and returns a list containing only the prime numbers from the inpu...
def is_prime(num): """ Helper function to 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...
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(-5) == False assert is_prime(0) == False assert is_prime(1) == Fal...
[ { "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 a list containing only the prime numbers from the input list.", "function_declaration": "def fi...
[ 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 <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_1
{ "original_instruction": "Write a function that takes a list of integers as input and returns a list containing only the prime numbers from the input list.\n\nA number is prime if it is greater than 1 and has no divisors other than 1 and itself. Your function should iterate through the input list, check each element...
0.744777
Taco_52943
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
eba44cb32f6e1d81df54db370635a41db2328dde
5dbad3aac9c637e553ee9120aca3cacd4d11b11b
v1.0
complete
Taco
Taco_52762_C
from typing import List, Tuple def max_possible_depth(n: int, edges: List[Tuple[int, int]]) -> int: """ You are given a tree consisting of n nodes. A tree is a connected undirected graph with n-1 edges. Each node is labeled with a unique integer from 1 to n. The depth of a node in the tree is the number of ...
from collections import defaultdict, deque def find_max_depth_after_operation(n, edges): def bfs(start_node): queue = deque([start_node]) depths = {start_node: 0} visited = {start_node} while queue: node = queue.popleft() for neighbor in adjacency_li...
from solution import max_possible_depth def test_max_possible_depth_case1(): assert max_possible_depth(4, [(1, 2), (2, 3), (2, 4)]) == 2 def test_max_possible_depth_case2(): assert max_possible_depth(6, [(1, 2), (1, 3), (3, 4), (3, 5), (5, 6)]) == 4 def test_max_possible_depth_case3(): assert max_possibl...
[ { "docstring": null, "function_declaration": "def find_max_depth_after_operation(n, edges):", "function_name": "find_max_depth_after_operation", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def max_possible_depth(n, edges):", "function_name": "max_p...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_max_depth(n, edges):\n from collections import defaultdict, deque\n \n def bfs(start_node):\n distances = [-1] * (n + 1)\n queue = ...
trial_gpt4o_8
{ "original_instruction": "You are given a tree consisting of n nodes. A tree is a connected undirected graph with n-1 edges. Each node is labeled with a unique integer from 1 to n. The depth of a node in the tree is the number of edges from the node to the root (node 1).\n\nYour task is to find the maximum possible ...
0.625763
Taco_52762
C
[ "find_max_depth_after_operation", "max_possible_depth" ]
2
[ [ "max_possible_depth", "find_max_depth_after_operation" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e120ac7a16b95445046da66b377b3f2ebf02167f
01ef824f2481ceb59fb4329ba01da466b9da18bf
v1.0
complete
Taco
Taco_52634_C
def process_input(input_lines): """ Processes the input lines and returns the sorted achievements Args: input_lines: list of str, the input lines Returns: list: sorted list of tuples, each containing (str, list of str) """ pass def sort_programmers_achievements(programmers_inf...
def sort_programmers_achievements(programmers_info): """ Given a list of programmers and their achievements, sorts the programmers by name and their achievements lexicographically. Args: programmers_info: list of tuples, each containing (str, int, list of str) - str: programmer's name ...
from solution import process_input, sort_programmers_achievements, display_sorted_achievements def test_example_case(): input_lines = [ "3", "alice 3 hackathon_leader top_coder open_source_contributor", "bob 2 ai_researcher robotics_spirit", "charlie 1 bug_finder" ] expected...
[ { "docstring": "Given a list of programmers and their achievements, sorts the programmers\nby name and their achievements lexicographically.\n\nArgs:\nprogrammers_info: list of tuples, each containing (str, int, list of str)\n - str: programmer's name\n - int: number of achievements\n - list of str: th...
[ 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 list_achievements(programmers):\n \"\"\"\n Given a list of programmers and their achievements, return a list of strings with each programmer's\n name ...
trial_gpt4o_1
{ "original_instruction": "The city of Techville is planning to set a new world record in constructing a \"Digital Wall of Fame\". A list of achievements by several programmers are to be engraved on this wall, but there is a catch. Each programmer's name will be engraved along with their achievements in lexicographic...
0.612522
Taco_52634
C
[ "sort_programmers_achievements", "display_sorted_achievements", "process_input" ]
3
[ [ "process_input", "sort_programmers_achievements" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
637c3192a071ad5e3b4d17eb573c7b240f2e643f
9077bbe37d99de18f839612b5ac320e8a4b2e91e
v1.0
complete
Taco
Taco_53085_C
def shortest_paths(cities, roads, queries): """ Calculate the shortest paths between pairs of cities based on the given road network and queries. Parameters: cities (tuple): A tuple containing the number of cities and number of roads roads (list of tuple): A list of tuples with each tuple cont...
def floyd_warshall(n, roads): """ Function to compute shortest paths using Floyd-Warshall algorithm. """ # Initialize distance matrix inf = float('inf') dist = [[inf] * (n + 1) for _ in range(n + 1)] # Distance from a city to itself is 0 for i in range(1, n + 1): dist[i][i] ...
from solution import shortest_paths def test_single_dataset(): cities = (4, 4) roads = [ (1, 2, 4), (1, 3, 2), (2, 3, 1), (3, 4, 1) ] queries = [ (1, 4), (2, 4) ] result = shortest_paths(cities, roads, queries) assert result == [3, 2] def tes...
[ { "docstring": "Function to compute shortest paths using Floyd-Warshall algorithm.", "function_declaration": "def floyd_warshall(n, roads):", "function_name": "floyd_warshall", "parameter_list": "(n, roads)" }, { "docstring": "Function to find shortest paths for multiple queries.", "func...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def floyd_warshall(n, roads):\n \"\"\"\n Implements the Floyd-Warshall algorithm to find the shortest paths between all pairs of cities.\n \"\"\"\n inf...
trial_gpt4o_3
{ "original_instruction": "In a faraway land named Graphonia, there is a kingdom with several cities connected by bidirectional roads. Each road has a specific travel time associated with it. The king of Graphonia, King Algorithmar, has a special interest in the shortest paths between cities. He frequently sends his ...
0.760431
Taco_53085
C
[ "floyd_warshall", "shortest_paths" ]
2
[ [ "shortest_paths", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
true
[]
true
999d57617b77468271d0025c3fd0d013b042af2c
7e1201791755f0c64ebb0f6cdf7f48b1f8f3ff36
v1.0
complete
Taco
Taco_53053_C
def process_image_data(M: int, N: int, image: List[List[int]], Q: int, adjustments: List[Tuple[int, int, int]]) -> List[List[int]]: """ Adjust the brightness of the image according to the given adjustments. Parameters: M (int): Number of rows in the image. N (int): Number of columns in the imag...
def adjust_brightness(image, adjustments): """ Adjust the brightness of the image according to the given adjustments. Parameters: image (list of list of int): M x N matrix representing the image's pixel values. adjustments (list of tuple): List of adjustments (a, b, k). Returns: li...
def test_single_adjustment(): M, N = 3, 3 image = [ [10, 20, 30], [40, 50, 60], [70, 80, 90] ] Q = 1 adjustments = [(1, 2, 10)] expected_output = [ [20, 30, 40], [50, 60, 70], [70, 80, 90] ] from solution import process_image_data ...
[ { "docstring": "Adjust the brightness of the image according to the given adjustments.\n\nParameters:\nimage (list of list of int): M x N matrix representing the image's pixel values.\nadjustments (list of tuple): List of adjustments (a, b, k).\n\nReturns:\nlist of list of int: The adjusted image.", "functi...
[ 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 adjust_brightness(image, adjustments):\n \"\"\"\n Adjusts the brightness of the image based on the list of adjustments.\n \n :param image: List of ...
trial_gpt4o_5
{ "original_instruction": "You are required to write a program to help Alice with her image processing task. Alice has an image represented as an M x N matrix of pixel values, where each pixel value is a positive integer. She needs to adjust the brightness of the image by increasing or decreasing the pixel values acc...
0.5976
Taco_53053
C
[ "adjust_brightness", "process_image_data" ]
2
[ [ "process_image_data", "adjust_brightness" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a6f8ac5d760e701bc1ad7796c6335c29e68f3e69
ebf0e2ba95fa9a8adc6a4a1a002eedec8f0520b6
v1.0
complete
Taco
Taco_53056_C
from typing import List, Tuple def handle_queries(n: int, values: List[int], edges: List[Tuple[int, int]], q: int, queries: List[int]) -> List[str]: """ Given a tree with `n` nodes and node values, determine if specified nodes are "balanced". A node is "balanced" if the sum of values in its left subtree i...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None self.subtree_sum = value def calculate_subtree_sums(node): if node is None: return 0 left_sum = calculate_subtree_sums(node.left) right_sum = calculate_subtree_sums(n...
from solution import handle_queries def test_sample_input_1(): n = 5 values = [1, 2, 3, 4, 5] edges = [ (1, 2), (1, 3), (3, 4), (3, 5) ] q = 2 queries = [3, 2] expected_output = ["NO", "YES"] assert handle_queries(n, values, edges, q, queries) == expected...
[]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.children = []\n\ndef build_tree(values, edges):\n nodes = [TreeNode(va...
trial_gpt4o_1
{ "original_instruction": "Given a tree with `n` nodes, where each node is assigned a value. A node is considered \"balanced\" if the sum of values in its left subtree is equal to the sum of values in its right subtree. \n\nYou need to write a program that processes `q` queries, each of which will require you to dete...
0.642873
Taco_53056
C
[ "calculate_subtree_sums", "is_balanced", "construct_tree", "process_queries", "handle_queries" ]
5
[ [ "construct_tree", "calculate_subtree_sums" ], [ "handle_queries", "construct_tree" ], [ "handle_queries", "process_queries" ], [ "process_queries", "is_balanced" ] ]
4
[ "process_queries", "handle_queries" ]
false
[ "TreeNode" ]
true
pytest
true
[]
true
74ea2fac5722f89ad89c78f3b732a3b3a496ea1b
56e84887770984142debdef546244e86c41acca7
v1.0
complete
Taco
Taco_53460_C
def process_call_records(input_data: str) -> dict: """ Processes call records and calculates total call durations for each person. Args: input_data (str): The input data string representing call records. Returns: dict: Dictionary with names as keys and total call duration as values, sorted by ...
def calculate_total_call_durations(records): """ Calculates the total call duration for each person (both as a caller and recipient). Args: records (list of tuple): List of tuples where each tuple contains caller's name, recipient's name, and call duration. Returns: dict: Dictionary with names...
from solution import process_call_records def test_process_call_records_sample_input(): input_data = "5\nAlice Bob 10\nBob Alice 15\nAlice Charlie 20\nCharlie Alice 5\nBob Charlie 30" expected_output = {"Alice": 50, "Bob": 55, "Charlie": 55} assert process_call_records(input_data) == expected_output def t...
[ { "docstring": "Calculates the total call duration for each person (both as a caller and recipient).\n\nArgs:\nrecords (list of tuple): List of tuples where each tuple contains caller's name, recipient's name, and call duration.\n\nReturns:\ndict: Dictionary with names as keys and total call duration as values....
[ 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 total_call_durations(n, call_records):\n \"\"\"\n Calculate the total call duration of each person involved in the call records.\n\n Args:\n n (int...
trial_gpt4o_2
{ "original_instruction": "To help the Secret Service identify potential security threats, you've been given a task to analyze a list of phone call records. Each record contains the caller, the recipient, and the duration of the call in minutes. Your task is to find out the total call duration for each person (both a...
0.558902
Taco_53460
C
[ "calculate_total_call_durations", "process_call_records" ]
2
[ [ "process_call_records", "calculate_total_call_durations" ] ]
1
[]
false
[]
false
pytest
true
[]
true
290d3c6ae7c0c3a49b713e43990d7e4585850318
ffa81b7074156c973a2458fb84003dcfbeea2f15
v1.0
complete
Taco
Taco_53643_C
def check_palindrome(s: str) -> str: """ Determines if the given string is a palindrome, considering only alphanumeric characters and ignoring case. >>> check_palindrome("A man, a plan, a canal: Panama") "YES" >>> check_palindrome("race a car") "NO" """
def is_palindrome(s): """ Determines if the given string is a palindrome, considering only alphanumeric characters and ignoring case. """ # Filter out non-alphanumeric characters and convert to lower case filtered_chars = [char.lower() for char in s if char.isalnum()] # Check if the filtere...
from solution import check_palindrome def test_palindrome_with_punctuation_and_spaces(): assert check_palindrome("A man, a plan, a canal: Panama") == "YES" def test_non_palindrome_with_spaces(): assert check_palindrome("race a car") == "NO" def test_palindrome_single_character(): assert check_palindr...
[ { "docstring": "Determines if the given string is a palindrome, considering only alphanumeric characters and ignoring case.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def ch...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Determine whether the given string is a palindrome, considering only alphanumeric characters and ignoring case.\n \n :...
trial_gpt4o_2
{ "original_instruction": "Given a string s, write a program to determine whether it is a palindrome, considering only alphanumeric characters and ignoring case.\n\nInput\n\nThe input contains a single line with a string s (1 ≤ |s| ≤ 105).\n\nOutput\n\nOutput \"YES\" if the given string is a palindrome, otherwise out...
0.91342
Taco_53643
C
[ "is_palindrome", "check_palindrome" ]
2
[ [ "check_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
770091c563caa9d066d8839ad80eb3dfb2023ef2
12867c7bb7bcdf29ca21ac015a73efae2d8c58ac
v1.0
complete
Taco
Taco_53422_C
from collections import defaultdict from typing import List, Tuple def solve(n: int, values: List[int], edges: List[Tuple[int, int]], queries: List[int]) -> List[int]: """ You are given an undirected tree with N nodes and N-1 edges. Each node has a value associated with it, and node 1 is considered the r...
import sys from collections import defaultdict, deque def find_subtree_max_values(root, values, adjacency_list): n = len(values) max_values = [0] * n visited = [False] * n def dfs(node): visited[node] = True max_value = values[node] for neighbor in adjacency_list[n...
def test_small_tree(): assert solve( 5, [1, 2, 3, 4, 5], [(1, 2), (1, 3), (2, 4), (3, 5)], [1, 2, 3] ) == [5, 4, 5] def test_medium_tree(): assert solve( 6, [10, 5, 20, 1, 2, 15], [(1, 2), (1, 3), (3, 4), (3, 5), (4, 6)], [3, 4] ) ==...
[ { "docstring": null, "function_declaration": "def find_subtree_max_values(root, values, adjacency_list):", "function_name": "find_subtree_max_values", "parameter_list": "(root, values, adjacency_list)" }, { "docstring": null, "function_declaration": "def solve(n, values, edges, queries):...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_subtree_max_values(N, values, edges, queries):\n from collections import defaultdict, deque\n \n # Create adjacency list for the tree\n tree =...
trial_gpt4o_2
{ "original_instruction": "You are given an undirected tree with N nodes and N-1 edges. Each node has a value associated with it, and node 1 is considered the root of the tree. You are required to answer Q queries on this tree. Each query is of the form:\n\n* Given a node v, find the maximum value of any node in the ...
0.625309
Taco_53422
C
[ "find_subtree_max_values", "solve", "main" ]
3
[ [ "solve", "find_subtree_max_values" ] ]
1
[]
false
[]
false
pytest
false
[]
true
f00d7e12ec75f82b6aea864292b223d429b204c9
fb5c7fb3ba6693e704baf211d3805db83fb9e952
v1.0
complete
Taco
Taco_53585_C
from typing import List def word_exists_in_matrix(matrix: List[List[str]], word: str) -> str: """ Given a 2D matrix of characters and a word, determine if the word exists in the matrix. The word can be constructed from letters of sequentially adjacent cells, where "adjacent" cells are those horizontally or ver...
def exist(board, word): def dfs(board, word, i, j, k): if not 0 <= i < len(board) or not 0 <= j < len(board[0]) or board[i][j] != word[k]: return False if k == len(word) - 1: return True tmp, board[i][j] = board[i][j], '/' found = dfs(board, word, i +...
def test_word_exists_in_matrix_1(): matrix = [ ["A", "B", "C", "E"], ["S", "F", "C", "S"], ["A", "D", "E", "E"] ] word = "ABCCED" assert word_exists_in_matrix(matrix, word) == "YES" def test_word_exists_in_matrix_2(): matrix = [ ["A", "B", "C", "E"], ["S", "F...
[ { "docstring": null, "function_declaration": "def exist(board, word):", "function_name": "exist", "parameter_list": "(board, word)" }, { "docstring": null, "function_declaration": "def word_exists_in_matrix(matrix, word):", "function_name": "word_exists_in_matrix", "parameter_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 exist(board, word):\n \"\"\"\n Determines if the word exists in the 2D board of characters.\n \"\"\"\n\n def backtrack(board, word, visited, i, j, ...
trial_gpt4o_2
{ "original_instruction": "Given a 2D matrix of characters and a word, implement a function to determine if the word exists in the matrix. The word can be constructed from letters of sequentially adjacent cells, where \"adjacent\" cells are those horizontally or vertically neighboring. The same letter cell may not be...
0.640258
Taco_53585
C
[ "exist", "word_exists_in_matrix" ]
2
[ [ "word_exists_in_matrix", "exist" ] ]
1
[]
false
[]
false
pytest
false
[]
true
91c1fc689f6cd775fb243ce50edacdab3a729fd4
dfce142b96f365465687ab811e7a6e3262d0a298
v1.0
complete
Taco
Taco_53794_C
def sum_prime_CSV(csv_content: str) -> int: """ Takes a string representing CSV file content and returns the sum of all prime numbers found in the CSV file. >>> sum_prime_CSV("23,10\n17,19,20\n4,5,6") 64 >>> sum_prime_CSV("8,10\n12,20,24\n4,6,8") 0 >>> sum_prime_CSV("") 0 >>> sum_prime_C...
import csv from math import isqrt def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) ...
from solution import sum_prime_CSV def test_prime_numbers_on_single_line(): csv_content = "23,10,17,19,20" assert sum_prime_CSV(csv_content) == 59 def test_prime_numbers_across_multiple_lines(): csv_content = "23,10\n17,19,20\n4,5,6" assert sum_prime_CSV(csv_content) == 64 def test_no_prime_numbers()...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a string representing CSV file content and returns the sum of all prime numbers found in the CSV f...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def 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_7
{ "original_instruction": "Write a function `sum_prime_CSV()` that takes a string representing a CSV file content, where each row contains numbers separated by commas, and returns the sum of all prime numbers found in the CSV file.\n\nA prime number is a natural number greater than 1 that has no positive divisors oth...
0.600603
Taco_53794
C
[ "is_prime", "sum_prime_CSV" ]
2
[ [ "sum_prime_CSV", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
29bf241faefeb869fe46c1e31ef411dadb82d91e
e9b50a33757ae6615ae4f9c2bb673ec84f3bf839
v1.0
complete
Taco
Taco_53270_C
def max_sum_path_in_forest(T: int, test_cases: List[Tuple[int, List[int], List[Tuple[int, int]]]]) -> List[int]: """ Find the maximum sum of node values in any simple path in the tree. Args: T: Number of test cases. test_cases: A list of test cases, where each test case is a tuple containin...
def dfs_max_sum(node, parent, adj, values): max1, max2 = 0, 0 # top two longest paths from this node for child in adj[node]: if child == parent: continue max_child_sum = dfs_max_sum(child, node, adj, values) if max_child_sum > max1: max1, max2 = max_child_su...
from solution import max_sum_path_in_forest def test_single_test_case(): T = 1 test_cases = [ (3, [1, 2, 3], [(1, 2), (2, 3)]) ] assert max_sum_path_in_forest(T, test_cases) == [6] def test_multiple_test_cases(): T = 2 test_cases = [ (3, [1, 2, 3], [(1, 2), (2, 3)]), (4...
[ { "docstring": null, "function_declaration": "def dfs_max_sum(node, parent, adj, values):", "function_name": "dfs_max_sum", "parameter_list": "(node, parent, adj, values)" }, { "docstring": null, "function_declaration": "def max_sum_path_in_tree(N, values, edges):", "function_name": ...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_path_sum_in_tree(T, test_cases):\n def dfs(node, parent):\n max_single_path, max_top_path = values[node - 1], values[node - 1]\n for neigh...
trial_gpt4o_1
{ "original_instruction": "There is a tree with $N$ nodes and $(N-1)$ edges rooted at node $1$. Each node has a value assigned to it. You need to find the maximum sum of node values in any simple path in the tree.\n\nA simple path is a path that does not revisit any node. \n\n-----Input-----\n- The first line of the ...
0.592946
Taco_53270
C
[ "dfs_max_sum", "max_sum_path_in_tree", "max_sum_path_in_forest" ]
3
[ [ "max_sum_path_in_forest", "max_sum_path_in_tree" ], [ "max_sum_path_in_tree", "dfs_max_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
858a65ee2fb48aacedf490fb9f7681e8e1837b62
81de24260b767cea69b1cc8a3ec94b57760342bd
v1.0
complete
Taco
Taco_53451_C
def min_time_to_destination(N, M, T, vehicles): """ Computes the minimum time required for each vehicle to reach its destination under the given traffic signal rules. :param N: Number of rows in the grid :param M: Number of columns in the grid :param T: Duration traffic signals remain in one st...
from heapq import heappop, heappush def min_time_to_destination(N, M, T, vehicles): """ Computes the minimum time required for each vehicle to reach its destination under the given traffic signal rules. :param N: Number of rows in the grid :param M: Number of columns in the grid :param T: Dura...
def test_min_time_to_destination(): datasets = [ (3, 3, 2, [(1, 1, 3, 3), (2, 1, 2, 3)]), (4, 4, 3, [(1, 1, 4, 4)]) ] expected_output = [ [4, 2], [6] ] assert traffic_simulation(datasets) == expected_output def test_unreachable_destination(): datasets = [ ...
[ { "docstring": "Computes the minimum time required for each vehicle to reach its destination under the given traffic signal rules.\n\n:param N: Number of rows in the grid\n:param M: Number of columns in the grid\n:param T: Duration traffic signals remain in one state before switching to the other\n:param vehicl...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_time_to_destination(N, M, T, vehicles):\n def bfs(sx, sy, dx, dy):\n queue = deque([(sx, sy, 0)])\n visit...
trial_gpt4o_7
{ "original_instruction": "Modern Urban Traffic Simulation\n\nYou are tasked with developing a simulation for a modern urban traffic system where intersections are controlled by traffic signals. The city layout is represented as a grid of streets, with each intersection having a traffic signal that alternates between...
0.577357
Taco_53451
C
[ "min_time_to_destination", "traffic_simulation", "parse_input" ]
3
[ [ "parse_input", "traffic_simulation" ], [ "traffic_simulation", "min_time_to_destination" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
322a8e025d820b7388689e2380653f7114926602
3104c2494f5883283590949bf013c928d85a06a9
v1.0
complete
Taco
Taco_53844_C
def is_palindromic(n: int) -> bool: """ Check if a number n is palindromic. >>> is_palindromic(121) == True >>> is_palindromic(123) == False """ def largest_palindromic_number(A: int, B: int) -> int: """ Returns the largest palindromic number in the range [A, B]. >>> largest_palindr...
def is_palindromic(n): """ Check if a number n is palindromic. """ s = str(n) return s == s[::-1] def largest_palindromic_number(A, B): """ Returns the largest palindromic number in the range [A, B]. """ largest = -1 for number in range(B, A - 1, -1): if is_palindromic(n...
import pytest from solution import is_palindromic, largest_palindromic_number, process_cases def test_is_palindromic(): assert is_palindromic(121) == True assert is_palindromic(123) == False assert is_palindromic(1) == True assert is_palindromic(22) == True def test_largest_palindromic_number(): a...
[ { "docstring": "Check if a number n is palindromic.", "function_declaration": "def is_palindromic(n):", "function_name": "is_palindromic", "parameter_list": "(n)" }, { "docstring": "Returns the largest palindromic number in the range [A, B].", "function_declaration": "def largest_palindr...
[ 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_palindromic(n):\n \"\"\"\n Check if a number is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef largest_palindromic_in_range(A, B)...
trial_gpt4o_2
{ "original_instruction": "Mike is passionate about palindromic numbers. A palindromic number is a number that remains the same when its digits are reversed. For example, 121 is palindromic, but 123 is not. He wants to perform some palindromic checks.\n\nGiven a range of numbers [A, B], compute the largest palindromi...
0.673719
Taco_53844
C
[ "is_palindromic", "largest_palindromic_number", "process_cases" ]
3
[ [ "largest_palindromic_number", "is_palindromic" ], [ "process_cases", "largest_palindromic_number" ] ]
2
[ "process_cases" ]
false
[]
false
pytest
true
[]
true
96edc1ef0dfe7df2e634bb1ccd098a184bd43722
894efdde72ab0a6e0feeb1e01b605a215d7d1e65
v1.0
complete
Taco
Taco_53169_C
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(node_descriptions): nodes = {} for value, left, right in node_descriptions: if value not in nodes: nodes[value] = TreeNode(value) if left != -1...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(node_descriptions): nodes = {} for value, left, right in node_descriptions: if value not in nodes: nodes[value] = TreeNode(value) if left ...
import pytest from solution import calculate_depth, parse_input def test_single_node_tree(): input_data = "1\n1\n1 -1 -1" test_cases = parse_input(input_data) result = calculate_depth(test_cases) assert result == [0] def test_three_node_tree(): input_data = "1\n3\n1 2 3\n2 -1 -1\n3 -1 -1" test...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef build_tree(nodes):\n if ...
trial_gpt4o_2
{ "original_instruction": "Jessie is practicing data structures and has recently come across the concept of trees. She wants to understand the concept of the depth (or height) of a binary tree. To do so, she has posed a problem to herself.\n\nThe problem states:\n\nGiven a binary tree, calculate the depth of the tree...
0.589972
Taco_53169
C
[ "build_tree", "tree_depth", "calculate_depth", "parse_input" ]
4
[ [ "calculate_depth", "build_tree" ], [ "calculate_depth", "tree_depth" ] ]
2
[ "parse_input" ]
false
[ "TreeNode" ]
true
pytest
true
[]
true
a745280529fba264997ac69a701e2ae2368e82ec
7ba0667f1a5c36e4f9fb3e3bfc2b21ee3fd7a426
v1.0
complete
Taco
Taco_53805_C
from typing import List def orchestra_sync_time(N: int, D: List[int]) -> int: """ Returns the time in seconds after which all instruments will play simultaneously again. Given: N : int : Number of instruments D : list of int : Time each instrument needs to complete one full cycle Examples: ...
from math import gcd from functools import reduce def lcm(a, b): """ Returns the least common multiple of a and b. """ return (a * b) // gcd(a, b) def orchestra_sync_time(N, D): """ Returns the time in seconds after which all instruments will play simultaneously again. Args: N : i...
from solution import orchestra_sync_time def test_orchestra_sync_time_case_1(): assert orchestra_sync_time(3, [2, 4, 5]) == 20 def test_orchestra_sync_time_case_2(): assert orchestra_sync_time(1, [10]) == 10 def test_orchestra_sync_time_case_3(): assert orchestra_sync_time(4, [2, 3, 6, 8]) == 24 def tes...
[ { "docstring": "Returns the least common multiple of a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the time in seconds after which all instruments will play simultaneously again.\n\nArgs:\nN : int : Number o...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef lcm(a, b):\n \"\"\"\n Return the least common multiple of a and b.\n \"\"\"\n return abs(a * b) // math.gcd(a, b)\n\ndef find_time_u...
trial_gpt4o_2
{ "original_instruction": "A large orchestra has N instruments. Each instrument i needs exactly D_i seconds to complete one full cycle of playing and resting. Initially, at time 0, all instruments start playing simultaneously.\n\nHow many seconds will pass until all the instruments play simultaneously again?\n\n-----...
0.621089
Taco_53805
C
[ "lcm", "orchestra_sync_time" ]
2
[ [ "orchestra_sync_time", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4c7b16d2bad054e4a3c6aa1862ea3635d92869d6
94ab31c709d592a03278c89e60a351fa698e966c
v1.0
complete
Taco
Taco_53887_C
def fib_mod(n: int) -> int: """ Compute the n-th Fibonacci number efficiently, modulo 10^9 + 7. >>> fib_mod(10) 55 >>> fib_mod(0) 0 >>> fib_mod(1) 1 """ pass # You may use the below unit test cases to validate your solution. from solution import fib_mod def test_sample_input(): assert fib_...
MOD = 10**9 + 7 def matrix_mult(A, B, mod=MOD): """ Multiplies two 2x2 matrices A and B under modulo mod. """ return [ [(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % mod, (A[0][0] * B[0][1] + A[0][1] * B[1][1]) % mod], [(A[1][0] * B[0][0] + A[1][1] * B[1][0]) % mod, (A[1...
from solution import fib_mod def test_sample_input(): assert fib_mod(10) == 55 def test_zero(): assert fib_mod(0) == 0 def test_one(): assert fib_mod(1) == 1 def test_large_number(): # Just some example, as checking the exact large value can be intricate # Using properties like patterns in Fibon...
[ { "docstring": "Multiplies two 2x2 matrices A and B under modulo mod.", "function_declaration": "def matrix_mult(A, B, mod=MOD):", "function_name": "matrix_mult", "parameter_list": "(A, B, mod=MOD)" }, { "docstring": "Performs matrix exponentiation on a 2x2 matrix under modulo mod to find ma...
[ 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 = 10**9 + 7\n\ndef matrix_mult(A, B):\n return [[(A[0][0]*B[0][0] + A[0][1]*B[1][0]) % MOD, (A[0][0]*B[0][1] + A[0][1]*B[1][1]) % MOD],\n [(A[1][...
trial_gpt4o_1
{ "original_instruction": "Alice has just learned about Fibonacci numbers and their properties. Now, Alice is curious about how to find the n-th Fibonacci number efficiently.\n\nShe knows the naive recursive method is too slow for large values of n, so she's asked for your help in writing a program to compute the n-t...
0.684267
Taco_53887
C
[ "matrix_mult", "matrix_pow", "fibonacci", "fib_mod" ]
4
[ [ "fib_mod", "fibonacci" ], [ "fibonacci", "matrix_pow" ], [ "matrix_pow", "matrix_mult" ] ]
3
[]
false
[]
false
pytest
true
[]
true
6e945960dcc885b3459634f7d599476ad5702fff
28f6c5a4c67d4c000c089596be1813b84f11be98
v1.0
complete
Taco
Taco_54007_C
def tsp_solver(input_data: str) -> int: """ Solve the Traveling Salesman Problem for the given input data. The function should take the input data containing the number of delivery locations and the adjacency matrix of distances between locations, and return the minimum sum of distances for a round trip r...
from itertools import permutations def find_min_tsp_cost(n, distance_matrix): min_cost = float('inf') locations = list(range(n)) for perm in permutations(locations[1:]): current_path = [0] + list(perm) + [0] current_cost = 0 for i in range(len(current_path) - 1): ...
from solution import tsp_solver def test_tsp_example_1(): input_data = "4\n0 10 15 20\n10 0 35 25\n15 35 0 30\n20 25 30 0" assert tsp_solver(input_data) == 80 def test_tsp_example_2(): input_data = "3\n0 5 9\n5 0 7\n9 7 0" assert tsp_solver(input_data) == 21 def test_tsp_min_locations(): input_da...
[ { "docstring": null, "function_declaration": "def find_min_tsp_cost(n, distance_matrix):", "function_name": "find_min_tsp_cost", "parameter_list": "(n, distance_matrix)" }, { "docstring": null, "function_declaration": "def tsp_solver(input_data):", "function_name": "tsp_solver", ...
[ 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": "from itertools import permutations\n\ndef tsp(n, distances):\n # Generate all permutations of the nodes except the starting node (node 0)\n nodes = list(rang...
trial_gpt4o_6
{ "original_instruction": "A delivery company is organizing a new route to deliver parcels more efficiently. The logistics team has the task of determining the shortest possible delivery path that visits each delivery location once and returns to the starting point.\n\nThe delivery routes can be represented as an und...
0.601521
Taco_54007
C
[ "find_min_tsp_cost", "tsp_solver" ]
2
[ [ "tsp_solver", "find_min_tsp_cost" ] ]
1
[]
false
[]
false
pytest
true
[]
true
62a5ae7892014bfb1a113a59e54549ee05280079
1672109cb8a90a79de487e3d5a772bca03f1d9d0
v1.0
complete
Taco
Taco_53594_C
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def insert_into_bst(root, val): if root is None: return TreeNode(val) if val < root.val: root.left = insert_into_bst(root.left, val) else: root.right = insert_into_bst(...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def insert_into_bst(root, val): if root is None: return TreeNode(val) if val < root.val: root.left = insert_into_bst(root.left, val) else: root.right = insert_into_bst(...
from solution import findKthSmallest, build_bst_from_preorder def test_kth_smallest(): preorder = [3, 1, 2, 4] k = 2 root = build_bst_from_preorder(preorder) assert findKthSmallest(root, k) == 2 def test_kth_smallest_first_element(): preorder = [3, 1, 2, 4] k = 1 root = build_bst_from_preo...
[]
[ 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, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef insert_into_bst(root, val):\n if r...
trial_gpt4o_0
{ "original_instruction": "You are given a binary search tree (BST) with N nodes, where each node contains an integer value. Given this BST, write a function findKthSmallest that returns the k-th smallest element in the tree.\n\nNote:\n- A Binary Search Tree is a binary tree in which for each node, the value of all t...
0.550272
Taco_53594
C
[ "insert_into_bst", "findKthSmallest", "build_bst_from_preorder" ]
3
[ [ "build_bst_from_preorder", "insert_into_bst" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
9e69687004c6e80968f4208780c9b4422fa78c29
2364951519bb98c12433823afde7c89c459472ee
v1.0
complete
Taco
Taco_54085_C
def message_time(n: int, edges: List[Tuple[int, int]], queries: List[Tuple[int, int]]) -> List[int]: """ Compute the minimum steps required for a message to travel from the sender to the receiver in the company's hierarchy. Args: n (int): Number of employees. edges (List[Tuple[int, int]]): List of ...
from collections import defaultdict, deque def build_tree(n, edges): tree = defaultdict(list) for u, v in edges: tree[u].append(v) tree[v].append(u) return tree def bfs(tree, start): parent = {start: None} depth = {start: 0} q = deque([start]) while q: node = q.popl...
from solution import message_time def test_message_time(): n = 7 edges = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7)] queries = [(4, 5), (6, 7), (4, 7)] result = message_time(n, edges, queries) assert result == [2, 2, 4] def test_message_time_single_employee(): n = 1 edges = [] que...
[ { "docstring": null, "function_declaration": "def build_tree(n, edges):", "function_name": "build_tree", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def bfs(tree, start):", "function_name": "bfs", "parameter_list": "(tree, start)" }, { ...
[ 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 build_tree(n, edges):\n tree = defaultdict(list)\n for u, v in edges:\n tree[u].append(v)\n t...
trial_gpt4o_1
{ "original_instruction": "A company has n employees, each with a unique ID from 1 to n. The company uses a hierarchy represented by a tree structure where each node corresponds to an employee and the root node (employee with ID 1) is the CEO. Each employee except the CEO has exactly one direct manager. \n\nThe CEO o...
0.579703
Taco_54085
C
[ "build_tree", "bfs", "lca", "message_time" ]
4
[ [ "message_time", "bfs" ], [ "message_time", "build_tree" ], [ "message_time", "lca" ] ]
3
[]
false
[]
false
pytest
true
[]
true
ef273caaa7e723f24ad8c469cbd96462647d742e
ac5e99e705f3e1b75bc5db2dd2081f287468ebba
v1.0
complete
Taco
Taco_54191_C
from typing import List def can_form_palindrome(s: str) -> bool: """ Helper function to determine if a palindrome can be formed from the given string. """ # To be implemented pass def construct_palindrome(s: str) -> str: """ Function to construct the lexicographically smallest palindrome f...
from collections import Counter def can_form_palindrome(s): """ Helper function to determine if a palindrome can be formed from the given string. """ counts = Counter(s) odd_count = sum(1 for count in counts.values() if count % 2 != 0) return odd_count <= 1 def construct_palindrome(s): """...
def test_construct_palindrome(): assert construct_palindrome("civic") == "civic" assert construct_palindrome("aabbcc") == "abccba" assert construct_palindrome("abc") == "Impossible" assert construct_palindrome("aaabbb") == "Impossible" assert construct_palindrome("aabb") == "abba" assert constru...
[ { "docstring": "Helper function to determine if a palindrome can be formed from the given string.", "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome", "parameter_list": "(s)" }, { "docstring": "Function to construct the lexicographically smallest 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 smallest_palindrome(S):\n from collections import Counter\n\n count = Counter(S)\n middle = \"\"\n halves = []\n\n for char in sorted(count):\n ...
trial_gpt4o_3
{ "original_instruction": "Sarah is passionate about palindromes. A palindrome is a string that reads the same forward and backward. She wants to create new strings by rearranging the characters of a given string to form a palindrome or determine if it is impossible.\n\nYour task is to help Sarah by constructing a pa...
0.819828
Taco_54191
C
[ "can_form_palindrome", "construct_palindrome", "process_input" ]
3
[ [ "construct_palindrome", "can_form_palindrome" ], [ "process_input", "construct_palindrome" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
784a4a05da610a60d222c16b95d47d566f1495e7
681e4506f0bb6e839ce7e9a31c908480a9bb4364
v1.0
complete
Taco
Taco_53591_C
def schedule_tournament(n: int, m: int, k: int, previous_matches: List[Tuple[int, int]]) -> str: """ Schedule the tournament matches for k rounds such that no match repeats a previously held match and that each employee competes exactly once in each round. Args: n (int): The number of employees. m...
def schedule_tournament(n, m, k, previous_matches): from itertools import combinations, permutations # Create a set of previous matches for quick lookup previous_set = set(map(tuple, previous_matches)) if n % 2 != 0: return "Not possible" # Helper function to generate matches ...
from solution import solve def test_example1(): input_str = "4 2 2\n1 2\n3 4" output_str = solve(input_str) assert output_str in ["1 3 2 4\n1 4 2 3", "1 4 2 3\n1 3 2 4"] def test_example2(): input_str = "4 3 2\n1 2\n1 3\n2 4" output_str = solve(input_str) assert output_str == "Not possible" d...
[ { "docstring": null, "function_declaration": "def schedule_tournament(n, m, k, previous_matches):", "function_name": "schedule_tournament", "parameter_list": "(n, m, k, previous_matches)" }, { "docstring": null, "function_declaration": "def solve(input_str):", "function_name": "solve...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_schedule(n, m, k, previous_matches):\n from itertools import combinations\n from collections import defaultdict\n \n # Parse the previous matc...
trial_gpt4o_2
{ "original_instruction": "A company is planning to organize a tournament where employees compete against each other in a series of one-on-one matches. Each employee participates exactly once in each round. The company wants to decide the order of employees such that each employee competes against new opponents in di...
0.680773
Taco_53591
C
[ "schedule_tournament", "solve" ]
2
[ [ "solve", "schedule_tournament" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7e7d12f0dd8471abc8a6ee74cae33265ee3c5596
1e23e2d5a8d34579f6430d956a8a18dc9fafedb9
v1.0
complete
Taco
Taco_54290_C
def max_rectangle_area(grid: List[str]) -> int: """ Find the area of the largest rectangle containing only active cells (1s) in the grid. >>> max_rectangle_area([ "1010", "1011", "1111", "0011" ]) 6 >>> max_rectangle_area([ "111111", "110001", ...
def max_histogram_area(histogram): stack = list() max_area = 0 index = 0 while index < len(histogram): if not stack or histogram[stack[-1]] <= histogram[index]: stack.append(index) index += 1 else: top_of_stack = stack.pop() area = (hi...
from solution import max_rectangle_area def test_example_1(): grid = [ "1010", "1011", "1111", "0011" ] assert max_rectangle_area(grid) == 6 def test_example_2(): grid = [ "111111", "110001", "111001", "111111", "100111", ...
[ { "docstring": null, "function_declaration": "def max_histogram_area(histogram):", "function_name": "max_histogram_area", "parameter_list": "(histogram)" }, { "docstring": null, "function_declaration": "def max_rectangle_area(grid):", "function_name": "max_rectangle_area", "param...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_histogram_area(histogram):\n stack = list()\n max_area = 0\n index = 0\n \n while index < len(histogram):\n if not stack or histogram...
trial_gpt4o_0
{ "original_instruction": "You are given a grid with n rows and m columns. Each cell in the grid can be in one of two states: 0 or 1. A cell is considered \"active\" if it is state 1. Two cells are \"neighbors\" if they share a side.\n\nYou need to write a program that finds the largest rectangle in the grid which co...
0.701918
Taco_54290
C
[ "max_histogram_area", "max_rectangle_area" ]
2
[ [ "max_rectangle_area", "max_histogram_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ac75733b2e724201fc032967ecc1aa5915b2b038
66fb5ae531f4d3803a17954519d31eea1013b37d
v1.0
complete
Taco
Taco_54296_C
def is_prime(n: int) -> bool: """Check if a number is prime.""" pass def longest_prime_subarray_length(arr: List[int]) -> int: """Given an array of integers, return the length of the longest contiguous subarray consisting entirely of prime numbers. >>> longest_prime_subarray_length([1, 2, 3, ...
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 longest_prime_subarray_length(arr): ma...
from solution import longest_prime_subarray_length def test_case_1(): assert longest_prime_subarray_length([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2 def test_case_2(): assert longest_prime_subarray_length([11, 13, 17, 4, 5, 6, 7]) == 3 def test_case_3(): assert longest_prime_subarray_length([4, 6, 8, 10, 12]...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def longest_prime_subarray_length(arr):", "function_name": "longest_prime_subarray_length", "parameter_list": "(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 sieve_of_eratosthenes(max_num):\n \"\"\"\n Returns a list of booleans indicating whether numbers from 0 to max_num are prime.\n \"\"\"\n is_prime =...
trial_gpt4o_2
{ "original_instruction": "In Mathland, a country with a rich tradition of numerical puzzles, the citizens celebrate the Festival of Primes. During this festival, a special game is played involving prime numbers and arrays. You are given an array of integers, and your task is to find the longest contiguous subarray s...
0.724659
Taco_54296
C
[ "is_prime", "longest_prime_subarray_length" ]
2
[ [ "longest_prime_subarray_length", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bf2436f6b0b6b3035da7793cb28ec3146de7d529
330245c3dd26365f20779a4b904e6d4533587508
v1.0
complete
Taco
Taco_54485_C
def check_arrangement(N: int, blocks: List[Tuple[int, int, int]]) -> str: """ Determine if the arrangement of blocks is stable. Parameters: N (int): The number of blocks. blocks (list of tuples): Each tuple represents (width_i, height_i, number_i). Returns: str: "Stable" if al...
def is_stable(arrangement): """ Determine if the arrangement of blocks is stable. Parameters: arrangement (list of tuples): Each tuple represents (width_i, height_i, number_i). Returns: str: "Stable" if all blocks are sufficiently supported, "Unstable" otherwise. """ fo...
from solution import check_arrangement def test_example_1(): N = 3 blocks = [(3, 2, 9), (2, 1, 4), (5, 4, 25)] assert check_arrangement(N, blocks) == "Stable" def test_example_2(): N = 2 blocks = [(3, 3, 9), (4, 2, 5)] assert check_arrangement(N, blocks) == "Unstable" def test_single_block_st...
[ { "docstring": "Determine if the arrangement of blocks is stable.\n\nParameters:\n arrangement (list of tuples): Each tuple represents (width_i, height_i, number_i).\n\nReturns:\n str: \"Stable\" if all blocks are sufficiently supported, \"Unstable\" otherwise.", "function_declaration": "def is_stable...
[ 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_stable(arrangement):\n \"\"\"\n Determines if the arrangement of blocks is stable.\n \n Parameters:\n arrangement (list of tuples): List of t...
trial_gpt4o_2
{ "original_instruction": "A small town has a peculiar tradition of building bonfires every weekend. The townsfolk arrange the wood pieces in a particular pattern: they form a number of rectangular blocks where each block can be described by its width, height, and number of wood pieces. At the end of the arrangement,...
0.542853
Taco_54485
C
[ "is_stable", "check_arrangement" ]
2
[ [ "check_arrangement", "is_stable" ] ]
1
[]
false
[]
false
pytest
true
[]
true
254c51f6cf5dcbb327d203b21e9f5312f0752004
bb190ea9a697189f9dd236aa2797f71b6c6d5fac
v1.0
complete
Taco
Taco_54089_C
class TreeNode: """ A tree node that contains an integer value, and left and right children. """ def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def sorted_array_to_bst(arr): """ Given a sorted array of integers, creat...
class TreeNode: """ A tree node that contains an integer value, and left and right children. """ def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def sorted_array_to_bst(arr): """ Given a sorted array of integers, creat...
from solution import create_balanced_bst, TreeNode def test_inorder_traversal(): def inorder_traversal(root): if not root: return [] return inorder_traversal(root.left) + [root.val] + inorder_traversal(root.right) bst = create_balanced_bst([3, 1, 2]) assert inorder_traversa...
[]
[ 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 create_...
trial_gpt4o_2
{ "original_instruction": "Alan has recently learned about balanced binary trees and is excited to implement one. He wants to write a function that will take an array of integers and build a balanced binary search tree (BST) from it. Given the nature of arrays, he is instructed to first sort the array to facilitate t...
0.683974
Taco_54089
C
[ "sorted_array_to_bst", "create_balanced_bst" ]
2
[ [ "create_balanced_bst", "sorted_array_to_bst" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
36c72bebeb375768e088730af9961a94151e0475
b44f2d7e038b4ca1d18ab45548cf8c6bfae4f92c
v1.0
complete
Taco
Taco_54503_C
from typing import List def can_construct(word: str, source_word: str) -> bool: """ Check if 'word' can be constructed from 'source_word' by ensuring each character in 'word' is present in 'source_word' with at least the same frequency. """ pass def find_longest_constructible_word(source_word: st...
def can_construct(word, source_word): """ Check if 'word' can be constructed from 'source_word' by ensuring each character in 'word' is present in 'source_word' with at least the same frequency. """ from collections import Counter word_count = Counter(word) source_count = Counter(source_wor...
from solution import can_construct, find_longest_constructible_word def test_can_construct(): assert can_construct("apple", "abppplee") == True assert can_construct("able", "abppplee") == True assert can_construct("ale", "abppplee") == True assert can_construct("bale", "abppplee") == True assert ca...
[ { "docstring": "Check if 'word' can be constructed from 'source_word' by ensuring each character in 'word' is present in 'source_word' \nwith at least the same frequency.", "function_declaration": "def can_construct(word, source_word):", "function_name": "can_construct", "parameter_list": "(word, so...
[ 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_construct_from_source(source_word, word):\n \"\"\"\n Checks if a word can be constructed from the source word\n \"\"\"\n source_count = {}\n ...
trial_gpt4o_1
{ "original_instruction": "Given a list of words, you are required to determine the longest word that can be constructed using letters of another word. A word can be constructed when each letter in the word appears in the source word at least as many times as it appears in the original word.\n\nConstraints:\n\n1 ≤ so...
0.69959
Taco_54503
C
[ "can_construct", "find_longest_constructible_word" ]
2
[ [ "find_longest_constructible_word", "can_construct" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9e9a932f136e208a25bd5d7d669574e2ab4ac435
a33ec742f0cce040f6958c5c3f3132978b249b4b
v1.0
complete
Taco
Taco_53755_C
def find_cleanest_plate(test_cases): """ Given a series of stacks filled with plates, each labeled with a cleanliness level, return the cleanliness level of the cleanest plate across all the stacks for each test case. :param test_cases: List of test cases, each test case is a tuple where the first ...
def find_cleanest_plate(test_cases): """ Given a series of stacks filled with plates, each labeled with a cleanliness level, return the cleanliness level of the cleanest plate across all the stacks for each test case. :param test_cases: List of test cases, each test case is a tuple where the first ...
import pytest from solution import find_cleanest_plate, parse_input, solve def test_find_cleanest_plate_single_case(): test_cases = [(3, [[3, 5, 1, 9], [2, 3, 8], [4, 7, 6, 2, 4]])] assert find_cleanest_plate(test_cases) == [9] def test_find_cleanest_plate_multiple_cases(): test_cases = [ (3, [[3,...
[ { "docstring": "Given a series of stacks filled with plates, each labeled with a cleanliness level,\nreturn the cleanliness level of the cleanest plate across all the stacks for each test case.\n\n:param test_cases: List of test cases, each test case is a tuple where the first item is\n the nu...
[ 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 cleanest_plate(test_cases):\n \"\"\"\n Determine the cleanliness level of the cleanest plate across all stacks for each test case.\n\n Parameters:\n ...
trial_gpt4o_2
{ "original_instruction": "You are given a series of stacks filled with plates. Plates in each stack are labeled with a number representing their cleanliness level, where a higher number indicates a cleaner plate. The task at hand is to help Raju determine the cleanliness level of the cleanest plate across all the st...
0.529403
Taco_53755
C
[ "find_cleanest_plate", "parse_input", "solve" ]
3
[ [ "solve", "find_cleanest_plate" ], [ "solve", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
bd4c7aa04bc5c44dcd28fc2f9a33c8de6c583e0a
5dc3cd8b165b02a49857f82d30cf0bd23974ffae
v1.0
complete
Taco
Taco_54461_C
def catalan_number(n): """ Return the nth Catalan number. This function uses a dynamic programming approach. """ def max_non_crossing_handshakes(N): """ Return the maximum number of non-crossing handshakes for N employees. This is the (N/2)th Catalan number. """ def solve(T, test_cases): ...
def catalan_number(n): """ Return the nth Catalan number. This function uses a dynamic programming approach. """ if n == 0: return 1 dp = [0] * (n + 1) dp[0], dp[1] = 1, 1 for i in range(2, n + 1): for j in range(i): dp[i] += dp[j] * dp[i - j - 1] re...
def test_catalan_number(): assert catalan_number(0) == 1 assert catalan_number(1) == 1 assert catalan_number(2) == 2 assert catalan_number(3) == 5 assert catalan_number(4) == 14 assert catalan_number(5) == 42 def test_max_non_crossing_handshakes(): assert max_non_crossing_handshakes(4) == 2...
[ { "docstring": "Return the nth Catalan number. This function uses a dynamic programming approach.", "function_declaration": "def catalan_number(n):", "function_name": "catalan_number", "parameter_list": "(n)" }, { "docstring": "Return the maximum number of non-crossing handshakes for N emplo...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_non_crossing_handshakes(N):\n \"\"\"\n Returns the maximum number of non-crossing handshakes possible for N employees.\n This problem is related...
trial_gpt4o_1
{ "original_instruction": "A company wants to host a meeting where employees are seated around a circular table. Each employee shakes hands with exactly one other employee to form a pair. Determine the maximum number of handshakes that can happen such that no two handshakes cross each other.\n\nFor example, if there ...
0.583899
Taco_54461
C
[ "catalan_number", "max_non_crossing_handshakes", "solve" ]
3
[ [ "max_non_crossing_handshakes", "catalan_number" ], [ "solve", "max_non_crossing_handshakes" ] ]
2
[]
false
[]
false
pytest
false
[]
true
1df028ec0409794cd6c4620b817e1ba0b8171118
b59be13494807caedd38bed354310847466d17c1
v1.0
complete
Taco
Taco_54546_C
def solve(input_string: str) -> str: """ Determines if a substring of s can be rearranged to become a palindrome after removing at most m characters and adding at most n characters. >>> solve("abac 1 1") 'YES' >>> solve("abcde 1 1") 'NO' >>> solve("racecar 0 0") 'YES' >>> solve("...
from collections import Counter def can_form_palindrome(s, m, n): """ Determines if a substring of s can be rearranged to become a palindrome after removing at most m characters and adding at most n characters. """ freq = Counter(s) odd_count = sum(1 for count in freq.values() if count % 2 == 1...
from solution import solve def test_example_1(): assert solve("abac 1 1") == "YES" def test_example_2(): assert solve("abcde 1 1") == "NO" def test_no_modifications_needed(): assert solve("racecar 0 0") == "YES" def test_single_character(): assert solve("a 0 0") == "YES" def test_exactly_needs_one_...
[ { "docstring": "Determines if a substring of s can be rearranged to become a palindrome after removing\nat most m characters and adding at most n characters.", "function_declaration": "def can_form_palindrome(s, m, n):", "function_name": "can_form_palindrome", "parameter_list": "(s, m, n)" }, { ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef can_form_palindrome(s, m, n):\n \"\"\"\n Determines if a substring of s can be rearranged to become a palindrome after...
trial_gpt4o_0
{ "original_instruction": "You have a string $s$ containing lowercase alphabetical characters and at most $10^5$ characters long. You are given two integers, $m$ and $n$. Your task is to determine if you can form a substring of $s$ that can be rearranged to become a palindrome after removing at most $m$ characters an...
0.741
Taco_54546
C
[ "can_form_palindrome", "solve" ]
2
[ [ "solve", "can_form_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2339545e052898fba468b59791104827bc56e96f
1485644a4cf1e98b7e168c94c2d44045e71c7da3
v1.0
complete
Taco
Taco_54262_C
class TreeNode: def __init__(self, val=0): self.val = val self.left = None self.right = None def build_tree(nodes): """ Build a binary tree from the given list of node values. :param nodes: a list of tuples containing (parent, left child, right child) :return: TreeNode repre...
class TreeNode: def __init__(self, val=0): self.val = val self.left = None self.right = None def buildTree(nodes): node_dict = {} for parent, left, right in nodes: if parent not in node_dict: node_dict[parent] = TreeNode(parent) if left != -1: ...
from solution import check_if_trees_are_mirrors def test_case_1(): n = 6 tree1 = [ (1, 2, 3), (2, 4, 5), (3, -1, -1), (4, -1, -1), (5, -1, -1), (-1, -1, -1) ] m = 6 tree2 = [ (1, 3, 2), (3, -1, -1), (2, 5, 4), (5, -1, -...
[]
[ 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": "class TreeNode:\n def __init__(self, val=0):\n self.val = val\n self.left = None\n self.right = None\n\ndef buildTree(nodes):\n node_dic...
trial_gpt4o_0
{ "original_instruction": "You are given two binary trees. Write a program to check if they are mirrors of each other.\n\nA binary tree is symmetrical if the left subtree is a mirror reflection of the right subtree and vice versa. \n\nFor example:\n\n 1 1\n / \\ / \\\n 2 3 3 2\n / \\ ...
0.595224
Taco_54262
C
[ "buildTree", "isMirror", "check_if_trees_are_mirrors" ]
3
[ [ "check_if_trees_are_mirrors", "buildTree" ], [ "check_if_trees_are_mirrors", "isMirror" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
85769fe3ed28139cf738b8de36d8edf69cda1369
f3983a8f7f14adab6d75b06efa71063086304ef8
v1.0
complete
Taco
Taco_54382_C
from typing import List def longestConcatenation(strings: List[str], dictionary: List[str]) -> str: """ Find the longest string in the list of strings that can be formed by concatenating the words from a given dictionary. You may use each word in the dictionary at most once. If no string can be formed, return ...
from typing import List def can_form(target: str, dictionary: List[str], memo: dict) -> bool: if target in memo: return memo[target] if target == "": return True for word in dictionary: if target.startswith(word): if can_form(target[len(word):], dictionary, memo): ...
from solution import longestConcatenation def test_example_case(): dictionary = ["a", "banana", "app", "appl", "ap", "apply", "apple"] strings = ["appleapp", "bananaapple", "aapplebanana", "banana"] assert longestConcatenation(strings, dictionary) == "aapplebanana" def test_no_possible_concatenation(): ...
[ { "docstring": null, "function_declaration": "def can_form(target, dictionary, memo):", "function_name": "can_form", "parameter_list": "(target, dictionary, memo)" }, { "docstring": null, "function_declaration": "def longestConcatenation(strings, dictionary):", "function_name": "long...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef can_form(target: str, dictionary: List[str], memo: dict) -> bool:\n if target in memo:\n return memo[target]\n if targe...
trial_gpt4o_0
{ "original_instruction": "# Task\n\nYou are given a list of strings where each string consists of lowercase English letters. Your task is to find the longest string in the list of strings that can be formed by concatenating the words from a given dictionary. You may use each word in the dictionary at most once. If n...
0.787367
Taco_54382
C
[ "can_form", "longestConcatenation" ]
2
[ [ "longestConcatenation", "can_form" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ad3ed39101e4b7c41c99e770e59a70339a3e4367
3e0e745c924a800339d82dca5ee282ad5a8a3a29
v1.0
complete
Taco
Taco_54645_C
from typing import List from math import gcd def lcm(a: int, b: int) -> int: """ Returns the least common multiple (LCM) of a and b. """ return a * b // gcd(a, b) def minMultiple(a: int, b: int) -> int: """ Given two positive integers a and b, find the smallest integer N, such that: - N i...
from math import gcd def lcm(a, b): """ Returns the least common multiple (LCM) of a and b. """ return a * b // gcd(a, b) def minMultiple(a, b): """ Returns the smallest integer N such that: - N is divisible by both a and b - N is greater than or equal to the least common multiple (LCM...
from solution import minMultiple def test_min_multiple_example_1(): assert minMultiple(6, 8) == 24 def test_min_multiple_example_2(): assert minMultiple(5, 15) == 15 def test_min_multiple_example_3(): assert minMultiple(7, 3) == 21 def test_min_multiple_prime_numbers(): assert minMultiple(13, 17) ==...
[ { "docstring": "Returns the least common multiple (LCM) of a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the smallest integer N such that:\n- N is divisible by both a and b\n- N is greater than or equal to t...
[ 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 math import gcd\n\ndef min_multiple(a, b):\n \"\"\"\n Returns the smallest integer N that is divisible by both a and b, and\n is at least greater tha...
trial_gpt4o_2
{ "original_instruction": "# Task\n\n**_Given_** two **_positive integers a and b_**, find the smallest integer N, such that:\n\n- **_N_** is *divisible by both a and b*\n- **_N_** is *greater than or equal to the least common multiple (LCM) of a and b*.\n\n___\n\n# Notes \n\n* The **_parameters (a, b)_** passed to t...
0.730894
Taco_54645
C
[ "lcm", "minMultiple" ]
2
[ [ "minMultiple", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
62700cb999929cc48faecb80ae916c4b2cfd9ef6
b12b84d157a0f9b7d7dda58244026163f106754a
v1.0
complete
Taco
Taco_54625_C
from typing import List, Union def is_prime(n: int) -> bool: """ Return True if n is a prime number, otherwise False """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def prime_sum_pairs(M: int) -> Union[List[int], bool...
from itertools import permutations def is_prime(n): """Check if a number is prime.""" if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i != 0: continue else: return False return True def prime_sum_pairs(M): """Return an arrangement ...
from solution import prime_sum_pairs def test_prime_sum_pairs_valid_example(): M = 10 result = prime_sum_pairs(M) expected = [2, 1, 4, 3, 8, 5, 6, 7, 10, 9] assert sorted(result) == sorted(expected) assert all(is_prime(result[i] + result[(i + 1) % M]) for i in range(M)) def test_prime_sum_pairs_no...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Return an arrangement of numbers 1..M such that the sum of each pair of adjacent numbers is prime.", "function_declaration": "...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\nfrom sympy import isprime\n\ndef prime_sum_pairs(M):\n def is_valid_permutation(perm):\n for i in range(M):\n ...
trial_gpt4o_1
{ "original_instruction": "# Prime Sum Pairs\n\nWrite function `prime_sum_pairs` (or `primeSumPairs`/`PrimeSumPairs` depending on language rules) that, given integer number `M` (in range `2..50`), returns an array of integers `1..M` arranged in a way, so the sum of each pair of adjacent numbers is a prime number.\n\n...
0.699576
Taco_54625
C
[ "is_prime", "prime_sum_pairs" ]
2
[ [ "prime_sum_pairs", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ec454abf0606002f3c02b87e3abc29728398395d
50d476e94b170f2f01649eabe0a72fc4b6a6b34c
v1.0
complete
Taco
Taco_54699_C
def minimum_roads_to_connect(N: int, M: int, edges: List[Tuple[int, int]]) -> int: """ Determine the minimum number of roads to add to make the graph connected. Args: N (int): Number of vertices. M (int): Number of edges. edges (List[Tuple[int, int]]): List of edges. Returns: int: ...
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] = ro...
def test_minimum_roads_to_connect(): assert minimum_roads_to_connect(6, 4, [(1, 2), (2, 3), (4, 5), (5, 6)]) == 1 assert minimum_roads_to_connect(3, 0, []) == 2 # No edges, 3 disconnected vertices assert minimum_roads_to_connect(4, 2, [(1, 2), (3, 4)]) == 1 # Two components assert minimum_roads_to_con...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(paren...
trial_gpt4o_0
{ "original_instruction": "You are given an undirected graph with N vertices labeled from 1 to N and M edges, where each edge forms a direct connection between two distinct vertices A and B. Each vertex represents a city, and each edge represents a road.\n\nYour task is to determine the minimum number of roads that n...
0.680771
Taco_54699
C
[ "find", "union", "minimum_roads_to_connect" ]
3
[ [ "minimum_roads_to_connect", "find" ], [ "minimum_roads_to_connect", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
3bae713bc8ec46216b814df0a36299ca04e4d087
6702b036ebaa425b6ecc8f07c4ecae37c7f2d38d
v1.0
complete
Taco
Taco_54722_C
def is_palindrome(s: str) -> bool: """ Check if the string s is a palindrome. >>> is_palindrome("abba") True >>> is_palindrome("abcba") True >>> is_palindrome("abcd") False >>> is_palindrome("a") True >>> is_palindrome("aa") True """ def generate_palindrome_permutati...
from itertools import permutations def is_palindrome(s): """Check if the string s is a palindrome.""" return s == s[::-1] def generate_palindrome_permutations(s): """Generate all unique palindrome permutations of the string s.""" unique_permutations = set(permutations(s)) palindrome_permutations =...
from solution import is_palindrome, generate_palindrome_permutations def test_is_palindrome(): assert is_palindrome("abba") == True assert is_palindrome("abcba") == True assert is_palindrome("abcd") == False assert is_palindrome("a") == True assert is_palindrome("aa") == True def test_generate_pal...
[ { "docstring": "Check if the string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Generate all unique palindrome permutations of the string s.", "function_declaration": "def generate_pali...
[ 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 itertools import permutations\n\ndef is_palindrome(s):\n return s == s[::-1]\n\ndef generate_palindrome_permutations(input_str):\n perms = set(permutati...
trial_gpt4o_3
{ "original_instruction": "You are given a string containing a sequence of characters. Your task is to write a program that generates all possible permutations of the string and filters the permutations to provide only those that are valid palindromes.\n\nA palindrome is a sequence that reads the same backward as for...
0.806817
Taco_54722
C
[ "is_palindrome", "generate_palindrome_permutations" ]
2
[ [ "generate_palindrome_permutations", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
493d0007b77e8c7e18c498afb68e8a7713bd7362
75b63e0cec17eb2d1ef2371930f71a9789fddf44
v1.0
complete
Taco
Taco_54858_C
def spelling_bee(word: str) -> str: """ Determines whether the student wins or loses in the spelling bee game. >>> spelling_bee("student14") "Lose" >>> spelling_bee("m@d@m") "Win" """
def is_palindrome(word): return word == word[::-1] def modify_word(word): next_consonant = { 'a': 'b', 'e': 'f', 'i': 'j', 'o': 'p', 'u': 'v' } prev_consonant = { 'b': 'a', 'c': 'b', 'd': 'c', 'f': 'e', 'g': 'f', 'h': 'g', 'j': 'i', 'k': 'j', 'l': 'k', 'm': 'l', 'n': 'm', 'p': ...
from solution import spelling_bee def test_spelling_bee_example1(): assert spelling_bee("student14") == "Lose" def test_spelling_bee_example2(): assert spelling_bee("m@d@m") == "Win" def test_spelling_bee_special_characters(): assert spelling_bee("!@#$$#@!") == "Win" def test_spelling_bee_digits(): ...
[ { "docstring": null, "function_declaration": "def is_palindrome(word):", "function_name": "is_palindrome", "parameter_list": "(word)" }, { "docstring": null, "function_declaration": "def modify_word(word):", "function_name": "modify_word", "parameter_list": "(word)" }, { ...
[ 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 transform_word(word):\n def next_consonant(c):\n vowels = 'aeiou'\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n if c == 'u':\n ...
trial_gpt4o_3
{ "original_instruction": "The game of Spelling Bee is very popular in a small town. The town organizes it every year for all the students. This year, the rules are a bit different. Each student is given a word and they are asked to perform the following operations:\n\n * Replace every vowel ('a', 'e', 'i', 'o', 'u'...
0.555716
Taco_54858
C
[ "is_palindrome", "modify_word", "spelling_bee" ]
3
[ [ "spelling_bee", "is_palindrome" ], [ "spelling_bee", "modify_word" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c4d29c9bfcd80934d513ad2d695fe1d1b07cf04b
1b1493ae0ea4f3696fec2e97c29f96482122f515
v1.0
complete
Taco
Taco_54681_C
def minimizedMaximumSum(n: int, k: int, array: List[int]) -> int: """ Alex is given an array of positive integers a1, a2, ..., an and he wants to split this array into exactly k non-empty contiguous subarrays such that the maximum possible sum of the subarrays is minimized. Help Alex find the minimize...
def splitArray(nums, k): """ This function determines the minimized maximum sum of the subarrays. """ def can_split(nums, max_sum, k): current_sum = 0 subarrays = 1 for num in nums: if current_sum + num > max_sum: subarrays += 1 curren...
from solution import minimizedMaximumSum def test_example1(): assert minimizedMaximumSum(5, 2, [1, 2, 3, 4, 5]) == 9 def test_example2(): assert minimizedMaximumSum(7, 3, [1, 2, 3, 4, 5, 6, 7]) == 11 def test_single_element(): assert minimizedMaximumSum(1, 1, [10]) == 10 def test_all_equal_elements(): ...
[ { "docstring": "This function determines the minimized maximum sum of the subarrays.", "function_declaration": "def splitArray(nums, k):", "function_name": "splitArray", "parameter_list": "(nums, k)" }, { "docstring": null, "function_declaration": "def minimizedMaximumSum(n, k, array):",...
[ 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 splitArray(nums, k):\n \"\"\"\n This function determines the minimized maximum sum of the subarrays.\n \"\"\"\n def can_split(nums, max_sum, k):\n ...
trial_gpt4o_0
{ "original_instruction": "Alex is given an array of positive integers a1, a2, ..., an and he wants to split this array into exactly k non-empty contiguous subarrays such that the maximum possible sum of the subarrays is minimized. Help Alex find the minimized maximum sum of the subarrays.\n\n-----Input-----\n\nThe f...
0.772528
Taco_54681
C
[ "splitArray", "minimizedMaximumSum" ]
2
[ [ "minimizedMaximumSum", "splitArray" ] ]
1
[]
false
[]
false
pytest
true
[]
true
890e83b18a0b20dc48ef8f7e1c4f6bd570af4bfa
c9a70af7198e82a5a65e783f1f858775dd6d466a
v1.0
complete
Taco
Taco_54511_C
def preprocess_prefix_sum(arr): """ Given a list of integers, returns a list where each index i contains the sum of elements from the beginning up to index i of the input list. >>> preprocess_prefix_sum([1, 2, 3, 4, 5]) [0, 1, 3, 6, 10, 15] """ pass def range_sum_query(prefix_sum, l, r): ""...
def preprocess_prefix_sum(arr): """ Given a list of integers, returns a list where each index i contains the sum of elements from the beginning up to index i of the input list. """ n = len(arr) prefix_sum = [0] * (n + 1) for i in range(1, n + 1): prefix_sum[i] = prefix_sum[i - 1] + a...
def test_preprocess_prefix_sum(): arr = [1, 2, 3, 4, 5] expected_prefix_sum = [0, 1, 3, 6, 10, 15] assert preprocess_prefix_sum(arr) == expected_prefix_sum def test_range_sum_query(): prefix_sum = [0, 1, 3, 6, 10, 15] assert range_sum_query(prefix_sum, 1, 3) == 6 assert range_sum_query(prefix_s...
[ { "docstring": "Given a list of integers, returns a list where each index i contains\nthe sum of elements from the beginning up to index i of the input list.", "function_declaration": "def preprocess_prefix_sum(arr):", "function_name": "preprocess_prefix_sum", "parameter_list": "(arr)" }, { ...
[ 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 prefix_sums(arr):\n \"\"\"\n Helper function to compute prefix sums of the given array.\n \"\"\"\n n = len(arr)\n prefix = [0] * (n + 1)\n fo...
trial_gpt4o_2
{ "original_instruction": "Given an array of n integers, you need to answer q queries. Each query consists of two integers l and r, and you are required to find the sum of the elements between the l-th and r-th index in the array (both inclusive). The array is 1-indexed.\n\n------ Input Format ------\n\n- The first l...
0.609386
Taco_54511
C
[ "preprocess_prefix_sum", "range_sum_query", "process_queries" ]
3
[ [ "process_queries", "preprocess_prefix_sum" ], [ "process_queries", "range_sum_query" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
6095e8852a5d6305527e079a7d234edacf6a3c74
02512e9d2bde00de9629aa0bc7d44b5aa517974b
v1.0
complete
Taco
Taco_54740_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nested_list): if not nested_list: return None node = TreeNode(nested_list[0]) if len(nested_list) > 1 and nested_list[1]: node.left...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nested_list): if not nested_list: return None node = TreeNode(nested_list[0]) if len(nested_list) > 1 and nested_list[1]: node.left...
from solution import find_max_path_sum def test_max_path_sum_simple(): tree = [1, [2, [4], [5]], [3, [6], [7]]] assert find_max_path_sum(tree) == 18 def test_max_path_sum_with_negative(): tree = [-10, [9], [20, [15], [7]]] assert find_max_path_sum(tree) == 42 def test_max_path_sum_single_node(): ...
[]
[ 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 TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef build_tree(lst):\n \"\"\"\n Bui...
trial_gpt4o_2
{ "original_instruction": "You are given a binary tree where each node has an integer value. Your task is to write a function to find the maximum path sum. A path in a binary tree is a series of connected nodes where each node can only be visited once, and it does not need to pass through the root.\n\nThe path sum is...
0.592287
Taco_54740
C
[ "build_tree", "max_path_sum", "find_max_path_sum" ]
3
[ [ "find_max_path_sum", "build_tree" ], [ "find_max_path_sum", "max_path_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
5703d388cc82b5cff9205ea6d064749e1c77676f
0ba442cf24ed7ef83f356837b3da802350854568
v1.0
complete
Taco
Taco_54825_C
def tree_depths(n: int, edges_input: List[str]) -> List[int]: """ Determine the depth of each node in the tree. The depth of a node is defined as the number of edges in the path from the root to that node. >>> tree_depths(5, ["1 2", "1 3", "3 4", "3 5"]) [0, 1, 1, 2, 2] >>> tree_depths(1,...
def calculate_depths(n, edges): from collections import deque, defaultdict # Create an adjacency list for the tree tree = defaultdict(list) for u, v in edges: tree[u].append(v) tree[v].append(u) # BFS to calculate depths depths = [-1] * (n + 1) queue = deque([(1, 0)...
from solution import tree_depths def test_tree_depths_example(): n = 5 edges_input = [ "1 2", "1 3", "3 4", "3 5" ] assert tree_depths(n, edges_input) == [0, 1, 1, 2, 2] def test_tree_depths_single_node(): n = 1 edges_input = [] assert tree_depths(n, edges_i...
[ { "docstring": null, "function_declaration": "def calculate_depths(n, edges):", "function_name": "calculate_depths", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def tree_depths(n, edges_input):", "function_name": "tree_depths", "parameter_list"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef find_node_depths(n, edges):\n def bfs_depth(root):\n depths = [-1] * (n + 1)\n queue = deque([ro...
trial_gpt4o_1
{ "original_instruction": "In a distant land, there is a unique and magical tree with n nodes and n-1 edges, forming a tree structure. Each node represents a village, and each edge represents a direct path between two villages. The tree is rooted at node 1, and each node has a unique identifier from 1 to n.\n\nThe vi...
0.641026
Taco_54825
C
[ "calculate_depths", "tree_depths" ]
2
[ [ "tree_depths", "calculate_depths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
717295b7fc7359d292baa2dc813eb7f227f0b330
9479bd25ad34ce1764f864bc864a4ab37a9d727b
v1.0
complete
Taco
Taco_54405_C
def generate_snake_pattern_matrix(N): """ Generate an NxN matrix filled with values from 1 to N^2 in a snake-like pattern. Parameters: N (int): The dimension of the matrix (N x N). Returns: List[List[int]]: The NxN matrix in a snake-like pattern. >>> generate_snake_pattern_matrix...
def generate_snake_pattern_matrix(N): """ Generates an NxN matrix filled with numbers in a snake-like pattern. """ matrix = [] num = 1 for i in range(N): row = [] for j in range(N): row.append(num) num += 1 if i % 2 == 1: # if the row index is odd...
from solution import generate_snake_pattern_matrix, format_matrix, solve_snake_patterns def test_generate_snake_pattern_matrix(): assert generate_snake_pattern_matrix(2) == [[1, 2], [4, 3]] assert generate_snake_pattern_matrix(3) == [[1, 2, 3], [6, 5, 4], [7, 8, 9]] assert generate_snake_pattern_matrix(4) ...
[ { "docstring": "Generates an NxN matrix filled with numbers in a snake-like pattern.", "function_declaration": "def generate_snake_pattern_matrix(N):", "function_name": "generate_snake_pattern_matrix", "parameter_list": "(N)" }, { "docstring": "Formats the matrix to the required form where e...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_snake_matrix(N):\n \"\"\"\n Generates a NxN matrix with values from 1 to N^2 arranged in a \"snake-like\" pattern.\n \"\"\"\n matrix = [[0...
trial_gpt4o_1
{ "original_instruction": "You are given an integer N. Output an NxN matrix with values from 1 to N^2 arranged in such a way that it forms a \"snake-like\" pattern. Specifically, the matrix should be filled as follows:\n\n- Fill the first row from left to right.\n- Fill the second row from right to left.\n- Fill the ...
0.691221
Taco_54405
C
[ "generate_snake_pattern_matrix", "format_matrix", "solve_snake_patterns" ]
3
[ [ "solve_snake_patterns", "format_matrix" ], [ "solve_snake_patterns", "generate_snake_pattern_matrix" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ffd590d47314357a40019709e2fcda166e5eca31
9d961e9f30ebebe8c6bf8c546bd1eb5c3a702533
v1.0
complete
Taco
Taco_55029_C
def minimum_spanning_tree(n: int, m: int, roads: List[Tuple[int, int, int]]) -> int: """ Calculate the total cost of the Minimum Spanning Tree (MST) using Kruskal's algorithm. Args: n (int): The number of cities. m (int): The number of roads. roads (List[Tuple[int, int, int]]): A list of tuples...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): rootX = find(parent, x) rootY = find(parent, y) if rank[rootX] > rank[rootY]: parent[rootY] = rootX elif rank[rootX] < rank[rootY]: parent[rootX]...
from solution import minimum_spanning_tree def test_example_1(): n = 4 m = 5 roads = [ (1, 2, 1), (2, 3, 2), (3, 4, 1), (4, 1, 3), (1, 3, 2) ] assert minimum_spanning_tree(n, m, roads) == 4 def test_example_2(): n = 4 m = 2 roads = [ ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 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": "class DisjointSetUnion:\n def __init__(self, n):\n self.parent = list(range(n))\n self.rank = [0] * n\n \n def find(self, u):\n if se...
trial_gpt4o_4
{ "original_instruction": "In a kingdom, there are n cities connected by m bidirectional roads. The kingdom's king wants to ensure that every city is accessible from every other city, meaning the road network needs to be connected.\n\nEach road between city u and city v has a cost c. To achieve the minimum total cost...
0.697412
Taco_55029
C
[ "find", "union", "kruskal", "minimum_spanning_tree" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_spanning_tree", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
28f16ea4bc4ed7115271c1a64f8cfa1dc38f1e3f
dcab353dcd3258d5d27c49d7f7738b81f91ff30c
v1.0
complete
Taco
Taco_55101_C
def min_path_cost(grid): """ Finds the minimum cost to reach the bottom-right corner of the grid from the top-left corner. >>> min_path_cost([ ... [1, 3, 1], ... [1, 5, 1], ... [4, 2, 1] ... ]) == 7 >>> min_path_cost([ ... [1, 2], ... [3, 4] ... ]) == 7 >>> min_path_cost(...
def min_path_cost(grid): """ Finds the minimum cost to reach the bottom-right corner of the grid from the top-left corner. """ n, m = len(grid), len(grid[0]) dp = [[0] * m for _ in range(n)] dp[0][0] = grid[0][0] for i in range(1, n): dp[i][0] = dp[i-1][0] + grid[i][0] for ...
def test_min_path_cost(): grid1 = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert min_path_cost(grid1) == 7 grid2 = [ [1, 2], [3, 4] ] assert min_path_cost(grid2) == 7 grid3 = [ [1, 1000], [1000, 1] ] assert min_path_cost(grid3) ==...
[ { "docstring": "Finds the minimum cost to reach the bottom-right corner of the grid from the top-left corner.", "function_declaration": "def min_path_cost(grid):", "function_name": "min_path_cost", "parameter_list": "(grid)" }, { "docstring": "Parses the input of multiple test cases and calc...
[ 1 ]
1
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 min_path_cost(grid):\n \"\"\"\n Finds the minimum cost to reach the bottom-right corner of the grid from the top-left corner.\n ...
trial_gpt4o_1
{ "original_instruction": "You are given a grid-based game where each cell in the grid has a certain cost associated with it. A player can only move right or down from the current position. The player starts at the top-left corner (1,1) and wants to reach the bottom-right corner (N, M) with the minimum cost possible....
0.712602
Taco_55101
C
[ "min_path_cost", "min_cost_to_reach_corner", "parse_input", "main" ]
4
[ [ "min_cost_to_reach_corner", "min_path_cost" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
b7d4f9a744cf3d9e987278dede8ab04e9cb35f74
8349002103f2638710bdab619521b5ce11f99c46
v1.0
complete
Taco
Taco_54659_C
def perform_queries(n, m, grid, queries): """ Performs the given queries on the grid. Args: n : int : number of rows in the grid m : int : number of columns in the grid grid : list of list of int : the grid with its initial values queries : list of tuple : the queries to be performed R...
def perform_queries(n, m, grid, queries): """ Performs the given queries on the grid. Args: n : int : number of rows in the grid m : int : number of columns in the grid grid : list of list of int : the grid with its initial values queries : list of tuple : the queries to be performed ...
from solution import perform_queries, find_max, increment_values def test_sample_input(): n = 4 m = 4 grid = [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16] ] queries = [ (1, 1, 1, 3, 3), (2, 2, 2, 4, 4), (1, 1, 1, 4, 4) ] ...
[ { "docstring": "Performs the given queries on the grid.\n\nArgs:\nn : int : number of rows in the grid\nm : int : number of columns in the grid\ngrid : list of list of int : the grid with its initial values\nqueries : list of tuple : the queries to be performed\n\nReturns:\nlist of int : results for each type 1...
[ 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 perform_queries(n, m, grid, queries):\n \"\"\"\n Performs the given queries on the grid.\n \n Args:\n n : int : number ...
trial_gpt4o_1
{ "original_instruction": "You are given a grid with $n$ rows and $m$ columns, containing positive integers in each cell. The task is to perform the following queries on the grid:\n\nType 1. Given four integers $\\boldsymbol{x_1}$, $\\boldsymbol{y_1}$, $\\boldsymbol{x_2}$, and $\\boldsymbol{y_2}$ $(1 \\leq x_1 \\leq ...
0.640276
Taco_54659
C
[ "perform_queries", "find_max", "increment_values" ]
3
[ [ "perform_queries", "find_max" ], [ "perform_queries", "increment_values" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9bc5cdf045b87fd9303f3785cf79b10ec7636384
d4b77560918b58d60d8a0484888318fac6de843b
v1.0
complete
Taco
Taco_54590_C
def calculate_min_distance(adventurers, treasures): """ Calculate the minimum total energy required for all adventurers to collect all the treasures. >>> calculate_min_distance([(1, 1), (2, 2)], [(1, 2), (2, 1)]) 2 >>> calculate_min_distance([(1, 2), (2, 1), (3, 3)], [(1, 1), (2, 2), (3, 1)]) 4 ...
from itertools import permutations def calculate_min_distance(adventurers, treasures): n = len(adventurers) min_distance = float('inf') for perm in permutations(treasures): distance = sum(abs(adventurers[i][0] - perm[i][0]) + abs(adventurers[i][1] - perm[i][1]) for i in range(n)) min_distan...
def test_parse_input(): input_str = "2\n2\n1 1\n2 2\n1 2\n2 1\n3\n1 2\n2 1\n3 3\n1 1\n2 2\n3 1\n" expected_output = [ ([(1, 1), (2, 2)], [(1, 2), (2, 1)]), ([(1, 2), (2, 1), (3, 3)], [(1, 1), (2, 2), (3, 1)]) ] assert parse_input(input_str) == expected_output def test_min_total_distance...
[ { "docstring": null, "function_declaration": "def calculate_min_distance(adventurers, treasures):", "function_name": "calculate_min_distance", "parameter_list": "(adventurers, treasures)" }, { "docstring": null, "function_declaration": "def min_total_distance(test_cases):", "function...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef min_total_energy(t, test_cases):\n results = []\n for i in range(t):\n n = test_cases[i][0]\n adventu...
trial_gpt4o_1
{ "original_instruction": "A treasure hunt game involves $n$ adventurers and $n$ treasures distributed across a grid.\n\nThe grid can be described as a set of $n \\times n$ cells. Each adventurer is located in a unique cell, and each treasure is hidden in a unique cell. The goal is for every adventurer to collect exa...
0.594946
Taco_54590
C
[ "calculate_min_distance", "min_total_distance", "parse_input" ]
3
[ [ "min_total_distance", "calculate_min_distance" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
df2fabc38826da1f391424000a02e8e533137a43
b808181c6c6d3ce4991681130cef8a8eec31bfca
v1.0
complete
Taco
Taco_54995_C
def can_measure_out(ingredient_weights, target_weight): """ Determine if the target weight can be achieved using any combination of given weights. This is a variation of the subset sum problem. """ pass def can_balance_taste(t, test_cases): """ Determine if it is possible to balance the tas...
def can_measure_out(ingredient_weights, target_weight): """ Determine if the target weight can be achieved using any combination of given weights. This is a variation of the subset sum problem. """ dp = [False] * (target_weight + 1) dp[0] = True for weight in ingredient_weights: for...
from solution import can_measure_out, can_balance_taste, parse_input, main def test_can_measure_out(): assert can_measure_out([1, 3, 5], 6) == True # 1+5 or 3+3 assert can_measure_out([2, 4], 6) == True # 2+4 assert can_measure_out([2, 4], 7) == False # impossible def test_can_balance_taste(): t...
[ { "docstring": "Determine if the target weight can be achieved using any combination of given weights.\nThis is a variation of the subset sum problem.", "function_declaration": "def can_measure_out(ingredient_weights, target_weight):", "function_name": "can_measure_out", "parameter_list": "(ingredie...
[ 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 can_measure(weights, target):\n \"\"\"\n Determines if we can make the exact target weight using any combination of the given weights.\n :param weight...
trial_gpt4o_2
{ "original_instruction": "A chef is designing a new dish and needs to perfectly balance the taste by mixing exactly a certain amount of two ingredients, A and B. The ingredients are available in packets of different weights. The chef needs to know if it is possible to measure out exactly the desired amount of both i...
0.630525
Taco_54995
C
[ "can_measure_out", "can_balance_taste", "parse_input", "main" ]
4
[ [ "can_balance_taste", "can_measure_out" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
06db1fb3b50d5518831e5f5d9f5be3129615bf5b
cd96d8508ce895172d5b0fba7be73c846b0475ef
v1.0
complete
Taco
Taco_54949_C
def findMissing(arr, n): """ Returns the smallest positive integer missing from the array. Args: arr: list of integers. n: size of the array. Returns: Smallest positive integer missing. """ pass def partition(arr, n): """ This function segregates positive and non-p...
def findMissing(arr, n): """ Returns the smallest positive integer missing from the array. Args: arr: list of integers. n: size of the array. Returns: Smallest positive integer missing. """ # Move all the non-positive numbers to the left side of the array # and the pos...
def test_findMissing(): assert findMissing([3, 4, -1, 1], 4) == 2 assert findMissing([1, 2, 0], 3) == 3 assert findMissing([7, 8, 9, 11, 12], 5) == 1 assert findMissing([2, 3, 4, -1, -2, 0, 1], 7) == 5 assert findMissing([-5, -1, -2, -3], 4) == 1 assert findMissing([0, 2, 2, 1, 1], 5) == 3 def ...
[ { "docstring": "Returns the smallest positive integer missing from the array.\n\nArgs:\narr: list of integers.\nn: size of the array.\n\nReturns:\nSmallest positive integer missing.", "function_declaration": "def findMissing(arr, n):", "function_name": "findMissing", "parameter_list": "(arr, n)" }...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def findMissing(arr):\n \"\"\"\n Returns the smallest positive integer that is missing from the array.\n \"\"\"\n n = len(arr)\n \n # Step 1: Mov...
trial_gpt4o_2
{ "original_instruction": "Given an array A of N integers, write a program to find the smallest positive integer that is missing from the array. Your solution should have a time complexity of O(n) and utilize constant space.\n\nExample 1:\nInput: Arr[] = {3, 4, -1, 1}\nOutput: 2\nExplanation: The smallest positive in...
0.66107
Taco_54949
C
[ "findMissing", "partition", "findMissingPositive" ]
3
[ [ "findMissing", "findMissingPositive" ], [ "findMissing", "partition" ] ]
2
[]
false
[]
false
pytest
false
[]
true
f335fa3722f8886dd06656d01b46bfa0b1e7b212
f87163c535b1b1e2bba5f67177aff57ea287d11b
v1.0
complete
Taco
Taco_54870_C
from typing import List, Tuple def is_prime(num: int) -> bool: # Check if a number is a prime number pass def find_min_edges(N: int, M: int, edges: List[Tuple[int, int, int]]) -> int: """ Given a graph with N nodes and M edges, determine the minimum number of edges to traverse from node 1 to nod...
import math import collections def is_prime(num): if num <= 1: return False if num == 2: return True if num % 2 == 0: return False limit = int(math.sqrt(num)) + 1 for i in range(3, limit, 2): if num % i == 0: return False return True def find_min_edg...
import pytest from solution import process_test_cases def test_case_1(): test_cases = [ [ (5, 5), (1, 2, 3), (1, 3, 4), (2, 4, 5), (3, 5, 7), (4, 5, 11), ], [ (3, 3), (1, 2, 6), (2, ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def find_min_edges(N, M, edges):", "function_name": "find_min_edges", "parameter_list": "(N, M, edges)" }, ...
[ 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\nimport math\n\ndef is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n ...
trial_gpt4o_1
{ "original_instruction": "There is an undirected graph with N nodes and M edges. Each edge has a weight associated with it. You are initially at node 1 and want to reach node N, but at each step, you can only move to an adjacent node if the weight of the edge connecting to that node is a prime number. Determine the ...
0.589108
Taco_54870
C
[ "is_prime", "find_min_edges", "process_test_cases" ]
3
[ [ "find_min_edges", "is_prime" ], [ "process_test_cases", "find_min_edges" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
5f5f75527a5bc03dbda8856200498c5b81d1c615
516e9016c2a477de573d0f5e9245a4339c11a6c6
v1.0
complete
Taco
Taco_54880_C
def find_minimum_total_distance(n: int, m: int, connections: List[Tuple[int, int, int]]) -> int: """ Determine the minimum total distance required to establish the direct lines of communication such that all offices are efficiently connected. Args: n (int): The number of cities. m (int): ...
def kruskal_minimum_spanning_tree(n, connections): parent = list(range(n)) rank = [0] * n def find(x): if parent[x] != x: parent[x] = find(parent[x]) return parent[x] def union(x, y): rootX = find(x) rootY = find(y) if rootX != rootY: if ...
import pytest from solution import find_minimum_total_distance def test_example1(): n = 4 m = 5 connections = [ (1, 2, 3), (1, 3, 1), (1, 4, 4), (2, 4, 2), (3, 4, 5) ] assert find_minimum_total_distance(n, m, connections) == 6 def test_example2(): n = 3 ...
[ { "docstring": null, "function_declaration": "def kruskal_minimum_spanning_tree(n, connections):", "function_name": "kruskal_minimum_spanning_tree", "parameter_list": "(n, connections)" }, { "docstring": null, "function_declaration": "def find_minimum_total_distance(n, m, connections):",...
[ 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 else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = f...
trial_gpt4o_1
{ "original_instruction": "A large company has multiple offices spread across different cities. Each office has a set of employees working there. The company wants to improve its communication network between the offices by establishing a minimum number of direct communication lines (connections) such that any employ...
0.628435
Taco_54880
C
[ "kruskal_minimum_spanning_tree", "find_minimum_total_distance" ]
2
[ [ "find_minimum_total_distance", "kruskal_minimum_spanning_tree" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f576f08a81e495e59d561ccd9e23816b35a5ef62
8e89bb39aff2248946d7703e868e6d551cb1829c
v1.0
complete
Taco
Taco_55002_C
from typing import List def is_subsequence(s: str, word: str) -> bool: """ Check if 'word' is a subsequence of 's'. """ def longest_subseq_length(s: str, words: List[str]) -> int: """ Returns the length of the longest string in 'words' that is a subsequence of 's'. """ def solve(test_case...
def is_subsequence(s, word): """ Check if 'word' is a subsequence of 's'. """ it = iter(s) return all(char in it for char in word) def longest_subseq_length(s, words): """ Returns the length of the longest string in 'words' that is a subsequence of 's'. """ max_length = 0 for wo...
from solution import is_subsequence, longest_subseq_length, solve def test_is_subsequence(): assert is_subsequence("abpcplea", "apple") assert not is_subsequence("abpcplea", "monkey") assert is_subsequence("abcd", "abc") assert not is_subsequence("abcd", "ace") def test_longest_subseq_length(): as...
[ { "docstring": "Check if 'word' is a subsequence of 's'.", "function_declaration": "def is_subsequence(s, word):", "function_name": "is_subsequence", "parameter_list": "(s, word)" }, { "docstring": "Returns the length of the longest string in 'words' that is a subsequence of 's'.", "func...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subsequence(s, word):\n it = iter(s)\n return all(char in it for char in word)\n\ndef longest_subsequence_length(s, words):\n max_length = 0\n f...
trial_gpt4o_2
{ "original_instruction": "You are given a string `s` consisting of lowercase Latin letters and a list of strings `words`.\n\nLet's call a string in `words` a subsequence of `s` if it can be derived by deleting some (possibly zero) characters from `s` without changing the order of the remaining characters.\n\nFind th...
0.72547
Taco_55002
C
[ "is_subsequence", "longest_subseq_length", "solve" ]
3
[ [ "longest_subseq_length", "is_subsequence" ], [ "solve", "longest_subseq_length" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e426434dcb26aeb01230b7f9c2b0057212e212cd
a4a802ee845aa620c4719cfba26858d08eb257cd
v1.0
complete
Taco
Taco_55037_C
from typing import List def solve_max_number(n: int, integers: List[int]) -> str: """ Construct the maximum possible number from a list of integers by concatenating them. >>> solve_max_number(3, [50, 2, 1]) "5021" >>> solve_max_number(4, [9, 34, 5, 3]) "95343" """ from solution import sol...
from functools import cmp_to_key def compare(n1, n2): if n1 + n2 > n2 + n1: return -1 else: return 1 def max_number(numbers): numbers = list(map(str, numbers)) numbers.sort(key=cmp_to_key(compare)) return ''.join(numbers) def solve_max_number(n, integers): return max_number(in...
from solution import solve_max_number def test_example_1(): assert solve_max_number(3, [50, 2, 1]) == "5021" def test_example_2(): assert solve_max_number(4, [9, 34, 5, 3]) == "95343" def test_single_number(): assert solve_max_number(1, [5]) == "5" def test_same_numbers(): assert solve_max_number(3,...
[ { "docstring": null, "function_declaration": "def compare(n1, n2):", "function_name": "compare", "parameter_list": "(n1, n2)" }, { "docstring": null, "function_declaration": "def max_number(numbers):", "function_name": "max_number", "parameter_list": "(numbers)" }, { "doc...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef compare(x, y):\n if x + y > y + x:\n return -1\n elif x + y < y + x:\n return 1\n else:\n ret...
trial_gpt4o_1
{ "original_instruction": "You are given n integers ai. Your task is to construct the maximum possible number from these integers by concatenating them in some order.\n\nInput\n\nThe first line contains a single integer n (1 ≤ n ≤ 100) — the number of integers.\n\nThe second line contains n positive integers ai (1 ≤ ...
0.641999
Taco_55037
C
[ "compare", "max_number", "solve_max_number" ]
3
[ [ "max_number", "compare" ], [ "solve_max_number", "max_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b868c386c4d1469064d36ef9d47190b834545cdb
8e042fcbe66dcb5b3cd70849412a345490ade01b
v1.0
complete
Taco
Taco_55318_C
def check_anagrams(test_cases): """ Given a list of strings, identify if there exist any two distinct strings in the list that are anagrams of each other. If such a pair exists, return "YES", otherwise return "NO". Input: - test_cases: a list of lists, where each inner list contains strings ...
def are_anagrams(str1, str2): """ Checks if two strings are anagrams of each other. """ return sorted(str1) == sorted(str2) def check_anagrams(test_cases): results = [] for signals in test_cases: anagram_found = False signal_count = len(signals) for i in ra...
def test_check_anagrams(): test_cases = [ ["abc", "bca", "xyz"], ["hello", "oellh", "world", "dlro"] ] expected_results = ["YES", "YES"] assert check_anagrams(test_cases) == expected_results def test_no_anagrams(): test_cases = [ ["abc", "def", "ghi"], ["one", "two",...
[ { "docstring": "Checks if two strings are anagrams of each other.", "function_declaration": "def are_anagrams(str1, str2):", "function_name": "are_anagrams", "parameter_list": "(str1, str2)" }, { "docstring": null, "function_declaration": "def check_anagrams(test_cases):", "function_...
[ 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 check_anagrams(test_cases):\n results = []\n for signals in test_cases:\n seen = set()\n has_anagram = False\n for signal in signals...
trial_gpt4o_2
{ "original_instruction": "In the land of ByteWorld, there exists a kingdom where people communicate using digital signals. These signals are unique and are represented using strings of characters. The citizens of ByteWorld have recently encountered a peculiar problem. They want to determine whether any two different...
0.594491
Taco_55318
C
[ "are_anagrams", "check_anagrams" ]
2
[ [ "check_anagrams", "are_anagrams" ] ]
1
[]
false
[]
false
pytest
false
[]
true
9e1a1c1225cb6fee4a1fd7a8e5ff42c8cec5f94b
da81dc4d134ab1f13e8f8a2731ea868b78294c82
v1.0
complete
Taco
Taco_55131_C
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def insert(root, key): # Implementation here def minValueNode(node): # Implementation here def deleteNode(root, key): # Implementation here def inorderTraversal(root, res): # Implem...
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def insert(root, key): if root is None: return TreeNode(key) else: if root.val < key: root.right = insert(root.right, key) else: root.left = ins...
from solution import bst_operations def test_sample_input_0(): operations = [ "Insert 10", "Insert 5", "Insert 15", "Delete 10", "Insert 20" ] assert bst_operations(operations) == [5, 15, 20] def test_insert_only(): operations = [ "Insert 8", "In...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, key):\n self.left = None\n self.right = None\n self.val = key\n\ndef insert(root, key):\n if root i...
trial_gpt4o_0
{ "original_instruction": "Consider a binary search tree (BST) where each node has a value and two children. You are required to perform multiple operations on this BST. The operations are of two types:\n\n1. Insert an integer $x$ into the BST.\n2. Delete an integer $y$ from the BST if it exists.\n\nGiven a series of...
0.550641
Taco_55131
C
[ "insert", "minValueNode", "deleteNode", "inorderTraversal", "bst_operations" ]
5
[ [ "bst_operations", "deleteNode" ], [ "bst_operations", "inorderTraversal" ], [ "bst_operations", "insert" ], [ "deleteNode", "minValueNode" ] ]
4
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
24918bb3f5e048eb148ce6802cb03490ff5f8de5
f5ee0675abf81139026e5684bd8ed6c9c5a6f5d5
v1.0
complete
Taco
Taco_55271_C
def can_form(s: str, word: str) -> bool: """ Check if `word` can be formed by deleting some characters from `s`. >>> can_form("abpcplea", "apple") True >>> can_form("abpcplea", "ale") True >>> can_form("abpcplea", "monkey") False >>> can_form("abpcplea", "plea") True >>> can_form("abpcplea", "ap...
def can_form(s, word): """ Helper function to determine if `word` can be formed by deleting some characters from `s`. """ it = iter(s) return all(char in it for char in word) def find_longest_word(s, d): """ Returns the longest word in `d` that can be formed by deleting some characters from...
def test_can_form(): assert can_form("abpcplea", "apple") == True assert can_form("abpcplea", "ale") == True assert can_form("abpcplea", "monkey") == False assert can_form("abpcplea", "plea") == True assert can_form("abpcplea", "applz") == False def test_find_longest_word(): assert find_longest...
[ { "docstring": "Helper function to determine if `word` can be formed by deleting some characters from `s`.", "function_declaration": "def can_form(s, word):", "function_name": "can_form", "parameter_list": "(s, word)" }, { "docstring": "Returns the longest word in `d` that can be formed by d...
[ 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 can_form(s, word):\n \"\"\"\n Helper function to determine if `word` can be formed by deleting some characters from `s`.\n \"\"\"\n it = iter(s)\n ...
trial_gpt4o_0
{ "original_instruction": "Write a function that takes a string `s` and a dictionary `d` and returns the longest word in `d` that can be formed by deleting some characters of the given string `s`. If there are more than one possible results, return the word which appears first in the dictionary. If there are no possi...
0.751622
Taco_55271
C
[ "can_form", "find_longest_word" ]
2
[ [ "find_longest_word", "can_form" ] ]
1
[]
false
[]
false
pytest
false
[]
true
db617f65ec0138d9a5075986ea7a2c893e74595b
faaa09daef2c40dc8e92e62ee0067c2af2e5be82
v1.0
complete
Taco
Taco_55005_C
from typing import List, Tuple def process_queries(n: int, edges: List[Tuple[int, int, int]], queries: List[Tuple[int, int]]) -> List[str]: """ Process queries to determine the weight of the heaviest edge on the path from node u to node v in a tree. Args: n (int): number of nodes in the tree. edge...
import sys from collections import defaultdict import heapq sys.setrecursionlimit(500000) input = sys.stdin.read def prepare_lca(n, edges): # adjacency list for the graph graph = defaultdict(list) for u, v, w in edges: graph[u].append((v, w)) graph[v].append((u, w)) # log base 2 o...
from solution import process_queries def test_example_case_multiple_queries(): n = 5 edges = [(1, 2, 4), (1, 3, 2), (3, 4, 3), (3, 5, 1)] queries = [(2, 4), (1, 5), (4, 5)] expected_output = ['4', '2', '3'] assert process_queries(n, edges, queries) == expected_output def test_single_node_tree(): ...
[ { "docstring": null, "function_declaration": "def prepare_lca(n, edges):", "function_name": "prepare_lca", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def lca(u, v, up, max_edge, depth):", "function_name": "lca", "parameter_list": "(u, v, up, m...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\nfrom collections import defaultdict\nimport heapq\n\nsys.setrecursionlimit(500000)\ninput = sys.stdin.read\n\ndef prepare_lca(n, edges):\n # adjacen...
trial_gpt4o_0
{ "original_instruction": "You are given a tree with `n` nodes, rooted at node 1. The weights of the edges between nodes are given. You need to process `q` queries, each containing two integers `u` and `v`, and for each query, determine the weight of the heaviest edge on the path from node `u` to node `v`.\n\nInput\n...
0.609428
Taco_55005
C
[ "prepare_lca", "lca", "process_queries", "main" ]
4
[ [ "process_queries", "lca" ], [ "process_queries", "prepare_lca" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
4e041f4866a4d9b99728cd9aae9b454ab87734ea
79c58e8ef33a11990bc8b72bc49e9c2e87a0ed68
v1.0
complete
Taco
Taco_55393_C
def can_partition(nums, K, max_sum): """ Helper function to determine if we can partition the array into at most K subarrays with each subarray having a sum less than or equal to max_sum. """ def min_max_cost_partition(C, N, K): """ Returns the minimum possible total cost of partitioning the ar...
def can_partition(nums, K, max_sum): """ Helper function to determine if we can partition the array into at most K subarrays with each subarray having a sum less than or equal to max_sum. """ current_sum = 0 current_k = 1 for num in nums: if current_sum + num > max_sum: ...
from solution import min_max_cost_partition def test_example_1(): assert min_max_cost_partition([1, 2, 3, 4, 5], 5, 3) == 6 def test_example_2(): assert min_max_cost_partition([1, 2, 3, 4, 5], 5, 2) == 9 def test_single_element(): assert min_max_cost_partition([10], 1, 1) == 10 def test_all_elements_sam...
[ { "docstring": "Helper function to determine if we can partition the array into at most K subarrays\nwith each subarray having a sum less than or equal to max_sum.", "function_declaration": "def can_partition(nums, K, max_sum):", "function_name": "can_partition", "parameter_list": "(nums, K, max_sum...
[ 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 can_partition(nums, K, max_sum):\n \"\"\"\n Helper function to determine if we can partition the array into at most K subarrays\n with each subarray h...
trial_gpt4o_0
{ "original_instruction": "You are given an array C of size N that contains integers. You want to partition this array into exactly K non-empty contiguous subarrays. The cost of a subarray is the sum of its elements. The total cost of a partitioning is the maximum cost among its K subarrays. Your task is to find the ...
0.724832
Taco_55393
C
[ "can_partition", "min_max_cost_partition" ]
2
[ [ "min_max_cost_partition", "can_partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
124ed67447eb720d310e2c41bdbee20a2e9a8a77
057a66f37d9d9fed83227a04a4cf339a71968a30
v1.0
complete
Taco
Taco_55509_C
def minimizeShelfWidth(books: List[int], shelves: int) -> int: """ Given an array of integers where each element represents the width of a book and a separate integer representing the number of bookshelves, distribute these books across the shelves such that the width of the widest shelf is minimized. >>> mini...
def can_place_books(books, shelves, max_width): current_width = 0 required_shelves = 1 for book in books: if current_width + book > max_width: required_shelves += 1 current_width = book if required_shelves > shelves: return False else: ...
from solution import minimizeShelfWidth def test_minimize_shelf_width_example1(): assert minimizeShelfWidth([1, 2, 3, 4, 5, 6, 7, 8, 9], 3) == 17 def test_minimize_shelf_width_example2(): assert minimizeShelfWidth([10, 20, 30, 40], 2) == 60 def test_minimize_shelf_width_single_shelf(): assert minimizeShe...
[ { "docstring": null, "function_declaration": "def can_place_books(books, shelves, max_width):", "function_name": "can_place_books", "parameter_list": "(books, shelves, max_width)" }, { "docstring": null, "function_declaration": "def minimizeShelfWidth(books, shelves):", "function_nam...
[ 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 minimizeShelfWidth(books, shelves):\n def canDistribute(books, shelves, maxWidth):\n currentShelfWidth = 0\n shelf_count = 1\n\n for bo...
trial_gpt4o_2
{ "original_instruction": "Given an array of integers where each element represents the width of a book and a separate integer representing the number of bookshelves, design a program that distributes these books across the shelves such that the width of the widest shelf is minimized.\n\nExample 1:\nInput:\nbooks = [...
0.605912
Taco_55509
C
[ "can_place_books", "minimizeShelfWidth" ]
2
[ [ "minimizeShelfWidth", "can_place_books" ] ]
1
[]
false
[]
false
pytest
true
[]
true
723bb824eafb0b6ef46b649fa4528bc1e37977af
23ac515e4de9a8fedf4c1605bd40d003d2ac4dce
v1.0
complete
Taco
Taco_55449_C
def minimum_swaps_to_sort(stacks: List[int]) -> int: """Determine the minimum number of swaps required to sort the sequence. Args: stacks (List[int]): The initial sequence of balls. Returns: int: The minimum number of swaps required to sort the sequence. >>> minimum_swaps_to_sort([5, 4, ...
def merge_and_count(arr, temp_arr, left, mid, right): i = left # Starting index for left subarray j = mid + 1 # Starting index for right subarray k = left # Starting index to be sorted inv_count = 0 # Conditions are checked to ensure that i doesn't exceed mid and j doesn't exceed right ...
import pytest from solution import minimum_swaps_to_sort def test_case_1(): assert minimum_swaps_to_sort([5, 4, 3, 2, 1]) == 10 def test_case_2(): assert minimum_swaps_to_sort([1, 2, 6, 4, 3, 5]) == 4 def test_case_3(): assert minimum_swaps_to_sort([1, 3, 5, 2, 4, 6]) == 3 def test_case_4(): assert ...
[ { "docstring": null, "function_declaration": "def merge_and_count(arr, temp_arr, left, mid, right):", "function_name": "merge_and_count", "parameter_list": "(arr, temp_arr, left, mid, right)" }, { "docstring": null, "function_declaration": "def merge_sort_and_count(arr, temp_arr, left, r...
[ 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 merge_and_count(arr, temp_arr, left, mid, right):\n i = left # Starting index for left subarray\n j = mid + 1 # Starting inde...
trial_gpt4o_1
{ "original_instruction": "Bob has a collection of $n$ balls, each uniquely numbered from $1$ to $n$, and he places them on a straight line. Alice challenges Bob to a game where she asks him to find the shortest path to swap the balls such that the resulting sequence is in ascending order.\n\nBob can swap adjacent ba...
0.634946
Taco_55449
C
[ "merge_and_count", "merge_sort_and_count", "minimum_swaps_to_sort" ]
3
[ [ "merge_sort_and_count", "merge_and_count" ], [ "minimum_swaps_to_sort", "merge_sort_and_count" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6aa1bec18a699ba21b5d5845c94107b0c72d2b9d
60822e15830afb631dfc29169333cc4c440d496a
v1.0
complete
Taco
Taco_55381_C
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def build_tree(node_info): nodes = {info[0]: TreeNode(info[0]) for info in node_info} root = nodes[node_info[0][0]] for value, left, right in node_info...
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def build_tree(node_info): nodes = {info[0]: TreeNode(info[0]) for info in node_info} root = nodes[node_info[0][0]] for value, left, right in node_info...
from solution import boundary_traversal_from_input def test_boundary_traversal_example(): assert boundary_traversal_from_input(5, [[1, 2, 3], [2, 4, -1], [4, -1, -1], [3, -1, 5], [5, -1, -1]]) == [1, 2, 4, 5, 3] def test_single_node(): assert boundary_traversal_from_input(1, [[1, -1, -1]]) == [1] def test_le...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef build_tree(nodes):\n if ...
trial_gpt4o_1
{ "original_instruction": "Alex is fascinated by Binary Trees and he wants to perform a unique kind of traversal on them. Given a binary tree, he's interested in finding the \"boundary traversal\" of the tree. The boundary traversal includes the nodes on the boundary of the tree in an anti-clockwise direction startin...
0.52416
Taco_55381
C
[ "build_tree", "boundary_traversal", "boundary_traversal_from_input" ]
3
[ [ "boundary_traversal_from_input", "boundary_traversal" ], [ "boundary_traversal_from_input", "build_tree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
1a8ad4f8f2bfc6d0a94706e77ae6f96672975005
83e5e6c7b7036123b0be00a7cb602471e6969700
v1.0
complete
Taco
Taco_55531_C
from typing import List def remove_adjacent_duplicates(identifier: str) -> str: """Remove adjacent duplicate characters in the identifier until no more removals can be made. >>> remove_adjacent_duplicates("abbac") 'c' >>> remove_adjacent_duplicates("aabbcc") '' >>> remove_adjacent_duplicates("a...
def remove_adjacent_duplicates(identifier): stack = [] for char in identifier: if stack and stack[-1] == char: stack.pop() # Remove the duplicate else: stack.append(char) return ''.join(stack) def process_identifiers(identifiers): return [remove_adjacent_duplica...
from solution import remove_adjacent_duplicates, process_identifiers def test_remove_adjacent_duplicates_single(): assert remove_adjacent_duplicates("abbac") == "c" def test_remove_adjacent_duplicates_entire(): assert remove_adjacent_duplicates("aabbcc") == "" def test_remove_adjacent_duplicates_nested(): ...
[ { "docstring": null, "function_declaration": "def remove_adjacent_duplicates(identifier):", "function_name": "remove_adjacent_duplicates", "parameter_list": "(identifier)" }, { "docstring": null, "function_declaration": "def process_identifiers(identifiers):", "function_name": "proce...
[ 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 reduce_identifier(identifier):\n \"\"\"\n Reduces the identifier by repeatedly removing adjacent duplicate characters until no more removals can be made....
trial_gpt4o_1
{ "original_instruction": "In a remote village, people have unique string patterns as their identifiers. However, the village has a peculiar rule: every identifier can be converted to a new identifier by repeatedly removing adjacent duplicate characters. For example, the identifier \"abbac\" can be converted to \"c\"...
0.657569
Taco_55531
C
[ "remove_adjacent_duplicates", "process_identifiers", "main" ]
3
[ [ "process_identifiers", "remove_adjacent_duplicates" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b6e635efe2606ae18b2308c8ae15e4b7d7780ebe
2f2e7fce936f9f52fa25f4159ee8e289c44582d0
v1.0
complete
Taco
Taco_55553_C
def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. """ def filter_primes(numbers: List[int]) -> List[int]: """ Returns a list of prime numbers from the input list. The result list is sorted in ascending order. >>> filter_primes([2, 3, 4, 5, 6, 7]) ...
def is_prime(num): """ Helper function to 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...
from solution import filter_primes def test_filter_primes_basic(): assert filter_primes([2, 3, 4, 5, 6, 7]) == [2, 3, 5, 7] assert filter_primes([10, 11, 12, 11, 13]) == [11, 11, 13] assert filter_primes([1, 4, 6, 8, 9]) == [] assert filter_primes([29, 1, 17, 17, 23]) == [17, 17, 23, 29] def test_filt...
[ { "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 a list of prime numbers from the input list.\nThe result list is sorted in ascending order.", "...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(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_2
{ "original_instruction": "Create a function that takes a list of integers and returns a list of integers from the original list that are prime numbers. \n\nPrime numbers are defined as numbers greater than 1 that have no divisors other than 1 and themselves.\n\nThe result list should be sorted in ascending order. As...
0.765913
Taco_55553
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dcfe3dcabde18a32e2cc7e1ceca147fc47ceebf8
8308c4a34e3b1e37a444ecae37f9a0a6520863b4
v1.0
complete
Taco
Taco_55378_C
def shortest_path_in_caves(N: int, M: int, edges: List[Tuple[int, int, int]], S: int, T: int) -> Union[int, str]: """ Determine the shortest path between two specified caves. Parameters: N (int): The number of caves (nodes). M (int): The number of paths (edges). edges (List[Tuple[int, int, int]...
import heapq def dijkstra(N, edges, S, T): # Create a graph from the edges graph = {i: [] for i in range(1, N+1)} for u, v, l in edges: graph[u].append((v, l)) graph[v].append((u, l)) # Use a min heap as the priority queue pq = [(0, S)] # (distance, node) distances = {i: fl...
from solution import shortest_path_in_caves def test_example_1(): N = 5 M = 6 edges = [ (1, 2, 4), (1, 3, 1), (3, 4, 2), (2, 3, 3), (2, 4, 1), (4, 5, 6) ] S = 1 T = 5 assert shortest_path_in_caves(N, M, edges, S, T) == 9 def test_example_2():...
[ { "docstring": null, "function_declaration": "def dijkstra(N, edges, S, T):", "function_name": "dijkstra", "parameter_list": "(N, edges, S, T)" }, { "docstring": null, "function_declaration": "def shortest_path_in_caves(N, M, edges, S, T):", "function_name": "shortest_path_in_caves",...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef shortest_path_in_caves(N, M, edges, S, T):\n # Create adjacency list\n graph = {i: [] for i in range(1, N+1)}\n for u, v, l in edges:\...
trial_gpt4o_1
{ "original_instruction": "A famous adventurer is planning his next big expedition to a vast network of caves. To make sure he doesn't get lost, he decides to create a map of the cave system that indicates the shortest path between various points within the caves.\n\nThe cave system can be represented as an undirecte...
0.590222
Taco_55378
C
[ "dijkstra", "shortest_path_in_caves" ]
2
[ [ "shortest_path_in_caves", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
83dcb3e58c61283c7034a0d47460384bd77ac00f
bbf30e71c45e63e102b076cae8e7ebc084df7474
v1.0
complete
Taco
Taco_55599_C
def rotate_90_clockwise(matrix): """ Rotate the given n x n matrix 90 degrees clockwise. """ pass def is_possible_to_transform(initial_matrix, target_matrix): """ Check if the target matrix can be obtained from the initial matrix via any number of 90 degree rotations. """ pass def ma...
def rotate_90_clockwise(matrix): """ Rotate the given n x n matrix 90 degrees clockwise. """ n = len(matrix) return [[matrix[n - j - 1][i] for j in range(n)] for i in range(n)] def is_possible_to_transform(initial_matrix, target_matrix): """ Check if the target matrix can be obtained from t...
from solution import rotate_90_clockwise, is_possible_to_transform, matrix_transformation_possible def test_rotate_90_clockwise(): assert rotate_90_clockwise([ [1, 2], [3, 4] ]) == [ [3, 1], [4, 2] ] assert rotate_90_clockwise([ [1, 2, 3], [4, 5, 6], ...
[ { "docstring": "Rotate the given n x n matrix 90 degrees clockwise.", "function_declaration": "def rotate_90_clockwise(matrix):", "function_name": "rotate_90_clockwise", "parameter_list": "(matrix)" }, { "docstring": "Check if the target matrix can be obtained from the initial matrix via any...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_90_clockwise(matrix):\n \"\"\"\n Rotates the given n x n matrix 90 degrees clockwise.\n \"\"\"\n n = len(matrix)\n rotated_matrix = [[0] ...
trial_gpt4o_2
{ "original_instruction": "Cathy and Dan are working on an image processing application that requires a specific transformation of a matrix. They need to know if it is possible to transform an initial matrix into a target matrix using a series of operations described below.\n\nAn operation is defined as: select a sub...
0.53618
Taco_55599
C
[ "rotate_90_clockwise", "is_possible_to_transform", "matrix_transformation_possible" ]
3
[ [ "is_possible_to_transform", "rotate_90_clockwise" ], [ "matrix_transformation_possible", "is_possible_to_transform" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4828559dfc2f0bea87d83aa771af61fedd35a881
3b049904fddc8496ec3a114283278414145a641c
v1.0
complete
Taco
Taco_55459_C
def find_min_tsp(N: int, matrix: List[List[int]]) -> int: """ Write a program to find the shortest path traversing every node exactly once in a weighted, undirected graph. This problem is also known as the Traveling Salesman Problem (TSP). Given a graph represented with an adjacency matrix, return the ...
import sys def tsp_helper(matrix, mask, pos, dp, N): if mask == (1 << N) - 1: return matrix[pos][0] if matrix[pos][0] != -1 else sys.maxsize if dp[mask][pos] != -1: return dp[mask][pos] ans = sys.maxsize for city in range(N): if (mask & (1 << city)) == 0 and matrix[pos][city] ...
from solution import find_min_tsp def test_case_1(): matrix = [ [0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0, 30], [20, 25, 30, 0] ] assert find_min_tsp(4, matrix) == 80 def test_case_2(): matrix = [ [0, -1, 10], [-1, 0, 20], [10, 20, 0] ] ...
[ { "docstring": null, "function_declaration": "def tsp_helper(matrix, mask, pos, dp, N):", "function_name": "tsp_helper", "parameter_list": "(matrix, mask, pos, dp, N)" }, { "docstring": null, "function_declaration": "def tsp(matrix):", "function_name": "tsp", "parameter_list": "(...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\n\ndef tsp_helper(matrix, mask, pos, dp, N):\n if mask == (1 << N) - 1:\n return matrix[pos][0] if matrix[pos][0] != -1 else sys.maxsize\n\n ...
trial_gpt4o_0
{ "original_instruction": "Write a program to find the shortest path traversing every node exactly once in a weighted, undirected graph. This problem is also known as the Traveling Salesman Problem (TSP). Given a graph represented with an adjacency matrix, you need to output the minimum weight of the traversal. If it...
0.666527
Taco_55459
C
[ "tsp_helper", "tsp", "find_min_tsp" ]
3
[ [ "find_min_tsp", "tsp" ], [ "tsp", "tsp_helper" ] ]
2
[]
false
[]
false
pytest
true
[]
true
465ad07cae07e46ba657eed68cfa2329efa0786c
9be3f9ffeb589c8fb3aed2963f10d61d19a36d86
v1.0
complete
Taco
Taco_55570_C
def library_unique_titles(T, cases): """ Transforms input and applies count_unique_titles to find unique book titles in the library. Parameters: T (int): The number of test cases. cases (list): A list of tuples with each tuple containing the number of titles and the list of titles. Ret...
def count_unique_titles(test_cases): """ Counts the number of unique book titles for each test case. Parameters: test_cases (list): a list of test cases, each test case is a tuple that contains the number of titles and a list of book titles. Returns: list: a lis...
def test_count_unique_titles(): test_cases = [ (5, ["The Great Gatsby", "Moby Dick", "The Great Gatsby", "War and Peace", "Moby Dick"]), (3, ["To Kill a Mockingbird", "1984", "1984"]) ] expected = [3, 2] assert library_unique_titles(2, test_cases) == expected def test_single_title(): ...
[ { "docstring": "Counts the number of unique book titles for each test case.\n\nParameters:\ntest_cases (list): a list of test cases, each test case is a tuple that contains \n the number of titles and a list of book titles.\n\nReturns:\nlist: a list containing the number of unique book titles ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_unique_titles(T, test_cases):\n \"\"\"\n Returns the number of unique book titles for each test case.\n \n Parameters:\n T (int): The numb...
trial_gpt4o_2
{ "original_instruction": "Problem description:\n\nYou are given a list of strings representing book titles in a library. Some of these titles might appear multiple times due to multiple copies of the same book. Write a function to determine the number of unique book titles in the library.\n\nInput\n\nThe first line ...
0.529674
Taco_55570
C
[ "count_unique_titles", "library_unique_titles" ]
2
[ [ "library_unique_titles", "count_unique_titles" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b7d9acc9ed4061156c49bbc2b317769c309a0d0d
fe58d0e5485acbbff5ee13f00e80132e4ae5973a
v1.0
complete
Taco
Taco_55766_C
def min_palindrome_partitions(s: str) -> int: """ Determine the smallest number of contiguous substrings into which the word can be split such that each substring is a palindrome. >>> min_palindrome_partitions("aab") 2 >>> min_palindrome_partitions("racecar") 1 >>> min_palindrome_partitions("a")...
def is_palindrome(s): return s == s[::-1] def min_palindrome_partitions(s): n = len(s) dp = [0] * (n + 1) dp[n] = 0 for i in range(n - 1, -1, -1): min_cut = float('inf') for j in range(i, n): if is_palindrome(s[i:j+1]): min_cut = min(min_cut, 1 + dp[j+1]...
def test_min_palindrome_partitions_single_char(): assert min_palindrome_partitions("a") == 1 def test_min_palindrome_partitions_double_palindrome(): assert min_palindrome_partitions("aa") == 1 assert min_palindrome_partitions("ab") == 2 def test_min_palindrome_partitions_example_cases(): assert min_pa...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def min_palindrome_partitions(s):", "function_name": "min_palindrome_partitions", "parameter_list": "(s...
[ 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 min_palindrome_partitions(s):\n \"\"\"\n Returns the minimum number of contiguous substrings into which the input word \n can be split such that each ...
trial_gpt4o_1
{ "original_instruction": "Jenny likes playing with strings and came up with a new game. She will provide a word, and the task is to determine the smallest number of contiguous substrings into which the word can be split such that each substring is a palindrome.\n\nA palindrome is a string that reads the same forward...
0.770572
Taco_55766
C
[ "is_palindrome", "min_palindrome_partitions" ]
2
[ [ "min_palindrome_partitions", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4102c5c8555b2c2ec2585f649dd73e8f621494a4
03ebea6aa0b8e84ed0864066b9108e50f9a4f367
v1.0
complete
Taco
Taco_55738_C
from typing import List def simplify_file_paths(paths: List[str]) -> List[str]: """Simplify a list of file paths by removing redundant segments. A single dot "." means to stay in the current directory and can be removed. A double dot ".." means to go up one directory. This means you remove the directory se...
def simplify_path(path): parts = path.split('/') stack = [] for part in parts: if part == '..': if stack: stack.pop() elif part and part != '.': stack.append(part) simplified_path = '/' + '/'.join(stack) return simplified_path.rstr...
from solution import simplify_file_paths def test_single_trailing_slash(): assert simplify_file_paths(['/home/foo/']) == ['/home/foo'] def test_root_path_with_parent_directory(): assert simplify_file_paths(['/../']) == ['/'] def test_mixed_example(): assert simplify_file_paths(['/home//foo/bar/../baz']) ...
[ { "docstring": null, "function_declaration": "def simplify_path(path):", "function_name": "simplify_path", "parameter_list": "(path)" }, { "docstring": null, "function_declaration": "def simplify_file_paths(paths):", "function_name": "simplify_file_paths", "parameter_list": "(pat...
[ 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 simplify_path(paths):\n def simplify_single_path(path):\n stack = []\n parts = path.split('/')\n \n for part in parts:\n ...
trial_gpt4o_2
{ "original_instruction": "You are given a list of strings that represent file paths. Each file path is formed with directory names separated by forward slashes ('/'). Sometimes there may be redundant segments in the path, such as \".\" which means the current directory and \"..\" which means to go up one directory (...
0.592854
Taco_55738
C
[ "simplify_path", "simplify_file_paths" ]
2
[ [ "simplify_file_paths", "simplify_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2f81c68c433026fddb3eeab27b3a66fdfa7ba2ab
4936baf2d296fb4cfa95b5d245da02a729e5a9fb
v1.0
complete
Taco
Taco_55927_C
def max_concat_subarray_sum(a: List[int], b: List[int]) -> int: """ Determine the maximum possible sum Anna can get by selecting subarrays and concatenating them. Args: a: List of integers representing the first array. b: List of integers representing the second array. Returns: An...
def max_subarray_sum(array): """ Helper function to find the maximum subarray sum using Kadane's algorithm. """ max_current = max_global = array[0] for num in array[1:]: max_current = max(num, max_current + num) if max_current > max_global: max_global = max_current ...
from solution import max_concat_subarray_sum def test_example1(): a = [1, 2, 3, 4] b = [-1, 2, 3] assert max_concat_subarray_sum(a, b) == 15 def test_example2(): a = [-1, -2, -3, -4, -5] b = [1, 2, 3, 4] assert max_concat_subarray_sum(a, b) == 10 def test_all_negative(): a = [-1, -2, -3] ...
[ { "docstring": "Helper function to find the maximum subarray sum using Kadane's algorithm.", "function_declaration": "def max_subarray_sum(array):", "function_name": "max_subarray_sum", "parameter_list": "(array)" }, { "docstring": "Returns the maximum sum of any subarray from a concatenated...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_subarray_sum(array):\n \"\"\"\n Helper function to find the maximum subarray sum using Kadane's algorithm.\n \"\"\"\n max_current = max_global ...
trial_gpt4o_0
{ "original_instruction": "Anna has two arrays of integers `a` and `b` of length `n` and `m` respectively. She wants to find the maximum sum of elements she can obtain by selecting any subarray from `a` and another subarray from `b`, and then concatenate one after another.\n\nA subarray from array `a` is a contiguous...
0.684704
Taco_55927
C
[ "max_subarray_sum", "max_concat_subarray_sum" ]
2
[ [ "max_concat_subarray_sum", "max_subarray_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
34bb6912890e3081681eea6ba95651f922854894
80edbbf7fa7f11ec68899d6a82bc7c4006bd153d
v1.0
complete
Taco
Taco_55556_C
def minimum_breaks(N: int, M: int, D: int, edges: List[Tuple[int, int, int]], queries: List[Tuple[int, int]]) -> List[int]: """ Determine the minimum number of breaks the driver needs to take to complete each delivery. Each query corresponds to a delivery task from one intersection to another. Args: ...
import heapq def dijkstra(N, edges, start, D): graph = [[] for _ in range(N)] for u, v, w in edges: graph[u-1].append((v-1, w)) distances = [float('inf')] * N distances[start] = 0 pq = [(0, start)] while pq: current_distance, u = heapq.heappop(pq) if c...
def test_sample_input(): from io import StringIO import sys input_data = '''4 4 5 1 2 3 2 3 4 3 4 6 1 3 2 2 1 4 3 1 ''' expected_output = '''1 -1 ''' old_stdin = sys.stdin sys.stdin = StringIO(input_data) old_stdout = sys.stdout sys.stdout = new_stdout = StringIO() main() ...
[ { "docstring": null, "function_declaration": "def dijkstra(N, edges, start, D):", "function_name": "dijkstra", "parameter_list": "(N, edges, start, D)" }, { "docstring": null, "function_declaration": "def minimum_breaks(N, M, D, edges, queries):", "function_name": "minimum_breaks", ...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(graph, start, max_distance, n):\n dist = [float('inf')] * n\n dist[start] = 0\n pq = [(0, start)]\n \n while pq:\n ...
trial_gpt4o_2
{ "original_instruction": "In a busy city, there are several intersections connected by one-way streets of varying lengths. You are given a map of the city with the intersections and streets and your task is to help a delivery driver determine the shortest path to deliver packages. However, the delivery driver can on...
0.656398
Taco_55556
C
[ "dijkstra", "minimum_breaks", "main" ]
3
[ [ "minimum_breaks", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
63923467ec46b14bb1e766faa2232a218e5a43e8
29cd9b19941aa166333436e89fd462aacdcf9c26
v1.0
complete
Taco
Taco_55941_C
def oddland_number(N: int) -> int: """ Returns the smallest integer greater than or equal to N whose sum of digits is odd. >>> oddland_number(47) 47 >>> oddland_number(28) 29 >>> oddland_number(1) 1 >>> oddland_number(44) 45 >>> oddland_number(135) 135 """
def sum_of_digits(n): """ Returns the sum of digits of the number n. """ return sum(int(digit) for digit in str(n)) def oddland_number(N): """ Returns the smallest integer greater than or equal to N whose sum of digits is odd. """ while sum_of_digits(N) % 2 == 0: N += 1 ...
from solution import oddland_number def test_oddland_number_example1(): assert oddland_number(47) == 47 def test_oddland_number_example2(): assert oddland_number(28) == 29 def test_oddland_number_edge_case(): assert oddland_number(1) == 1 def test_oddland_number_increment(): assert oddland_number(44...
[ { "docstring": "Returns the sum of digits of the number n.", "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": "Returns the smallest integer greater than or equal to N \nwhose sum of digits is odd.", "function_dec...
[ 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 sum_of_digits_is_odd(n):\n \"\"\"\n Returns True if the sum of digits of n is odd, else returns False.\n \"\"\"\n return sum(int(digit) for digit i...
trial_gpt4o_3
{ "original_instruction": "In the kingdom of Oddland, the kingdom's balance is maintained using an ancient number system consisting of bizarre properties. One such property is that the sum of the digits of a number should be an odd number. \n\nAlbert, the new head of Oddland Academy, has come up with an interesting p...
0.705747
Taco_55941
C
[ "sum_of_digits", "oddland_number" ]
2
[ [ "oddland_number", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b906e48d6d7cbc226d93b519ac76f3d8cefb9a51
4d27a9abcb63389cdbfdc34cc73c9b1fa8f22c1c
v1.0
complete
Taco
Taco_55992_C
import math from typing import List def is_perfect_square(x: int) -> bool: """ Returns True if x is a perfect square, False otherwise. """ root = int(math.sqrt(x)) return root * root == x def digit_swap_square(q: int, queries: List[int]) -> List[str]: """ For each number in queries, check if any permu...
import math def is_perfect_square(x): """ Returns True if x is a perfect square, False otherwise. """ root = int(math.sqrt(x)) return root * root == x def digit_swap_square(q, queries): """ For each number in queries, check if any permutation of its digits (including the number itself) is ...
def test_digit_swap_square(): assert digit_swap_square(3, [13, 82, 144]) == ["NO", "NO", "YES"] def test_digit_swap_square_single_digit(): assert digit_swap_square(1, [1]) == ["YES"] assert digit_swap_square(1, [2]) == ["NO"] def test_digit_swap_square_double_digit(): assert digit_swap_square(1, [49])...
[ { "docstring": "Returns True if x is a perfect square, False otherwise.", "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_square", "parameter_list": "(x)" }, { "docstring": "For each number in queries, check if any permutation of its digits (including the nu...
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_digit_swap_square(n):\n \"\"\"\n Determines if any permutation of the digits of n is a perfect square.\n \"\"\"\n from math import isqrt, sqrt\n...
trial_gpt4o_5
{ "original_instruction": "Dr. Adams is researching a specific type of number transformation and calls it ‘Digit Swap Square’. A number is transformed by swapping any two of its digits once. If any such permutation leads to a number that is a perfect square, then the original number is considered a Digit Swap Square....
0.606356
Taco_55992
C
[ "is_perfect_square", "digit_swap_square" ]
2
[ [ "digit_swap_square", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1f4306096f2de3d52e5c115e93076d562dee2b44
96cf09e6f9da99f5b76027621238782ce3c154d2
v1.0
complete
Taco
Taco_56102_C
import math from typing import List def find_perfect_square_product(arr: List[int]) -> str: """ Given an integer array `arr`, determine if there exist two distinct indices i and j such that the product of elements at these indices is a perfect square. >>> find_perfect_square_product([2, 3, 4, 6, 8]) "...
import math from itertools import combinations def is_perfect_square(x): root = int(math.isqrt(x)) return root * root == x def find_perfect_square_product(arr): for i, j in combinations(range(len(arr)), 2): if is_perfect_square(arr[i] * arr[j]): return "YES" return "NO"
from solution import find_perfect_square_product def test_example1(): arr = [2, 3, 4, 6, 8] assert find_perfect_square_product(arr) == "YES" def test_example2(): arr = [11, 13, 17, 19] assert find_perfect_square_product(arr) == "NO" def test_single_element(): arr = [5] assert find_perfect_squ...
[ { "docstring": null, "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_square", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def find_perfect_square_product(arr):", "function_name": "find_perfect_square_product", "parame...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom itertools import combinations\n\ndef is_perfect_square(x):\n root = int(math.isqrt(x))\n return root * root == x\n\ndef find_perfect_square...
trial_gpt4o_0
{ "original_instruction": "Given an integer array `arr` of size `n`, you need to determine if there exist two distinct indices i and j such that the product of elements at these indices is a perfect square. A perfect square is an integer that is the square of another integer (for example, 1, 4, 9, 16, etc.).\n\nInput...
0.669536
Taco_56102
C
[ "is_perfect_square", "find_perfect_square_product" ]
2
[ [ "find_perfect_square_product", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
21906889abcaec0e0716fd37b153b9d37fdb7b6f
89e1b8a8876913b275c68594326d1d2d15747298
v1.0
complete
Taco
Taco_55692_C
class TreeNode: def __init__(self, id): self.id = id self.children = [] def build_tree(n, ids, manager_pairs): nodes = {id: TreeNode(id) for id in ids} for u, v in manager_pairs: nodes[u].children.append(nodes[v]) root = nodes[ids[0]] return root def find_path(root, t...
class TreeNode: def __init__(self, id): self.id = id self.children = [] def build_tree(n, ids, manager_pairs): nodes = {id: TreeNode(id) for id in ids} for u, v in manager_pairs: nodes[u].children.append(nodes[v]) root = nodes[ids[0]] return root def find_path(root, t...
from solution import employee_path def test_example(): n = 7 ids = [1, 2, 3, 4, 5, 6, 7] manager_pairs = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7)] target = 5 assert employee_path(n, ids, manager_pairs, target) == "1 -> 2 -> 5" def test_single_employee(): n = 1 ids = [1] manager_...
[]
[ 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": "class TreeNode:\n def __init__(self, id):\n self.id = id\n self.children = []\n\ndef build_tree(n, employees, relations):\n nodes = {id: TreeNo...
trial_gpt4o_2
{ "original_instruction": "In a large company, an employee can have multiple direct reports but only one manager. The employees are represented as nodes in a tree, where each node contains an integer representing the employee's ID. The root node represents the CEO who has no manager.\n\nYou need to implement a functi...
0.563395
Taco_55692
C
[ "build_tree", "find_path", "employee_path" ]
3
[ [ "employee_path", "build_tree" ], [ "employee_path", "find_path" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
e2870a3eb297bdd13711d8130ae56f8d64b810ce
865e0d17e8d9a4c548e97e692460d494aac06c48
v1.0
complete
Taco
Taco_55970_C
def reduce_array_to_prime(n, arr): """ You are given an array of n positive integers. In one operation, you can select any two adjacent elements in the array, remove them, and insert their sum back into the array. The goal is to determine if it is possible to reduce the array to a single element which...
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def reduce_to_prime(n, arr): ...
from solution import reduce_array_to_prime def test_prime_array(): import io import sys captured_output = io.StringIO() sys.stdout = captured_output reduce_array_to_prime(5, [2, 3, 5, 7, 11]) sys.stdout = sys.__stdout__ assert "YES" in captured_output.getvalue() def test_small_array(): ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def reduce_to_prime(n, arr):", "function_name": "reduce_to_prime", "parameter_list": "(n, arr)" }, { ...
[ 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(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_1
{ "original_instruction": "You are given an array of n positive integers. In one operation, you can select any two adjacent elements in the array, remove them, and insert their sum back into the array. The goal is to determine if it is possible to reduce the array to a single element which is a prime number. If it is...
0.674312
Taco_55970
C
[ "is_prime", "reduce_to_prime", "reduce_array_to_prime" ]
3
[ [ "reduce_array_to_prime", "reduce_to_prime" ], [ "reduce_to_prime", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
d3b3d4db6a94c23806ecec7476dd17e15aaaa05d
f68484af1892e1b81daf0b77b909d96f1a0288d9
v1.0
complete
Taco
Taco_55945_C
def can_split_sequence(sequence): """ Determine whether a given sequence can be split into two non-empty subsequences such that each subsequence is sorted in strictly increasing or strictly decreasing order. >>> can_split_sequence([5, 1, 4, 3, 2]) 'YES' >>> can_split_sequence([4, 3, 2, 1]) 'NO' """ ...
def can_split_sequence(sequence): n = len(sequence) inc_ord = sorted(sequence) dec_ord = sorted(sequence, reverse=True) if inc_ord != sequence and dec_ord != sequence: return "YES" else: return "NO" def analyze_sequences(test_cases): results = [] for test_case in test_cases...
def test_can_split_sequence_scenario1(): assert can_split_sequence([5, 1, 4, 3, 2]) == "YES" def test_can_split_sequence_scenario2(): assert can_split_sequence([4, 3, 2, 1]) == "NO" def test_can_split_sequence_scenario3(): assert can_split_sequence([2, 4, 1, 5, 3, 6]) == "YES" def test_can_split_sequence...
[ { "docstring": null, "function_declaration": "def can_split_sequence(sequence):", "function_name": "can_split_sequence", "parameter_list": "(sequence)" }, { "docstring": null, "function_declaration": "def analyze_sequences(test_cases):", "function_name": "analyze_sequences", "par...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_be_split(nums):\n n = len(nums)\n \n # Check strictly increasing subsequences\n inc = [nums[0]]\n for i in range(1, n):\n if nums[i] ...
trial_gpt4o_2
{ "original_instruction": "Jacob works for a company where he needs to analyze sequences of numbers. His task is to determine whether a given sequence can be split into two non-empty subsequences such that each subsequence is sorted in strictly increasing or strictly decreasing order. Note that the subsequences do no...
0.664935
Taco_55945
C
[ "can_split_sequence", "analyze_sequences", "process_input" ]
3
[ [ "analyze_sequences", "can_split_sequence" ], [ "process_input", "analyze_sequences" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
a971b78913e46eb3207f88d43ae3fedd27f6aaa1
0a37e3a20ead401cc4c3baca9ccce0cc1af8769f
v1.0
complete
Taco
Taco_55931_C
def encode_message(shift: int, message: str) -> str: """ Encodes a given message by shifting each letter by the specified shift value. Args: shift (int): The shift value (1 <= shift <= 25) message (str): The message to be encoded. Returns: str: The encoded message. >>> enc...
def encode_message(shift, message): """ Encodes a given message by shifting each letter by the specified shift value. Args: shift (int): The shift value (1 <= shift <= 25) message (str): The message to be encoded. Returns: str: The encoded message. """ encoded_message = [] ...
from solution import encode_message def test_encode_simple(): assert encode_message(3, "hello world") == "khoor zruog" def test_encode_with_max_shift(): assert encode_message(25, "hello world") == "gdkkn vnqkc" def test_encode_with_wrap_around(): assert encode_message(1, "xyz") == "yza" assert encode...
[ { "docstring": "Encodes a given message by shifting each letter by the specified shift value.\n\nArgs:\nshift (int): The shift value (1 <= shift <= 25)\nmessage (str): The message to be encoded.\n\nReturns:\nstr: The encoded message.", "function_declaration": "def encode_message(shift, message):", "func...
[ 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 encode_message(shift, message):\n \"\"\"\n Encodes the message by shifting each letter by the given shift value.\n \n Args:\n shift (int): The f...
trial_gpt4o_4
{ "original_instruction": "Alyssa is working on a secret message system where each message is encoded based on a specific pattern. The encoding process involves shifting each character in the message a given number of positions forward in the alphabet, wrapping around if necessary. \n\nThe rules for encoding are as f...
0.789544
Taco_55931
C
[ "encode_message", "encoder" ]
2
[ [ "encoder", "encode_message" ] ]
1
[]
false
[]
false
pytest
true
[]
true
00e087c73c1e3464e5cb3f020713b6733d6dbd53
51fe3b08aae9bbd489f0de65a69666a8b72633d3
v1.0
complete
Taco
Taco_55865_C
def alice_can_reach(n, k, grid): """ Alice wants to navigate from the top-left cell (1, 1) to the bottom-right cell (n, n) in a given n x n grid, using right and down moves and a limited number of teleportation gadgets. Parameters: n (int): size of the grid. k (int): number of teleportation gadgets av...
from collections import deque def min_teleportation_gadgets(n, k, grid): def neighbors(x, y): for nx, ny in ((x+1, y), (x, y+1), (x-1, y), (x, y-1)): if 0 <= nx < n and 0 <= ny < n and grid[nx][ny] == '0': yield nx, ny start = (0, 0) end = (n-1, n-1) if gri...
def test_alice_can_reach_possible(): grid = [ "00000", "01110", "00000", "01110", "00000" ] assert alice_can_reach(5, 1, grid) == "YES 1" def test_alice_can_reach_impossible(): grid = [ "0100", "0110", "0000", "0111", ] ass...
[ { "docstring": null, "function_declaration": "def min_teleportation_gadgets(n, k, grid):", "function_name": "min_teleportation_gadgets", "parameter_list": "(n, k, grid)" }, { "docstring": null, "function_declaration": "def alice_can_reach(n, k, grid):", "function_name": "alice_can_re...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_teleportations_needed(grid, n, k):\n # Directions for moving right and down\n directions = [(0, 1), (1, 0)]\n\n #...
trial_gpt4o_7
{ "original_instruction": "There is a square grid of size n × n, where each cell of the grid can be either traversable or blocked. Alice wants to navigate from the top-left cell (1, 1) to the bottom-right cell (n, n) using only right and down moves. She can also use teleportation gadgets, which allow her to move from...
0.626825
Taco_55865
C
[ "min_teleportation_gadgets", "alice_can_reach" ]
2
[ [ "alice_can_reach", "min_teleportation_gadgets" ] ]
1
[]
false
[]
false
pytest
false
[]
true
ba42c14127a4959a89220e23f48d7099aa4b94fa
74c508315f874db4d8cf364345d65423393b63c4
v1.0
complete
Taco
Taco_55712_C
from typing import List, Tuple, Dict def dijkstra(n: int, adj: List[List[Tuple[int, int]]], start: int) -> List[int]: """Find the shortest paths from a start node to all other nodes using Dijkstra's algorithm. Parameters: - n: int - The number of cities. - adj: List[List[Tuple[int, int]]] - Adjacency l...
import heapq def dijkstra(n, adj, start): dist = [float('inf')] * (n + 1) dist[start] = 0 pq = [(0, start)] # priority queue (distance, node) while pq: current_distance, u = heapq.heappop(pq) if current_distance > dist[u]: continue for v, length in adj[u]: ...
def test_dijkstra(): n = 5 adj = [[] for _ in range(n + 1)] edges = [(1, 2, 2), (1, 3, 5), (2, 3, 1), (2, 4, 4), (3, 5, 3), (4, 5, 1)] for u, v, l in edges: adj[u].append((v, l)) adj[v].append((u, l)) dist = dijkstra(n, adj, 1) assert dist[1] == 0 assert dist[2] == 2 asse...
[ { "docstring": null, "function_declaration": "def dijkstra(n, adj, start):", "function_name": "dijkstra", "parameter_list": "(n, adj, start)" }, { "docstring": null, "function_declaration": "def min_distance_to_collect_points(t, tests):", "function_name": "min_distance_to_collect_poi...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(graph, start, n):\n \"\"\"\n Dijkstra's algorithm to find the shortest path from start to all other nodes.\n Returns a list o...
trial_gpt4o_3
{ "original_instruction": "In a game of strategic points, players collect points based on the order they visit a set of cities. This game is played on a road network consisting of $N$ cities connected by $M$ bidirectional roads. Each road connects a pair of cities $(u, v)$ and has an associated length $l$. The goal i...
0.721514
Taco_55712
C
[ "dijkstra", "min_distance_to_collect_points" ]
2
[ [ "min_distance_to_collect_points", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b6e4285c16795947ecd2bc1cdf23b489336b87ca
edb185fbf89ae1f3bbab6b47a0ee65304ff5022f
v1.0
complete
Taco
Taco_55702_C
def grid_queries(n: int, m: int, grid: List[List[int]], queries: List[Tuple[int, int, int, int]]) -> List[int]: """ Determine the total number of coins in the subrectangle defined by the top-left corner (x1, y1) and the bottom-right corner (x2, y2) for each query in a grid. Args: n : int : number of ro...
def preprocess_grid(grid, n, m): prefix_sum = [[0] * (m + 1) for _ in range(n + 1)] for i in range(n): for j in range(m): prefix_sum[i + 1][j + 1] = grid[i][j] + prefix_sum[i][j + 1] + prefix_sum[i + 1][j] - prefix_sum[i][j] return prefix_sum def query_coins(prefix_sum, x1, y1...
from solution import grid_queries def test_single_query(): n, m = 3, 4 grid = [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12] ] queries = [(1, 1, 2, 2)] assert grid_queries(n, m, grid, queries) == [14] def test_multiple_queries(): n, m = 3, 4 grid = [ [1, ...
[ { "docstring": null, "function_declaration": "def preprocess_grid(grid, n, m):", "function_name": "preprocess_grid", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def query_coins(prefix_sum, x1, y1, x2, y2):", "function_name": "query_coins", "p...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_grid(grid):\n \"\"\"\n Preprocess the grid to create a prefix sum matrix.\n \"\"\"\n n = len(grid)\n m = len(grid[0])\n prefix_sum...
trial_gpt4o_2
{ "original_instruction": "You are given a rectangular grid with `n` rows and `m` columns. Each cell in the grid contains a certain number of coins. You need to perform several queries on this grid. Each query consists of four integers `x1`, `y1`, `x2`, and `y2`, and you need to determine the total number of coins in...
0.5681
Taco_55702
C
[ "preprocess_grid", "query_coins", "grid_queries" ]
3
[ [ "grid_queries", "preprocess_grid" ], [ "grid_queries", "query_coins" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3d9d5eea62cdf9baf5a1ab3498b0bfd968c8e856
cffd508a1f48649643f1872616c51329c8c2244f
v1.0
complete
Taco
Taco_56448_C
def count_ways(n): """ Return the number of unique ways to climb a staircase with n steps. >>> count_ways(0) 0 >>> count_ways(1) 1 >>> count_ways(2) 2 >>> count_ways(3) 3 >>> count_ways(4) 5 >>> count_ways(5) 8 >>> count_ways(10) 89 """ def process_staircases(steps_list): ""...
def count_ways(n): """ Return the number of unique ways to climb a staircase with n steps. """ if n == 0: return 0 elif n == 1: return 1 elif n == 2: return 2 # Using dynamic programming to store the number of ways to solve subproblems dp = [0] * (n + 1) ...
from solution import count_ways, process_staircases def test_count_ways(): assert count_ways(0) == 0 assert count_ways(1) == 1 assert count_ways(2) == 2 assert count_ways(3) == 3 assert count_ways(4) == 5 assert count_ways(5) == 8 assert count_ways(10) == 89 def test_process_staircases(): ...
[ { "docstring": "Return the number of unique ways to climb a staircase with n steps.", "function_declaration": "def count_ways(n):", "function_name": "count_ways", "parameter_list": "(n)" }, { "docstring": "Process a list of steps, and return a list of results for each\nsteps count in the for...
[ 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 climb_stairs(n):\n \"\"\"\n Calculate the number of unique ways to climb to the top of a staircase with n steps.\n You can either take 1 step or 2 ste...
trial_gpt4o_2
{ "original_instruction": "You are given a series of tasks. Each task consists of climbing a staircase with `n` steps. You can climb the stairs by taking either one step or two steps at a time. Calculate the number of unique ways to climb to the top for each task. \n\nInput\n\nThe input consists of multiple test case...
0.685866
Taco_56448
C
[ "count_ways", "process_staircases" ]
2
[ [ "process_staircases", "count_ways" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2897ba42e8634dc4ceeab19083fe514399330423
a9cccdfb857b9e15e8530386caf946a6c8a0a544
v1.0
complete
Taco
Taco_56116_C
def max_treasure(n: int, treasures: List[int]) -> int: """ Given the number of houses and a list of treasures in each house, find the maximum amount of treasure the thieves can steal without alerting the police by robbing two adjacent houses. Parameters: n (int): the number of houses ...
def max_robbery(treasures): """ Given a list of treasures in each house, this function returns the maximum amount of treasure the thieves can steal without alerting the police by robbing two adjacent houses. """ n = len(treasures) if n == 0: return 0 if n == 1: return tre...
from solution import max_treasure def test_example1(): assert max_treasure(5, [2, 7, 9, 3, 1]) == 12 def test_example2(): assert max_treasure(3, [2, 1, 4]) == 6 def test_example3(): assert max_treasure(6, [5, 5, 10, 40, 50, 35]) == 80 def test_single_house(): assert max_treasure(1, [7]) == 7 def te...
[ { "docstring": "Given a list of treasures in each house, this function returns the maximum\namount of treasure the thieves can steal without alerting the police by\nrobbing two adjacent houses.", "function_declaration": "def max_robbery(treasures):", "function_name": "max_robbery", "parameter_list":...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_treasure(n, treasures):\n if n == 1:\n return treasures[0]\n \n dp = [0] * n\n dp[0] = treasures[0]\n dp[1] = max(treasures[0], treas...
trial_gpt4o_2
{ "original_instruction": "In a small village, there are n houses arranged in a row. Each house has a certain amount of coin treasure. Thieves plan to rob the houses and want to maximize the amount of treasure they can steal. However, they have a simple constraint: if they rob two adjacent houses, the police will be ...
0.617429
Taco_56116
C
[ "max_robbery", "max_treasure" ]
2
[ [ "max_treasure", "max_robbery" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5d907746338783e1f0fe2e761409f33efb3409d7
7e80234efdd356cfdc3d82f02d7e9f902161913a
v1.0
complete
Taco
Taco_56605_C
from typing import List def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. """ # Implement prime checking logic def prime_sum_triple(n: int) -> List[int]: """ Function to determine if n can be represented as a sum of three prime numbers. Returns one possible...
def is_prime(num): """ Helper function to check if a number is prime. """ if num < 2: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def prime_sum_triple(n): """ Function to determine if n can be represented as ...
from solution import prime_sum_triple def test_prime_sum_triple_existence(): assert prime_sum_triple(30) != [] assert prime_sum_triple(17) != [] assert prime_sum_triple(23) != [] assert prime_sum_triple(30000) != [] def test_prime_sum_triple_specific_cases(): # 30 can be 7 + 11 + 12 or any other v...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Function to determine if n can be represented as a sum of three prime numbers.\nReturns one possible combin...
[ 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 < 2:\n return False\n for i in range(2, int(nu...
trial_gpt4o_0
{ "original_instruction": "Given an integer `n`, your task is to determine if it can be represented as a sum of three prime numbers. If it is possible, return one possible combination as a list `[p1, p2, p3]` where `p1`, `p2`, and `p3` are prime numbers. If there are multiple solutions, return any one of them. If no ...
0.762697
Taco_56605
C
[ "is_prime", "prime_sum_triple" ]
2
[ [ "prime_sum_triple", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d01676a691e5cece847b392ce3800cd4a92b44f5
2a139f592cfd6d1e1d35b96d4799141d09d57d3f
v1.0
complete
Taco
Taco_56547_C
def is_palindrome(num: int) -> bool: """ Check if the given number is a palindrome. >>> is_palindrome(121) True >>> is_palindrome(123) False """ pass def next_palindrome(M: int) -> int: """ Return the smallest palindromic number which is strictly greater than M. >>> next_palindrome(...
def is_palindrome(num): return str(num) == str(num)[::-1] def next_palindrome(M): M = int(M) while True: M += 1 if is_palindrome(M): return M def find_palindromes_for_test_cases(test_cases): results = [] for M in test_cases: results.append(next_palindrome(M)) ...
from solution import main def test_example_cases(): input_data = "2\n123\n808" expected_output = "131\n818" assert main(input_data) == expected_output def test_single_digit_palindrome(): input_data = "1\n5" expected_output = "6" assert main(input_data) == expected_output def test_larger_palin...
[ { "docstring": null, "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def next_palindrome(M):", "function_name": "next_palindrome", "parameter_list": "(M)" }, { ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n return str(n) == str(n)[::-1]\n\ndef next_palindrome(m):\n m += 1\n while not is_palindrome(m):\n m += 1\n return m\n\nd...
trial_gpt4o_2
{ "original_instruction": "John is obsessed with palindromes. He believes that palindromic numbers possess special properties and wants to explore them further. Given a number M, he wants to find the smallest palindromic number which is strictly greater than M.\n\n-----Input-----\n\nFirst line of input contains numbe...
0.75258
Taco_56547
C
[ "is_palindrome", "next_palindrome", "find_palindromes_for_test_cases", "main" ]
4
[ [ "find_palindromes_for_test_cases", "next_palindrome" ], [ "next_palindrome", "is_palindrome" ] ]
2
[ "find_palindromes_for_test_cases" ]
false
[]
false
pytest
true
[]
true
d26abf01f5047ced411c064ad8c2e0d315ca8139
7c483ba819c00983643561d406e1db47621f3ad4