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_78665_C
def are_all_players_in_same_alliance(n: int, moves: List[Tuple[int, int]]) -> str: """ Determine if all players are in the same alliance at the end of the given moves. >>> are_all_players_in_same_alliance(4, [(1, 2), (2, 3), (3, 4)]) == "yes" >>> are_all_players_in_same_alliance(4, [(1, 2), (3, 4)]) == "no"...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, x, y): xroot = find(parent, x) yroot = find(parent, y) parent[xroot] = yroot def are_all_players_in_same_alliance(n, moves): parent = list(range(n+1)) for u, v in moves: union...
from solution import are_all_players_in_same_alliance def test_players_in_same_alliance_1(): assert are_all_players_in_same_alliance(4, [(1, 2), (2, 3), (3, 4)]) == "yes" def test_players_in_same_alliance_2(): assert are_all_players_in_same_alliance(4, [(1, 2), (3, 4)]) == "no" def test_players_in_same_allia...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, x, y):", "function_name": "union", "parameter_list": "(parent, x, y)" }, { "doc...
[ 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 are_all_players_in_same_alliance(n, m, moves):\n \"\"\"\n Determine if all players are in the same alliance.\n \n Args:\n n (int): number of pla...
trial_gpt4o_1
{ "original_instruction": "A new online game allows players to form alliances. Each player starts alone and can choose to ally with other players. When a player allies with another player, all their alliances merge into one. There are $n$ players and $m$ moves describing alliances between players.\n\nCan you determin...
0.589499
Taco_78665
C
[ "find", "union", "are_all_players_in_same_alliance" ]
3
[ [ "are_all_players_in_same_alliance", "find" ], [ "are_all_players_in_same_alliance", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
1683196f7ab1e2875c71bf856abad17135ddaeef
cfab58229206a381793f92bbc0652baf684d6e5b
v1.0
complete
Taco
Taco_77977_C
from typing import List def isPrime(X: int) -> bool: """ Returns True if X is a prime number, False otherwise. >>> isPrime(11) True >>> isPrime(4) False """ def isSumOfSquares(PR: int) -> bool: """ Returns True if PR can be expressed as the sum of the squares of two non-negative integers. ...
def isPrime(X): """ Returns True if X is a prime number, False otherwise. """ if X <= 1: return False if X <= 3: return True if X % 2 == 0 or X % 3 == 0: return False i = 5 while i * i <= X: if X % i == 0 or X % (i + 2) == 0: return False ...
from solution import isPrime, isSumOfSquares, smallest_prime_sum_of_squares_greater_than, process_input def test_is_prime(): assert isPrime(2) == True assert isPrime(3) == True assert isPrime(4) == False assert isPrime(29) == True assert isPrime(30) == False def test_is_sum_of_squares(): asser...
[ { "docstring": "Returns True if X is a prime number, False otherwise.", "function_declaration": "def isPrime(X):", "function_name": "isPrime", "parameter_list": "(X)" }, { "docstring": "Returns True if PR can be expressed as the sum of the squares of two non-negative integers.", "functio...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef isPrime(x):\n \"\"\"\n Returns True if x is a prime number, otherwise False.\n \"\"\"\n if x <= 1:\n return False\n if x <...
trial_gpt4o_1
{ "original_instruction": "Given a positive integer N, define a function `isPrime(X)` which returns true if X is a prime number and false otherwise.\n\nFor example, `isPrime(11)` = True, because 11 has no divisors other than 1 and itself.\n\nYour task is to find the smallest prime number P which is both greater than ...
0.66194
Taco_77977
C
[ "isPrime", "isSumOfSquares", "smallest_prime_sum_of_squares_greater_than", "process_input" ]
4
[ [ "process_input", "smallest_prime_sum_of_squares_greater_than" ], [ "smallest_prime_sum_of_squares_greater_than", "isPrime" ], [ "smallest_prime_sum_of_squares_greater_than", "isSumOfSquares" ] ]
3
[ "process_input" ]
false
[]
false
pytest
true
[]
true
8f818bd5db0e8a5c86f4b2b860cd705616e791d4
c759285d4ef4575310f8134cc02d01cd2aa9b104
v1.0
complete
Taco
Taco_78986_C
def min_intervals_to_remove(intervals): """ Determines the minimum number of intervals to remove to make the rest of the intervals non-overlapping. >>> min_intervals_to_remove([[1, 2], [2, 3], [3, 4], [1, 3]]) 1 >>> min_intervals_to_remove([[1, 2], [1, 2], [1, 2]]) 2 >>> min_intervals_to_remove(...
def min_intervals_to_remove(intervals): """ Determines the minimum number of intervals to remove to make the rest non-overlapping. :param intervals: List of intervals represented as [start, end] :return: Minimum number of intervals to remove """ if not intervals: return 0 # Sort in...
def test_min_intervals_to_remove(): assert min_intervals_to_remove([[1, 2], [2, 3], [3, 4], [1, 3]]) == 1 assert min_intervals_to_remove([[1, 2], [1, 2], [1, 2]]) == 2 assert min_intervals_to_remove([[1, 2], [2, 3]]) == 0 assert min_intervals_to_remove([]) == 0 assert min_intervals_to_remove([[1, 4]...
[ { "docstring": "Determines the minimum number of intervals to remove to make the rest non-overlapping.\n\n:param intervals: List of intervals represented as [start, end]\n:return: Minimum number of intervals to remove", "function_declaration": "def min_intervals_to_remove(intervals):", "function_name": ...
[ 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 erase_overlap_intervals(intervals):\n \"\"\"\n Find the minimum number of intervals to remove to make the intervals non-overlapping.\n :param interval...
trial_gpt4o_2
{ "original_instruction": "Given a list of intervals, determine the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.\n\nConstraints\n\n* $1 \\leq n \\leq 100,000$\n* $1 \\leq start_i, end_i \\leq 1,000,000,000$\n* Each interval [start_i, end_i] is represented by two in...
0.643059
Taco_78986
C
[ "min_intervals_to_remove", "solve" ]
2
[ [ "solve", "min_intervals_to_remove" ] ]
1
[]
false
[]
false
pytest
false
[]
true
62d993f1b88be29a592d152ef778c57d496b610f
01baaf6e45ffda2deeb29a988f6c23c1485443c5
v1.0
complete
Taco
Taco_79159_C
def max_temperature_difference(test_cases): """ Determines the maximum difference in temperatures for multiple test cases. Parameters: test_cases (list of list of tuple): Each element is a test case, which is a list of tuples with highest and lowest temperat...
def max_temperature_difference(test_cases): """ Determines the maximum difference in temperatures for multiple test cases. Parameters: test_cases (list of list of tuple): Each element is a test case, which is a list of tuples with highest and lowest temperat...
from solution import process def test_example_case(): input_str = "2\n3\n30 10\n40 20\n25 5\n2\n15 5\n10 0\n" expected_output = [35, 15] assert process(input_str) == expected_output def test_single_day(): input_str = "1\n1\n0 -50\n" expected_output = [50] assert process(input_str) == expected_...
[ { "docstring": "Determines the maximum difference in temperatures for multiple test cases.\n\nParameters:\ntest_cases (list of list of tuple): Each element is a test case, which is a list \n of tuples with highest and lowest temperatures.\n \...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_temperature_range(T, test_cases):\n \"\"\"\n Returns a list of the maximum temperature differences for each test case.\n \n Parameters:\n T ...
trial_gpt4o_2
{ "original_instruction": "Jamie is a keen camper and loves to track the weather during his camping trips. On one such trip, Jamie decided to record the highest and lowest temperatures every day. After coming back, Jamie realized that it would be interesting to find the temperature range he experienced during the tri...
0.597618
Taco_79159
C
[ "max_temperature_difference", "parse_input", "process" ]
3
[ [ "process", "max_temperature_difference" ], [ "process", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
ba08787f927bb52301178883e9723dd8261e35f7
cf61bb85f07b89c4b88af1f0be59361ed2d5d062
v1.0
complete
Taco
Taco_79193_C
def next_palindrome(n: int) -> int: """ Find the smallest palindrome number greater than n. >>> next_palindrome(123) 131 >>> next_palindrome(99) 101 >>> next_palindrome(1234) 1331 """ def is_palindrome(num: int) -> bool: """ Check if the given number is a palindrome. """
def is_palindrome(num): """ Check if the given number is a palindrome. """ return str(num) == str(num)[::-1] def next_palindrome(n): """ Find the smallest palindrome number greater than n. """ n += 1 while not is_palindrome(n): n += 1 return n # Example usage: # next_pa...
from solution import next_palindrome def test_next_palindrome_simple(): assert next_palindrome(123) == 131 assert next_palindrome(99) == 101 assert next_palindrome(1234) == 1331 def test_next_palindrome_small_numbers(): assert next_palindrome(1) == 2 assert next_palindrome(9) == 11 assert next...
[ { "docstring": "Check if the given number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Find the smallest palindrome number greater than n.", "function_declaration": "def next_palindrom...
[ 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 next_palindrome(n):\n \"\"\"\n Returns the smallest palindrome number greater than n.\n \"\"\"\n def is_palindrome(num):\n return str(num) =...
trial_gpt4o_2
{ "original_instruction": "Alice loves palindrome numbers and decided to create an interesting game involving them. In this game, you are given an integer `n`, and you are required to find the smallest palindrome number greater than `n`.\n\nA palindrome number is a number that remains the same when its digits are rev...
0.765842
Taco_79193
C
[ "is_palindrome", "next_palindrome" ]
2
[ [ "next_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
237eff95d85fe3a07c69cc948beac7334358d840
f9a7d239c50d71273eb259e6826c857e1bddb847
v1.0
complete
Taco
Taco_79036_C
class TreeNode: def __init__(self, value): self.value = value self.children = [] def build_tree(n, values, edges): nodes = [TreeNode(values[i]) for i in range(n)] for u, v in edges: nodes[u-1].children.append(nodes[v-1]) nodes[v-1].children.append(nodes[u-1]) return node...
class TreeNode: def __init__(self, value): self.value = value self.children = [] def build_tree(n, values, edges): nodes = [TreeNode(values[i]) for i in range(n)] for u, v in edges: nodes[u-1].children.append(nodes[v-1]) nodes[v-1].children.append(nodes[u-1]) return node...
def test_example_1(): n = 5 values = [1, 2, 3, 4, 5] edges = [(1, 2), (1, 3), (2, 4), (2, 5)] assert solve(n, values, edges) == 8 def test_example_2(): n = 3 values = [10, 2, 3] edges = [(1, 2), (1, 3)] assert solve(n, values, edges) == 13 def test_single_node_tree(): n = 1 val...
[]
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef find_max_sum_longest_path(N, values, edges):\n tree = defaultdict(list)\n for U, V in edges:\n tree[U].appe...
trial_gpt4o_1
{ "original_instruction": "You are given a binary tree with N nodes. Each node has an integer value assigned to it. Your task is to find the sum of values of nodes on the longest path from the root to any leaf. If there are multiple longest paths, consider the path with the maximum sum of node values.\n\nInput:\n\nTh...
0.65391
Taco_79036
C
[ "build_tree", "find_longest_path_sum", "solve" ]
3
[ [ "solve", "build_tree" ], [ "solve", "find_longest_path_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
bb98dd729b3c43deaf5301002af01e46f39acf5f
5007947fd4fdffdfe8f8a33236cf4888ce84b43c
v1.0
complete
Taco
Taco_78855_C
def solve(input_text: str) -> List[int]: """Calculate the total number of words in the specified book for each test case. Args: input_text (str): The input string containing test cases details. Returns: List[int]: A list containing the total number of words in the specified book for each t...
def calculate_total_words(test_cases): results = [] for test_case in test_cases: book_details = test_case['book_details'] query_id = test_case['query_id'] for book in book_details: if book['id'] == query_id: results.append(sum(book['words'])) b...
from solution import solve def test_case_1(): input_text = "2\n3\n1 3 100 200 300\n2 2 50 75\n3 4 10 20 30 40\n2\n2\n1 3 100 200 300\n3 4 10 20 30 40\n3" expected_output = [125, 100] assert solve(input_text) == expected_output def test_case_2(): input_text = "1\n1\n50 3 500 600 700\n50" expected_o...
[ { "docstring": null, "function_declaration": "def calculate_total_words(test_cases):", "function_name": "calculate_total_words", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_text):", "function_name": "parse_input", "param...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def total_words_per_book(test_cases):\n results = []\n for case in test_cases:\n books = case['books']\n query_id = case['query_id']\n f...
trial_gpt4o_2
{ "original_instruction": "Aman loves reading and has a collection of books. Each book is represented by a unique ID and has its own number of pages. Each page of a book can contain different numbers of words. Aman wants to know the total number of words across all pages in a specific book from his collection.\n\n**H...
0.595162
Taco_78855
C
[ "calculate_total_words", "parse_input", "solve" ]
3
[ [ "solve", "calculate_total_words" ], [ "solve", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
793fb4a9fc49524d58bba288e13850f33a1ae83c
852676a80e7b6ed5d2976e545c9786612602a625
v1.0
complete
Taco
Taco_78935_C
from typing import List, Tuple def graph_diameter(n: int, m: int, roads: List[Tuple[int, int]]) -> int: """ Determine the diameter of a graph from given number of stations and roads. >>> graph_diameter(4, 4, [(1, 2), (2, 3), (3, 4), (4, 1)]) 2 >>> graph_diameter(5, 4, [(1, 2), (2, 3), (3, 4), (4, 5)]) ...
from collections import deque def bfs(graph, start): """ Perform BFS starting from the vertex `start` and return the farthest node and its distance. """ visited = [-1] * len(graph) visited[start] = 0 q = deque([start]) farthest_node = start max_distance = 0 while q: node = ...
from solution import graph_diameter def test_example_1(): n = 4 m = 4 roads = [(1, 2), (2, 3), (3, 4), (4, 1)] assert graph_diameter(n, m, roads) == 2 def test_example_2(): n = 5 m = 4 roads = [(1, 2), (2, 3), (3, 4), (4, 5)] assert graph_diameter(n, m, roads) == 4 def test_single_edg...
[ { "docstring": "Perform BFS starting from the vertex `start` and return the farthest node and its distance.", "function_declaration": "def bfs(graph, start):", "function_name": "bfs", "parameter_list": "(graph, start)" }, { "docstring": null, "function_declaration": "def graph_diameter(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 deque\n\ndef bfs(graph, start):\n \"\"\"\n Perform BFS starting from the vertex `start` and return the farthest node and its distance...
trial_gpt4o_0
{ "original_instruction": "There is a city with $n$ transportation stations and $m$ bidirectional roads connecting them. Each road has a travel time of 1 unit. The city transit authority wants to improve efficiency by identifying the longest travel time between the two most distant stations.\n\nIf the stations are re...
0.560015
Taco_78935
C
[ "bfs", "graph_diameter" ]
2
[ [ "graph_diameter", "bfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b2a013901cae90abc4ac52652deb7380cb026358
8ad15d06da9d20d24776ed68157a492cc4f3a4a4
v1.0
complete
Taco
Taco_79276_C
def number_to_words(n): """Convert numbers to words for given integer 0 <= n < 100.""" pass def amountToWords(amount): """ Converts an amount in cents to words representing dollars and cents. Parameters: amount (int): The amount in cents. Returns: str: The amount in words. ...
def number_to_words(n): """Convert numbers to words for given integer 0 <= n < 100.""" words_1_to_19 = [ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "...
from solution import amountToWords def test_amount_in_single_dollars_and_single_cents(): assert amountToWords(101) == "one dollar and one cent" def test_amount_in_single_dollars_and_multiple_cents(): assert amountToWords(107) == "one dollar and seven cents" def test_amount_in_tens_of_dollars_and_single_cents...
[ { "docstring": "Convert numbers to words for given integer 0 <= n < 100.", "function_declaration": "def number_to_words(n):", "function_name": "number_to_words", "parameter_list": "(n)" }, { "docstring": "Converts an amount in cents to words representing dollars and cents.\n\nParameters:\nam...
[ 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 number_to_words(n):\n \"\"\"Convert numbers to words for given integer 0 <= n < 100.\"\"\"\n \n words_1_to_19 = [\n \"zero\", \"one\", \"two\",...
trial_gpt4o_0
{ "original_instruction": "Given an integer amount representing cents (0 <= amount <= 10000), write a function to convert it into a string representing that amount in dollars and cents in words.\nNote: Consider the singular and plural forms based on the values, as well as zero values.\nExamples of conversion:\n1234 -...
0.598831
Taco_79276
C
[ "number_to_words", "amountToWords" ]
2
[ [ "amountToWords", "number_to_words" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8f82556d85b4bad50cabfb65e86c8ac1bf0a07fb
099caebddad6efdfb2de45adc6e4aa09c594d38b
v1.0
complete
Taco
Taco_79141_C
import os from collections import Counter import string def read_documents(directory): """Reads all documents in the provided directory and returns a list of their contents. Args: directory (str): Path to the directory containing documents. Returns: List[str]: List of documents' contents. """...
import os from collections import Counter, defaultdict import string import math def read_documents(directory): documents = [] for filename in os.listdir(directory): filepath = os.path.join(directory, filename) if os.path.isfile(filepath): with open(filepath, 'r') as file: ...
import pytest from solution import classify_new_document, preprocess, read_documents, get_word_frequencies def test_preprocess(): text = "Hello, World!" assert preprocess(text) == ["hello", "world"] def test_get_word_frequencies(): docs = ["Hello world", "world of Python"] word_freq = get_word_frequen...
[ { "docstring": null, "function_declaration": "def read_documents(directory):", "function_name": "read_documents", "parameter_list": "(directory)" }, { "docstring": "Basic preprocessing of text by:\n- Converting to lowercase\n- Removing punctuation", "function_declaration": "def preproces...
[ 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": "import os\nimport string\nfrom collections import Counter, defaultdict\nimport math\n\ndef tokenize(text):\n \"\"\"\n Tokenizes the input text into words.\n ...
trial_gpt4o_8
{ "original_instruction": "You are tasked with developing a program to analyze the distribution of words in a series of text files and determine which category each file most likely belongs to based on word frequency. The three categories are: News, Sports, and Entertainment. You are provided with a training set of d...
0.737686
Taco_79141
C
[ "read_documents", "preprocess", "get_word_frequencies", "classify_document", "classify_new_document" ]
5
[ [ "classify_document", "get_word_frequencies" ], [ "classify_document", "preprocess" ], [ "classify_new_document", "classify_document" ], [ "classify_new_document", "read_documents" ], [ "get_word_frequencies", "preprocess" ] ]
5
[]
false
[]
false
pytest
true
[]
true
0129817d6fd4a8bedee92fb8f0a1aebcb16dc00a
a2240e1619a38838d379d326b3049570c0f6fc04
v1.0
complete
Taco
Taco_79402_C
def is_prime(num: int) -> bool: """ Returns True if the input number is a prime number, otherwise False. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False """ def reverse_num(n: int) -> int: """ Returns the reversed digits of the input number. >>> reverse_num(123) == ...
def is_prime(num): """ Returns True if the input number is a prime number, otherwise False. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while (i * i) <= num: if num % i == 0 or num % (i + 2) ==...
from solution import is_prime, reverse_num, is_reversed_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(17) == True assert is_prime(20) == False assert is_prime(1) == False def test_reve...
[ { "docstring": "Returns True if the input number is a prime number, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the reversed digits of the input number.", "function_declaration": "def r...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a given number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n ...
trial_gpt4o_3
{ "original_instruction": "Digits Reversal\n\nProblem Statement\n\nGiven a non-negative integer n, reverse the digits of n and determine if the resultant number is a prime. Write a function to check whether the reversed number is a prime number or not.\n\nA prime number is a number greater than 1 with no positive div...
0.773944
Taco_79402
C
[ "is_prime", "reverse_num", "is_reversed_prime" ]
3
[ [ "is_reversed_prime", "is_prime" ], [ "is_reversed_prime", "reverse_num" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f64b2165facbe9708bb42407571881810db1c793
be5b61e2902ee838192c8c1ab87315858addce06
v1.0
complete
Taco
Taco_79188_C
def shift_string(s: str, k: int) -> str: """ Shifts all alphabetic characters in the string s by k positions in the alphabet while preserving the positions of non-alphabetic characters. >>> shift_string("Hello, World!", 3) == "Khoor, Zruog!" >>> shift_string("Encrypt123", 5) == "Jshwduy123" ""...
def shift_char(c, k): if 'a' <= c <= 'z': return chr((ord(c) - ord('a') + k) % 26 + ord('a')) elif 'A' <= c <= 'Z': return chr((ord(c) - ord('A') + k) % 26 + ord('A')) else: return c def shift_string(s, k): """ Shifts all alphabetic characters in the string s by k positions ...
from solution import shift_string def test_shift_string_simple_case(): assert shift_string("Hello, World!", 3) == "Khoor, Zruog!" def test_shift_string_with_numbers(): assert shift_string("Encrypt123", 5) == "Jshwduy123" def test_shift_string_wrap_around(): assert shift_string("xyz", 3) == "abc" def tes...
[ { "docstring": null, "function_declaration": "def shift_char(c, k):", "function_name": "shift_char", "parameter_list": "(c, k)" }, { "docstring": "Shifts all alphabetic characters in the string s by k positions\nin the alphabet, preserving the positions of non-alphabetic characters.", "f...
[ 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 shift_char(c, k):\n if 'a' <= c <= 'z':\n return chr((ord(c) - ord('a') + k) % 26 + ord('a'))\n elif 'A' <= c <= 'Z':\n return chr((ord(c) ...
trial_gpt4o_0
{ "original_instruction": "You have been hired by a top-security agency to develop an encryption mechanism for their messaging system. The mechanism uses a unique method of shifting the positions of characters within a string while preserving the order of non-letter characters. \n\nYour task is to write a function th...
0.743675
Taco_79188
C
[ "shift_char", "shift_string" ]
2
[ [ "shift_string", "shift_char" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bbf73d411e1a290be61314ca06c1b1e5e6f2bf71
8c2348daa2c9e81425e8ff832be8f316f511b1e9
v1.0
complete
Taco
Taco_78625_C
from typing import List, Tuple from math import sqrt from itertools import permutations def calculate_distance(point1: Tuple[int, int], point2: Tuple[int, int]) -> float: """ Calculate the Euclidean distance between two points. >>> calculate_distance((0, 0), (3, 4)) 5.0 >>> calculate_distance((1, 1), (...
from itertools import permutations from math import sqrt def calculate_distance(point1, point2): return sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2) def find_minimum_distance(waypoints): n = len(waypoints) min_distance = float('inf') for perm in permutations(range(n)): ...
def test_calculate_distance(): assert calculate_distance((0, 0), (3, 4)) == 5.0 assert calculate_distance((1, 1), (4, 5)) == 5.0 def test_find_minimum_distance_simple(): waypoints = [(0, 0), (1, 0), (1, 1), (0, 1)] assert find_minimum_distance(waypoints) == 4.0 def test_minimum_track_distance_single_c...
[ { "docstring": null, "function_declaration": "def calculate_distance(point1, point2):", "function_name": "calculate_distance", "parameter_list": "(point1, point2)" }, { "docstring": null, "function_declaration": "def find_minimum_distance(waypoints):", "function_name": "find_minimum_...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\nimport math\n\ndef calculate_distance(point1, point2):\n return math.sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2)\n\ndef mini...
trial_gpt4o_4
{ "original_instruction": "You have been tasked with organizing a race event. For the event, you need to design a track such that the total length of the track is minimized but it contains a series of required waypoints. Given a set of waypoints, each with a specific distance between them, determine the minimum total...
0.618775
Taco_78625
C
[ "calculate_distance", "find_minimum_distance", "minimum_track_distance", "main" ]
4
[ [ "find_minimum_distance", "calculate_distance" ], [ "minimum_track_distance", "find_minimum_distance" ] ]
2
[]
false
[]
false
pytest
false
[]
true
0fe24429bb95ce4f7adebcb445057da474289e58
ae394f5f5dc895dde98f83aadbeb8159b07860fb
v1.0
complete
Taco
Taco_79230_C
import itertools def tsp_min_cost(n, cost): """ Find the minimum cost to complete the trip where friends visit each city exactly once and return to the starting city. :param n: int, number of cities :param cost: list of list of ints, cost[i][j] is the cost of traveling from city i to city j ...
import itertools def tsp_min_cost(n, cost): """ Find the minimum cost to complete the trip where friends visit each city exactly once and return to the starting city. :param n: int, number of cities :param cost: list of list of ints, cost[i][j] is the cost of traveling from city i to city j ...
from solution import tsp_min_cost, solve def test_tsp_min_cost(): assert tsp_min_cost(4, [ [0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0, 30], [20, 25, 30, 0] ]) == 80 assert tsp_min_cost(3, [ [0, 10, 15], [10, 0, 20], [15, 20, 0] ]) == 45 ...
[ { "docstring": "Find the minimum cost to complete the trip where friends visit each city exactly once \nand return to the starting city.\n\n:param n: int, number of cities\n:param cost: list of list of ints, cost[i][j] is the cost of traveling from city i to city j\n:return: int, minimum cost to complete the tr...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
2
hard
0.222
{ "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_cost_trip(n, cost):\n \"\"\"\n Finds the minimum cost to complete the trip where friends visit each city exactl...
trial_gpt4o_9
{ "original_instruction": "A group of friends are planning a road trip. They have a specific list of cities they want to visit, and they have asked you to help them with the logistics of the trip. The friends will start the trip from one of the cities and will visit each of the listed cities exactly once before retur...
0.679491
Taco_79230
C
[ "tsp_min_cost", "solve" ]
2
[ [ "solve", "tsp_min_cost" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8ccec783de0893e739a0f4fbd1b879de77b5e03d
f05421d6793e3ef6376d8207ff3811bcbc70612b
v1.0
complete
Taco
Taco_79129_C
def first_unique_number(test_cases): """ Given a list of test cases, find the first integer in each list that occurs only once. If no such integer exists, return -1 for that test case. >>> first_unique_number([[2, 3, 4, 2, 3]]) [4] >>> first_unique_number([[1, 2, 3, 4, 5, 1]]) [2] >>> ...
def first_unique_number(test_cases): results = [] for case in test_cases: count = {} for num in case: count[num] = count.get(num, 0) + 1 found = -1 for num in case: if count[num] == 1: found = num break results.appen...
import pytest from solution import first_unique_number, parse_input, produce_output, solve_problem def test_first_unique_number(): assert first_unique_number([[2, 3, 4, 2, 3]]) == [4] assert first_unique_number([[1, 2, 3, 4, 5, 1]]) == [2] assert first_unique_number([[7, 7, 7, 7]]) == [-1] assert first...
[ { "docstring": null, "function_declaration": "def first_unique_number(test_cases):", "function_name": "first_unique_number", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", "paramet...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_first_non_repeating_integer(test_cases):\n \"\"\"\n Given a list of test cases, finds and returns the first integer in each list that\n occurs on...
trial_gpt4o_2
{ "original_instruction": "Watson gives Sherlock a list of positive integers and asks him to find the first integer in the list that occurs only once. Help Sherlock.\nYou are given a list of integers. You have to find the first integer that occurs only once in the list. If no such integer exists, print -1.\n\nInput a...
0.615309
Taco_79129
C
[ "first_unique_number", "parse_input", "produce_output", "solve_problem" ]
4
[ [ "solve_problem", "first_unique_number" ], [ "solve_problem", "parse_input" ], [ "solve_problem", "produce_output" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
956b74414f75ffe4ea6b38c5e2e5ab7b8eb08666
31d828e26e19fce6a29f8f073ee24ef4cfad1e72
v1.0
complete
Taco
Taco_79692_C
import math def is_interesting_number(n: int) -> str: """ Determine whether a given number is interesting according to Polycarpus's definition. A number is interesting if it is a prime number or can be expressed as the product of exactly two prime numbers. >>> is_interesting_number(5) 'Yes' >>...
import math def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def is_interesting_number(n): ...
from solution import is_interesting_number def test_prime_numbers(): assert is_interesting_number(2) == "Yes" assert is_interesting_number(5) == "Yes" assert is_interesting_number(11) == "Yes" def test_product_of_two_primes(): assert is_interesting_number(6) == "Yes" # 2*3 assert is_interesting_n...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def is_interesting_number(n):", "function_name": "is_interesting_number", "parameter_list": "(n)" } ]
[ 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 if n == 2:\n return True\n if n % 2 == 0:\n return False\n p = 3\n while p * p <...
trial_gpt4o_2
{ "original_instruction": "Polycarpus enjoys solving number problems. One day, he encountered an interesting problem related to the properties of prime numbers. He defines an interesting number as a number that is either a prime number itself or can be expressed as the product of exactly two prime numbers (which coul...
0.662187
Taco_79692
C
[ "is_prime", "is_interesting_number" ]
2
[ [ "is_interesting_number", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7d80334d63068d7db6cdacc6b09fc4e20ad780c0
2c03333aa6afbd74afe49f27fb26a7fa249ebe53
v1.0
complete
Taco
Taco_79611_C
def is_subsequence(s: str, word: str) -> bool: """ Check if word is a subsequence of the string s. >>> is_subsequence("abcde", "a") True >>> is_subsequence("abcde", "bb") False >>> is_subsequence("abcde", "acd") True """ def count_subsequences(s: str, words: List[str]) -> int: "...
def is_subsequence(s, word): """ Check if word is a subsequence of the string s. :param s: The main string :param word: The word to check if it's a subsequence :return: True if word is a subsequence of s, False otherwise """ it = iter(s) return all(char in it for char in word) def coun...
def test_is_subsequence(): assert is_subsequence("abcde", "a") == True assert is_subsequence("abcde", "bb") == False assert is_subsequence("abcde", "acd") == True assert is_subsequence("xyz", "xyz") == True assert is_subsequence("xyz", "zx") == False def test_count_subsequences(): assert count_...
[ { "docstring": "Check if word is a subsequence of the string s.\n\n:param s: The main string\n:param word: The word to check if it's a subsequence\n:return: True if word is a subsequence of s, False otherwise", "function_declaration": "def is_subsequence(s, word):", "function_name": "is_subsequence", ...
[ 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 \"\"\"\n Returns True if word is a subsequence of s.\n \"\"\"\n it = iter(s)\n for char in word:\n if char not...
trial_gpt4o_2
{ "original_instruction": "**Problem**\n\nGiven a string `s` and a list of words `words`, determine the number of words that are subsequences of `s`. A subsequence of a string is a new string generated from the original string by deleting some (can be none) of the characters without disturbing the relative positions ...
0.721802
Taco_79611
C
[ "is_subsequence", "count_subsequences" ]
2
[ [ "count_subsequences", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0997d07f2a19481a975865fff7027758bf6bf012
fef3d238558e115d5b5208453d898c7a51acf520
v1.0
complete
Taco
Taco_79117_C
from typing import List, Tuple def minimum_total_latency(N: int, K: int, connections: List[Tuple[int, int, int]]) -> int: """ Determine the minimum total latency from the root to all K selected computers with special software installed in a tree network. Args: N (int): Number of computers in the ...
import heapq def dijkstra(tree, number_of_nodes, start): distances = {node: float('infinity') for node in range(1, number_of_nodes + 1)} distances[start] = 0 priority_queue = [(0, start)] while priority_queue: current_distance, current_node = heapq.heappop(priority_queue) ...
from solution import minimum_total_latency def test_example_case(): assert minimum_total_latency(6, 3, [(1, 2, 1), (1, 3, 2), (2, 4, 1), (2, 5, 2), (5, 6, 1)]) == 3 def test_min_k(): assert minimum_total_latency(5, 1, [(1, 2, 3), (2, 3, 4), (3, 4, 5), (4, 5, 6)]) == 0 def test_same_latencies(): assert mi...
[ { "docstring": null, "function_declaration": "def dijkstra(tree, number_of_nodes, start):", "function_name": "dijkstra", "parameter_list": "(tree, number_of_nodes, start)" }, { "docstring": null, "function_declaration": "def minimum_total_latency(N, K, connections):", "function_name"...
[ 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 heapq import heappush, heappop\n\ndef min_total_latency(N, K, edges):\n from collections import defaultdict\n import heapq\n \n # Build graph\n ...
trial_gpt4o_3
{ "original_instruction": "A large computer network consists of $N$ computers connected in an acyclic, undirected graph (i.e., a tree). Each edge in the graph has an associated cost representing the latency between the two computers it connects. The root computer is always computer $1$, and we need to consider paths ...
0.588977
Taco_79117
C
[ "dijkstra", "minimum_total_latency" ]
2
[ [ "minimum_total_latency", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e1e1ffd5a47538a0da6aadae5c3bda75f22ef345
4d094b2be0eb167386f22f2a518badc6ffdd4477
v1.0
complete
Taco
Taco_79502_C
def find_maximum_subarray_sum(arr: List[int]) -> int: """ Given an array of integers, find the contiguous subarray which has the largest sum and return the sum. Implement your solution using a Divide and Conquer approach. >>> find_maximum_subarray_sum([-2, 1, -3, 4, -1, 2, 1, -5, 4]) == 6 >>> find_maxi...
def max_crossing_sum(arr, left, mid, right): """ Helper function to find the maximum sum crossing the middle of the array. """ sm = 0 left_sum = float('-inf') for i in range(mid, left - 1, -1): sm = sm + arr[i] if (sm > left_sum): left_sum = sm sm = 0 ri...
from solution import find_maximum_subarray_sum def test_example_case_1(): arr = [-2, 1, -3, 4, -1, 2, 1, -5, 4] assert find_maximum_subarray_sum(arr) == 6 def test_example_case_2(): arr = [-1, -2, -3, -4, -5, -6] assert find_maximum_subarray_sum(arr) == -1 def test_all_positive_numbers(): arr = [...
[ { "docstring": "Helper function to find the maximum sum crossing the middle of the array.", "function_declaration": "def max_crossing_sum(arr, left, mid, right):", "function_name": "max_crossing_sum", "parameter_list": "(arr, left, mid, right)" }, { "docstring": "Helper function using the di...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_crossing_sum(arr, left, mid, right):\n \"\"\"\n Helper function to find the maximum contiguous subarray sum that crosses the midpoint.\n \"\"\"\n ...
trial_gpt4o_4
{ "original_instruction": "Given an array of integers, find the contiguous subarray which has the largest sum and return the sum. Implement your solution using a Divide and Conquer approach.\n\nInput:\nFirst line contains an integer T, the number of test cases.\nFor each test case, the first line contains an integer ...
0.794768
Taco_79502
C
[ "max_crossing_sum", "max_subarray_sum", "find_maximum_subarray_sum" ]
3
[ [ "find_maximum_subarray_sum", "max_subarray_sum" ], [ "max_subarray_sum", "max_crossing_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
67c24479dafed025083516627ea35042d3d708a7
d1789d3d374b0d32108137f2551a0702ec02257e
v1.0
complete
Taco
Taco_79321_C
def prime_factors(n: int) -> List[int]: """ Returns the list of prime factors of a given positive integer n. >>> prime_factors(6) [2, 3] >>> prime_factors(15) [3, 5] >>> prime_factors(21) [3, 7] >>> prime_factors(10) [2, 5] >>> prime_factors(25) [5, 5] >>> prime_facto...
def prime_factors(n): """ Returns the list of prime factors of a given positive integer n. """ factors = [] divisor = 2 while n > 1: while n % divisor == 0: factors.append(divisor) n = n // divisor divisor += 1 return factors def prime_factors_list(nu...
from solution import prime_factors, prime_factors_list def test_prime_factors(): assert prime_factors(6) == [2, 3] assert prime_factors(15) == [3, 5] assert prime_factors(21) == [3, 7] assert prime_factors(10) == [2, 5] assert prime_factors(25) == [5, 5] assert prime_factors(8) == [2, 2, 2] ...
[ { "docstring": "Returns the list of prime factors of a given positive integer n.", "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": "Given a list of integers, return a sorted list of lists, \neach containing the prim...
[ 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 prime_factors(n):\n \"\"\"\n Returns the list of prime factors of a given number n.\n If n is zero or negative, it returns an empty list.\n \"\"\"\...
trial_gpt4o_2
{ "original_instruction": "Write a function that takes a list of integers and returns a sorted list of their prime factors. If an integer is negative or zero, it should be excluded from the output.\n\n## Examples\n```\nInput: [6, 15, -4, 0, 21]\nOutput: [[2, 3], [3, 5], [3, 7]]\n\nInput: [10, 25, 8]\nOutput: [[2, 5],...
0.823059
Taco_79321
C
[ "prime_factors", "prime_factors_list" ]
2
[ [ "prime_factors_list", "prime_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ecd6a70686454e2c12f2d1884239358fbfabb21e
6f714906fdc20bef8be8b7f68c5ab390638bdb8b
v1.0
complete
Taco
Taco_79446_C
from typing import List def gcd(a, b): while b: a, b = b, a % b return a def simplify_fraction(n, d): """ Simplify a fraction n/d by dividing both the numerator and denominator by their greatest common divisor. >>> simplify_fraction(4, 2) (2, 1) >>> simplify_fraction(6, 9) (2, 3) ...
def gcd(a, b): while b: a, b = b, a % b return a def simplify_fraction(n, d): common_divisor = gcd(n, d) return n // common_divisor, d // common_divisor def to_mixed_number(n, d): integer_part = n // d remainder = n % d if remainder == 0: return f"{integer_part}" else: ...
from solution import simplify_fraction, to_mixed_number, reform_fraction, process_input_output def test_simplify_fraction(): assert simplify_fraction(4, 2) == (2, 1) assert simplify_fraction(6, 9) == (2, 3) assert simplify_fraction(50, 100) == (1, 2) assert simplify_fraction(7, 1) == (7, 1) def test_t...
[ { "docstring": null, "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def simplify_fraction(n, d):", "function_name": "simplify_fraction", "parameter_list": "(n, d)" }, { "docstri...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import gcd\n\ndef simplify_fraction(q, fractions):\n \"\"\"\n This function takes the number of fractions q and a list of fraction strings,\n th...
trial_gpt4o_2
{ "original_instruction": "Write a function to reform fractions by converting them into their simplest forms or mixed numbers. Given a non-negative fraction represented as a string \"N/D\" (where N and D are integers and D > 0), perform the following steps:\n\n1. Simplify the fraction, if possible, by dividing both t...
0.680723
Taco_79446
C
[ "gcd", "simplify_fraction", "to_mixed_number", "reform_fraction", "process_input_output" ]
5
[ [ "process_input_output", "reform_fraction" ], [ "reform_fraction", "simplify_fraction" ], [ "reform_fraction", "to_mixed_number" ], [ "simplify_fraction", "gcd" ], [ "to_mixed_number", "simplify_fraction" ] ]
5
[ "process_input_output" ]
false
[]
false
pytest
true
[]
true
68bb230f353ec017149b4084639448916a0e9812
4b3870bf2ff7742f810824564c53fabb2fcb35fa
v1.0
complete
Taco
Taco_79547_C
import re from collections import defaultdict def parse_record(record): """Parse a single record string to count animal sightings. Args: record (str): A single record containing encoded sightings. Returns: dict: A dictionary with the count of each unique animal. Examples: >>> parse_re...
import re from collections import defaultdict def parse_record(record): pattern = re.compile(r'([a-z])(\d+)') matches = pattern.findall(record) animal_counts = defaultdict(int) for animal, count in matches: animal_counts[animal] += int(count) return animal_counts def combine_results(result...
def test_parse_record(): assert parse_record('a10b20c30') == {'a': 10, 'b': 20, 'c': 30} assert parse_record('a5b15c25a40') == {'a': 45, 'b': 15, 'c': 25} assert parse_record('z100y200z300') == {'z': 400, 'y': 200} def test_combine_results(): records = [ {'a': 10, 'b': 20, 'c': 30}, {'a...
[ { "docstring": null, "function_declaration": "def parse_record(record):", "function_name": "parse_record", "parameter_list": "(record)" }, { "docstring": null, "function_declaration": "def combine_results(results):", "function_name": "combine_results", "parameter_list": "(results...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\nfrom collections import defaultdict\n\ndef decode_records(N, records):\n result = []\n pattern = re.compile(r'([a-z])(\\d+)')\n\n for record in...
trial_gpt4o_2
{ "original_instruction": "Tom is a nature enthusiast who loves counting the animals he sees while hiking. However, all of his counts are written in a specific encoding style where each type of animal is represented by a specific letter, and the count of each sighting is attached as a suffix to the letter. Tom wants ...
0.639632
Taco_79547
C
[ "parse_record", "combine_results", "process_records", "main" ]
4
[ [ "process_records", "combine_results" ], [ "process_records", "parse_record" ] ]
2
[]
false
[]
false
pytest
false
[]
true
27abcd3f137d4d9e05c53cb7f288019d18ba534d
7dc1bc836bf97b95b0341eb3208625d15abaf68b
v1.0
complete
Taco
Taco_79357_C
from typing import List def sum_of_unique_elements(grid: List[List[int]]) -> int: """ Returns the sum of all unique elements in the grid. :param grid: list of list of integers representing the grid :return: sum of all unique elements in the grid """ pass def parse_input(input_str: str) -> Lis...
def sum_of_unique_elements(grid): """ Returns the sum of all unique elements in the grid. :param grid: list of list of integers representing the grid :return: sum of all unique elements in the grid """ element_count = {} for row in grid: for element in row: if eleme...
def test_sum_of_unique_elements(): grid = [ [1, 2, 3], [4, 5, 6], [1, 2, 3] ] assert sum_of_unique_elements(grid) == 15 grid = [ [10] ] assert sum_of_unique_elements(grid) == 10 grid = [ [1, 2, 2], [3, 4, 4], [5, 6, 6] ] asser...
[ { "docstring": "Returns the sum of all unique elements in the grid.\n\n:param grid: list of list of integers representing the grid\n:return: sum of all unique elements in the grid", "function_declaration": "def sum_of_unique_elements(grid):", "function_name": "sum_of_unique_elements", "parameter_lis...
[ 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_unique_elements(grid):\n \"\"\"\n Returns the sum of all unique elements in the grid.\n\n :param grid: list of list of integers representing th...
trial_gpt4o_0
{ "original_instruction": "Given a grid of size MxN filled with integers, you're required to find the sum of all unique elements in the grid.\n\nInput:\n- The first line contains two integers M and N, denoting the number of rows and columns of the grid, respectively.\n- The next M lines each contain N integers repres...
0.632098
Taco_79357
C
[ "sum_of_unique_elements", "parse_input", "main_function" ]
3
[ [ "main_function", "parse_input" ], [ "main_function", "sum_of_unique_elements" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
ca53db1ccedda173433d714ded116f65720b2258
b6f77c903e550978a7bcc1ed2be2187419240d4e
v1.0
complete
Taco
Taco_79549_C
def minimize_max_travel_time(C, R, roads): """ In a kingdom, there are several cities connected by bidirectional roads. Each road has a specific travel time associated with it. The king wants to build a new road such that the maximum travel time between any two cities is minimized. This function calc...
import heapq def calculate_max_distances(adj_matrix, C): dist = [[float('inf')]*C for _ in range(C)] for i in range(C): for j in range(C): if i == j: dist[i][j] = 0 elif adj_matrix[i][j] != float('inf'): dist[i][j] = adj_matrix[i][j] for ...
def test_minimize_max_travel_time(): assert minimize_max_travel_time(4, 4, [(1, 2, 5), (2, 3, 10), (3, 4, 5), (1, 4, 15)]) == 10 assert minimize_max_travel_time(3, 2, [(1, 2, 1), (2, 3, 1)]) == 1 assert minimize_max_travel_time(3, 3, [(1, 2, 1), (2, 3, 1), (3, 1, 2)]) == 2 assert minimize_max_travel_tim...
[ { "docstring": null, "function_declaration": "def calculate_max_distances(adj_matrix, C):", "function_name": "calculate_max_distances", "parameter_list": "(adj_matrix, C)" }, { "docstring": null, "function_declaration": "def minimize_max_travel_time(C, R, roads):", "function_name": "...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef calculate_max_distances(adj_matrix, C):\n dist = [[float('inf')]*C for _ in range(C)]\n for i in range(C):\n for j in range(C):\n ...
trial_gpt4o_0
{ "original_instruction": "In a kingdom, there are several cities connected by bidirectional roads. Each road has a specific travel time associated with it. The king wants to build a new road such that the maximum travel time between any two cities is minimized.\n\n-----Input-----\nThe first line of the input consist...
0.746048
Taco_79549
C
[ "calculate_max_distances", "minimize_max_travel_time" ]
2
[ [ "minimize_max_travel_time", "calculate_max_distances" ] ]
1
[]
false
[]
false
pytest
false
[]
true
25d09ac8fc58022605e99ef6402a03f1089dcd92
603ea1c31739d057100e26942efa7e66809312b3
v1.0
complete
Taco
Taco_79591_C
def is_palindrome(num: int) -> bool: """ Check if a given number is a palindrome. >>> is_palindrome(121) True >>> is_palindrome(123) False """ # Your code here def smallest_palindrome(N: int) -> int: """ Returns the smallest palindrome greater than or equal to N. >>> smallest_palind...
def is_palindrome(num): """ Check if a given number is a palindrome. """ return str(num) == str(num)[::-1] def smallest_palindrome(N): """ Returns the smallest palindrome greater than or equal to N. """ while not is_palindrome(N): N += 1 return N
from solution import smallest_palindrome def test_example1(): assert smallest_palindrome(28) == 33 def test_example2(): assert smallest_palindrome(123) == 131 def test_example3(): assert smallest_palindrome(8) == 8 def test_single_digit_palindrome(): assert smallest_palindrome(5) == 5 def test_near...
[ { "docstring": "Check if a given number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Returns the smallest palindrome greater than or equal to N.", "function_declaration": "def smallest...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(num):\n \"\"\"\n Helper function to determine if a given number is a palindrome.\n \"\"\"\n return str(num) == str(num)[::-1]\n\ndef ...
trial_gpt4o_2
{ "original_instruction": "Given a positive integer N, return the smallest integer Y that is greater than or equal to N and is a palindrome.\n\nA palindrome is a number that reads the same forward and backward, such as 101 or 1331.\n\nExample 1:\nInput: 28\nOutput: 33\nExplanation: The smallest palindrome greater tha...
0.732887
Taco_79591
C
[ "is_palindrome", "smallest_palindrome" ]
2
[ [ "smallest_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e8c766bd64b9f39721778327f741963353f17bc4
4b32c1839375dc008067b5488faf3fb4d956c385
v1.0
complete
Taco
Taco_78945_C
from typing import List, Tuple def min_jumps_to_cross_stones(T: int, test_cases: List[Tuple[Tuple[int, int], List[int], List[int]]]) -> List[int]: """ Determines the minimum number of jumps to cross the river on stones for each friend. Args: T : int : number of test cases test_cases : List[Tup...
def min_jumps_to_cross_stones(T, test_cases): results = [] for i in range(T): N, M = test_cases[i*3] strengths = test_cases[i*3 + 1] W = test_cases[i*3 + 2][0] if strengths[0] < W or strengths[-1] < W: results.append(-1) continue ...
def test_min_jumps_to_cross_stones(): data = "3\n5 2\n3 2 1 4 5\n2\n5 3\n3 2 1 4 5\n3\n4 1\n3 2 1 4\n2" expected_output = [3, 2, -1] T, test_cases = process_input(data) assert min_jumps_to_cross_stones(T, test_cases) == expected_output data = "1\n3 1\n1 1 1\n1" expected_output = [2] T, test...
[ { "docstring": null, "function_declaration": "def min_jumps_to_cross_stones(T, test_cases):", "function_name": "min_jumps_to_cross_stones", "parameter_list": "(T, test_cases)" }, { "docstring": null, "function_declaration": "def process_input(data):", "function_name": "process_input"...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_jumps_to_cross_river(T, test_cases):\n results = []\n \n for i in range(T):\n N, M = test_cases[i][0]\n strengths = test_cases[i][1]...
trial_gpt4o_1
{ "original_instruction": "A group of friends are playing a game where they have to jump across stones placed in a straight line on a river. The friends start at the first stone, and the goal is to reach the last stone following a set of rules. Each friend can jump up to a maximum number of stones ahead in one jump, ...
0.612421
Taco_78945
C
[ "min_jumps_to_cross_stones", "process_input", "solve" ]
3
[ [ "solve", "min_jumps_to_cross_stones" ], [ "solve", "process_input" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
e0af09b81641f9afd9f5d33e0a0a3b84dcdb8f87
328e11d87e7c0e0c1fba7a8005dabfcab122e9a5
v1.0
complete
Taco
Taco_79671_C
def max_items(weight_limit: int, items: List[int]) -> int: """ Calculate the maximum number of items that can be packed without exceeding the weight limit. >>> max_items(10, [2, 3, 4, 5]) 3 >>> max_items(15, [1, 2, 8, 4, 5]) 4 """ # Your code here def solve_trip_packing(test_cases: List[Tup...
def max_items(weight_limit, items): items.sort() current_weight = 0 count = 0 for weight in items: if current_weight + weight <= weight_limit: current_weight += weight count += 1 else: break return count def solve_trip_packing(test_cases): res...
import pytest from solution import max_items, solve_trip_packing, process_input, process_output def test_max_items_basic(): assert max_items(10, [2, 3, 4, 5]) == 3 assert max_items(15, [1, 2, 8, 4, 5]) == 4 def test_max_items_edge_cases(): assert max_items(5, [5, 5, 5, 5]) == 1 assert max_items(10, []...
[ { "docstring": null, "function_declaration": "def max_items(weight_limit, items):", "function_name": "max_items", "parameter_list": "(weight_limit, items)" }, { "docstring": null, "function_declaration": "def solve_trip_packing(test_cases):", "function_name": "solve_trip_packing", ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_items_to_pack(W, weights):\n \"\"\"\n Returns the maximum number of items that can be packed without exceeding the weight limit.\n \"\"\"\n # S...
trial_gpt4o_1
{ "original_instruction": "Alice is going on a summer trip and she wants to pack her suitcase optimally. She has a suitcase with a maximum weight capacity W and a set of items, each with a certain weight. Alice wants to know the maximum number of items she can pack without exceeding the weight limit of her suitcase.\...
0.574691
Taco_79671
C
[ "max_items", "solve_trip_packing", "process_input", "process_output" ]
4
[ [ "solve_trip_packing", "max_items" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
124f9c77b7131e05bcd7b72d320f4f154e5c666e
b5758e5808f7bdb347986a1cb45e3b84a962f312
v1.0
complete
Taco
Taco_79873_C
from typing import List def is_prime(n: int) -> bool: """ Checks if a number n is prime. """ pass # implement the function def move_primes_to_front(nums: List[int]) -> List[int]: """ Write a function that takes a list of integers and returns a new list where all the prime numbers are moved...
def is_prime(n): """ Checks if a number n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def move_primes_to_front(nums): ...
from solution import move_primes_to_front def test_move_primes_to_front(): assert move_primes_to_front([10, 3, 4, 7, 6, 11, 13, 15]) == [3, 7, 11, 13, 10, 4, 6, 15] assert move_primes_to_front([1, 2, 3, 5, 8, 9, 10]) == [2, 3, 5, 1, 8, 9, 10] assert move_primes_to_front([4, 6, 8, 10, 12]) == [4, 6, 8, 10, ...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list where all the prime numbers are at the front and non-prime numbers at the back.", "function_declaration"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef is_prime(n: int) -> bool:\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n retur...
trial_gpt4o_2
{ "original_instruction": "Write a function that takes a list of integers and returns a new list where all the prime numbers are moved to the front, and the non-prime numbers are moved to the back, preserving their original order within their respective groups.\n\n## Examples\n\n```python\nFor the input list: [10, 3,...
0.762563
Taco_79873
C
[ "is_prime", "move_primes_to_front" ]
2
[ [ "move_primes_to_front", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a94d91fa88810af64088e5e7c228be6b43f7c376
7e4ea46fcbee5a1ef45965567a51c7c9a58c1954
v1.0
complete
Taco
Taco_79848_C
def floyd_warshall(n, graph): """ Given a list of edges in a graph, computes the shortest paths between all pairs of vertices using the Floyd-Warshall algorithm. >>> floyd_warshall(4, [(1,2,1),(2,3,1),(3,4,1),(4,1,1)]) [[0, 1, 2, 1], [1, 0, 1, 2], [2, 1, 0, 1], [1, 2, 1, 0]] """ pass def strong_dis...
def floyd_warshall(n, graph): dist = [[float('inf')] * n for _ in range(n)] for i in range(n): dist[i][i] = 0 for u, v, w in graph: dist[u-1][v-1] = w dist[v-1][u-1] = w for k in range(n): for i in range(n): for j in range(n): if dist[...
def test_floyd_warshall(): graph = [ (1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 1, 1) ] result = floyd_warshall(4, graph) expected = [ [0, 1, 2, 1], [1, 0, 1, 2], [2, 1, 0, 1], [1, 2, 1, 0] ] assert result == expected def test_strong_...
[ { "docstring": null, "function_declaration": "def floyd_warshall(n, graph):", "function_name": "floyd_warshall", "parameter_list": "(n, graph)" }, { "docstring": null, "function_declaration": "def strong_distance(n, graph):", "function_name": "strong_distance", "parameter_list": ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def floyd_warshall(n, adj_matrix):\n \"\"\"\n Helper function to implement the Floyd-Warshall algorithm to find the shortest\n path between all pairs of v...
trial_gpt4o_2
{ "original_instruction": "Savita is fascinated with graphs and shortest paths. She is trying to experiment by defining a new measure in a connected undirected graph called \"strong distance\" between two vertices $u$ and $v$. The strong distance $s(u, v)$ is defined as the length of the longest shortest path between...
0.577079
Taco_79848
C
[ "floyd_warshall", "strong_distance", "solve" ]
3
[ [ "solve", "strong_distance" ], [ "strong_distance", "floyd_warshall" ] ]
2
[]
false
[]
false
pytest
false
[]
true
9230f8bcbc28d27a6cee57e75ed243f7ee618aef
17687b27daf7a08b7c9ea94084743c40f6f4e7ed
v1.0
complete
Taco
Taco_79200_C
import heapq from typing import List, Tuple def dijkstra(n: int, graph: List[List[Tuple[int, int]]], start: int) -> List[int]: """ Compute shortest paths from the start node to all other nodes using Dijkstra's algorithm. Args: n (int): Number of nodes. graph (List[List[Tuple[int, int]]]): The graph r...
import heapq def dijkstra(n, graph, start): distances = [float('inf')] * (n + 1) distances[start] = 0 pq = [(0, start)] while pq: current_distance, current_node = heapq.heappop(pq) if current_distance > distances[current_node]: continue for nei...
from solution import find_palace_city def test_find_palace_city_example1(): n = 4 m = 4 roads = [ (1, 2, 2), (2, 3, 4), (3, 4, 1), (4, 1, 3) ] assert find_palace_city(n, roads) == 1 def test_find_palace_city_example2(): n = 3 m = 2 roads = [ (1, ...
[ { "docstring": null, "function_declaration": "def dijkstra(n, graph, start):", "function_name": "dijkstra", "parameter_list": "(n, graph, start)" }, { "docstring": null, "function_declaration": "def find_palace_city(n, roads):", "function_name": "find_palace_city", "parameter_lis...
[ 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, graph, start):\n distances = [float('inf')] * n\n distances[start] = 0\n priority_queue = [(0, start)]\n \n while pr...
trial_gpt4o_8
{ "original_instruction": "There is a kingdom with n cities connected by m bidirectional roads. Each road connects two different cities and has a certain length. The king wants to make his kingdom more accessible, so he plans to build a palace in one of the cities. The goal is to place the palace in such a way that t...
0.705779
Taco_79200
C
[ "dijkstra", "find_palace_city" ]
2
[ [ "find_palace_city", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a421500b377c364bf57cd3a73811ddf4fc67b022
d2d54ab19da7cf7c39de2c578b09830b269ffb2b
v1.0
complete
Taco
Taco_79492_C
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def addTwoNumbers(l1, l2): """ Adds two numbers represented by linked lists in reverse order. :param l1: ListNode :param l2: ListNode :return: ListNode """ def add_linked_list_pairs(input...
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def addTwoNumbers(l1, l2): """ Adds two numbers represented by linked lists in reverse order. :param l1: ListNode :param l2: ListNode :return: ListNode """ dummy_head = ListNode(0)...
def parse_output(output_list): lists = [] current_list = [] for item in output_list: if item == '-': lists.append(current_list) current_list = [] else: current_list.append(int(item)) return lists def test_add_two_linked_lists(): input_data = [ ...
[]
[ 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 ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef addTwoNumbers(l1, l2):\n \"\"\"\n Given t...
trial_gpt4o_1
{ "original_instruction": "### Problem Statement\n\nYou are given two linked lists representing two non-negative integers. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write a function to add the two numbers and return the sum as a linked list.\n\nYou may assume the two ...
0.636435
Taco_79492
C
[ "addTwoNumbers", "add_linked_list_pairs" ]
2
[ [ "add_linked_list_pairs", "addTwoNumbers" ] ]
1
[]
false
[ "ListNode" ]
true
pytest
false
[]
true
768fcbdeece8daef17d4cc5997976e56ab7af151
bfc307386f9487d6166d5113b7b17b3cd4717f9f
v1.0
complete
Taco
Taco_80010_C
def find_odd_occurrence(numbers): """ Returns the integer that appears an odd number of times in the list. """ pass def find_odd_occurrences_in_cases(cases): """ Returns a list of answers for each test case. """ pass def parse_input(input_data): """ Parses the input data. "...
def find_odd_occurrence(numbers): """ Returns the integer that appears an odd number of times in the list. """ result = 0 for number in numbers: result ^= number return result def find_odd_occurrences_in_cases(cases): """ Returns a list of answers for each test case. """ ...
import pytest from solution import find_odd_occurrence, find_odd_occurrences_in_cases, parse_input def test_find_odd_occurrence(): assert find_odd_occurrence([1, 2, 3, 2, 3, 1, 3]) == 3 assert find_odd_occurrence([4, 4, 3, 3, 5]) == 5 assert find_odd_occurrence([9, 9, 7, 7, 7]) == 7 assert find_odd_occ...
[ { "docstring": "Returns the integer that appears an odd number of times in the list.", "function_declaration": "def find_odd_occurrence(numbers):", "function_name": "find_odd_occurrence", "parameter_list": "(numbers)" }, { "docstring": "Returns a list of answers for each test case.", "fu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_odd_occurrence(test_cases):\n results = []\n for case in test_cases:\n n, arr = case\n result = 0\n for num in arr:\n ...
trial_gpt4o_2
{ "original_instruction": "You are given a list of integers where each integer appears an even number of times, except for one integer which appears an odd number of times. Your task is to find the integer that appears an odd number of times in the list.\n\n------ Input Format ------ \n\n- The first line of input con...
0.691762
Taco_80010
C
[ "find_odd_occurrence", "find_odd_occurrences_in_cases", "parse_input" ]
3
[ [ "find_odd_occurrences_in_cases", "find_odd_occurrence" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
133ae71ea7127c785f6622377d20fcc7428ac50e
ef65ad469da8bc768a379bbfda3c70f9ddccd99e
v1.0
complete
Taco
Taco_80110_C
def is_prime(n: int) -> bool: """Return True if n is a prime number, otherwise False. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(16) False >>> is_prime(17) True """ pass def sort_special(nums: List[int]) ...
def is_prime(n): """Return True if n is a prime number, otherwise False.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False sqrt_n = int(n**0.5) + 1 for i in range(3, sqrt_n, 2): if n % i == 0: return False return True d...
from solution import sort_special, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(16) == False assert is_prime(17) == True def test_sort_special(): assert sort_special([29, 4, 17, 2,...
[ { "docstring": "Return True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of the numbers sorted such that prime numbers come first in their\noriginal order followed...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_1
{ "original_instruction": "Write a function that takes a list of integers and returns a list of the same integers sorted in ascending order, except that all prime numbers should come first, in the original order they appeared in the input list.\n\nExamples:\n\n```\nInput: [29, 4, 17, 2, 1, 23, 8]\nOutput: [29, 17, 2,...
0.742775
Taco_80110
C
[ "is_prime", "sort_special" ]
2
[ [ "sort_special", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dd1b4ee29695925b87b7bf4451e74f87e84ab295
ea223c776b264a4766df76bbd5f61b718ed995cf
v1.0
complete
Taco
Taco_80352_C
from typing import List def largestNumber(arr: List[int]) -> str: """ Given an array of non-negative integers, arrange them such that they form the largest possible number. >>> largestNumber([10, 2, 9]) '9210' >>> largestNumber([3, 30, 34, 5, 9]) '9534330' """ pass
from functools import cmp_to_key def compare(x, y): # Custom compare function to determine the order if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def largestNumber(arr): """ Returns the largest number that can be formed by concatenating the ar...
from solution import largestNumber def test_example1(): assert largestNumber([10, 2, 9]) == "9210" def test_example2(): assert largestNumber([3, 30, 34, 5, 9]) == "9534330" def test_all_zeros(): assert largestNumber([0, 0, 0]) == "0" def test_single_digit_numbers(): assert largestNumber([1, 2, 3, 4,...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": "Returns the largest number that can be formed by concatenating the array elements.", "function_declaration": "def largestNumber(arr):", "functi...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef compare(a, b):\n \"\"\"\n Custom comparator to decide the order of numbers to form the largest number.\n \"\"\"\n ...
trial_gpt4o_2
{ "original_instruction": "You have an array of integers, and you need to form the largest possible number by concatenating the elements of the array.\n\nGiven an array of non-negative integers, arrange them such that they form the largest possible number. Return the result as a string.\n\n### Example 1:\n**Input:**\...
0.772718
Taco_80352
C
[ "compare", "largestNumber" ]
2
[ [ "largestNumber", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ccd91bf14b3a88f6fb14c405c28a0263de33e81a
a6e05cdd8cc1e3704cbeacd93d8cb7d8ebab4c2e
v1.0
complete
Taco
Taco_80344_C
def find_largest_balanced_bst_size(n: int, shininess_values: List[int]) -> int: """ Determine the maximum number of nodes in the largest balanced binary search tree (BST) that can be constructed from a given sequence of shininess values. >>> find_largest_balanced_bst_size(5, [10, 5, 1, 7, 40]) 5 >>...
from typing import List class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None # Function to construct balanced BST def sorted_array_to_bst(arr: List[int]) -> TreeNode: if not arr: return None mid = len(arr) // 2 node = TreeNode...
from solution import find_largest_balanced_bst_size def test_example_1(): assert find_largest_balanced_bst_size(5, [10, 5, 1, 7, 40]) == 5 def test_example_2(): assert find_largest_balanced_bst_size(7, [10, 20, 30, 40, 50, 60, 70]) == 7 def test_single_element(): assert find_largest_balanced_bst_size(1, ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_balanced_bst_size(values):\n \"\"\"\n Given a sequence of shininess values, returns the maximum number of nodes in the \n largest balanced bin...
trial_gpt4o_2
{ "original_instruction": "In a far-off land, there exists a Kingdom where magical magpies are known for their extraordinary hoarding skills. The magpies are particularly fond of shiny objects, and they have a peculiar way of managing their treasures. Each magpie constructs a binary search tree (BST) where each node ...
0.571079
Taco_80344
C
[ "sorted_array_to_bst", "find_largest_balanced_bst_size" ]
2
[ [ "find_largest_balanced_bst_size", "sorted_array_to_bst" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
ae507e696a44d1aebdbbbe41d54597c8cec2683f
3a1995fc5f1aff1cdaf7c597c46dc105b568995b
v1.0
complete
Taco
Taco_78608_C
def is_valid(board, row, col, num): """ Check if it's valid to place the number 'num' in the board at (row, col). Args: board (List[List[int]]): The 9x9 grid representing the Sudoku board. row (int): The row index where the number is to be placed. col (int): The column index where the number is...
def is_valid(board, row, col, num): """ Check if it's valid to place the number 'num' in the board at (row, col). """ # Check if the number is in the current row or column for i in range(9): if board[row][i] == num or board[i][col] == num: return False # Check if the num...
from solution import solve_sudoku, is_valid, solve_and_print_sudoku def test_is_valid(): grid = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0,...
[ { "docstring": "Check if it's valid to place the number 'num' in the board at (row, col).", "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": "Solve the Sudoku board using backtracking.", ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid(board, row, col, num):\n # Check if 'num' is not in the current row, column and 3x3 subgrid\n for i in range(9):\n if board[row][i] == nu...
trial_gpt4o_8
{ "original_instruction": "Shiro loves solving puzzles and he recently came across the 'Sudoku Solver' challenge. In this challenge, you are given a partially filled 9x9 grid of a Sudoku puzzle and you need to fill in the empty cells such that each row, each column, and each of the nine 3x3 subgrids that compose the ...
0.537443
Taco_78608
C
[ "is_valid", "solve_sudoku", "print_board", "solve_and_print_sudoku" ]
4
[ [ "solve_and_print_sudoku", "print_board" ], [ "solve_and_print_sudoku", "solve_sudoku" ], [ "solve_sudoku", "is_valid" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8ec3a6d2409776aa4924e3a64560a15920e7d82a
9525ee987878650ca00e56c189fc762cfe7996e5
v1.0
complete
Taco
Taco_80388_C
def simplify_equation(equation: str) -> str: """ Given a string representing a mathematical equation which only contains numbers, variables (like `x` or `y`), and the operators `+, -, *, and /`, the function simplifies fractions in the equation by performing all possible simplifications. The function main...
import fractions def simplify_fraction(fraction_str): numerator, denominator = map(int, fraction_str.split('/')) simplified_fraction = fractions.Fraction(numerator, denominator) if simplified_fraction.denominator == 1: return str(simplified_fraction.numerator) return f"{simplified_fraction.nume...
from solution import simplify_equation def test_simplify_equation_basic(): assert simplify_equation("4/2 + 2*3 - 6/3") == "2 + 2*3 - 2" def test_simplify_equation_with_non_fraction(): assert simplify_equation("5 + 3 * 2 - 10/2") == "5 + 3 * 2 - 5" def test_simplify_equation_all_fractions(): assert simpli...
[ { "docstring": null, "function_declaration": "def simplify_fraction(fraction_str):", "function_name": "simplify_fraction", "parameter_list": "(fraction_str)" }, { "docstring": null, "function_declaration": "def simplify_equation(equation):", "function_name": "simplify_equation", ...
[ 0, 1 ]
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": "from sympy import simplify, Rational\n\ndef simplify_equation(equation):\n \"\"\"\n Simplifies fractions in the given equation by pe...
trial_gpt4o_2
{ "original_instruction": "Given a string representing a mathematical equation which only contains numbers, variables (like `x` or `y`), and the operators `+, -, *, and /`, write a function `simplify_equation` that simplifies fractions in the equation by performing all possible simplifications. \n\nThe function shoul...
0.724788
Taco_80388
C
[ "simplify_fraction", "simplify_equation" ]
2
[ [ "simplify_equation", "simplify_fraction" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e487fd1cccca6074a7e1be099f4d11b3839095ea
ced34f0b9603ea77f86327bd8d4ed7ad400700ec
v1.0
complete
Taco
Taco_80383_C
def filter_primes(nums: List[int]) -> List[int]: """ Filters the prime numbers out of the list `nums`. Args: nums (list of int): List of integers to filter. Returns: list of int: List containing only the prime numbers. >>> filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) [2, 3, 5, 7] >>> f...
def is_prime(n): """ Helper function to determine if a number is prime. Returns True if n is prime, otherwise False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n...
from solution import filter_primes def test_filter_primes(): assert filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] assert filter_primes([12, 15, 20, 23, 30, 31]) == [23, 31] assert filter_primes([1, 2, 3]) == [2, 3] assert filter_primes([0, 1, 4, 9, 16, 25, 36]) == [] assert filter_pri...
[ { "docstring": "Helper function to determine if a number is prime.\nReturns True if n is prime, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters the prime numbers out of the list `nums`.\n\nArgs:\nn...
[ 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 Helper function to check if a given number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n r...
trial_gpt4o_1
{ "original_instruction": "You are given a list of integers `nums`. Your task is to return a new list that contains only the prime numbers from the original list `nums`.\n\nExample 1:\nInput: [2, 3, 4, 5, 6, 7, 8, 9, 10]\nOutput: [2, 3, 5, 7]\n\nExample 2:\nInput: [12, 15, 20, 23, 30, 31]\nOutput: [23, 31]\n\nNote:\n...
0.685427
Taco_80383
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a129f872c62898fa69dfc867b11e2e135c904fc9
4e89cbb384736d058670ccd3d40d496120e52677
v1.0
complete
Taco
Taco_79732_C
import heapq def dijkstra(matrix, start): """ Dijkstra's algorithm to find the shortest path from start to all other nodes. Returns a list of shortest path distances from the start node. """ n = len(matrix) dist = [float('inf')] * n dist[start] = 0 priority_queue = [(0, start)] # (dist...
import heapq def dijkstra(matrix, start): """ Dijkstra's algorithm to find the shortest path from start to all other nodes. Returns a list of shortest path distances from the start node. """ n = len(matrix) dist = [float('inf')] * n dist[start] = 0 priority_queue = [(0, start)] # (dist...
def test_shortest_time_to_travel(): N = 4 matrix = [ [0, 2, 1, 3], [2, 0, 4, 5], [1, 4, 0, 3], [3, 5, 3, 0] ] players = [(0, 2), (1, 3), (3, 0)] results = shortest_time_to_travel(N, matrix, players) assert results == [1, 5, 3] def test_all_rooms_directly_connecte...
[ { "docstring": "Dijkstra's algorithm to find the shortest path from start to all other nodes.\nReturns a list of shortest path distances from the start node.", "function_declaration": "def dijkstra(matrix, start):", "function_name": "dijkstra", "parameter_list": "(matrix, start)" }, { "docst...
[ 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": "import heapq\n\ndef dijkstra(n, time_matrix, start, end):\n \"\"\"\n Use Dijkstra's algorithm to find the shortest time from start to end.\n \"\"\"\n d...
trial_gpt4o_1
{ "original_instruction": "An online gaming company is organizing a competition where players need to navigate through a series of interconnected rooms. Each room has multiple doors leading to other rooms, and each door has a specific time delay to open. The goal for the players is to determine the shortest time requ...
0.746478
Taco_79732
C
[ "dijkstra", "shortest_time_to_travel" ]
2
[ [ "shortest_time_to_travel", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
682a817d3c9d8aeaf636d07d6ff4f156ab5d1634
620a4208e54baf3eb642f223676392267f30cbbf
v1.0
complete
Taco
Taco_80408_C
def calculate_repunit(n): """Calculates the n-digit repunit. >>> calculate_repunit(1) 1 >>> calculate_repunit(2) 11 >>> calculate_repunit(3) 111 """ def sum_of_repunits(l, r): """Calculates the sum of repunits from r_l to r_r. >>> sum_of_repunits(1, 1) 1 >>> sum_of_r...
def calculate_repunit(n): """ Calculates the n-digit repunit. """ return (10 ** n - 1) // 9 def sum_of_repunits(l, r): """ Calculates the sum of repunits from r_l to r_r. """ return sum(calculate_repunit(i) for i in range(l, r + 1)) def process_queries(queries): """ Process eac...
from solution import calculate_repunit, sum_of_repunits, process_queries def test_calculate_repunit(): assert calculate_repunit(1) == 1 assert calculate_repunit(2) == 11 assert calculate_repunit(3) == 111 def test_sum_of_repunits_single(): assert sum_of_repunits(1, 1) == 1 assert sum_of_repunits(2...
[ { "docstring": "Calculates the n-digit repunit.", "function_declaration": "def calculate_repunit(n):", "function_name": "calculate_repunit", "parameter_list": "(n)" }, { "docstring": "Calculates the sum of repunits from r_l to r_r.", "function_declaration": "def sum_of_repunits(l, r):", ...
[ 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 repunit_sum(l, r):\n \"\"\"\n Calculates the sum of repunits from r_l to r_r inclusive.\n\n :param l: left index of the range\n :param r: right ind...
trial_gpt4o_2
{ "original_instruction": "After his recent exploration into mathematical sequences, Marin encounters another fascinating challenge, which he calls the \"Repunit Sum Problem.\" A repunit is a number consisting entirely of 1s. For example, 1, 11, 111 are all repunits.\n\nMarin defines a sequence of repunits where each...
0.567479
Taco_80408
C
[ "calculate_repunit", "sum_of_repunits", "process_queries" ]
3
[ [ "process_queries", "sum_of_repunits" ], [ "sum_of_repunits", "calculate_repunit" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
e0f6569aa81adf5eeff751b17a91a107536c961c
f1f617c44fd4ea62054a965ed4ef92dbf55b1020
v1.0
complete
Taco
Taco_80430_C
def longest_domino_chain(n: int, dominoes: List[Tuple[int, int]]) -> int: """ Determine the length of the longest valid chain that can be formed using a subset of the given dominoes. Each domino is represented as a tuple of two integers (a, b). >>> longest_domino_chain(5, [(1, 2), (2, 3), (3, 4), (1, 3...
from itertools import permutations def find_longest_chain(dominoes): def is_chain_valid(chain): for i in range(len(chain) - 1): if chain[i][1] != chain[i+1][0]: return False return True max_length = 0 for perm in permutations(dominoes): for i in rang...
from solution import longest_domino_chain def test_example_1(): assert longest_domino_chain(5, [(1, 2), (2, 3), (3, 4), (1, 3), (4, 5)]) == 4 def test_example_2(): assert longest_domino_chain(3, [(6, 1), (1, 2), (2, 6)]) == 3 def test_single_domino(): assert longest_domino_chain(1, [(0, 0)]) == 1 def te...
[ { "docstring": null, "function_declaration": "def find_longest_chain(dominoes):", "function_name": "find_longest_chain", "parameter_list": "(dominoes)" }, { "docstring": null, "function_declaration": "def longest_domino_chain(n, dominoes):", "function_name": "longest_domino_chain", ...
[ 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 longest_domino_chain(dominoes):\n from collections import defaultdict, deque\n \n def bfs(start):\n queue = deque([(start, [start])])\n ...
trial_gpt4o_3
{ "original_instruction": "Alice loves playing with dominoes. She has a set of dominoes with numbers from 0 to 6 on each half. She wants to use these dominoes to create a chain. A valid chain of dominoes is one in which adjacent halves of neighboring dominoes have matching numbers.\n\nMore specifically, let d_1, d_2,...
0.55782
Taco_80430
C
[ "find_longest_chain", "longest_domino_chain" ]
2
[ [ "longest_domino_chain", "find_longest_chain" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0517202e1208bb775e4133da1b19e2dc5341204c
8106d3ad915e3697dd3bafb97a31f6e3f35d278a
v1.0
complete
Taco
Taco_80371_C
def minimum_distance(n: int, m: int, A: int, B: int, roads: List[Tuple[int, int, int]]) -> int: """ Find the minimum distance required to connect Town A and Town B either directly or indirectly through other towns. Parameters: n (int): Number of towns m (int): Number of roads A (int): Inde...
import heapq def dijkstra(n, roads, A, B): graph = {i: [] for i in range(1, n+1)} for x, y, d in roads: graph[x].append((y, d)) graph[y].append((x, d)) distances = {i: float('inf') for i in range(1, n+1)} distances[A] = 0 priority_queue = [(0, A)] while priority_queue:...
from solution import minimum_distance def test_minimum_distance_example1(): n, m, A, B = 5, 6, 1, 5 roads = [ (1, 2, 3), (2, 3, 4), (3, 1, 1), (1, 4, 5), (4, 5, 2), (2, 5, 7) ] assert minimum_distance(n, m, A, B, roads) == 7 def test_minimum_distance_exa...
[ { "docstring": null, "function_declaration": "def dijkstra(n, roads, A, B):", "function_name": "dijkstra", "parameter_list": "(n, roads, A, B)" }, { "docstring": null, "function_declaration": "def minimum_distance(n, m, A, B, roads):", "function_name": "minimum_distance", "parame...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef minimum_distance(n, m, A, B, roads):\n \"\"\"\n Finds the minimum distance required to connect Town A to Town B\n \n Parameters:\n ...
trial_gpt4o_1
{ "original_instruction": "In a certain kingdom, the king wants to build a new road that connects two towns, Town A and Town B. There are n towns in the kingdom and they are connected by m bidirectional roads. Each road has a specific distance. A road that connects towns x and y with distance d can be represented as ...
0.739007
Taco_80371
C
[ "dijkstra", "minimum_distance" ]
2
[ [ "minimum_distance", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6e2e2cbff6f6bab82d1b4a296e01c983b6aff1eb
bf1a689c4388b197390fa75fd58ece13b539eb74
v1.0
complete
Taco
Taco_80585_C
def rob_circle(nums: List[int]) -> int: """ Determine the maximum amount of money that can be robbed from houses arranged in a circle without alerting the police, given that two adjacent houses cannot be robbed. Examples: >>> rob_circle([2, 3, 2]) 3 >>> rob_circle([1, 2, 3, 1]) 4 >>...
def rob_linear(nums): """ Helper function to rob houses arranged in a linear fashion """ if not nums: return 0 if len(nums) == 1: return nums[0] dp = [0] * len(nums) dp[0] = nums[0] dp[1] = max(nums[0], nums[1]) for i in range(2, len(nums)): dp[i] = ...
from solution import rob_circle def test_example_1(): assert rob_circle([2, 3, 2]) == 3 def test_example_2(): assert rob_circle([1, 2, 3, 1]) == 4 def test_example_3(): assert rob_circle([0]) == 0 def test_empty_list(): assert rob_circle([]) == 0 def test_single_element(): assert rob_circle([5]...
[ { "docstring": "Helper function to rob houses arranged in a linear fashion", "function_declaration": "def rob_linear(nums):", "function_name": "rob_linear", "parameter_list": "(nums)" }, { "docstring": "Returns the maximum amount of money that can be robbed from houses arranged in a circle",...
[ 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rob_linear(nums):\n \"\"\"\n Helper function to solve the problem for a linear arrangement of houses.\n \"\"\"\n prev_max = 0\n curr_max = 0\n ...
trial_gpt4o_8
{ "original_instruction": "You are given a list of non-negative integers representing the amount of money of each house arranged in a circle. Your task is to determine the maximum amount of money you can rob tonight without alerting the police, given that two adjacent houses cannot be robbed.\n\nImportant Note: Becau...
0.536334
Taco_80585
C
[ "rob_linear", "rob_circle" ]
2
[ [ "rob_circle", "rob_linear" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4dee4a1d5d45b6a2309bf49585edf638adde99dd
3b43fd799612b4ef319bb213ab23c0bc6d1586b1
v1.0
complete
Taco
Taco_80343_C
from typing import List, Tuple def sum_of_max_elements_in_subsequences(arr: List[int], k: int) -> int: """ Given an array of N integers and an integer K, calculate the sum of the maximum element in all possible unique subsequences of length K, modulo 10^9+7. >>> sum_of_max_elements_in_subsequences([1, 2, ...
from itertools import combinations def sum_of_max_elements_in_subsequences(arr, k): MOD = 10**9 + 7 subsequence_sums = (max(subseq) for subseq in combinations(arr, k)) return sum(subsequence_sums) % MOD def solve(test_cases): results = [] for n, k, arr in test_cases: results.append(sum_of_...
def test_sum_of_max_elements_in_subsequences(): assert sum_of_max_elements_in_subsequences([1, 2, 3], 2) == 8 assert sum_of_max_elements_in_subsequences([4, 5, 1, 2], 3) == 19 assert sum_of_max_elements_in_subsequences([1, 1, 1], 1) == 3 assert sum_of_max_elements_in_subsequences([1, 1, 1], 2) == 3 ...
[ { "docstring": null, "function_declaration": "def sum_of_max_elements_in_subsequences(arr, k):", "function_name": "sum_of_max_elements_in_subsequences", "parameter_list": "(arr, k)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\nMOD = 10**9 + 7\n\ndef sum_of_max_in_subsequences(arr, N, K):\n subsequences = list(combinations(arr, K))\n max_sum = 0...
trial_gpt4o_2
{ "original_instruction": "A group of explorers have discovered an ancient artifact which contains a riddle. The artifact asks for the calculation of a special kind of sum involving lists of numbers. To move forward, the explorers need to solve the riddle correctly. Assist them by providing a solution for the followi...
0.685745
Taco_80343
C
[ "sum_of_max_elements_in_subsequences", "solve", "parse_input", "format_output", "main" ]
5
[ [ "solve", "sum_of_max_elements_in_subsequences" ] ]
1
[ "parse_input", "format_output" ]
false
[]
false
pytest
false
[]
true
ed98f517f0e8acb60e64d507729fa0087267b04a
2ecc7d9101bddc1b4955bf8b917c92c42bc34439
v1.0
complete
Taco
Taco_80517_C
def max_standing_wizards(T: int, test_cases: List[Tuple[int, List[int]]]) -> List[int]: """ Determine the maximum number of wizards that can be left standing after all optimal challenges. Args: T : int : the number of test cases test_cases : List[Tuple[int, List[int]]] : a list of tuples where...
def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def max_standing_wizards(T, test_cases): def can_challenge(p1, p2): return is_prime(abs(p1 - p2)) results = [] for i in range(T): ...
from solution import max_standing_wizards def test_case_1(): T = 2 test_cases = [ (4, [1, 4, 7, 10]), (3, [5, 6, 15]) ] expected_results = [4, 3] assert max_standing_wizards(T, test_cases) == expected_results def test_all_same_power(): T = 1 test_cases = [ (5, [10, ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def max_standing_wizards(T, test_cases):", "function_name": "max_standing_wizards", "parameter_list": "(T, test_c...
[ 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 math\n\ndef is_prime(n):\n \"\"\"Helper function to check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n retu...
trial_gpt4o_3
{ "original_instruction": "In a magical kingdom, there are N wizards standing in a circle. Each wizard possesses a magical power represented by an integer P_i for wizard i (1 ≤ i ≤ N). Wizards have a peculiar way of challenging each other: a wizard i can challenge another wizard j ( j ≠ i) only if the absolute differ...
0.588925
Taco_80517
C
[ "is_prime", "max_standing_wizards" ]
2
[ [ "max_standing_wizards", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e6c7efca3eb531f30d3945b875fc6b82c81ee5ef
89a718e7a3dcc6d19a6c951ebad1bb74f270d06b
v1.0
complete
Taco
Taco_80550_C
def play_game(sequence): """ Takes the sequence string as input and returns a tuple with two lists: the first list containing the integers Alice counted, and the second list containing the integers Bob counted. >>> play_game("1,2,3,4,5,6,7,8,9") == ([1, 5, 9], [2, 3, 4, 6, 7, 8]) >>> play_game("10,2...
def play_game(sequence): """ Takes the sequence string as input and returns a tuple with two lists: the first list containing the integers Alice counted, and the second list containing the integers Bob counted. """ numbers = list(map(int, sequence.split(','))) alice_counts = [] bob_counts = ...
from solution import play_game, total_sum def test_play_game(): assert play_game("1,2,3,4,5,6,7,8,9") == ([1, 5, 9], [2, 3, 4, 6, 7, 8]) assert play_game("10,20,30,40,50,60,70") == ([10, 50], [20, 30, 40, 60, 70]) assert play_game("1,2,3,4") == ([1], [2, 3, 4]) assert play_game("7,8,9") == ([7], [8, 9]...
[ { "docstring": "Takes the sequence string as input and returns a tuple with two lists:\nthe first list containing the integers Alice counted, and the second list containing the integers Bob counted.", "function_declaration": "def play_game(sequence):", "function_name": "play_game", "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": "def play_game(sequence):\n \"\"\"\n Distribute the numbers from the sequence to Alice and Bob according to their counting rules.\n \n Args:\n sequen...
trial_gpt4o_2
{ "original_instruction": "Alice and Bob are playing a game using a sequence of integers. They will take turns counting numbers from the sequence according to specific rules.\n\nAlice will always start first. On her turn, she counts one number. On Bob's turn, he counts three numbers. This alternating goes on until th...
0.602415
Taco_80550
C
[ "play_game", "total_sum" ]
2
[ [ "total_sum", "play_game" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ea18a872f1c60b88b549afacd50eb9a43f0103ef
8813dd7c635d988ed0f6028cd493901f7e0d8464
v1.0
complete
Taco
Taco_80462_C
from typing import List, Union from collections import deque class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(level_order: List[Union[int, None]]) -> Union[TreeNode, None]: """ Builds a binary tree f...
from typing import List, Union from collections import deque class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(level_order: List[Union[int, None]]) -> Union[TreeNode, None]: if not level_order or level_or...
def test_depth_of_tree(): level_order = [3, 9, 20, None, None, 15, 7] root_val = 3 root = build_tree(level_order) assert depth_of_tree(root) == 3 def test_max_values_at_each_level(): level_order = [3, 9, 20, None, None, 15, 7] root_val = 3 root = build_tree(level_order) assert max_value...
[]
[ 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, Union\nfrom collections import deque\n\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n ...
trial_gpt4o_0
{ "original_instruction": "Heidi has learned about binary trees and their properties. She now needs to perform certain operations on a binary tree, specifically calculating the depth of the tree and finding the maximum value in each level of the tree.\n\nCan you help Heidi with these tasks?\n\n----- Input -----\n\nTh...
0.527183
Taco_80462
C
[ "build_tree", "depth_of_tree", "max_values_at_each_level", "process_tree" ]
4
[ [ "process_tree", "build_tree" ], [ "process_tree", "depth_of_tree" ], [ "process_tree", "max_values_at_each_level" ] ]
3
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
27190d0dd5296dd98d079762b584d3d40de9cfb6
9180ade002623e3121e45a2cbd55d7c7445f44b6
v1.0
complete
Taco
Taco_80410_C
def generate_sequence(n): """ Generates the sequence as described in the problem. Parameters: n (int): A non-negative integer as starting point of the sequence. Returns: List[int]: A list containing the sequence. """ # Your code here def format_sequence(sequence): """ ...
def generate_sequence(n): """ Generates the sequence as described in the problem. Parameters: n (int): A non-negative integer as starting point of the sequence. Returns: List[int]: A list containing the sequence. """ if n == 0: return [0] sequence = [] whil...
from solution import generate_sequence, format_sequence def test_generate_sequence(): assert generate_sequence(6) == [6, 3, 10, 5, 16, 8, 4, 2, 1] assert generate_sequence(0) == [0] assert generate_sequence(1) == [1] assert generate_sequence(7) == [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4...
[ { "docstring": "Generates the sequence as described in the problem.\n\nParameters:\nn (int): A non-negative integer as starting point of the sequence.\n\nReturns:\nList[int]: A list containing the sequence.", "function_declaration": "def generate_sequence(n):", "function_name": "generate_sequence", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_sequence(n):\n \"\"\"\n Generates the sequence based on the given rules and returns it as a string.\n The sequence follows these rules:\n ...
trial_gpt4o_2
{ "original_instruction": "Tom loves playing with numbers, and he has come up with a fun sequence problem. He wants to generate a special sequence based on a given non-negative integer n.\n\nThe sequence is generated as follows:\n\n1. Start with the number n.\n2. If n is even, the next number in the sequence is n/2.\...
0.658651
Taco_80410
C
[ "generate_sequence", "format_sequence", "print_sequence" ]
3
[ [ "print_sequence", "format_sequence" ], [ "print_sequence", "generate_sequence" ] ]
2
[]
false
[]
false
pytest
true
[]
true
937ed7bc4249fdd38bcfeef6c8f93bf03e0127c0
e1138d3149fdd6d6a571b8fef880573ca6006629
v1.0
complete
Taco
Taco_80702_C
def is_prime(num): """ Check if a given number is a prime number.""" pass def find_shortest_list_length(n: int) -> int: """ Find the shortest length of a list starting from 1 that contains exactly n prime numbers with the last number being a prime. >>> find_shortest_list_length(3) 5 >>> fi...
def is_prime(num): """ Check if a given number is a prime number. """ 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...
from solution import find_shortest_list_length def test_small_values(): assert find_shortest_list_length(1) == 2 assert find_shortest_list_length(2) == 3 assert find_shortest_list_length(3) == 5 def test_edge_cases(): assert find_shortest_list_length(10) == 29 assert find_shortest_list_length(15) ...
[ { "docstring": "Check if a given number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Find the shortest length of a list starting from 1 that contains exactly n prime numbers \nwith the last number...
[ 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 shortest_list_with_n_primes(n):\n \"\"\"\n Returns the shortest length of a list of consecutive integers from 1 \n that includes exactly n prime numbe...
trial_gpt4o_3
{ "original_instruction": "Mike wants to create a list of consecutive integers starting from 1 that includes exactly n prime numbers. However, the list must have its last number p being a prime number. Help Mike find the shortest length of this list.\n\n-----Constraints-----\n - 1 ≦ n ≦ 10^4\n\n-----Input-----\nThe i...
0.787394
Taco_80702
C
[ "is_prime", "find_shortest_list_length" ]
2
[ [ "find_shortest_list_length", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
61e831d5a6674ca513ce3243dd2723a5ab1d9d10
aed43022b78bbfda93deff9506c434858da4c911
v1.0
complete
Taco
Taco_80305_C
def find_minimum_toll(n: int, m: int, roads: List[Tuple[int, int, int]]) -> int: """ Find the minimal sum of toll fees to keep the cities connected. The function takes the number of cities `n`, the number of roads `m`, and a list of tuples `roads` where each tuple contains three integers ai, bi, ci represe...
def find_minimum_toll(n, m, roads): """ Find the minimal sum of toll fees to keep the cities connected. """ # Kruskal's algorithm to find the Minimum Spanning Tree (MST) parent = list(range(n)) def find(x): if parent[x] != x: parent[x] = find(parent[x]) return parent...
def test_find_minimum_toll_case1(): assert solve("4 6\n1 2 3\n1 3 4\n1 4 2\n2 3 1\n2 4 5\n3 4 7") == 6 def test_find_minimum_toll_case2(): assert solve("5 7\n1 2 1\n2 3 2\n3 4 3\n4 5 4\n1 3 10\n2 4 6\n3 5 8") == 10 def test_find_minimum_toll_case3(): assert solve("3 3\n1 2 2\n1 3 4\n2 3 3") == 5 def test...
[ { "docstring": "Find the minimal sum of toll fees to keep the cities connected.", "function_declaration": "def find_minimum_toll(n, m, roads):", "function_name": "find_minimum_toll", "parameter_list": "(n, m, roads)" }, { "docstring": null, "function_declaration": "def solve(input_data):...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def minimal_toll_fee(n, m, roads):\n \"\"\"\n Function to calculate the minimum sum of toll fees \n to keep the kingdom connected while minimizing the tot...
trial_gpt4o_1
{ "original_instruction": "In a kingdom, there are n cities connected by m roads. Each road has a toll fee associated with it. The kingdom wants to maximize its revenue by ensuring that anyone traveling between different cities has to pay the toll fee. However, they also want to keep the infrastructure cost low by re...
0.651943
Taco_80305
C
[ "find_minimum_toll", "solve" ]
2
[ [ "solve", "find_minimum_toll" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b5e484aaa99b338c0ff4813cd7f2195e53ac68b8
dccf5bf54473a705a2e6aecdd999024b8c26bee0
v1.0
complete
Taco
Taco_80629_C
def process_input_output(n, m, q, road_list, query_list): """ Given a number of cities connected by bidirectional roads, find the minimum time required to travel from a starting city to a destination city for each of the provided queries. Parameters: n (int): Number of cities. m (int): Num...
def floyd_warshall(n, edges): # Initialize distance matrix with infinity dist = [[float('inf')] * n for _ in range(n)] # Distance from a city to itself is 0 for i in range(n): dist[i][i] = 0 # Populate the distance matrix with the given edges for u, v, t in edges: dist[...
from solution import process_input_output def test_example_1(): n, m, q = 4, 4, 3 roads = [(1, 2, 4), (1, 3, 5), (2, 3, 3), (3, 4, 9)] queries = [(1, 4), (2, 4), (1, 3)] assert process_input_output(n, m, q, roads, queries) == [14, 12, 5] def test_example_2(): n, m, q = 5, 3, 2 roads = [(1, 2, ...
[ { "docstring": null, "function_declaration": "def floyd_warshall(n, edges):", "function_name": "floyd_warshall", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def min_travel_time(n, m, q, roads, queries):", "function_name": "min_travel_time", "pa...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\nimport heapq\n\ndef dijkstra(n, edges, start):\n graph = [[] for _ in range(n+1)]\n for u, v, t in edges:\n graph[u].append((v, t))\n ...
trial_gpt4o_1
{ "original_instruction": "You are given a list of cities connected by bidirectional roads. Each road has a weight representing the time it takes to travel from one city to another. You need to find the minimum time required to travel from the starting city to the destination city. You're also given a list of queries...
0.782458
Taco_80629
C
[ "floyd_warshall", "min_travel_time", "process_input_output" ]
3
[ [ "min_travel_time", "floyd_warshall" ], [ "process_input_output", "min_travel_time" ] ]
2
[ "process_input_output" ]
false
[]
false
pytest
true
[]
true
4790d277ea383a5e3b14397a48c0a5675d66bcab
cea51e7836048d48f744d31395b6cf49631a12c5
v1.0
complete
Taco
Taco_80842_C
def reverse_number(n: int) -> int: """ Reverse the digits of the given number. >>> reverse_number(56) 65 >>> reverse_number(123) 321 >>> reverse_number(120) 21 >>> reverse_number(1) 1 """ def is_palindrome(n: int) -> bool: """ Check if the given number is a palindrome. ...
def reverse_number(n): return int(str(n)[::-1]) def is_palindrome(n): s = str(n) return s == s[::-1] def steps_to_palindrome(n): steps = 0 while not is_palindrome(n): n = n + reverse_number(n) steps += 1 return steps
def test_reverse_number(): assert reverse_number(56) == 65 assert reverse_number(123) == 321 assert reverse_number(120) == 21 assert reverse_number(1) == 1 def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(11) == True ass...
[ { "docstring": null, "function_declaration": "def reverse_number(n):", "function_name": "reverse_number", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docst...
[ 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_palindrome(num):\n \"\"\"Check if a number is a palindrome.\"\"\"\n return str(num) == str(num)[::-1]\n\ndef reverse_and_add(num):\n \"\"\"Reverse ...
trial_gpt4o_1
{ "original_instruction": "Alice is a fan of puzzles and recently she found one involving an interesting number sequence. The sequence is derived as follows:\n\n- The sequence starts with a single positive integer n.\n- Each next term is obtained by reversing the digits of the current term and adding it to the curren...
0.71554
Taco_80842
C
[ "reverse_number", "is_palindrome", "steps_to_palindrome" ]
3
[ [ "steps_to_palindrome", "is_palindrome" ], [ "steps_to_palindrome", "reverse_number" ] ]
2
[]
false
[]
false
pytest
false
[]
true
ad38777d328408bd4ab5afe800bc65b0ce9e0d81
66c214757bd156b515b0be39ecd8eb320b5848e7
v1.0
complete
Taco
Taco_80828_C
from typing import List class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def construct_postorder_from_pre_in(preorder: List[int], inorder: List[int]) -> List[int]: """ Given preorder and inorder traversal arrays, const...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def buildTree(preorder, inorder): if not preorder or not inorder: return None # Root is the first element in preorder traversal root_val = preorder[0...
from solution import construct_postorder_from_pre_in def test_example_case(): assert construct_postorder_from_pre_in([3, 9, 20, 15, 7], [9, 3, 15, 20, 7]) == [9, 15, 7, 20, 3] def test_single_node(): assert construct_postorder_from_pre_in([1], [1]) == [1] def test_left_skewed_tree(): assert construct_pos...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_2
{ "original_instruction": "Jason has recently learned about binary trees and their various traversals. He is particularly interested in constructing a binary tree from its preorder and inorder traversal arrays. He knows that the unique binary tree can be constructed if both preorder and inorder traversal arrays are g...
0.556566
Taco_80828
C
[ "buildTree", "postOrderTraversal", "construct_postorder_from_pre_in" ]
3
[ [ "construct_postorder_from_pre_in", "buildTree" ], [ "construct_postorder_from_pre_in", "postOrderTraversal" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
5115c97fc1e5638b29f1cd1f4ab6841084041b71
541804ded4b443c556013405a516310967adc748
v1.0
complete
Taco
Taco_80840_C
def rotate_array(arr, k): """ Rotates the array 'arr' to the right by 'k' steps. The array should be rotated in-place without using extra space. :param arr: List[int], an array of integers to be rotated. :param k: int, non-negative integer representing the number of steps to rotate the arr...
def rotate_array(arr, k): """ Rotates the array 'arr' to the right by 'k' steps. """ n = len(arr) k = k % n # Handle cases where k is larger than the array length # Reverse the first part reverse(arr, 0, n - k - 1) # Reverse the second part reverse(arr, n - k, n - 1) ...
import pytest from solution import rotate_array def test_rotate_array_example1(): assert rotate_array([1, 2, 3, 4, 5], 2) == [4, 5, 1, 2, 3] def test_rotate_array_example2(): assert rotate_array([0, 1, 2, 3, 4, 5, 6], 1) == [6, 0, 1, 2, 3, 4, 5] def test_rotate_array_no_rotation(): assert rotate_array([...
[ { "docstring": "Rotates the array 'arr' to the right by 'k' steps.", "function_declaration": "def rotate_array(arr, k):", "function_name": "rotate_array", "parameter_list": "(arr, k)" }, { "docstring": "Reverses elements in the array 'arr' from index 'start' to 'end'", "function_declarat...
[ 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_array(arr, k):\n \"\"\"\n Rotates an array to the right by k steps.\n \n :param arr: List of integers to be rotated.\n :param k: Number o...
trial_gpt4o_2
{ "original_instruction": "One of the major banks in Metro City has implemented a new security system. The security system rotates an array of integers (representing the unique IDs of employees) to generate new secret passcodes for secure access. The rotation is defined as shifting a part of the array to the beginnin...
0.659637
Taco_80840
C
[ "rotate_array", "reverse" ]
2
[ [ "rotate_array", "reverse" ] ]
1
[]
false
[]
false
pytest
true
[]
true
408c13264f66d0469323c48fdd0c209cb4ebcaea
bf417fd547b6dfe7ab50a437de95f49fbeaf4ab1
v1.0
complete
Taco
Taco_80965_C
def constructBinaryTree(inorder: List[int], preorder: List[int]) -> int: """ Construct a binary tree from given inorder and preorder traversal and return the height of the tree. >>> constructBinaryTree([2, 1, 3], [1, 2, 3]) == 2 >>> constructBinaryTree([2, 1, 3, 4], [1, 2, 3, 4]) == 3 >>> constr...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def buildTree(inorder, preorder): if not inorder or not preorder: return None root_val = preorder.pop(0) root = TreeNode(root_val) inorder_index = inorder.index(root_val) ...
from solution import constructBinaryTree def test_custom_case_1(): assert constructBinaryTree([2, 1, 3], [1, 2, 3]) == 2 def test_custom_case_2(): assert constructBinaryTree([2, 1, 3, 4], [1, 2, 3, 4]) == 3 def test_custom_case_3(): assert constructBinaryTree([3, 2, 4, 1], [1, 2, 3, 4]) == 3 def test_cu...
[]
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class 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 buildTr...
trial_gpt4o_4
{ "original_instruction": "Given the in-order and pre-order traversal of a binary tree, construct the binary tree and return its root. \n\nExample:\nInput:\n2\n3\n1 2 3 \n1 2 3\n4\n2 1 3 4\n1 2 3 4\n\nOutput:\n3\n4\nExplanation:\nTestcase 1: The in-order and pre-order traversal of nodes 1, 2, and 3 reconstructs a bin...
0.573584
Taco_80965
C
[ "buildTree", "treeHeight", "constructBinaryTree" ]
3
[ [ "constructBinaryTree", "buildTree" ], [ "constructBinaryTree", "treeHeight" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
3244e28885308843c7a770045e344c0dbc4bdf72
ffb7dad5a1b413bef12d35e714f96d28698811e7
v1.0
complete
Taco
Taco_80733_C
import re from collections import defaultdict def parse_formula(formula: str) -> dict: """ Parse a chemical formula into a dictionary of elements and their counts. """ # Define regular expression pattern for elements and counts pattern = re.compile(r'([A-Z][a-z]*)(\d*)') # Initialize a dic...
import re from collections import defaultdict def parse_formula(formula): """ Parse a chemical formula into a dictionary of elements and their counts. """ pattern = re.compile(r'([A-Z][a-z]*)(\d*)') element_count = defaultdict(int) for (element, count) in pattern.findall(formula): ...
from solution import are_formulas_equivalent def test_identical_formulas(): assert are_formulas_equivalent("H2O", "H2O") == True def test_rearranged_formula(): assert are_formulas_equivalent("C6H12O6", "H12C6O6") == True def test_complex_identical_formula(): assert are_formulas_equivalent("K4[ON(SO3)2]2"...
[ { "docstring": "Parse a chemical formula into a dictionary of elements and their counts.", "function_declaration": "def parse_formula(formula):", "function_name": "parse_formula", "parameter_list": "(formula)" }, { "docstring": "Check if two chemical formulas are equivalent by comparing the ...
[ 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 re\nfrom collections import defaultdict\n\ndef parse_formula(formula):\n \"\"\"\n Parse a chemical formula into a dictionary of elements and their cou...
trial_gpt4o_0
{ "original_instruction": "Anna got her hands on two strings `x` and `y` representing chemical formulas, consisting of lowercase Latin letters and digits. She wishes to find out if the formula represented by `x` can be transformed to the formula represented by `y` by rearranging the order of its elements. In a chemic...
0.613371
Taco_80733
C
[ "parse_formula", "are_formulas_equivalent", "main" ]
3
[ [ "are_formulas_equivalent", "parse_formula" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4087a720aa4628ef8e424da0f09ecb1ce6af0c6c
b760559f8652b4015737977181c28094a475c61b
v1.0
complete
Taco
Taco_80512_C
def find(parent, i): """ A helper function to find the subset of an element 'i'. """ pass def union(parent, rank, x, y): """ A helper function to do union of two subsets 'x' and 'y'. """ pass def kruskal(n, edges): """ Function to perform Kruskal's algorithm to find the minimum spanning tr...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yr...
def test_minimum_cost(): input_data = """2 4 5 1 2 10 1 3 15 1 4 20 2 3 25 3 4 30 3 1 1 2 10 2 3 15""" expected_output = "45\nImpossible" assert main(input_data) == expected_output def test_single_edge(): input_data = """1 2 1 1 2 5""" expected_output = "5" assert main(input_data) == expected_o...
[ { "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, 0 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class UnionFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.rank = [1] * n\n\n def find(self, u):\n if self.parent[u...
trial_gpt4o_3
{ "original_instruction": "Yara wants to build a theme park and realized that she needed to plan the paths that connect the different attractions so that all attractions are connected. She wants the minimum cost to build these paths. You need to find the minimum cost required to connect all attractions. The attractio...
0.621471
Taco_80512
C
[ "find", "union", "kruskal", "solve_minimum_cost", "main" ]
5
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "solve_minimum_cost", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
b46b7240ca3fb92154e8c2f5c7092581f8f3f53c
2ebfeac7ddf53b8058beb5582f3f7b6cd4d93cf9
v1.0
complete
Taco
Taco_80957_C
def check_graph_coloring(n: int, m: int, edges: List[Tuple[int, int]]) -> str: """ Determine if it is possible to color an undirected, unweighted graph with two colors such that no two adjacent nodes have the same color. >>> check_graph_coloring(5, 4, [(1, 2), (2, 3), (3, 4), (4, 5)]) "YES" >>> check_graph_...
def is_bipartite(n, m, edges): from collections import deque, defaultdict def bfs(start): queue = deque([start]) color[start] = 0 while queue: node = queue.popleft() for neighbor in graph[node]: if color[neighbor] == -1: color[...
from solution import check_graph_coloring def test_example1(): n = 5 m = 4 edges = [(1, 2), (2, 3), (3, 4), (4, 5)] assert check_graph_coloring(n, m, edges) == "YES" def test_example2(): n = 3 m = 3 edges = [(1, 2), (2, 3), (3, 1)] assert check_graph_coloring(n, m, edges) == "NO" def ...
[ { "docstring": null, "function_declaration": "def is_bipartite(n, m, edges):", "function_name": "is_bipartite", "parameter_list": "(n, m, edges)" }, { "docstring": null, "function_declaration": "def check_graph_coloring(n, m, edges):", "function_name": "check_graph_coloring", "pa...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef is_bipartite(n, edges):\n \"\"\"\n Determines if the given graph is bipartite (can be colored with 2 colors).\n\n Par...
trial_gpt4o_2
{ "original_instruction": "You are given an undirected, unweighted graph with n nodes and m edges. Each node is initially uncolored. You are to determine whether it is possible to color the graph using two colors such that no two adjacent nodes have the same color.\n\n-----Input-----\n\nThe first line contains two in...
0.524371
Taco_80957
C
[ "is_bipartite", "check_graph_coloring" ]
2
[ [ "check_graph_coloring", "is_bipartite" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4fb7114933043e63b191889a0d1f13a8fdffecfa
5564d9b4587862eb549dcf70b5385900d9480fbe
v1.0
complete
Taco
Taco_80749_C
def is_bipartite(graph, node, color, colors): queue = [node] colors[node] = color while queue: current = queue.pop(0) for neighbor in graph[current]: if colors[neighbor] == -1: colors[neighbor] = 1 - colors[current] queue.append(neighbor) ...
def is_bipartite(graph, node, color, colors): queue = [node] colors[node] = color while queue: current = queue.pop(0) for neighbor in graph[current]: if colors[neighbor] == -1: colors[neighbor] = 1 - colors[current] queue.append(neighbor) ...
from solution import process_input, graph_coloring def test_graph_coloring_one(): input_data = "4 4\n1 2\n2 3\n3 4\n4 1\n0 0\n" result = process_input(input_data) assert result == [[1, 2, 1, 2]], f"Unexpected result: {result}" def test_graph_coloring_two(): input_data = "3 3\n1 2\n2 3\n3 1\n0 0\n" ...
[ { "docstring": null, "function_declaration": "def is_bipartite(graph, node, color, colors):", "function_name": "is_bipartite", "parameter_list": "(graph, node, color, colors)" }, { "docstring": null, "function_declaration": "def graph_coloring(n, edges):", "function_name": "graph_col...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_be_colored_3_colors(n, m, edges):\n from collections import defaultdict, deque\n\n def is_valid_coloring(node, color, graph, colors):\n for ne...
trial_gpt4o_5
{ "original_instruction": "Given an undirected graph with n nodes and m edges, determine if the graph can be colored using exactly 3 colors such that no two adjacent nodes share the same color. If such a coloring is possible, output the colors of the nodes. If not, output \"Not possible\".\n\nThe input consists of mu...
0.535404
Taco_80749
C
[ "is_bipartite", "graph_coloring", "process_input" ]
3
[ [ "graph_coloring", "is_bipartite" ], [ "process_input", "graph_coloring" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
9cb1629d62788c7832165d6b4b0a19c8b6a59efc
60476188f08fe1d68889ce33eee3cc001e070642
v1.0
complete
Taco
Taco_81155_C
from typing import List def communication_path(n: int, m: int, grid: List[str]) -> str: """ Determine if there is a path from the top-left corner to the bottom-right corner of the grid. >>> communication_path(4, 4, ["....", ".W..", "....", "..W."]) "YES" >>> communication_path(4, 3, [".CW", ".W.", "CW.", "...
from collections import deque def is_path_exist(grid, n, m): """ Determines if there is a path from the top-left corner to the bottom-right corner of the grid. """ def is_valid_move(x, y): return 0 <= x < n and 0 <= y < m and grid[x][y] == '.' and not visited[x][y] directions = [(1, 0), (-...
from solution import communication_path def test_simple_path(): grid = [ "....", ".W..", "....", "..W." ] assert communication_path(4, 4, grid) == "YES" def test_no_path(): grid = [ ".CW", ".W.", "CW.", "C.W" ] assert communicatio...
[ { "docstring": "Determines if there is a path from the top-left corner to the bottom-right corner of the grid.", "function_declaration": "def is_path_exist(grid, n, m):", "function_name": "is_path_exist", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "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": "from collections import deque\n\ndef is_path_exist(grid, n, m):\n \"\"\"\n Determines if there is a path from the top-left corner to the bottom-right corner ...
trial_gpt4o_0
{ "original_instruction": "A team of engineers is working on a project to optimize a large network of computers. One of their tasks is to analyze the communication patterns between the computers in the network. They represent the network as a grid of characters, where '.' represents an empty space, 'C' represents a c...
0.569561
Taco_81155
C
[ "is_path_exist", "communication_path" ]
2
[ [ "communication_path", "is_path_exist" ] ]
1
[]
false
[]
false
pytest
true
[]
true
32d2ac05a74a393a28fe5edb379cb08cca675edf
1b376112aeb5207c29c3ee65595d6db0cc8970da
v1.0
complete
Taco
Taco_81129_C
def find_shortest_path_length(N, M, k, important_vertices, edges): """ Find the length of the shortest path that visits all important vertices in an undirected graph. Args: N (int): Number of vertices. M (int): Number of edges. k (int): Number of important vertices. important_vertices (Lis...
from itertools import permutations from collections import deque, defaultdict def find_shortest_path_length(N, M, k, important_vertices, edges): # Adjacency list representation of graph graph = defaultdict(list) for u, v in edges: graph[u].append(v) graph[v].append(u) # Function to...
def test_simple_cases(): import sys from io import StringIO input_data = "6 7\n3\n2 4 5\n1 2\n1 3\n2 4\n3 4\n4 5\n5 6\n6 3\n" sys.stdin = StringIO(input_data) solve() # Expected output: 8 def test_simple_cases_2(): import sys from io import StringIO input_data = "5 5\...
[ { "docstring": null, "function_declaration": "def find_shortest_path_length(N, M, k, important_vertices, edges):", "function_name": "find_shortest_path_length", "parameter_list": "(N, M, k, important_vertices, edges)" }, { "docstring": null, "function_declaration": "def solve():", "f...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\nfrom collections import deque\nimport sys\n\ndef find_shortest_path(N, M, k, important_vertices, edges):\n # Create the adja...
trial_gpt4o_6
{ "original_instruction": "There is an undirected graph with N vertices and M edges. Each vertex has a unique ID from 1 to N and each edge connects two different vertices. Some vertices are marked as important.\n\nTakahashi needs to find the shortest path that visits all important vertices at least once. Write a prog...
0.654837
Taco_81129
C
[ "find_shortest_path_length", "solve" ]
2
[ [ "solve", "find_shortest_path_length" ] ]
1
[]
false
[]
false
pytest
false
[]
true
33d9f96193301c60f4b9a3425460a9f882f34604
7fdaed61dca6bfa9b26082b8bda4c408742e7723
v1.0
complete
Taco
Taco_81096_C
def is_transformation_possible(n: int, m: int, initial_matrix: List[List[int]], target_matrix: List[List[int]], k: int) -> str: """ Determine if the target matrix can be obtained from the initial matrix with exactly k row-reversing submatrix operations. Args: n (int): The number of rows in the matrix. ...
def are_matrices_equal(mat1, mat2): """ Check if two matrices are equal. """ return mat1 == mat2 def is_transformation_possible(n, m, initial_matrix, target_matrix, k): """ Determine if the target matrix can be obtained from the initial matrix with exactly k row-reversing submatrix operati...
from solution import is_transformation_possible def test_possible_case(): n = 3 m = 3 initial_matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] target_matrix = [ [3, 2, 1], [6, 5, 4], [9, 8, 7] ] k = 3 assert is_transformation_possible(n, m, in...
[ { "docstring": "Check if two matrices are equal.", "function_declaration": "def are_matrices_equal(mat1, mat2):", "function_name": "are_matrices_equal", "parameter_list": "(mat1, mat2)" }, { "docstring": "Determine if the target matrix can be obtained from the initial matrix \nwith exactly k...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def are_matrices_equal(mat1, mat2):\n \"\"\"\n Check if two matrices are equal.\n \"\"\"\n return mat1 == mat2\n\ndef is_transformation_possible(n, m, ...
trial_gpt4o_0
{ "original_instruction": "In a distant galaxy, there exists a matrix called the \"Galaxy Matrix\". The matrix has N rows and M columns. The Galactic Council has decided to introduce a special operation for the Galaxy Matrix:\n\n1. Select any submatrix from the Galaxy Matrix.\n2. Reverse the order of elements in ever...
0.557081
Taco_81096
C
[ "are_matrices_equal", "is_transformation_possible" ]
2
[ [ "is_transformation_possible", "are_matrices_equal" ] ]
1
[]
false
[]
false
pytest
true
[]
true
14000aae6e4c2cb2ede49263d3f1f5b4ba4b8549
a5da81faab78ff882db20393430a2609ef3d2313
v1.0
complete
Taco
Taco_81335_C
def is_subsequence(target: str, candidate: str) -> bool: """ Check if 'candidate' is a subsequence of 'target'. """ it = iter(target) return all(char in it for char in candidate) def find_longest_subsequence(n: int, T: str, candidates: List[str]) -> str: """ Find the longest candidate sequence that...
def is_subsequence(target, candidate): it = iter(target) return all(char in it for char in candidate) def find_longest_subsequence(n, T, candidates): longest_match = "" for candidate in candidates: if is_subsequence(T, candidate): if len(candidate) > len(longest_match): ...
def test_example_case(): assert find_longest_subsequence(5, "ACGTACGTGACG", ["ACT", "ACG", "GAT", "TAC", "GACG"]) == "GACG" def test_no_match_case(): assert find_longest_subsequence(3, "ACGT", ["GTA", "CCC", "GGG"]) == "No Match" def test_same_length_different_order_case(): assert find_longest_subsequence...
[ { "docstring": null, "function_declaration": "def is_subsequence(target, candidate):", "function_name": "is_subsequence", "parameter_list": "(target, candidate)" }, { "docstring": null, "function_declaration": "def find_longest_subsequence(n, T, candidates):", "function_name": "find_...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subsequence(s, t):\n \"\"\"\n Check if s is a subsequence of t.\n \"\"\"\n it = iter(t)\n return all(c in it for c in s)\n\ndef find_longest_...
trial_gpt4o_8
{ "original_instruction": "You are designing a string matching algorithm in a DNA sequencing project. Given a target DNA sequence T and a set of N candidate DNA sequences, your task is to find the longest candidate sequence that can be found as a subsequence in the target sequence T. \n\nA subsequence of a string is ...
0.62785
Taco_81335
C
[ "is_subsequence", "find_longest_subsequence" ]
2
[ [ "find_longest_subsequence", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
false
[]
true
a9f406ccc7d139b74c1f322ad7bed93d97353705
a2a5536fd8c2c3011f130ba6ea9ce7de4a95dc1f
v1.0
complete
Taco
Taco_81342_C
def rotate_matrix_90_clockwise(matrix): """ Rotates the given NxN matrix by 90 degrees in the clockwise direction. >>> rotate_matrix_90_clockwise([ ... [1, 2, 3], ... [4, 5, 6], ... [7, 8, 9] ... ]) [[7, 4, 1], [8, 5, 2], [9, 6, 3]] """ pass def max_diagonal_sum(matrix): ...
def rotate_matrix_90_clockwise(matrix): """ Rotates the given NxN matrix by 90 degrees in the clockwise direction. """ N = len(matrix) rotated_matrix = [[0]*N for _ in range(N)] for i in range(N): for j in range(N): rotated_matrix[j][N-1-i] = matrix[i][j] return rotated_m...
from solution import rotate_matrix_90_clockwise, max_diagonal_sum def test_rotate_matrix_90_clockwise(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] rotated = rotate_matrix_90_clockwise(matrix) expected = [ [7, 4, 1], [8, 5, 2], [9, 6, 3] ] asser...
[ { "docstring": "Rotates the given NxN matrix by 90 degrees in the clockwise direction.", "function_declaration": "def rotate_matrix_90_clockwise(matrix):", "function_name": "rotate_matrix_90_clockwise", "parameter_list": "(matrix)" }, { "docstring": "Returns the maximum sum of the elements i...
[ 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 rotate_matrix_90_clockwise(matrix):\n \"\"\"\n Rotates the given N x N matrix 90 degrees clockwise.\n \"\"\"\n N = len(matrix)\n rotated = [[0] ...
trial_gpt4o_3
{ "original_instruction": "Given a matrix of size $ N \\times N $ consisting of integers. You are allowed to perform a single operation of rotating the matrix by 90 degrees in the clockwise direction any number of times (i.e., 0, 1, 2, 3 times). The goal is to obtain the maximum possible sum of elements in the main d...
0.517049
Taco_81342
C
[ "rotate_matrix_90_clockwise", "max_diagonal_sum", "main" ]
3
[ [ "max_diagonal_sum", "rotate_matrix_90_clockwise" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ba45ac0592912fa295a985b314a7e201cbea0cd9
2b43a02aaa237bc02b32c35c290f237f2c19b499
v1.0
complete
Taco
Taco_81252_C
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(node_list): if not node_list: return None nodes = {node_value: TreeNode(node_value) for node_value, _, _ in node_list} root = nodes[node_list[0][0]] for ...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(node_list): if not node_list: return None nodes = {node_value: TreeNode(node_value) for node_value, _, _ in node_list} root = nodes[node_list[0][0]] for ...
def test_longest_increasing_path(): from solution import build_tree, longest_increasing_path # Test case 1 node_list_1 = [ (10, 5, 15), (5, -1, -1), (15, 12, 20), (12, -1, -1), (20, -1, -1) ] root_1 = build_tree(node_list_1) assert longest_increasing_path...
[]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "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_7
{ "original_instruction": "Given a binary tree, you are tasked with finding the longest path from the root to a leaf node where each node in the path satisfies a given condition. The condition is that the value of a node must be greater than the value of its parent. In other words, each step along the path should mov...
0.568832
Taco_81252
C
[ "build_tree", "longest_increasing_path", "process_test_case" ]
3
[ [ "process_test_case", "build_tree" ], [ "process_test_case", "longest_increasing_path" ] ]
2
[ "process_test_case" ]
false
[ "TreeNode" ]
true
pytest
true
[]
true
b5c70d8105c12d5671d94d30ccb7d4ae798e3559
01bc229c93535b9a934d7caf5e24fdb1f76975be
v1.0
complete
Taco
Taco_81388_C
def product_of_digits(n: int) -> int: """ Returns the product of the digits of n. >>> product_of_digits(11) == 1 >>> product_of_digits(14) == 4 """ pass def nth_term(n: int) -> int: """ Returns the nth term in the sequence as defined. >>> nth_term(1) == 1 >>> nth_term(5) == 5 ...
def product_of_digits(n): """ Returns the product of the digits of n. """ product = 1 while n > 0: product *= (n % 10) n //= 10 return product def nth_term(n): """ Returns the nth term in the sequence as defined. """ if n < 10: return n else: ...
from solution import product_of_digits, nth_term, compute_sequence def test_product_of_digits(): assert product_of_digits(11) == 1 assert product_of_digits(14) == 4 assert product_of_digits(123) == 6 assert product_of_digits(999) == 729 def test_nth_term(): assert nth_term(1) == 1 assert nth_t...
[ { "docstring": "Returns the product of the digits of n.", "function_declaration": "def product_of_digits(n):", "function_name": "product_of_digits", "parameter_list": "(n)" }, { "docstring": "Returns the nth term in the sequence as defined.", "function_declaration": "def nth_term(n):", ...
[ 0, 0, 1, 0 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def digit_product(num):\n \"\"\"\n Returns the product of the digits of an integer num.\n \"\"\"\n product = 1\n while num > 0:\n digit = num...
trial_gpt4o_3
{ "original_instruction": "## Each number in the sequence is the product of its digits if the number is greater than 9, and equal to the number itself otherwise. You are required to compute the nth term of this sequence.\n\n### Input Format\n\nThe first line contains T, the number of test cases. \nEach of the next T...
0.704729
Taco_81388
C
[ "product_of_digits", "nth_term", "compute_sequence" ]
3
[ [ "compute_sequence", "nth_term" ], [ "nth_term", "product_of_digits" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1d93fe84440c94c4b27b4610fd55a63a0f09dcb3
b93edcaea5bf4a872a4a07f0cb10306b8f1e1ab7
v1.0
complete
Taco
Taco_81408_C
def hiking_trip(n: int, m: int, trails: List[Tuple[int, int]]) -> Tuple[int, List[int]]: """ Find the minimum number of trail segments required to visit all scenic spots at least once and the starting spots for these optimal routes. >>> hiking_trip(5, 5, [(1, 2), (1, 3), (3, 4), (2, 4), (4, 5)]) (4, [1...
def find(parent, i): # A utility function to find set of an element i (uses path compression technique) if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): # A function that does union of two sets of x and y (uses...
def test_hiking_trip(): # Test case 1 n, m = 5, 5 trails = [(1, 2), (1, 3), (3, 4), (2, 4), (4, 5)] result = hiking_trip(n, m, trails) assert result == (4, [1]) # Test case 2 n, m = 2, 1 trails = [(1, 2)] result = hiking_trip(n, m, trails) assert result == (1, [1]) # Test c...
[ { "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": "from collections import defaultdict, deque\n\ndef find_min_trail_coverage(n, m, trails):\n # Build the adjacency list representation of the park's graph\n gr...
trial_gpt4o_4
{ "original_instruction": "There is a large national park with several scenic spots connected by hiking trails. You are a ranger stationed at this park, and your task is to find the best way to cover the entire park, visiting all scenic spots with the minimum number of distinct trail segments.\n\nEach trail segment i...
0.647888
Taco_81408
C
[ "find", "union", "kruskal_mst", "hiking_trip" ]
4
[ [ "hiking_trip", "kruskal_mst" ], [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
1c294266aa9651390287acef879077295bb1e98c
77fd6ba55423a988e7a16cf1022b3d133fb751ec
v1.0
complete
Taco
Taco_81411_C
from typing import List def partition(arr: List[int], low: int, high: int) -> int: """ Helper function for the quicksort algorithm >>> partition([10, 7, 8, 9, 1, 5], 0, 5) 4 >>> partition([1, 4, 3, 5, 6, 2], 0, 5) 1 """ pass def quicksort(arr: List[int], low: int, high: int): """ S...
def partition(arr, low, high): i = low - 1 pivot = arr[high] for j in range(low, high): if arr[j] <= pivot: i += 1 arr[i], arr[j] = arr[j], arr[i] arr[i + 1], arr[high] = arr[high], arr[i + 1] return i + 1 def quicksort(arr, low, high): if low < high: ...
from solution import partition, quicksort def test_quicksort(): arr1 = [10, 7, 8, 9, 1, 5] quicksort(arr1, 0, len(arr1) - 1) assert arr1 == [1, 5, 7, 8, 9, 10] arr2 = [1, 4, 3, 5, 6, 2] quicksort(arr2, 0, len(arr2) - 1) assert arr2 == [1, 2, 3, 4, 5, 6] arr3 = [3, 6, 8, 10, 1, 2, 1] q...
[ { "docstring": null, "function_declaration": "def partition(arr, low, high):", "function_name": "partition", "parameter_list": "(arr, low, high)" }, { "docstring": null, "function_declaration": "def quicksort(arr, low, high):", "function_name": "quicksort", "parameter_list": "(ar...
[ 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 partition(arr, low, high):\n pivot = arr[high]\n i = low - 1\n for j in range(low, high):\n if arr[j] <= pivot:\n i += 1\n ...
trial_gpt4o_2
{ "original_instruction": "Given an unsorted array of integers, write a function to sort the array using the quicksort algorithm.\n\nExample 1:\nInput:\narr = [10, 7, 8, 9, 1, 5]\nOutput:\n[1, 5, 7, 8, 9, 10]\n\nExample 2:\nInput:\narr = [1, 4, 3, 5, 6, 2]\nOutput:\n[1, 2, 3, 4, 5, 6]\n\nYour Task:\nYou don't need to...
0.643085
Taco_81411
C
[ "partition", "quicksort" ]
2
[ [ "quicksort", "partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a76a0d911c0dbf9c09f2f8956d4719864a0d281f
3a54e5b943d37ae3205d027f7bcb0164207a66ae
v1.0
complete
Taco
Taco_81441_C
def count_smaller_elements(arr): """ Given an array of integers, return an array where each element is the number of smaller elements to the right of that element. Example: >>> count_smaller_elements([5, 2, 6, 1]) [2, 1, 1, 0] >>> count_smaller_elements([1, 2, 3, 4]) [0, 0, 0, 0] """
def count_smaller_elements(arr): """ Given an array of integers, return an array where each element is the number of smaller elements to the right of that element. :param arr: List[int] - an array of integers :return: List[int] - an array with counts of smaller elements to the right """ n =...
from solution import count_smaller_elements def test_sample_input(): assert count_smaller_elements([5, 2, 6, 1]) == [2, 1, 1, 0] def test_single_element(): assert count_smaller_elements([10]) == [0] def test_all_equal_elements(): assert count_smaller_elements([2, 2, 2, 2]) == [0, 0, 0, 0] def test_decre...
[ { "docstring": "Given an array of integers, return an array where each element is the number of smaller elements to the right of that element.\n\n:param arr: List[int] - an array of integers\n:return: List[int] - an array with counts of smaller elements to the right", "function_declaration": "def count_smal...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_smaller_elements_to_right(arr):\n \"\"\"\n Returns an array where each element is the count of smaller elements to the right of that element in the...
trial_gpt4o_2
{ "original_instruction": "Given an array of integers, return an array where each element is the number of smaller elements to the right of that element. \n\nInput Format\n\nAn array of integers $\\boldsymbol{arr}$ of length $\\boldsymbol{n}$.\n\nConstraints\n\n$1\\leq n\\leq 2\\times10^5$\n\n$-10^9\\leq arr[i]\\leq ...
0.628586
Taco_81441
C
[ "count_smaller_elements", "binary_search" ]
2
[ [ "count_smaller_elements", "binary_search" ] ]
1
[]
false
[]
false
pytest
true
[]
true
187b647acac1e2340a766234b5a3fa79c9678ee3
0c140aab144f1efb4f6e9e662919f801760da279
v1.0
complete
Taco
Taco_81501_C
import math from functools import reduce def earliest_maturity_day(n: int, cycles: List[int]) -> int: """ Returns the earliest day on which all plant types will mature simultaneously. Parameters: - n (int): Number of plant types - cycles (list of int): Growth cycles of the plant types Ret...
import math from functools import reduce def lcm(a, b): """ Helper function to find the least common multiple (LCM) of two numbers. """ return abs(a * b) // math.gcd(a, b) def earliest_maturity_day(n, cycles): """ Returns the earliest day on which all plant types will mature simultaneously. ...
from solution import earliest_maturity_day def test_single_cycle(): assert earliest_maturity_day(1, [4]) == 4 def test_two_cycles(): assert earliest_maturity_day(2, [6, 8]) == 24 def test_three_cycles(): assert earliest_maturity_day(3, [3, 5, 7]) == 105 def test_prime_cycles(): assert earliest_matur...
[ { "docstring": "Helper function to find the least common multiple (LCM) of two numbers.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the earliest day on which all plant types will mature simultaneously.\n\nParameter...
[ 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\nfrom functools import reduce\n\ndef lcm(a, b):\n \"\"\"\n Returns the least common multiple of a and b.\n \"\"\"\n return a * b /...
trial_gpt4o_2
{ "original_instruction": "A top-secret experiment involving genetically modified plants is being conducted on the planet Yavin. The plants exhibit unique growth cycles, with varying times to reach full maturity. Each plant type grows in cycles, repeating its growth pattern infinitely. The research team needs to pred...
0.605866
Taco_81501
C
[ "lcm", "earliest_maturity_day" ]
2
[ [ "earliest_maturity_day", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
50168640ad175fe4ebc870caf6e7f849430f89cc
026142990890641eb455bac8e31bc9677891dd47
v1.0
complete
Taco
Taco_81448_C
def extend_number_to_palindrome(n: int) -> int: """ Given a positive integer number n, add the fewest number of digits to n such that the resulting number is a palindrome and has an even number of digits. If it's not possible to make such a number by adding up to 3 digits, return -1. Otherwise, return...
def is_palindrome(s): return s == s[::-1] def extend_number_to_palindrome(n): n_str = str(n) for i in range(3, -1, -1): for j in range(10**i): potential_palindrome = n_str + str(j) if is_palindrome(potential_palindrome) and len(potential_palindrome) % 2 == 0: ...
from solution import extend_number_to_palindrome def test_extend_number_to_palindrome(): assert extend_number_to_palindrome(123) == 123321, "Test case 1 failed" assert extend_number_to_palindrome(4567) == -1, "Test case 2 failed" assert extend_number_to_palindrome(12) in (1212, 1221), "Test case 3 failed" ...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def extend_number_to_palindrome(n):", "function_name": "extend_number_to_palindrome", "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 create_palindrome(n):\n n_str = str(n)\n for i in range(1, 4):\n candidate = n_str + n_str[-i:][::-1]\n if len(candidate) % 2 == 0 and cand...
trial_gpt4o_2
{ "original_instruction": "You are given a positive integer number n. Your task is to add the fewest number of digits to n such that the resulting number is a palindrome and has an even number of digits. A palindrome is a number that reads the same backward as forward. \n\nIf it's not possible to make such a number b...
0.708143
Taco_81448
C
[ "is_palindrome", "extend_number_to_palindrome" ]
2
[ [ "extend_number_to_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cd3be911ba64f2d3a11487cf6f86048bdae9ef47
5fba7c411d133df7c4b8dbb88476db53a59afcc1
v1.0
complete
Taco
Taco_81242_C
def highest_sales(book_sales_data): """ Finds the book(s) with the highest sales for each test case input. Parameters: book_sales_data (list of tuples): A list where each element is a tuple (book_code, copies_sold). Returns: list: A list of book codes with the highest sales for each te...
def highest_sales(book_sales_data): """ Finds the book(s) with the highest sales for each test case input. Parameters: book_sales_data (list of tuples): A list where each element is a tuple (book_code, copies_sold). Returns: list: A list of book codes with the highest sales for each te...
def test_example_case(): input_data = """\ 2 3 book1 100 book2 250 book3 250 4 codeA 500 codeB 120 codeC 500 codeD 450""" expected_output = "book2 book3\ncodeA codeC" T, data = parse_input(input_data) results = bookstore_sales(T, data) output = format_output(results) assert output ==...
[ { "docstring": "Finds the book(s) with the highest sales for each test case input.\n\nParameters:\nbook_sales_data (list of tuples): A list where each element is a tuple (book_code, copies_sold).\n\nReturns:\nlist: A list of book codes with the highest sales for each test case.", "function_declaration": "de...
[ 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 highest_sales_books(test_cases):\n \"\"\"\n Given test cases containing sales records, return the book code(s)\n with the highest number of copies sol...
trial_gpt4o_2
{ "original_instruction": "An online bookstore wishes to organize their book sales data for better analysis. Each sale is represented by the book's unique code and the number of copies sold. The bookstore is interested in knowing which book had the highest number of copies sold for the given input data. If there is a...
0.638871
Taco_81242
C
[ "highest_sales", "bookstore_sales", "parse_input", "format_output" ]
4
[ [ "bookstore_sales", "highest_sales" ] ]
1
[ "parse_input", "format_output" ]
false
[]
false
pytest
false
[]
true
5242e8a593362424016212022d008aa9d7e96a14
a30ca8b56191b552ebdd779f19073e850db93011
v1.0
complete
Taco
Taco_81424_C
def can_be_palindrome(s: str, k: int) -> bool: """ Check if the string s can be transformed into a valid palindrome by removing at most k characters. >>> can_be_palindrome("abca", 1) True >>> can_be_palindrome("abcba", 0) True >>> can_be_palindrome("abcda", 3) True """ pass def proc...
def can_be_palindrome(s, k): def min_deletions_to_palindrome(s): n = len(s) dp = [[0] * n for _ in range(n)] for l in range(2, n + 1): for i in range(n - l + 1): j = i + l - 1 if s[i] == s[j]: dp[i][j] = dp[i + 1][j - 1...
def test_can_be_palindrome(): assert can_be_palindrome("abca", 1) == True assert can_be_palindrome("abcba", 0) == True assert can_be_palindrome("abcda", 3) == True assert can_be_palindrome("aabbcc", 2) == False assert can_be_palindrome("racecar", 0) == True assert can_be_palindrome("racecar", 1)...
[ { "docstring": null, "function_declaration": "def can_be_palindrome(s, k):", "function_name": "can_be_palindrome", "parameter_list": "(s, k)" }, { "docstring": null, "function_declaration": "def process_test_cases(test_cases):", "function_name": "process_test_cases", "parameter_l...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_be_palindrome(s, k):\n def min_deletions_to_palindrome(s):\n n = len(s)\n dp = [[0] * n for _ in range(n)]\n \n for l in ran...
trial_gpt4o_0
{ "original_instruction": "You are given a string $s$ and an integer $k$. Your task is to determine if $s$ can be transformed into a valid palindrome by removing at most $k$ characters from it. A palindrome is a string that reads the same forwards and backwards.\n\n------ Input ------\nThe first line contains an inte...
0.7667
Taco_81424
C
[ "can_be_palindrome", "process_test_cases", "parse_input", "solve" ]
4
[ [ "process_test_cases", "can_be_palindrome" ], [ "solve", "parse_input" ], [ "solve", "process_test_cases" ] ]
3
[ "process_test_cases", "parse_input" ]
false
[]
false
pytest
false
[]
true
5ce7ea77e1aa59174bb4821f8d72457695811ae9
8d7f6a8f719670f249252b59d3f9ba1a7cbbb307
v1.0
complete
Taco
Taco_81431_C
def maximalRectangle(matrix) -> int: """ Find the largest rectangle containing only 1s in a given grid and return its area. The input should be a list of lists consisting of '0' and '1' as strings. >>> maximalRectangle([ ... ['1', '0', '1', '0', '0'], ... ['1', '0', '1', '1', '1'], ... ['1'...
def maximalRectangle(matrix): if not matrix or not matrix[0]: return 0 max_area = 0 heights = [0] * len(matrix[0]) for row in matrix: for i in range(len(row)): heights[i] = heights[i] + 1 if row[i] == '1' else 0 max_area = max(max_area, largestRectangleArea(heights...
def test_maximalRectangle_small_grid(): matrix = [ ['1', '0', '1', '0', '0'], ['1', '0', '1', '1', '1'], ['1', '1', '1', '1', '1'], ['1', '0', '0', '1', '0'] ] assert maximalRectangle(matrix) == 6 def test_maximalRectangle_single_row(): matrix = [ ['1', '1', '1',...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "paramete...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximalRectangle(grid):\n if not grid:\n return 0\n\n max_area = 0\n rows, cols = len(grid), len(grid[0])\n heights = [0] * cols\n\n for ...
trial_gpt4o_1
{ "original_instruction": "In a game, you are given a grid of size N x M where each cell contains either a 0 or a 1. The goal is to find the largest rectangle containing only 1s and return its area. The rectangle can be of varying sizes.\n\nYou are required to write a program to find the area of the largest rectangle...
0.710741
Taco_81431
C
[ "maximalRectangle", "largestRectangleArea" ]
2
[ [ "maximalRectangle", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c5705a5d2097556adb32d507145df2f2cf6ad716
4e06d0c4de1a4574dd04fd11fcce881120ce34de
v1.0
complete
Taco
Taco_81551_C
def is_valid_identifier(identifier: str) -> bool: """ Returns whether the given string is a valid identifier. An identifier is valid if it starts with a letter (A-Z, a-z) or an underscore (_), followed by letters, digits (0-9), or underscores. """ def validate_identifiers(input_list: List[Union...
def is_valid_identifier(identifier): """ Returns whether the given string is a valid identifier. An identifier is valid if it starts with a letter (A-Z, a-z) or an underscore (_), followed by letters, digits (0-9), or underscores. """ if not identifier: return False if not (iden...
from solution import is_valid_identifier, validate_identifiers def test_is_valid_identifier(): assert is_valid_identifier("_validIdentifier") == True assert is_valid_identifier("1Invalid") == False assert is_valid_identifier("anotherValid_id3") == True assert is_valid_identifier("_invalid123") == True ...
[ { "docstring": "Returns whether the given string is a valid identifier.\nAn identifier is valid if it starts with a letter (A-Z, a-z) or an underscore (_),\nfollowed by letters, digits (0-9), or underscores.", "function_declaration": "def is_valid_identifier(identifier):", "function_name": "is_valid_ide...
[ 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_valid_identifier(s):\n \"\"\"\n Returns \"Yes\" if s is a valid identifier, \"No\" otherwise.\n \"\"\"\n if not s:\n return \"No\"\n ...
trial_gpt4o_2
{ "original_instruction": "-----General Statement:-----\nWrite a program to determine if a given string is a valid identifier in a programming language.\n\n-----Input:-----\nThe first integer indicates the number of strings following it. Each subsequent string represents a potential identifier.\n\n-----Output:-----\n...
0.569048
Taco_81551
C
[ "is_valid_identifier", "validate_identifiers" ]
2
[ [ "validate_identifiers", "is_valid_identifier" ] ]
1
[]
false
[]
false
pytest
true
[]
true
501fa981a31ccf72a13d30716499de76f76d7c5e
8899d3f551a8dfd012eb00e3c649cde2a86c8b85
v1.0
complete
Taco
Taco_81722_C
def find_triplet(nums): """ This function takes a list of integers and returns a triplet that sums to zero if such a triplet exists, otherwise it returns "NO". >>> find_triplet([-1, 0, 1, 2, -1, -4]) == ("YES", [-1, -1, 2]) >>> find_triplet([-2, -1, 0, 1, 2]) == ("YES", [-2, 0, 2]) >>> find_trip...
def find_triplet(nums): """ This function takes a list of integers and returns a triplet that sums to zero if such a triplet exists, otherwise it returns "NO". """ nums.sort() n = len(nums) for i in range(n-2): if i > 0 and nums[i] == nums[i-1]: continue left...
from solution import find_triplet, print_triplet_result def test_find_triplet_exists(): assert find_triplet([-1, 0, 1, 2, -1, -4]) == ("YES", [-1, -1, 2]) assert find_triplet([-2, -1, 0, 1, 2]) == ("YES", [-2, 0, 2]) assert find_triplet([-1, 0, 1, -1, 1, 1]) == ("YES", [-1, 0, 1]) assert find_triplet([...
[ { "docstring": "This function takes a list of integers and returns a triplet that sums to zero if such a triplet exists,\notherwise it returns \"NO\".", "function_declaration": "def find_triplet(nums):", "function_name": "find_triplet", "parameter_list": "(nums)" }, { "docstring": null, ...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_triplet(nums):\n nums.sort()\n n = len(nums)\n \n for i in range(n - 2):\n if i > 0 and nums[i] == nums[i - 1]:\n continue\n...
trial_gpt4o_3
{ "original_instruction": "You are given an integer array nums of length n. Determine if there are three distinct elements in the array whose sum is zero. If there are:\n\n1. Print \"YES\" followed by the three elements in non-decreasing order.\n2. If no such triplet exists, print \"NO\".\n\n-----Input-----\n\nThe fi...
0.721523
Taco_81722
C
[ "find_triplet", "print_triplet_result" ]
2
[ [ "print_triplet_result", "find_triplet" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3c41cd44697cab63db25b85862d79ae0671951f2
3f0c2d46408915eff194b22ddc842f653f3f482d
v1.0
complete
Taco
Taco_81526_C
def has_winning_strategy(numbers): """Determine if Alice has a winning strategy for the given list of numbers. Args: numbers (List[int]): List of distinct positive integers representing the initial state of the game. Returns: bool: True if Alice has a winning strategy, False otherwise. ...
def has_winning_strategy(numbers): numbers.sort(reverse=True) move_count = 0 while numbers: current_max = numbers[0] move_count += 1 numbers = [num for num in numbers if num % current_max != 0] return move_count % 2 == 1 def alice_or_bob(test_cases): results = [] ...
import pytest from solution import has_winning_strategy, alice_or_bob, parse_input def test_has_winning_strategy(): assert has_winning_strategy([3, 9, 6]) == True assert has_winning_strategy([5, 10, 20, 25]) == False assert has_winning_strategy([1, 2, 4, 8, 16]) == True assert has_winning_strategy([2, ...
[ { "docstring": null, "function_declaration": "def has_winning_strategy(numbers):", "function_name": "has_winning_strategy", "parameter_list": "(numbers)" }, { "docstring": null, "function_declaration": "def alice_or_bob(test_cases):", "function_name": "alice_or_bob", "parameter_l...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def determine_winner(test_cases):\n results = []\n for case in test_cases:\n N, numbers = case\n numbers.sort(reverse=True)\n move_count...
trial_gpt4o_8
{ "original_instruction": "Alice and Bob are playing a game where they take turns choosing numbers from a list. The player who makes the final move wins. The game starts with a list of distinct positive integers. In each player's turn, they must choose a number from the list such that the chosen number is a divisor o...
0.706268
Taco_81526
C
[ "has_winning_strategy", "alice_or_bob", "parse_input" ]
3
[ [ "alice_or_bob", "has_winning_strategy" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
9264209e1f5cfdf6f53e46a63bc5b09a05a45d65
d5ec69040be6e9db0fbec9604e0f8a6db62684c0
v1.0
complete
Taco
Taco_81861_C
from typing import List def findPrimes(arr: List[int]) -> List[int]: """ Returns a list of prime numbers from the input array, sorted in ascending order. >>> findPrimes([10, 7, 4, 20, 19, 13]) [7, 13, 19] >>> findPrimes([0, 1, 4, 9, 15, 21]) [] >>> findPrimes([44, 29, 2, 17, 12, 23]) [...
def is_prime(n): """ Determines if n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 retu...
from solution import findPrimes def test_find_primes_example_cases(): assert findPrimes([10, 7, 4, 20, 19, 13]) == [7, 13, 19] assert findPrimes([0, 1, 4, 9, 15, 21]) == [] assert findPrimes([44, 29, 2, 17, 12, 23]) == [2, 17, 23, 29] def test_find_primes_edge_cases(): assert findPrimes([]) == [] ...
[ { "docstring": "Determines if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns an array of prime numbers from the input array, sorted in ascending order.", "function_declaration": "def findP...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True...
trial_gpt4o_1
{ "original_instruction": "## Task\n\nWrite a function that takes an array of integers as input and returns a new array composed of only the prime numbers from the input array, sorted in ascending order. \n\nPrime numbers are integers greater than 1 that are only divisible by 1 and themselves.\n\n### Examples\n\n```p...
0.704791
Taco_81861
C
[ "is_prime", "findPrimes" ]
2
[ [ "findPrimes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e35cb56ce5319e077bc1402c5b3bbac6850345d7
a095d85174cdabb9ac2127fd507de87ef4cd08ac
v1.0
complete
Taco
Taco_81983_C
def rectangle_possible(n: int, plank_lengths: List[int]) -> str: """ Determine if a rectangle can be formed with given set of planks. Args: n (int): The number of planks. plank_lengths (List[int]): The lengths of the planks. Returns: str: "yes" if a rectangle can be formed, otherwise "...
def can_form_rectangle(n, planks): from collections import Counter # Count the frequency of each plank length frequency = Counter(planks) # Count pairs of planks pairs = sum(count // 2 for count in frequency.values()) # To form a rectangle, we need at least 4 planks (2 pairs) ...
from solution import rectangle_possible def test_rectangle_possible(): assert rectangle_possible(6, [2, 2, 2, 2, 4, 4]) == "yes" assert rectangle_possible(5, [1, 2, 3, 4, 5]) == "no" assert rectangle_possible(8, [3, 3, 3, 3, 5, 5, 5, 5]) == "yes" assert rectangle_possible(4, [1, 1, 1, 1]) == "yes" ...
[ { "docstring": null, "function_declaration": "def can_form_rectangle(n, planks):", "function_name": "can_form_rectangle", "parameter_list": "(n, planks)" }, { "docstring": null, "function_declaration": "def rectangle_possible(n, plank_lengths):", "function_name": "rectangle_possible"...
[ 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 could_form_rectangle(n, planks):\n \"\"\"\n Determines if a rectangle can be formed using given planks.\n \n :param n: Number of planks\n :param...
trial_gpt4o_1
{ "original_instruction": "Julia is planning to make a rectangular flowerbed in her garden, using some wooden planks she found in her garage. Each wooden plank has a given length, and she wants to use these planks to form the perimeter of the rectangle. However, she can only use each plank once.\n\nWrite a program to...
0.6257
Taco_81983
C
[ "can_form_rectangle", "rectangle_possible" ]
2
[ [ "rectangle_possible", "can_form_rectangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fa3dac69da1ec2777294ed6bb9ede4d8f2a7bd5f
7cf69b99d2bbe65dbaf5262bf8217343098d0265
v1.0
complete
Taco
Taco_81786_C
def is_prime(n): """ Helper function to check if a number is a prime number. """ pass def special_action(dice1, dice2): """ Determines whether the absolute difference between two dice rolls is a prime number. Parameters: dice1 (int): Result of the first dice roll dice2 (int...
def is_prime(n): """ Helper function to check if a number is a prime number. """ if n <= 1: return False if n in (2, 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 Fal...
from solution import special_action def test_special_action_prime_diff(): assert special_action(5, 2) == "YES" assert special_action(6, 1) == "YES" assert special_action(3, 1) == "YES" def test_special_action_non_prime_diff(): assert special_action(4, 4) == "NO" assert special_action(6, 2) == "NO"...
[ { "docstring": "Helper function to check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Determines whether the absolute difference between two dice rolls\nis a prime number.\n\nParameters:\n...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n in (2, 3):\n ...
trial_gpt4o_0
{ "original_instruction": "A group of friends are playing a board game that involves rolling two six-sided dice. To add some excitement, they decided to introduce a special rule: If the absolute difference between the two numbers rolled is a prime number, they will perform a special action.\n\nYour task is to write a...
0.71719
Taco_81786
C
[ "is_prime", "special_action" ]
2
[ [ "special_action", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c64ec3bade6e9ee88890a2ac2faccbed537d6570
b0a631060e37b14bdee003eafdd95a099ea55ce7
v1.0
complete
Taco
Taco_81911_C
def digit_sum(n: int) -> int: """ Return the sum of the digits of an integer n. >>> digit_sum(123) 6 >>> digit_sum(456) 15 """ def transform_subarray(a: List[int], L: int, R: int, K: int) -> int: """ Transform the subarray a[L...R] K times and return the sum of the resulting subarray. >...
def digit_sum(n): """Return the sum of the digits of an integer n.""" return sum(int(d) for d in str(n)) def transform_subarray(a, L, R, K): """ Transform the subarray a[L...R] K times as per the problem statement. """ for _ in range(K): for i in range(L, R + 1): a[i] = digi...
from solution import digit_sum, transform_subarray, process_queries def test_digit_sum(): assert digit_sum(123) == 6 assert digit_sum(456) == 15 assert digit_sum(789) == 24 assert digit_sum(12345) == 15 assert digit_sum(67890) == 30 def test_transform_subarray(): assert transform_subarray([123...
[ { "docstring": "Return the sum of the digits of an integer n.", "function_declaration": "def digit_sum(n):", "function_name": "digit_sum", "parameter_list": "(n)" }, { "docstring": "Transform the subarray a[L...R] K times as per the problem statement.", "function_declaration": "def trans...
[ 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 digit_sum(n):\n \"\"\" Utility function to compute the sum of digits of a number \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef transform_and...
trial_gpt4o_4
{ "original_instruction": "Given a sequence of N integers and Q queries, each requiring a transformation of the sequence. Chef wants to improve efficiency by saving intermediate results to answer queries faster.\n\nYou are given an array a of N integers. Each of the Q queries provides three integers: L, R, and K.\n\n...
0.630341
Taco_81911
C
[ "digit_sum", "transform_subarray", "process_queries" ]
3
[ [ "process_queries", "transform_subarray" ], [ "transform_subarray", "digit_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
2e6d9c35c483743f7b70d5d1e433cd6a0f347db4
6df81138622e730afa075831b09f04dca77ef88d
v1.0
complete
Taco
Taco_81673_C
def max_subarray_sum(nums): """ Returns the maximum subarray sum using Kadane's algorithm. """ pass def max_sum_after_one_negation(n, nums): """ Returns the maximum subarray sum possible after at most one negation of any subarray. >>> max_sum_after_one_negation(4, [2, -1, 2, 3]) == 8 >>> ...
def max_subarray_sum(nums): """ Returns the maximum subarray sum using Kadane's algorithm. """ max_sum = current_sum = nums[0] for num in nums[1:]: current_sum = max(num, current_sum + num) max_sum = max(max_sum, current_sum) return max_sum def max_sum_after_one_negation(n, nums...
from solution import max_subarray_sum, max_sum_after_one_negation, solve def test_max_subarray_sum(): assert max_subarray_sum([2, -1, 2, 3]) == 6 assert max_subarray_sum([-1, -2, -3, -4, -5]) == -1 assert max_subarray_sum([1, 2, 3]) == 6 def test_max_sum_after_one_negation(): assert max_sum_after_one_...
[ { "docstring": "Returns the maximum subarray sum using Kadane's algorithm.", "function_declaration": "def max_subarray_sum(nums):", "function_name": "max_subarray_sum", "parameter_list": "(nums)" }, { "docstring": "Returns the maximum subarray sum possible after at most one negation of any 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 max_subarray_with_negation(sequence):\n def kadane(arr):\n max_ending_here = max_so_far = arr[0]\n for x in arr[1:]:\n max_ending_h...
trial_gpt4o_1
{ "original_instruction": "In a distant land, there is a famous detective named Sherlock who is very fond of puzzles. One day, he encountered a lock which can only be opened by solving a unique problem.\n\nThe lock has a sequence of `n` numbers, but to open it, Sherlock needs to find the maximum possible sum of any s...
0.738216
Taco_81673
C
[ "max_subarray_sum", "max_sum_after_one_negation", "solve", "main" ]
4
[ [ "max_sum_after_one_negation", "max_subarray_sum" ], [ "solve", "max_sum_after_one_negation" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e7cf9a45e130e7757b8dd152f830726d86086974
4cdc665787660855058f5f1280cd3ce460b2fa0f
v1.0
complete
Taco
Taco_81936_C
def safe_eval(expression: str) -> int: """ Evaluates a mathematical expression using only allowed operators. >>> safe_eval('3+5') == 8 >>> safe_eval('10-3') == 7 >>> safe_eval('4*2') == 8 >>> safe_eval('10/3') == 3 >>> safe_eval('7%3') == 1 >>> safe_eval('3+5*2') == 13 >>> safe_eval('10/...
import operator def safe_eval(expression): """ Evaluates a mathematical expression using only allowed operators. """ allowed_operators = { '+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.floordiv, '%': operator.mod } # Replace ...
from solution import safe_eval, process_expressions def test_addition(): assert safe_eval('3+5') == 8 def test_subtraction(): assert safe_eval('10-3') == 7 def test_multiplication(): assert safe_eval('4*2') == 8 def test_division(): assert safe_eval('10/3') == 3 def test_modulo(): assert safe_e...
[ { "docstring": "Evaluates a mathematical expression using only allowed operators.", "function_declaration": "def safe_eval(expression):", "function_name": "safe_eval", "parameter_list": "(expression)" }, { "docstring": null, "function_declaration": "def process_expressions(expressions):"...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def compute_expression(expression):\n \"\"\"\n Evaluate a simple mathematical expression provided as a string.\n Supported operators: +, -, *, /, %\n \...
trial_gpt4o_1
{ "original_instruction": "Write a program that simulates a simple calculator supporting addition, subtraction, multiplication, division, and modulo operations. The calculator accepts mathematical expressions in infix notation, computes the result, and outputs the answer.\n\nThe expressions can include integer number...
0.628873
Taco_81936
C
[ "safe_eval", "process_expressions" ]
2
[ [ "process_expressions", "safe_eval" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dc2f6e70e612e1c877974836c8d44ae442422588
8cb1f6898794bdbe0622782745038114abbc570b
v1.0
complete
Taco
Taco_82067_C
def construct_bst_from_preorder(preorder: List[int]) -> Optional[TreeNode]: """ Construct a BST from the given preorder traversal. Args: preorder: List[int] - a list of integers representing the preorder traversal of a BST. Returns: TreeNode - the root node of the constructed BST. """ pass...
class Node: def __init__(self, value): self.value = value self.left = None self.right = None def construct_bst_from_preorder(preorder): if not preorder: return None root = Node(preorder[0]) stack = [root] for value in preorder[1:]: if value < stack[...
from solution import findPostorderFromPreorder def test_example_1(): assert findPostorderFromPreorder(5, [4, 2, 1, 3, 6]) == [1, 3, 2, 6, 4] def test_example_2(): assert findPostorderFromPreorder(3, [8, 5, 7]) == [7, 5, 8] def test_single_node(): assert findPostorderFromPreorder(1, [10]) == [10] def tes...
[]
[ 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.value = key\n\ndef constructBSTFromPreorder(preord...
trial_gpt4o_1
{ "original_instruction": "You are given an array `arr` of N integers representing the preorder traversal of a binary search tree. The task is to construct the BST from the given preorder traversal and then find its postorder traversal.\n\nExample 1:\nInput:\nN = 5\narr = [4, 2, 1, 3, 6]\nOutput:\n[1, 3, 2, 6, 4]\nEx...
0.467693
Taco_82067
C
[ "construct_bst_from_preorder", "postorder_traversal", "findPostorderFromPreorder" ]
3
[ [ "findPostorderFromPreorder", "construct_bst_from_preorder" ], [ "findPostorderFromPreorder", "postorder_traversal" ] ]
2
[]
false
[ "Node" ]
true
pytest
true
[]
true
4c83a7284dd7ebed1326bccb3cb45a5d691e33e4
1709dbfb459a85a4284da618fbf576de4bbd367c
v1.0
complete
Taco
Taco_81926_C
def is_perfect(n): """ Check if a number is a perfect number. Args: n (int): The number to check. Returns: bool: True if n is a perfect number, False otherwise. Example: >>> is_perfect(28) True >>> is_perfect(27) False """ def P(n): """ Returns...
def is_perfect(n): """ Check if a number is a perfect number. """ if n <= 1: return False divisors_sum = 1 sqrt_n = int(n**0.5) for i in range(2, sqrt_n + 1): if n % i == 0: divisors_sum += i if i != n // i: divisors_sum += n // i r...
from solution import P, perfect_pairs_sum, main def test_is_perfect(): assert P(6) == 1 assert P(28) == 1 assert P(27) == 0 assert P(1) == 0 def test_perfect_pairs_sum_small_range(): assert perfect_pairs_sum(1, 30) == 1 def test_perfect_pairs_sum_no_perfect_numbers(): assert perfect_pairs_sum...
[ { "docstring": "Check if a number is a perfect number.", "function_declaration": "def is_perfect(n):", "function_name": "is_perfect", "parameter_list": "(n)" }, { "docstring": "Returns 1 if n is a perfect number, 0 otherwise.", "function_declaration": "def P(n):", "function_name": "P...
[ 0, 0, 1, 0 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 10**9 + 7\n\ndef is_perfect_number(N):\n \"\"\"\n Check if a number N is a perfect number.\n \"\"\"\n if N <= 1:\n return False\n divis...
trial_gpt4o_3
{ "original_instruction": "For a given integer N, define the function `P(N)` as:\n\n- `P(N) = 1` if `N` is a perfect number.\n- `P(N) = 0` otherwise.\n\nA perfect number is a positive integer that is equal to the sum of its positive divisors, excluding itself (e.g., 6, 28, etc.).\n\nGiven two integers `L` and `R`, co...
0.636147
Taco_81926
C
[ "is_perfect", "P", "perfect_pairs_sum", "main" ]
4
[ [ "P", "is_perfect" ], [ "perfect_pairs_sum", "P" ] ]
2
[]
false
[]
false
pytest
true
[]
true
31ee46dfce7e23f5248ffebd87631a3c20058fa1
0240e8da54e646ceb0cbee4d2a5887efe721aa2b
v1.0
complete
Taco
Taco_81931_C
def is_palindrome(n): """ Checks if a given number is a palindrome. >>> is_palindrome(121) True >>> is_palindrome(123) False >>> is_palindrome(1) True >>> is_palindrome(22) True >>> is_palindrome(12321) True """ def product_of_palindromes(A, B): """ Calculates the product of...
def is_palindrome(n): """ Checks if a given number is a palindrome. """ return str(n) == str(n)[::-1] def product_of_palindromes(A, B): """ Calculates the product of all palindromic numbers between A and B, inclusive, and returns the product modulo 1000000007. """ MOD = 1000000007 ...
from solution import product_of_palindromes, is_palindrome def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1) == True assert is_palindrome(22) == True assert is_palindrome(12321) == True def test_product_of_palindromes(): asse...
[ { "docstring": "Checks if a given number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Calculates the product of all palindromic numbers between A and B, inclusive,\nand returns the product mod...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Checks if a given number is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef product_of_palindromes(A, B)...
trial_gpt4o_0
{ "original_instruction": "Your task is to calculate the product (denoted as P) of all the palindromic numbers between [A, B]. An integer is called palindromic if it reads the same forwards and backwards.\n\nInput format\n\nA B\n\nOutput format\n\nP % 1000000007\n\nConstraints\n\n0 < A <= B < 10^18\n\nSample Input\n\...
0.689659
Taco_81931
C
[ "is_palindrome", "product_of_palindromes" ]
2
[ [ "product_of_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c3170011eb83ed92f86d2bb83c1ce8c001806722
bff7c9d3f80246575ccd6660576fce105d57adc9
v1.0
complete
Taco
Taco_82194_C
def max_gold_coins(grid: List[List[int]]) -> int: """ Find the maximum number of gold coins that can be collected on the way from the top-left cell to the bottom-right cell. >>> max_gold_coins([ [1, 3, 1], [1, 5, 1], [4, 2, 1] ]) 12 >>> max_gold_coins([ ...
def max_gold_coins(grid): M = len(grid) N = len(grid[0]) # Create a dp table to store the maximum coins up to each cell dp = [[0]*N for _ in range(M)] dp[0][0] = grid[0][0] # Starting point # Fill the first row (can only come from the left) for j in range(1, N): dp[0]...
def test_max_gold_coins(): grid1 = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert max_gold_coins(grid1) == 12 grid2 = [ [0, 3, 1], [9, 2, 1], [4, 6, 1] ] assert max_gold_coins(grid2) == 20 grid3 = [ [1, 2, 3], [4, 5, 6], ...
[ { "docstring": null, "function_declaration": "def max_gold_coins(grid):", "function_name": "max_gold_coins", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def read_input_and_solve():", "function_name": "read_input_and_solve", "parameter_list": "()" ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_gold_coins(M, N, grid):\n # Initialize a 2D list with the same dimensions as the grid to store the max coins collected to each cell\n dp = [[0] * N f...
trial_gpt4o_2
{ "original_instruction": "A group of explorers are on a quest to recover a lost treasure deep within a magical forest. The forest can be represented as a 2D grid of size MxN, where each cell has a certain amount of gold coins. The starting point for the explorers is the top-left cell (0, 0) and the treasure is at th...
0.611509
Taco_82194
C
[ "max_gold_coins", "read_input_and_solve" ]
2
[ [ "read_input_and_solve", "max_gold_coins" ] ]
1
[]
false
[]
false
pytest
false
[]
true
5f2ef801bdfcbe47ff29502eb0bf6dd8df30270f
7acb946fc8d69880c99381de627048cb00d987ab
v1.0
complete
Taco
Taco_82364_C
def count_balanced_parenthesis(n: int) -> int: """ Calculate the number of distinct balanced parenthesis strings that can be generated with n pairs of parentheses. >>> count_balanced_parenthesis(1) 1 >>> count_balanced_parenthesis(2) 2 >>> count_balanced_parenthesis(3) 5 """
def catalan_number(n): """ Function to compute the nth Catalan number, which represents the number of distinct balanced parenthesis strings that can be generated using n pairs of parentheses. """ if n == 0 or n == 1: return 1 # Table to store results of subproblems catalan = [0]...
from solution import count_balanced_parenthesis def test_count_balanced_parenthesis_small_cases(): assert count_balanced_parenthesis(1) == 1 assert count_balanced_parenthesis(2) == 2 assert count_balanced_parenthesis(3) == 5 def test_count_balanced_parenthesis_medium_cases(): assert count_balanced_par...
[ { "docstring": "Function to compute the nth Catalan number, which represents the number of distinct balanced\nparenthesis strings that can be generated using n pairs of parentheses.", "function_declaration": "def catalan_number(n):", "function_name": "catalan_number", "parameter_list": "(n)" }, ...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_balanced_parentheses(n):\n \"\"\"\n Returns the number of distinct balanced parenthesis strings \n that can be generated with n pairs of parenth...
trial_gpt4o_2
{ "original_instruction": "Aria loves playing with sequences of parentheses. One day, she came up with the idea of generating all possible balanced parenthesis strings. She defined a balanced parenthesis string as follows:\n\n- An empty string is considered balanced.\n- If \"A\" and \"B\" are balanced parenthesis str...
0.721568
Taco_82364
C
[ "catalan_number", "count_balanced_parenthesis" ]
2
[ [ "count_balanced_parenthesis", "catalan_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d6fb980a4a1efa88217fcb22db49d9f98508e081
ac12fffdbcd61d7f08ef7c0e2931541a1a2eade9
v1.0
complete
Taco
Taco_82192_C
from typing import List, Tuple def can_form_palindrome(s: str) -> bool: """ Determines if a given string can be rearranged to form a palindrome. >>> can_form_palindrome("aabb") True >>> can_form_palindrome("abcde") False >>> can_form_palindrome("aaaaaa") True >>> can_form_palindrome("r...
from collections import Counter def can_form_palindrome(s): """ Determines if a given string can be rearranged to form a palindrome. """ counter = Counter(s) odd_count = sum(1 for count in counter.values() if count % 2 != 0) return odd_count <= 1 def rearrange_to_palindrome(s): """ Rea...
from solution import can_form_palindrome, rearrange_to_palindrome, process_test_cases def test_can_form_palindrome(): assert can_form_palindrome("aabb") == True assert can_form_palindrome("abcde") == False assert can_form_palindrome("aaaaaa") == True assert can_form_palindrome("racecar") == True as...
[ { "docstring": "Determines if a given string can be rearranged to form a palindrome.", "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome", "parameter_list": "(s)" }, { "docstring": "Rearranges a given string to form a palindrome if possible, otherwi...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_form_palindrome(s):\n \"\"\"\n Determines if a string can be rearranged to form a palindrome. \n If yes, returns one such rearrangement, otherwise...
trial_gpt4o_1
{ "original_instruction": "You are given a string `S` of length `N` consisting of lowercase English letters. Chef wants to create a palindromic string from `S` by rearranging its characters. A string is called palindromic if it reads the same forward and backward. Chef also wants to maximize the number of distinct pa...
0.743003
Taco_82192
C
[ "can_form_palindrome", "rearrange_to_palindrome", "process_test_cases" ]
3
[ [ "process_test_cases", "rearrange_to_palindrome" ], [ "rearrange_to_palindrome", "can_form_palindrome" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
39c512025fa03180922f7e1ee28e5dc9071282c2
bcbd2fc529a91c9368ffc4f958a54448ebccc5bb
v1.0
complete
Taco
Taco_82262_C
def arpas_candy_chain(n, sweetness_levels): """ Determines if there is a valid way to arrange the given candy pieces to meet the judges’ requirements. Each candy piece should have a distinct sweetness level. The total sweetness level of the whole candy chain must be an even number. Among any three ...
def is_valid_candy_chain(candy_chain): """ Checks if the candy chain meets the requirements: - Each candy piece has a distinct sweetness level. - The total sweetness level is an even number. - Among any three consecutive candy pieces, the total sweetness level is not divisible by 3. """ tota...
def test_case_1(): assert arpas_candy_chain(5, [3, 2, 1, 6, 7]) == None # Prints 1 2 6 7 3 or similar valid configuration def test_case_2(): assert arpas_candy_chain(3, [2, 4, 5]) == None # Prints 2 4 5 def test_case_3(): assert arpas_candy_chain(3, [6, 6, 6]) == None # Prints -1 due to duplicates def te...
[ { "docstring": "Checks if the candy chain meets the requirements:\n- Each candy piece has a distinct sweetness level.\n- The total sweetness level is an even number.\n- Among any three consecutive candy pieces, the total sweetness level is not divisible by 3.", "function_declaration": "def is_valid_candy_ch...
[ 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_valid_chain(chain):\n \"\"\"\n Helper function to check if a given chain is a valid candy chain\n according to the conditions mentioned.\n \"\"\...
trial_gpt4o_2
{ "original_instruction": "Arpa is participating in a confectionery contest in Arpa’s land to create beautiful and tasty candy chains to impress the judges. A candy chain consists of individual candy pieces, each having a specific sweetness level. The judges have peculiar requirements for the arrangement of candies. ...
0.613211
Taco_82262
C
[ "is_valid_candy_chain", "arpas_candy_chain" ]
2
[ [ "arpas_candy_chain", "is_valid_candy_chain" ] ]
1
[]
false
[]
false
pytest
false
[]
true
27e121fdf9eb71cb5ff7423a0238e4cdcfb9f5a4
f181d98107f95d3d298bd9c3f04eeccee32f9131
v1.0
complete
Taco
Taco_82288_C
def process(input_str: str) -> str: """ Calculate the smallest possible length of an enclosing segment of given segments in a sequence. Each test case contains: - An integer N (1 ≤ N ≤ 1000), representing the number of segments. - A single line with N integers separated by spaces, representing ...
def smallest_enclosing_segment_length(test_cases): results = [] for case in test_cases: N, segments = case total_length = sum(segments) results.append(total_length) return results def parse_input(input_str): lines = input_str.strip().split('\n') test_cases = [] ...
from solution import process def test_sample1(): input_str = "3\n1 2 3\n4\n5 5 5 5\n2\n7 3\n0" expected_output = "6\n20\n10" assert process(input_str) == expected_output def test_single_segment(): input_str = "1\n1000\n0" expected_output = "1000" assert process(input_str) == expected_output d...
[ { "docstring": null, "function_declaration": "def smallest_enclosing_segment_length(test_cases):", "function_name": "smallest_enclosing_segment_length", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "p...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def smallest_enclosing_length(test_cases):\n \"\"\"\n Given multiple test cases, computes the smallest possible enclosing length for each case.\n \"\"\"\n...
trial_gpt4o_2
{ "original_instruction": "Zara, an avid puzzle lover, has recently come across an interesting challenge. The challenge involves a peculiar number game where each number in the sequence has to follow a specific set of rules. Intrigued, she has tasked you with writing a program to help her solve these puzzles more eff...
0.644158
Taco_82288
C
[ "smallest_enclosing_segment_length", "parse_input", "process" ]
3
[ [ "process", "parse_input" ], [ "process", "smallest_enclosing_segment_length" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
f531f2376ae2865b681b15784b3046f8542049a2
194095331ddd974cded4b400dae39b7064b1bc59
v1.0
complete
Taco
Taco_81980_C
def is_palindrome(s): """ Returns True if s is a palindrome, ignoring spaces, punctuation, and capitalization. """ # Implementation goes here def longest_palindromic_substring(s): """ Returns the longest palindromic substring in s. """ # Implementation goes here def process_input_strin...
def is_palindrome(s): """ Returns True if s is a palindrome, ignoring spaces, punctuation, and capitalization. """ stripped = ''.join([c.lower() for c in s if c.isalnum()]) return stripped == stripped[::-1] def longest_palindromic_substring(s): """ Returns the longest palindromic substring ...
from solution import is_palindrome, longest_palindromic_substring, process_input_strings def test_is_palindrome(): assert is_palindrome("madam") == True assert is_palindrome("racecar") == True assert is_palindrome("apple") == False assert is_palindrome("noon") == True assert is_palindrome("A man, a...
[ { "docstring": "Returns True if s is a palindrome, ignoring spaces, punctuation, and capitalization.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns the longest palindromic substring in s.", "function...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n filtered_s = ''.join([c.lower() for c in s if c.isalnum()])\n return filtered_s == filtered_s[::-1]\n\ndef longest_palindromic_substr...
trial_gpt4o_1
{ "original_instruction": "A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalization). Write a program that checks whether a given string is a palindrome, and identify the longest palindromic substring within the ...
0.769197
Taco_81980
C
[ "is_palindrome", "longest_palindromic_substring", "process_input_strings" ]
3
[ [ "process_input_strings", "is_palindrome" ], [ "process_input_strings", "longest_palindromic_substring" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9a83c3491bfe4bd63bc65f54a609b0b31531f1ad
d341612013447ded8384067680046bc0b328c8d2
v1.0
complete
Taco
Taco_82190_C
def isSumOfTwoPrimes(n: int) -> bool: """ Given an integer n, determine if it's possible to represent n as a sum of exactly two distinct prime numbers. Args: n (int): The integer to be checked. Returns: bool: True if n can be expressed as the sum of two distinct prime numbers, otherwise Fa...
def is_prime(num): """Return True if num is a prime number, else False.""" 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 ...
from solution import isSumOfTwoPrimes def test_isSumOfTwoPrimes_10(): assert isSumOfTwoPrimes(10) == True def test_isSumOfTwoPrimes_11(): assert isSumOfTwoPrimes(11) == False def test_isSumOfTwoPrimes_15(): assert isSumOfTwoPrimes(15) == True def test_isSumOfTwoPrimes_34(): assert isSumOfTwoPrimes(3...
[ { "docstring": "Return True if num is a prime number, else False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Return True if n can be represented as the sum of two distinct prime numbers, otherwise, return False.",...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_8
{ "original_instruction": "Given an integer n, the task is to determine if it's possible to represent n as a sum of exactly two distinct prime numbers. Return true if possible, otherwise, return false.\n\nExample 1:\nInput: n = 10\nOutput: True\nExplanation: 10 can be represented as 3 + 7, where both 3 and 7 are prim...
0.727569
Taco_82190
C
[ "is_prime", "isSumOfTwoPrimes" ]
2
[ [ "isSumOfTwoPrimes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9fad604c81112defc0138575351444ef371e3b98
65418532695a4ec69a1cc369898cad79fb881373
v1.0
complete
Taco
Taco_82270_C
from typing import List, Tuple def solve_queries(queries: List[Tuple[Tuple[int, int], List[int]]]) -> List[int]: """ Farmer John wants to place exactly c cows in n stalls such that the minimum distance between any two cows is maximized. The stalls are represented by an array of integers, where each intege...
def canPlaceCows(stalls, n, c, min_dist): cows_placed = 1 # Place cow in the first stall last_pos = stalls[0] for i in range(1, n): if stalls[i] - last_pos >= min_dist: cows_placed += 1 last_pos = stalls[i] if cows_placed == c: return True ret...
from solution import solve_queries def test_single_query(): queries = [((5, 3), [1, 2, 8, 4, 9])] assert solve_queries(queries) == [3] def test_multiple_queries(): queries = [ ((5, 3), [1, 2, 8, 4, 9]), ((6, 4), [3, 4, 7, 1, 9, 12]) ] assert solve_queries(queries) == [3, 3] def te...
[ { "docstring": null, "function_declaration": "def canPlaceCows(stalls, n, c, min_dist):", "function_name": "canPlaceCows", "parameter_list": "(stalls, n, c, min_dist)" }, { "docstring": null, "function_declaration": "def largestMinDistance(n, c, stalls):", "function_name": "largestMi...
[ 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_place_cows(stalls, n, c, min_dist):\n \"\"\"\n Helper function to determine if cows can be placed such that\n the minimum distance between any two...
trial_gpt4o_2
{ "original_instruction": "Farmer John has a barn with `n` stalls, and he wants to place exactly `c` cows in them such that the minimum distance between any two cows is maximized. The stalls are represented by an array of `n` integers, where each integer represents the position of a stall along a straight line.\n\nYo...
0.601834
Taco_82270
C
[ "canPlaceCows", "largestMinDistance", "solve_queries" ]
3
[ [ "largestMinDistance", "canPlaceCows" ], [ "solve_queries", "largestMinDistance" ] ]
2
[ "solve_queries" ]
false
[]
false
pytest
true
[]
true
beeeddffb18a59f2a5e72e81c6d4b7e57ce37441
5f3f03c9af47fb780e49cf43ccec1c1901ba3f8c
v1.0
complete
Taco
Taco_81753_C
from typing import List, Tuple def do_lines_intersect(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, x4: float, y4: float) -> bool: """Determine if two line segments intersect. >>> do_lines_intersect(0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0) True >>> do_lines_intersect(0.0, 0.0, 1.0, 1.0, ...
def do_lines_intersect(x1, y1, x2, y2, x3, y3, x4, y4): def ccw(ax, ay, bx, by, cx, cy): return (cy - ay) * (bx - ax) > (by - ay) * (cx - ax) def intersect(ax, ay, bx, by, cx, cy, dx, dy): return ccw(ax, ay, cx, cy, dx, dy) != ccw(bx, by, cx, cy, dx, dy) and \ ccw(ax, ay, bx, by,...
from solution import do_lines_intersect, any_intersections, parse_input, check_intersection def test_do_lines_intersect(): assert do_lines_intersect(0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0) == True assert do_lines_intersect(0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0) == False assert do_lines_intersect(0.0, 0.0,...
[ { "docstring": null, "function_declaration": "def do_lines_intersect(x1, y1, x2, y2, x3, y3, x4, y4):", "function_name": "do_lines_intersect", "parameter_list": "(x1, y1, x2, y2, x3, y3, x4, y4)" }, { "docstring": null, "function_declaration": "def any_intersections(line_segments):", ...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def do_segments_intersect(p1, q1, p2, q2):\n \"\"\"\n Function to determine if two line segments intersect.\n \"\"\"\n def on_segment(p, q, r):\n ...
trial_gpt4o_3
{ "original_instruction": "Given a set of line segments in a 2D plane, determine if any two line segments intersect each other.\n\nInput\n\nThe first line is an integer $ n $ (2 ≤ $ n $ ≤ 50) representing the number of line segments.\n\nThe next $ n $ lines each contain four floating point numbers $ x_1 $, $ y_1 $, $...
0.583054
Taco_81753
C
[ "do_lines_intersect", "any_intersections", "parse_input", "check_intersection" ]
4
[ [ "any_intersections", "do_lines_intersect" ], [ "check_intersection", "any_intersections" ], [ "check_intersection", "parse_input" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
1e01a4bb0f7e95ee259535185eb557d7ab753b32
b942d2f8123f2257db771fbee74d5b481adfa85b
v1.0
complete
Taco
Taco_82280_C
def final_balance(test_cases): """Compute the final balances after processing all transactions for each test case. Args: test_cases (List[List[int]]): A list of test cases, where each test case is a list of transactions. Returns: List[int]: A list of final balances for each test case. >>> ...
def final_balance(test_cases): results = [] for case in test_cases: final_amount = sum(case) results.append(final_amount) return results def parse_input(input_string): data = input_string.strip().split('\n') index = 0 T = int(data[index]) index += 1 test_cases = [] f...
def test_parse_input(): input_string = '2\n3\n-200\n300\n-100\n4\n500\n1000\n-1500\n-500\n' expected_output = [[-200, 300, -100], [500, 1000, -1500, -500]] assert parse_input(input_string) == expected_output def test_final_balance(): test_cases = [[-200, 300, -100], [500, 1000, -1500, -500]] expect...
[ { "docstring": null, "function_declaration": "def final_balance(test_cases):", "function_name": "final_balance", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", "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": "def compute_balances(test_cases):\n \"\"\"\n Computes the final balance for each test case of daily transactions.\n \n Parameters:\n test_cases (lis...
trial_gpt4o_2
{ "original_instruction": "A new bank is revolutionizing financial management with their innovative account balance tracking system. As a software developer, you need to implement a feature to help users monitor their daily transactions and compute their final balance.\n\n------ Input ------\n\nThe first line contain...
0.565559
Taco_82280
C
[ "final_balance", "parse_input", "format_output", "process_transactions" ]
4
[ [ "process_transactions", "final_balance" ], [ "process_transactions", "format_output" ], [ "process_transactions", "parse_input" ] ]
3
[ "parse_input", "format_output" ]
false
[]
false
pytest
false
[]
true
e58125a8205c358f1e18fd297baeb51255b19523
70bfc6ab0bc8686224ddefe1e22dcbdc6feddcea
v1.0
complete
Taco
Taco_82463_C
def road_network(n, m, roads): """ Determine if the road network will remain connected after removing any single road. Args: n (int): Number of cities. m (int): Number of roads. roads (List[Tuple[int, int]]): List of bidirectional roads connecting the cities. Returns: str: "YES" if the...
def find_bridges(n, m, roads): from collections import defaultdict, deque def dfs(v, parent, disc, low, graph, bridges, time): children = 0 disc[v] = low[v] = time[0] time[0] += 1 for to in graph[v]: if disc[to] == -1: children += 1 ...
from solution import road_network def test_example_1(): assert road_network(5, 5, [(1, 2), (2, 3), (3, 4), (4, 5), (5, 1)]) == "YES" def test_example_2(): assert road_network(5, 4, [(1, 2), (2, 3), (3, 4), (4, 5)]) == "NO" def test_single_city(): assert road_network(1, 0, []) == "YES" def test_two_citie...
[ { "docstring": null, "function_declaration": "def find_bridges(n, m, roads):", "function_name": "find_bridges", "parameter_list": "(n, m, roads)" }, { "docstring": null, "function_declaration": "def road_network(n, m, roads):", "function_name": "road_network", "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": "def is_2_edge_connected(n, m, roads):\n from collections import defaultdict\n \n def dfs(v, visited, graph, parent, visited_time, low_time, time, bridges)...
trial_gpt4o_1
{ "original_instruction": "In a fictional kingdom, there are several cities connected by bidirectional roads. The citizens of this kingdom are facing some trouble as the roads are not in good condition and are prone to getting blocked during bad weather. The governor wants to ensure that even if one road gets blocked...
0.653678
Taco_82463
C
[ "find_bridges", "road_network" ]
2
[ [ "road_network", "find_bridges" ] ]
1
[]
false
[]
false
pytest
true
[]
true
60594d3f639bce780c210bfe04213f88d4264cea
ee82e45e9f7b1eb383f932b39d03c171ec9711ac
v1.0
complete
Taco
Taco_82493_C
def cow_race(input_str: str) -> int: """ Determine which cow visits the maximum number of unique positions. Args: input_str (str): a string containing the number of cows and their respective paths. Returns: int: the 1-based index of the cow that visits the maximum number of unique positions. I...
def find_winning_cow(cow_paths): """ Determine which cow visits the maximum number of unique positions. """ max_unique_positions = 0 index_of_winning_cow = 0 for idx, path in enumerate(cow_paths): unique_positions = set(path) if len(unique_positions) > max_unique_positions: ...
import pytest from solution import cow_race def test_sample_input_1(): input_str = "3\n4\n1 1\n2 2\n1 1\n3 4\n3\n5 6\n5 6\n5 6\n5\n7 8\n7 8\n8 9\n9 10\n10 11\n" assert cow_race(input_str) == 3 def test_sample_input_2(): input_str = "2\n5\n1 1\n2 2\n3 3\n4 4\n5 5\n4\n10 10\n10 10\n20 20\n30 30\n" asser...
[ { "docstring": "Determine which cow visits the maximum number of unique positions.", "function_declaration": "def find_winning_cow(cow_paths):", "function_name": "find_winning_cow", "parameter_list": "(cow_paths)" }, { "docstring": "Parse the input string to extract the number of cows and th...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_winning_cow(m, cow_paths):\n max_unique_positions = 0\n winning_cow_index = 0\n \n for i in range(m):\n k, positions = cow_paths[i]\n ...
trial_gpt4o_2
{ "original_instruction": "Farmer John's cows have started organizing races in the pastures. Each cow competes by running along a specific path and keeping track of the positions they visit. Farmer John wants to find out which cow visits the maximum number of unique positions. Can you help him determine the winning c...
0.518329
Taco_82493
C
[ "find_winning_cow", "parse_input", "cow_race" ]
3
[ [ "cow_race", "find_winning_cow" ], [ "cow_race", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
7485402414a1d1c11167678947a1f77c9c3bdbcd
e61646de050696057ceebe4fa74b2c74ddd78201
v1.0
complete
Taco
Taco_82340_C
from typing import List, Tuple def is_wonderful(n: int) -> bool: """ Check if a number is a Wonderful Number. A number n is a Wonderful Number if the sum of its digits is greater than the product of its digits. >>> is_wonderful(13) True >>> is_wonderful(24) False """ def wonde...
def is_wonderful(n): """ Returns True if the number n is a Wonderful Number, otherwise False. A number is Wonderful if the sum of its digits is greater than the product of its digits. """ digits = [int(d) for d in str(n)] digit_sum = sum(digits) digit_product = 1 for d in digits: ...
def test_is_wonderful(): assert is_wonderful(13) == True # 1 + 3 > 1 * 3 assert is_wonderful(24) == False # 2 + 4 <= 2 * 4 assert is_wonderful(36) == False # 3 + 6 <= 3 * 6 assert is_wonderful(45) == False # 4 + 5 <= 4 * 5 assert is_wonderful(56) == False # 5 + 6 <= 5 * 6 assert is_wonderful(10...
[ { "docstring": "Returns True if the number n is a Wonderful Number, otherwise False.\nA number is Wonderful if the sum of its digits is greater than the product of its digits.", "function_declaration": "def is_wonderful(n):", "function_name": "is_wonderful", "parameter_list": "(n)" }, { "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": "def is_wonderful(number):\n \"\"\"\n Check if a given number is a Wonderful Number.\n \"\"\"\n digits = [int(d) for d in str(number)]\n digit_sum = ...
trial_gpt4o_2
{ "original_instruction": "A number N is called a *Wonderful Number* if the sum of its digits is greater than the product of its digits.\n\nYou are given an array B of size M. You are also given P queries. Each query consists of two integers Y and Z.\n\nFor each query, find the count of *Wonderful Numbers* in the sub...
0.643216
Taco_82340
C
[ "is_wonderful", "wonderful_numbers_count", "process_test_cases" ]
3
[ [ "process_test_cases", "wonderful_numbers_count" ], [ "wonderful_numbers_count", "is_wonderful" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
false
[]
true
040274aec4e2f262293ae5e7dd2e039f130f3b00
24585eaae5fc565054b065ccb769c8e1ea450b04
v1.0
complete
Taco
Taco_81858_C
from typing import List, Tuple def count_components(n: int, edges: List[Tuple[int, int]]) -> int: """ Helper function to count the number of connected components in an undirected graph. """ from collections import defaultdict, deque def bfs(node: int): queue = deque([node]) visited...
def count_components(n, edges): """ Helper function to count the number of connected components in an undirected graph. """ from collections import defaultdict, deque def bfs(node): queue = deque([node]) visited.add(node) while queue: current = queue.popleft() ...
def test_count_components(): assert count_components(4, [(1, 2), (3, 4)]) == 2 assert count_components(3, [(1, 2)]) == 2 assert count_components(5, []) == 5 assert count_components(4, [(1, 2), (2, 3), (3, 4)]) == 1 def test_minimum_new_connections_needed(): assert minimum_new_connections_needed(4, ...
[ { "docstring": "Helper function to count the number of connected components in an undirected graph.", "function_declaration": "def count_components(n, edges):", "function_name": "count_components", "parameter_list": "(n, edges)" }, { "docstring": "Given the number of servers (n), the number ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(paren...
trial_gpt4o_2
{ "original_instruction": "You are the network administrator of a large organization. The organization uses a system of servers, each identified by a unique number from 1 to N. The servers are interconnected such that each server can directly communicate with some subset of other servers. The communications between t...
0.622145
Taco_81858
C
[ "count_components", "minimum_new_connections_needed", "solve", "main" ]
4
[ [ "minimum_new_connections_needed", "count_components" ], [ "solve", "minimum_new_connections_needed" ] ]
2
[]
false
[]
false
pytest
false
[]
true
1b3a11a3bae6ceb1b377b587b75da59bb234bd41
fef0ca76e672da0f3170df3188db0ff5880a918d