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_23385_I | You are given an array of N integers. You need to perform Q queries on this array. Each query is of the following form:
- 1 x y: Update the element at index x to y.
- 2 l r: Calculate the sum of elements from index l to r (inclusive).
The indexing is 1-based.
------ Input ------
The first line contains two integers... | def update_array(arr, idx, value):
"""
Update the element at index idx in the array arr with the value.
"""
arr[idx - 1] = value
def sum_range(arr, l, r):
"""
Calculate the sum of elements from index l to r (inclusive) in the array arr.
"""
return sum(arr[l - 1:r])
def process_queries(... | from solution import update_array, sum_range, process_queries
def test_update_array():
arr = [1, 2, 3, 4, 5]
update_array(arr, 2, 10)
assert arr == [1, 10, 3, 4, 5]
def test_sum_range():
arr = [1, 2, 10, 4, 5]
assert sum_range(arr, 1, 3) == 13
assert sum_range(arr, 2, 4) == 16
assert sum_r... | [
{
"docstring": "Update the element at index idx in the array arr with the value.",
"function_declaration": "def update_array(arr, idx, value):",
"function_name": "update_array",
"parameter_list": "(arr, idx, value)"
},
{
"docstring": "Calculate the sum of elements from index l to r (inclusiv... | [
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 process_queries(n, q, arr, queries):\n \"\"\"\n This function processes a list of queries on the given array. \n Each query will either update an elem... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00023385",
"row_id": 23385,
"seed_ids": "[13529]"
} | 0.750037 | Taco_23385 | I | [
"update_array",
"sum_range",
"process_queries"
] | 3 | [
[
"process_queries",
"sum_range"
],
[
"process_queries",
"update_array"
]
] | 2 | [
"process_queries"
] | false | [] | false | pytest | true | [] | true | 586936727d065b7f5ad5a6a6c5f9060374b763bf | 4438418e73ca118b0a91bf13a649cd41a969c603 | |||
v1.0 | instruct | Taco | Taco_23389_I | Alex loves playing with a string S of length N. His goal is to determine the minimum number of contiguous substrings such that every substring is either a palindrome or can be rearranged to form a palindrome.
Your task is to help Alex by writing a program that finds this minimum number.
Input Format:
The first line... | def can_form_palindrome(s):
"""
Returns True if the string s can be rearranged to form a palindrome.
"""
from collections import Counter
count = Counter(s)
odd_count = sum(1 for x in count.values() if x % 2 == 1)
return odd_count <= 1
def min_palindromic_substrings(N, S):
"""
Return... | from solution import min_palindromic_substrings
def test_example_case():
assert min_palindromic_substrings(7, "nooonan") == 3
def test_single_character():
assert min_palindromic_substrings(1, "a") == 1
def test_all_palindrome():
assert min_palindromic_substrings(5, "madam") == 1
def test_all_characters_... | [
{
"docstring": "Returns True if the string s can be rearranged to form a palindrome.",
"function_declaration": "def can_form_palindrome(s):",
"function_name": "can_form_palindrome",
"parameter_list": "(s)"
},
{
"docstring": "Returns the minimum number of contiguous substrings such that every... | [
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_rearrange_to_palindrome(s):\n from collections import Counter\n count = Counter(s)\n odd_count = sum(1 for c in count if count[c] % 2 != 0)\n r... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00023389",
"row_id": 23389,
"seed_ids": "[13869]"
} | 0.842021 | Taco_23389 | I | [
"can_form_palindrome",
"min_palindromic_substrings"
] | 2 | [
[
"min_palindromic_substrings",
"can_form_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e098f4d4b89dfd5c0a11003017dc67d7af57651b | 36c1e93f44cf50442c7de5ee2460be47ab0b8795 | |||
v1.0 | instruct | Taco | Taco_23404_I | In a faraway magical land, there is a kingdom with $n$ cities connected by $n-1$ roads in such a way that there is exactly one path between any two cities. Each city has a certain amount of soldiers. The king wants to know the minimum number of soldiers that can be obtained by traveling from city $u$ to city $v$ along ... | from collections import defaultdict, deque
def bfs(graph, start, soldiers):
queue = deque([start])
visited = {start}
dist = {start: soldiers[start - 1]}
parent = {start: None}
while queue:
node = queue.popleft()
for neighbor in graph[node]:
if neighbor not in visited:
... | def test_find_minimum_soldiers():
# Example 1
n = 5
soldiers = [10, 20, 30, 40, 50]
roads = [(1, 2), (1, 3), (3, 4), (3, 5)]
queries = [(1, 5), (2, 4), (4, 5)]
expected = [10, 10, 30]
result = find_minimum_soldiers(n, soldiers, roads, queries)
assert result == expected, f"expected {... | [
{
"docstring": null,
"function_declaration": "def bfs(graph, start, soldiers):",
"function_name": "bfs",
"parameter_list": "(graph, start, soldiers)"
},
{
"docstring": null,
"function_declaration": "def find_minimum_soldiers(n, soldiers, roads, queries):",
"function_name": "find_mini... | [
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 defaultdict, deque\n\ndef bfs(graph, start, soldiers):\n queue = deque([start])\n visited = {start}\n dist = {start: soldiers[star... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00023404",
"row_id": 23404,
"seed_ids": "[2485]"
} | 0.79498 | Taco_23404 | I | [
"bfs",
"find_minimum_soldiers"
] | 2 | [
[
"find_minimum_soldiers",
"bfs"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 1666e78152b71d485a5b274e73d039c0e4bd0fb0 | ed37d828bdfcfa24d00924b7caa8d9cc4750684b | |||
v1.0 | instruct | Taco | Taco_23442_I | A tech company has a network of servers connected by bidirectional cables. Each server is labeled uniquely with an id from 1 to n. The goal is to ensure that all servers are directly or indirectly connected to server 1 (the main server). If a server is not connected to the main server, the company wants to determine wh... | def find_min_additional_cables(n, m, connections):
from collections import defaultdict, deque
def bfs(start, graph, visited):
queue = deque([start])
visited[start] = True
while queue:
node = queue.popleft()
for neighbor in graph[node]:
if not visi... | def test_find_min_additional_cables_example_1():
assert find_min_additional_cables(5, 3, [(1, 2), (2, 3), (4, 5)]) == 1
def test_find_min_additional_cables_example_2():
assert find_min_additional_cables(4, 0, []) == 3
def test_find_min_additional_cables_single_cable():
assert find_min_additional_cables(4,... | [
{
"docstring": null,
"function_declaration": "def find_min_additional_cables(n, m, connections):",
"function_name": "find_min_additional_cables",
"parameter_list": "(n, m, connections)"
},
{
"docstring": null,
"function_declaration": "def solve():",
"function_name": "solve",
"par... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def minimum_additional_cables(n, m, connections):\n from collections import defaultdict\n\n def dfs(node, visited, adj):\n stack = [node]\n whi... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00023442",
"row_id": 23442,
"seed_ids": "[10683]"
} | 0.664013 | Taco_23442 | I | [
"find_min_additional_cables",
"solve"
] | 2 | [
[
"solve",
"find_min_additional_cables"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | c04fb14c764cb567cb23ed47dfd683ee32426609 | ae6c75542645013d9e59fe48a72195951b18e0ba | |||
v1.0 | instruct | Taco | Taco_23491_I | Polycarp is fascinated by prime numbers and enjoys playing with them. One day, he thought of a problem involving prime numbers and asked you to solve it.
Polycarp defines a prime palindrome number as a number that is both prime and a palindrome. A palindrome is a number that remains the same when its digits are revers... | def is_prime(n):
"""
Check if a number n is prime. A number is prime if it is greater than 1 and is only divisible by 1 and itself.
"""
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 % ... | from solution import is_prime, is_palindrome, smallest_prime_palindrome
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(29) == True
assert is_prime(1) == False
assert is_prime(0) == False
assert is_prime(-5) == False
de... | [
{
"docstring": "Check if a number n is prime. A number is prime if it is greater than 1 and is only divisible by 1 and itself.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Check if a number n is a palindrome. A number i... | [
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 Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00023491",
"row_id": 23491,
"seed_ids": "[21002]"
} | 0.662466 | Taco_23491 | I | [
"is_prime",
"is_palindrome",
"smallest_prime_palindrome"
] | 3 | [
[
"smallest_prime_palindrome",
"is_palindrome"
],
[
"smallest_prime_palindrome",
"is_prime"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 24498f8f519a62e8f4a6c5dfb80a916fe172ae5b | dceced66a735d63e52bf29b0fa52a4bec2c6da4d | |||
v1.0 | instruct | Taco | Taco_23512_I | A famous detective is working on a case involving a secret society. The society communicates using a cipher based on prime factorization. The detective has a list of numbers, and he suspects that they are encoded messages. To start decoding, he needs to find all numbers in the list that have exactly two distinct prime ... | def has_exactly_two_distinct_prime_factors(number):
prime_factors = set()
factor = 2
while factor * factor <= number:
while (number % factor) == 0:
prime_factors.add(factor)
number //= factor
factor += 1
if number > 1:
prime_factors.add(number)
return ... | from solution import solve
def test_case_1():
assert solve(3, [
(5, [10, 15, 21, 30, 35]),
(4, [16, 27, 64, 81]),
(3, [49, 77, 91])
]) == ["TRUE", "FALSE", "TRUE"]
def test_case_2():
assert solve(2, [
(3, [6, 10, 14]),
(2, [18, 20])
]) == ["TRUE", "TRUE"]
def t... | [
{
"docstring": null,
"function_declaration": "def has_exactly_two_distinct_prime_factors(number):",
"function_name": "has_exactly_two_distinct_prime_factors",
"parameter_list": "(number)"
},
{
"docstring": null,
"function_declaration": "def solve(t, test_cases):",
"function_name": "s... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef has_two_distinct_prime_factors(num):\n prime_factors = set()\n # Check for number of 2s that divide num\n while num % 2 == 0:\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00023512",
"row_id": 23512,
"seed_ids": "[19792]"
} | 0.612523 | Taco_23512 | I | [
"has_exactly_two_distinct_prime_factors",
"solve"
] | 2 | [
[
"solve",
"has_exactly_two_distinct_prime_factors"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | fb9079062735e1f9b7be30ef68dfc06cf4dd2e62 | 9c2d820b7d5ab9165b6e3fe4c82db96546fe79e4 | |||
v1.0 | instruct | Taco | Taco_23590_I | In a dense forest, there is a grid of square cells, each cell representing a portion of the forest. Some of these cells contain trees (marked with `1`), and some are empty (marked with `0`). A tree cluster is defined as a group of connected `1`s, where two `1`s are considered "connected" if they are adjacent horizontal... | def find_tree_clusters(grid):
"""
Returns the number of tree clusters in the given grid.
Parameters:
grid (list of list of int): 2D grid representing the forest.
Returns:
int: Number of tree clusters.
"""
def dfs(x, y):
# If out of bounds or already visited or empty cell, retur... | from solution import find_tree_clusters_from_input
def test_find_tree_clusters_sample1():
n = 4
m = 4
grid_input = [
"1 1 0 0",
"1 0 0 1",
"0 0 1 0",
"0 1 1 1"
]
assert find_tree_clusters_from_input(n, m, grid_input) == 3
def test_find_tree_clusters_sample2():
n... | [
{
"docstring": "Returns the number of tree clusters in the given grid.\n\nParameters:\ngrid (list of list of int): 2D grid representing the forest.\n\nReturns:\nint: Number of tree clusters.",
"function_declaration": "def find_tree_clusters(grid):",
"function_name": "find_tree_clusters",
"parameter_... | [
1,
1
] | 2 | easy | 1 | {
"trial_gpt4o_0": null,
"trial_gpt4o_1": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl",
"solution_code": "def find_tree_clusters(grid):\n \"\"\"\n Returns the number of tree clusters in the given grid.\n\n Parameters:\n grid (list o... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00023590",
"row_id": 23590,
"seed_ids": "[24400]"
} | 0.622138 | Taco_23590 | I | [
"find_tree_clusters",
"find_tree_clusters_from_input"
] | 2 | [
[
"find_tree_clusters_from_input",
"find_tree_clusters"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b918eb9ba56341808db87763f84763941d21d424 | 9da4710c978398652e60bbaeacfa909a41a02547 | |||
v1.0 | instruct | Taco | Taco_23761_I | Write a program that reads sequences of integers and outputs the median for each sequence.
The median is the middle number in a sorted, odd-length list of numbers, or the average of the two middle numbers in a sorted, even-length list.
Constraints
* Each sequence contains between 1 and 1000 integers.
* Each integer ... | def find_median(sequence):
"""
Returns the median of a given sequence of integers.
"""
sequence.sort()
n = len(sequence)
if n % 2 == 1:
median = sequence[n // 2]
else:
median = (sequence[n // 2 - 1] + sequence[n // 2]) / 2
return median
def process_sequences(input_lines... | from solution import find_median, process_sequences
def test_find_median_odd_length():
assert find_median([3, 1, 2]) == 2
assert find_median([10, 20, 30, 40, 50]) == 30
def test_find_median_even_length():
assert find_median([10, 20, 30, 40]) == 25
assert find_median([5, 3, 8, 1]) == 4
def test_proces... | [
{
"docstring": "Returns the median of a given sequence of integers.",
"function_declaration": "def find_median(sequence):",
"function_name": "find_median",
"parameter_list": "(sequence)"
},
{
"docstring": "Processes multiple lines of integer sequences and returns the medians.",
"function... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def calculate_median(seq):\n \"\"\"\n Calculate the median of a list of integers.\n \"\"\"\n seq.sort()\n n = len(seq)\n if n % 2 == 1:\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00023761",
"row_id": 23761,
"seed_ids": "[1092]"
} | 0.690412 | Taco_23761 | I | [
"find_median",
"process_sequences"
] | 2 | [
[
"process_sequences",
"find_median"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | ea1d4ca62089d5c84856c1fa1d0aea46bcaf8f2f | 666cbc49353fc9be98c5fdcaed83a0e427e8ba87 | |||
v1.0 | instruct | Taco | Taco_23791_I | You are given a binary tree of N nodes. Each node of the tree contains a positive integer value. You need to perform the following task:
1. Find all possible paths from the root to leaf nodes.
2. For each path, compute the sum of the values of the nodes in the path.
Your task is to return the number of distinct sums ... | class TreeNode:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def handle_input_to_tree(N, values, edges):
if N == 0:
return None
nodes = {i + 1: TreeNode(val) for i, val in enumerate(values)}
for u, v in edges:
if not node... | def test_handle_input_to_tree():
# Test the helper function to construct the binary tree from input data
N = 5
values = [1, 2, 3, 4, 5]
edges = [(1, 2), (1, 3), (2, 4), (2, 5)]
root = handle_input_to_tree(N, values, edges)
assert root.value == 1
assert root.left.value == 2
asse... | [] | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, value=0, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\ndef b... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00023791",
"row_id": 23791,
"seed_ids": "[16706]"
} | 0.709386 | Taco_23791 | I | [
"handle_input_to_tree",
"get_all_paths_sums",
"count_distinct_path_sums"
] | 3 | [
[
"count_distinct_path_sums",
"get_all_paths_sums"
],
[
"count_distinct_path_sums",
"handle_input_to_tree"
]
] | 2 | [] | false | [
"TreeNode"
] | true | pytest | false | [] | true | e2993514eff7e9186d80bde6697378d994f30377 | f9f5df4ef6db73092e48689f1b8ee3088a84d5d9 | |||
v1.0 | instruct | Taco | Taco_23818_I | You are given a grid with $m$ rows and $n$ columns. Each cell in the grid contains a positive integer value. You want to find a subgrid (a rectangular part of the grid) such that the sum of the integers within it is as large as possible.
Note that the subgrid must be at least $1 \times 1$ in size, and you can choose ... | def max_sum_subgrid(grid):
"""
Given a grid of positive integers, return the largest sum of any subgrid.
"""
m = len(grid)
n = len(grid[0])
max_sum = -float('inf')
for top_row in range(m):
row_sum = [0] * n
for bottom_row in range(top_row, m):
for col in... | def test_largest_sum_subgrid_case1():
grid = [
[1, 2, 3],
[4, 5, 6]
]
assert max_sum_subgrid(grid) == 21
def test_largest_sum_subgrid_case2():
grid = [
[1, 1, 1],
[1, 1, 1],
[1, 1, 1]
]
assert max_sum_subgrid(grid) == 9
def test_largest_sum_subgrid_case3... | [
{
"docstring": "Given a grid of positive integers, return the largest sum of any subgrid.",
"function_declaration": "def max_sum_subgrid(grid):",
"function_name": "max_sum_subgrid",
"parameter_list": "(grid)"
},
{
"docstring": "Helper function to find the maximum sum subarray using Kadane's ... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_sum_subgrid(m, n, grid):\n def kadane(arr):\n max_sum = current_sum = arr[0]\n for num in arr[1:]:\n current_sum = max(num, cur... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00023818",
"row_id": 23818,
"seed_ids": "[8406]"
} | 0.665713 | Taco_23818 | I | [
"max_sum_subgrid",
"kadane"
] | 2 | [
[
"max_sum_subgrid",
"kadane"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 7c30e75fe410ff81b8d964bf59c1870545a479ee | 5e7e423ea23ea79bfa9d36da710d44c2d726dae1 | |||
v1.0 | instruct | Taco | Taco_23895_I | Your small community organizes a network of volunteers who assist with delivering groceries to those unable to venture out, particularly focusing on elderly individuals and those with disabilities. Each volunteer is responsible for delivering to specific areas within the community, and each area has a list of household... | from itertools import combinations
def parse_input(M, areas_info, V, volunteer_info):
areas = {} # Dictionary to store areas and their households
volunteers = {} # Dictionary to store volunteers and their coverage
for area_info in areas_info:
parts = area_info.split()
area_name = par... | def test_parse_input():
M = 2
areas_info = ["Area1 1 2 3", "Area2 2 4"]
V = 1
volunteer_info = ["Vol1 Area1 Area2"]
areas, volunteers = parse_input(M, areas_info, V, volunteer_info)
assert areas == {"Area1": {1, 2, 3}, "Area2": {2, 4}}
assert volunteers == {"Vol1": ["Area1", "Area2"]}
def t... | [
{
"docstring": null,
"function_declaration": "def parse_input(M, areas_info, V, volunteer_info):",
"function_name": "parse_input",
"parameter_list": "(M, areas_info, V, volunteer_info)"
},
{
"docstring": null,
"function_declaration": "def max_unique_households(M, areas_info, V, volunteer... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from itertools import combinations\nfrom typing import List, Dict, Set\n\ndef max_unique_households_covered(area_data: List[str], volunteer_data: List[str]) -> int... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00023895",
"row_id": 23895,
"seed_ids": "[10067]"
} | 0.642283 | Taco_23895 | I | [
"parse_input",
"max_unique_households"
] | 2 | [
[
"max_unique_households",
"parse_input"
]
] | 1 | [
"parse_input"
] | false | [] | false | pytest | false | [] | true | 31e0350afd2675bb4a153f814bab3317108e576f | bd0de69e47c923404bcec9abebbfbe05f37cb5c0 | |||
v1.0 | instruct | Taco | Taco_23952_I | Lily has a directed graph with N nodes and M edges. Each edge has a weight associated with it. Lily wants to find the longest path in the graph that doesn't revisit any node. The graph may contain cycles.
Constraints
* 1 \leq N \leq 1000
* 0 \leq M \leq 5000
* 1 \leq weight of each edge \leq 1000
Input
Input is giv... | from collections import defaultdict, deque
def longest_path_dag(N, M, edges):
# Construct the adjacency list
graph = defaultdict(list)
indegree = [0] * (N + 1)
for u, v, w in edges:
graph[u].append((v, w))
indegree[v] += 1
# Topological Sort using Kahn's Algorithm
topo_sort = [... | def test_longest_path_dag():
# Test Case 1
N, M = 4, 4
edges = [(1, 2, 3), (2, 3, 4), (3, 4, 5), (1, 3, 2)]
assert longest_path_dag(N, M, edges) == 12
# Test Case 2
N, M = 3, 2
edges = [(1, 2, 5), (2, 3, 7)]
assert longest_path_dag(N, M, edges) == 12
# Test Case 3
N, M = 3,... | [
{
"docstring": null,
"function_declaration": "def longest_path_dag(N, M, edges):",
"function_name": "longest_path_dag",
"parameter_list": "(N, M, edges)"
},
{
"docstring": null,
"function_declaration": "def solve():",
"function_name": "solve",
"parameter_list": "()"
}
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import defaultdict, deque\nimport sys\n\ndef longest_path(N, M, edges):\n def topological_sort():\n in_degree = [0] * (N + 1)\n f... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00023952",
"row_id": 23952,
"seed_ids": "[11031]"
} | 0.676588 | Taco_23952 | I | [
"longest_path_dag",
"solve"
] | 2 | [
[
"solve",
"longest_path_dag"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | e56567da20718c0db32064f05ab67684f59ad3ee | 858fc710047064046b292078235d8572f4d7b56b | |||
v1.0 | instruct | Taco | Taco_23970_I | Dreamoon has a new challenge for his zoo management program. He manages a zoo where the animals are categorized by their species and age. Given a list of species and the ages of animals from each species, Dreamoon wants to construct a binary tree for each species where each node represents an animal and contains the ag... | from collections import defaultdict
class Node:
def __init__(self, age):
self.age = age
self.left = None
self.right = None
def insert_node(root, age):
if root is None:
return Node(age)
else:
if age < root.age:
root.left = insert_node(root.left, age)
... | from solution import manage_zoo
def test_manage_zoo_case_1():
n = 6
animal_data = [
"lion 5",
"tiger 3",
"lion 3",
"elephant 7",
"tiger 2",
"lion 9"
]
output = manage_zoo(n, animal_data)
expected_output = ["lion", "5 3 9", "tiger", "3 2", "elephant", ... | [] | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, age):\n self.age = age\n self.left = None\n self.right = None\n\ndef insert(root, age):\n if root i... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00023970",
"row_id": 23970,
"seed_ids": "[10425]"
} | 0.538004 | Taco_23970 | I | [
"insert_node",
"pre_order_traversal",
"build_and_traverse_bst",
"manage_zoo"
] | 4 | [
[
"build_and_traverse_bst",
"insert_node"
],
[
"build_and_traverse_bst",
"pre_order_traversal"
],
[
"manage_zoo",
"build_and_traverse_bst"
]
] | 3 | [] | false | [
"Node"
] | true | pytest | true | [] | true | b62cd5b4c61436fe44cf54a760f5e52c506e718c | 71c913247847f051fac4a15fb1c6b11573851a9c | |||
v1.0 | instruct | Taco | Taco_24015_I | **Problem Description:**
In the world of competitive programming, efficiency is key. One frequently encountered operation is finding the sum of elements within a specific range in an array. Given the rapid pace required during contests, doing this repeatedly through brute force can be too slow. Instead, we seek a more... | def preprocess_prefix_sums(arr):
"""
This function preprocesses the given array into a prefix sum array for efficient range sum queries.
"""
n = len(arr)
prefix_sums = [0] * n
prefix_sums[0] = arr[0]
for i in range(1, n):
prefix_sums[i] = prefix_sums[i - 1] + arr[i]
ret... | from solution import range_sum_queries
def test_example():
arr = [3, 1, 4, 1, 5]
queries = [(0, 2), (1, 3), (0, 4)]
assert range_sum_queries(arr, queries) == [8, 6, 14]
def test_single_element_array():
arr = [5]
queries = [(0, 0)]
assert range_sum_queries(arr, queries) == [5]
def test_identic... | [
{
"docstring": "This function preprocesses the given array into a prefix sum array for efficient range sum queries.",
"function_declaration": "def preprocess_prefix_sums(arr):",
"function_name": "preprocess_prefix_sums",
"parameter_list": "(arr)"
},
{
"docstring": "This function uses the pre... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def preprocess_prefix_sums(arr):\n \"\"\"\n Given an array, preprocess the prefix sums.\n \"\"\"\n prefix_sums = [0] * len(arr)\n prefix_sums[0] = a... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024015",
"row_id": 24015,
"seed_ids": "[651]"
} | 0.622029 | Taco_24015 | I | [
"preprocess_prefix_sums",
"range_sum_queries"
] | 2 | [
[
"range_sum_queries",
"preprocess_prefix_sums"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | f782104ba6ee549013beed28d9e6d8c0c34e2f1e | c13a23fc21f10d1674c1358624e60b7271ce5dc7 | |||
v1.0 | instruct | Taco | Taco_24039_I | Alice loves playing with numbers, especially prime numbers. She recently came up with a challenge to find the smallest prime number greater than a given input number 'n'. Write a program to help Alice out. The program should take an integer input 'n' and return the smallest prime number that is greater than 'n'.
Input... | def is_prime(num):
"""
Helper function to check if a number is prime.
"""
if num <= 1:
return False
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while (i * i) <= num:
if num % i == 0 or num % (i + 2) == 0:
return... | from solution import is_prime, next_prime
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(11) == True
assert is_prime(15) == False
def test_next_prime():
assert next_prime(10) == 11
assert next_prime(11) == 13
asser... | [
{
"docstring": "Helper function to check if a number is prime.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Returns the smallest prime number greater than n.",
"function_declaration": "def next_prime(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(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024039",
"row_id": 24039,
"seed_ids": "[24752]"
} | 0.55409 | Taco_24039 | I | [
"is_prime",
"next_prime"
] | 2 | [
[
"next_prime",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | fe8b13d6e32d5f1b1eb51197918d57e1c3d0161a | 9a47e14d52f61d4d4f7bcd3b8ead1225d1103b25 | |||
v1.0 | instruct | Taco | Taco_24054_I | You have been tasked with developing a function to analyze a list of integers and determine which of them are "prime". A prime number is a number greater than 1 that has no positive divisors other than 1 and itself. Given a list of integers, your function should return a new list containing only the prime numbers from ... | import math
def is_prime(n):
"""
Checks if a number n 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... | from solution import filterPrimes
def test_filterPrimes_all_prime():
assert filterPrimes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11]
def test_filterPrimes_no_prime():
assert filterPrimes([1, 4, 6, 8, 9, 10]) == []
def test_filterPrimes_mixed():
assert filterPrimes([10, 17, 18, 19, 20]) == [17, 19]
assert f... | [
{
"docstring": "Checks if a number n is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Filters a list of integers to return only the prime numbers.\n\n:param numbers: List of integers\n:return: List of prime intege... | [
1,
1
] | 2 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef is_prime(n):\n \"\"\"\n Checks if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return T... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00024054",
"row_id": 24054,
"seed_ids": "[13579]"
} | 0.662139 | Taco_24054 | I | [
"is_prime",
"filterPrimes"
] | 2 | [
[
"filterPrimes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 75a0ee814ae675f795036e58ab144ab3aaf63848 | f25eb254b8b3fb80f3dd3dc73b8cf824132e7243 | |||
v1.0 | instruct | Taco | Taco_24090_I | Write a program to simulate a simple social network by reading a list of friendships and then processing queries to determine the degrees of separation between users.
Constraints
* $2 \leq n \leq 200$ (number of users)
* $1 \leq m \leq 10^4$ (number of friendships)
Input
- The first line contains two integers $n$ a... | from collections import deque, defaultdict
def build_graph(friendships, n):
graph = defaultdict(list)
for u, v in friendships:
graph[u].append(v)
graph[v].append(u)
return graph
def bfs_shortest_path(graph, start, goal):
if start == goal:
return 0
visited = set()
q... | from solution import degrees_of_separation
def test_degrees_of_separation():
n, m = 5, 4
friendships = [(1, 2), (2, 3), (3, 4), (4, 5)]
q = 3
queries = [(1, 5), (1, 3), (2, 5)]
expected_output = [4, 2, 3]
assert degrees_of_separation(n, m, friendships, q, queries) == expected_output
def t... | [
{
"docstring": null,
"function_declaration": "def build_graph(friendships, n):",
"function_name": "build_graph",
"parameter_list": "(friendships, n)"
},
{
"docstring": null,
"function_declaration": "def bfs_shortest_path(graph, start, goal):",
"function_name": "bfs_shortest_path",
... | [
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 deque, defaultdict\n\ndef bfs_degree_of_separation(n, friendships, queries):\n graph = defaultdict(list)\n for u, v in friendships:\n... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024090",
"row_id": 24090,
"seed_ids": "[18887]"
} | 0.694188 | Taco_24090 | I | [
"build_graph",
"bfs_shortest_path",
"degrees_of_separation"
] | 3 | [
[
"degrees_of_separation",
"bfs_shortest_path"
],
[
"degrees_of_separation",
"build_graph"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | f4acc0a97003690652bda0390cfe1f9aec89ae1d | 199c18cb2073a3237038f505b64dc0a37832071f | |||
v1.0 | instruct | Taco | Taco_24096_I | A city is planning to build a series of watchtowers on strategic hilltops for surveillance. Each hilltop is represented by a node, and there are possible paths (edges) between the hilltops. The city needs to place a specific number of watchtowers such that the surveillance area is maximized, which essentially means max... | from collections import deque
def bfs(graph, start, r):
"""
Perform BFS and return nodes covered within range limit `r` starting from `start` node.
"""
visited = set()
queue = deque([(start, 0)])
visited.add(start)
while queue:
current, dist = queue.popleft()
if dist < ... | from solution import hilltops_surveillance
def test_example_case():
n = 6
m = 7
edges = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (4, 5), (5, 6)]
k = 3
r = 1
assert hilltops_surveillance(n, m, edges, k, r) == 6
def test_single_node():
n = 1
m = 0
edges = []
k = 1
r = 1
a... | [
{
"docstring": "Perform BFS and return nodes covered within range limit `r` starting from `start` node.",
"function_declaration": "def bfs(graph, start, r):",
"function_name": "bfs",
"parameter_list": "(graph, start, r)"
},
{
"docstring": "Returns the maximum number of hilltops that can be m... | [
0,
0,
0,
0,
1
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque, defaultdict\n\ndef max_monitored_hilltops(n, m, paths, k, r):\n # Convert the list of paths into an adjacency list\n graph = d... | trial_gpt4o_4 | {
"original_instruction": "",
"prompt_id": "00024096",
"row_id": 24096,
"seed_ids": "[16337]"
} | 0.649165 | Taco_24096 | I | [
"bfs",
"hilltops_surveillance"
] | 2 | [
[
"hilltops_surveillance",
"bfs"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 307e342d2926da063e085540e3008326556058df | 3e33248f3f559af6050a51f35aabec95e388c90a | |||
v1.0 | instruct | Taco | Taco_24146_I | You are given a sequence of n integers. A "peak" is an element which is greater than its immediate neighbors. Similarly, a "valley" is an element which is smaller than its immediate neighbors. You are allowed to modify the sequence by changing any element to any value. The goal is to minimize the number of peaks and va... | def find_peaks_and_valleys(arr):
peaks_valleys = []
for i in range(1, len(arr) - 1):
if (arr[i] > arr[i - 1] and arr[i] > arr[i + 1]) or (arr[i] < arr[i - 1] and arr[i] < arr[i + 1]):
peaks_valleys.append(i)
return peaks_valleys
def count_peaks_and_valleys(arr):
count = 0
for i ... | import pytest
from solution import min_peaks_and_valleys
def test_min_peaks_and_valleys_example_1():
assert min_peaks_and_valleys(5, [1, 3, 2, 4, 5]) == 0
def test_min_peaks_and_valleys_example_2():
assert min_peaks_and_valleys(7, [10, 5, 3, 7, 2, 9, 8]) == 1
def test_min_peaks_and_valleys_example_3():
a... | [
{
"docstring": null,
"function_declaration": "def find_peaks_and_valleys(arr):",
"function_name": "find_peaks_and_valleys",
"parameter_list": "(arr)"
},
{
"docstring": null,
"function_declaration": "def count_peaks_and_valleys(arr):",
"function_name": "count_peaks_and_valleys",
"... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_peaks_and_valleys(arr):\n peaks_valleys = []\n for i in range(1, len(arr) - 1):\n if (arr[i] > arr[i - 1] and arr[i] > arr[i + 1]) or (arr[i]... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00024146",
"row_id": 24146,
"seed_ids": "[15081]"
} | 0.712534 | Taco_24146 | I | [
"find_peaks_and_valleys",
"count_peaks_and_valleys",
"min_peaks_and_valleys"
] | 3 | [
[
"min_peaks_and_valleys",
"count_peaks_and_valleys"
],
[
"min_peaks_and_valleys",
"find_peaks_and_valleys"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 4ec329bcd51602b16fcef9c8db0faefd1dcdf2c2 | c7073f30dbd983b3c413fd5947fab444c50af842 | |||
v1.0 | instruct | Taco | Taco_24163_I | You are given a rectangular grid representing a map where 'S' denotes the starting point, 'E' represents the endpoint, and '.' represents a path. All other characters represent obstacles. The objective is to find a path from the starting point 'S' to the endpoint 'E' such that a person travels only through '.' without ... | from collections import deque
def path_exists(grid, R, C):
"""
Determines if there is a path from 'S' to 'E' in the given grid.
Parameters:
grid (list of list of str): The grid representing the map.
R (int): Number of rows in the grid.
C (int): Number of columns in the grid.
Retur... | def test_find_path_case_1():
R = 4
C = 4
lines = [
"S..#",
".#.#",
".#.E",
"####"
]
assert find_path(R, C, lines) == "YES"
def test_find_path_case_2():
R = 3
C = 3
lines = [
"S#.",
"###",
".#E"
]
assert find_path(R, C, line... | [
{
"docstring": "Determines if there is a path from 'S' to 'E' in the given grid.\n\nParameters:\ngrid (list of list of str): The grid representing the map.\nR (int): Number of rows in the grid.\nC (int): Number of columns in the grid.\n\nReturns:\nstr: \"YES\" if a path exists, otherwise \"NO\".",
"function... | [
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_path_exists(R, C, grid):\n from collections import deque\n\n def get_neighbors(x, y):\n for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1)]:\n ... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00024163",
"row_id": 24163,
"seed_ids": "[20572]"
} | 0.726843 | Taco_24163 | I | [
"path_exists",
"find_path"
] | 2 | [
[
"find_path",
"path_exists"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | dfd4ff929f1ccb19ef05a77356adaa2eafd744ba | 235d6d0d7e48fb375bdf2e7e82be80ba489b040a | |||
v1.0 | instruct | Taco | Taco_24200_I | A group of friends have decided to organize a small team programming contest. For the contest, they've decided to use an algorithm to pair up the participants based on their skill levels to make the teams as balanced as possible. The skill level of each participant is represented as an integer.
They will be forming ex... | def min_partition_difference(skill_levels):
"""
Function to find the minimum difference between two partitions of skill_levels.
Args:
skill_levels (list of int): List of skill levels of participants.
Returns:
int: Minimum possible difference in the sum of skill levels between two groups.
... | from solution import min_partition_difference, minimal_diff_of_partitions
def test_min_partition_difference_example():
assert min_partition_difference([3, 1, 4, 2]) == 0
def test_min_partition_difference_small_diff():
assert min_partition_difference([10, 11, 23, 20]) == 2
def test_min_partition_differenc... | [
{
"docstring": "Function to find the minimum difference between two partitions of skill_levels.\n\nArgs:\nskill_levels (list of int): List of skill levels of participants.\n\nReturns:\nint: Minimum possible difference in the sum of skill levels between two groups.",
"function_declaration": "def min_partitio... | [
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 min_partition_difference(N, skills):\n from itertools import combinations\n \n total_sum = sum(skills)\n min_diff = float('inf')\n \n for i i... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024200",
"row_id": 24200,
"seed_ids": "[22591]"
} | 0.726932 | Taco_24200 | I | [
"min_partition_difference",
"minimal_diff_of_partitions"
] | 2 | [
[
"minimal_diff_of_partitions",
"min_partition_difference"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | fe3ecf85787c1bfe06afadc18494787f6ee68146 | eed307999dbeccf608112847485baa8ee6ddbcf5 | |||
v1.0 | instruct | Taco | Taco_24221_I | Treehouse is a popular recreational development located in the center of a large natural reserve. To better cater to visitors, the management has decided to build a series of bridges that connect the various treehouses. The objective is to ensure that visitors can travel between any two treehouses using the fewest numb... | def find(parent, i):
if parent[i] == i:
return i
return find(parent, parent[i])
def union(parent, rank, x, y):
root_x = find(parent, x)
root_y = find(parent, y)
if rank[root_x] < rank[root_y]:
parent[root_x] = root_y
elif rank[root_x] > rank[root_y]:
parent[root_y] ... | from solution import minimal_bridges
def test_minimal_bridges_case1():
edges = [
(1, 2, 1),
(2, 3, 4),
(1, 3, 2),
(3, 4, 3)
]
assert minimal_bridges(4, edges) == 6
def test_minimal_bridges_case2():
edges = [
(1, 2, 1),
(1, 3, 3),
(4, 2, 2),
... | [
{
"docstring": null,
"function_declaration": "def find(parent, i):",
"function_name": "find",
"parameter_list": "(parent, i)"
},
{
"docstring": null,
"function_declaration": "def union(parent, rank, x, y):",
"function_name": "union",
"parameter_list": "(parent, rank, x, y)"
},
... | [
0,
0,
0,
1,
1
] | 2 | medium | 0.4 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class UnionFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.rank = [0] * n\n\n def find(self, u):\n if self.parent[u... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00024221",
"row_id": 24221,
"seed_ids": "[12388]"
} | 0.751428 | Taco_24221 | I | [
"find",
"union",
"minimal_total_length",
"minimal_bridges"
] | 4 | [
[
"minimal_bridges",
"minimal_total_length"
],
[
"minimal_total_length",
"find"
],
[
"minimal_total_length",
"union"
],
[
"union",
"find"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | 0ab2c28d34b651860c92d0c54677603442381988 | eea26646614de5ea2cac3a1681060be0be2550b7 | |||
v1.0 | instruct | Taco | Taco_24282_I | You're given an undirected weighted graph with n nodes and m edges. Each edge has a weight associated with it. The graph may contain cycles.
Write a program to find the weight of the maximum spanning tree of the graph. A maximum spanning tree is a spanning tree having maximum total edge weight.
-----Input-----
The ... | def find(parent, i):
if parent[i] == i:
return i
else:
return find(parent, parent[i])
def union(parent, rank, x, y):
xroot = find(parent, x)
yroot = find(parent, y)
if rank[xroot] < rank[yroot]:
parent[xroot] = yroot
elif rank[xroot] > rank[yroot]:
parent[yroot]... | def test_max_spanning_tree():
input_lines = "4 5\n1 2 3\n1 3 2\n2 3 4\n2 4 1\n3 4 5"
assert read_input_and_calculate_mst(input_lines) == 12
def test_no_edges():
input_lines = "1 0"
assert read_input_and_calculate_mst(input_lines) == 0
def test_two_nodes_one_edge():
input_lines = "2 1\n1 2 10"
... | [
{
"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": "def find_maximum_spanning_tree(n, edges):\n \"\"\"\n Returns the weight of the maximum spanning tree of a graph using Kruskal's algorithm.\n \n n: Numb... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00024282",
"row_id": 24282,
"seed_ids": "[9625]"
} | 0.751165 | Taco_24282 | I | [
"find",
"union",
"max_spanning_tree",
"read_input_and_calculate_mst"
] | 4 | [
[
"max_spanning_tree",
"find"
],
[
"max_spanning_tree",
"union"
],
[
"read_input_and_calculate_mst",
"max_spanning_tree"
],
[
"union",
"find"
]
] | 4 | [] | false | [] | false | pytest | false | [] | true | c866b1ed0a8497a8cc73e6ba0f82e1079d2711e8 | 570ca4728f6e023be33bb011fc67648c23f8bcdb | |||
v1.0 | instruct | Taco | Taco_24321_I | Farah is teaching her students about string manipulation and palindrome checking. She created a fun game and wants to test her students' coding skills with this game. The rules of the game are as follows:
Farah writes down a string $S$ of length $N$ consisting of lowercase English letters. She then challenges her stud... | def rotate_substring(s, L, R, K):
"""
Rotates the substring s[L:R+1] to the right by K positions
"""
L -= 1
R -= 1
K %= (R - L + 1) # Adjust K to make sure it is within the length of the substring
rotated_part = s[L:R+1][-K:] + s[L:R+1][:-K]
return s[:L] + rotated_part + s[R+1:]
def is... | from solution import palindrome_game
def test_palindrome_game():
# Given example test cases
T = 2
test_cases = [
(5, "abcde", 2, [(1, 3, 1), (2, 5, 2)]), # After all rotations -> "cbdae" -> NOT a palindrome -> "NO"
(3, "aab", 1, [(1, 3, 2)]) # After all rotations -> "baa" -> a palindrome... | [
{
"docstring": "Rotates the substring s[L:R+1] to the right by K positions",
"function_declaration": "def rotate_substring(s, L, R, K):",
"function_name": "rotate_substring",
"parameter_list": "(s, L, R, K)"
},
{
"docstring": "Checks if the given string s is a palindrome",
"function_decl... | [
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 perform_rotation(S, L, R, K):\n # Convert 1-based indices to 0-based\n L -= 1\n R -= 1\n # Extract substring to be rotated\n sub_str = S[L:R + 1... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024321",
"row_id": 24321,
"seed_ids": "[18973]"
} | 0.783969 | Taco_24321 | I | [
"rotate_substring",
"is_palindrome",
"palindrome_game"
] | 3 | [
[
"palindrome_game",
"is_palindrome"
],
[
"palindrome_game",
"rotate_substring"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | afde271010817527be3a4488588fc3708f5fdf3e | d2a9e1f64d9a14049d4b99ffbcc5a2aa78460884 | |||
v1.0 | instruct | Taco | Taco_24327_I | Chef has an array $A$ containing $N$ distinct integers. Chef also has another array $B$ of the same length $N$, with each element either 0 or 1, representing the state of corresponding element in $A$. If $B[i] = 1$, the element $A[i]$ is considered 'active'; otherwise, the element $A[i]$ is 'inactive'.
Chef wants to p... | def activate_element(B, i):
"""
Activate the element at index i in the array B.
"""
B[i-1] = 1
def deactivate_element(B, i):
"""
Deactivate the element at index i in the array B.
"""
B[i-1] = 0
def range_sum(A, B, l, r):
"""
Compute the sum of all active elements in the range [... | def test_activate_element():
B = [0, 0, 0]
activate_element(B, 1)
assert B == [1, 0, 0]
activate_element(B, 3)
assert B == [1, 0, 1]
def test_deactivate_element():
B = [1, 1, 1]
deactivate_element(B, 2)
assert B == [1, 0, 1]
deactivate_element(B, 3)
assert B == [1, 0, 0]
... | [
{
"docstring": "Activate the element at index i in the array B.",
"function_declaration": "def activate_element(B, i):",
"function_name": "activate_element",
"parameter_list": "(B, i)"
},
{
"docstring": "Deactivate the element at index i in the array B.",
"function_declaration": "def dea... | [
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 perform_operations(N, A, B, queries):\n results = []\n active_prefix_sum = [0] * (N + 1)\n \n # Initial calculation of prefix sums for active eleme... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024327",
"row_id": 24327,
"seed_ids": "[15310]"
} | 0.594068 | Taco_24327 | I | [
"activate_element",
"deactivate_element",
"range_sum",
"process_queries"
] | 4 | [
[
"process_queries",
"activate_element"
],
[
"process_queries",
"deactivate_element"
],
[
"process_queries",
"range_sum"
]
] | 3 | [
"process_queries"
] | false | [] | false | pytest | false | [] | true | 6b4ea98a04d986284ac0ebdc36a0c94c2f97e935 | 525faaa7431ca03c83202341bb0b23c657f3d5fa | |||
v1.0 | instruct | Taco | Taco_24340_I | In this exercise, you need to create a function called **level_checker** that will take a dictionary of names and their corresponding levels as input. Each level is represented as an integer. The task is to assess the average level of the names whose levels are prime numbers and return the average level rounded to the ... | 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 level_check... | from solution import level_checker
def test_level_checker_with_prime_levels():
assert level_checker({"Alice": 2, "Bob": 4, "Charlie": 5, "David": 9, "Eve": 11}) == 6
def test_level_checker_without_prime_levels():
assert level_checker({"Anna": 8, "Ben": 10, "Cara": 15, "Dani": 20}) == 0
def test_level_checker... | [
{
"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 average level (rounded to the nearest integer) of names whose levels are prime numbers.\nIf there... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Determines if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00024340",
"row_id": 24340,
"seed_ids": "[18228]"
} | 0.573193 | Taco_24340 | I | [
"is_prime",
"level_checker"
] | 2 | [
[
"level_checker",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e3764bcc44b25f8353484ed8bc9258bbfb813f77 | 3582b3c370ece11981136d57f1b5d717e910e81c | |||
v1.0 | instruct | Taco | Taco_24406_I | Luke is training a team of developers for a coding competition. He has a sequence of strings, each string representing a problem where each character denotes the difficulty of a specific subtask ('a' being the easiest and 'z' the hardest).
Luke wants to ensure that the developers practice on problems with increasing d... | def is_suitable_problem(problem):
"""
Determines if a given problem string is suitable for practice.
A problem string is suitable if characters are unique and in strictly increasing order.
"""
return list(problem) == sorted(problem) and len(set(problem)) == len(problem)
def check_problems(t, pr... | from solution import is_suitable_problem, check_problems
def test_is_suitable_problem():
assert is_suitable_problem("abc") == True
assert is_suitable_problem("acb") == False
assert is_suitable_problem("aaa") == False
assert is_suitable_problem("def") == True
assert is_suitable_problem("xyz") == Tru... | [
{
"docstring": "Determines if a given problem string is suitable for practice.\nA problem string is suitable if characters are unique and in strictly increasing order.",
"function_declaration": "def is_suitable_problem(problem):",
"function_name": "is_suitable_problem",
"parameter_list": "(problem)"... | [
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_suitable_problem_string(p):\n \"\"\"\n Determines if the problem string is suitable for practice.\n A string is suitable if it contains no duplicat... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00024406",
"row_id": 24406,
"seed_ids": "[4426]"
} | 0.696809 | Taco_24406 | I | [
"is_suitable_problem",
"check_problems"
] | 2 | [
[
"check_problems",
"is_suitable_problem"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c4dd20b0ef9637bc7814d14c8eb8cfd8a158f508 | 724b37f851482fcf9834005d580231dbe5444058 | |||
v1.0 | instruct | Taco | Taco_24425_I | You are given an n x n grid of cells filled with different integers. Your task is to identify if there exists a "magic square" of size 3x3 within this grid. A "magic square" is a 3x3 grid where every row, column, and both diagonals all sum to the same value.
Input
The first line contains an integer n (3 ≤ n ≤ 50) — t... | def is_magic_square(matrix, row, col):
"""
Helper function to check if a 3x3 grid with top-left corner at (row, col)
is a magic square.
"""
s = set()
# Sum of the first row
magic_sum = sum(matrix[row][col:col+3])
for i in range(3):
if sum(matrix[row+i][col:col+3]) != magic_s... | from solution import contains_magic_square
def test_magic_square_1():
grid = [
[4, 9, 2, 3],
[3, 5, 7, 8],
[8, 1, 6, 3],
[2, 7, 6, 9]
]
assert contains_magic_square(grid) == "YES"
def test_magic_square_2():
grid = [
[4, 8, 2, 4, 9],
[3, 5, 7, 23, 5],
... | [
{
"docstring": "Helper function to check if a 3x3 grid with top-left corner at (row, col)\nis a magic square.",
"function_declaration": "def is_magic_square(matrix, row, col):",
"function_name": "is_magic_square",
"parameter_list": "(matrix, row, col)"
},
{
"docstring": "Returns \"YES\" if t... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_magic_square(grid, row, col):\n \"\"\"\n Check if the 3x3 grid starting at (row, col) is a magic square.\n \"\"\"\n target_sum = grid[row][col] ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024425",
"row_id": 24425,
"seed_ids": "[913]"
} | 0.69799 | Taco_24425 | I | [
"is_magic_square",
"contains_magic_square"
] | 2 | [
[
"contains_magic_square",
"is_magic_square"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 5fb0d2c8ccba992a602f1409bf22998f6e5be7c7 | b4af701d43fab4df711d6d52e81457c510a6deef | |||
v1.0 | instruct | Taco | Taco_24452_I | Dmitry has a large rectangular garden which he wants to divide into smaller rectangular plots. Each plot should have an equal area and should be as large as possible. To achieve this, Dmitry needs to find the largest possible integer area for each of the smaller plots that the garden can be divided into.
Given the dim... | def gcd(a, b):
while b:
a, b = b, a % b
return a
def max_plot_area(m, n):
greatest_common_divisor = gcd(m, n)
return greatest_common_divisor ** 2
def solve_garden_division(test_cases):
results = []
for m, n in test_cases:
results.append(max_plot_area(m, n))
return results | from solution import gcd, max_plot_area, solve_garden_division
def test_gcd():
assert gcd(6, 9) == 3
assert gcd(12, 15) == 3
assert gcd(24, 36) == 12
assert gcd(7, 3) == 1
assert gcd(100, 1000) == 100
def test_max_plot_area():
assert max_plot_area(6, 9) == 9
assert max_plot_area(12, 15) ==... | [
{
"docstring": null,
"function_declaration": "def gcd(a, b):",
"function_name": "gcd",
"parameter_list": "(a, b)"
},
{
"docstring": null,
"function_declaration": "def max_plot_area(m, n):",
"function_name": "max_plot_area",
"parameter_list": "(m, n)"
},
{
"docstring": nul... | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
1
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from math import gcd\n\ndef max_plot_area(test_cases):\n results = []\n for m, n in test_cases:\n # Calculate the greatest common divisor of m and n\n... | trial_gpt4o_5 | {
"original_instruction": "",
"prompt_id": "00024452",
"row_id": 24452,
"seed_ids": "[21435]"
} | 0.715701 | Taco_24452 | I | [
"gcd",
"max_plot_area",
"solve_garden_division"
] | 3 | [
[
"max_plot_area",
"gcd"
],
[
"solve_garden_division",
"max_plot_area"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 7c71e45e0d4989cd06cf4b9bf12c44696ce162a0 | 50c4b9c23b2f6ca74e4fc329e0ef4e1a7c06cbe5 | |||
v1.0 | instruct | Taco | Taco_24486_I | problem
Consider a grid of size $N \times M$. Each cell in the grid can either be empty or occupied by a block. You are required to find the largest rectangle composed entirely of empty cells. The rectangle must be aligned with the grid (no diagonal rectangles) and can be of any size.
### Input
- The first line conta... | def max_histogram_area(histogram):
"""
Finds the largest rectangular area possible in a given histogram
where the width of each bar is 1.
"""
stack = []
max_area = 0
index = 0
while index < len(histogram):
if not stack or histogram[stack[-1]] <= histogram[index]:
... | from solution import largest_empty_rectangle
def test_largest_empty_rectangle():
N = 5
M = 6
grid = [
"......",
".##...",
".#....",
"....#.",
"....##"
]
assert largest_empty_rectangle(N, M, grid) == 9
N = 4
M = 4
grid = [
"####",
... | [
{
"docstring": "Finds the largest rectangular area possible in a given histogram\nwhere the width of each bar is 1.",
"function_declaration": "def max_histogram_area(histogram):",
"function_name": "max_histogram_area",
"parameter_list": "(histogram)"
},
{
"docstring": "Returns the area of th... | [
1,
1
] | 2 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_histogram_area(histogram):\n \"\"\"\n Finds the largest rectangular area possible in a given histogram\n where the width of each bar is 1.\n \"... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00024486",
"row_id": 24486,
"seed_ids": "[6848]"
} | 0.675687 | Taco_24486 | I | [
"max_histogram_area",
"largest_rectangle_area",
"largest_empty_rectangle"
] | 3 | [
[
"largest_empty_rectangle",
"largest_rectangle_area"
],
[
"largest_rectangle_area",
"max_histogram_area"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 160464a71833fd4d85de30ecee82b8929bc1026c | 9a2786ff40e8c2f68b0d4959764237bd0a2f58ca | |||
v1.0 | instruct | Taco | Taco_24503_I | Shannon is fascinated by sequences and their properties. She recently learned about the Fibonacci sequence and wants to explore it further. The Fibonacci sequence is defined as:
- F(0) = 0
- F(1) = 1
- F(n) = F(n-1) + F(n-2) for n >= 2
Shannon is interested in the large Fibonacci numbers, and she wants to know the sum... | def matrix_mult(A, B):
"""
Multiplies two matrices A and B.
"""
return [
[A[0][0] * B[0][0] + A[0][1] * B[1][0], A[0][0] * B[0][1] + A[0][1] * B[1][1]],
[A[1][0] * B[0][0] + A[1][1] * B[1][0], A[1][0] * B[0][1] + A[1][1] * B[1][1]]
]
def matrix_pow(matrix, n):
"""
Raises the... | from solution import process_fibonacci_sums, sum_fib_upto_n
def test_sum_fib_upto_0():
assert sum_fib_upto_n(0) == 0
def test_sum_fib_upto_1():
assert sum_fib_upto_n(1) == 1
def test_sum_fib_upto_2():
assert sum_fib_upto_n(2) == 2
def test_sum_fib_upto_3():
assert sum_fib_upto_n(3) == 4
def test_su... | [
{
"docstring": "Multiplies two matrices A and B.",
"function_declaration": "def matrix_mult(A, B):",
"function_name": "matrix_mult",
"parameter_list": "(A, B)"
},
{
"docstring": "Raises the matrix to the power of n using exponentiation by squaring.",
"function_declaration": "def matrix_p... | [
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 matrix_mult(A, B, mod):\n \"\"\"\n Multiplies two 2x2 matrices A and B under modulo `mod`.\n \"\"\"\n return [\n [(A[0][0] * B[0][0] + A[0][... | trial_gpt4o_4 | {
"original_instruction": "",
"prompt_id": "00024503",
"row_id": 24503,
"seed_ids": "[698]"
} | 0.623512 | Taco_24503 | I | [
"matrix_mult",
"matrix_pow",
"fib",
"sum_fib_upto_n",
"process_fibonacci_sums"
] | 5 | [
[
"fib",
"matrix_pow"
],
[
"matrix_pow",
"matrix_mult"
],
[
"process_fibonacci_sums",
"sum_fib_upto_n"
],
[
"sum_fib_upto_n",
"fib"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | 43e57d51040a8914c9fa8a1aecfac5fe03f292cf | 84032f55d795c3cd95cf34e4e054e80812c58894 | |||
v1.0 | instruct | Taco | Taco_24543_I | A tree is an undirected connected acyclic graph.
The length of a path between two vertices in a tree is the number of edges in this path.
The diameter of a tree is the maximum length of a path between any two vertices.
You are given a tree with n vertices and you are allowed to remove at most one edge and add back a... | from collections import deque, defaultdict
def bfs_to_get_farthest_node(tree, start):
"""
Perform BFS to find the farthest node from the start node.
Also returns the distances of each node from the start.
"""
n = len(tree)
distances = [-1] * n
queue = deque([start])
distances[start] = 0... | def test_solve(capsys):
t = 2
test_cases = [
(5, [(1, 2), (1, 3), (1, 4), (1, 5)]),
(4, [(1, 2), (2, 3), (2, 4)]),
]
expected_output = "2\n2\n"
solve(t, test_cases)
captured = capsys.readouterr()
assert captured.out == expected_output
def test_diagram():
t... | [
{
"docstring": "Perform BFS to find the farthest node from the start node.\nAlso returns the distances of each node from the start.",
"function_declaration": "def bfs_to_get_farthest_node(tree, start):",
"function_name": "bfs_to_get_farthest_node",
"parameter_list": "(tree, start)"
},
{
"doc... | [
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, defaultdict\n\ndef bfs_to_get_farthest_node(tree, start):\n \"\"\"\n Perform BFS to find the farthest node from the start node... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00024543",
"row_id": 24543,
"seed_ids": "[13309]"
} | 0.757957 | Taco_24543 | I | [
"bfs_to_get_farthest_node",
"calculate_diameter",
"find_minimum_diameter",
"process_test_cases",
"solve"
] | 5 | [
[
"calculate_diameter",
"bfs_to_get_farthest_node"
],
[
"find_minimum_diameter",
"calculate_diameter"
],
[
"process_test_cases",
"find_minimum_diameter"
],
[
"solve",
"process_test_cases"
]
] | 4 | [
"process_test_cases"
] | false | [] | false | pytest | false | [] | true | e0df0f7f75902f4c259006a4f9a1774a9deef656 | 0e9854b3fed605e20f05a06f10859069e94e5b97 | |||
v1.0 | instruct | Taco | Taco_24659_I | My friend Lexi loves coding and the magic of prime numbers. She is working on a project for which she needs to identify "special primes." A "special prime" is a prime number such that when you reverse its digits, the resulting number is also a prime. Your task is to help Lexi write a program to find all special primes ... | def is_prime(n):
"""
Checks if a number n is a prime number.
"""
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
... | from solution import is_prime, special_primes
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(17) == True
assert is_prime(19) == True
assert is_prime(20) == False
def test_special_primes():
assert special_primes(2) == [... | [
{
"docstring": "Checks if a number n is a prime number.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Finds all special primes up to and including N.\nA special prime is a prime number whose reverse is also a prime numbe... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(num):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024659",
"row_id": 24659,
"seed_ids": "[10386]"
} | 0.564844 | Taco_24659 | I | [
"is_prime",
"special_primes",
"main"
] | 3 | [
[
"special_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 19b0041c3b5bcd0ddfcccd7737d72f3ca0c8a4c8 | aed9702bf85c6534d255221a4e631688f83fd161 | |||
v1.0 | instruct | Taco | Taco_24702_I | Given a positive integer N, write a function to determine whether the number of 1's in its binary representation is a prime number or not.
Example 1:
Input:
N = 5
Output: 1
Explanation: The Binary Representation of 5 is 101, which has two 1's. Since 2 is a prime number, the function should return 1.
Example 2:
Input:
N... | def is_prime(n):
"""
Helper function to determine 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 primeOnesCount
def test_primeOnesCount_1():
assert primeOnesCount(5) == 1 # Binary: 101 has two 1s, 2 is prime
def test_primeOnesCount_2():
assert primeOnesCount(10) == 1 # Binary: 1010 has two 1s, 2 is prime
def test_primeOnesCount_3():
assert primeOnesCount(15) == 0 # Binary: 11... | [
{
"docstring": "Helper function to determine if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns 1 if the number of 1's in the binary representation of N is a prime number, else returns 0.",
"... | [
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 Helper function to determine if a given number is prime.\n \"\"\"\n if num < 2:\n return False\n if num == 2:\n... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00024702",
"row_id": 24702,
"seed_ids": "[3005]"
} | 0.6452 | Taco_24702 | I | [
"is_prime",
"primeOnesCount"
] | 2 | [
[
"primeOnesCount",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | db1ee44de09f3660e2435666646df70715d0b652 | ba7f0f83ecbff85235a82ad25cd449b1e0b7debe | |||
v1.0 | instruct | Taco | Taco_24719_I | You are given a tree, which is a connected undirected graph with no cycles. The tree consists of $n$ nodes numbered from 1 to $n$, and $n-1$ edges connecting them.
Each node in the tree has a value assigned to it, represented by an array $A$ of length $n$, where $A[i]$ represents the value of the $(i+1)$-th node.
You... | from collections import defaultdict
import sys
import math
sys.setrecursionlimit(200000)
def dfs(node, parent, depth, A, adj, P, min_val):
P[node][0] = parent
min_val[node][0] = A[node]
for i in range(1, len(P[node])):
if P[node][i-1] != -1:
P[node][i] = P[P[node][i-1]][i-1]
... | def test_case_1():
n = 5
A = [4, 2, 5, 7, 3]
edges = [(1, 2), (1, 3), (2, 4), (2, 5)]
queries = [(1, 4), (4, 5), (3, 5)]
result = solve_tree_path_queries(n, A, edges, queries)
expected = [2, 2, 2]
assert result == expected
def test_case_2():
n = 3
A = [1, 2, 3]
edges = [(1, 2), ... | [
{
"docstring": null,
"function_declaration": "def dfs(node, parent, depth, A, adj, P, min_val):",
"function_name": "dfs",
"parameter_list": "(node, parent, depth, A, adj, P, min_val)"
},
{
"docstring": null,
"function_declaration": "def find_lca_and_min(u, v, depth, P, min_val):",
"f... | [
0,
0,
0,
0,
1,
0,
0,
0
] | 1 | hard | 0.125 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import sys\nimport collections\nimport math\n\ndef preprocess(n, values, edges):\n # Create a tree (adjacency list)\n tree = collections.defaultdict(list)\n ... | trial_gpt4o_5 | {
"original_instruction": "",
"prompt_id": "00024719",
"row_id": 24719,
"seed_ids": "[12300]"
} | 0.741771 | Taco_24719 | I | [
"dfs",
"find_lca_and_min",
"solve_tree_path_queries"
] | 3 | [
[
"solve_tree_path_queries",
"dfs"
],
[
"solve_tree_path_queries",
"find_lca_and_min"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | 69c0cd92293be5dbbaa4e30326712126d8a464c5 | 23da4c819b2222c807b4bd64500d8170aabf8f5d | |||
v1.0 | instruct | Taco | Taco_24752_I | Given an array of n integers, you are required to sort the elements in non-decreasing order using the merge sort algorithm. Merge sort is a divide-and-conquer algorithm that works as follows:
1. Divide the unsorted list into n sublists, each containing one element.
2. Repeatedly merge sublists to produce new sorted su... | def merge_sort(arr):
"""
Function to implement merge sort algorithm on an array.
"""
if len(arr) > 1:
mid = len(arr) // 2
L = arr[:mid]
R = arr[mid:]
merge_sort(L)
merge_sort(R)
i = j = k = 0
while i < len(L) and j < len(R):
if L[i] ... | from solution import sort_array
def test_merge_sort():
assert sort_array(8, [38, 27, 43, 3, 9, 82, 10, -5]) == "-5 3 9 10 27 38 43 82"
assert sort_array(5, [5, 2, 9, 1, 5, 6]) == "1 2 5 5 6 9"
assert sort_array(3, [3, -1, -2]) == "-2 -1 3"
assert sort_array(1, [1]) == "1"
assert sort_array(10, [10,... | [
{
"docstring": "Function to implement merge sort algorithm on an array.",
"function_declaration": "def merge_sort(arr):",
"function_name": "merge_sort",
"parameter_list": "(arr)"
},
{
"docstring": "Function to handle input and output for the merge sort problem.",
"function_declaration": ... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def merge_sort(arr):\n \"\"\"\n Function to perform merge sort on a list of integers.\n \"\"\"\n if len(arr) > 1:\n mid = len(arr) // 2\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024752",
"row_id": 24752,
"seed_ids": "[14555]"
} | 0.701729 | Taco_24752 | I | [
"merge_sort",
"sort_array"
] | 2 | [
[
"sort_array",
"merge_sort"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | cbb7dbdde69d7ecccf68cb058920265d086b3b44 | 40f39394bd2f6b96f59fbefaf563ae62ffaaafbb | |||
v1.0 | instruct | Taco | Taco_24762_I | You are given an array of $N$ integers and a set of $Q$ queries. Each query consists of two integers, $L$ and $R$ ($1 \leq L \leq R \leq N$). For each query, find the sum of the integers in the subarray from index $L$ to $R$ inclusive. Your task is to process all the queries efficiently.
Input Format:
The first line c... | 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 query_sum(prefix_sum, L, R):
"""
Returns the sum of the subarray ... | def test_preprocess_array():
assert preprocess_array([1, 2, 3, 4, 5]) == [0, 1, 3, 6, 10, 15]
def test_query_sum():
prefix_sum = preprocess_array([1, 2, 3, 4, 5])
assert query_sum(prefix_sum, 1, 3) == 6
assert query_sum(prefix_sum, 2, 4) == 9
assert query_sum(prefix_sum, 1, 5) == 15
def test_proce... | [
{
"docstring": "Preprocess the array to create a prefix sum array.",
"function_declaration": "def preprocess_array(arr):",
"function_name": "preprocess_array",
"parameter_list": "(arr)"
},
{
"docstring": "Returns the sum of the subarray from L to R (inclusive) using the prefix sum array.\nL ... | [
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 preprocess_array(arr):\n \"\"\"\n Preprocesses the array to create a prefix sum array.\n \"\"\"\n n = len(arr)\n prefix_sum = [0] * (n + 1)\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024762",
"row_id": 24762,
"seed_ids": "[11828]"
} | 0.706411 | Taco_24762 | I | [
"preprocess_array",
"query_sum",
"process_queries"
] | 3 | [
[
"process_queries",
"preprocess_array"
],
[
"process_queries",
"query_sum"
]
] | 2 | [
"process_queries"
] | false | [] | false | pytest | false | [] | true | 98ac6f50f45215d3ec791ec2c492e43f82bfa585 | dc51afc62f154217ad4118fa7574c1ae2129f810 | |||
v1.0 | instruct | Taco | Taco_24780_I | Write a program that reads an integer $N$ and generates two lists. The first list contains the prime numbers up to $N$ (inclusive if $N$ is prime). The second list contains the sum of the digits of each prime number from the first list. The program should then check if any number from the second list is also a prime nu... | from math import isqrt
def is_prime(num):
if num < 2:
return False
if num in (2, 3):
return True
if num % 2 == 0 or num % 3 == 0:
return False
for i in range(5, isqrt(num) + 1, 6):
if num % i == 0 or num % (i + 2) == 0:
return False
return True
def sieve... | from solution import is_prime, sieve_of_eratosthenes, sum_of_digits, generate_prime_lists_and_check, 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(11) == True
assert is_prime(25) == False
def test_sieve_of_... | [
{
"docstring": null,
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": null,
"function_declaration": "def sieve_of_eratosthenes(n):",
"function_name": "sieve_of_eratosthenes",
"parameter_list": "(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": "from math import isqrt\n\ndef is_prime(num):\n if num < 2:\n return False\n if num in (2, 3):\n return True\n if num % 2 == 0 or num % 3 == ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00024780",
"row_id": 24780,
"seed_ids": "[4322]"
} | 0.650961 | Taco_24780 | I | [
"is_prime",
"sieve_of_eratosthenes",
"sum_of_digits",
"generate_prime_lists_and_check",
"process_test_cases"
] | 5 | [
[
"generate_prime_lists_and_check",
"is_prime"
],
[
"generate_prime_lists_and_check",
"sieve_of_eratosthenes"
],
[
"generate_prime_lists_and_check",
"sum_of_digits"
],
[
"process_test_cases",
"generate_prime_lists_and_check"
]
] | 4 | [
"process_test_cases"
] | false | [] | false | pytest | true | [] | true | 18ea27349f09befb9cfab80c528b81c21e786465 | a4abc2f2ea30c40865196db6e71eb1c5c6a4766e | |||
v1.0 | instruct | Taco | Taco_24790_I | Implement a function that takes a list of integers and returns a new list containing the median of every contiguous subarray of length `k`.
A median is the middle number in a sorted, odd-length list, or the average of the two middle numbers in an even-length list.
### Input
- list of integers, where 1 ≤ length of th... | def find_median(arr):
n = len(arr)
arr.sort()
if n % 2 == 0:
return (arr[n//2 - 1] + arr[n//2]) / 2
else:
return arr[n//2]
def medians(arr, k):
"""
Returns a list of medians for every contiguous subarray of length `k`.
"""
if k == 1:
return arr # each element is... | from solution import medians
def test_medians_example1():
assert medians([1, 3, 4, 2, 5], k=3) == [3, 3, 4]
def test_medians_example2():
assert medians([7, 2, 1, 6, 5], k=2) == [4.5, 1.5, 3.5, 5.5]
def test_medians_single_element_subarray():
assert medians([10, -5, 3, 8], k=1) == [10, -5, 3, 8]
def test... | [
{
"docstring": null,
"function_declaration": "def find_median(arr):",
"function_name": "find_median",
"parameter_list": "(arr)"
},
{
"docstring": "Returns a list of medians for every contiguous subarray of length `k`.",
"function_declaration": "def medians(arr, k):",
"function_name":... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def medians(nums, k):\n \"\"\"\n Returns a list of medians for every contiguous subarray of length `k`.\n \n Parameters:\n nums (list of int): List ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024790",
"row_id": 24790,
"seed_ids": "[11718]"
} | 0.768594 | Taco_24790 | I | [
"find_median",
"medians"
] | 2 | [
[
"medians",
"find_median"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 1d2b009e9294d486630eece44a9f9b76d66a0926 | f8efe56573380d2ba81f87609ec6cfee93368694 | |||
v1.0 | instruct | Taco | Taco_24825_I | Alice has recently learned about Fibonacci sequences and wants to generate a list of the first N Fibonacci numbers. Moreover, she wants to know which of these numbers are prime.
A Fibonacci sequence is defined as follows:
- F(0) = 0
- F(1) = 1
- F(n) = F(n-1) + F(n-2) for n > 1
A prime number is a natural number grea... | def generate_fibonacci(n):
"""
Generate the first N Fibonacci numbers.
"""
if n == 1:
return [0]
fib_nums = [0, 1]
while len(fib_nums) < n:
fib_nums.append(fib_nums[-1] + fib_nums[-2])
return fib_nums
def is_prime(num):
"""
Check if a number is prime.
"""
if ... | from solution import generate_fibonacci, is_prime, fibonacci_primes, format_output
def test_generate_fibonacci():
assert generate_fibonacci(1) == [0]
assert generate_fibonacci(2) == [0, 1]
assert generate_fibonacci(5) == [0, 1, 1, 2, 3]
def test_is_prime():
assert is_prime(2) == True
assert is_pri... | [
{
"docstring": "Generate the first N Fibonacci numbers.",
"function_declaration": "def generate_fibonacci(n):",
"function_name": "generate_fibonacci",
"parameter_list": "(n)"
},
{
"docstring": "Check if a number is prime.",
"function_declaration": "def is_prime(num):",
"function_name... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def generate_fibonacci(n):\n if n < 1:\n return []\n fibs = [0, 1]\n for i in range(2, n):\n fibs.append(fibs[-1] + fibs[-2])\n return fi... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024825",
"row_id": 24825,
"seed_ids": "[319]"
} | 0.784078 | Taco_24825 | I | [
"generate_fibonacci",
"is_prime",
"fibonacci_primes",
"format_output"
] | 4 | [
[
"fibonacci_primes",
"generate_fibonacci"
],
[
"fibonacci_primes",
"is_prime"
],
[
"format_output",
"fibonacci_primes"
]
] | 3 | [
"format_output"
] | false | [] | false | pytest | true | [] | true | 4bbfc7fcee1057ae17df2dfd198e0230016a33c7 | ead466bac3b9f3d9672a53540d4983b2708f871e | |||
v1.0 | instruct | Taco | Taco_24890_I | Create a program that evaluates mathematical expressions from strings and computes their results. Your program should correctly interpret the four basic arithmetic operations: addition (+), subtraction (-), multiplication (*), and division (/), while respecting the order of operations (PEMDAS/BODMAS rules).
### Input
... | def evaluate_expression(expression):
"""
Evaluates a mathematical expression and returns the result as a float with two decimal places.
"""
# Evaluating the expression using eval
result = eval(expression)
# Formatting the result to two decimal places
return format(result, ".2f")
def process... | from solution import evaluate_expression, process_expressions
import io
import sys
def test_evaluate_expression():
assert evaluate_expression("3+5*2") == "13.00"
assert evaluate_expression("10/2+1") == "6.00"
assert evaluate_expression("7*(2+3)") == "35.00"
assert evaluate_expression("8/3*3") == "8.00"... | [
{
"docstring": "Evaluates a mathematical expression and returns the result as a float with two decimal places.",
"function_declaration": "def evaluate_expression(expression):",
"function_name": "evaluate_expression",
"parameter_list": "(expression)"
},
{
"docstring": "Processes a list of exp... | [
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 evaluate_expression(expression):\n \"\"\"\n Evaluates a mathematical expression and returns the result as a float with two decimal places.\n \"\"\"\n ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00024890",
"row_id": 24890,
"seed_ids": "[2519]"
} | 0.568468 | Taco_24890 | I | [
"evaluate_expression",
"process_expressions"
] | 2 | [
[
"process_expressions",
"evaluate_expression"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 63ff64c70f2d626585d8950f1a3434cdb8d6fc02 | 59296ce6ae1a0d84be1c8e2e4514bd46c408a732 | |||
v1.0 | instruct | Taco | Taco_24906_I | You are tasked with implementing a modified k-means clustering algorithm to automatically classify the topics of a set of documents. Each document is represented as a list of words and you will use a given pre-trained word embedding model to convert words to vectors.
To simplify, you will only work with a small subset... | import numpy as np
from sklearn.cluster import KMeans
def avg_vector(document, embeddings):
vectors = [embeddings[word] for word in document if word in embeddings]
return np.mean(vectors, axis=0) if vectors else np.zeros(300)
def k_means_clustering(k, n, documents, embeddings_list):
embeddings = {emb.spli... | from solution import k_means_clustering
def test_k_means_clustering():
k = 2
n = 3
documents = [
"apple banana fruit",
"fruit apple",
"dog cat pet"
]
embeddings_list = [
"apple 0.1 0.2 0.3 ..." + ' '.join(['0.299'] * 296),
"banana 0.4 0.5 0.6 ..." + ' '.join(... | [
{
"docstring": null,
"function_declaration": "def avg_vector(document, embeddings):",
"function_name": "avg_vector",
"parameter_list": "(document, embeddings)"
},
{
"docstring": null,
"function_declaration": "def k_means_clustering(k, n, documents, embeddings_list):",
"function_name"... | [
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": "import numpy as np\nfrom sklearn.cluster import KMeans\n\ndef convert_document_to_vector(document, word_embeddings):\n \"\"\"\n Conv... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024906",
"row_id": 24906,
"seed_ids": "[6241]"
} | 0.616702 | Taco_24906 | I | [
"avg_vector",
"k_means_clustering"
] | 2 | [
[
"k_means_clustering",
"avg_vector"
]
] | 1 | [] | false | [] | false | pytest | true | [
"numpy",
"sklearn"
] | false | 344519ff18a95d7fc51715922e18eea0840600c4 | 8a337ba6de14609efd56dbabdcd8bb7da9a1d0c6 | |||
v1.0 | instruct | Taco | Taco_24949_I | A famous railway network consists of n stations connected by bidirectional tracks. Each track connects two different stations and is associated with a specific length. The government wants to determine the minimum cost to connect all the stations such that every station can be reached from any other station. Additional... | def find(parent, i):
if parent[i] == i:
return i
else:
parent[i] = find(parent, parent[i])
return parent[i]
def union(parent, rank, x, y):
root_x = find(parent, x)
root_y = find(parent, y)
if root_x != root_y:
if rank[root_x] > rank[root_y]:
parent[r... | def test_case_1():
n = 6
tracks = [
(1, 2, 3),
(2, 3, 2),
(3, 4, 1),
(4, 5, 4),
(5, 6, 5),
(1, 3, 6),
(2, 4, 7),
(3, 5, 8),
(4, 6, 9)
]
assert minimum_cost_to_connect_all_stations(n, tracks) == 15
def test_case_2():
n = 4
t... | [
{
"docstring": null,
"function_declaration": "def find(parent, i):",
"function_name": "find",
"parameter_list": "(parent, i)"
},
{
"docstring": null,
"function_declaration": "def union(parent, rank, x, y):",
"function_name": "union",
"parameter_list": "(parent, rank, x, y)"
},
... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(paren... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00024949",
"row_id": 24949,
"seed_ids": "[20078]"
} | 0.730066 | Taco_24949 | I | [
"find",
"union",
"kruskal",
"minimum_cost_to_connect_all_stations"
] | 4 | [
[
"kruskal",
"find"
],
[
"kruskal",
"union"
],
[
"minimum_cost_to_connect_all_stations",
"kruskal"
],
[
"union",
"find"
]
] | 4 | [] | false | [] | false | pytest | false | [] | true | 5c0bd3661522043e9b25121994bbd3089e5d10fc | 8202a3dcd3eaa321f43f1120dd2003d8b2b27e6d | |||
v1.0 | instruct | Taco | Taco_24978_I | Marta is working on a chatbot service that should respond to a user's question with the best possible answer from a given set of predefined answers. The chatbot service has a set of predefined questions and their respective predefined answers stored in the form of strings. The aim is to find the most relevant predefine... | def longest_common_subsequence(a, b):
m, n = len(a), len(b)
dp = [[0] * (n + 1) for _ in range(m + 1)]
for i in range(1, m + 1):
for j in range(1, n + 1):
if a[i - 1] == b[j - 1]:
dp[i][j] = dp[i - 1][j - 1] + 1
else:
dp[i][j] = max(dp[i - 1][j... | from solution import find_best_answer, longest_common_subsequence
def test_longest_common_subsequence():
assert longest_common_subsequence("abc", "abc") == 3
assert longest_common_subsequence("abc", "def") == 0
assert longest_common_subsequence("abc", "aebdc") == 3
assert longest_common_subsequence("ab... | [
{
"docstring": null,
"function_declaration": "def longest_common_subsequence(a, b):",
"function_name": "longest_common_subsequence",
"parameter_list": "(a, b)"
},
{
"docstring": null,
"function_declaration": "def find_best_answer(n, qa_pairs, user_question):",
"function_name": "find_... | [
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 lcs(X, Y):\n \"\"\" Function to compute the Longest Common Subsequence of X and Y \"\"\"\n matrix = [[0] * (len(Y) + 1) for _ in range(len(X) + 1)]\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00024978",
"row_id": 24978,
"seed_ids": "[8279]"
} | 0.562653 | Taco_24978 | I | [
"longest_common_subsequence",
"find_best_answer"
] | 2 | [
[
"find_best_answer",
"longest_common_subsequence"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c94b7426943020a55dc1bb29fe773400815bfc0c | dacb61b7bd06139b96b8e261010d10efede1499f | |||
v1.0 | instruct | Taco | Taco_25044_I | The city of Alphaville has a peculiar street layout. The city is organized into a grid of N x N blocks, each with a unique integer value representing the building height. The mayor of Alphaville wants to build new infrastructure that spans several blocks, but she needs to know the sum of the building heights in certain... | def compute_prefix_sum(grid, N):
prefix_sum = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
for j in range(1, N + 1):
prefix_sum[i][j] = grid[i-1][j-1] + prefix_sum[i-1][j] + prefix_sum[i][j-1] - prefix_sum[i-1][j-1]
return prefix_sum
def query_sum(pr... | def test_solve():
N = 3
grid = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
Q = 2
queries = [
(0, 0, 1, 1),
(1, 1, 2, 2)
]
expected = [12, 28]
assert solve(N, grid, Q, queries) == expected
def test_single_block_query():
N = 3
grid = [
[1, 2... | [
{
"docstring": null,
"function_declaration": "def compute_prefix_sum(grid, N):",
"function_name": "compute_prefix_sum",
"parameter_list": "(grid, N)"
},
{
"docstring": null,
"function_declaration": "def query_sum(prefix_sum, i1, j1, i2, j2):",
"function_name": "query_sum",
"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 preprocess(grid):\n N = len(grid)\n prefix_sum = [[0] * (N + 1) for _ in range(N + 1)]\n \n for i in range(1, N + 1):\n for j in range(1, N ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00025044",
"row_id": 25044,
"seed_ids": "[1611]"
} | 0.749107 | Taco_25044 | I | [
"compute_prefix_sum",
"query_sum",
"solve"
] | 3 | [
[
"solve",
"compute_prefix_sum"
],
[
"solve",
"query_sum"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | 6fd421bd36201723fcc43ab74f67c7936ffaecc3 | 4ce28a149d858bdd91a76ada05883bceb55e7460 | |||
v1.0 | instruct | Taco | Taco_25067_I | In a certain country, license plates are formed based on specific patterns: they either start with two uppercase letters followed by four digits, or four digits followed by two uppercase letters. Given a set of strings, your objective is to identify which among them are valid license plates.
Input
The input consists ... | def is_valid_license_plate(s):
"""
Checks if the given string is a valid license plate.
The valid formats are two uppercase letters followed by four digits,
or four digits followed by two uppercase letters.
"""
if len(s) != 6:
return "Invalid"
if (s[:2].isupper() and s[2:].isdig... | def test_is_valid_license_plate():
assert is_valid_license_plate("AB1234") == "Valid"
assert is_valid_license_plate("1234AB") == "Valid"
assert is_valid_license_plate("abcd12") == "Invalid"
assert is_valid_license_plate("1A2B3C") == "Invalid"
assert is_valid_license_plate("ABCD12") == "Invalid"
... | [
{
"docstring": "Checks if the given string is a valid license plate.\nThe valid formats are two uppercase letters followed by four digits,\nor four digits followed by two uppercase letters.",
"function_declaration": "def is_valid_license_plate(s):",
"function_name": "is_valid_license_plate",
"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": "import re\n\ndef is_valid_license_plate(plate):\n \"\"\"\n Check whether the given plate is a valid license plate.\n Pattern: XXDDDD or DDDDXX where X is ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00025067",
"row_id": 25067,
"seed_ids": "[16442]"
} | 0.595913 | Taco_25067 | I | [
"is_valid_license_plate",
"check_license_plates"
] | 2 | [
[
"check_license_plates",
"is_valid_license_plate"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | d796273f1ad67eb3885923c10e82be7a039b5d88 | 558b201c752fe5aea90a3b685ca94d6bc09c6fd5 | |||
v1.0 | instruct | Taco | Taco_25093_I | Given an array arr[] of integers and an integer k such that 1 <= k <= n where n is the length of the array. Your task is to find the k-th largest element in the array using a quickselect algorithm.
Example 1:
Input:
arr[] = [3,2,1,5,6,4]
k = 2
Output:
5
Explanation: The 2nd largest element in the array is 5.
Example ... | import random
def partition(arr, left, right):
pivot_index = random.randint(left, right)
pivot = arr[pivot_index]
arr[pivot_index], arr[right] = arr[right], arr[pivot_index]
i = left
for j in range(left, right):
if arr[j] > pivot: # Note: We use '>' to find the k-th largest element.
... | def test_findKthLargest_example1():
assert findKthLargest([3, 2, 1, 5, 6, 4], 2) == 5
def test_findKthLargest_example2():
assert findKthLargest([3, 2, 3, 1, 2, 4, 5, 5, 6], 4) == 4
def test_findKthLargest_single_element():
assert findKthLargest([1], 1) == 1
def test_findKthLargest_all_elements_same():
... | [
{
"docstring": null,
"function_declaration": "def partition(arr, left, right):",
"function_name": "partition",
"parameter_list": "(arr, left, right)"
},
{
"docstring": null,
"function_declaration": "def quickselect(arr, left, right, k):",
"function_name": "quickselect",
"paramete... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\ndef findKthLargest(arr, k):\n \"\"\"\n Returns the k-th largest element in the array using Quickselect algorithm.\n \"\"\"\n\n def par... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00025093",
"row_id": 25093,
"seed_ids": "[21846]"
} | 0.619094 | Taco_25093 | I | [
"partition",
"quickselect",
"findKthLargest"
] | 3 | [
[
"findKthLargest",
"quickselect"
],
[
"quickselect",
"partition"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | fbbfa2a540114cf64183ef88620b6ba8b14080cd | 192e936e061822833f2218269d4dc26b008dbc36 | |||
v1.0 | instruct | Taco | Taco_25112_I | A company hosts several events annually, and each event has a specific start and end time represented in 24-hour format (HH:MM). The HR team wants to know the maximum number of events that overlap at any point in time during the day.
The task is to write a program that, given a list of events with their start and end ... | def to_minutes(time_str):
"""
Converts a time string in HH:MM format to the total number of minutes since 00:00.
"""
hh, mm = map(int, time_str.split(':'))
return hh * 60 + mm
def max_overlap(events):
"""
Determines the maximum number of overlapping events.
"""
times = []
#... | def test_max_overlap_single_event():
assert max_overlap([("09:00", "10:00")]) == 1
def test_max_overlap_no_overlap():
assert max_overlap([("09:00", "10:00"), ("10:00", "11:00")]) == 1
def test_max_overlap_full_overlap():
assert max_overlap([("09:00", "10:00"), ("09:30", "09:45")]) == 2
def test_max_overl... | [
{
"docstring": "Converts a time string in HH:MM format to the total number of minutes since 00:00.",
"function_declaration": "def to_minutes(time_str):",
"function_name": "to_minutes",
"parameter_list": "(time_str)"
},
{
"docstring": "Determines the maximum number of overlapping events.",
... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_overlap(events):\n \"\"\"\n Calculate the maximum number of overlapping intervals.\n \n Args:\n events (list of tuples): List of events with... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00025112",
"row_id": 25112,
"seed_ids": "[8089]"
} | 0.661646 | Taco_25112 | I | [
"to_minutes",
"max_overlap",
"process_test_cases"
] | 3 | [
[
"max_overlap",
"to_minutes"
],
[
"process_test_cases",
"max_overlap"
]
] | 2 | [
"process_test_cases"
] | false | [] | false | pytest | false | [] | true | 7ad1c2d7ec9414e35828125e42d7b54f9a769353 | f09bd7f4c99375c973a65d4777153e4968e3cb8d | |||
v1.0 | instruct | Taco | Taco_25138_I | You are given an array of $n$ integers and a list of $m$ queries. Each query consists of two indices $l$ and $r$, and the task is to calculate the sum of the elements in the subarray from index $l$ to index $r$ (1-based inclusive). After answering all the queries, the array is modified by incrementing each element by 1... | def preprocess_prefix_sums(arr):
"""
Preprocess the array to get the prefix sums which help in finding the sum of
any subarray efficiently.
"""
prefix_sums = [0] * (len(arr) + 1)
for i in range(len(arr)):
prefix_sums[i + 1] = prefix_sums[i] + arr[i]
return prefix_sums
def query_sum(... | def test_preprocess_prefix_sums():
arr = [1, 2, 3, 4, 5]
assert preprocess_prefix_sums(arr) == [0, 1, 3, 6, 10, 15]
def test_query_sum():
prefix_sums = [0, 1, 3, 6, 10, 15]
assert query_sum(prefix_sums, 2, 4) == 9
assert query_sum(prefix_sums, 1, 5) == 15
assert query_sum(prefix_sums, 3, 3) == ... | [
{
"docstring": "Preprocess the array to get the prefix sums which help in finding the sum of\nany subarray efficiently.",
"function_declaration": "def preprocess_prefix_sums(arr):",
"function_name": "preprocess_prefix_sums",
"parameter_list": "(arr)"
},
{
"docstring": "Returns the sum of the... | [
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 process_queries(n, m, a, queries):\n \"\"\"\n This function processes the queries to get the sum of elements between indices l and r \n (1-based inclu... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00025138",
"row_id": 25138,
"seed_ids": "[20058]"
} | 0.779399 | Taco_25138 | I | [
"preprocess_prefix_sums",
"query_sum",
"process_queries"
] | 3 | [
[
"process_queries",
"preprocess_prefix_sums"
],
[
"process_queries",
"query_sum"
]
] | 2 | [
"process_queries"
] | false | [] | false | pytest | false | [] | true | 07bc695c33f645ca32e6a5db2e7c6174f31cb28f | 29fcdf13f699a1b3e2909a7f8094de505ac5202c | |||
v1.0 | instruct | Taco | Taco_25172_I | A group of wizards in the mystical land of Alvora are trying to protect their sacred tower from an incoming horde of trolls. They have a magical defense system that can release a powerful energy wave to eliminate the trolls. The energy wave can only be fired once, and it must be aimed strategically to affect the maximu... | import math
from itertools import combinations
def distance(troll1, troll2):
return math.sqrt((troll1[0] - troll2[0]) ** 2 + (troll1[1] - troll2[1]) ** 2)
def max_trolls_affected(N, R, trolls):
max_affected = 0
for troll1, troll2 in combinations(trolls, 2):
mid_point = ((troll1[0] + troll2[0]... | from solution import max_trolls_affected
def test_example1():
N, R = 5, 2
trolls = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]
assert max_trolls_affected(N, R, trolls) == 3
def test_example2():
N, R = 6, 3
trolls = [(-2, -2), (1, 1), (0, 2), (2, 3), (5, 5), (-1, -3)]
assert max_trolls_affected(N,... | [
{
"docstring": null,
"function_declaration": "def distance(troll1, troll2):",
"function_name": "distance",
"parameter_list": "(troll1, troll2)"
},
{
"docstring": null,
"function_declaration": "def max_trolls_affected(N, R, trolls):",
"function_name": "max_trolls_affected",
"param... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_trolls_affected(N, R, trolls):\n from itertools import combinations\n from math import sqrt\n\n def distance(p1, p2):\n return sqrt((p1[0] ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00025172",
"row_id": 25172,
"seed_ids": "[2504]"
} | 0.608969 | Taco_25172 | I | [
"distance",
"max_trolls_affected",
"main"
] | 3 | [
[
"max_trolls_affected",
"distance"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 14d918afbccc5ace417c503b8f2678f124a5c7c0 | 83bd7e83f2f7c4c69f94bfb3c45261b5a98b8733 | |||
v1.0 | instruct | Taco | Taco_25197_I | Given a string S, your task is to complete the function possiblePalindromes() which returns a list of all unique substrings of S that are palindromes. A palindrome is a string that reads the same forward and backward.
Example 1:
Input:
S = "aab"
Output: ["a", "aa", "b"]
Example 2:
Input:
S = "abcba"
Output: ["a", "b... | def is_palindrome(s):
"""
Helper function to check if a given string is a palindrome.
"""
return s == s[::-1]
def possiblePalindromes(S):
"""
This function returns a list of all unique palindromic substrings of the input string S.
"""
n = len(S)
palindromes = set()
for i in... | from solution import possiblePalindromes
def test_possiblePalindromes_example1():
assert possiblePalindromes("aab") == ["a", "aa", "b"]
def test_possiblePalindromes_example2():
assert possiblePalindromes("abcba") == ["a", "abcba", "b", "bcb", "c"]
def test_possiblePalindromes_single_character():
assert p... | [
{
"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": "This function returns a list of all unique palindromic substrings of the input string S.... | [
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 possiblePalindromes(S):\n \"\"\"\n Returns a list of all unique palindromic substrings of S in lexicographical order.\n \"\"\"\n def is_palindrome(... | trial_gpt4o_4 | {
"original_instruction": "",
"prompt_id": "00025197",
"row_id": 25197,
"seed_ids": "[9407]"
} | 0.738468 | Taco_25197 | I | [
"is_palindrome",
"possiblePalindromes"
] | 2 | [
[
"possiblePalindromes",
"is_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | bf2d79082845cd14cf2a5aa8e9b7998984f6d9a4 | 8c99a419f213bb417503f08dc45fc912e8a4fa6c | |||
v1.0 | instruct | Taco | Taco_25232_I | Write a program that determines if a given string is a "quasi-palindrome." A quasi-palindrome is defined as a string that can be made into a palindrome by removing at most one character.
Input
The input consists of several datasets. The first line contains the number of datasets $n$ ($1 \leq n \leq 100$). The next $n... | def is_quasi_palindrome(s):
"""
Returns True if the string s can be a palindrome by removing at most one character, False otherwise.
"""
# Helper function to check if a substring is a palindrome
def is_palindrome_range(l, r):
while l < r:
if s[l] != s[r]:
return F... | from solution import determine_quasi_palindromes
def test_all_yes_cases():
assert determine_quasi_palindromes(3, ['abca', 'abccba', 'a']) == ["YES", "YES", "YES"]
def test_all_no_cases():
assert determine_quasi_palindromes(3, ['abcdef', 'abcd', 'abcdefghij']) == ["NO", "NO", "NO"]
def test_mix_cases():
a... | [
{
"docstring": "Returns True if the string s can be a palindrome by removing at most one character, False otherwise.",
"function_declaration": "def is_quasi_palindrome(s):",
"function_name": "is_quasi_palindrome",
"parameter_list": "(s)"
},
{
"docstring": "Determines if each string in the li... | [
0,
0,
0,
1,
1
] | 2 | medium | 0.4 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_palindrome(s):\n \"\"\"\n Checks if a given string s is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef is_quasi_palindrome(s):\n \"\"\"\... | trial_gpt4o_4 | {
"original_instruction": "",
"prompt_id": "00025232",
"row_id": 25232,
"seed_ids": "[4793]"
} | 0.748273 | Taco_25232 | I | [
"is_quasi_palindrome",
"determine_quasi_palindromes"
] | 2 | [
[
"determine_quasi_palindromes",
"is_quasi_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 338486dc4b46ad6c990050d7c16baac003a9e785 | 61a2f27ad976ec4b874159181068fda7ab4d5c71 | |||
v1.0 | instruct | Taco | Taco_25256_I | Sara is an avid participant in treasure hunts. Recently, she came across a peculiar treasure hunt that involves deciphering secret messages encoded in strings. These messages contain clues as pairs of digits. For instance, the string "1234" contains pairs 12, 23, and 34.
Sara needs to identify the number of unique pai... | def count_unique_pairs(case_strings):
result = []
for s in case_strings:
pairs = set()
for i in range(len(s) - 1):
pairs.add(s[i:i+2])
result.append(len(pairs))
return result
# Function to parse the input and call count_unique_pairs
def treasure_hunt_solution(n, cases):
... | from solution import treasure_hunt_solution
def test_single_case():
assert treasure_hunt_solution(1, ["1234"]) == [3]
def test_repeated_digits():
assert treasure_hunt_solution(1, ["1111"]) == [1]
def test_mix_pairs():
assert treasure_hunt_solution(1, ["432123"]) == [5]
def test_multiple_cases():
... | [
{
"docstring": null,
"function_declaration": "def count_unique_pairs(case_strings):",
"function_name": "count_unique_pairs",
"parameter_list": "(case_strings)"
},
{
"docstring": null,
"function_declaration": "def treasure_hunt_solution(n, cases):",
"function_name": "treasure_hunt_sol... | [
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 unique_digit_pairs(N, messages):\n results = []\n for message in messages:\n pairs = {message[i:i+2] for i in range(len(message)-1)}\n resu... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00025256",
"row_id": 25256,
"seed_ids": "[23978]"
} | 0.622185 | Taco_25256 | I | [
"count_unique_pairs",
"treasure_hunt_solution"
] | 2 | [
[
"treasure_hunt_solution",
"count_unique_pairs"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2a3affe8818f392cbc1e02b5510c28610f43d372 | 981fdab8af6b74be0d3ff74d0f5cc2a3fe7f2276 | |||
v1.0 | instruct | Taco | Taco_25401_I | Given an array of integers, you need to count the frequency of unique prime numbers present in that array. Prime numbers are those numbers greater than 1 that have no divisors other than 1 and itself.
-----Input:-----
- First line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case... | def is_prime(num):
if num <= 1:
return False
if num == 2:
return True
if num % 2 == 0:
return False
p = 3
while p * p <= num:
if num % p == 0:
return False
p += 2
return True
def count_unique_primes(arr):
primes = set()
for number in a... | from solution import process_test_cases, is_prime, count_unique_primes
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(5) == True
assert is_prime(16) == False
assert is_prime(17) == True
def test_count_unique_primes():
... | [
{
"docstring": null,
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": null,
"function_declaration": "def count_unique_primes(arr):",
"function_name": "count_unique_primes",
"parameter_list": "(arr)"
},
{
... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 == 0:\n return False\n p = 3\n while... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00025401",
"row_id": 25401,
"seed_ids": "[15609]"
} | 0.628989 | Taco_25401 | I | [
"is_prime",
"count_unique_primes",
"process_test_cases"
] | 3 | [
[
"count_unique_primes",
"is_prime"
],
[
"process_test_cases",
"count_unique_primes"
]
] | 2 | [
"process_test_cases"
] | false | [] | false | pytest | true | [] | true | 0bc5f67c4aa1ef23b9676a62a6f3621664d9a89b | 59bbac2f6f478057b7e87c5fba85fc8dc7a9c302 | |||
v1.0 | instruct | Taco | Taco_25477_I | You are given a directed graph with n vertices and m edges.
Some operations need to be performed on this graph:
* Reverse the direction of an existing edge.
* Find the length of the shortest cycle in the graph.
Initially, and after each operation, you should determine the length of the shortest cycle in the graph. I... | import heapq
def dijkstra(graph, n, start):
distances = [float('inf')] * n
distances[start] = 0
pq = [(0, start)]
while pq:
current_distance, current_vertex = heapq.heappop(pq)
if current_distance > distances[current_vertex]:
continue
for neighbor, weight in graph[cu... | import sys
from io import StringIO
from solution import main
def run_test(input_data, expected_output):
old_stdin = sys.stdin
sys.stdin = StringIO(input_data)
try:
main()
finally:
sys.stdin = old_stdin
def test_case_1():
input_data = """5 6
1 2
2 3
3 4
4 1
4 5
5 2
3
0 4 1
0 1 2
0 5... | [
{
"docstring": null,
"function_declaration": "def dijkstra(graph, n, start):",
"function_name": "dijkstra",
"parameter_list": "(graph, n, start)"
},
{
"docstring": null,
"function_declaration": "def floyd_warshall(graph, n):",
"function_name": "floyd_warshall",
"parameter_list": ... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\n\ndef dijkstra(graph, n, start):\n distances = [float('inf')] * n\n distances[start] = 0\n pq = [(0, start)]\n while pq:\n current... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00025477",
"row_id": 25477,
"seed_ids": "[3883]"
} | 0.780639 | Taco_25477 | I | [
"dijkstra",
"floyd_warshall",
"shortest_cycle_length",
"reverse_edge",
"main"
] | 5 | [
[
"shortest_cycle_length",
"floyd_warshall"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | dea9f5e17b5ba43b7afc49e60564c0e885e697b8 | 796e7f13d71e3284be38f8946ea321069e9c1114 | |||
v1.0 | instruct | Taco | Taco_25581_I | A network of cities and highways can be represented as a graph with $n$ nodes and $m$ edges. Each node represents a city, and each edge represents a bidirectional highway with an associated travel cost. You are starting in city $1$ and want to visit city $n$ with the least cost. However, you need to visit exactly one s... | import heapq
def dijkstra(start, graph, n):
"""
Uses Dijkstra's algorithm to find the shortest paths from a starting node
to all other nodes in a graph. Returns a list of minimum distances.
"""
distances = [float('inf')] * (n + 1)
distances[start] = 0
priority_queue = [(0, start)]
... | from solution import min_cost_through_intermediate
def test_example_1():
n = 6
m = 7
k = 4
highways = [
(1, 2, 1),
(2, 3, 2),
(3, 6, 3),
(1, 3, 2),
(2, 4, 4),
(4, 5, 2),
(5, 6, 3)
]
assert min_cost_through_intermediate(n, m, k, highways) =... | [
{
"docstring": "Uses Dijkstra's algorithm to find the shortest paths from a starting node \nto all other nodes in a graph. Returns a list of minimum distances.",
"function_declaration": "def dijkstra(start, graph, n):",
"function_name": "dijkstra",
"parameter_list": "(start, graph, n)"
},
{
... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\nimport sys\n\ndef dijkstra(graph, start):\n \"\"\"\n Returns the shortest paths from start to all other nodes using Dijkstra's algorithm\n \... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00025581",
"row_id": 25581,
"seed_ids": "[525]"
} | 0.818236 | Taco_25581 | I | [
"dijkstra",
"min_cost_through_intermediate"
] | 2 | [
[
"min_cost_through_intermediate",
"dijkstra"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 08510327aae2dcfb69076858c9fc3d07d6a507d7 | da54555b6dc97afee0892cd76412a916b02e289c | |||
v1.0 | instruct | Taco | Taco_25596_I | Given a binary tree, determine if it is height-balanced.
A height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differs by more than 1.
-----Input-----
The input consists of a binary tree represented as a string in the following format: "node_value(left_s... | class Node:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def parse_tree(data):
def parse_helper(index):
if index >= len(data) or data[index] == ')':
return None, index
start = index
while index < len(data) and (dat... | from solution import check_height_balanced
def test_balanced_tree():
assert check_height_balanced("1(2(4)(5))(3)") == "Yes"
def test_unbalanced_tree():
assert check_height_balanced("1(2(4()()))(3())") == "No"
def test_empty_tree():
assert check_height_balanced("") == "Yes"
def test_balanced_tree_with_mu... | [] | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, value=0, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\ndef d... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00025596",
"row_id": 25596,
"seed_ids": "[1442]"
} | 0.773858 | Taco_25596 | I | [
"parse_tree",
"is_balanced",
"check_height_balanced"
] | 3 | [
[
"check_height_balanced",
"is_balanced"
],
[
"check_height_balanced",
"parse_tree"
]
] | 2 | [] | false | [
"Node"
] | true | pytest | true | [] | true | 84907a696769fe6b28c4ea9d5836e815ca7a9cc3 | d296b95e19d9796449e0c34dde785da42bffb355 | |||
v1.0 | instruct | Taco | Taco_25651_I | You are given a list of integers. Your task is to find the sum of all prime numbers in the list. If there are no prime numbers in the list, return 0.
A prime number is defined as a number greater than 1 with no positive divisors other than 1 and itself.
Example 1:
Input:
numbers = [2, 3, 4, 5, 10]
Output:
10
Explana... | def is_prime(n):
"""
Check if a number is prime.
"""
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True... | from solution import sumOfPrimes
def test_sumOfPrimes_with_primes():
numbers = [2, 3, 4, 5, 10]
assert sumOfPrimes(numbers) == 10
def test_sumOfPrimes_without_primes():
numbers = [10, 15, 20]
assert sumOfPrimes(numbers) == 0
def test_sumOfPrimes_empty_list():
numbers = []
assert sumOfPrimes(n... | [
{
"docstring": "Check if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns the sum of all prime numbers in the list.",
"function_declaration": "def sumOfPrimes(numbers):",
"function_name": ... | [
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_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 ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00025651",
"row_id": 25651,
"seed_ids": "[20975]"
} | 0.610363 | Taco_25651 | I | [
"is_prime",
"sumOfPrimes"
] | 2 | [
[
"sumOfPrimes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 53fa62107dc746e2e70b4c213a74e8fbae714b5b | 4dbac1c76b8073932809983196a1816eceb16442 | |||
v1.0 | instruct | Taco | Taco_25654_I | A kingdom is filled with numerous interconnected towns. Each pair of towns is either connected by a direct road or not. The king wants to travel from the capital city, Town 1, to his summer palace in Town n in the shortest number of steps possible. However, there's a twist: once he travels on a road, that road becomes ... | from collections import deque, defaultdict
def shortest_path(n, roads):
adj_list = defaultdict(list)
for u, v in roads:
adj_list[u].append(v)
adj_list[v].append(u)
dist = [-1] * (n + 1)
parent = [-1] * (n + 1)
dist[1] = 0
q = deque([1])
while q:
u = q.pople... | def test_kingdom_path_short_direct_route():
result = kingdom_path(5, 5, ["1 2", "2 3", "3 4", "4 5", "1 5"])
assert result == (1, [1, 5])
def test_kingdom_path_no_possible_route():
result = kingdom_path(5, 3, ["1 2", "2 3", "4 5"])
assert result == -1
def test_kingdom_path_complex_route():
result ... | [
{
"docstring": null,
"function_declaration": "def shortest_path(n, roads):",
"function_name": "shortest_path",
"parameter_list": "(n, roads)"
},
{
"docstring": null,
"function_declaration": "def kingdom_path(n, m, roads):",
"function_name": "kingdom_path",
"parameter_list": "(n, ... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque, defaultdict\n\ndef shortest_path(n, m, roads):\n graph = defaultdict(list)\n \n for u, v in roads:\n graph[u].append... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00025654",
"row_id": 25654,
"seed_ids": "[3837]"
} | 0.754337 | Taco_25654 | I | [
"shortest_path",
"kingdom_path"
] | 2 | [
[
"kingdom_path",
"shortest_path"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 6081493e5046997d1a93a834f03d786f805dfd6a | 623c37c7bbc90915a304b09d3b9062a3b1fbe321 | |||
v1.0 | instruct | Taco | Taco_25670_I | Alicia is working on a large distributed system composed of multiple servers. She wants to optimize the use of the network bandwidth when transferring data between servers. Each server is directly connected to several other servers, and each connection has a certain bandwidth limit. Alicia needs to find ways to optimiz... | from collections import defaultdict, deque
def bfs(capacity, source, sink, parent):
visited = set()
queue = deque([source])
visited.add(source)
while queue:
u = queue.popleft()
for v in capacity[u]:
if v not in visited and capacity[u][v] > 0:
... | from solution import max_bandwidth
def test_single_path():
n = 2
m = 1
connections = [(1, 2, 10)]
s = 1
t = 2
assert max_bandwidth(n, m, connections, s, t) == 10
def test_multiple_paths():
n = 4
m = 5
connections = [
(1, 2, 10),
(1, 3, 5),
(2, 3, 15),
... | [
{
"docstring": null,
"function_declaration": "def bfs(capacity, source, sink, parent):",
"function_name": "bfs",
"parameter_list": "(capacity, source, sink, parent)"
},
{
"docstring": null,
"function_declaration": "def edmonds_karp(n, edges, source, sink):",
"function_name": "edmonds... | [
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 heapq\n\ndef dijkstra(n, adj_list, source, target):\n max_bandwidth = [0] * (n + 1)\n max_bandwidth[source] = float('inf')\n priority_queue = [(flo... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00025670",
"row_id": 25670,
"seed_ids": "[23136]"
} | 0.579416 | Taco_25670 | I | [
"bfs",
"edmonds_karp",
"max_bandwidth"
] | 3 | [
[
"edmonds_karp",
"bfs"
],
[
"max_bandwidth",
"edmonds_karp"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | b032e311233b67d3f27a9d0bcfa951c1966f9948 | be15ac16568da823810d80d7d27dc6e5cd999e79 | |||
v1.0 | instruct | Taco | Taco_25695_I | You are given an undirected graph with N nodes and M edges.
Your task is to determine the length of the shortest simple cycle in the graph, or to determine that no cycle exists.
A simple cycle is a cycle that does not repeat any vertices except for the start and end vertex.
------ Input ------
The first line of the... | from collections import defaultdict, deque
def shortest_cycle_length(N, edges):
def bfs(start):
dist = [-1] * N
parent = [-1] * N
q = deque([start])
dist[start] = 0
while q:
node = q.popleft()
for neighbor in graph[node]:
if dist[neigh... | import pytest
from solution import read_input_and_solve
def test_example_cases():
input_data = "2\n3 3\n1 2\n2 3\n3 1\n4 3\n1 2\n2 3\n3 4\n"
expected_output = [3, -1]
assert read_input_and_solve(input_data) == expected_output
def test_no_cycle():
input_data = "1\n4 2\n1 2\n3 4\n"
expected_output =... | [
{
"docstring": null,
"function_declaration": "def shortest_cycle_length(N, edges):",
"function_name": "shortest_cycle_length",
"parameter_list": "(N, edges)"
},
{
"docstring": null,
"function_declaration": "def solve(T, cases):",
"function_name": "solve",
"parameter_list": "(T, c... | [
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 sys\nfrom collections import deque, defaultdict\n\ndef find_shortest_cycle(n, m, edges):\n adj = defaultdict(list)\n for u, v in edges:\n adj[u... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00025695",
"row_id": 25695,
"seed_ids": "[6403]"
} | 0.824617 | Taco_25695 | I | [
"shortest_cycle_length",
"solve",
"read_input_and_solve"
] | 3 | [
[
"read_input_and_solve",
"solve"
],
[
"solve",
"shortest_cycle_length"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | d5bf669dc1ed81972fe0991e264eef0d956a9585 | c0be8c39635f8e0384d5c2829baf36672f64c45f | |||
v1.0 | instruct | Taco | Taco_25709_I | In Farland, there are n cities connected by n - 1 roads in such a way that there is exactly one path between any two cities. Each city has a certain number of residents, and there is exactly one hospital in one of the cities.
Each day, ambulances travel from the hospital to any city through the roads to provide medica... | from collections import defaultdict, deque
def farthest_node_and_dist(graph, start):
visited = set()
queue = deque([(start, 0)])
farthest_node, max_dist = start, 0
while queue:
current, dist = queue.popleft()
if dist > max_dist:
farthest_node, max_dist = curren... | def test_best_city_for_hospital():
assert best_city_for_hospital(4, [3, 6, 2, 4], [(1, 2), (2, 3), (2, 4)]) == 2
assert best_city_for_hospital(6, [1, 2, 1, 3, 4, 5], [(1, 2), (1, 3), (3, 4), (3, 5), (5, 6)]) == 3
assert best_city_for_hospital(5, [10, 20, 30, 40, 50], [(2, 1), (2, 3), (3, 4), (4, 5)]) == 3
... | [
{
"docstring": null,
"function_declaration": "def farthest_node_and_dist(graph, start):",
"function_name": "farthest_node_and_dist",
"parameter_list": "(graph, start)"
},
{
"docstring": null,
"function_declaration": "def best_city_for_hospital(n, residents, roads):",
"function_name":... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque\n\ndef find_best_city(n, residents, roads):\n if n == 1:\n return 1\n \n # Building the adjacency list for the graph ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00025709",
"row_id": 25709,
"seed_ids": "[22277]"
} | 0.698117 | Taco_25709 | I | [
"farthest_node_and_dist",
"best_city_for_hospital"
] | 2 | [
[
"best_city_for_hospital",
"farthest_node_and_dist"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | f40f91b0f9512b3acf9012271647f5dcbd21a505 | c9598f351f5ce18bdc5a6d616b00ae6e6281e60e | |||
v1.0 | instruct | Taco | Taco_25718_I | Alice loves playing board games. Recently, she bought a game where she needs to find paths in a grid. The grid is represented by a 2D array of size N x M, and each cell contains an integer that represents the difficulty of the cell. The game requires Alice to find the path from the top-left corner to the bottom-right c... | def min_path_cost(grid):
N = len(grid)
M = len(grid[0])
# Initialize dp table
dp = [[0] * M for _ in range(N)]
dp[0][0] = grid[0][0]
# Fill the first row
for j in range(1, M):
dp[0][j] = dp[0][j-1] + grid[0][j]
# Fill the first column
for i in range(1, N):
dp[i][0]... | from solution import min_path_costs
def test_min_path_costs(capsys):
input_text = """2
3 3
1 3 1
1 5 1
4 2 1
2 2
1 2
1 1"""
expected_output = "7\n3\n"
min_path_costs(input_text)
captured = capsys.readouterr()
assert captured.out == expected_output | [
{
"docstring": null,
"function_declaration": "def min_path_cost(grid):",
"function_name": "min_path_cost",
"parameter_list": "(grid)"
},
{
"docstring": null,
"function_declaration": "def process_input(input_text):",
"function_name": "process_input",
"parameter_list": "(input_text... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def min_path_cost(grid):\n N = len(grid)\n M = len(grid[0])\n\n # Initialize dp table\n dp = [[0] * M for _ in range(N)]\n dp[0][0] = grid[0][0]\n\n... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00025718",
"row_id": 25718,
"seed_ids": "[9650]"
} | 0.722415 | Taco_25718 | I | [
"min_path_cost",
"process_input",
"min_path_costs"
] | 3 | [
[
"min_path_costs",
"process_input"
],
[
"process_input",
"min_path_cost"
]
] | 2 | [
"process_input"
] | false | [] | false | pytest | true | [] | true | 2e97eace2812a15791ed6db7c8863bdd58e7e8de | d73224de526c93c73b2c028c809d6fc4cb9fa5c9 | |||
v1.0 | instruct | Taco | Taco_25738_I | Marc loves to explore new places and wants to implement a maze-solving algorithm to help him find the shortest path from the entrance to the exit of a maze. The maze is represented as a 2D grid where each cell is either passable ('.') or a wall ('#'). Marc can move up, down, left, or right but cannot move diagonally. Y... | from collections import deque
def shortest_path(maze, n, m):
# Directions for moving in the maze (right, down, left, up)
directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
# Helper function to check if a position is valid and passable
def is_valid(x, y):
return 0 <= x < n and 0 <= y < m and maze[... | from solution import maze_solver
def test_shortest_path_example1():
maze_str = "5 5\n.....\n.#.#.\n.#.#.\n.#.#.\n....."
assert maze_solver(maze_str) == 8
def test_shortest_path_example2():
maze_str = "3 3\n.#.\n###\n.#."
assert maze_solver(maze_str) == -1
def test_shortest_path_single_path():
maz... | [
{
"docstring": null,
"function_declaration": "def shortest_path(maze, n, m):",
"function_name": "shortest_path",
"parameter_list": "(maze, n, m)"
},
{
"docstring": null,
"function_declaration": "def maze_solver(maze_str):",
"function_name": "maze_solver",
"parameter_list": "(maze... | [
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 deque\n\ndef shortest_path_in_maze(n, m, maze):\n \"\"\"\n Finds the shortest path from the entrance (top-left) to the exit (bottom-r... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00025738",
"row_id": 25738,
"seed_ids": "[3372]"
} | 0.680878 | Taco_25738 | I | [
"shortest_path",
"maze_solver"
] | 2 | [
[
"maze_solver",
"shortest_path"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b1f456a1d9d140a6483ab8c61f71b987a8762ff8 | f55e7198f40c61aaeab45d4d9169def2d7d908a8 | |||
v1.0 | instruct | Taco | Taco_25758_I | Determine the nth Fibonacci Number modulo 10^9+7.
The Fibonacci sequence is a series of numbers in which each number (Fibonacci number) is the sum of the two preceding numbers. Typically, it starts with 0 and 1.
Example 1:
Input:
n = 5
Output:
5
Explanation:
The first 6 Fibonacci numbers are:
0, 1, 1, 2, 3, 5, ...
Ex... | def mat_mult(A, B, mod=10**9+7):
"""
Matrix multiplication (modular).
"""
return [[(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % mod,
(A[0][0] * B[0][1] + A[0][1] * B[1][1]) % mod],
[(A[1][0] * B[0][0] + A[1][1] * B[1][0]) % mod,
(A[1][0] * B[0][1] + A[1][1] * B[1][1]) ... | from solution import nthFibonacci
def test_small_values():
assert nthFibonacci(1) == 1
assert nthFibonacci(2) == 1
assert nthFibonacci(3) == 2
assert nthFibonacci(4) == 3
assert nthFibonacci(5) == 5
def test_larger_values():
assert nthFibonacci(10) == 55
assert nthFibonacci(20) == 6765
... | [
{
"docstring": "Matrix multiplication (modular).",
"function_declaration": "def mat_mult(A, B, mod=10 ** 9 + 7):",
"function_name": "mat_mult",
"parameter_list": "(A, B, mod=10 ** 9 + 7)"
},
{
"docstring": "Matrix exponentiation with modular arithmetic.",
"function_declaration": "def mat... | [
0,
0,
0,
1,
0
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "MOD = 10**9 + 7\n\ndef matrix_mult(a, b):\n return [\n [(a[0][0] * b[0][0] + a[0][1] * b[1][0]) % MOD,\n (a[0][0] * b[0][1] + a[0][1] * b[1][1]) ... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00025758",
"row_id": 25758,
"seed_ids": "[11336]"
} | 0.657954 | Taco_25758 | I | [
"mat_mult",
"mat_pow",
"nthFibonacci"
] | 3 | [
[
"mat_pow",
"mat_mult"
],
[
"nthFibonacci",
"mat_pow"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 1d5e051ea393221b76865ac8931ce2379dffb34b | 96bf541d872307ec53b145007b1bb2f305bafca5 | |||
v1.0 | instruct | Taco | Taco_25813_I | Alex loves to grow a different kind of tree today, a balanced binary search tree (BST) from an array of integers. A BST is a binary tree in which each node has at most two children, where the left child contains only nodes with values less than the parent node, and the right child only nodes with values greater than th... | from functools import lru_cache
@lru_cache(None)
def count_unique_bsts(n):
if n <= 1:
return 1
total_trees = 0
for i in range(n):
left_trees = count_unique_bsts(i)
right_trees = count_unique_bsts(n - 1 - i)
total_trees += left_trees * right_trees
return total_trees
def ... | from solution import number_of_unique_balanced_bsts
def test_small_arrays():
assert number_of_unique_balanced_bsts([10]) == 1
assert number_of_unique_balanced_bsts([10, 20]) == 2
assert number_of_unique_balanced_bsts([10, 20, 30]) == 5
def test_medium_arrays():
assert number_of_unique_balanced_bsts([1... | [
{
"docstring": null,
"function_declaration": "def count_unique_bsts(n):",
"function_name": "count_unique_bsts",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def number_of_unique_balanced_bsts(a):",
"function_name": "number_of_unique_balanced_bsts",
"pa... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from math import comb\n\ndef count_balanced_bsts(n):\n \"\"\"\n Returns the number of unique balanced BSTs that can be formed\n with n unique elements usi... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00025813",
"row_id": 25813,
"seed_ids": "[14425]"
} | 0.579051 | Taco_25813 | I | [
"count_unique_bsts",
"number_of_unique_balanced_bsts"
] | 2 | [
[
"number_of_unique_balanced_bsts",
"count_unique_bsts"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 9651486cb0474e428f59e002b4c9c053bcc67ebe | a57dac9970c49c1a5171b294644da303b6c63a3f | |||
v1.0 | instruct | Taco | Taco_26056_I | In the land of Pyroland, there is a peculiar ritual involving lanterns. The Pyrolandians want to create a unique sequence of lanterns for their annual festival. Due to the symbolism of unique peaks and troughs in their culture, they have set specific rules for arranging the heights of these lanterns.
Given an array of... | def arrange_lanterns(n, heights):
if n < 3:
return "Impossible"
heights.sort()
mid = (n - 1) // 2
lows = heights[:mid+1]
highs = heights[mid+1:]
arranged = []
while lows or highs:
if lows:
arranged.append(lows.pop())
if highs:
arran... | from solution import arrange_lanterns
def test_example_1():
assert arrange_lanterns(3, [2, 3, 1]) == [2, 3, 1] or arrange_lanterns(3, [2, 3, 1]) == [3, 1, 2]
def test_example_2():
assert arrange_lanterns(4, [5, 1, 2, 4]) == [2, 5, 1, 4] or arrange_lanterns(4, [5, 1, 2, 4]) == [1, 5, 2, 4]
def test_impossible... | [
{
"docstring": null,
"function_declaration": "def arrange_lanterns(n, heights):",
"function_name": "arrange_lanterns",
"parameter_list": "(n, heights)"
},
{
"docstring": null,
"function_declaration": "def is_alternating(arranged):",
"function_name": "is_alternating",
"parameter_l... | [
0,
0,
0,
1,
0
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def arrange_lanterns(heights):\n \"\"\"\n Arranges the lanterns such that each peak is higher than its neighbors and each trough is lower than its neighbors.... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00026056",
"row_id": 26056,
"seed_ids": "[20026]"
} | 0.573584 | Taco_26056 | I | [
"arrange_lanterns",
"is_alternating"
] | 2 | [
[
"arrange_lanterns",
"is_alternating"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | baf666b381c742a2a9acca72df5eb87d96cc1577 | fb4726d7dd020fe7a4f24f1c97893b5b072df59b | |||
v1.0 | instruct | Taco | Taco_26096_I | A notable tech company has developed a secure system that requires password updates from employees every 30 days. The system leverages a policy that enforces each password to be a combination of numbers and letters, both uppercase and lowercase. As part of this policy, a password is considered valid if it adheres to th... | def is_valid_password(password):
"""
Returns "Valid" if the password complies with all the security rules, otherwise returns "Invalid".
"""
# Rule: Password must be at least 8 characters long
if len(password) < 8:
return "Invalid"
# Rule: Password must not contain any spaces
if ... | from solution import is_valid_password, process_passwords
def test_is_valid_password():
assert is_valid_password("P@ssw0rd") == "Valid"
assert is_valid_password("incorrect") == "Invalid"
assert is_valid_password("Secure2021") == "Valid"
assert is_valid_password("Alph@numeric1") == "Valid"
assert is... | [
{
"docstring": "Returns \"Valid\" if the password complies with all the security rules, otherwise returns \"Invalid\".",
"function_declaration": "def is_valid_password(password):",
"function_name": "is_valid_password",
"parameter_list": "(password)"
},
{
"docstring": "Processes a list of pas... | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_valid_password(password):\n \"\"\"\n Check if the given password is valid as per the specified rules.\n \"\"\"\n if len(password) < 8:\n ... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00026096",
"row_id": 26096,
"seed_ids": "[4955]"
} | 0.638685 | Taco_26096 | I | [
"is_valid_password",
"process_passwords"
] | 2 | [
[
"process_passwords",
"is_valid_password"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 692cf85c4bb42201f4d8a2f27f891f27fb88d366 | 8e775109868c455cd8bdf2bed4211df2bd9a7af6 | |||
v1.0 | instruct | Taco | Taco_26126_I | In a magical land called Algorithmia, there is a special kind of tree with nodes that hold valuable information. Each node in this binary tree has a numerical value. The people of Algorithmia have developed a ritual where they must calculate the "mystic sum" of the tree before they can use the information.
The "mystic... | class TreeNode:
def __init__(self, value=0, left=None, right=None):
self.value = value
self.left = left
self.right = right
def build_tree(levels):
if not levels or levels[0] == -1:
return None
root = TreeNode(levels[0])
queue = [(root, 1)]
i = 1
while i < len(lev... | def test_build_tree():
levels = [1, 2, 3, 4, 5, 6, -1, -1, -1, -1, -1, -1, -1]
root = build_tree(levels)
assert root.value == 1
assert root.left.value == 2
assert root.right.value == 3
assert root.left.left.value == 4
assert root.left.right.value == 5
assert root.right.left.value == 6
d... | [] | [
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\nclass TreeNode:\n def __init__(self, value=0):\n self.value = value\n self.left = None\n self.right = None... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00026126",
"row_id": 26126,
"seed_ids": "[19791]"
} | 0.612744 | Taco_26126 | I | [
"build_tree",
"calculate_mystic_sum",
"mystic_sum"
] | 3 | [
[
"mystic_sum",
"build_tree"
],
[
"mystic_sum",
"calculate_mystic_sum"
]
] | 2 | [] | false | [
"TreeNode"
] | true | pytest | false | [] | true | 18d8156b46614bdce6bdf3b2e313d92ea74c5247 | 520a245fa147b3c2d4ec2383b7b16e5d0283798a | |||
v1.0 | instruct | Taco | Taco_26187_I | A group of friends are working on a project to design a game. In this game, a player has to solve sequences of transformations on matrices. Each transformation involves rotating a square matrix 90 degrees to the right, k times. The game has multiple levels, and each level gives the player a matrix along with the number... | def rotate_matrix_90_degrees(matrix):
n = len(matrix)
rotated = [[0] * n for _ in range(n)]
for i in range(n):
for j in range(n):
rotated[j][n - 1 - i] = matrix[i][j]
return rotated
def rotate_matrix(matrix, k):
rotations = k % 4 # As 4 rotations bring the matrix to the initial... | def test_rotate_matrix_90_degrees():
matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
expected = [
[7, 4, 1],
[8, 5, 2],
[9, 6, 3]
]
assert rotate_matrix_90_degrees(matrix) == expected
def test_rotate_matrix():
matrix = [
[1, 2, 3],
[4... | [
{
"docstring": null,
"function_declaration": "def rotate_matrix_90_degrees(matrix):",
"function_name": "rotate_matrix_90_degrees",
"parameter_list": "(matrix)"
},
{
"docstring": null,
"function_declaration": "def rotate_matrix(matrix, k):",
"function_name": "rotate_matrix",
"para... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def rotate_matrix_90_degrees(matrix):\n n = len(matrix)\n rotated = [[0] * n for _ in range(n)]\n for i in range(n):\n for j in range(n):\n ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00026187",
"row_id": 26187,
"seed_ids": "[11590]"
} | 0.669195 | Taco_26187 | I | [
"rotate_matrix_90_degrees",
"rotate_matrix",
"solve_game_configuration",
"main"
] | 4 | [
[
"rotate_matrix",
"rotate_matrix_90_degrees"
],
[
"solve_game_configuration",
"rotate_matrix"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | 2a2e953a1fcc44d39b151b2c5f2eca073897e9f1 | 4a7765dacc1c5b482a9c838ff04bcead07227cd8 | |||
v1.0 | instruct | Taco | Taco_26380_I | Write a function that takes a positive integer `n` as an input and returns the list of all prime numbers less than `n` that are also palindromes.
A **palindrome number** is a number that reads the same backward as forward (e.g., 101, 131, 151).
A **prime number** is a number greater than 1 that has no positive diviso... | from typing import List
def is_prime(num: int) -> bool:
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
retur... | from solution import prime_palindromes
def test_prime_palindromes_less_than_30():
assert prime_palindromes(30) == [2, 3, 5, 7, 11]
def test_prime_palindromes_less_than_100():
assert prime_palindromes(100) == [2, 3, 5, 7, 11]
def test_prime_palindromes_less_than_200():
assert prime_palindromes(200) == [2,... | [
{
"docstring": null,
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": null,
"function_declaration": "def is_palindrome(num):",
"function_name": "is_palindrome",
"parameter_list": "(num)"
},
{
"docstring... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from typing import List\n\ndef is_prime(num: int) -> bool:\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or n... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00026380",
"row_id": 26380,
"seed_ids": "[6989]"
} | 0.639829 | Taco_26380 | I | [
"is_prime",
"is_palindrome",
"prime_palindromes"
] | 3 | [
[
"prime_palindromes",
"is_palindrome"
],
[
"prime_palindromes",
"is_prime"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 386e2f5100d385028e7cbb09dc4e7b053a6d0c33 | 73e57b239f5c1e245267bc27de357e772572a9ca | |||
v1.0 | instruct | Taco | Taco_26393_I | In the magical realm of Hogwarts, students must choose their subjects at the start of each term. However, there's a peculiar way to determine their schedules. Each subject is assigned a unique code, and students must solve a puzzle involving these codes to finalize their schedule.
The puzzle goes like this: You are gi... | def sum_of_digits(num):
"""
Returns the sum of the digits of a given number.
"""
return sum(int(digit) for digit in str(num))
def custom_sort(subject_codes):
"""
Returns the subject codes sorted by the sum of their digits
in non-decreasing order. If two subject codes have the same
sum o... | from solution import custom_sort
def test_single_code():
assert custom_sort([15]) == [15]
def test_multiple_codes_with_different_digit_sums():
assert custom_sort([56, 23, 89, 12, 34]) == [12, 23, 34, 56, 89]
def test_multiple_codes_with_same_digit_sums():
assert custom_sort([102, 210, 31]) == [102, 210, ... | [
{
"docstring": "Returns the sum of the digits of a given number.",
"function_declaration": "def sum_of_digits(num):",
"function_name": "sum_of_digits",
"parameter_list": "(num)"
},
{
"docstring": "Returns the subject codes sorted by the sum of their digits\nin non-decreasing order. If two su... | [
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 sort_subject_codes(subject_codes):\n \"\"\"\n Sort subject codes first by the sum of their digits in non-decreasing order,\n then by their numerical v... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00026393",
"row_id": 26393,
"seed_ids": "[13037]"
} | 0.598403 | Taco_26393 | I | [
"sum_of_digits",
"custom_sort"
] | 2 | [
[
"custom_sort",
"sum_of_digits"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 81f4f376dc9396d95d28f48c7597d5f73dfdcfbc | b963a86c89b3e783c7b6d4e4871ccf1d4e629dd4 | |||
v1.0 | instruct | Taco | Taco_26394_I | Write a function that calculates the sum of all prime numbers less than or equal to a given integer n.
Input
An integer n (2 ≤ n ≤ 1000) is given on a line.
Output
Print the sum of all prime numbers less than or equal to n on a line.
Example
Input
10
Output
17 | def is_prime(num):
"""
Helper function to determine 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
... | from solution import is_prime, sum_of_primes
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(10) == False
assert is_prime(11) == True
def test_sum_of_primes():
assert sum_of_primes(2) == 2... | [
{
"docstring": "Helper function to determine if a number is a prime.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Returns the sum of all prime numbers less than or equal to n.",
"function_declaration": "def sum_... | [
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_primes(n):\n \"\"\"\n Calculates the sum of all prime numbers less than or equal to n.\n \n Parameters:\n n (int): The upper limit intege... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00026394",
"row_id": 26394,
"seed_ids": "[18334]"
} | 0.706874 | Taco_26394 | I | [
"is_prime",
"sum_of_primes"
] | 2 | [
[
"sum_of_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e6ec4a44921bd41f80c7a06d03a2b98d16e22ee3 | 9b6718c3e1c73398bff7a14717e140fb38d13b42 | |||
v1.0 | instruct | Taco | Taco_26397_I | A chef is preparing a special dish that requires cooking multiple ingredients in a sequence. Each ingredient i needs a certain cooking time ti, and the ingredients must be cooked in a specific order. The chef can cook only one ingredient at a time. Given the cooking times of the ingredients and the required order, dete... | def total_cooking_time(test_cases):
results = []
for case in test_cases:
N, times = case
total_time = sum(times)
results.append(total_time)
return results
def parse_input(input_data):
lines = input_data.strip().split('\n')
T = int(lines[0])
test_cases = []
index = 1
... | from solution import cooking_time_wrapper
def test_cooking_time_example_cases():
input_data = "2\n3\n10 20 30\n4\n5 10 15 20\n"
assert cooking_time_wrapper(input_data) == [60, 50]
def test_cooking_time_single_case_small():
input_data = "1\n1\n100\n"
assert cooking_time_wrapper(input_data) == [100]
de... | [
{
"docstring": null,
"function_declaration": "def total_cooking_time(test_cases):",
"function_name": "total_cooking_time",
"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 cooking_time(test_cases):\n \"\"\"\n Returns the minimum total cooking time for each test case.\n \"\"\"\n results = []\n for case in test_cases... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00026397",
"row_id": 26397,
"seed_ids": "[25025]"
} | 0.765275 | Taco_26397 | I | [
"total_cooking_time",
"parse_input",
"cooking_time_wrapper"
] | 3 | [
[
"cooking_time_wrapper",
"parse_input"
],
[
"cooking_time_wrapper",
"total_cooking_time"
]
] | 2 | [
"parse_input"
] | false | [] | false | pytest | true | [] | true | 9f2fcfa0550b71f4c13ad0557a7ad2fcfb7e1b0b | 1eb038fddb891a384110137eb1fb2f528ff14f20 | |||
v1.0 | instruct | Taco | Taco_26400_I | Professor Thoneo recently invented a new function, which she named ThoneoisPrime. For a given integer array `b`, indexed from `1` to `n`, the function ThoneoisPrime(b, k) represents the count of prime numbers in the subarray from the 1st to the kth element.
Thoneo has posed a challenge for you. In this challenge, you ... | def is_prime(n):
"""
Determine if a number is prime.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return False
return True
def thoneo_is_prime(b, queries):... | def test_is_prime():
assert is_prime(1) == False
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(5) == True
assert is_prime(13) == True
def test_thoneo_is_prime():
b = [3, 5, 7, 9, 11]
queries = [(2, 3), (1, 2, 4), (2, 2), (2, 5)]
re... | [
{
"docstring": "Determine if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def thoneo_is_prime(b, queries):",
"function_name": "thoneo_is_prime",
"parameter_li... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00026400",
"row_id": 26400,
"seed_ids": "[18740]"
} | 0.635505 | Taco_26400 | I | [
"is_prime",
"thoneo_is_prime"
] | 2 | [
[
"thoneo_is_prime",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 21b9ae0c13b915b0128efed13609b23163b5ad7b | 3b4754a7eb28e5b6fb91ca6e795bf5d9dde5bd47 | |||
v1.0 | instruct | Taco | Taco_26432_I | In a grid-based puzzle game, the player can move from one cell to any adjacent cell. Adjacent cells are those that share a side (up, down, left, right). The grid is represented by a 2D array of integers, where the player starts at the top-left corner (0, 0) and needs to move to the bottom-right corner (N-1, M-1). Some ... | def can_reach_destination(grid):
from collections import deque
N = len(grid)
M = len(grid[0])
# Directions for exploring adjacent cells: up, down, left, right
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
# Queue for BFS, starting from (0, 0)
queue = deque([(0, 0)])
# Se... | def test_simple_path():
N, M = 3, 3
grid = [
[0, 0, 0],
[1, 0, 1],
[1, 0, 0]
]
assert is_path_exist(N, M, grid) == "YES"
def test_no_path():
N, M = 3, 3
grid = [
[0, 0, 0],
[1, 1, 1],
[1, 0, 0]
]
assert is_path_exist(N, M, grid) == "NO"
d... | [
{
"docstring": null,
"function_declaration": "def can_reach_destination(grid):",
"function_name": "can_reach_destination",
"parameter_list": "(grid)"
},
{
"docstring": null,
"function_declaration": "def is_path_exist(N, M, grid):",
"function_name": "is_path_exist",
"parameter_lis... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def can_reach_bottom_right(grid):\n from collections import deque\n\n N = len(grid)\n M = len(grid[0])\n\n # Directions for moving {Up, Down, Left, Rig... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00026432",
"row_id": 26432,
"seed_ids": "[15789]"
} | 0.803808 | Taco_26432 | I | [
"can_reach_destination",
"is_path_exist"
] | 2 | [
[
"is_path_exist",
"can_reach_destination"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 43667009ac76e182247f1de76ecadf0b13aaa94e | 443f532cebe0d88ba7ea14b379561fc06f9b7f95 | |||
v1.0 | instruct | Taco | Taco_26461_I | You are given a binary tree with n nodes, each node having a positive integer value. Your task is to calculate the sum of values of all nodes lying in the path between two given nodes u and v (inclusive, considering the values of u and v themselves in the sum).
-----Input-----
The first line contains one integer n (1... | class TreeNode:
def __init__(self, value):
self.value = value
self.children = []
def build_tree(n, values, edges):
nodes = [TreeNode(value) for value in values]
for a, b in edges:
nodes[a - 1].children.append(nodes[b - 1])
nodes[b - 1].children.append(nodes[a - 1])
retur... | from solution import sum_path_between_nodes
def test_sum_path_between_nodes_example1():
n = 5
values = [1, 2, 3, 4, 5]
edges = [(1, 2), (1, 3), (3, 4), (3, 5)]
u, v = 2, 4
assert sum_path_between_nodes(n, values, edges, u, v) == 10
def test_sum_path_between_nodes_example2():
n = 3
values =... | [] | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.children = []\n\ndef build_tree(values, edges):\n nodes = [TreeNode(va... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00026461",
"row_id": 26461,
"seed_ids": "[25414]"
} | 0.690839 | Taco_26461 | I | [
"build_tree",
"dfs",
"sum_path_between_nodes"
] | 3 | [
[
"sum_path_between_nodes",
"build_tree"
],
[
"sum_path_between_nodes",
"dfs"
]
] | 2 | [] | false | [
"TreeNode"
] | true | pytest | true | [] | true | afab2279f323a20edd21c5afb4ca385d92e5cc10 | c32a3b162732baa81fbf489453f8052849688657 | |||
v1.0 | instruct | Taco | Taco_26477_I | Read problem statements in CSV format here
A large retail company wants to analyze its sales performance on different days of the week. Each day's sales data is represented as an integer array. The company wants to find out the K-th highest sales amount across all the days combined for various values of K. Given multi... | def find_kth_highest_sales(test_cases):
results = []
for case in test_cases:
N, Q, days_data, queries = case['N'], case['Q'], case['days'], case['queries']
all_sales = []
for sales in days_data:
all_sales.extend(sales)
all_sales.sort(reverse=Tru... | import pytest
def test_example_case():
input_str = "1\n3 2\n10 20 30\n15 25 35\n5 50\n2\n5"
expected_output = [35, 20]
assert get_results(input_str) == expected_output
def test_all_identical_sales():
input_str = "1\n2 2\n10 10 10\n10 10\n3\n6"
expected_output = [10, None]
assert get_results(in... | [
{
"docstring": null,
"function_declaration": "def find_kth_highest_sales(test_cases):",
"function_name": "find_kth_highest_sales",
"parameter_list": "(test_cases)"
},
{
"docstring": null,
"function_declaration": "def parse_input(input_str):",
"function_name": "parse_input",
"para... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_kth_highest_sales(num_test_cases, test_cases):\n results = []\n for test_case in test_cases:\n N, Q, days_sales, queries = test_case\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00026477",
"row_id": 26477,
"seed_ids": "[24831]"
} | 0.726375 | Taco_26477 | I | [
"find_kth_highest_sales",
"parse_input",
"get_results"
] | 3 | [
[
"get_results",
"find_kth_highest_sales"
],
[
"get_results",
"parse_input"
]
] | 2 | [
"parse_input"
] | false | [] | false | pytest | false | [] | true | 64204dea85e039c6fb10d9805fbc1b440cdac387 | 8d38bccdc1912fca580e9561e8d3b3cec6a1f781 | |||
v1.0 | instruct | Taco | Taco_26563_I | A delivery company has decided to optimize the delivery routes by using an automated system that can determine the shortest path for the vehicles. The roads in the city are represented as a bidirectional weighted graph, where intersections are the nodes and roads between them are the edges with non-negative weights ind... | import heapq
def dijkstra(n, graph, start):
"""
Performs the Dijkstra's algorithm to find the shortest path from
start node to all other nodes.
Args:
- n (int): Number of nodes
- graph (dict of lists): Adjacency list where the key is the node
and the value is ... | def test_shortest_travel_time():
n, m, q = 4, 4, 2
roads = [(1, 2, 5), (2, 3, 10), (3, 4, 2), (1, 4, 100)]
queries = [(1, 3), (2, 4)]
assert shortest_travel_time(n, m, q, roads, queries) == [15, 12]
def test_no_path():
n, m, q = 4, 2, 2
roads = [(1, 2, 7), (3, 4, 5)]
queries = [(1, 4), (2, ... | [
{
"docstring": "Performs the Dijkstra's algorithm to find the shortest path from\nstart node to all other nodes.\n\nArgs:\n- n (int): Number of nodes\n- graph (dict of lists): Adjacency list where the key is the node\n and the value is a list of (neighbor, weight)\n- start (int): Starti... | [
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 heapq\n\ndef shortest_paths(n, roads, queries):\n def dijkstra(start):\n \"\"\"\n The function uses Dijkstra's algorithm to find the shorte... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00026563",
"row_id": 26563,
"seed_ids": "[13017]"
} | 0.776593 | Taco_26563 | I | [
"dijkstra",
"shortest_travel_time"
] | 2 | [
[
"shortest_travel_time",
"dijkstra"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 0d04506442005f79827d0648c91484ccb63f45fb | bc3e53510b9169387e3884dcae6c8b0cb5a9bdad | |||
v1.0 | instruct | Taco | Taco_26628_I | Write a program that validates a series of username strings based on specific rules. The rules for a valid username are:
1. The username must be between 5 and 15 characters long.
2. The username must start with an alphabetic character.
3. The username can contain only alphanumeric characters (a-z, A-Z, 0-9).
Your task... | import re
def validate_username(username):
"""
Validates a single username according to the specified rules.
Parameters:
username (str): The username to validate.
Returns:
str: "Valid" if the username is valid, otherwise "Invalid".
"""
# Check if the username is between 5 and ... | from solution import validate_username, validate_usernames
def test_validate_username():
assert validate_username("user_1") == "Invalid"
assert validate_username("User2") == "Valid"
assert validate_username("aVeryLongUsername123") == "Invalid"
assert validate_username("abc") == "Invalid"
assert val... | [
{
"docstring": "Validates a single username according to the specified rules.\n\nParameters:\nusername (str): The username to validate.\n\nReturns:\nstr: \"Valid\" if the username is valid, otherwise \"Invalid\".",
"function_declaration": "def validate_username(username):",
"function_name": "validate_us... | [
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 re\n\ndef is_valid_username(username):\n \"\"\"\n Validates a username based on the following rules:\n 1. The username must be between 5 and 15 cha... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00026628",
"row_id": 26628,
"seed_ids": "[17296]"
} | 0.594846 | Taco_26628 | I | [
"validate_username",
"validate_usernames"
] | 2 | [
[
"validate_usernames",
"validate_username"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2f56a27747cd670003fbbfeb4ebafc816bd19a29 | e30bb9f7e20aeefaca823ff85f2fd830d8cf81b7 | |||
v1.0 | instruct | Taco | Taco_26664_I | Alex is a fan of prime numbers and loves solving problems involving them. One day, his friend gave him a challenge involving a rotated sorted array.
Alex is given a rotated sorted array of $N$ integers and is then provided with a list of $Q$ queries. Each query consists of two integers $L$ and $R$, and Alex needs to c... | # To check for prime numbers
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 check_prime_i... | from solution import is_prime, check_prime_in_subarray
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(17) == True
assert is_prime(18) == False
assert is_prime(19) == True
assert is_prime(1) == False
def test_check_prim... | [
{
"docstring": null,
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def check_prime_in_subarray(arr, queries):",
"function_name": "check_prime_in_subarray",
"parameter_list": "(arr,... | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
1
] | 2 | 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 \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return Tru... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00026664",
"row_id": 26664,
"seed_ids": "[4743]"
} | 0.612378 | Taco_26664 | I | [
"is_prime",
"check_prime_in_subarray"
] | 2 | [
[
"check_prime_in_subarray",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 1cf49e23f65e0bb8136fe2d586b674401377e311 | 14f6b4f3f8459e2e2e60dd61a2eb90971d187876 | |||
v1.0 | instruct | Taco | Taco_26678_I | Given an integer n, find the maximum product of its digits after performing at most one swap between any two digits of the number. If the number remains the same, the product of its digits should be calculated once. The product of digits of a number is defined as the product of all its digits.
For example, for the num... | import itertools
def max_product_after_swap(n: int) -> int:
"""
Compute the maximum product of digits of the number n after performing at most one swap between any two digits.
Args:
n (int): The integer number for which the maximum product needs to be evaluated.
Returns:
int: The maxi... | from solution import max_product_after_swap
def test_max_product_after_swap_2736():
assert max_product_after_swap(2736) == 252
def test_max_product_after_swap_9973():
assert max_product_after_swap(9973) == 1701
def test_max_product_after_swap_321():
assert max_product_after_swap(321) == 6
def test_max_p... | [
{
"docstring": "Compute the maximum product of digits of the number n after performing at most one swap between any two digits.\n\nArgs:\nn (int): The integer number for which the maximum product needs to be evaluated.\n\nReturns:\nint: The maximum product of digits after the potential one swap.",
"function... | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from itertools import permutations\n\ndef digit_product(num):\n \"\"\"\n Helper function to calculate the product of digits of the number.\n \"\"\"\n p... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00026678",
"row_id": 26678,
"seed_ids": "[25123]"
} | 0.690381 | Taco_26678 | I | [
"max_product_after_swap",
"product_of_digits"
] | 2 | [
[
"max_product_after_swap",
"product_of_digits"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 445ba4b9364e3c8ffa20b7172787fd93f5bd6a66 | e0d34bd6876c1901d469ca6d06cba31ebd07310c | |||
v1.0 | instruct | Taco | Taco_26727_I | Write a program to find the length of the shortest transformation sequence from a starting word to a target word, given a list of intermediate words. Each intermediate word represents a valid transformation if it is one character change away from the current word, and all transformations must use intermediate words fro... | from collections import deque
def is_one_char_diff(word1, word2):
"""
Helper function to check if two words differ by exactly one character.
"""
count = 0
for c1, c2 in zip(word1, word2):
if c1 != c2:
count += 1
if count > 1:
return False
return count == ... | from solution import shortest_transformation_sequence
def test_example_1():
start = "hit"
target = "cog"
word_list = ["hot", "dot", "dog", "lot", "log", "cog"]
assert shortest_transformation_sequence(start, target, word_list) == 5
def test_example_2():
start = "hit"
target = "cog"
word_lis... | [
{
"docstring": "Helper function to check if two words differ by exactly one character.",
"function_declaration": "def is_one_char_diff(word1, word2):",
"function_name": "is_one_char_diff",
"parameter_list": "(word1, word2)"
},
{
"docstring": "Returns the length of the shortest transformation... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque\n\ndef shortest_transformation_sequence(start, target, word_list):\n if target not in word_list:\n return 0\n\n word_set... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00026727",
"row_id": 26727,
"seed_ids": "[8825]"
} | 0.698176 | Taco_26727 | I | [
"is_one_char_diff",
"shortest_transformation_sequence"
] | 2 | [
[
"shortest_transformation_sequence",
"is_one_char_diff"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 02f41e8237dce48df5b259c387405da776342ec9 | e43e2e5cdbe5c85bd2848d4a00fd0d76d8327b7f | |||
v1.0 | instruct | Taco | Taco_26749_I | Problem Description
A very powerful alien race has challenged you to solve a puzzle to prove human intelligence. The puzzle is called "Binary Tree Path Sum".
You are given a binary tree where each node contains an integer value (which can be negative or positive). Your task is to find all root-to-leaf paths where ea... | class TreeNode:
def __init__(self, value=0, left=None, right=None):
self.value = value
self.left = left
self.right = right
def find_paths(root, target_sum):
if not root:
return []
def dfs(node, current_sum, path, results):
if not node:
return
... | from solution import parse_input, build_tree, find_paths, run_tests
def test_parse_input():
input_data = "1\n22\n5 4 8 11 None 13 4 7 2 None None None 1"
expected = [(22, [5, 4, 8, 11, None, 13, 4, 7, 2, None, None, None, 1])]
assert parse_input(input_data) == expected
def test_build_tree():
level_ord... | [] | [
0,
0,
0,
0,
1
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t... | trial_gpt4o_4 | {
"original_instruction": "",
"prompt_id": "00026749",
"row_id": 26749,
"seed_ids": "[679]"
} | 0.615346 | Taco_26749 | I | [
"find_paths",
"build_tree",
"parse_input",
"run_tests"
] | 4 | [
[
"run_tests",
"build_tree"
],
[
"run_tests",
"find_paths"
],
[
"run_tests",
"parse_input"
]
] | 3 | [
"parse_input"
] | false | [
"TreeNode"
] | true | pytest | true | [] | true | 08f36e846627e3d61b52b9eb8c3e31856a9f3499 | 2c411156a3129f868e74afa63dac2a9ff0977997 | |||
v1.0 | instruct | Taco | Taco_26782_I | Percy the Hedgehog loves collecting shiny objects, and he's particularly fond of gemstones. He organizes his gemstones in a linear sequence based on their intrinsic beauty values, represented as a sequence of integers.
To upgrade his collection, Percy engages in the following magical operation: he can choose any three... | def median_of_three(a, b, c):
"""
Given three numbers a, b, and c, return their median.
"""
return sorted([a, b, c])[1]
def max_beauty_value(n, beauties):
"""
Given the number of gemstones and their beauty values, return the maximum possible beauty value
of the gemstone if Percy keeps apply... | from solution import percy_gemstones
def test_case_1():
T = 1
test_cases = [(3, [1, 3, 2])]
assert percy_gemstones(T, test_cases) == [2]
def test_case_2():
T = 1
test_cases = [(4, [4, 2, 5, 1])]
assert percy_gemstones(T, test_cases) == [4]
def test_case_3():
T = 1
test_cases = [(5... | [
{
"docstring": "Given three numbers a, b, and c, return their median.",
"function_declaration": "def median_of_three(a, b, c):",
"function_name": "median_of_three",
"parameter_list": "(a, b, c)"
},
{
"docstring": "Given the number of gemstones and their beauty values, return the maximum poss... | [
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 max_beauty_value(n, beauties):\n \"\"\"\n Determine the maximum possible beauty value of the last remaining gemstone.\n :param n: Number of gemstones\... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00026782",
"row_id": 26782,
"seed_ids": "[19814]"
} | 0.642465 | Taco_26782 | I | [
"median_of_three",
"max_beauty_value",
"percy_gemstones"
] | 3 | [
[
"percy_gemstones",
"max_beauty_value"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 1850437e4d8b8e29d22d38c0eac3946cd77f4744 | 7cb10069f0b11eaa894415dca272c04ae6d131bc | |||
v1.0 | instruct | Taco | Taco_26837_I | Snuke has a favorite number S and he is very fond of prime numbers. He decides to find a pair of prime numbers (p1, p2) such that p1 + p2 = S and |p1 - p2| is minimized. If there is more than one pair with the same difference, choose the one with the largest p1. If no such pair exists, output "No pair found".
-----Con... | import math
def sieve_of_eratosthenes(max_num):
"""
Generates a list of booleans indicating primality of numbers up to max_num.
"""
is_prime = [True] * (max_num + 1)
is_prime[0] = is_prime[1] = False # 0 and 1 are not prime numbers
for start in range(2, int(math.sqrt(max_num)) + 1):
... | def test_find_prime_pair():
assert find_prime_pair(10) == (3, 7) or find_prime_pair(10) == (5, 5)
assert find_prime_pair(34) == (17, 17)
assert find_prime_pair(40) == (17, 23)
assert find_prime_pair(2) == "No pair found"
assert find_prime_pair(20) == (7, 13)
def test_prime_pairs_large_input():
... | [
{
"docstring": "Generates a list of booleans indicating primality of numbers up to max_num.",
"function_declaration": "def sieve_of_eratosthenes(max_num):",
"function_name": "sieve_of_eratosthenes",
"parameter_list": "(max_num)"
},
{
"docstring": null,
"function_declaration": "def find_p... | [
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_prime_pair(S):\n \"\"\"\n Find two prime numbers p1 and p2 such that:\n - p1 + p2 == S\n - |p1 - p2| is minimized\n - If multiple pairs hav... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00026837",
"row_id": 26837,
"seed_ids": "[19980]"
} | 0.667637 | Taco_26837 | I | [
"sieve_of_eratosthenes",
"find_prime_pair"
] | 2 | [
[
"find_prime_pair",
"sieve_of_eratosthenes"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 74dfccd5e2f98d46f87bd327de391c8079170329 | a4d86685c5ad5ed884570d27b061a7eccaf9587a | |||
v1.0 | instruct | Taco | Taco_26877_I | You are given a 2D grid of size n × m representing a farm. Each cell in the grid has either a crop (represented by 1) or is left empty (represented by 0). The farm can be rotated 90 degrees clockwise a certain number of times to change its orientation, which can help in performing various agriculture operations.
Your ... | def rotate_90(grid):
"""
Rotates a given grid 90 degrees clockwise.
"""
n, m = len(grid), len(grid[0])
return [[grid[n - j - 1][i] for j in range(n)] for i in range(m)]
def max_continuous_crops(row):
"""
Returns the maximum number of continuous crops (1s) in a row.
"""
max_count = 0... | from solution import rotate_90, max_continuous_crops, process_queries
def test_rotate_90():
grid = [
[0, 1, 0, 1],
[1, 1, 1, 0],
[0, 0, 1, 1]
]
rotated = rotate_90(grid)
expected = [
[0, 1, 0],
[0, 1, 1],
[1, 1, 0],
[1, 0, 1]
]
assert rota... | [
{
"docstring": "Rotates a given grid 90 degrees clockwise.",
"function_declaration": "def rotate_90(grid):",
"function_name": "rotate_90",
"parameter_list": "(grid)"
},
{
"docstring": "Returns the maximum number of continuous crops (1s) in a row.",
"function_declaration": "def max_contin... | [
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 max_continuous_crops_after_rotation(n, m, grid, queries):\n def rotate_grid_90_clockwise(grid):\n return [[grid[n - 1 - j][i] for j in range(n)] for ... | trial_gpt4o_5 | {
"original_instruction": "",
"prompt_id": "00026877",
"row_id": 26877,
"seed_ids": "[12693]"
} | 0.674709 | Taco_26877 | I | [
"rotate_90",
"max_continuous_crops",
"process_queries"
] | 3 | [
[
"process_queries",
"max_continuous_crops"
],
[
"process_queries",
"rotate_90"
]
] | 2 | [
"process_queries"
] | false | [] | false | pytest | true | [] | true | f5cd842383acc0f645f7e790b4afeee4108c0ba6 | 1ed776b6bdc7d1855c1a729ed7861920ed75d965 | |||
v1.0 | instruct | Taco | Taco_26927_I | A game involves a grid of cells, where each cell can be either alive or dead. This game follows specific rules:
1. Any live cell with fewer than two live neighbors dies (underpopulation).
2. Any live cell with two or three live neighbors lives on to the next generation.
3. Any live cell with more than three live neigh... | def get_next_state(grid, M, N):
def get_live_neighbors_count(grid, x, y):
live_neighbors = 0
directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]
for dx, dy in directions:
nx, ny = x + dx, y + dy
if 0 <= nx < M and 0 <= ny < N and grid[n... | from solution import process_input
def test_example_case_1():
M, N, K = 3, 3, 1
grid_lines = ['.O.', 'OOO', '.O.']
expected_output = ['OOO', 'O.O', 'OOO']
assert process_input(M, N, K, grid_lines) == expected_output
def test_minimal_case():
M, N, K = 1, 1, 1
grid_lines = ['.']
expected_out... | [
{
"docstring": null,
"function_declaration": "def get_next_state(grid, M, N):",
"function_name": "get_next_state",
"parameter_list": "(grid, M, N)"
},
{
"docstring": null,
"function_declaration": "def game_of_life(grid, M, N, K):",
"function_name": "game_of_life",
"parameter_list... | [
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 game_of_life(M, N, K, grid):\n def count_live_neighbors(board, r, c):\n directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00026927",
"row_id": 26927,
"seed_ids": "[8426]"
} | 0.690322 | Taco_26927 | I | [
"get_next_state",
"game_of_life",
"process_input"
] | 3 | [
[
"game_of_life",
"get_next_state"
],
[
"process_input",
"game_of_life"
]
] | 2 | [
"process_input"
] | false | [] | false | pytest | true | [] | true | fe1bf76e78c02b10f00545c12c7f1f300548f9ad | 790cfe7685ff109870f81365c9a80aea750d21fd | |||
v1.0 | instruct | Taco | Taco_26931_I | Ming is a chess enthusiast and likes to place queens on a chessboard. One day, a friend challenged him to place as many queens as possible on an N x N chessboard such that no two queens can attack each other. You may recall that a queen in chess can move horizontally, vertically, or diagonally any number of squares.
Y... | def is_safe(board, row, col, n):
# Check the same column
for i in range(row):
if board[i][col] == 'Q':
return False
# Check the upper left diagonal
for i, j in zip(range(row, -1, -1), range(col, -1, -1)):
if board[i][j] == 'Q':
return False
# Check the upper... | from solution import count_queens
def test_count_queens_1():
assert count_queens(1) == 1
def test_count_queens_2():
assert count_queens(2) == 0
def test_count_queens_3():
assert count_queens(3) == 0
def test_count_queens_4():
assert count_queens(4) == 4
def test_count_queens_5():
assert count_q... | [
{
"docstring": null,
"function_declaration": "def is_safe(board, row, col, n):",
"function_name": "is_safe",
"parameter_list": "(board, row, col, n)"
},
{
"docstring": null,
"function_declaration": "def solve_n_queens(board, row, n, result):",
"function_name": "solve_n_queens",
"... | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def solveNQueens(N):\n \"\"\" Returns the solution to the N-Queens problem \"\"\"\n def isSafe(board, row, col):\n # Check this row on the left side\n... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00026931",
"row_id": 26931,
"seed_ids": "[15520]"
} | 0.714057 | Taco_26931 | I | [
"is_safe",
"solve_n_queens",
"max_queens",
"count_queens"
] | 4 | [
[
"max_queens",
"solve_n_queens"
],
[
"solve_n_queens",
"is_safe"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | f974c32074bb8632f76effc22ff5b90f74ac1838 | f4e925a8c094cfef2b6566d634f3b8e323a0074c | |||
v1.0 | instruct | Taco | Taco_26980_I | You are given a **binary tree** consisting of `n` nodes. A binary tree can be uniquely identified by its **preorder** and **inorder** traversals (both given in arrays).
Write a program to reconstruct the binary tree from its preorder and inorder traversal arrays, and then perform a **postorder** traversal of the tree.... | class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def build_tree(preorder, inorder):
if not preorder or not inorder:
return None
root_val = preorder[0]
root = TreeNode(root_val)
root_index_inorde... | from solution import reconstruct_and_postorder
def test_example():
n = 6
preorder = [1, 2, 4, 5, 3, 6]
inorder = [4, 2, 5, 1, 6, 3]
assert reconstruct_and_postorder(n, preorder, inorder) == [4, 5, 2, 6, 3, 1]
def test_single_node():
n = 1
preorder = [1]
inorder = [1]
assert reconstruct... | [] | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00026980",
"row_id": 26980,
"seed_ids": "[1001]"
} | 0.633536 | Taco_26980 | I | [
"build_tree",
"postorder_traversal",
"reconstruct_and_postorder"
] | 3 | [
[
"reconstruct_and_postorder",
"build_tree"
],
[
"reconstruct_and_postorder",
"postorder_traversal"
]
] | 2 | [] | false | [
"TreeNode"
] | true | pytest | true | [] | true | 77fad34a4479e97d9c1e60ab2e532ae8cff84ba8 | e8d4629efb41d6dfa1edf0ea2fc0844a1b54c9a1 | |||
v1.0 | instruct | Taco | Taco_26987_I | You are given a sequence of integers. You need to answer several queries about the sum of the elements in a subarray. More formally, each query is defined by two integers `L` and `R`. You need to output the sum of the elements in the subarray that starts at position `L` and ends at position `R` (both inclusive).
Examp... | def create_prefix_sum(arr):
"""
Creates a prefix sum array for the given array.
"""
prefix_sum = [0] * (len(arr) + 1)
for i in range(1, len(arr) + 1):
prefix_sum[i] = prefix_sum[i - 1] + arr[i - 1]
return prefix_sum
def subarray_sum(arr, queries):
"""
Given an array and queries,... | def test_create_prefix_sum():
arr = [1, 2, 3, 4, 5]
expected = [0, 1, 3, 6, 10, 15]
assert create_prefix_sum(arr) == expected
def test_subarray_sum():
arr = [1, 2, 3, 4, 5]
queries = [(1, 3), (2, 5), (1, 5)]
expected = [6, 14, 15]
assert subarray_sum(arr, queries) == expected
def test_suba... | [
{
"docstring": "Creates a prefix sum array for the given array.",
"function_declaration": "def create_prefix_sum(arr):",
"function_name": "create_prefix_sum",
"parameter_list": "(arr)"
},
{
"docstring": "Given an array and queries, returns the sum of the subarrays for each query.\n\nParamete... | [
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 precompute_prefix_sums(arr):\n \"\"\"\n Precompute prefix sums for the array.\n \"\"\"\n prefix_sums = [0] * (len(arr) + 1)\n for i in range(1, ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00026987",
"row_id": 26987,
"seed_ids": "[4066]"
} | 0.71534 | Taco_26987 | I | [
"create_prefix_sum",
"subarray_sum"
] | 2 | [
[
"subarray_sum",
"create_prefix_sum"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | d7c6b679d0c8ab8ff7bc49c65ce37897f6a0387d | aa43507c1975a134fc215848fe3d318e528799b0 | |||
v1.0 | instruct | Taco | Taco_27076_I | Your friend has recently learned about prime numbers and palindrome numbers. They are now interested in finding numbers that are both prime and palindrome, which we call "palindromic primes". To help your friend, you decide to write a program that finds the smallest palindromic prime greater than a given number n.
A n... | 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 is_palindrome(num):
re... | from solution import smallest_palindromic_prime_greater_than
def test_example_1():
assert smallest_palindromic_prime_greater_than(31) == 101
def test_example_2():
assert smallest_palindromic_prime_greater_than(11) == 101
def test_example_3():
assert smallest_palindromic_prime_greater_than(101) == 131
de... | [
{
"docstring": null,
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": null,
"function_declaration": "def is_palindrome(num):",
"function_name": "is_palindrome",
"parameter_list": "(num)"
},
{
"docstring... | [
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_palindrome(num):\n \"\"\"\n Check if a number is a palindrome.\n \"\"\"\n return str(num) == str(num)[::-1]\n\ndef is_prime(num):\n \"\"\"\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00027076",
"row_id": 27076,
"seed_ids": "[17594]"
} | 0.769923 | Taco_27076 | I | [
"is_prime",
"is_palindrome",
"smallest_palindromic_prime_greater_than"
] | 3 | [
[
"smallest_palindromic_prime_greater_than",
"is_palindrome"
],
[
"smallest_palindromic_prime_greater_than",
"is_prime"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 7dd232f458ec8cf1befc798d6a7952272f92d942 | 7db34995dd48fb78c327e3770e3dbd6bb1069dcd | |||
v1.0 | instruct | Taco | Taco_27089_I | You are given a 2-dimensional plane with a horizontal number line represented by an x-axis. A set of vertical sticks of varying lengths is placed on this line. All sticks are standing on the x-axis at different x-coordinates.
Write a function to determine the area of the largest rectangle that can be formed using any ... | def largest_rectangle_area(sticks):
heights = [sticks[i] for i in range(1, len(sticks), 2)]
max_area = 0
stack = []
heights.append(0)
for i in range(len(heights)):
while stack and heights[i] < heights[stack[-1]]:
h = heights[stack.pop()]
width = i if not stack el... | from solution import largest_rectangle
def test_example_1():
assert largest_rectangle("1 2 2 1 3 5 4 6 5 2") == 10
def test_example_2():
assert largest_rectangle("1 1 2 2 3 3 4 4 5 5") == 9
def test_example_3():
assert largest_rectangle("1 6 2 3 3 4") == 9
def test_single_stick():
assert largest_rec... | [
{
"docstring": null,
"function_declaration": "def largest_rectangle_area(sticks):",
"function_name": "largest_rectangle_area",
"parameter_list": "(sticks)"
},
{
"docstring": null,
"function_declaration": "def parse_input(input_string):",
"function_name": "parse_input",
"parameter... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def largest_rectangle_area(sticks):\n \"\"\"\n Finds the largest rectangular area that can be formed using any contiguous set of sticks.\n \n Args:\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00027089",
"row_id": 27089,
"seed_ids": "[12839]"
} | 0.715312 | Taco_27089 | I | [
"largest_rectangle_area",
"parse_input",
"largest_rectangle"
] | 3 | [
[
"largest_rectangle",
"largest_rectangle_area"
],
[
"largest_rectangle",
"parse_input"
]
] | 2 | [
"parse_input"
] | false | [] | false | pytest | true | [] | true | 9ef5ccb8563082b80e0728565ab8aa3b5e628124 | 8b66277e3faeb145dc39dd877efce2ec45a24ecc | |||
v1.0 | instruct | Taco | Taco_27120_I | The Galaxy Federation is organizing an interstellar programming contest. Each team is assigned one spaceship and asked to solve a set of programming problems during the course of a galactic journey. The journey consists of a series of missions, and for each mission, the teams can earn energy points based on their perfo... | def calculate_energy_points_and_metrics(missions):
energy_points = 0
successful_missions = 0
pirate_encounters = 0
for mission in missions:
if mission == 'S':
energy_points += 3
successful_missions += 1
elif mission == 'E':
energy_points -= 1
... | def test_interstellar_programming_contest():
input_data = "2\n3\nSSNN\nSSEW\nSENNN\n2\nSESENS\nENS\n"
expected_output = ["1", "1"]
assert interstellar_programming_contest(input_data) == expected_output
def test_interstellar_programming_contest_with_tie():
input_data = "1\n3\nSSSSS\nSSSSS\nEEE\n"
ex... | [
{
"docstring": null,
"function_declaration": "def calculate_energy_points_and_metrics(missions):",
"function_name": "calculate_energy_points_and_metrics",
"parameter_list": "(missions)"
},
{
"docstring": null,
"function_declaration": "def find_winner(test_cases):",
"function_name": "... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_winner(test_cases):\n def calculate_points(team_result):\n points = 0\n successful_missions = 0\n encounters = 0\n for miss... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00027120",
"row_id": 27120,
"seed_ids": "[5500]"
} | 0.735993 | Taco_27120 | I | [
"calculate_energy_points_and_metrics",
"find_winner",
"interstellar_programming_contest"
] | 3 | [
[
"find_winner",
"calculate_energy_points_and_metrics"
],
[
"interstellar_programming_contest",
"find_winner"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | f5cf64b82ad73e3e9dfd39b7b21b361cc1b1b85c | 32aa49a153a7664bb0ec9e41e8091d9fff102cb8 | |||
v1.0 | instruct | Taco | Taco_27163_I | Dr. Victor is a scientist who has a laboratory with a unique security system. His lab is located in a facility having multiple rooms connected by a series of passageways. Each passageway has a different security level which represents the risk associated with passing through it. Dr. Victor needs to find the safest rout... | import heapq
def dijkstra(graph, N):
max_security = [float('inf')] * (N + 1)
max_security[1] = 0
pq = [(0, 1)]
while pq:
current_security, u = heapq.heappop(pq)
for v, security in graph[u]:
max_security_level = max(current_security, security)
if max... | def test_parse_input():
input_str = "6 7\n1 2 3\n1 3 4\n2 4 2\n3 4 6\n4 5 1\n5 6 3\n4 6 4\n4 4\n1 2 5\n1 3 4\n2 4 1\n3 4 2\n0 0\n"
expected_output = [
[(6, 7), (1, 2, 3), (1, 3, 4), (2, 4, 2), (3, 4, 6), (4, 5, 1), (5, 6, 3), (4, 6, 4)],
[(4, 4), (1, 2, 5), (1, 3, 4), (2, 4, 1), (3, 4, 2)],
... | [
{
"docstring": null,
"function_declaration": "def dijkstra(graph, N):",
"function_name": "dijkstra",
"parameter_list": "(graph, N)"
},
{
"docstring": null,
"function_declaration": "def find_safest_route(datasets):",
"function_name": "find_safest_route",
"parameter_list": "(datase... | [
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 find(parent, node):\n if parent[node] != node:\n parent[node] = find(parent, parent[node])\n return parent[node]\n\ndef union(parent, rank, u, v):... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00027163",
"row_id": 27163,
"seed_ids": "[23331]"
} | 0.656823 | Taco_27163 | I | [
"dijkstra",
"find_safest_route",
"parse_input",
"main"
] | 4 | [
[
"find_safest_route",
"dijkstra"
]
] | 1 | [
"parse_input"
] | false | [] | false | pytest | false | [] | true | db19f3161e886afe9ad3945e4ea8b01f83707453 | 4022fe3546e84e33c5ec6ccb9de37fcdbe41ad58 | |||
v1.0 | instruct | Taco | Taco_27189_I | Given a list of up to 100,000 email addresses, write a program that processes them to identify which of the email addresses are valid, according to the following rules:
1. The email address must start with a local part, followed by the "@" symbol, and then a domain part.
2. The local part can contain lowercase letters ... | import re
def is_valid_email(email):
"""
Validates an email address based on the given rules.
"""
email_regex = re.compile(
r'^[a-z0-9]+[a-z0-9._-]*[a-z0-9]+@[a-z0-9]+\.[a-z0-9]+$',
re.IGNORECASE
)
local_part = re.compile(r'^[a-z0-9]+([._-][a-z0-9]+)*$', re.IGNORECASE)
... | from solution import is_valid_email, process_emails
def test_single_valid_emails():
assert is_valid_email("user.name@example.com") == "valid"
assert is_valid_email("abc.def@mail.com") == "valid"
def test_single_invalid_emails():
assert is_valid_email("user--name@example-domain.com") == "invalid"
asser... | [
{
"docstring": "Validates an email address based on the given rules.",
"function_declaration": "def is_valid_email(email):",
"function_name": "is_valid_email",
"parameter_list": "(email)"
},
{
"docstring": null,
"function_declaration": "def process_emails(M, emails):",
"function_name... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import re\n\ndef validate_emails(email_list):\n \"\"\"\n Given a list of email addresses, return a list indicating whether each email is 'valid' or 'invalid'... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00027189",
"row_id": 27189,
"seed_ids": "[7491]"
} | 0.549466 | Taco_27189 | I | [
"is_valid_email",
"process_emails"
] | 2 | [
[
"process_emails",
"is_valid_email"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 87207b4988328a73a2c44a6648bec2f98f71ea26 | 722f86373f4a3d1db59765a2e4a6fcd4b9ccf433 | |||
v1.0 | instruct | Taco | Taco_27193_I | You are given a grid of size N x M, filled with integer values. You need to answer Q queries for the grid. Each query requires you to calculate the sum of all values in a sub-grid.
INPUT
The first line of input will contain two integers, N and M, the number of rows and columns in the grid respectively. The next N lin... | def prefix_sum(grid):
N = len(grid)
M = len(grid[0])
prefix = [[0] * (M + 1) for _ in range(N + 1)]
for i in range(1, N+1):
for j in range(1, M+1):
prefix[i][j] = grid[i-1][j-1] + prefix[i-1][j] + prefix[i][j-1] - prefix[i-1][j-1]
return prefix
def sum_subgrid(... | from solution import process_queries
def test_example_case():
grid = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
queries = [
(1, 1, 2, 2),
(2, 2, 3, 3)
]
expected = [12, 28]
assert process_queries(grid, queries) == expected
def test_single_element_grid():
gr... | [
{
"docstring": null,
"function_declaration": "def prefix_sum(grid):",
"function_name": "prefix_sum",
"parameter_list": "(grid)"
},
{
"docstring": null,
"function_declaration": "def sum_subgrid(prefix, r1, c1, r2, c2):",
"function_name": "sum_subgrid",
"parameter_list": "(prefix, ... | [
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 calculate_sum(grid, queries):\n \"\"\"\n Returns a list of sums for each query sub-grid from the input grid.\n \n Parameters:\n grid (list of li... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00027193",
"row_id": 27193,
"seed_ids": "[5285]"
} | 0.68607 | Taco_27193 | I | [
"prefix_sum",
"sum_subgrid",
"process_queries"
] | 3 | [
[
"process_queries",
"prefix_sum"
],
[
"process_queries",
"sum_subgrid"
]
] | 2 | [
"process_queries"
] | false | [] | false | pytest | true | [] | true | 987431acb341ff153c3ad36d3722a9c3feebcc2c | 1aac4a167691831f42e06f38d89c22f8ce630d73 | |||
v1.0 | instruct | Taco | Taco_27244_I | You are given a binary tree with N nodes. Each node has an integer value associated with it. Your task is to determine if there exists a path from the root to any leaf such that the sum of the values of the nodes along the path equals a given integer targetSum.
A binary tree is defined as a tree data structure where e... | from typing import Optional, List
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def hasPathSum(root: Optional[TreeNode], targetSum: int) -> bool:
if not root:
return False
targetSum -= root.val
if not root.left and not root.... | import pytest
from solution import determine_path_sum_exists
def test_basic_case():
test_data = [
[5, 22, [5, 4, 8, 11, None, 13, 4, 7, 2, None, None, None, 1]],
[3, 5, [1, 2, 3]]
]
assert determine_path_sum_exists(2, test_data) == ["Yes", "No"]
def test_single_node_tree():
test_data =... | [] | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef hasPath... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00027244",
"row_id": 27244,
"seed_ids": "[22465]"
} | 0.699574 | Taco_27244 | I | [
"hasPathSum",
"build_tree",
"determine_path_sum_exists"
] | 3 | [
[
"determine_path_sum_exists",
"build_tree"
],
[
"determine_path_sum_exists",
"hasPathSum"
]
] | 2 | [] | false | [
"TreeNode"
] | true | pytest | true | [] | true | 82eadf84187b807cb5e206ab3e92dd43438d8ea0 | 1c7e07af410275f6888b4d9885bb28d9955aecd0 | |||
v1.0 | instruct | Taco | Taco_27269_I | You are given a grid with $n$ rows and $m$ columns. Each cell is either empty ('.') or filled with an obstacle ('#'). You need to determine how many ways there are to move from the top-left corner of the grid (cell $(1, 1)$) to the bottom-right corner (cell $(n, m)$) by only moving down or right, and without passing th... | def count_paths(grid, n, m):
if grid[0][0] == '#' or grid[n-1][m-1] == '#':
return 0
dp = [[0] * m for _ in range(n)]
dp[0][0] = 1
for i in range(n):
for j in range(m):
if grid[i][j] == '#':
dp[i][j] = 0
else:
if i > 0:
... | from solution import count_paths_from_input
def test_example_case():
n, m = 3, 3
grid_lines = [
".#.",
"...",
"#.."
]
assert count_paths_from_input(n, m, grid_lines) == 2
def test_no_path_due_to_obstacle():
n, m = 3, 3
grid_lines = [
".#.",
".#.",
... | [
{
"docstring": null,
"function_declaration": "def count_paths(grid, n, m):",
"function_name": "count_paths",
"parameter_list": "(grid, n, m)"
},
{
"docstring": null,
"function_declaration": "def count_paths_from_input(n, m, grid_lines):",
"function_name": "count_paths_from_input",
... | [
0,
0,
0,
1
] | 1 | hard | 0.25 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_paths(grid, n, m):\n if grid[0][0] == '#' or grid[n-1][m-1] == '#':\n return 0\n\n dp = [[0] * m for _ in range(n)]\n dp[0][0] = 1\n\n ... | trial_gpt4o_4 | {
"original_instruction": "",
"prompt_id": "00027269",
"row_id": 27269,
"seed_ids": "[6234]"
} | 0.768566 | Taco_27269 | I | [
"count_paths",
"count_paths_from_input"
] | 2 | [
[
"count_paths_from_input",
"count_paths"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c6ce1f230f720561570fb41fbec12bd3d4021a78 | 8f0cac8840efe6039cd4ac4169ee14dc4b6a347a | |||
v1.0 | instruct | Taco | Taco_27373_I | Bob loves playing with numbers. In particular, he is fascinated with the concept of sequences and wants to create a special sequence with a specific property.
Given two integers, a and b, Bob wants to find the smallest positive integer n such that it satisfies the following conditions:
1. n must be a multiple of both ... | import math
def lcm(a, b):
"""
Returns the least common multiple of a and b.
"""
return abs(a * b) // math.gcd(a, b)
def sum_of_digits(n):
"""
Returns the sum of the digits of n.
"""
return sum(int(digit) for digit in str(n))
def smallest_multiple_with_min_digit_sum(a, b):
"""
... | from solution import smallest_multiple_with_min_digit_sum
def test_smallest_multiple_with_min_digit_sum():
assert smallest_multiple_with_min_digit_sum(12, 15) == 60
assert smallest_multiple_with_min_digit_sum(13, 17) == 221
assert smallest_multiple_with_min_digit_sum(10, 20) == 20
def test_lcm():
asse... | [
{
"docstring": "Returns the least common multiple of a and b.",
"function_declaration": "def lcm(a, b):",
"function_name": "lcm",
"parameter_list": "(a, b)"
},
{
"docstring": "Returns the sum of the digits of n.",
"function_declaration": "def sum_of_digits(n):",
"function_name": "sum... | [
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": "import math\n\ndef lcm(a, b):\n return abs(a * b) // math.gcd(a, b)\n\ndef sum_of_digits(number):\n return sum(int(digit) for digit in str(number))\n\ndef sm... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00027373",
"row_id": 27373,
"seed_ids": "[22514]"
} | 0.680856 | Taco_27373 | I | [
"lcm",
"sum_of_digits",
"smallest_multiple_with_min_digit_sum"
] | 3 | [
[
"smallest_multiple_with_min_digit_sum",
"lcm"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b02b0587d764b0b3adaddd554aa42682a4294b66 | 21a348bf5ef694947604c5fb486f67f40cfe97ce |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.