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
instruct
Taco
Taco_59326_I
A group of friends is playing a game on a grid. The grid has M rows and N columns. Each cell in the grid can either be empty or contain a block. The friends move from one cell to another adjacent cell. Adjacent cells are those that share an edge either horizontally or vertically (not diagonally). Their objective is to...
from collections import deque def shortest_path_in_grid(M, N, Sx, Sy, Dx, Dy, grid): directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] Sx -= 1 Sy -= 1 Dx -= 1 Dy -= 1 queue = deque([(Sx, Sy, 0)]) visited = set() visited.add((Sx, Sy)) while queue: x, y, steps = queue.pople...
def test_shortest_path_in_grid(): # Test Example 1 M = 5 N = 5 Sx = 1 Sy = 1 Dx = 5 Dy = 5 grid = [ ".....", "..#..", "..#..", "..#..", "....." ] assert shortest_path_in_grid(M, N, Sx, Sy, Dx, Dy, grid) == 8 # Test Example 2 M = 3 ...
[ { "docstring": null, "function_declaration": "def shortest_path_in_grid(M, N, Sx, Sy, Dx, Dy, grid):", "function_name": "shortest_path_in_grid", "parameter_list": "(M, N, Sx, Sy, Dx, Dy, grid)" }, { "docstring": null, "function_declaration": "def read_input_and_compute():", "function...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path_in_grid(M, N, Sx, Sy, Dx, Dy, grid):\n directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]\n Sx -= 1\n Sy -...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00059326", "row_id": 59326, "seed_ids": "[130]" }
0.86004
Taco_59326
I
[ "shortest_path_in_grid", "read_input_and_compute" ]
2
[ [ "read_input_and_compute", "shortest_path_in_grid" ] ]
1
[]
false
[]
false
pytest
false
[]
true
754e919a519fbf17e06d57a895ec5e4c6001d92b
f458accc2da4b648ec8b06de1b161f0eec58b128
v1.0
instruct
Taco
Taco_59332_I
You are given a binary tree. Your task is to find the maximum path sum. The path may start and end at any node in the tree and must move downward (traveling only from parent nodes to child nodes). A path sum is the sum of the values of nodes in a specific path. Input The input consists of a single line that represen...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def maxPathSum(root): def helper(node): nonlocal max_sum if not node: return 0 # Calculate the maximum path sum with respect to curre...
from solution import find_max_path_sum def test_find_max_path_sum_simple(): assert find_max_path_sum("1 2 3") == 6 def test_find_max_path_sum_with_negatives(): assert find_max_path_sum("-10 9 20 null null 15 7") == 42 def test_find_max_path_sum_single_node(): assert find_max_path_sum("5") == 5 def test_...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List, Optional\n\n# Definition for a binary tree node.\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00059332", "row_id": 59332, "seed_ids": "[14793]" }
0.623147
Taco_59332
I
[ "maxPathSum", "deserialize", "find_max_path_sum" ]
3
[ [ "find_max_path_sum", "deserialize" ], [ "find_max_path_sum", "maxPathSum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
9ebb26a20ba5703cb37cd17d3d86e104cf4f1d21
1cf72260f3bc7d09515d2a621d21fcd2598dc90d
v1.0
instruct
Taco
Taco_59338_I
A group of friends is planning a treasure hunt. Each treasure is represented by a string of length $N$, made up of uppercase English letters. They have a map that gives clues about the treasure's location. Each clue is a string of length $M$ which might contain a sequence of characters that can be found as a subsequenc...
def is_subsequence(treasure, clue): """ Determines if 'clue' is a subsequence of 'treasure'. """ it = iter(treasure) return all(char in it for char in clue) def count_subsequences(T, test_cases): """ Counts the number of clues that are subsequences of the treasure strings for each test case...
from solution import is_subsequence, count_subsequences, parse_input def test_is_subsequence(): assert is_subsequence("TREASURE", "TRE") == True assert is_subsequence("TREASURE", "SURE") == True assert is_subsequence("TREASURE", "ASTR") == False assert is_subsequence("GDVANC", "GAC") == True assert...
[ { "docstring": "Determines if 'clue' is a subsequence of 'treasure'.", "function_declaration": "def is_subsequence(treasure, clue):", "function_name": "is_subsequence", "parameter_list": "(treasure, clue)" }, { "docstring": "Counts the number of clues that are subsequences of the treasure st...
[ 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_subsequence(treasure, clue):\n \"\"\"\n Helper function to check if clue is a subsequence of treasure.\n \"\"\"\n it = iter(treasure)\n retur...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00059338", "row_id": 59338, "seed_ids": "[568]" }
0.717287
Taco_59338
I
[ "is_subsequence", "count_subsequences", "parse_input" ]
3
[ [ "count_subsequences", "is_subsequence" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
0a85222b88fa6a402a2110a5682e6b6f48e277ea
93856ce15049bfd85bf121dbe8adc3e226f6fb3a
v1.0
instruct
Taco
Taco_59359_I
Given a string S, calculate its lexicographic rank among all its possible permutations sorted in alphabetical order. Assume that all characters in the string are distinct. Example 1: Input: S = "abc" Output: 1 Explanation: All permutations of "abc" in lexicographic order are ["abc", "acb", "bac", "bca", "cab", "cba"]....
def factorial(n): """ Returns the factorial of n. """ return 1 if n == 0 or n == 1 else n * factorial(n - 1) def lexicographicRank(S): """ Returns the lexicographic rank of string S. """ n = len(S) rank = 1 mul = factorial(n) for i in range(n): mul //= (n - i) ...
from solution import lexicographicRank def test_lexicographicRank_example1(): assert lexicographicRank("abc") == 1 def test_lexicographicRank_example2(): assert lexicographicRank("cba") == 6 def test_lexicographicRank_single_character(): assert lexicographicRank("a") == 1 def test_lexicographicRank_two_...
[ { "docstring": "Returns the factorial of n.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Returns the lexicographic rank of string S.", "function_declaration": "def lexicographicRank(S):", "function_name": "lex...
[ 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 factorial(n):\n if n == 0 or n == 1:\n return 1\n fact = 1\n for i in range(2, n + 1):\n fact *= i\n return fact\n\ndef lexicographic...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00059359", "row_id": 59359, "seed_ids": "[9551]" }
0.690297
Taco_59359
I
[ "factorial", "lexicographicRank" ]
2
[ [ "lexicographicRank", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5b78e421e569d291c37a89a33a08c0078783aebc
89143a5b1b6632f4bcea73b1a014b12869b8cb2f
v1.0
instruct
Taco
Taco_59376_I
Imagine you are tasked with developing a new scheduling algorithm for a hospital. The hospital operates with a set number of operating rooms, and each surgery requires one room for its entire duration. Each surgery also cannot overlap with another surgery in the same room. The hospital receives a daily list of surgeri...
def min_operating_rooms(test_cases): """ Returns a list of minimum number of operating rooms required for each test case. """ results = [] for surgeries in test_cases: events = [] for s, t in surgeries: events.append((s, 'start')) events.append((t, 'end')) ...
def test_min_operating_rooms(): input_lines = [ "5", "1 4", "2 5", "6 7", "3 8", "8 9", "3", "2 3", "4 5", "6 7", "0" ] expected_output = [3, 1] assert process_surgery_data(input_lines) == expected_output ...
[ { "docstring": "Returns a list of minimum number of operating rooms required for each test case.", "function_declaration": "def min_operating_rooms(test_cases):", "function_name": "min_operating_rooms", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def min_operating_rooms(surgeries):\n \"\"\"\n Determine the minimum number of operating rooms required to schedule all the surgerie...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00059376", "row_id": 59376, "seed_ids": "[6894]" }
0.64772
Taco_59376
I
[ "min_operating_rooms", "parse_input", "process_surgery_data" ]
3
[ [ "process_surgery_data", "min_operating_rooms" ], [ "process_surgery_data", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
bfb9dfecb856ff224d08f56f0f8818439cf2b3a4
3e60a40c347f6a3cd70f2cd2d65183c5908fee68
v1.0
instruct
Taco
Taco_59473_I
A team of archaeologists is deciphering an ancient numeric code inscribed on stones found at a site. The code forms a unique triangle pattern based on a provided number. Your task is to help them generate this pattern. -----Input:----- - First line will contain an integer $N$, the number of stones with inscriptions. -...
def generate_triangle(base_length): """ Generate a triangle pattern of numbers with the specified base length. Args: base_length (int): The base length and the height of the triangle. Returns: List[str]: A list of strings representing each row of the triangle. """ triangle = []...
from solution import generate_triangle, generate_patterns def test_generate_triangle_base_2(): expected_output = ["12", "23"] assert generate_triangle(2) == expected_output def test_generate_triangle_base_3(): expected_output = ["123", "234", "345"] assert generate_triangle(3) == expected_output def ...
[ { "docstring": "Generate a triangle pattern of numbers with the specified base length.\n\nArgs:\nbase_length (int): The base length and the height of the triangle.\n\nReturns:\nList[str]: A list of strings representing each row of the triangle.", "function_declaration": "def generate_triangle(base_length):"...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_triangle_patterns(N, stones):\n \"\"\"\n Given N stones and their respective base lengths, generate the triangle patterns.\n \n Args:\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00059473", "row_id": 59473, "seed_ids": "[375]" }
0.560736
Taco_59473
I
[ "generate_triangle", "generate_patterns" ]
2
[ [ "generate_patterns", "generate_triangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3e99e3f3323b34c11ed94d6efa324912f543472a
680d51a8bf363c8893b235c141d9363d89995a0c
v1.0
instruct
Taco
Taco_59486_I
A logistics company is trying to optimize their delivery routes. They have multiple delivery points and want to determine the shortest possible round trip route that visits each point exactly once and returns to the starting point. Can you help them by writing an algorithm to solve this problem? ## Task Create a func...
from itertools import permutations import math from typing import List, Tuple def euclidean_distance(p1: Tuple[int, int], p2: Tuple[int, int]) -> float: return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def calculate_route_length(route: List[Tuple[int, int]]) -> float: length = 0.0 for i in ra...
from solution import shortest_route def test_shortest_route_simple_case(): points = [(0, 0), (2, 2), (2, 0), (0, 2)] result = shortest_route(points) assert result[0] == (0, 0) and result[-1] == (0, 0), "The route must start and end at the first point." assert len(result) == 5, "The route must have the ...
[ { "docstring": null, "function_declaration": "def euclidean_distance(p1, p2):", "function_name": "euclidean_distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def calculate_route_length(route):", "function_name": "calculate_route_length", "pa...
[ 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 itertools\nimport math\nfrom typing import List, Tuple\n\ndef calculate_distance(point1: Tuple[int, int], point2: Tuple[int, int]) -> float:\n \"\"\"\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00059486", "row_id": 59486, "seed_ids": "[22258]" }
0.634594
Taco_59486
I
[ "euclidean_distance", "calculate_route_length", "shortest_route" ]
3
[ [ "calculate_route_length", "euclidean_distance" ], [ "shortest_route", "calculate_route_length" ] ]
2
[]
false
[]
false
pytest
true
[]
true
39878140f30a1ecbb17dc22bdf6d98ea2712b89a
e74e756db481ac9eb97bca379f6dd458612fca0a
v1.0
instruct
Taco
Taco_59496_I
You are given several pairs of strings a, b consisting of lowercase letters and you need to determine if one string is a permutation of the other. A permutation is a rearrangement of letters. Input The first line contains T (number of test cases). 1 ≤ T ≤ 100 Each of the next 2T lines contains a lowercase string a (1 ...
def are_permutations(a, b): """ Returns 'YES' if string 'b' is a permutation of string 'a', otherwise returns 'NO'. """ return "YES" if sorted(a) == sorted(b) else "NO" def check_permutations(test_cases): """ Given a list of test cases, where each pair of strings is represented as a tuple, ...
from solution import are_permutations, check_permutations, process_input def test_are_permutations(): assert are_permutations('listen', 'silent') == 'YES' assert are_permutations('triangle', 'integral') == 'YES' assert are_permutations('apple', 'pale') == 'NO' assert are_permutations('abc', 'cab') == '...
[ { "docstring": "Returns 'YES' if string 'b' is a permutation of string 'a', otherwise returns 'NO'.", "function_declaration": "def are_permutations(a, b):", "function_name": "are_permutations", "parameter_list": "(a, b)" }, { "docstring": "Given a list of test cases, where each pair of strin...
[ 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_permutations(a, b):\n \"\"\"\n Returns whether the given strings a and b are permutations of each other.\n \"\"\"\n return sorted(a) == sorted(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00059496", "row_id": 59496, "seed_ids": "[18380]" }
0.752019
Taco_59496
I
[ "are_permutations", "check_permutations", "process_input" ]
3
[ [ "check_permutations", "are_permutations" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
154959fd525eac0acdb280ea439a59ab77b6699f
d930a9e067a80ad68bccccf0b426a22578603dd6
v1.0
instruct
Taco
Taco_59501_I
You are given a list of n distinct integers, and you need to divide this list into two non-empty subsets such that the sum of the integers in each subset is equal. If it is not possible to do so, return "No". Otherwise, return "Yes". -----Input----- The input consists of a single line which contains an integer n (2 ≤...
def can_partition(nums): total_sum = sum(nums) # If the total sum is odd, it's not possible to divide into two subsets with equal sum if total_sum % 2 != 0: return "No" target = total_sum // 2 n = len(nums) # Initialize a list to track possible sums using dynamic programmi...
from solution import partition_equal_sum def test_partition_equal_sum_case1(): assert partition_equal_sum([4, 1, 5, 11, 5]) == "Yes" def test_partition_equal_sum_case2(): assert partition_equal_sum([3, 1, 2, 5]) == "No" def test_partition_equal_sum_case3(): assert partition_equal_sum([5, 3, 1, 4, 2, 2]) ...
[ { "docstring": null, "function_declaration": "def can_partition(nums):", "function_name": "can_partition", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def partition_equal_sum(nums):", "function_name": "partition_equal_sum", "parameter_list": "(nums...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_partition(n, nums):\n # Calculate the sum of the list\n total_sum = sum(nums)\n \n # If the total sum is odd, it's not possible to partition it...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00059501", "row_id": 59501, "seed_ids": "[3555]" }
0.672199
Taco_59501
I
[ "can_partition", "partition_equal_sum" ]
2
[ [ "partition_equal_sum", "can_partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
769a929ed09f6fa7418936434705453b24b817c1
eea6bf402881b7227bd620f96a8232e07cdaf66c
v1.0
instruct
Taco
Taco_59534_I
Create a program to determine if a given Sudoku puzzle is valid. The program should check if the puzzle board contains valid digits from 1 to 9 and adheres to Sudoku rules: each row, each column, and each of the nine 3x3 sub-grids must contain all unique digits from 1 to 9 only once. Input: The input consists of multi...
def is_valid_sudoku(board): def is_valid_unit(unit): elements = [num for num in unit if num != '.'] return len(elements) == len(set(elements)) def get_subgrid(board, start_row, start_col): return [board[row][col] for row in range(start_row, start_row + 3) for col in range(start_col,...
def test_is_valid_sudoku(): valid_puzzle = [ "53..7....", "6..195...", ".98....6.", "8...6...3", "4..8.3..1", "7...2...6", ".6....28.", "...419..5", "....8..79" ] invalid_puzzle = [ "63..7....", "6..895...", ".9...
[ { "docstring": null, "function_declaration": "def is_valid_sudoku(board):", "function_name": "is_valid_sudoku", "parameter_list": "(board)" }, { "docstring": null, "function_declaration": "def validate_sudoku_puzzles(puzzles):", "function_name": "validate_sudoku_puzzles", "parame...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_sudoku(board):\n def is_valid_unit(unit):\n elements = [num for num in unit if num != '.']\n return len(elements) == len(set(elements...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00059534", "row_id": 59534, "seed_ids": "[19278]" }
0.6322
Taco_59534
I
[ "is_valid_sudoku", "validate_sudoku_puzzles" ]
2
[ [ "validate_sudoku_puzzles", "is_valid_sudoku" ] ]
1
[]
false
[]
false
pytest
false
[]
true
3838f80ec6ae34c692042de78bdff46a6bdf1ee5
934500951fdae989b55e9ea85041299f601c31d8
v1.0
instruct
Taco
Taco_59548_I
In a land far away, the kingdom is divided into several provinces. The kingdom's defense council is considering connecting these provinces with roads to facilitate efficient troop movement. To ensure the shortest possible paths between any two provinces, they want to build roads in such a way that the total length of r...
def kruskal_minimum_spanning_tree(N, edges): """ Given number of nodes (N) and a list of edges (u, v, w), this function computes the minimum possible total length of roads required to connect all provinces using Kruskal's algorithm. If it is impossible to connect all provinces, return -1. """ ...
from solution import minimum_road_length def test_example_case(): N = 4 M = 5 roads = [ (1, 2, 1), (2, 3, 2), (3, 4, 3), (1, 4, 4), (1, 3, 5) ] assert minimum_road_length(N, M, roads) == 6 def test_all_disconnected(): N = 4 M = 0 roads = [] a...
[ { "docstring": "Given number of nodes (N) and a list of edges (u, v, w), \nthis function computes the minimum possible total length \nof roads required to connect all provinces using Kruskal's algorithm.\nIf it is impossible to connect all provinces, return -1.", "function_declaration": "def kruskal_minimum...
[ 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": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return par...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00059548", "row_id": 59548, "seed_ids": "[10495]" }
0.740563
Taco_59548
I
[ "kruskal_minimum_spanning_tree", "minimum_road_length" ]
2
[ [ "minimum_road_length", "kruskal_minimum_spanning_tree" ] ]
1
[]
false
[]
false
pytest
true
[]
true
46b4b7db0534bba48e05f59d8c9f344f0f57dac2
0264813a07a5ec98a38ce1268d5dd6cb63e3622e
v1.0
instruct
Taco
Taco_59631_I
Description A palindrome is a string that reads the same backward as forward. Write a function that checks if a given string is almost a palindrome. A string is considered almost a palindrome if it can be made into a palindrome by removing exactly one character. The input is a string that can contain upper and lowerc...
def is_palindrome(s): """ Helper function to check if a given string is a palindrome. """ return s == s[::-1] def almost_palindrome(s): """ Returns True if the given string is an almost palindrome. A string is considered an almost palindrome if it can be made into a palindrome by removi...
from solution import almost_palindrome def test_almost_palindrome(): assert almost_palindrome("radkar") == True assert almost_palindrome("raceecar") == True assert almost_palindrome("abc") == False assert almost_palindrome("Race, Car") == True # Removing , and space, then r gets removed assert almo...
[ { "docstring": "Helper function to check if a given string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns True if the given string is an almost palindrome.\nA string is considered an alm...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s: str) -> bool:\n \"\"\"\n Helper function to check if a given string is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef preproc...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00059631", "row_id": 59631, "seed_ids": "[22327]" }
0.79655
Taco_59631
I
[ "is_palindrome", "almost_palindrome" ]
2
[ [ "almost_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
07a084856d5d547047ae3cf9d36cb3368e703f18
3a268b2c3ab50eaee5cb82af1f95769c88ae77d7
v1.0
instruct
Taco
Taco_59679_I
You have been assigned the task of developing a new software system for managing orders in a restaurant. One of the functionalities is to compute the total cost of orders placed by customers. Each customer can place multiple orders, and each order consists of multiple items. Each item has a name, quantity, and price p...
from typing import List, Tuple def parse_orders(input_data: str) -> List[List[Tuple[str, int, float]]]: """ Parses the input data and returns a list where each element is a list of tuples representing an order. """ lines = input_data.strip().split('\n') n = int(lines[0]) index = 1 orders = ...
import pytest from solution import parse_orders, compute_order_cost, compute_total_cost def test_parse_orders(): input_data = "2\n3\nburger 2 5.00\nfries 1 2.50\ncola 1 1.25\n2\npizza 1 10.00\nwater 2 1.00" expected_output = [ [("burger", 2, 5.00), ("fries", 1, 2.50), ("cola", 1, 1.25)], [("piz...
[ { "docstring": "Parses the input data and returns a list where each element is a list of tuples representing an order.", "function_declaration": "def parse_orders(input_data):", "function_name": "parse_orders", "parameter_list": "(input_data)" }, { "docstring": "Takes an order and returns th...
[ 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, Tuple\n\ndef parse_orders(input_data: str) -> List[List[Tuple[str, int, float]]]:\n \"\"\"\n Parses the input data and returns a lis...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00059679", "row_id": 59679, "seed_ids": "[19378]" }
0.646186
Taco_59679
I
[ "parse_orders", "compute_order_cost", "compute_total_cost" ]
3
[ [ "compute_total_cost", "compute_order_cost" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c016944babc1fcb74f8c5aa097f4b2468ee2eed5
fa578f5ce99aaff5af3f9c71c2aa9bb2101fc3b5
v1.0
instruct
Taco
Taco_59710_I
Kevin loves to play all sorts of games, and one of his favorite types of puzzles is Sudoku. However, he has become bored of the classic 9x9 Sudoku and decided to create his own version called Mini Sudoku. In Mini Sudoku, the grid size is 4x4, and the standard rules of Sudoku apply: each row, each column, and each 2x2 s...
def is_valid(grid, row, col, num): # Check if num is not in the given row if num in grid[row]: return False # Check if num is not in the given column if num in [grid[r][col] for r in range(4)]: return False # Check if num is not in the 2x2 sub-grid start_row, start_col = 2 * (r...
from solution import mini_sudoku_solver def test_sample_input(): grid = [ [0, 0, 3, 4], [3, 4, 0, 0], [0, 3, 4, 0], [4, 0, 0, 3] ] assert mini_sudoku_solver(grid) == "YES" def test_no_solution(): grid = [ [1, 1, 2, 3], [3, 4, 1, 0], [2, 3, 4, 1],...
[ { "docstring": null, "function_declaration": "def is_valid(grid, row, col, num):", "function_name": "is_valid", "parameter_list": "(grid, row, col, num)" }, { "docstring": null, "function_declaration": "def solve(grid):", "function_name": "solve", "parameter_list": "(grid)" }, ...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid(board, r, c, num):\n for i in range(4):\n if board[r][i] == num or board[i][c] == num:\n return False\n \n startRow, startC...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00059710", "row_id": 59710, "seed_ids": "[21261]" }
0.63696
Taco_59710
I
[ "is_valid", "solve", "mini_sudoku_solver" ]
3
[ [ "mini_sudoku_solver", "solve" ], [ "solve", "is_valid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fcf5593354472c36a7dd923b22c5a2c1c1478083
952eaf8fc76d2c44d290833e2c8330e1c30c8c37
v1.0
instruct
Taco
Taco_59732_I
Given a list of integers, write a function that calculates the sum of all prime numbers in the list. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example: ``` sumOfPrimes([1, 2, 3, 4, 5]) = 10 // 2 + 3 + 5 sumOfPrimes([10, 11, 12, 13, 14]) = 24 // 1...
def is_prime(n): """ Returns True if n is a prime number, else False. """ 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 sumOfPrimes...
from solution import sumOfPrimes def test_with_primes(): assert sumOfPrimes([1, 2, 3, 4, 5]) == 10 assert sumOfPrimes([10, 11, 12, 13, 14]) == 24 assert sumOfPrimes([17, 19, 23]) == 59 def test_with_no_primes(): assert sumOfPrimes([4, 6, 8, 10]) == 0 assert sumOfPrimes([1, 1, 1]) == 0 assert s...
[ { "docstring": "Returns True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the list numbers.", "function_declaration": "def sumOfPrimes(numb...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n retur...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00059732", "row_id": 59732, "seed_ids": "[18275]" }
0.68245
Taco_59732
I
[ "is_prime", "sumOfPrimes" ]
2
[ [ "sumOfPrimes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
172f2702105514d42de18fcae59503a2286becf2
f095c2e9306ff4c290c510ed9be7285c4addff05
v1.0
instruct
Taco
Taco_59792_I
Task The provided code stub reads an integer, $n$, from STDIN. For all positive integers $i \leq n$, print whether $i$ is prime or not. Example $n = 5$ The list of positive integers from 1 to $n=5$ is $[1, 2, 3, 4, 5]$. Print whether each number is prime on a separate line. 1 is not prime 2 is prime 3 is prime 4...
def is_prime(num): """ Checks if a number is prime. Parameters: num (int): The number to check. Returns: bool: True if num is prime, else False. """ if num <= 1: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False ...
from solution import is_prime, print_prime_status def test_is_prime(): assert is_prime(1) == False, "Test case 1 failed" assert is_prime(2) == True, "Test case 2 failed" assert is_prime(3) == True, "Test case 3 failed" assert is_prime(4) == False, "Test case 4 failed" assert is_prime(5) == True, "T...
[ { "docstring": "Checks if a number is prime.\n\nParameters:\nnum (int): The number to check.\n\nReturns:\nbool: True if num is prime, else False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "For all positive integer...
[ 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 for i in range(3, int(n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00059792", "row_id": 59792, "seed_ids": "[3363]" }
0.670758
Taco_59792
I
[ "is_prime", "print_prime_status" ]
2
[ [ "print_prime_status", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c9bcc7511908fa8d69f81a5c52977c5ab98aded7
7a4f0397a4bb34935845ce21a3cabd12169fe722
v1.0
instruct
Taco
Taco_59796_I
A famous artist specializes in creating mosaic artwork using colorful square tiles. Each tile has a unique color, represented by an uppercase English letter (from 'A' to 'Z'). He arranges these tiles in a grid with R rows and C columns. The artist wants to know the largest contiguous rectangular region (subgrid) in the...
def largest_contiguous_area(grid): R = len(grid) C = len(grid[0]) if R > 0 else 0 max_area = 0 for row_start in range(R): for col_start in range(C): color = grid[row_start][col_start] for row_end in range(row_start, R): for col_end in range(col_start,...
def test_largest_contiguous_area_single_color_grid(): grid = [ "AAA", "AAA", "AAA" ] assert largest_contiguous_area(grid) == 9 def test_largest_contiguous_area_mixed_colors(): grid = [ "ABAA", "ABBB", "ABBB", "AAAA", "BBBB" ] asser...
[ { "docstring": null, "function_declaration": "def largest_contiguous_area(grid):", "function_name": "largest_contiguous_area", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def check_uniform(grid, row_start, col_start, row_end, col_end, color):", "functi...
[ 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 largest_contiguous_area(grid):\n R = len(grid)\n C = len(grid[0]) if R > 0 else 0\n max_area = 0\n \n for row_start in range(R):\n for co...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00059796", "row_id": 59796, "seed_ids": "[15489]" }
0.629612
Taco_59796
I
[ "largest_contiguous_area", "check_uniform", "parse_input", "solve" ]
4
[ [ "largest_contiguous_area", "check_uniform" ], [ "solve", "largest_contiguous_area" ], [ "solve", "parse_input" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
e5ed60233d109a5661256e24413137d16816a2d2
5e27c609d0474ef8a8b9b051a81225a9bd41b383
v1.0
instruct
Taco
Taco_59879_I
A forest is a collection of trees. Alice is a caretaker of a special forest where each tree has a distinct number of fruits. Alice wants to count the forest fruits in specific ranges but needs your help to do it efficiently. Given the fruits on the trees in an array and multiple queries which each ask for the sum of fr...
def preprocess_fruits(fruits): """ Preprocesses the fruits list to create a prefix sums array. """ prefix_sums = [0] * (len(fruits) + 1) for i in range(1, len(fruits) + 1): prefix_sums[i] = prefix_sums[i - 1] + fruits[i - 1] return prefix_sums def query_sum(prefix_sums, l, r): """ ...
def test_preprocess_fruits(): fruits = [4, 7, 2, 9, 5] expected_prefix_sums = [0, 4, 11, 13, 22, 27] assert preprocess_fruits(fruits) == expected_prefix_sums def test_query_sum(): prefix_sums = [0, 4, 11, 13, 22, 27] assert query_sum(prefix_sums, 1, 3) == 13 assert query_sum(prefix_sums, 2, 4) ...
[ { "docstring": "Preprocesses the fruits list to create a prefix sums array.", "function_declaration": "def preprocess_fruits(fruits):", "function_name": "preprocess_fruits", "parameter_list": "(fruits)" }, { "docstring": "Computes the sum of fruits in the range [l, r] using the prefix sums a...
[ 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 forest_fruits(n, fruits, q, queries):\n \"\"\"\n Computes the sum of fruits in specified ranges for multiple queries.\n \n :param n: int - Number o...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00059879", "row_id": 59879, "seed_ids": "[6760]" }
0.578821
Taco_59879
I
[ "preprocess_fruits", "query_sum", "count_fruits" ]
3
[ [ "count_fruits", "preprocess_fruits" ], [ "count_fruits", "query_sum" ] ]
2
[]
false
[]
false
pytest
false
[]
true
adc2573af9141bfbce3adc554e87a9b50334c741
87f6c59f8584c43306d76144091eb825a32782d1
v1.0
instruct
Taco
Taco_59914_I
A software company implements a system for monitoring user activities on its platform. The platform has a tree structure representing a hierarchy of different modules, where each module is connected to its parent module. Each module has an associated activity score which represents the user engagement on that module. ...
class TreeNode: def __init__(self, index, score): self.index = index self.score = score self.children = [] self.parent = None def build_tree(n, scores, edges): nodes = [TreeNode(i, scores[i-1]) for i in range(1, n+1)] for u, v in edges: nodes[u-1].children.appen...
def test_case_1(): n = 5 q = 3 scores = [1, 5, 3, 2, 4] edges = [(1, 2), (1, 3), (2, 4), (2, 5)] queries = [(1, 4), (4, 5), (3, 4)] expected_result = [5, 5, 5] assert solve(n, q, scores, edges, queries) == expected_result def test_case_2(): n = 4 q = 2 scores = [8, 6, 7, 5] ...
[]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef build_tree(n, edges):\n tree = defaultdict(list)\n for u, v in edges:\n tree[u].append(v)\n t...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00059914", "row_id": 59914, "seed_ids": "[10835]" }
0.671759
Taco_59914
I
[ "build_tree", "preprocess_lca", "query_max_score", "solve" ]
4
[ [ "solve", "build_tree" ], [ "solve", "preprocess_lca" ], [ "solve", "query_max_score" ] ]
3
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
acae9b11be10ceaaca2ff990adc8ba4b328b5c1a
b43123548791d448e705e8d73889ef919037b5fd
v1.0
instruct
Taco
Taco_59924_I
A binary tree is called a uni-value binary tree if all nodes of the tree have the same value. Given a binary tree, your task is to determine if it is a uni-value binary tree. ### Constraints - The number of nodes in the tree will be in the range [1, 1000]. - Each node will have a value in the range [0, 100]. ### Inpu...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def is_unival_tree(root): """ Determines if a binary tree is a uni-value tree. """ if not root: return True val = root.val def dfs(n...
from solution import is_unival_tree_from_str def test_unival_tree(): assert is_unival_tree_from_str("1 1 1 1 1 null null") == True assert is_unival_tree_from_str("2 2 2 null null 5 2") == False assert is_unival_tree_from_str("1 1 1 1 1 1 1") == True assert is_unival_tree_from_str("1") == True asser...
[]
[ 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 constru...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00059924", "row_id": 59924, "seed_ids": "[21844]" }
0.637956
Taco_59924
I
[ "is_unival_tree", "deserialize", "is_unival_tree_from_str" ]
3
[ [ "is_unival_tree_from_str", "deserialize" ], [ "is_unival_tree_from_str", "is_unival_tree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
2c9aca716c95121ff403a98d135a35dd5d6d0a95
684dc53eb4accb91939e434cff49b38bc1911258
v1.0
instruct
Taco
Taco_59981_I
Given a binary tree, your task is to complete the function findTreeHeight() which takes the root of the binary tree as input and returns the height of the tree. Input: The input line contains T, denoting the number of test cases. Each test case contains a binary tree in level-order traversal where -1 represents a null ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def buildTree(levelOrder): if not levelOrder or levelOrder[0] == -1: return None root = TreeNode(levelOrder[0]) queue = [root] i = 1 whi...
from solution import findTreeHeight, evaluateTestCases def test_basic_cases(): testCases = [ [3, 9, 20, -1, -1, 15, 7], [1, -1, 2, -1, -1] ] expected = [3, 2] assert evaluateTestCases(testCases) == expected def test_single_node(): testCases = [ [1] ] expected = [1] ...
[]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, data):\n self.data = data\n self.left = None\n self.right = None\n\ndef findTreeHeight(root):\n if ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00059981", "row_id": 59981, "seed_ids": "[8124]" }
0.630823
Taco_59981
I
[ "buildTree", "findTreeHeight", "evaluateTestCases" ]
3
[ [ "evaluateTestCases", "buildTree" ], [ "evaluateTestCases", "findTreeHeight" ] ]
2
[ "evaluateTestCases" ]
false
[ "TreeNode" ]
true
pytest
true
[]
true
25a5cce73fc348abb02407b6c2ee93a2bce991df
08a971ca6df862974ce002a1bb608727a0fb4234
v1.0
instruct
Taco
Taco_60001_I
You are an environmental researcher studying the migration patterns of a special species of birds. Surprisingly, the birds' migratory habits are influenced by sequences of weather patterns. Your task is to write a program that can analyze the weather patterns to predict whether the birds will migrate on a given day. T...
def will_birds_migrate(test_cases): results = [] for case in test_cases: N, L, binary_string = case found = False for i in range(N - L + 1): substring = binary_string[i:i + L] if substring.count('1') > substring.count('0'): found = True ...
import pytest from solution import will_birds_migrate, parse_input, solution def test_will_birds_migrate(): test_cases = [ (7, 3, '1011010'), (5, 2, '01101'), (6, 4, '000011') ] expected = ["YES", "YES", "NO"] assert will_birds_migrate(test_cases) == expected def test_parse_in...
[ { "docstring": null, "function_declaration": "def will_birds_migrate(test_cases):", "function_name": "will_birds_migrate", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_data):", "function_name": "parse_input", "parameter_l...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bird_migration(T, test_cases):\n results = []\n for i in range(T):\n N, L = test_cases[i][0]\n pattern = test_cases[i][1]\n \n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00060001", "row_id": 60001, "seed_ids": "[20043]" }
0.65681
Taco_60001
I
[ "will_birds_migrate", "parse_input", "solution" ]
3
[ [ "solution", "parse_input" ], [ "solution", "will_birds_migrate" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
3c59c229faf1599ad8d48026b7a97b9311ec07a5
07df30949a51a833440190652495b077fce91f10
v1.0
instruct
Taco
Taco_60047_I
# Task You have a rectangular grid of cells with `m` rows and `n` columns. Each cell in the grid can be in one of two states: populated (represented by 1) or unpopulated (represented by 0). The grid evolves over discrete time steps according to the following rules: 1. Any populated cell with fewer than two populated ne...
def get_next_state(grid): m, n = len(grid), len(grid[0]) next_grid = [[0] * n for _ in range(m)] def count_live_neighbors(x, y): directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)] count = 0 for dx, dy in directions: nx, ny = x + dx, y...
from solution import game_of_life def test_game_of_life_1(): initial_state = [[0, 1, 0], [0, 0, 1], [1, 1, 1]] T = 1 expected_state = [[0, 0, 0], [1, 0, 1], [0, 1, 1]] assert game_of_life(initial_state, T) == expected...
[ { "docstring": null, "function_declaration": "def get_next_state(grid):", "function_name": "get_next_state", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def game_of_life(initial_state, T):", "function_name": "game_of_life", "parameter_list": "(init...
[ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_neighbors_count(grid, row, col):\n \"\"\"\n Helper function to count populated neighbors of a cell in the grid.\n \"\"\"\n rows = len(grid)\n ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00060047", "row_id": 60047, "seed_ids": "[836]" }
0.697841
Taco_60047
I
[ "get_next_state", "game_of_life" ]
2
[ [ "game_of_life", "get_next_state" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5820e56cf15d67e2d88ffae1f69246da15bf733b
6a732a6eca411441ec7d4cfef2cb805e0ee64e37
v1.0
instruct
Taco
Taco_60063_I
Problem statement: You are given the task of developing a new sorting algorithm named "Twist Sort". This algorithm sorts an array of n integers in a unique way. Instead of sorting the entire array, Twist Sort sorts pairs of adjacent elements and iteratively merges these pairs. Here's how Twist Sort works: 1. Divide t...
def twist_sort(arr): """ Sorts the array using the Twist Sort algorithm. """ n = len(arr) if n < 2: return arr[:] # Step 1: Sort adjacent pairs sorted_pairs = [] for i in range(0, n - 1, 2): if arr[i] > arr[i + 1]: sorted_pairs.append((arr[i + 1], arr[i])...
from solution import twist_sort def test_twist_sort_basic(): assert twist_sort([4, 3, 2, 8, 1, 5]) == [1, 2, 3, 4, 5, 8] def test_twist_sort_with_odd_elements(): assert twist_sort([10, 7, 5, 2, 9]) == [2, 5, 7, 9, 10] def test_twist_sort_single_element(): assert twist_sort([1]) == [1] def test_twist_sor...
[ { "docstring": "Sorts the array using the Twist Sort algorithm.", "function_declaration": "def twist_sort(arr):", "function_name": "twist_sort", "parameter_list": "(arr)" }, { "docstring": "Merges two sorted pairs into one.", "function_declaration": "def _merge(pair1, pair2):", "func...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def twist_sort(arr):\n \"\"\"\n Sorts the array using the Twist Sort algorithm.\n \"\"\"\n n = len(arr)\n if n < 2:\n return arr[:]\n \n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00060063", "row_id": 60063, "seed_ids": "[5512]" }
0.568597
Taco_60063
I
[ "twist_sort", "_merge" ]
2
[ [ "twist_sort", "_merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
140d3fb5e7af9e1ea241b75c94414da61df16865
f6f738146c6c92c866e7d603c4e96511c282152f
v1.0
instruct
Taco
Taco_60082_I
Bob loves palindromic numbers. He finds them to be symmetrical and beautiful. Bob defines a number as palindromic if it reads the same backward as forward. Bob wants to know how many palindromic numbers exist in a given range [a, b]. Write a program to help Bob count the number of palindromic numbers between a and b, ...
def is_palindromic(number): """ Returns True if the number is palindromic, False otherwise. """ return str(number) == str(number)[::-1] def count_palindromic_numbers(a, b): """ Returns the count of palindromic numbers in the range [a, b] inclusive. """ count = 0 for number in range(...
from solution import is_palindromic, count_palindromic_numbers def test_is_palindromic(): assert is_palindromic(1) == True assert is_palindromic(9) == True assert is_palindromic(11) == True assert is_palindromic(22) == True assert is_palindromic(121) == True assert is_palindromic(123) == False ...
[ { "docstring": "Returns True if the number is palindromic, False otherwise.", "function_declaration": "def is_palindromic(number):", "function_name": "is_palindromic", "parameter_list": "(number)" }, { "docstring": "Returns the count of palindromic numbers in the range [a, b] inclusive.", ...
[ 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 count_palindromic_numbers(a, b):\n \"\"\"\n Returns the number of palindromic numbers between a and b, inclusive.\n\n Parameters:\n a (int): The st...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00060082", "row_id": 60082, "seed_ids": "[16893]" }
0.699728
Taco_60082
I
[ "is_palindromic", "count_palindromic_numbers" ]
2
[ [ "count_palindromic_numbers", "is_palindromic" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6668e44402902d84bdd8ddc2db940dd78e50ffb7
2ec486427601a4074be3f49c57994bef6b798d8b
v1.0
instruct
Taco
Taco_60137_I
Problem Statement Alex is a digital artist who enjoys working with hexagonal grids. He wants to create a program that can help him fill these grids with colors. Each hexagon in the grid can be painted either "red" or "blue". The grid is represented by an arrangement of nodes, with each node being a hexagon and each ed...
def is_bipartite(graph, n): color = [-1] * n def bfs(source): queue = [source] color[source] = 0 while queue: node = queue.pop(0) for neighbor in graph[node]: if color[neighbor] == -1: color[neighbor] = 1 - color[node] ...
from solution import paint_hex_grid def test_example_1(): n = 6 m = 7 edges = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 5), (4, 6), (5, 6)] result = paint_hex_grid(n, m, edges) assert result.startswith("Possible") def test_example_2(): n = 4 m = 5 edges = [(1, 2), (2, 3), (3, 1), (1, 4), (3...
[ { "docstring": null, "function_declaration": "def is_bipartite(graph, n):", "function_name": "is_bipartite", "parameter_list": "(graph, n)" }, { "docstring": null, "function_declaration": "def paint_hex_grid(n, m, edges):", "function_name": "paint_hex_grid", "parameter_list": "(n...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_bipartite(graph, n):\n \"\"\"\n Function to check if the given graph can be colored with 2 colors\n \"\"\"\n color = [-1] * n\n for start in ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00060137", "row_id": 60137, "seed_ids": "[21910]" }
0.700894
Taco_60137
I
[ "is_bipartite", "paint_hex_grid" ]
2
[ [ "paint_hex_grid", "is_bipartite" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d9bdb3d2b1b0f7307e3eb8136b37f052857d6307
bbea12a113c4e000c122836f345b9fb9190a4ca5
v1.0
instruct
Taco
Taco_60171_I
You are tasked to develop a drone delivery system for a warehouse. The warehouse layout is represented as a grid with `n` rows and `m` columns. Each cell in the grid can either be empty or contain an obstacle. A drone can move between adjacent cells (up, down, left, right) if there's no obstacle. Initially, the drone ...
from collections import deque def minimum_moves_to_deliver_package(grid, n, m): """ Determine the minimum number of moves required for the drone to reach the destination, or return -1 if it's impossible. Arguments: grid: List of strings representing the warehouse layout. n: Number of rows ...
def test_minimum_moves_to_deliver_package(): # Test Case 1 layout = [ ".....", ".***.", ".....", ".***.", ".....", ] assert execute_minimum_moves(5, 5, layout) == 8 # Test Case 2 layout = [ ".***", "*...", "....", ] ass...
[ { "docstring": "Determine the minimum number of moves required for the drone to reach the destination,\nor return -1 if it's impossible.\n\nArguments:\ngrid: List of strings representing the warehouse layout.\nn: Number of rows in the grid.\nm: Number of columns in the grid.\n\nReturns:\nint: Minimum number of ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef minimum_moves_to_deliver_package(grid, n, m):\n \"\"\"\n Determine the minimum number of moves required for the drone to...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00060171", "row_id": 60171, "seed_ids": "[1487]" }
0.668007
Taco_60171
I
[ "minimum_moves_to_deliver_package", "execute_minimum_moves" ]
2
[ [ "execute_minimum_moves", "minimum_moves_to_deliver_package" ] ]
1
[]
false
[]
false
pytest
false
[]
true
789374e223282779b064d7dcb14f59ffbaab95a3
4ec49eccc27cbf284b063d85bad6b5a91bcdc19c
v1.0
instruct
Taco
Taco_60191_I
A park ranger is tracking the migration of a certain bird species. The birds migrate according to a pattern defined by "flight points", which are specific coordinates in a 2D plane that the birds touch upon during their journey. The ranger has observed and recorded these flight points on multiple days. Birds are said...
import math def is_perfect_circle(flight_points): distances = [math.sqrt(x**2 + y**2) for x, y in flight_points] return all(abs(d - distances[0]) < 1e-6 for d in distances) def check_circular_paths(test_cases): results = [] for points in test_cases: if is_perfect_circle(points): re...
import pytest from solution import main def test_sample_inputs(): input_str = "2\n4\n1 1\n-1 -1\n-1 1\n1 -1\n3\n0 2\n2 2\n-2 -2" expected_output = "YES\nNO" assert main(input_str) == expected_output def test_all_points_same_distance(): input_str = "1\n4\n3 4\n-3 -4\n-3 4\n3 -4" expected_output = "...
[ { "docstring": null, "function_declaration": "def is_perfect_circle(flight_points):", "function_name": "is_perfect_circle", "parameter_list": "(flight_points)" }, { "docstring": null, "function_declaration": "def check_circular_paths(test_cases):", "function_name": "check_circular_pa...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_perfect_circle(points):\n \"\"\"\n Given a list of points, determines if all points lie on a circle centered at the origin.\n \"\"\"...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00060191", "row_id": 60191, "seed_ids": "[1614]" }
0.694667
Taco_60191
I
[ "is_perfect_circle", "check_circular_paths", "parse_input", "main" ]
4
[ [ "check_circular_paths", "is_perfect_circle" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
4aeefd8a87ef347657760d7e53a9842fa8f4a53e
fdf2176c614512ce4b60421622de57765dfb91be
v1.0
instruct
Taco
Taco_60219_I
Bob is organizing his library, which contains $n$ books. Each book has a positive integer weight $w_i$. Bob wants to move exactly two books at a time into a box, such that the sum of the weights of these two books is maximized. Each book can be moved into the box only once. Determine the maximum possible sum of weight...
def max_sum_of_two_books(test_cases): results = [] for books in test_cases: # Sort the books weights weights = sorted(books) # The maximum sum of two books will be the sum of the two heaviest books results.append(weights[-1] + weights[-2]) return results # Helper function to...
import pytest from solution import max_sum_weights def test_example_cases(): input_data = "3\n3\n1 2 4\n4\n5 1 2 9\n5\n7 5 12 8 10\n" expected_output = [6, 14, 22] assert max_sum_weights(input_data) == expected_output def test_single_case_min_books(): input_data = "1\n2\n1 2\n" expected_output = [...
[ { "docstring": null, "function_declaration": "def max_sum_of_two_books(test_cases):", "function_name": "max_sum_of_two_books", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", "param...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_sum_of_two_books(t, test_cases):\n \"\"\"\n Determine the maximum possible sum of weights of two books for each test case.\n \n Parameters:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00060219", "row_id": 60219, "seed_ids": "[5439]" }
0.720137
Taco_60219
I
[ "max_sum_of_two_books", "parse_input", "max_sum_weights" ]
3
[ [ "max_sum_weights", "max_sum_of_two_books" ], [ "max_sum_weights", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
aa97959a604479d9943219153218cb8138d9aeea
32a911839c71b4823cb3c3ee7b4e3b757de6d2e6
v1.0
instruct
Taco
Taco_60224_I
Write a function, `largest_integer`, that takes a list of non-negative integers and returns the largest integer that can be formed by concatenating the integers together. For example, given `[50, 2, 1, 9]`, the largest integer would be `95021`. Function Signature `def largest_integer(numbers: List[int]) -> str:` ...
from typing import List from functools import cmp_to_key def compare(x, y): if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def largest_integer(numbers: List[int]) -> str: # Convert all the integers to strings str_numbers = list(map(str, numbers)) ...
from solution import largest_integer def test_largest_integer_basic(): assert largest_integer([10, 2]) == "210" assert largest_integer([3, 30, 34, 5, 9]) == "9534330" def test_largest_integer_single_element(): assert largest_integer([5]) == "5" def test_largest_integer_duplicate_elements(): assert la...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def largest_integer(numbers):", "function_name": "largest_integer", "parameter_list": "(numbers)" } ]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\nfrom functools import cmp_to_key\n\ndef compare(x, y):\n if x + y > y + x:\n return -1\n elif x + y < y + x:\n return ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00060224", "row_id": 60224, "seed_ids": "[5428]" }
0.711028
Taco_60224
I
[ "compare", "largest_integer" ]
2
[ [ "largest_integer", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cba7d5229c963d345fec3e95acb42de798b1e12e
6fdf0d9a4ed4034a4ef78a90e362ae95da8774e8
v1.0
instruct
Taco
Taco_60280_I
**Connection Network Optimization** You are tasked with designing an optimal network for a new city. The city administration has a unique requirement: they want the entire city to be interconnected, but they want to minimize the overall cost of laying down the roads that form the network. The city comprises $n$ distri...
def find(parent, i): while parent[i] != i: i = parent[i] return i def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent[root_y] = root_x else: ...
import pytest from solution import minimum_cost_to_connect_all_districts def test_sample_input_1(): n, m, e = 4, 2, 5 edges = [(0, 1, 10), (0, 2, 6), (0, 3, 5), (1, 2, 15), (2, 3, 4)] assert minimum_cost_to_connect_all_districts(n, m, edges) == 19 def test_sample_input_2(): n, m, e = 4, 1, 4 edges...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00060280", "row_id": 60280, "seed_ids": "[21510]" }
0.751964
Taco_60280
I
[ "find", "union", "minimum_cost_to_connect_all_districts" ]
3
[ [ "minimum_cost_to_connect_all_districts", "find" ], [ "minimum_cost_to_connect_all_districts", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
b12a7039965e4b771a41ced779ee7c7ecb25feb6
9a5e814b61046f1bf08817325c0143e437ac46e4
v1.0
instruct
Taco
Taco_60313_I
In a software company, there are several projects, each with a unique project ID. Each project has a starting and ending date, represented as strings in the format "YYYY-MM-DD". There are also several employees, each working on one or more projects during given time periods, also specified by a unique employee ID, proj...
import datetime from collections import defaultdict def parse_date(date_str): return datetime.datetime.strptime(date_str, '%Y-%m-%d').date() def find_employees_on_date(P, W, projects, work_periods, Q, queries): project_periods = {} for project in projects: project_id, start_str, end_str = projec...
import pytest from solution import find_employees_on_date def test_single_project_single_period(): assert find_employees_on_date( 2, 4, [["P1", "2023-01-01", "2023-12-31"], ["P2", "2024-01-01", "2024-12-31"]], [["E1", "P1", "2023-01-10", "2023-01-20"], ["E2", "P1", "2023-01-15", "2023-02-1...
[ { "docstring": null, "function_declaration": "def parse_date(date_str):", "function_name": "parse_date", "parameter_list": "(date_str)" }, { "docstring": null, "function_declaration": "def find_employees_on_date(P, W, projects, work_periods, Q, queries):", "function_name": "find_empl...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import datetime\nfrom collections import defaultdict\n\n\ndef parse_date(date_str):\n return datetime.datetime.strptime(date_str, '%Y-%m-%d').date()\n\n\ndef fi...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00060313", "row_id": 60313, "seed_ids": "[15509]" }
0.625755
Taco_60313
I
[ "parse_date", "find_employees_on_date" ]
2
[ [ "find_employees_on_date", "parse_date" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9073b4f55a44088f7cf65d2140f0054abcb8b8ea
ebc48af914f768dc5d2d8b6777f79ccbd57f7c1b
v1.0
instruct
Taco
Taco_60343_I
Implement a function for matrix rotation. Input Format: First line contains two integers n and m denoting the dimensions of the matrix (n rows and m columns). Next n lines contain m space-separated integers each representing matrix elements. Output Format: Print the matrix after rotating it 90 degrees clockwise. Con...
def rotate_matrix_90_degrees(matrix): """ Rotates a given matrix 90 degrees clockwise. :param matrix: A list of lists representing the matrix. :return: A list of lists representing the rotated matrix. """ if not matrix: return [] n, m = len(matrix), len(matrix[0]) rotated_ma...
from solution import rotate_matrix_90_degrees, transform_input, matrix_rotation def test_rotate_matrix_90_degrees(): assert rotate_matrix_90_degrees([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) == [[9, 5, 1], [10, 6, 2], [11, 7, 3], [12, 8, 4]] assert rotate_matrix_90_degrees([[1]]) == [[1]] assert rotat...
[ { "docstring": "Rotates a given matrix 90 degrees clockwise.\n\n:param matrix: A list of lists representing the matrix.\n:return: A list of lists representing the rotated matrix.", "function_declaration": "def rotate_matrix_90_degrees(matrix):", "function_name": "rotate_matrix_90_degrees", "paramete...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_matrix_90_clockwise(matrix):\n \"\"\"\n Rotates the given matrix 90 degrees clockwise and returns the rotated matrix.\n \n :param matrix: Li...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00060343", "row_id": 60343, "seed_ids": "[1572]" }
0.597249
Taco_60343
I
[ "rotate_matrix_90_degrees", "transform_input", "matrix_rotation" ]
3
[ [ "matrix_rotation", "rotate_matrix_90_degrees" ], [ "matrix_rotation", "transform_input" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b3c78951a8d240902657a7659df87cc692b277d5
8acb527eeb4c23981abab852c637fe2af21c616c
v1.0
instruct
Taco
Taco_60362_I
There is a sports tournament with n players. Each player can play against only one other player in each round. You are tasked with scheduling the matches in such a way that each player gets to play in every round. Moreover, no player should play against the same player more than once throughout the tournament. Input ...
def schedule_tournament(n): if n % 2 != 0 or n < 2 or n > 100: return ("NO",) rounds = [] players = list(range(1, n + 1)) for i in range(n - 1): round_matches = [] for j in range(n // 2): player1 = players[j] player2 = players[n - 1 - j] ...
from solution import schedule_tournament, format_schedule_tournament def test_schedule_tournament_4(): assert format_schedule_tournament(4) == "YES\n1 4 2 3\n1 3 4 2\n1 2 3 4" def test_schedule_tournament_6(): assert format_schedule_tournament(6) == "YES\n1 6 2 5 3 4\n1 5 6 4 2 3\n1 4 5 3 6 2\n1 3 4 2 5 6\n1 ...
[ { "docstring": null, "function_declaration": "def schedule_tournament(n):", "function_name": "schedule_tournament", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def format_schedule_tournament(n):", "function_name": "format_schedule_tournament", "parame...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def schedule_tournament(n):\n if n % 2 != 0:\n return \"NO\"\n \n schedule = []\n \n players = list(range(1, n + 1))\n \n for i in rang...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00060362", "row_id": 60362, "seed_ids": "[4638]" }
0.731604
Taco_60362
I
[ "schedule_tournament", "format_schedule_tournament" ]
2
[ [ "format_schedule_tournament", "schedule_tournament" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cb85c3a2c5eeb73318c4479ae88a332252395617
834842d0aa66d10513e7c8d6c0f9d5ed8dafe013
v1.0
instruct
Taco
Taco_60377_I
Given a list of n integers, you have to determine if you can rearrange the list so that the sum of the first half of the list is equal to the sum of the second half. If the number of elements in the list is odd, it is not possible to split the list into two equal halves, so the answer should be "NO" in that case. Form...
from itertools import combinations def can_split_into_equal_halves(n, arr): """ Determines if the array can be rearranged to have equal sums in its two halves. """ if n % 2 != 0: return "NO" half = n // 2 total_sum = sum(arr) if total_sum % 2 != 0: return "NO" ...
from solution import can_split_into_equal_halves, process_input def test_can_split_into_equal_halves(): assert can_split_into_equal_halves(4, [1, 1, 2, 2]) == "YES" assert can_split_into_equal_halves(5, [1, 2, 3, 4, 5]) == "NO" assert can_split_into_equal_halves(6, [3, 3, 3, 3, 6, 6]) == "YES" assert c...
[ { "docstring": "Determines if the array can be rearranged to have equal sums in its two halves.", "function_declaration": "def can_split_into_equal_halves(n, arr):", "function_name": "can_split_into_equal_halves", "parameter_list": "(n, arr)" }, { "docstring": "Determines if any subset of nu...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef can_split_into_equal_halves(n, arr):\n \"\"\"\n Determines if the array can be rearranged to have equal sums in its...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00060377", "row_id": 60377, "seed_ids": "[1891]" }
0.65245
Taco_60377
I
[ "can_split_into_equal_halves", "sum_possible", "process_input" ]
3
[ [ "can_split_into_equal_halves", "sum_possible" ], [ "process_input", "can_split_into_equal_halves" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
b6fd801b3961e8b046f043e7ab6ae619db268027
a5bbb0a7129bd749d1277ea24c723e4a8e32310f
v1.0
instruct
Taco
Taco_60383_I
- You have been provided with a grid filled with numbers. Your task is to write a function `find_largest_sum(grid)` that finds the greatest sum of any contiguous subgrid within the given grid. A subgrid is defined as a rectangular section of the grid. Given a grid as follows: ``` grid = [ [1, 2, -1, -4, -20], ...
def find_largest_sum(grid): """ Finds the greatest sum of any contiguous subgrid within the given grid. Uses dynamic programming approach similar to Kadane's algorithm for 2D arrays. """ if not grid or not grid[0]: return 0 rows, cols = len(grid), len(grid[0]) max_sum = float('-inf'...
from solution import find_largest_sum def test_find_largest_sum_basic(): grid = [ [1, 2, -1, -4, -20], [-8, -3, 4, 2, 1], [3, 8, 10, 1, 3], [-4, -1, 1, 7, -6] ] assert find_largest_sum(grid) == 29 def test_find_largest_sum_single_element(): grid = [ [1] ] ...
[ { "docstring": "Finds the greatest sum of any contiguous subgrid within the given grid.\nUses dynamic programming approach similar to Kadane's algorithm for 2D arrays.", "function_declaration": "def find_largest_sum(grid):", "function_name": "find_largest_sum", "parameter_list": "(grid)" }, { ...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def kadane(arr):\n \"\"\"\n Helper function to find the maximum sum of any contiguous subarray in a 1D array.\n \"\"\"\n max_sum = current_sum = arr[0]...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00060383", "row_id": 60383, "seed_ids": "[14843]" }
0.719192
Taco_60383
I
[ "find_largest_sum", "kadane" ]
2
[ [ "find_largest_sum", "kadane" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9a7fc323dcba2f33eaed8379283ba8fbe337f9e4
2b74593a93133998914f795dc391cd9ae9ca97b5
v1.0
instruct
Taco
Taco_60385_I
FurniCo is a company that sells handcrafted furniture. They receive orders for some pieces of furniture which need to be made from specific wood planks available in their inventory. Each piece of furniture is made from one or more types of wood, and each piece must use exactly the specified amount of each type of wood....
def parse_input(data): lines = data.strip().split('\n') index = 0 result = [] while index < len(lines): I, J = map(int, lines[index].split()) if I == 0 and J == 0: break index += 1 inventory = [] for i in range(I): wi, li = map(int...
def test_parse_input(): data = "3 2\n1 500\n2 1000\n3 300\n5 1 100\n3 2 250\n0 0" expected_output = [ ([(1, 500), (2, 1000), (3, 300)], [(5, 1, 100), (3, 2, 250)]) ] assert parse_input(data) == expected_output def test_compute_planks(): inventory = [(1, 500), (2, 1000), (3, 300)] orders...
[ { "docstring": null, "function_declaration": "def parse_input(data):", "function_name": "parse_input", "parameter_list": "(data)" }, { "docstring": null, "function_declaration": "def compute_planks(inventory, orders):", "function_name": "compute_planks", "parameter_list": "(inven...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_wood_planks(inventory, orders):\n \"\"\"\n Given the inventory and orders, calculate the number of wood planks necessary\n to fulfill each o...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00060385", "row_id": 60385, "seed_ids": "[17039]" }
0.675627
Taco_60385
I
[ "parse_input", "compute_planks", "get_wood_planks", "format_output" ]
4
[ [ "get_wood_planks", "compute_planks" ], [ "get_wood_planks", "parse_input" ] ]
2
[ "parse_input", "format_output" ]
false
[]
false
pytest
false
[]
true
541280157ad1472f203cbfb963cd6c769d14c8b0
e169ac5afedd95029b6e3074b683d1b0168f524e
v1.0
instruct
Taco
Taco_60476_I
You are managing a relay race track, where N runners are numbered 1 through N and arranged in a circle. The runners are initially positioned at coordinates on the track denoted by an array a, where a[i] is the starting position of the i-th runner, and all ai are distinct integers such that 1 ≤ a[i] ≤ K. The track can b...
import math from functools import reduce def gcd(a, b): while b: a, b = b, a % b return a def lcm(x, y): return x * y // gcd(x, y) def min_rounds_return_to_initial(N, K, positions): def steps_to_return(pos, K): # Since it's a circle, if pos is at a[i] it should return after K steps. ...
def test_case_1(): assert min_rounds_return_to_initial(3, 5, [1, 3, 5]) == 5 def test_case_2(): assert min_rounds_return_to_initial(4, 6, [2, 4, 6, 1]) == 6 def test_case_3(): assert min_rounds_return_to_initial(5, 7, [1, 2, 3, 4, 5]) == 7 def test_case_4(): assert min_rounds_return_to_initial(4, 12,...
[ { "docstring": null, "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def lcm(x, y):", "function_name": "lcm", "parameter_list": "(x, y)" }, { "docstring": null, "function_dec...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom functools import reduce\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(x, y):\n return x * y // gcd(x, y)\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00060476", "row_id": 60476, "seed_ids": "[16897]" }
0.617916
Taco_60476
I
[ "gcd", "lcm", "min_rounds_return_to_initial", "main" ]
4
[ [ "lcm", "gcd" ], [ "min_rounds_return_to_initial", "lcm" ] ]
2
[]
false
[]
false
pytest
false
[]
true
d4ba7970c9835202027f207d0be5ec1d567654f3
85888ee35bcff94fda6ef7e7c178e37da8958790
v1.0
instruct
Taco
Taco_60480_I
A wealthy eccentric has decided to build an elaborate network of bridges in his grand estate. He has $n$ wooden planks available and wants to use them to construct $k$ identical bridges. Each bridge is made up of exactly $m$ planks. The eccentric wants to use all $n$ planks and ensure the bridges are identical. Your t...
def find_possible_k_m_pairs(n): """ Given an integer n, this function returns all pairs (k, m) such that k * m = n. If no such pairs exist, it returns an empty list. """ pairs = [] for k in range(1, int(n**0.5) + 1): if n % k == 0: pairs.append((k, n // k)) if k !...
from solution import find_possible_k_m_pairs, solve def test_find_possible_k_m_pairs_with_12(): assert find_possible_k_m_pairs(12) == [(1, 12), (2, 6), (3, 4), (4, 3), (6, 2), (12, 1)] def test_find_possible_k_m_pairs_with_15(): assert find_possible_k_m_pairs(15) == [(1, 15), (3, 5), (5, 3), (15, 1)] def tes...
[ { "docstring": "Given an integer n, this function returns all pairs (k, m) such that k * m = n.\nIf no such pairs exist, it returns an empty list.", "function_declaration": "def find_possible_k_m_pairs(n):", "function_name": "find_possible_k_m_pairs", "parameter_list": "(n)" }, { "docstring"...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_bridge_pairs(t, cases):\n \"\"\"\n Find all possible pairs (k, m) such that k * m = n for a given number of planks n.\n \n Parameters:\n t ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00060480", "row_id": 60480, "seed_ids": "[16902]" }
0.683075
Taco_60480
I
[ "find_possible_k_m_pairs", "solve" ]
2
[ [ "solve", "find_possible_k_m_pairs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
229bf8031c2c0fbcfecf7fdd32861c609538d9ae
2c2331511756a603ee5e45fa8d6da05b6ffc82ef
v1.0
instruct
Taco
Taco_60500_I
You have been hired to design the control system for an autonomous vacuum cleaner, RoboVac, that operates in a rectangular room. RoboVac moves in straight lines and changes direction only when it encounters an obstacle or the boundary of the room. The room may contain multiple stationary obstacles placed at fixed posit...
def robovac_path(w, h, n, obstacles): """ Given the dimensions of the room, the number of obstacles and their positions, this function returns the path taken by the RoboVac. Args: w (int): Width of the room. h (int): Height of the room. n (int): Number of obstacles. obstacles (list of t...
def test_robovac_path_no_obstacles(): w, h = 4, 3 n = 0 obstacles = [] result = robovac_path(w, h, n, obstacles) expected = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (4, 1), (4, 2), (4, 3), (3, 3), (2, 3), (1, 3), (0, 3), (0, 2), (0, 1)] for i in range(len(expected)): assert result[i] == ...
[ { "docstring": "Given the dimensions of the room, the number of obstacles and their positions,\nthis function returns the path taken by the RoboVac.\n\nArgs:\nw (int): Width of the room.\nh (int): Height of the room.\nn (int): Number of obstacles.\nobstacles (list of tuples): List containing the coordinates of ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def clean_room(w, h, n, obstacles):\n directions = [(1, 0), (0, 1), (-1, 0), (0, -1)] # right, up, left, down\n obstacles_set = set(obstacles)\n x, y = 0...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00060500", "row_id": 60500, "seed_ids": "[12580]" }
0.621737
Taco_60500
I
[ "robovac_path", "print_robovac_path" ]
2
[ [ "print_robovac_path", "robovac_path" ] ]
1
[]
false
[]
false
pytest
false
[]
true
a9ae80d51df58653f0196215dc96907a673d1ce0
e36a24219372ba9194bb18b4901ecf9c4a3c4699
v1.0
instruct
Taco
Taco_60512_I
In a small village, there are n houses connected by m roads. Each road connects exactly two houses bidirectionally and has a certain length. The houses and roads form a connected graph. The village head has decided to celebrate the village's anniversary by decorating the houses and roads with lights. However, she want...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yr...
from solution import main def test_single_case(): input_str = "1\n4 5\n1 2 3\n2 3 4\n3 4 5\n4 1 2\n1 3 7\n" output_str = "9" assert main(input_str) == output_str def test_multiple_cases(): input_str = "3\n4 5\n1 2 3\n2 3 4\n3 4 5\n4 1 2\n1 3 7\n5 7\n1 2 1\n2 3 2\n3 4 3\n4 5 4\n1 5 5\n1 3 6\n2 4 7\n3 3...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\n\ndef union(parent, rank, x, y):\n root_x =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00060512", "row_id": 60512, "seed_ids": "[4871]" }
0.717003
Taco_60512
I
[ "find", "union", "kruskal_minimum_spanning_tree", "minimum_roads_to_decorate", "process_input", "main" ]
6
[ [ "kruskal_minimum_spanning_tree", "find" ], [ "kruskal_minimum_spanning_tree", "union" ], [ "minimum_roads_to_decorate", "kruskal_minimum_spanning_tree" ], [ "union", "find" ] ]
4
[ "process_input" ]
false
[]
false
pytest
true
[]
true
d3809e78a1070f20f1275dc07002a48c3fecf96a
af389b2e146256c511fceaec0050faad933ed69f
v1.0
instruct
Taco
Taco_60635_I
A company has decided to revamp its internal communication platform and make some changes to its chat system. The system consists of multiple chat rooms, each identified by an integer id. Employees can join multiple chat rooms and each chat room tracks activity based on the last active timestamp of any user in that roo...
def earliest_chat_room(chat_rooms): """ Returns the chat room id with the earliest last active timestamp. In case of ties, returns the smallest chat room id among the tied ones. Args: chat_rooms (list of tuples): a list where each tuple contains two integers, ci...
import pytest from solution import find_earliest_chat_room def test_single_chat_room(): assert find_earliest_chat_room(1, [(101, 1610000000)]) == 101 def test_multiple_chat_rooms(): assert find_earliest_chat_room(3, [(101, 1610000000), (102, 1610005000), (103, 1609999999)]) == 103 def test_tie_on_timestamp()...
[ { "docstring": "Returns the chat room id with the earliest last active timestamp.\nIn case of ties, returns the smallest chat room id among the tied ones.\n\nArgs:\nchat_rooms (list of tuples): a list where each tuple contains two integers,\n ci (chat room id) and ti (last active tim...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_earliest_chat_room(rooms):\n \"\"\"\n Finds the chat room with the earliest last active timestamp.\n \n Parameters:\n rooms (list of tuple)...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00060635", "row_id": 60635, "seed_ids": "[576]" }
0.591663
Taco_60635
I
[ "earliest_chat_room", "find_earliest_chat_room" ]
2
[ [ "find_earliest_chat_room", "earliest_chat_room" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a91c92585b51479333814f52899595c30a732b9d
11a8c8bf231e2a1bf8675cf011ea5f0389640386
v1.0
instruct
Taco
Taco_60658_I
In a fantasy land, there are n cities connected by m two-way roads. Each road connects two different cities and has a certain length in miles. The king of this land arranges a grand festival in one of the cities and wants citizens from all other cities to travel to the festival city with the least distance traveled. ...
import heapq from collections import defaultdict def dijkstra(n, graph, start): """ Perform Dijkstra's algorithm to find shortest paths from a start node. """ distances = [float('inf')] * n distances[start] = 0 pq = [(0, start)] heapq.heapify(pq) while pq: current_distance, current...
def test_example1(): n, m, d = 4, 5, 6 roads = [(1, 2, 2), (2, 3, 2), (3, 4, 2), (4, 1, 2), (1, 3, 6)] queries = [(1, 3), (1, 4), (2, 4)] expected = [4, 2, 4] assert find_shortest_paths(n, m, d, roads, queries) == expected def test_example2(): n, m, d = 3, 2, 3 roads = [(1, 2, 2), (2, 3, 2)...
[ { "docstring": "Perform Dijkstra's algorithm to find shortest paths from a start node. ", "function_declaration": "def dijkstra(n, graph, start):", "function_name": "dijkstra", "parameter_list": "(n, graph, start)" }, { "docstring": null, "function_declaration": "def find_shortest_paths(...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef shortest_path_within_limit(n, m, d, roads, queries):\n graph = {i: [] for i in range(1, n + 1)}\n for u, v, l in roads:\n graph[u]...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00060658", "row_id": 60658, "seed_ids": "[1353]" }
0.814606
Taco_60658
I
[ "dijkstra", "find_shortest_paths" ]
2
[ [ "find_shortest_paths", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
720702fc73bddb1576f3eca65fbb9026ce39c597
adc97ee3ae32561308b74e21d1832a29162871eb
v1.0
instruct
Taco
Taco_60661_I
Alex is learning about data structures and especially interested in binary trees. After studying the theory, he decided to implement binary search trees (BST) and test their properties. A binary search tree is a binary tree where each node has a key greater than all the keys in its left subtree and less than or equal t...
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def insert(root, key): if root is None: return TreeNode(key) if key < root.val: root.left = insert(root.left, key) else: root.right = insert(root.right, key) ...
from solution import calculate_sums def test_single_element(): assert calculate_sums([(1, [1])]) == [1] def test_multiple_elements_linear(): assert calculate_sums([(5, [10, 20, 30, 40, 50])]) == [150] def test_multiple_elements_bst(): assert calculate_sums([(3, [5, 3, 8])]) == [16] def test_empty(): ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, key):\n self.left = None\n self.right = None\n self.val = key\n\ndef insert(root, key):\n if root i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00060661", "row_id": 60661, "seed_ids": "[16830]" }
0.592448
Taco_60661
I
[ "insert", "sum_bst", "calculate_sums" ]
3
[ [ "calculate_sums", "insert" ], [ "calculate_sums", "sum_bst" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
dbe411c3188c50e71d188499305e3630ae7dc608
e64a972ac9bb9feaa8632fa09aa22e06bdfb90ea
v1.0
instruct
Taco
Taco_60676_I
Design a function that checks if a given integer number can be expressed as the sum of two prime numbers. Input An integer number n (1 ≤ n ≤ 10^9). Output Print "YES" if n can be expressed as the sum of two prime numbers. Otherwise, print "NO". Examples Input 34 Output YES Input 17 Output NO
def is_prime(num): """ Helper function to check if a number is a prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def...
from solution import can_be_expressed_as_sum_of_two_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False def test_expressed_as_sum_of_two_primes_yes(): assert can_be_expr...
[ { "docstring": "Helper function to check if a number is a prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns \"YES\" if n can be expressed as the sum of two prime numbers.\nOtherwise, returns \"NO\".", ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00060676", "row_id": 60676, "seed_ids": "[5251]" }
0.669914
Taco_60676
I
[ "is_prime", "can_be_expressed_as_sum_of_two_primes" ]
2
[ [ "can_be_expressed_as_sum_of_two_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
578e34f12bf79e56e27a7dffd39d3f75f0995efd
8c34a788abde79e36c3aa579ee85d82a6118158f
v1.0
instruct
Taco
Taco_60744_I
The school library wants to organize its books such that it’s easy to find the right book by its unique ID number. For this, they decided to sort all books using a custom sorting algorithm based on the digits of the IDs. The sorting algorithm works as follows: 1. A book ID is considered smaller if the sum of its digit...
def sum_of_digits(s): return sum(int(d) for d in s) def custom_sort_book_ids(book_ids): return sorted(book_ids, key=lambda x: (sum_of_digits(x), len(x), x)) def organize_books(T, test_cases): results = [] for i in range(T): N = test_cases[i][0] book_ids = test_cases[i][1] sorte...
from solution import organize_books def test_organize_books_case1(): T = 2 test_cases = [ (3, ["103", "002", "21"]), (4, ["123", "234", "345", "456"]) ] assert organize_books(T, test_cases) == [ "002 21 103", "123 234 345 456" ] def test_organize_books_case2(): ...
[ { "docstring": null, "function_declaration": "def sum_of_digits(s):", "function_name": "sum_of_digits", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def custom_sort_book_ids(book_ids):", "function_name": "custom_sort_book_ids", "parameter_list": "(book...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def digit_sum(x):\n return sum(int(c) for c in x)\n\ndef custom_sort(book_ids):\n return sorted(book_ids, key=lambda x: (digit_sum(x), len(x), x))\n\ndef sor...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00060744", "row_id": 60744, "seed_ids": "[11621]" }
0.694669
Taco_60744
I
[ "sum_of_digits", "custom_sort_book_ids", "organize_books" ]
3
[ [ "custom_sort_book_ids", "sum_of_digits" ], [ "organize_books", "custom_sort_book_ids" ] ]
2
[]
false
[]
false
pytest
true
[]
true
602891fb41669082f4fa7e9307f1e082c7c2d710
52ae5488259401710591dd80dda8caac656bc145
v1.0
instruct
Taco
Taco_60803_I
You are given a binary matrix of size N x M, where each cell contains either a 0 or a 1. The task is to find and return the largest rectangular sub-matrix that contains only 1s. Input Format: - The first line contains two integers N and M, representing the number of rows and columns in the matrix. - Each of the follo...
def maximalRectangle(matrix): if not matrix or not matrix[0]: return 0 N, M = len(matrix), len(matrix[0]) max_area = 0 heights = [0] * M for i in range(N): for j in range(M): heights[j] = heights[j] + 1 if matrix[i][j] == 1 else 0 max_area = max(max_area, large...
from solution import maximalRectangle def test_maximalRectangle_regular_case(): matrix = [ [1, 0, 1, 1], [1, 0, 1, 1], [1, 1, 1, 1], [1, 0, 0, 1] ] assert maximalRectangle(matrix) == 6 def test_maximalRectangle_all_zeros(): matrix = [ [0, 0, 0], [0, 0, 0...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "paramete...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximalRectangle(matrix):\n if not matrix or not matrix[0]:\n return 0\n\n N, M = len(matrix), len(matrix[0])\n max_area = 0\n heights = [0]...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00060803", "row_id": 60803, "seed_ids": "[8675]" }
0.716665
Taco_60803
I
[ "maximalRectangle", "largestRectangleArea" ]
2
[ [ "maximalRectangle", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b1856d8b19e46d04a6e3392c668eb1498e6580f7
7f686b6535240cd2d2940c0e36d6b4e7a2e26c64
v1.0
instruct
Taco
Taco_60855_I
Given a binary search tree (BST), you need to find the k-th smallest element in the BST. A binary search tree is a binary tree in which for each node: - The left subtree of a node contains only nodes with keys less than the node's key. - The right subtree of a node contains only nodes with keys greater than the node'...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def insert_into_bst(root, val): if not root: return TreeNode(val) if val < root.val: root.left = insert_into_bst(root.left, val) else: root.right = insert_into_bst(root...
import pytest from solution import TreeNode, insert_into_bst, build_bst_from_list, inorder_traversal, kth_smallest_element, process_input def test_kth_smallest_element(): # Test with given examples root = build_bst_from_list([5, 3, 8, 1, 4]) assert kth_smallest_element(root, 1) == 1 assert kth_smallest...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, key):\n self.left = None\n self.right = None\n self.val = key\n\ndef insert(root, key):\n if root i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00060855", "row_id": 60855, "seed_ids": "[22206]" }
0.555977
Taco_60855
I
[ "insert_into_bst", "build_bst_from_list", "inorder_traversal", "kth_smallest_element", "process_input" ]
5
[ [ "build_bst_from_list", "insert_into_bst" ], [ "kth_smallest_element", "inorder_traversal" ], [ "process_input", "build_bst_from_list" ], [ "process_input", "kth_smallest_element" ] ]
4
[ "process_input" ]
false
[ "TreeNode" ]
true
pytest
true
[]
true
4415a8b7820392ff1f41185e575ac2145d5c6ba5
4f0a58328fefa01e1a7dea629aab5e1544a71b4a
v1.0
instruct
Taco
Taco_60870_I
Given a positive integer N, check if it is possible to rearrange its digits to form a prime number. The resulting number must be a prime and must not have leading zeroes. Return true if and only if at least one such rearrangement exists. Example 1: Input: 13 Output: true Example 2: Input: 41 Output: true Example 3:...
from itertools import permutations def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def can_fo...
from solution import can_form_prime def test_can_form_prime_13(): assert can_form_prime(13) == True def test_can_form_prime_41(): assert can_form_prime(41) == True def test_can_form_prime_15(): assert can_form_prime(15) == False def test_can_form_prime_30(): assert can_form_prime(30) == False def t...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def can_form_prime(N):", "function_name": "can_form_prime", "parameter_list": "(N)" } ]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00060870", "row_id": 60870, "seed_ids": "[22700]" }
0.580525
Taco_60870
I
[ "is_prime", "can_form_prime" ]
2
[ [ "can_form_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f0a388e367ff727731df62e4796704912e387e31
0a81e3f74409f5daa23a233b9e0ea25f328d5de4
v1.0
instruct
Taco
Taco_61064_I
Monocarp is managing a warehouse and needs to move several items from the initial location to target locations. The warehouse is represented as a grid with dimensions n x m. Each cell in the grid is either empty or contains an item. Monocarp can move the items UP, DOWN, LEFT, or RIGHT. An item cannot move into a cell o...
def parse_input(data): lines = data.strip().split('\n') n, m = map(int, lines[0].split()) grid = [list(line) for line in lines[1:n+1]] return n, m, grid def find_positions(grid): initial_positions = {} target_positions = {} for i in range(len(grid)): for j in range(len(grid[0])): ...
def test_parse_input(): data = "5 5\nA..*.\n.....\n.....\n.*...\n...a.\n" n, m, grid = parse_input(data) assert n == 5 assert m == 5 assert grid == [['A', '.', '.', '*', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '*',...
[ { "docstring": null, "function_declaration": "def parse_input(data):", "function_name": "parse_input", "parameter_list": "(data)" }, { "docstring": null, "function_declaration": "def find_positions(grid):", "function_name": "find_positions", "parameter_list": "(grid)" }, { ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef find_path(start, end, grid, n, m):\n # Directions in the order of UP, DOWN, LEFT, RIGHT\n directions = [(-1, 0, 'UP'), (...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00061064", "row_id": 61064, "seed_ids": "[3208]" }
0.640372
Taco_61064
I
[ "parse_input", "find_positions", "generate_moves", "solve_monocarp" ]
4
[ [ "solve_monocarp", "find_positions" ], [ "solve_monocarp", "generate_moves" ], [ "solve_monocarp", "parse_input" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
73296d161e5d0d56224c5fe48a2fdd0e67aad4d5
29f793412d2f26c050663e73cccbe2242eed3442
v1.0
instruct
Taco
Taco_61140_I
You are given an integer matrix `grid` with `m` rows and `n` columns. Each element of the matrix represents a value in the grid, where `1` denotes land and `0` denotes water. The grid is completely surrounded by water. You need to count the number of distinct islands in the grid. An island is defined as a group of con...
def num_distinct_islands(grid): def dfs(x, y, direction): if x < 0 or x >= len(grid) or y < 0 or y >= len(grid[0]) or grid[x][y] != 1: return [] grid[x][y] = -1 shape.append(direction) dfs(x + 1, y, 'D') dfs(x - 1, y, 'U') dfs(x, y + 1, 'R') dfs(x,...
from solution import num_distinct_islands_from_input, read_input_to_test_cases def test_example_1(): input_str = "1\n3 3\n1 1 0\n0 1 0\n1 0 0\n" t, test_cases = read_input_to_test_cases(input_str) results = num_distinct_islands_from_input(t, test_cases) expected = [2] assert results == expected de...
[ { "docstring": null, "function_declaration": "def num_distinct_islands(grid):", "function_name": "num_distinct_islands", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def num_distinct_islands_from_input(t, test_cases):", "function_name": "num_distinct_is...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def num_distinct_islands(grid):\n def dfs(x, y, origin_x, origin_y, path):\n if x < 0 or x >= len(grid) or y < 0 or y >= len(grid[0]) or grid[x][y] == 0:...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00061140", "row_id": 61140, "seed_ids": "[11166]" }
0.671529
Taco_61140
I
[ "num_distinct_islands", "num_distinct_islands_from_input", "read_input_to_test_cases" ]
3
[ [ "num_distinct_islands_from_input", "num_distinct_islands" ] ]
1
[ "read_input_to_test_cases" ]
false
[]
false
pytest
true
[]
true
d18785b998b689d97997b1c8d0479b8ed0dbbe82
9c1b0651d57be8a025f54880f9855133f42ca2dd
v1.0
instruct
Taco
Taco_61164_I
You are given a grid with $n$ rows and $m$ columns. Each cell contains a character that is either '.' (representing an empty cell) or '*' (representing a blocked cell). You need to determine the the shortest path from the top-left corner of the grid $(1,1)$ to the bottom-right corner $(n,m)$ moving only through empty c...
from collections import deque def shortest_path_in_grid(t, test_cases): def bfs(grid, n, m): directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(0, 0, 0)]) # (row, col, distance) visited = [[False] * m for _ in range(n)] visited[0][0] = True while queue: ...
def test_shortest_path_case_1(): input_data = "2\n3 4\n....\n.*..\n....\n4 4\n*..*\n.*.*\n.*.*\n*..*" expected_output = "5\n-1" assert solution(input_data) == expected_output def test_shortest_path_case_2(): input_data = "1\n1 2\n.." expected_output = "1" assert solution(input_data) == expected...
[ { "docstring": null, "function_declaration": "def shortest_path_in_grid(t, test_cases):", "function_name": "shortest_path_in_grid", "parameter_list": "(t, test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", ...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path_in_grid(t, test_cases):\n results = []\n for case in test_cases:\n n, m, grid = case\n if gr...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00061164", "row_id": 61164, "seed_ids": "[21503]" }
0.774443
Taco_61164
I
[ "shortest_path_in_grid", "parse_input", "solution" ]
3
[ [ "solution", "parse_input" ], [ "solution", "shortest_path_in_grid" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
c5f1c4227334b398d7e89b89e42a9119aa2a842b
9af68f8c2ffa44e9c22fffca6273bab15b442523
v1.0
instruct
Taco
Taco_61169_I
Given a large network of computers, we want to perform data transfer between two computers through the shortest possible path. The network is represented as an undirected graph, where nodes denote computers and edges denote direct communication links between them. Each edge has a weight representing the time taken to t...
import heapq def dijkstra(n, edges, start, end): # Create an adjacency list adj = {i: [] for i in range(1, n + 1)} for u, v, w in edges: adj[u].append((v, w)) adj[v].append((u, w)) # Priority queue to store (weight, node) pq = [(0, start)] distances = {i: float('inf') for i...
def test_example_case(): n = 5 m = 6 edges = [ (1, 2, 2), (1, 3, 4), (2, 3, 1), (2, 4, 7), (3, 5, 3), (4, 5, 1) ] start = 1 end = 5 result = minimum_transfer_time(n, m, edges, start, end) assert result == 6 def test_no_path_case(): n =...
[ { "docstring": null, "function_declaration": "def dijkstra(n, edges, start, end):", "function_name": "dijkstra", "parameter_list": "(n, edges, start, end)" }, { "docstring": null, "function_declaration": "def minimum_transfer_time(n, m, edges, start, end):", "function_name": "minimum...
[ 0, 0, 1, 1 ]
2
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef minimum_transfer_time(n, m, edges, start, end):\n \"\"\"\n Returns the minimum transfer time between two computers using Dijkstra's Algor...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00061169", "row_id": 61169, "seed_ids": "[21057]" }
0.733468
Taco_61169
I
[ "dijkstra", "minimum_transfer_time" ]
2
[ [ "minimum_transfer_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1b0e80753dae06e99bd70e89a7f999e6518b2004
463f7b8cb579ddb7f202720849e4c565b837be6f
v1.0
instruct
Taco
Taco_61259_I
In the kingdom of Westeros, Tyrion Lannister, the clever dwarf, loves to play with numbers. He has a magical number sequence generator. The generator takes two integer inputs `N` and `K` and generates a sequence of length `N` where each element is the sum of the last `K` elements in the sequence. By default, the first ...
def generate_sequence(N, K): """ Generates a sequence of length N where each element is the sum of the last K elements in the sequence. The first K elements are all 1. :param N: Length of the sequence :param K: Number of elements to sum for generating the next element in the sequence :retur...
import pytest from solution import generate_sequence, generate_sequences, process_input def test_generate_sequence_basic(): assert generate_sequence(5, 2) == [1, 1, 2, 3, 5] assert generate_sequence(7, 3) == [1, 1, 1, 3, 5, 9, 17] def test_generate_sequence_k_equals_n(): assert generate_sequence(3, 3) == ...
[ { "docstring": "Generates a sequence of length N where each element is the sum of the last K elements in the sequence.\nThe first K elements are all 1.\n\n:param N: Length of the sequence\n:param K: Number of elements to sum for generating the next element in the sequence\n:return: The generated sequence as a l...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_sequence(N, K):\n \"\"\"\n Generates a sequence of length N where each element is the sum of the last K elements in the sequence.\n The first...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00061259", "row_id": 61259, "seed_ids": "[17484]" }
0.65222
Taco_61259
I
[ "generate_sequence", "generate_sequences", "process_input" ]
3
[ [ "generate_sequences", "generate_sequence" ], [ "process_input", "generate_sequences" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
b2eecf50cabd205e269056c15792026209a1188a
f16e5601d289de6e22664fa0fc338ee482696a6d
v1.0
instruct
Taco
Taco_61278_I
Arya is learning about prime numbers and came up with a sequence of integers. She wants to know if this sequence can be arranged into a special format. Specifically, she wants to rearrange the sequence such that all prime numbers appear first in ascending order, followed by all non-prime numbers in descending order. -...
def is_prime(num): if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def special_sort(n, sequence): primes = [num for num in sequence i...
from solution import is_prime, special_sort def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(-5) == False assert is_prime(0) == False assert is_prime(1) == Fals...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def special_sort(n, sequence):", "function_name": "special_sort", "parameter_list": "(n, sequence)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(max_number):\n is_prime = [True for _ in range(max_number+1)]\n p = 2\n while (p * p <= max_number):\n if (is_prime[p] ==...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00061278", "row_id": 61278, "seed_ids": "[25261]" }
0.614529
Taco_61278
I
[ "is_prime", "special_sort" ]
2
[ [ "special_sort", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2cdc117048a8260a29de22cd053e96dd3d9a441c
d79e7d2a336e25067feedc850cc35a881f9139d9
v1.0
instruct
Taco
Taco_61307_I
Landsville is a town with several parks, each uniquely numbered from 1 to P. Emily is responsible for managing the connectivity between these parks through pathways. A pathway can only connect two parks directly. Landsville undergoes frequent construction, so the connectivity between parks can change over time. Emily ...
from collections import defaultdict def is_connected(P, pathways): graph = defaultdict(list) for u, v in pathways: graph[u].append(v) graph[v].append(u) visited = [False] * (P + 1) def dfs(node): stack = [node] while stack: curr = stack.pop() ...
from solution import landsville_connectivity def test_landsville_sample(): t = 2 cases = [ (5, 4, [(1, 2), (2, 3), (3, 4), (4, 5)]), (4, 2, [(1, 2), (3, 4)]) ] expected = ["YES 4", "NO"] assert landsville_connectivity(t, cases) == expected def test_all_connected_with_extra_paths():...
[ { "docstring": null, "function_declaration": "def is_connected(P, pathways):", "function_name": "is_connected", "parameter_list": "(P, pathways)" }, { "docstring": null, "function_declaration": "def min_pathways_to_connect(P):", "function_name": "min_pathways_to_connect", "parame...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_connected(P, pathways):\n from collections import deque, defaultdict\n \n if P == 1:\n return True\n \n graph = defaultdict(list)\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00061307", "row_id": 61307, "seed_ids": "[6952]" }
0.678985
Taco_61307
I
[ "is_connected", "min_pathways_to_connect", "solve", "landsville_connectivity" ]
4
[ [ "landsville_connectivity", "solve" ], [ "solve", "is_connected" ], [ "solve", "min_pathways_to_connect" ] ]
3
[]
false
[]
false
pytest
true
[]
true
cac52ac05a1a37c54f3c5654de1b45937e2416be
5bcb48d0c140121e56280001f2dc11af25cfd0ba
v1.0
instruct
Taco
Taco_61325_I
Given an integer array of size N, you have to find out the sum of all elements in the array that are not prime numbers. It's guaranteed that the array size N will be between 1 and 1000, and each element in the array will be between 1 and 10000. -----Input----- The first line of input contains an integer T (1 ≤ T ≤ 100...
def is_prime(n): """ Returns True if the number n is prime, otherwise False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import is_prime, sum_of_non_prime_numbers, process_test_cases def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False...
[ { "docstring": "Returns True if the number n is prime, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of non-prime numbers in the array.", "function_declaration": "def sum_of_non_prime...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n This function checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00061325", "row_id": 61325, "seed_ids": "[1770]" }
0.644244
Taco_61325
I
[ "is_prime", "sum_of_non_prime_numbers", "process_test_cases" ]
3
[ [ "process_test_cases", "sum_of_non_prime_numbers" ], [ "sum_of_non_prime_numbers", "is_prime" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
222acb1b3ab6de0b8344754acf247567149a43bb
47c0aadfcd6f7a1c560b90d930810caaab9564a9
v1.0
instruct
Taco
Taco_61360_I
Maria is preparing for a coding competition and she practices by solving various types of problems. One day, she encounters a problem about sorting arrays. The problem is related to the uniqueness and frequency of array elements after sorting them. She finds it interesting and decides to challenge her friends with a si...
def unique_elements_and_frequencies(test_cases): results = [] for case in test_cases: N, array = case sorted_array = sorted(array) frequencies = {} for num in sorted_array: if num in frequencies: frequencies[num] += 1 else: ...
def test_unique_elements_and_frequencies(): input_data = "2\n5\n4 5 4 2 2\n6\n1 1 1 1 1 1" expected_output = "3\n2 2 1\n1\n6" assert solve_problem(input_data) == expected_output def test_single_element_array(): input_data = "1\n1\n10" expected_output = "1\n1" assert solve_problem(input_data) ==...
[ { "docstring": null, "function_declaration": "def unique_elements_and_frequencies(test_cases):", "function_name": "unique_elements_and_frequencies", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def process_input(input_data):", "function_name": "pr...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef unique_elements_and_frequencies(test_cases):\n results = []\n for case in test_cases:\n N, arr = case\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00061360", "row_id": 61360, "seed_ids": "[3218]" }
0.679178
Taco_61360
I
[ "unique_elements_and_frequencies", "process_input", "format_output", "solve_problem" ]
4
[ [ "solve_problem", "format_output" ], [ "solve_problem", "process_input" ], [ "solve_problem", "unique_elements_and_frequencies" ] ]
3
[ "process_input", "format_output" ]
false
[]
false
pytest
false
[]
true
dbb14a69480bac8eca60c1abfff27410f298c520
4b0b87446a5972b65f2d84e24509e37f61287f09
v1.0
instruct
Taco
Taco_61390_I
In a small town, there is a network of roads connecting various houses. The town consists of n houses, numbered from 1 to n, and m roads, each connecting two houses bidirectionally. Each road has a positive integer weight representing the time it takes to travel between the two houses. Residents complain about the trav...
import heapq def dijkstra(n, graph, source): dist = [float('inf')] * (n + 1) dist[source] = 0 pq = [(0, source)] while pq: current_distance, u = heapq.heappop(pq) if current_distance > dist[u]: continue for v, weight in graph[u]: di...
def test_example_1(): n, m = 4, 4 roads = [ (1, 2, 4), (2, 3, 3), (3, 4, 2), (1, 4, 10) ] k = 3 critical_pairs = [ (1, 3), (2, 4), (1, 4) ] expected = [7, 5, 9] assert shortest_travel_time(n, m, roads, k, critical_pairs) == expected...
[ { "docstring": null, "function_declaration": "def dijkstra(n, graph, source):", "function_name": "dijkstra", "parameter_list": "(n, graph, source)" }, { "docstring": null, "function_declaration": "def shortest_travel_time(n, m, roads, k, critical_pairs):", "function_name": "shortest_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, adj, src):\n dist = [float(\"inf\")] * (n + 1)\n dist[src] = 0\n pq = [(0, src)] # (distance, node)\n \n while pq:\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00061390", "row_id": 61390, "seed_ids": "[32]" }
0.74134
Taco_61390
I
[ "dijkstra", "shortest_travel_time" ]
2
[ [ "shortest_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
fc97ff63ab495af3e72b77ceabfee430fb9d0f9c
c79ce54453f673b098dce15781732a503b6b6940
v1.0
instruct
Taco
Taco_61413_I
You are working as an engineer for a company that designs and implements advanced sorting algorithms. Your team has come up with a hybrid sorting algorithm named HybridSort, which combines the properties of QuickSort and InsertionSort. Your task is to implement this HybridSort algorithm. HybridSort works as follows: ...
def hybrid_sort(arr, T): """ Sorts the array `arr` using the HybridSort algorithm. Parameters: arr (list): The array to be sorted. T (int): The threshold value to decide between QuickSort and InsertionSort. Returns: list: The sorted array. """ if len(arr) <= T: retu...
from solution import hybrid_sort, quick_sort, insertion_sort def test_hybrid_sort(): assert hybrid_sort([12, 4, 5, 6, 7, 3, 1, 15], 4) == [1, 3, 4, 5, 6, 7, 12, 15] assert hybrid_sort([4, 3, 2, 10, 12, 1, 5, 6], 3) == [1, 2, 3, 4, 5, 6, 10, 12] def test_quick_sort(): assert quick_sort([3, 6, 8, 10, 1, 2, ...
[ { "docstring": "Sorts the array `arr` using the HybridSort algorithm.\n\nParameters:\narr (list): The array to be sorted.\nT (int): The threshold value to decide between QuickSort and InsertionSort.\n\nReturns:\nlist: The sorted array.", "function_declaration": "def hybrid_sort(arr, T):", "function_name...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def hybrid_sort(arr, T):\n \"\"\"\n Sorts the array `arr` using the HybridSort algorithm.\n \n Parameters:\n arr (list): The array to be sorted.\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00061413", "row_id": 61413, "seed_ids": "[18182]" }
0.527052
Taco_61413
I
[ "hybrid_sort", "quick_sort", "insertion_sort" ]
3
[ [ "hybrid_sort", "insertion_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4091238e585cfaf4780c709395d8564a082158b0
8bb19b907f52f020813bdf9157294df182c3102e
v1.0
instruct
Taco
Taco_61422_I
Alex is a software engineer who loves bitwise operations. He recently encountered a problem that he couldn't solve, and he needs your help. Problem is: Given an array of integers, find the maximum product of any two distinct elements in the array using only bitwise operations. For example: Given the array [4, 7, 2, ...
def max_product_bitwise(arr): """ Returns the maximum product of any two distinct elements in the array using bitwise operations. """ # Initialize first and second largest elements first_largest = second_largest = 0 for num in arr: if num > first_largest: second_largest ...
def test_max_product_bitwise(): input_string = "2\n5\n4 7 2 8 1\n3\n3 6 9\n" expected_output = "56\n54" assert process_input(input_string) == expected_output def test_max_product_bitwise_single_case(): input_string = "1\n4\n1 2 3 4\n" expected_output = "12" assert process_input(input_string) ==...
[ { "docstring": "Returns the maximum product of any two distinct elements in the array using bitwise operations.", "function_declaration": "def max_product_bitwise(arr):", "function_name": "max_product_bitwise", "parameter_list": "(arr)" }, { "docstring": "Processes multiple test cases and re...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_product_bitwise(arr):\n \"\"\"\n Returns the maximum product of any two distinct elements in the array using bitwise operations.\n \"\"\"\n # I...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00061422", "row_id": 61422, "seed_ids": "[7872]" }
0.726978
Taco_61422
I
[ "max_product_bitwise", "solve", "parse_input", "process_input" ]
4
[ [ "process_input", "parse_input" ], [ "process_input", "solve" ], [ "solve", "max_product_bitwise" ] ]
3
[ "parse_input", "process_input" ]
false
[]
false
pytest
false
[]
true
91ddedb5a35c4668f4db298fd2fc9bbf293f8207
2007e0462ac46cce49d4a1b719e7b0ab25426627
v1.0
instruct
Taco
Taco_61453_I
Palindrome Decomposition A **palindrome** is a string that reads the same backward as forward (e.g., "madam", "racecar"). Given a string, its **palindrome decomposition** is a way of breaking the string into contiguous substrings such that each substring is a palindrome. Your objective is to find all possible palindro...
def is_palindrome(s): """ Check if a given string s is a palindrome. """ return s == s[::-1] def palindrome_decomposition(s): """ Find all possible palindrome decompositions of a given string s. The function returns a list of lists, where each list represents a decomposition. """ de...
from solution import decompose_string def test_aab(): result = decompose_string("aab") expected_result = [['a', 'a', 'b'], ['aa', 'b']] assert sorted(result) == sorted(expected_result) def test_racecar(): result = decompose_string("racecar") expected_result = [['r', 'a', 'c', 'e', 'c', 'a', 'r'], ...
[ { "docstring": "Check if a given string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Find all possible palindrome decompositions of a given string s.\nThe function returns a list of lists, w...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Checks if a given string s is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef palindrome_decompositions(s):\n \...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00061453", "row_id": 61453, "seed_ids": "[405]" }
0.6722
Taco_61453
I
[ "is_palindrome", "palindrome_decomposition", "decompose_string" ]
3
[ [ "decompose_string", "palindrome_decomposition" ], [ "palindrome_decomposition", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c507b21da17d3b39e6436923a7abbf5adb8b3f41
06c09aefed0c23f49cf68ffddf7eb17b2ec98472
v1.0
instruct
Taco
Taco_61505_I
You are given an array of integers and multiple queries. Each query consists of two integers, $l$ and $r$. The task is to compute and print the sum of elements from index $l$ to index $r$ (inclusive) for each query. The array is 0-indexed. Constraints * $1 \leq n \leq 100,000$ * $1 \leq q \leq 100,000$ * $1 \leq a_i...
def preprocess_array(arr): """ Preprocess the array to create a prefix sum array. """ n = len(arr) prefix_sum = [0] * (n + 1) for i in range(n): prefix_sum[i + 1] = prefix_sum[i] + arr[i] return prefix_sum def range_sum(prefix_sum, l, r): """ Compute the sum of elements from...
from solution import preprocess_array, range_sum, answer_queries def test_preprocess_array(): arr = [1, 2, 3, 4, 5] result = preprocess_array(arr) expected = [0, 1, 3, 6, 10, 15] assert result == expected def test_range_sum(): prefix_sum = [0, 1, 3, 6, 10, 15] assert range_sum(prefix_sum, 0, 1...
[ { "docstring": "Preprocess the array to create a prefix sum array.", "function_declaration": "def preprocess_array(arr):", "function_name": "preprocess_array", "parameter_list": "(arr)" }, { "docstring": "Compute the sum of elements from index l to index r using the prefix sum array.", "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_elements(n, q, array, queries):\n \"\"\"\n Computes the sum of elements from index l to r for each query.\n\n Parameters:\n n (int): Size of...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00061505", "row_id": 61505, "seed_ids": "[14449]" }
0.70573
Taco_61505
I
[ "preprocess_array", "range_sum", "answer_queries" ]
3
[ [ "answer_queries", "preprocess_array" ], [ "answer_queries", "range_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e25073b7a513158d5f564cdbfb965a6bd2b968ed
93210ad8b69eced50b3a047a8c3638aee25ef23d
v1.0
instruct
Taco
Taco_61585_I
Problem Statement: You are tasked with implementing a simple language detector for a text processing system. The system processes a stream of character strings. You need to determine if a string is written in English or not. For simplicity, assume that a string is in English if it contains only the letters 'a' through ...
def detect_language(word): """ Returns whether the word is in English or not. """ if all('a' <= char <= 'z' or 'A' <= char <= 'Z' for char in word): return "English" return "Not English" def process_stream(stream): """ Processes a stream of words and outputs "English" or "Not Englis...
from solution import detect_language, process_stream def test_detect_language_english(): assert detect_language("hello") == "English" assert detect_language("world") == "English" assert detect_language("HELLO") == "English" assert detect_language("WoRLd") == "English" def test_detect_language_non_engl...
[ { "docstring": "Returns whether the word is in English or not.", "function_declaration": "def detect_language(word):", "function_name": "detect_language", "parameter_list": "(word)" }, { "docstring": "Processes a stream of words and outputs \"English\" or \"Not English\"\nfor each word until...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef detect_language(stream):\n \"\"\"\n Detect if each word in the stream is English or not.\n A word is considered English if it contains on...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00061585", "row_id": 61585, "seed_ids": "[8309]" }
0.565217
Taco_61585
I
[ "detect_language", "process_stream" ]
2
[ [ "process_stream", "detect_language" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ece156a5448ad4ee0ea86360e662df45764cddbf
7f82dfb18364c3e54dafebdb8ef08e4af6a521b5
v1.0
instruct
Taco
Taco_61593_I
A famous bakery chain is expanding its reach and opening a specific number of new bakeries across various towns in a new region. The towns are interconnected by a set of roads such that there is always a path from any town to any other town. The bakery chain wants to minimize the maximum distance any resident has to tr...
from collections import deque def find_max_distance_from_bakeries(n, bakeries, roads): def bfs(start): visited = [-1] * n queue = deque([(start, 0)]) visited[start] = 0 while queue: node, dist = queue.popleft() for neighbor in graph[node]: if ...
from solution import optimal_bakery_placement def test_example_1(): assert optimal_bakery_placement(5, 2, [(1, 2), (1, 3), (3, 4), (3, 5)]) == 1 def test_example_2(): assert optimal_bakery_placement(6, 1, [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6)]) == 3 def test_standard_case(): assert optimal_bakery_place...
[ { "docstring": null, "function_declaration": "def find_max_distance_from_bakeries(n, bakeries, roads):", "function_name": "find_max_distance_from_bakeries", "parameter_list": "(n, bakeries, roads)" }, { "docstring": null, "function_declaration": "def optimal_bakery_placement(N, M, roads_...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef bfs_farthest_distance_from_any_node(graph, n):\n \"\"\"Finds the farthest distance from any node in the graph.\"\"\"\n \...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00061593", "row_id": 61593, "seed_ids": "[9687]" }
0.703312
Taco_61593
I
[ "find_max_distance_from_bakeries", "optimal_bakery_placement" ]
2
[ [ "optimal_bakery_placement", "find_max_distance_from_bakeries" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3e3ccc5d3716a8053c5a580fa8053f37ddb07613
110bc7cd2e23ec06b4735857c9b6799aa8489ac6
v1.0
instruct
Taco
Taco_61648_I
Palindromania is a small town that celebrates palindromes with great enthusiasm. A string is called a palindrome if it reads the same backward as forward. One fascinating game in Palindromania involves substrings of a given string. Given a string, the task is to determine the length of the longest substring that forms ...
def longest_palindromic_substring_length(s): """ Returns the length of the longest palindromic substring in the given string s. """ n = len(s) if n == 0: return 0 # Initialize a table to store lengths of palindromic substrings dp = [[0] * n for _ in range(n)] max_length...
from solution import longest_palindromic_substring_length_from_input def test_longest_palindromic_substring_length_1(): assert longest_palindromic_substring_length_from_input(7, "racecar") == 7 def test_longest_palindromic_substring_length_2(): assert longest_palindromic_substring_length_from_input(8, "abcdef...
[ { "docstring": "Returns the length of the longest palindromic substring in the given string s.", "function_declaration": "def longest_palindromic_substring_length(s):", "function_name": "longest_palindromic_substring_length", "parameter_list": "(s)" }, { "docstring": null, "function_decl...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_palindromic_substring(n, s):\n \"\"\"\n Returns the length of the longest palindromic substring in the given string.\n \n Args:\n n : in...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00061648", "row_id": 61648, "seed_ids": "[24138]" }
0.782656
Taco_61648
I
[ "longest_palindromic_substring_length", "longest_palindromic_substring_length_from_input" ]
2
[ [ "longest_palindromic_substring_length_from_input", "longest_palindromic_substring_length" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1c432169369bbba2bba49f15816a25e9cbb7d3cb
4f5d5527dbad3fe811f6bcc4bfcac5b33995299b
v1.0
instruct
Taco
Taco_61653_I
You are given a list of strings, where each string represents a mathematical expression containing positive integers and the operators `+`, `-`, `*`, `/`. Check if each expression is mathematically valid, which means it contains proper operations between integers, and there is no division by zero. Return a list of resu...
def is_valid_expression(expression): """ Checks if a mathematical expression is valid. Returns 'Valid', 'Invalid', or 'Division by zero'. """ operators = set('+-*/') try: prev_char = None for char in expression: if char not in '0123456789' and char not in operators: ...
import pytest from solution import check_expressions def test_valid_expressions(): assert check_expressions(["3+5", "10-2*3", "7/2", "14/2", "9+3-4", "6*7/8"]) == ["Valid", "Valid", "Valid", "Valid", "Valid", "Valid"] def test_invalid_expressions(): assert check_expressions(["5+*7", "5//2", "*/2", "a+3", "3a+...
[ { "docstring": "Checks if a mathematical expression is valid.\nReturns 'Valid', 'Invalid', or 'Division by zero'.", "function_declaration": "def is_valid_expression(expression):", "function_name": "is_valid_expression", "parameter_list": "(expression)" }, { "docstring": "Checks a list of mat...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef validate_expression(expression):\n \"\"\"\n Validates a mathematical expression.\n \n Args:\n expression (str): The mathematical ex...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00061653", "row_id": 61653, "seed_ids": "[21415]" }
0.608534
Taco_61653
I
[ "is_valid_expression", "check_expressions" ]
2
[ [ "check_expressions", "is_valid_expression" ] ]
1
[]
false
[]
false
pytest
true
[]
true
545421441d82761b57dbac8c41509847c0fa790b
3bede8a8b257ce8b361c74b0f584082cc6ef212b
v1.0
instruct
Taco
Taco_61681_I
Alice and Bob are collaboratively developing a new language called AlphaLang, which heavily relies on the manipulation of lists of integers. In AlphaLang, there are pre-defined functions that perform various operations on these integer lists. These functions include: - repeat(x,n): Creates a new list by repeating the ...
import re import ast def repeat(lst, n): return lst * n def merge(lst1, lst2): merged = [] i = 0 while i < len(lst1) and i < len(lst2): merged.append(lst1[i]) merged.append(lst2[i]) i += 1 if i < len(lst1): merged.extend(lst1[i:]) if i < len(lst2): merge...
import pytest from solution import evaluate_alpha_lang def test_repeat(): assert evaluate_alpha_lang("repeat([1, 2], 3)") == [1, 2, 1, 2, 1, 2] assert evaluate_alpha_lang("repeat([0], 5)") == [0, 0, 0, 0, 0] assert evaluate_alpha_lang("repeat([], 10)") == [] def test_merge(): assert evaluate_alpha_lan...
[ { "docstring": null, "function_declaration": "def repeat(lst, n):", "function_name": "repeat", "parameter_list": "(lst, n)" }, { "docstring": null, "function_declaration": "def merge(lst1, lst2):", "function_name": "merge", "parameter_list": "(lst1, lst2)" }, { "docstring...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef repeat(x, n):\n return x * n\n\ndef merge(x, y):\n result = []\n len_x, len_y = len(x), len(y)\n for i in range(max(len_x, len_y)):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00061681", "row_id": 61681, "seed_ids": "[20270]" }
0.605027
Taco_61681
I
[ "repeat", "merge", "slice", "evaluate_alpha_lang" ]
4
[ [ "evaluate_alpha_lang", "merge" ], [ "evaluate_alpha_lang", "repeat" ], [ "evaluate_alpha_lang", "slice" ] ]
3
[]
false
[]
false
pytest
true
[]
true
90c20b1914007b26351913ae2e9dda1ab60412c5
67542497a6ca8f83b6cb182798c6ec6ec5b146c4
v1.0
instruct
Taco
Taco_61690_I
A transportation company needs to track the movement of their fleet of vehicles across multiple depots. Each vehicle can move from one depot to another in a specified order. All movements are logged and operations managers need a tool to extract specific data about vehicle movements. You need to write a program to ha...
from collections import defaultdict from datetime import datetime def parse_log_entries(n, log_entries): """ Parse log_entries into a dictionary grouped by depot number with each value being a list of dates (in string format). """ depot_movements = defaultdict(list) for log in log_entries: ...
from solution import handle_queries, extract_input def test_handle_queries(): input_data = """5 3 1 2023-01-01 2 2023-01-02 1 2023-01-03 3 2023-01-02 1 2023-01-04 1 2023-01-01 2023-01-04 ...
[ { "docstring": "Parse log_entries into a dictionary grouped by depot number with \neach value being a list of dates (in string format).", "function_declaration": "def parse_log_entries(n, log_entries):", "function_name": "parse_log_entries", "parameter_list": "(n, log_entries)" }, { "docstri...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_vehicles_in_depot_range(n, q, movements, queries):\n \"\"\"\n Returns the number of unique vehicles that have visited the specified depot within th...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00061690", "row_id": 61690, "seed_ids": "[2914]" }
0.657663
Taco_61690
I
[ "parse_log_entries", "count_vehicles", "handle_queries", "extract_input" ]
4
[ [ "handle_queries", "count_vehicles" ], [ "handle_queries", "parse_log_entries" ] ]
2
[ "handle_queries" ]
false
[]
false
pytest
true
[]
true
f4ea8ab214d03ebe5322a4bb6e453fa0a678c1ef
b2cba2ff73ce6d82bd044f8dc27a34a11292895a
v1.0
instruct
Taco
Taco_61708_I
A famous game developer has designed a new game called "Island Hopper". In this game, players start on an island located at point (sx, sy) and need to reach a target island located at (tx, ty) on a 2-D coordinate plane. There are several teleportation points on the plane that can help players reach their destination fa...
from collections import deque def min_time_to_target(sx, sy, tx, ty, teleport_points): def bfs(): queue = deque([(sx, sy, 0)]) visited = set() visited.add((sx, sy)) while queue: x, y, time = queue.popleft() if (x, y) == (tx, ty): ...
from solution import island_hopper def test_island_hopper_example(): assert island_hopper(0, 0, 10, 10, 3, ["1 1 8 8", "2 2 3 3", "6 6 10 5"]) == 6 def test_island_hopper_no_teleportations(): assert island_hopper(0, 0, 5, 5, 0, []) == 10 def test_island_hopper_direct_teleport(): assert island_hopper(...
[ { "docstring": null, "function_declaration": "def min_time_to_target(sx, sy, tx, ty, teleport_points):", "function_name": "min_time_to_target", "parameter_list": "(sx, sy, tx, ty, teleport_points)" }, { "docstring": null, "function_declaration": "def island_hopper(sx, sy, tx, ty, n, tele...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from heapq import heappop, heappush\nimport sys\n\ndef min_time_to_reach(sx, sy, tx, ty, teleport_list):\n points = [(sx, sy), (tx, ty)]\n for t in teleport_...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00061708", "row_id": 61708, "seed_ids": "[22703]" }
0.70119
Taco_61708
I
[ "min_time_to_target", "island_hopper" ]
2
[ [ "island_hopper", "min_time_to_target" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6f172af3ce9a1ca77407e79be86f2a4a7308f7c8
e5394525826ba31872ac4e19ae3923484d23ac9f
v1.0
instruct
Taco
Taco_61803_I
In the distant land of Numerovia, there exists a peculiar numerical tree called the Binary Parity Tree (BPT). The BPT is a binary tree where each node holds a single integer value. In this tree, the word "parity" refers to whether a number is even or odd. The Binary Parity Tree comes with a special property: for any gi...
class Node: def __init__(self, value): self.value = value self.left = None self.right = None def insert(root, value): if not root: return Node(value) if value % 2 == 0: if not root.left: root.left = Node(value) else: insert(root.left, ...
from solution import binary_parity_tree def test_example_1(): n = 5 arr = [2, 3, 4, 1, 5] assert binary_parity_tree(n, arr) == [2, 4, 3, 1, 5] def test_single_element(): n = 1 arr = [2] assert binary_parity_tree(n, arr) == [2] def test_all_even(): n = 3 arr = [4, 6, 2] assert bina...
[]
[ 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.125
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0):\n self.val = val\n self.left = None\n self.right = None\n\ndef insert...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00061803", "row_id": 61803, "seed_ids": "[16358]" }
0.56261
Taco_61803
I
[ "insert", "inorder_traversal", "build_bpt", "binary_parity_tree" ]
4
[ [ "binary_parity_tree", "build_bpt" ], [ "build_bpt", "inorder_traversal" ], [ "build_bpt", "insert" ] ]
3
[]
false
[ "Node" ]
true
pytest
true
[]
true
3180ec3f7c8848716b84876ba8cd604aa1d5c0f4
9ef0dfa1a986ff6c04876b5c52297a948bfd1c6f
v1.0
instruct
Taco
Taco_61806_I
You are given a list of employees in a company. Each employee record is represented by an employee ID and a boolean value that indicates whether the employee is a manager or not. Your task is to organize these employees into departments such that each department has at least one manager and no department contains more ...
def organize_departments(test_cases): result = [] for case in test_cases: N, employees = case managers = [emp for emp in employees if emp[1] == 1] non_managers = [emp for emp in employees if emp[1] == 0] if len(managers) == 0: result.append("Impossible") ...
from solution import organize_departments, parse_input, serialize_output, solution def test_example_case_1(): input_data = "3\n4\nabc123 1\nxyz456 0\nlmn789 0\npqr012 1\n6\nmgr05 1\nemp99 0\nemp01 0\nmgr22 1\nemp11 0\nemp33 0\n3\nempA 0\nempB 0\nempC 0" expected_output = "abc123 xyz456 lmn789\npqr012\nmgr05 em...
[ { "docstring": null, "function_declaration": "def organize_departments(test_cases):", "function_name": "organize_departments", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_data):", "function_name": "parse_input", "paramet...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def organize_employees(T, test_cases):\n result = []\n for case in test_cases:\n N, employees = case\n managers = [emp for emp in employees if ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00061806", "row_id": 61806, "seed_ids": "[12377]" }
0.677178
Taco_61806
I
[ "organize_departments", "parse_input", "serialize_output", "solution" ]
4
[ [ "solution", "organize_departments" ], [ "solution", "parse_input" ], [ "solution", "serialize_output" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
93eea7e61676934cd282b08c5210c796e3128209
cc1d24a961781ff04024d37a4694f50c209c6c65
v1.0
instruct
Taco
Taco_61913_I
Given an array of integers and a window size K, the task is to find the maximum number of prime numbers in any subarray of size K. Example 1: Input: K = 3 arr = [1, 3, 7, 6, 13, 19, 18, 22] Output: 2 Explanation: The subarrays of size 3 are: [1, 3, 7], [3, 7, 6], [7, 6, 13], [6, 13, 19], [13, 19, 18], [19, 18, 22] Pr...
from math import isqrt def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) ==...
from solution import maxPrimeCount def test_example1(): K = 3 arr = [1, 3, 7, 6, 13, 19, 18, 22] assert maxPrimeCount(K, arr) == 2 def test_example2(): K = 2 arr = [11, 15, 8, 5, 33, 7, 2] assert maxPrimeCount(K, arr) == 2 def test_single_element(): K = 1 arr = [1, 3, 7, 6, 13, 19, 18...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Function to find the maximum number of prime numbers in any \nsubarray of size K.", "function_declarati...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00061913", "row_id": 61913, "seed_ids": "[10691]" }
0.638677
Taco_61913
I
[ "is_prime", "maxPrimeCount" ]
2
[ [ "maxPrimeCount", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
56134e8828d9bec24207a395fd875198c1ef4191
f6f5ad311ff99f9caee60369ab6c3a46c9639b02
v1.0
instruct
Taco
Taco_61971_I
In an amusement park, there is a fun house with a maze of mirrors. The mirrors are aligned perfectly vertical or horizontal, forming a rectangular grid with $N$ rows and $M$ columns. Each cell in the grid is either a clear path (represented by '.') or contains a mirror (represented by '/'). The mirrors can reflect ligh...
from collections import deque def min_steps_to_exit(grid, start_x, start_y): N = len(grid) M = len(grid[0]) directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] # Right, Down, Left, Up # BFS initialization queue = deque([(start_x, start_y, 0)]) # store (current_x, current_y, steps) visited = ...
from solution import min_steps_grid def test_min_steps_to_exit(): grid = [ ['.', '.', '.', '.', '.'], ['.', '/', '.', '/', '.'], ['.', '.', '.', '.', '.'], ['/', '.', '/', '.', '/'], ['.', '.', '.', '.', '.'] ] assert min_steps_grid(5, 5, grid, 2, 2) == 2 def test_m...
[ { "docstring": null, "function_declaration": "def min_steps_to_exit(grid, start_x, start_y):", "function_name": "min_steps_to_exit", "parameter_list": "(grid, start_x, start_y)" }, { "docstring": null, "function_declaration": "def min_steps_grid(N, M, grid, S_x, S_y):", "function_nam...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef is_valid(x, y, N, M):\n return 0 <= x < N and 0 <= y < M\n\ndef min_steps_to_exit(N, M, grid, S_x, S_y):\n directions = ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00061971", "row_id": 61971, "seed_ids": "[21511]" }
0.708058
Taco_61971
I
[ "min_steps_to_exit", "min_steps_grid" ]
2
[ [ "min_steps_grid", "min_steps_to_exit" ] ]
1
[]
false
[]
false
pytest
true
[]
true
571493dce30ff66ca13ae631af1324f9c8106fca
967e96a72fe34a50e09ca012e293a50bd304f85c
v1.0
instruct
Taco
Taco_62039_I
The troglodytes are a secluded group of people living in the vast caverns of the mountainous region. They have developed a unique way of creating murals depicting their history, using a set of simple operations on arrays of numbers. In particular, they perform a series of operations to determine a "power value" for ea...
def digit_sum(n): """ Calculate the sum of digits of a given integer. """ return sum(int(digit) for digit in str(n)) def calculate_power_value(arr): """ Calculate the power value for the given array of integers. """ # Step 1: Calculate the digit sum of each element in the array. dig...
from solution import calculate_power_value def test_example1(): assert calculate_power_value([987, 123, 456]) == 9 def test_example2(): assert calculate_power_value([1, 2, 3, 4, 5]) == 6 def test_all_zero(): assert calculate_power_value([0, 0, 0, 0, 0]) == 0 def test_single_digit_elements(): assert ...
[ { "docstring": "Calculate the sum of digits of a given integer.", "function_declaration": "def digit_sum(n):", "function_name": "digit_sum", "parameter_list": "(n)" }, { "docstring": "Calculate the power value for the given array of integers.", "function_declaration": "def calculate_powe...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def digit_sum(n):\n \"\"\"\n Calculate the sum of digits of a given integer.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef calculate_pow...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00062039", "row_id": 62039, "seed_ids": "[9795]" }
0.611111
Taco_62039
I
[ "digit_sum", "calculate_power_value" ]
2
[ [ "calculate_power_value", "digit_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
be124aa852e9d359d7063a3df6c04a5dc7b1f2d8
5b7ac1a8330614b6c5656d74c10d3c57cc44674a
v1.0
instruct
Taco
Taco_62186_I
You are given a sequence of integers P_1, P_2, ..., P_N and Q_1, Q_2, ..., Q_M. You are to find a common subsequence R that is both subsequence of P and Q, and perform the following operations: Operations: - Add an integer at the end of R. - Remove the last integer of R. - Reverse R. You have to write a function that...
def lcs_length(P, Q): N = len(P) M = len(Q) dp = [[0] * (M+1) for _ in range(N+1)] for i in range(1, N+1): for j in range(1, M+1): if P[i-1] == Q[j-1]: dp[i][j] = dp[i-1][j-1] + 1 else: dp[i][j] = max(dp[i-1][j], dp[i][j-1]) r...
from solution import min_cost_to_form_lcs def test_example_case(): assert min_cost_to_form_lcs(4, 5, [1, 3, 4, 1], [1, 2, 3, 4, 1]) == 4 def test_no_common_elements(): assert min_cost_to_form_lcs(3, 3, [1, 2, 3], [4, 5, 6]) == 0 def test_some_common_elements(): assert min_cost_to_form_lcs(5, 6, [1, 2, 3,...
[ { "docstring": null, "function_declaration": "def lcs_length(P, Q):", "function_name": "lcs_length", "parameter_list": "(P, Q)" }, { "docstring": null, "function_declaration": "def min_cost_to_form_lcs(N, M, P, Q):", "function_name": "min_cost_to_form_lcs", "parameter_list": "(N,...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def lcs_length(P, Q):\n N = len(P)\n M = len(Q)\n lcs_table = [[0]*(M+1) for _ in range(N+1)]\n \n for i in range(1, N+1):\n for j in range(1...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00062186", "row_id": 62186, "seed_ids": "[7835]" }
0.664616
Taco_62186
I
[ "lcs_length", "min_cost_to_form_lcs" ]
2
[ [ "min_cost_to_form_lcs", "lcs_length" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f11bd0fe3aab86837f45572e9268aaea8c59d7bf
53d243553f8252006a5345e69e2adf2a452b05ad
v1.0
instruct
Taco
Taco_62348_I
You are given $n$ integers and a positive number $k$. Your task is to arrange these integers into $k$ non-empty subsets such that the maximum difference between the sum of integers in any two subsets is minimized. You need to find that minimum possible value. ------Input------ The first line of input contains a singl...
def can_partition(nums, k, max_sub_sum): current_sum = 0 partitions = 1 # We need at least one partition for num in nums: if current_sum + num > max_sub_sum: partitions += 1 current_sum = num if partitions > k: return False else: ...
def test_can_partition(): assert can_partition([1, 2, 3, 4, 5], 2, 9) == True assert can_partition([1, 2, 3, 4, 5], 2, 7) == False assert can_partition([10, 20, 30, 40], 2, 60) == True assert can_partition([10, 20, 30, 40], 2, 30) == False def test_min_max_partition(): assert min_max_partition(...
[ { "docstring": null, "function_declaration": "def can_partition(nums, k, max_sub_sum):", "function_name": "can_partition", "parameter_list": "(nums, k, max_sub_sum)" }, { "docstring": null, "function_declaration": "def min_max_partition(nums, k):", "function_name": "min_max_partition...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_min_max_diff(t, test_cases):\n \"\"\"\n Finds the minimum possible value of the maximum difference between the sums of integers in any two subsets.\...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00062348", "row_id": 62348, "seed_ids": "[6748]" }
0.697718
Taco_62348
I
[ "can_partition", "min_max_partition", "minimum_max_difference", "main" ]
4
[ [ "min_max_partition", "can_partition" ], [ "minimum_max_difference", "min_max_partition" ] ]
2
[]
false
[]
false
pytest
false
[]
true
0c5fb311309a383de287051bcb0fd78cdf0b7466
0f19ed41a181c20fd8379b798ec026faad18eea7
v1.0
instruct
Taco
Taco_62349_I
You are tasked with counting the number of vowels in string(s) provided in the input. ------ Input ------ An integer t, 1≤t≤50, denoting the number of testcases, followed by t lines, each containing a single string s with a length of up to 100 characters. The string consists of lowercase and uppercase English letters...
def count_vowels(t, strings): """ Counts vowels in a list of strings. Args: t (int): Number of test cases strings (list of str): List of strings Returns: list of int: List of vowel counts for each string """ vowels = set('aeiouAEIOU') result = [] for s in strings: ...
from solution import count_vowels def test_count_vowels_single_string(): assert count_vowels(1, ['Hello']) == [2] def test_count_vowels_multiple_strings(): assert count_vowels(3, ['Hello', 'world', 'AEIOU']) == [2, 1, 5] def test_count_vowels_empty_string(): assert count_vowels(1, ['']) == [0] def test_...
[ { "docstring": "Counts vowels in a list of strings.\n\nArgs:\nt (int): Number of test cases\nstrings (list of str): List of strings\n\nReturns:\nlist of int: List of vowel counts for each string", "function_declaration": "def count_vowels(t, strings):", "function_name": "count_vowels", "parameter_li...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_vowels(t, lst):\n \"\"\"\n Counts the number of vowels in each string in the input list.\n\n Parameters:\n t (int): number of test cases\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00062349", "row_id": 62349, "seed_ids": "[193]" }
0.827113
Taco_62349
I
[ "count_vowels", "get_vowel_counts" ]
2
[ [ "get_vowel_counts", "count_vowels" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c4ac547e7d9d0572535b4282ae261fc72f973966
2cdb65a5adef6253632c74809651bc0cd41a544f
v1.0
instruct
Taco
Taco_62387_I
Fantasy Land is a magical place with a network of n transportation portals, which allow wizards to teleport instantly between locations. Each portal is bidirectional and connects a pair of locations with a certain teleportation time. All teleportation times are positive integers. The Council of Elders is planning to s...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent...
import pytest from solution import select_portals def test_example_1(): n = 4 p = 5 edges = [ (1, 2, 5), (1, 3, 4), (2, 3, 2), (3, 4, 3), (2, 4, 7) ] m = 3 result = select_portals(n, p, edges, m) assert len(result) == 3 assert sorted(result) == [(...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "# This solution employs Kruskal's Algorithm to find the Minimum Spanning Tree (MST)\n# and then selectively adds edges until the desired number of edges m is reach...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00062387", "row_id": 62387, "seed_ids": "[16737]" }
0.653578
Taco_62387
I
[ "find", "union", "select_portals" ]
3
[ [ "select_portals", "find" ], [ "select_portals", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
73c7f3e0f8a0ec08aa5bd4c410558eb2303e2826
ab3db0c9cbd23a00da68589c0dc9b3f152088f62
v1.0
instruct
Taco
Taco_62430_I
A unique square matrix of integers is given. The task is to rotate the matrix 90 degrees clockwise. INPUT The first line contains an integer N, representing the size of the matrix (NxN). The next N lines contain N space-separated integers each, representing the elements of the matrix. OUTPUT Output the rotated mat...
def rotate_matrix_90_degrees_clockwise(matrix): """ Rotates the given NxN matrix 90 degrees clockwise. :param matrix: List of lists, where each sublist represents a row in the matrix. :return: Rotated matrix as a list of lists. """ N = len(matrix) rotated_matrix = [[0] * N for _ in rang...
from solution import read_matrix_and_rotate, rotate_matrix_90_degrees_clockwise def test_rotate_3x3_matrix(): input_matrix = [ "3", "1 2 3", "4 5 6", "7 8 9" ] expected_output = [ "7 4 1", "8 5 2", "9 6 3" ] assert read_matrix_and_rotate(input...
[ { "docstring": "Rotates the given NxN matrix 90 degrees clockwise.\n\n:param matrix: List of lists, where each sublist represents a row in the matrix.\n:return: Rotated matrix as a list of lists.", "function_declaration": "def rotate_matrix_90_degrees_clockwise(matrix):", "function_name": "rotate_matrix...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_matrix_90_degrees_clockwise(matrix):\n \"\"\"\n Rotates the given NxN matrix 90 degrees clockwise.\n \n :param matrix: List of lists, where ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00062430", "row_id": 62430, "seed_ids": "[5097]" }
0.653952
Taco_62430
I
[ "rotate_matrix_90_degrees_clockwise", "read_matrix_and_rotate" ]
2
[ [ "read_matrix_and_rotate", "rotate_matrix_90_degrees_clockwise" ] ]
1
[]
false
[]
false
pytest
true
[]
true
676c8b1043499b439739fd32ef92dfd04112264a
093c4777d7f625d881165e89746cd272399ab9d3
v1.0
instruct
Taco
Taco_62555_I
Given a string of lowercase letters, return all the distinct subsequences of the string that are palindromes. A subsequence is a sequence derived from another sequence by deleting some or no elements without changing the order of the remaining elements. Example: Input: "abca" Output: ["a", "b", "c", "aa", "aba", "aca...
def is_palindrome(s): """ Check if the given string s is a palindrome. """ return s == s[::-1] def generate_subsequences(string): """ Generate all subsequences of the given string. """ subsequences = set() def backtrack(index, path): if index == len(string): sub...
from solution import is_palindrome, generate_subsequences, find_palindromic_subsequences def test_is_palindrome(): assert is_palindrome("a") == True assert is_palindrome("aba") == True assert is_palindrome("abc") == False assert is_palindrome("racecar") == True assert is_palindrome("") == True # A...
[ { "docstring": "Check if the given string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Generate all subsequences of the given string.", "function_declaration": "def generate_subsequences...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n return s == s[::-1]\n\ndef generate_subsequences(s):\n subsequences = set()\n n = len(s)\n for i in range(1, 1 << n):\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00062555", "row_id": 62555, "seed_ids": "[18338]" }
0.719795
Taco_62555
I
[ "is_palindrome", "generate_subsequences", "find_palindromic_subsequences" ]
3
[ [ "find_palindromic_subsequences", "generate_subsequences" ], [ "find_palindromic_subsequences", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
75787bf00cde7fa1638673beb37fc00e6588f3c8
7241af19e9626314092a0bdfc7e29610f2621a60
v1.0
instruct
Taco
Taco_62571_I
A logistics company needs to optimize the delivery routes for its fleet of trucks. Each truck starts from a central warehouse (point 0) and makes deliveries to multiple locations represented as points on a 2D plane. The objective is to minimize the total distance traveled by each truck. Given a list of delivery locati...
from itertools import permutations import math def calculate_distance(point1, point2): """ Calculate the Euclidean distance between two points in a 2D plane. """ return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2) def get_minimum_distance(n, locations): """ Given the ...
import pytest from solution import logistics_company def test_example_case(): input_data = "4\n0 2\n2 2\n2 0\n0 0" assert logistics_company(input_data) == 8 def test_two_locations(): input_data = "2\n1 1\n1 0" result = logistics_company(input_data) expected = round( calculate_distance((0, ...
[ { "docstring": "Calculate the Euclidean distance between two points in a 2D plane.", "function_declaration": "def calculate_distance(point1, point2):", "function_name": "calculate_distance", "parameter_list": "(point1, point2)" }, { "docstring": "Given the number of delivery locations and th...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\nimport math\n\ndef calculate_distance(x1, y1, x2, y2):\n return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)\n\ndef minimum_to...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00062571", "row_id": 62571, "seed_ids": "[5337]" }
0.733398
Taco_62571
I
[ "calculate_distance", "get_minimum_distance", "logistics_company" ]
3
[ [ "get_minimum_distance", "calculate_distance" ], [ "logistics_company", "get_minimum_distance" ] ]
2
[]
false
[]
false
pytest
true
[]
true
80c5473244d0556f54089d54ffe52c6a8d4f8a76
b65d042556688d73872714e52135ad1280482477
v1.0
instruct
Taco
Taco_62580_I
You are working on a top-down 2D game where characters can move around a grid map. Each cell in the map can be either a passable terrain represented by ‘.’ or an obstacle represented by ‘#’. One of the game features is a pathfinding function that allows the characters to find the shortest path from their current positi...
from collections import deque def bfs_shortest_path(grid, start, end): R, C = len(grid), len(grid[0]) directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(start[0], start[1], 0)]) # row, col, distance visited = set() visited.add((start[0], start[1])) while queue: r...
from solution import find_shortest_path def test_case_1(): R, C = 3, 3 grid = [ "..#", ".#.", "..." ] Sr, Sc, Dr, Dc = 0, 0, 2, 2 assert find_shortest_path(R, C, grid, Sr, Sc, Dr, Dc) == 4 def test_case_2(): R, C = 3, 3 grid = [ "###", ".##", ...
[ { "docstring": null, "function_declaration": "def bfs_shortest_path(grid, start, end):", "function_name": "bfs_shortest_path", "parameter_list": "(grid, start, end)" }, { "docstring": null, "function_declaration": "def find_shortest_path(R, C, grid, Sr, Sc, Dr, Dc):", "function_name"...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path(R, C, grid, sr, sc, dr, dc):\n def is_valid(x, y):\n return 0 <= x < R and 0 <= y < C and grid[x][y] =...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00062580", "row_id": 62580, "seed_ids": "[3337]" }
0.658403
Taco_62580
I
[ "bfs_shortest_path", "find_shortest_path" ]
2
[ [ "find_shortest_path", "bfs_shortest_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
efca688a2f233d125ce17b555badb9d5c147cd89
a68db754968cc970ac4269dc11f8db75a70f4cd5
v1.0
instruct
Taco
Taco_62582_I
Alex is a collector of rare stones and keeps his collection in a special grid. One day, he decided to rearrange his stones such that the grid forms a "magic matrix". A grid is considered a magic matrix if all its rows and columns contain the exact same set of elements (including repetitions). You need to help Alex det...
def is_magic_matrix(n, m, grid): """ This function checks if the grid is already a magic matrix. """ sorted_first_row = sorted(grid[0]) sorted_first_column = sorted(grid[i][0] for i in range(n)) # Check if all rows have the same sorted elements as the first row for row in grid: ...
from solution import solve def test_cases(): T = 3 cases = [ (2, 2, [ [1, 2], [2, 1] ]), (3, 3, [ [1, 2, 3], [3, 1, 2], [2, 3, 1] ]), (2, 3, [ [1, 2, 3], [3, 2, 1] ]), ] ...
[ { "docstring": "This function checks if the grid is already a magic matrix.", "function_declaration": "def is_magic_matrix(n, m, grid):", "function_name": "is_magic_matrix", "parameter_list": "(n, m, grid)" }, { "docstring": null, "function_declaration": "def min_swaps_to_magic_matrix(n,...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_swaps_to_magic_matrix(test_cases):\n \"\"\"\n Given a list of test cases where each test case is a grid, returns the minimum number of swaps\n req...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00062582", "row_id": 62582, "seed_ids": "[18029]" }
0.699759
Taco_62582
I
[ "is_magic_matrix", "min_swaps_to_magic_matrix", "solve" ]
3
[ [ "min_swaps_to_magic_matrix", "is_magic_matrix" ], [ "solve", "min_swaps_to_magic_matrix" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ca11dac136375655ce64687f12a5614815fea218
0e8176402bcc68c907db5a02c6e3d339679501d0
v1.0
instruct
Taco
Taco_62589_I
A popular online bookstore maintains logs of books viewed by users. Each log entry contains the user ID and the book ID. The bookstore wants to analyze browsing patterns to recommend related books to users based on popular sequential views. Given a list of log entries, identify the longest sequence of books that are r...
from collections import defaultdict def longest_sequence_viewed_together(log_entries): # Step 1: Parse the logs into a dictionary by user user_views = defaultdict(list) for user_id, book_id in log_entries: user_views[user_id].append(book_id) # Step 2: Extract sequences and store in sequenc...
def test_bookstore_analysis_basic(): assert bookstore_analysis(8, [(1, 5), (1, 6), (1, 7), (2, 5), (2, 6), (2, 8), (3, 7), (3, 6)]) == 2 def test_bookstore_analysis_all_single(): assert bookstore_analysis(4, [(1, 1), (2, 2), (3, 3), (4, 4)])...
[ { "docstring": null, "function_declaration": "def longest_sequence_viewed_together(log_entries):", "function_name": "longest_sequence_viewed_together", "parameter_list": "(log_entries)" }, { "docstring": null, "function_declaration": "def bookstore_analysis(n, log_entries):", "functi...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef longest_sequence_viewed_together(log_entries):\n # Step 1: Parse the logs into a dictionary by user\n user_views =...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00062589", "row_id": 62589, "seed_ids": "[14162]" }
0.559389
Taco_62589
I
[ "longest_sequence_viewed_together", "bookstore_analysis" ]
2
[ [ "bookstore_analysis", "longest_sequence_viewed_together" ] ]
1
[]
false
[]
false
pytest
false
[]
true
8fd15726adb6e752f730612cafee5339f24a5dc5
d941987de24aed8b652e8ded5e10a33ea0ebede1
v1.0
instruct
Taco
Taco_62679_I
In the popular game of "Tetris," players manipulate various shapes (tetrominoes) to complete and clear lines on a grid. One important aspect of the game is determining whether a newly spawned tetromino can be placed on the grid without any overlaps with existing blocks. Write a program that checks if a given tetromino...
def can_place_tetromino(grid, tetromino, pos_x, pos_y): """ Checks if a given tetromino can be placed on the grid at the specified position without overlapping any filled cells. :param grid: List of strings representing the grid :param tetromino: List of tuples representing the relative positions o...
from solution import tetris_fit_checker def test_tetris_fit_checker_simple_yes(): n = 5 m = 5 grid = [ '.....', '.....', '.....', '.....', '.....' ] t = 4 tetromino = [(0, 0), (0, 1), (1, 0), (1, 1)] x = 2 y = 2 assert tetris_fit_checker(n, m,...
[ { "docstring": "Checks if a given tetromino can be placed on the grid at the specified position without overlapping any filled cells.\n\n:param grid: List of strings representing the grid\n:param tetromino: List of tuples representing the relative positions of the tetromino cells\n:param pos_x: Integer represen...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_place_tetromino(n, m, grid, t, tetromino_positions, x, y):\n for delta_r, delta_c in tetromino_positions:\n new_r = x + delta_r\n new_c = ...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00062679", "row_id": 62679, "seed_ids": "[9493]" }
0.662211
Taco_62679
I
[ "can_place_tetromino", "tetris_fit_checker" ]
2
[ [ "tetris_fit_checker", "can_place_tetromino" ] ]
1
[]
false
[]
false
pytest
true
[]
true
24c7df2ee66393ea96ec9fe27964ff4c3dca2049
ec87f909fc48adb146f800372776ae278b423f18
v1.0
instruct
Taco
Taco_62692_I
A Magical Square In a land far away, there exists a magical square of numbers which holds incredible significance in rituals. Each number in the magical square not only influences the power of the ritual but also follows certain mathematical properties. A magical square is a square matrix of size n × n (where n is an ...
def is_magic_square(matrix, n): magic_constant = sum(matrix[0]) # Check rows for row in matrix: if sum(row) != magic_constant: return "NOT MAGIC" # Check columns for col in range(n): if sum(matrix[row][col] for row in range(n)) != magic_constant: ret...
def test_is_magic_square(): assert magic_square(3, [8, 1, 6, 3, 5, 7, 4, 9, 2]) == 15 assert magic_square(5, [17, 24, 1, 8, 15, 23, 5, 7, 14, 16, 4, 6, 13, 20, 22, 10, 12, 19, 21, 3, 11, 18, 25, 2, 9]) == 65 assert magic_square(5, [11, 18, 25, 2, 9, 17, 24, 1, 8, 15, 23, 5, 7, 14, 16, 4, 6, 13, 20, 22, 10, ...
[ { "docstring": null, "function_declaration": "def is_magic_square(matrix, n):", "function_name": "is_magic_square", "parameter_list": "(matrix, n)" }, { "docstring": null, "function_declaration": "def magic_square(n, data):", "function_name": "magic_square", "parameter_list": "(n...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_magic_square(n, matrix):\n # Calculate the magic constant (sum of any row/column/diagonal)\n magic_constant = n * (n**2 + 1) // 2\n \n # Check r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00062692", "row_id": 62692, "seed_ids": "[21651]" }
0.63638
Taco_62692
I
[ "is_magic_square", "magic_square" ]
2
[ [ "magic_square", "is_magic_square" ] ]
1
[]
false
[]
false
pytest
false
[]
true
293fd0c94f181a4b1813c899ae8ac7dbcfd0b1bc
c797ba3e69a8414099e99482e58a50a984f9894e
v1.0
instruct
Taco
Taco_62742_I
The new task for you is to manage a competition in ChefLand, where various participants will compete in different events. Each participant is required to participate in a series of events, and their final ranking will depend upon their cumulative performance across all events. The competition has a peculiar rule: a par...
def validate_scores(scores): """ Validate if scores for a participant follow the rules: scores must stay the same or increase. """ return all(scores[i] <= scores[i+1] for i in range(len(scores) - 1)) def check_all_participants(participants_scores): """ Check if all participants' scores are vali...
import pytest from solution import validate_scores, check_all_participants, main def test_validate_scores_increasing(): assert validate_scores([5, 10, 15]) == True def test_validate_scores_same(): assert validate_scores([8, 8, 10, 12]) == True def test_validate_scores_decreasing(): assert validate_scores...
[ { "docstring": "Validate if scores for a participant follow the rules: scores must stay the same or increase.", "function_declaration": "def validate_scores(scores):", "function_name": "validate_scores", "parameter_list": "(scores)" }, { "docstring": "Check if all participants' scores are va...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def validate_scores(participants_scores):\n \"\"\"\n Takes a list of lists, with each inner list representing a participant's sequential event scores.\n R...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00062742", "row_id": 62742, "seed_ids": "[18054]" }
0.686136
Taco_62742
I
[ "validate_scores", "check_all_participants", "main" ]
3
[ [ "check_all_participants", "validate_scores" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2cc34941ff4154326d6839c8cbb57fedd93cf2e9
5f49ae6727ba0be7bf298bed27a2cf55e29695b0
v1.0
instruct
Taco
Taco_62800_I
You work as a software engineer at a company that handles a lot of data collections. Your data team has a collection of n data points and they want you to help them organize the data in a way that allows them to quickly find specific ranges of data points. You decide to implement a range query solution. You need to di...
def preprocess_segments(data_points, k): """ Preprocess the data points into k segments and sort each segment. """ # Calculate segment size segment_size = len(data_points) // k remainder = len(data_points) % k segments = [] index = 0 for i in range(k): size = segmen...
def test_preprocess_segments(): data_points = [5, 2, 9, 1, 7, 3] k = 3 expected_segments = [[2, 5], [1, 9], [3, 7]] assert preprocess_segments(data_points, k) == expected_segments def test_compute_prefix_sums(): sorted_data_points = [1, 2, 3, 5, 7, 9] expected_prefix_sums = [0, 1, 3, 6, 11, 18,...
[ { "docstring": "Preprocess the data points into k segments and sort each segment.", "function_declaration": "def preprocess_segments(data_points, k):", "function_name": "preprocess_segments", "parameter_list": "(data_points, k)" }, { "docstring": "Compute prefix sums for the sorted data poin...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def range_query(n, k, q, data_points, queries):\n \"\"\"\n Divides data points into k segments, sorts each segment, and processes range queries.\n \"\"\"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00062800", "row_id": 62800, "seed_ids": "[10081]" }
0.645866
Taco_62800
I
[ "preprocess_segments", "compute_prefix_sums", "range_query", "range_query_solution" ]
4
[ [ "range_query_solution", "compute_prefix_sums" ], [ "range_query_solution", "preprocess_segments" ], [ "range_query_solution", "range_query" ] ]
3
[]
false
[]
false
pytest
false
[]
true
1a2652734cc621513c9e6a99c7e918ebf530dda9
f29039fdc9f1ced878c6b6e1054257576b34f6d6
v1.0
instruct
Taco
Taco_62855_I
In a large forest, there is a network of n nodes connected by m undirected edges, forming a connected graph. A special type of beetle starts its journey from node 1 and can traverse the graph through edges. However, this beetle has an unusual travelling habit. Whenever it reaches a node, it will only move to a neighbo...
import heapq import math def is_prime(n): """Function to check if a number is prime.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import shortest_path def test_example(): n = 5 m = 5 edges = [ (1, 2, 4), (2, 3, 6), (3, 5, 8), (1, 4, 10), (4, 5, 12) ] assert shortest_path(n, m, edges) == -1 def test_no_prime_lengths(): n = 3 m = 3 edges = [ (1, 2, 6), ...
[ { "docstring": "Function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def shortest_path(n, m, edges):", "function_name": "shortest_path", "paramet...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nimport math\n\ndef is_prime(n):\n \"\"\"Function to check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00062855", "row_id": 62855, "seed_ids": "[19227]" }
0.650041
Taco_62855
I
[ "is_prime", "shortest_path" ]
2
[ [ "shortest_path", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e9a96ae45c141248995c95416417a1398c234ad7
0aad0ea4c64de8f3d4813d6ef9ab2c0ba12591f5
v1.0
instruct
Taco
Taco_62859_I
Write a function to find the smallest number that is greater than or equal to the given target and can be expressed as the sum of two prime numbers. Example 1: Input: target = 10 Output: 10 Explanation: 10 = 3 + 7, and both 3 and 7 are prime. Example 2: Input: target = 17 Output: 18 Explanation: 17 cannot be express...
def is_prime(n): """ Checks if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while (i * i) <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return T...
from solution import smallest_sum_of_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(9) == False assert is_prime(29) == True def test_smallest_sum_of_primes_example_1(): asser...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Finds the smallest number greater than or equal to the given target that can be expressed as the sum of two prime numbers.", ...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\"Helper function to check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n == 2 or n == 3:\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00062859", "row_id": 62859, "seed_ids": "[8825]" }
0.689544
Taco_62859
I
[ "is_prime", "smallest_sum_of_primes" ]
2
[ [ "smallest_sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2049cdbcc21d0bcbe0717aefc15e5d26b0f84d32
b9e5f4b6fba276506cd39c4d22668f4054ad9346
v1.0
instruct
Taco
Taco_62879_I
Given an integer N, you need to return the sum of the first N prime numbers. A prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. For example, the first few prime numbers are 2, 3, 5, 7, 11, etc. Example 1: Input: N=3 Output: 10 Explanation: The first 3 prime numbers a...
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def sum_of_primes(N): """ ...
def test_sum_of_primes(): assert sum_of_primes(1) == 2 assert sum_of_primes(2) == 5 assert sum_of_primes(3) == 10 assert sum_of_primes(5) == 28 assert sum_of_primes(10) == 129 assert sum_of_primes(20) == 639 def test_large_N(): assert sum_of_primes(100) == 24133 assert sum_of_primes(100...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of the first N prime numbers.", "function_declaration": "def sum_of_primes(N):", "function_name": "sum_of_primes", "paramet...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00062879", "row_id": 62879, "seed_ids": "[6317]" }
0.634077
Taco_62879
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
d0849f59ab1e8b13bb1c70065fa399f49307b22c
17daf2aaab42e47b2fe61b6ac35babfb82e72b35
v1.0
instruct
Taco
Taco_62906_I
# Story&Task You are given a rectangular matrix of size n x m that contains only ones and zeroes. Find the largest rectangle (containing only ones) and return its area. # Input/Output - `[input]` 2D integer array `matrix` The array of integers representing the matrix. The values are either 0 or 1. `1 ≤ matrix.len...
def maximal_rectangle(matrix): if not matrix or not matrix[0]: return 0 n = len(matrix) m = len(matrix[0]) max_area = 0 heights = [0] * m for row in matrix: for i in range(m): heights[i] = heights[i] + 1 if row[i] == 1 else 0 max_area = max(max_area, largest_r...
from solution import maximal_rectangle def test_maximal_rectangle_case_1(): matrix = [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0] ] assert maximal_rectangle(matrix) == 6 def test_maximal_rectangle_case_2(): matrix = [ [0, 1, 1, 0], ...
[ { "docstring": null, "function_declaration": "def maximal_rectangle(matrix):", "function_name": "maximal_rectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largest_rectangle_area(heights):", "function_name": "largest_rectangle_area", "pa...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximal_rectangle(matrix):\n if not matrix:\n return 0\n\n max_area = 0\n n = len(matrix)\n m = len(matrix[0])\n heights = [0] * (m + 1)\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00062906", "row_id": 62906, "seed_ids": "[22015]" }
0.774332
Taco_62906
I
[ "maximal_rectangle", "largest_rectangle_area" ]
2
[ [ "maximal_rectangle", "largest_rectangle_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1bc1ff9fccb5ee2cd87e046dd7445680cd511f1e
3e744d17ea2b91a32c74a11e9164b6aa21378cc7
v1.0
instruct
Taco
Taco_62947_I
In a binary tree, each node contains either a value of 0 or 1. Given a binary tree, you need to perform the following operations: 1. For each node, find the sum of values of the nodes in its subtree (including the node itself). 2. Find and return the maximum sum among all subtrees. Input Format The input consists of...
class TreeNode: def __init__(self, value): self.value = value self.children = [] def build_tree(node_values, edges): nodes = [TreeNode(value) for value in node_values] for u, v in edges: nodes[u-1].children.append(nodes[v-1]) nodes[v-1].children.append(nodes[u-1]) ...
def test_example_case(): n = 5 node_values = [1, 0, 1, 1, 0] edges = [(1, 2), (1, 3), (2, 4), (2, 5)] assert max_subtree_sum(n, node_values, edges) == 3 def test_single_node_tree(): n = 1 node_values = [1] edges = [] assert max_subtree_sum(n, node_values, edges) == 1 def test_all_zeros...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value=0):\n self.value = value\n self.children = []\n\ndef build_tree(values, edges):\n nodes = {i: TreeNo...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00062947", "row_id": 62947, "seed_ids": "[4852]" }
0.688408
Taco_62947
I
[ "build_tree", "subtree_sum", "max_subtree_sum" ]
3
[ [ "max_subtree_sum", "build_tree" ], [ "max_subtree_sum", "subtree_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
acaa674cfae9172596286646a15f3ffd1ef4d650
5983a1c9c0e4d18e0851f9e29f5b0b8a1f704cff
v1.0
instruct
Taco
Taco_62979_I
Given an integer array of length N, determine if it is possible to select a subset of the elements such that their sum is a prime number. ------ Input Format ------ - The first line of input will contain a single integer T, denoting the number of test cases. - Each test case consists of two lines: - The first li...
from itertools import combinations def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def has_prime_sum_subset(arr): for r in rang...
from solution import solve def test_sample_input_1(): T = 3 test_cases = [(4, [1, 2, 3, 4]), (3, [10, 15, 20]), (5, [2, 3, 5, 7, 11])] expected = ["YES", "NO", "YES"] assert solve(T, test_cases) == expected def test_all_single_element_prime(): T = 1 test_c...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def has_prime_sum_subset(arr):", "function_name": "has_prime_sum_subset", "parameter_list": "(arr)" }, { ...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef is_prime(num):\n \"\"\"\n Returns True if num is a prime number, else returns False.\n \"\"\"\n if num <= 1:\...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00062979", "row_id": 62979, "seed_ids": "[7315]" }
0.660969
Taco_62979
I
[ "is_prime", "has_prime_sum_subset", "solve" ]
3
[ [ "has_prime_sum_subset", "is_prime" ], [ "solve", "has_prime_sum_subset" ] ]
2
[]
false
[]
false
pytest
true
[]
true
33c868edc874841d1c2b4ce80faab108cea39ccf
9ad92f59eb8c6bfed4322df784683392cf324671
v1.0
instruct
Taco
Taco_62990_I
There is a road network between several cities, represented as a tree with $n$ nodes (cities) and $n-1$ edges (roads). All roads are bidirectional. Each road has a given toll fee associated with it. The toll fee between the $i$-th city and the $j$-th city is represented by an integer $c(i, j)$. A merchant wants to tra...
import sys from collections import defaultdict import heapq def create_graph(n, edges): graph = defaultdict(list) for u, v, w in edges: graph[u].append((v, w)) graph[v].append((u, w)) return graph def dijkstra(graph, start, end): heap = [(0, start)] visited = set() min_cost = {...
from solution import min_toll_fees def test_example_case(): n = 5 edges = [ (1, 2, 3), (1, 3, 4), (2, 4, 5), (2, 5, 6) ] queries = [ (1, 4), (4, 5), (3, 5) ] expected = [8, 11, 13] assert min_toll_fees(n, edges, queries) == expected d...
[ { "docstring": null, "function_declaration": "def create_graph(n, edges):", "function_name": "create_graph", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def dijkstra(graph, start, end):", "function_name": "dijkstra", "parameter_list": "(graph, ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\nfrom collections import defaultdict, deque\n\n# Function to build the tree as a graph\ndef build_tree(n, edges):\n graph = defaultdict(list)\n fo...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00062990", "row_id": 62990, "seed_ids": "[399]" }
0.754149
Taco_62990
I
[ "create_graph", "dijkstra", "min_toll_fees" ]
3
[ [ "min_toll_fees", "create_graph" ], [ "min_toll_fees", "dijkstra" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a9c31eb4f82c9a9c890d7566aa895dd7ec0909e4
a74e0f0890013a67bee3bfe9c2ddc4922ae13ecc
v1.0
instruct
Taco
Taco_62999_I
Ringo loves playing with number sequences in his yellow submarine. He recently came across an interesting sequence of integers and would like to transform it into a non-decreasing sequence using the minimum number of swap operations. A swap operation allows you to choose two indices i and j (1 ≤ i, j ≤ n) and swap the ...
def merge_sort_and_count(arr, temp_arr, left, right): if left >= right: return 0 mid = (left + right) // 2 inv_count = merge_sort_and_count(arr, temp_arr, left, mid) inv_count += merge_sort_and_count(arr, temp_arr, mid + 1, right) inv_count += merge_and_count(arr, temp_arr, left, mid, right...
from solution import minimum_swaps_to_sort def test_case_1(): assert minimum_swaps_to_sort([3, 1, 2]) == 2 def test_case_2(): assert minimum_swaps_to_sort([5, 4, 3, 2, 1]) == 10 def test_case_3(): assert minimum_swaps_to_sort([1, 2, 3, 4]) == 0 def test_case_4(): assert minimum_swaps_to_sort([2, 3, ...
[ { "docstring": null, "function_declaration": "def merge_sort_and_count(arr, temp_arr, left, right):", "function_name": "merge_sort_and_count", "parameter_list": "(arr, temp_arr, left, right)" }, { "docstring": null, "function_declaration": "def merge_and_count(arr, temp_arr, left, mid, r...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_swaps_to_sorted(arr):\n \"\"\"\n Returns the minimum number of swap operations required to transform the given array \n into a non-decreasing sequ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00062999", "row_id": 62999, "seed_ids": "[11606]" }
0.659243
Taco_62999
I
[ "merge_sort_and_count", "merge_and_count", "minimum_swaps_to_sort" ]
3
[ [ "merge_sort_and_count", "merge_and_count" ], [ "minimum_swaps_to_sort", "merge_sort_and_count" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e75ac5f53918211e02e822acad701f2ad5a57b2f
7dd1df82f113ca955dcbbb6ac76ac9cdc0f8f09e
v1.0
instruct
Taco
Taco_63019_I
Raghav is fascinated by prime numbers and often spends time discovering interesting properties about them. One day, while analyzing certain series of numbers, he came across a unique problem. He discovered that some numbers can be transformed into prime numbers by rearranging their digits. Now, Raghav wants to know whe...
from itertools import permutations def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: ...
from solution import can_form_prime def test_sample_input_197(): assert can_form_prime(197) == "YES" def test_sample_input_123(): assert can_form_prime(123) == "NO" def test_single_digit_prime(): assert can_form_prime(3) == "YES" def test_single_digit_non_prime(): assert can_form_prime(4) == "NO" d...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Determines if any permutation of the digits of n is a prime number.", "function_declaration": "def can_form_prime(n):", ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef is_prime(num):\n \"\"\"\n Returns True if num is a prime number, otherwise False.\n \"\"\"\n if num <= 1:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00063019", "row_id": 63019, "seed_ids": "[8335]" }
0.583231
Taco_63019
I
[ "is_prime", "can_form_prime" ]
2
[ [ "can_form_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
91cc07b83dd977dbd2e1bd71be67bbb6239e810a
19f789234cc2ea5bb8b7d9392737f6314f76e1c0
v1.0
instruct
Taco
Taco_63105_I
Create a method that takes a list of integer numbers and returns a new list that contains only the prime numbers from the original list. Prime numbers are integers greater than 1 that have no divisors other than 1 and themselves. Examples: ```python filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) # => [2, 3, 5, 7] filter...
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n == 2: return True # 2 is a prime number if n % 2 == 0: return False # Eliminate even numbers greater than 2 for i in range(3, int(n**0.5) + 1, 2): if ...
from solution import filter_primes def test_filter_primes_with_primes_and_non_primes(): assert filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] assert filter_primes([11, 12, 13, 14, 15, 16]) == [11, 13] assert filter_primes([17, 18, 19, 20, 21, 22, 23]) == [17, 19, 23] assert filter_primes([...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given list of numbers.", "function_declaration": "def filte...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n*...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00063105", "row_id": 63105, "seed_ids": "[13806]" }
0.689749
Taco_63105
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7327575b4a00fe80d0fa28e23631707b3a95a6d8
d43486c2d40b92f19ce7b1b22012da0cc9cdc610
v1.0
instruct
Taco
Taco_63128_I
## Description Design a function that takes a list of integers as input and returns a new list that contains only the prime numbers from the original list. - A prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. - Implement an efficient algorithm to check for prime numb...
def is_prime(n): """ Check if a number n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import is_prime, filter_primes def test_is_prime(): assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert is_prime(13) assert not is_prime(15) assert is_prime(29) assert not is_prime(30) assert is_prime(101) ...
[ { "docstring": "Check if a number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given a list of integers, return a list with only the prime numbers.", "function_declaration": "def filter_primes(n...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00063128", "row_id": 63128, "seed_ids": "[14591]" }
0.663614
Taco_63128
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
63fbb1d390431af30a8bfe8b53c74932abffe517
0631be1aaddd5779a446adacd5e231a85e5d8519