Dataset Viewer
Auto-converted to Parquet Duplicate
context
listlengths
1
1
gen_kwargs
dict
repeat_idx
int64
0
4
request_idx
int64
0
510
task_name
stringclasses
6 values
metadata
dict
model_outputs
stringlengths
9
4.97k
[ { "content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are three cards with letters $\\texttt{a}$, $\\texttt{b}$, $\\texttt{c}$ placed in a row in some order. You can ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
0
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Here's a Python function that implements the required functionality based on the provided problem statement. It checks if it is possible to convert the given arrangements of cards into the ordered sequence "abc" by making at most one swap, and it handles multiple test cases as specified. ```python def can_make_abc(): ...
[ { "content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Slavic is preparing a present for a friend's birthday. He has an array $a$ of $n$ digits and the present will be the p...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
1
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
To tackle the problem of maximizing the product of an array of digits by adding 1 to exactly one of the digits, we can create a function that follows these steps: 1. Read the number of test cases. 2. For each test case, read the number of digits and the digits themselves. 3. For each digit, compute the product of the ...
[ { "content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a strip of paper $s$ that is $n$ cells long. Each cell is either black or white. In an operation you can...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
2
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Here is the Python function that implements the solution to the problem you described: ```python def minimum_operations(): import sys input = sys.stdin.read data = input().splitlines() t = int(data[0]) # Read number of test cases results = [] index = 1 for _ in range(t): ...
[ { "content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a string $s$ of length $n$, consisting of lowercase Latin letters, and an integer $k$.\n\nYou need to ch...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
3
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Here's the Python function that solves the problem as described. It checks if it's possible to remove exactly `k` characters from a given string `s` such that the remaining characters can form a palindrome: ```python def can_form_palindrome_after_removal(): import sys from collections import Counter input...
[ { "content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array of integers $a_1, a_2, \\ldots, a_n$ and a number $k$ ($2 \\leq k \\leq 5$). In one operation, ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
4
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
To solve the problem, we need to determine the minimum number of increments necessary to make the product of an array of integers divisible by a given integer \( k \). Let's break down the solution step-by-step. ### Key Concepts 1. **Divisibility**: For a number to be divisible by \( k \), it must include all the pri...
[ { "content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vanya and Vova are playing a game. Players are given an integer $n$. On their turn, the player can add $1$ to the curr...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
5
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Here is a Python function that implements the solution to the problem. The function reads from standard input, processes the number of test cases, and determines the winner for each case based on the game's rules. ```python def game_winner(): import sys input = sys.stdin.read data = input().split() ...
[ { "content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alex is participating in the filming of another video of BrMeast, and BrMeast asked Alex to prepare 250 thousand tons ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
6
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
To solve the problem, we need to find the maximum absolute difference between the total weights of any two trucks after distributing the boxes optimally for given numbers of boxes. Here’s a clear breakdown of our approach: 1. Each test case provides us with a number of boxes and their respective weights. 2. We can l...
[ { "content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A subarray is a continuous part of array.\n\nYarik recently found an array $a$ of $n$ elements and became very interes...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
7
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Here is a Python function that follows the specified requirements. It reads from standard input and computes the maximum sum of a non-empty subarray with alternating parities for adjacent elements. ```python def max_alternating_subarray_sum(): import sys input = sys.stdin.read data = input().splitlines() ...
[ { "content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Yarik is a big fan of many kinds of music. But Yarik loves not only listening to music but also writing it. He likes e...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
8
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
To solve the problem, we need to determine how many pairs of indices `(i, j)` such that `i < j` exist in an array where two corresponding notes `b_i` and `b_j` can be represented by the same power combination, i.e., `b_i^{b_j} = b_j^{b_i}`. For the combination to hold true, we can deduce: - Given \( b_i = 2^{a_i} \) a...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array of strings details. Each element of details provides information about a given passenger compressed into a string of length 15....
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
9
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def count_passengers_over_60(details): count = 0 for detail in details: age = int(detail[10:12]) # Extract the age part (2 characters at index 10 and 11) if age > 60: count += 1 return count ```
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed 2D integer array nums. Initially, your score is 0. Perform the following operations until the matrix becomes empty:\n\nFrom each row ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
10
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def calculate_score(nums): score = 0 while nums: max_values = [max(row) for row in nums] max_in_round = max(max_values) score += max_in_round nums = [list(filter(lambda x: x != max(row), row)) for row in nums] nums = [row for row in nums if row] # Remove empty ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums of length n and an integer k. In an operation, you can choose an element and multiply it by 2.\nReturn the maximum...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
11
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def max_bitwise_or_after_operations(nums, k): n = len(nums) max_or_value = 0 # Try applying the operation on each element from 0 to k times for i in range(n): current_value = nums[i] for j in range(k + 1): # j is the count of times we multiply by 2 # Calculate...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums representing the score of students in an exam. The teacher would like to form one non-empty group of students with...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
12
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def max_strength(nums): from itertools import combinations max_product = float('-inf') for r in range(1, len(nums) + 1): for combo in combinations(nums, r): product = 1 for num in combo: product *= num max_product = max(max_product, ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed string s and a dictionary of words dictionary. You have to break s into one or more non-overlapping substrings such that each substri...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
13
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def min_extra_characters(s, dictionary): n = len(s) dp = [0] * (n + 1) for i in range(n + 1): dp[i] = i # All characters are extra initially for i in range(n): for word in dictionary: l = len(word) if s[i:i + l] == word: # Match found ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an integer array prices representing the prices of various chocolates in a store. You are also given a single integer money, which represents you...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
14
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def leftover_money(prices, money): n = len(prices) min_sum = float('inf') # Check all pairs of chocolates for i in range(n): for j in range(i + 1, n): current_sum = prices[i] + prices[j] # Only consider pairs that are within budget if current_su...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two numeric strings num1 and num2 and two integers max_sum and min_sum. We denote an integer x to be good if:\n\nnum1 <= x <= num2\nmin_sum <= di...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
15
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def count_good_integers(num1: str, num2: str, min_sum: int, max_sum: int) -> int: MOD = 10**9 + 7 # A function to calculate the sum of digits of an integer x def digit_sum(x: int) -> int: return sum(int(d) for d in str(x)) # A function that checks if a number is good def is_good(...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array nums of length n.\nThe distinct difference array of nums is an array diff of length n such that diff[i] is equal to the number ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
16
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def distinct_difference_array(nums): n = len(nums) diff = [0] * n for i in range(n): prefix_set = set(nums[:i + 1]) suffix_set = set(nums[i + 1:]) diff[i] = len(prefix_set) - len(suffix_set) return diff ```
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There is a 0-indexed array nums of length n. Initially, all elements are uncolored (has a value of 0).\nYou are given a 2D integer array queries where queries[...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
17
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def color_the_array(n, queries): nums = [0] * n answer = [] adjacent_count = 0 for index, color in queries: # Check left neighbor if index > 0 and nums[index] == nums[index - 1] != 0: adjacent_count -= 1 # Check right neighbor if index < n - 1 and n...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums representing the strength of some heroes. The power of a group of heroes is defined as follows:\n\nLet i_0, i_1, ....
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
18
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def sum_of_hero_powers(nums): MOD = 10**9 + 7 n = len(nums) nums.sort() total_power = 0 for i in range(n): max_strength = nums[i] # Number of valid min elements will be all elements to the left (including current) num_left = i + 1 # total elements from 0 to i ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed permutation of n integers nums.\nA permutation is called semi-ordered if the first number equals 1 and the last number equals n. You ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
19
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def min_operations_to_semi_ordered(nums): n = len(nums) # Find the positions of '1' and 'n' pos_one = nums.index(1) pos_n = nums.index(n) # Count swaps needed to bring '1' to the front moves = pos_one # If 'n' is to the left of '1', we need to adjust the moves for 'n...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed string s that consists of digits from 0 to 9.\nA string t is called a semi-repetitive if there is at most one consecutive pair of the...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
20
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def longest_semi_repetitive_substring(s: str) -> int: max_length = 0 start = 0 repeat_count = 0 for end in range(len(s)): if end > 0 and s[end] == s[end - 1]: repeat_count += 1 while repeat_count > 1: if s[start] == s[start + 1]: repeat...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwi...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
21
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def find_losers(n, k): visited = set() current = 1 turn = 1 while current not in visited: visited.add(current) current = (current + turn * k - 1) % n + 1 turn += 1 losers = [friend for friend in range(1, n + 1) if friend not in visited] return sorted(l...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A 0-indexed array derived with length n is derived by computing the bitwise XOR (βŠ•) of adjacent values in a binary array original of length n.\nSpecifically, f...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
22
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def can_form_original(derived): n = len(derived) if n == 1: return derived[0] == 0 # A single element can only be 0 to derive from itself # Sum of the derived array total_sum = sum(derived) # If the sum of derived is even, it could be valid if we can create pairs return...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a string s consisting only of uppercase English letters.\nYou can apply some operations to this string where, in one operation, you can remove an...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
23
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def min_length_after_removals(s: str) -> int: stack = [] for char in s: stack.append(char) # Check if the last two characters in the stack can form "AB" or "CD" if len(stack) >= 2 and ((stack[-1] == 'B' and stack[-2] == 'A') or (stack[-1] == 'D' and stack[-2] == 'C')): ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a positive integer n, return the punishment number of n.\nThe punishment number of n is defined as the sum of the squares of all integers i such that:\n\...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
24
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def punishment_number(n: int) -> int: def can_partition(num: str, target: int) -> bool: if not num: return target == 0 for i in range(1, len(num) + 1): if int(num[:i]) <= target and can_partition(num[i:], target - int(num[:i])): return True r...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two 0-indexed integer arrays, cost and time, of size n representing the costs and the time taken to paint n different walls respectively. There a...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
25
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def min_cost_paint_walls(cost, time): n = len(cost) dp = [float('inf')] * (n + 1) dp[0] = 0 # No walls painted, no cost for i in range(n): # Use the paid painter for the current wall for j in range(i + 1): if j + time[i] <= n: dp[j + time[i]] = min...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums of size n representing the cost of collecting different chocolates. The cost of collecting the chocolate at the in...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
26
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def min_cost_to_collect_chocolates(nums, x): n = len(nums) total_cost = sum(nums) # Cost of collecting all chocolates without any operations min_cost = total_cost # Initialize min_cost with the total_cost # Iterate through possible number of operations for k in range(n): cur...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two integers, n and k.\nAn array of distinct positive integers is called a k-avoiding array if there does not exist any pair of distinct elements...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
27
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def min_k_avoiding_sum(n, k): result = [] current_num = 1 while len(result) < n: if current_num < k and (k - current_num) not in result: result.append(current_num) elif current_num >= k: result.append(current_num) current_num += 1 return sum(resu...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two integers, num and t.\nAn integer x is called achievable if it can become equal to num after applying the following operation no more than t t...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
28
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def max_achievable_number(num, t): return num + t * 2 ```
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a string s consisting of lowercase English letters, and you are allowed to perform operations on it. In one operation, you can replace a characte...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
29
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def make_smallest_palindrome(s: str) -> str: n = len(s) s_list = list(s) for i in range(n // 2): left_char = s_list[i] right_char = s_list[n - 1 - i] if left_char != right_char: # Replace both with the lexicographically smaller one smal...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed binary string s of length n on which you can apply two types of operations:\n\nChoose an index i and invert all characters from index...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
30
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def min_cost_to_equal_string(s: str) -> int: n = len(s) total_cost = float('inf') # Cost to make all '0's zeros_cost = 0 ones_count = s.count('1') for i in range(n): if s[i] == '1': ones_count -= 1 # Cost to make all '0's can be calculated progressivel...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a positive integer num represented as a string, return the integer num without trailing zeros as a string.\n \nExample 1:\n\nInput: num = \"51230100\"\nO...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
31
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def remove_trailing_zeros(num: str) -> str: return num.rstrip('0') ```
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an integer n that consists of exactly 3 digits.\nWe call the number n fascinating if, after the following modification, the resulting number cont...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
32
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def is_fascinating(n): # Generate the concatenated string of n, 2*n, and 3*n concatenated_number = str(n) + str(2 * n) + str(3 * n) # Check if the concatenated number has exactly 9 digits and contains no '0's if len(concatenated_number) != 9 or '0' in concatenated_number: return F...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a 0-indexed string s, repeatedly perform the following operation any number of times:\n\nChoose an index i in the string, and let c be the character in p...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
33
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def minimized_length(s: str) -> int: index_map = {} for i, char in enumerate(s): if char not in index_map: index_map[char] = [] index_map[char].append(i) to_remove = set() for char, indices in index_map.items(): while len(indices) > 1: left_inde...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums, and you are allowed to traverse between its indices. You can traverse between index i and index j, i != j, if and...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
34
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python from math import gcd from collections import defaultdict, deque def canTraverse(nums): # Create a graph where each number points to its indices graph = defaultdict(list) # Create a mapping of numbers to their indices for i in range(len(nums)): for j in range(i + 1, len(nums)): ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a string s consisting of only lowercase English letters. In one operation, you can do the following:\n\nSelect any non-empty substring of s, poss...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
35
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def smallest_lexicographic_string(s: str) -> str: n = len(s) # Create a list to hold the modified characters result = list(s) # We'll replace starting from the first character until we hit 'a' for i in range(n): if s[i] > 'a': result[i] = chr(ord(s[i]) - 1) ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums. A pair of indices i, j where 0 <= i < j < nums.length is called beautiful if the first digit of nums[i] and the l...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
36
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python from math import gcd def count_beautiful_pairs(nums): count = 0 def first_digit(n): while n >= 10: n //= 10 return n for i in range(len(nums)): for j in range(i + 1, len(nums)): if gcd(first_digit(nums[i]), nums[j] % 10) == 1: ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums and an integer k.\nA subarray is called equal if all of its elements are equal. Note that the empty subarray is an...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
37
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def longest_equal_subarray(nums, k): left = 0 counts = {} max_length = 0 for right in range(len(nums)): counts[nums[right]] = counts.get(nums[right], 0) + 1 while (right - left + 1) - max(counts.values()) > k: counts[nums[left]] -= 1 if cou...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an integer n denoting the total number of servers and a 2D 0-indexed integer array logs, where logs[i] = [server_id, time] denotes that the serve...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
38
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def count_unreceived_requests(n, logs, x, queries): from collections import defaultdict # Create a dictionary to maintain request times for each server server_requests = defaultdict(list) # Fill the dictionary with the logs of server requests for server_id, time in logs: ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums representing the initial positions of some marbles. You are also given two 0-indexed integer arrays moveFrom and m...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
39
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def moveMarbles(nums, moveFrom, moveTo): occupied_positions = set(nums) # Use a set to store unique positions for from_pos, to_pos in zip(moveFrom, moveTo): if from_pos in occupied_positions: # Only move if there's a marble at from_pos occupied_positions.discard(from_pos) # Rem...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two integers num1 and num2.\nIn one operation, you can choose integer i in the range [0, 60] and subtract 2^i + num2 from num1.\nReturn the integ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
40
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def min_operations_to_zero(num1, num2): # Check if it's impossible if num2 >= 0 and num1 > 0: return -1 operations = 0 while num1 > 0: max_subtract = -1 # Try to find the maximum 2^i that can be used for i in range(61): power_of_two = 1 << i # ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two 0-indexed integer arrays nums1 and nums2, each of length n, and a 1-indexed 2D array queries where queries[i] = [x_i, y_i].\nFor the i^th que...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
41
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def max_sum_queries(nums1, nums2, queries): n = len(nums1) combined = [(nums1[i] + nums2[i], nums1[i], nums2[i]) for i in range(n)] combined.sort(reverse=True, key=lambda x: x[0]) # Sort by the sum nums1[j] + nums2[j] in descending order max_sums = [] for x, y in queries: max_sum...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 1-indexed integer array nums of length n.\nAn element nums[i] of nums is called special if i divides n, i.e. n % i == 0.\nReturn the sum of the...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
42
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def sum_of_squares_of_special_elements(nums): n = len(nums) special_sum = 0 for i in range(1, n + 1): if n % i == 0: special_sum += nums[i - 1] ** 2 return special_sum ```
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a positive integer array nums.\nPartition nums into two arrays, nums1 and nums2, such that:\n\nEach element of the array nums belongs to either t...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
43
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def minimize_partition_value(nums): # Sort the array for easier partitioning nums.sort() # The minimum partition value will be the difference between # the maximum of the first part and the minimum of the second part # We need to consider partitions between adjacent elements min_p...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array words consisting of distinct strings.\nThe string words[i] can be paired with the string words[j] if:\n\nThe string words[i] is...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
44
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def max_pairs(words): word_set = set(words) pairs_count = 0 for word in words: reversed_word = word[::-1] if reversed_word in word_set: pairs_count += 1 word_set.remove(word) word_set.remove(reversed_word) return pairs_count // 2 ``...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums containing n distinct positive integers. A permutation of nums is called special if:\n\nFor all indexes 0 <= i < n...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
45
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def count_special_permutations(nums): from math import gcd from functools import lru_cache mod = 10**9 + 7 n = len(nums) # Create adjacency matrix where adj[i][j] is True if nums[i] and nums[j] can be adjacent adj = [[False] * n for _ in range(n)] for i in range(n): ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The imbalance number of a 0-indexed integer array arr of length n is defined as the number of indices in sarr = sorted(arr) such that:\n\n0 <= i < n - 1, and\n...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
46
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def sum_of_imbalance_numbers(nums): n = len(nums) total_imbalance = 0 for start in range(n): for end in range(start + 1, n + 1): subarray = nums[start:end] sorted_subarray = sorted(subarray) imbalance = 0 for i in range(len(...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given three integers x, y, and z.\nYou have x strings equal to \"AA\", y strings equal to \"BB\", and z strings equal to \"AB\". You want to choose som...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
47
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def optimized_string_length(x, y, z): # Start with the total length being the length of all usable strings total_length = 0 # Calculate the maximum pairs of "AA" and "BB" pairs = min(x, y) # Use up the pairs of "AA" and "BB" first total_length += pairs * 4 # Each pair contri...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array words containing n strings.\nLet's define a join operation join(x, y) between two strings x and y as concatenating them into xy...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
48
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def minimum_length_after_join(words): # Initialize the current string with the first word current_str = words[0] # Iterate through the rest of the words for i in range(1, len(words)): # Calculate two possible join lengths join_from_current = (current_str + words[i]) if current...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array nums of n integers and an integer target.\nYou are initially positioned at index 0. In one step, you can jump from index i to a...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
49
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def maxJumps(nums, target): n = len(nums) dp = [-1] * n dp[0] = 0 for i in range(n): if dp[i] == -1: continue for j in range(i + 1, n): if -target <= nums[j] - nums[i] <= target: dp[j] = max(dp[j], dp[i] + 1) return dp[n - 1] ```
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an array nums consisting of positive integers.\nWe call a subarray of an array complete if the following condition is satisfied:\n\nThe number of...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
50
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def count_complete_subarrays(nums): total_distinct = len(set(nums)) # Count of distinct elements in the whole array n = len(nums) count = 0 for start in range(n): seen = set() for end in range(start, n): seen.add(nums[end]) if len(seen) == total_distin...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A truck has two fuel tanks. You are given two integers, mainTank representing the fuel present in the main tank in liters and additionalTank representing the f...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
51
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def maxDistance(mainTank, additionalTank): distance_per_liter = 10 total_distance = 0 while mainTank > 0: if mainTank >= 5: distance = 5 * distance_per_liter total_distance += distance mainTank -= 5 if additionalTank > 0: ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums and an integer threshold.\nFind the length of the longest subarray of nums starting at index l and ending at index...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
52
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def longest_subarray(nums, threshold): max_length = 0 n = len(nums) for l in range(n): if nums[l] % 2 != 0 or nums[l] > threshold: continue r = l while r < n and nums[r] <= threshold and (r == l or nums[r] % 2 != nums[r - 1] % 2): r += 1 ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a binary array nums.\nA subarray of an array is good if it contains exactly one element with the value 1.\nReturn an integer denoting the number ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
53
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def countGoodSubarrays(nums): MOD = 10**9 + 7 count = 0 last_one_index = -1 total_ways = 1 for i in range(len(nums)): if nums[i] == 1: if last_one_index != -1: # The number of zeros between the last '1' and the current '1' zeros_betw...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums. A subarray of nums is called continuous if:\n\nLet i, i + 1, ..., j_ be the indices in the subarray. Then, for ea...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
54
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def continuous_subarrays(nums): n = len(nums) left = 0 count = 0 for right in range(n): while max(nums[left:right + 1]) - min(nums[left:right + 1]) > 2: left += 1 count += right - left + 1 return count ```
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two 0-indexed integer arrays nums1 and nums2 of length n.\nLet's define another 0-indexed integer array, nums3, of length n. For each index i in ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
55
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def maxNonDecreasingLength(nums1, nums2): n = len(nums1) max_length = 1 current_length = 1 # Start from the first element and iterate through the arrays for i in range(1, n): # Choose one of the two numbers to continue a non-decreasing sequence if nums1[i] >= nums1[i-1...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums. A subarray s of length m is called alternating if:\n\nm is greater than 1.\ns_1 = s_0 + 1.\nThe 0-indexed subarra...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
56
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def max_alternating_length(nums): max_length = -1 current_length = 1 for i in range(1, len(nums)): if nums[i] == nums[i-1] + 1 and (i % 2 == 1): current_length += 1 elif nums[i] == nums[i-1] - 1 and (i % 2 == 0): current_length += 1 else: ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array nums consisting of positive integers.\nYou can do the following operation on the array any number of times:\n\nChoose an intege...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
57
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def largest_final_element(nums): total = 0 for num in nums: total += num return total ```
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an integer n. We say that two integers x and y form a prime number pair if:\n\n1 <= x <= y <= n\nx + y == n\nx and y are prime numbers\n\nReturn ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
58
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def find_prime_pairs(n): def is_prime(num): if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True primes = [i for i in range(2, n + 1) if is_prime(i)] prime_pairs = [] ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There are n employees in a company, numbered from 0 to n - 1. Each employee i has worked for hours[i] hours in the company.\nThe company requires each employee...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
59
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def count_employees_meeting_target(hours, target): count = 0 for hour in hours: if hour >= target: count += 1 return count ```
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given three strings a, b, and c, your task is to find a string that has the minimum length and contains all three strings as substrings.\nIf there are multiple...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
60
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def minimum_substring(a: str, b: str, c: str) -> str: from itertools import permutations def merge_strings(s1: str, s2: str) -> str: # Find the maximum overlap between s1 and s2 max_overlap = 0 for i in range(1, min(len(s1), len(s2)) + 1): if s1[-i:] == s2[:i]: ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums and a positive integer k.\nYou can apply the following operation on the array any number of times:\n\nChoose any s...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
61
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def can_make_zero(nums, k): max_num = max(nums) # If the maximum number is less than 1, return True if max_num == 0: return True # Calculate the total number of operations needed total_operations = sum(nums) // k # Check if we can perform enough operations to red...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a string s and an integer k, partition s into k substrings such that the sum of the number of letter changes required to turn each substring into a semi-...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
62
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def min_letter_changes_to_semi_palindrome(s: str, k: int) -> int: def semi_palindrome_changes(substring): n = len(substring) changes = 0 for d in range(1, n): if n % d == 0: valid = True for i in range(d): cha...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array of strings words and a character separator, split each string in words by separator.\nReturn an array of strings containing the new strings form...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
63
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def split_strings(words, separator): result = [] for word in words: split_words = word.split(separator) result.extend(filter(bool, split_words)) return result ```
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given two positive integers n and x.\nReturn the number of ways n can be expressed as the sum of the x^th power of unique positive integers, in other words, th...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
64
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def count_ways(n, x): mod = 10**9 + 7 # Precompute the powers of integers as needed powers = [i**x for i in range(1, int(n**(1/x)) + 1)] # dp[i] will store the number of ways to express i as the sum of unique powers dp = [0] * (n + 1) dp[0] = 1 # There's one way to make 0: using ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a binary string s, partition the string into one or more substrings such that each substring is beautiful.\nA string is beautiful if:\n\nIt doesn't conta...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
65
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def min_beautiful_substrings(s: str) -> int: powers_of_5 = set() num = 1 for i in range(15): # Precompute all powers of 5 that can be represented in binary powers_of_5.add(bin(num)[2:]) num *= 5 n = len(s) dp = [float('inf')] * (n + 1) dp[0] = 0 # Base case: 0 substr...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a string word and an array of strings forbidden.\nA string is called valid if none of its substrings are present in forbidden.\nReturn the length...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
66
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def longest_valid_substring(word, forbidden): forbidden_set = set(forbidden) max_length = 0 n = len(word) # Initialize the start of the valid substring window start = 0 for end in range(n): # Check each substring from start to current end for length in range(1...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your laptop keyboard is faulty, and whenever you type a character 'i' on it, it reverses the string that you have written. Typing other characters works as exp...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
67
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def faulty_keyboard(s: str) -> str: result = [] for char in s: if char == 'i': result.reverse() else: result.append(char) return ''.join(result) ```
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a 0-indexed string s, permute s to get a new string t such that:\n\nAll consonants remain in their original places. More formally, if there is an index i...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
68
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def sort_vowels(s: str) -> str: vowels = 'aeiouAEIOU' vowel_positions = [] vowel_chars = [] # Collect the vowels and their positions for i, char in enumerate(s): if char in vowels: vowel_positions.append(i) vowel_chars.append(char) # Sort the vowels ba...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An element x of an integer array arr of length m is dominant if freq(x) * 2 > m, where freq(x) is the number of occurrences of x in arr. Note that this definit...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
69
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def find_min_split(nums): n = len(nums) # Count the frequency of each number in the array freq = {} for num in nums: if num in freq: freq[num] += 1 else: freq[num] = 1 # Identify the dominant element and its frequency dominant_e...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array nums and a non-negative integer k.\nIn one operation, you can do the following:\n\nChoose an index i that hasn't been chosen be...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
70
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def maxBeauty(nums, k): # Dictionary to count frequency of values after adjustment count = {} # Iterate through each number in nums for num in nums: # The range of numbers we can transform to is [num - k, num + k] for new_num in range(num - k, num + k + 1): if ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an integer array nums. We consider an array good if it is a permutation of an array base[n].\nbase[n] = [1, 2, ..., n - 1, n, n] (in other words,...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
71
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def is_good_array(nums): n = max(nums) expected_length = n + 1 actual_length = len(nums) if expected_length != actual_length: return False count = [0] * (n + 1) for num in nums: if num > n: return False count[num] += 1 return ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums and a positive integer x.\nYou are initially at position 0 in the array and you can visit other positions accordin...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
72
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def max_score(nums, x): n = len(nums) dp = [0] * n dp[0] = nums[0] for i in range(1, n): dp[i] = nums[i] # start with the score at the current position for j in range(i): score = dp[j] + nums[i] if (nums[j] % 2) != (nums[i] % 2): # check for differing...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums. You have to find the maximum sum of a pair of numbers from nums such that the maximum digit in both numbers are e...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
73
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def maximumSum(nums): from collections import defaultdict max_digit_map = defaultdict(list) for num in nums: max_digit = max(int(d) for d in str(num)) max_digit_map[max_digit].append(num) max_sum = -1 for num_list in max_digit_map.values(): if len(num...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums, an integer modulo, and an integer k.\nYour task is to find the count of subarrays that are interesting.\nA subarr...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
74
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def count_interesting_subarrays(nums, modulo, k): n = len(nums) cnt = 0 interesting_subarrays_count = 0 frequency = {0: 1} # To handle the case where cnt % modulo == k directly for num in nums: if num % modulo == k: cnt += 1 # Check if we can form an ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an array nums of length n and an integer m. You need to determine if it is possible to split the array into n non-empty arrays by performing a se...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 0, "temperature": 0.7 }
0
75
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
```python def can_split_array(nums, m): total_sum = sum(nums) n = len(nums) # If total sum is less than m, we cannot even form a single subarray with sum >= m if total_sum < m: return False # We will use a stack to track the current subarrays stack = [] # We begin by consideri...
End of preview. Expand in Data Studio
Made with Curator

Dataset card for REASONING_evalchemy_8_sharded_gpt-4o-mini

This dataset was made with Curator.

Dataset details

A sample from the dataset:

{
    "context": [
        {
            "content": "Problem: What is the degree measure of the acute angle formed by lines with slopes $2$ and $\\frac{1}{3}$?\nMark your solution with \\boxed\nAnswer:",
            "role": "user"
        }
    ],
    "gen_kwargs": {
        "do_sample": false,
        "max_new_tokens": 32768,
        "seed": 3,
        "temperature": 0.7
    },
    "repeat_idx": 3,
    "request_idx": 2,
    "task_name": "AMC23",
    "metadata": {
        "expected_answer": "45",
        "problem_id": "2",
        "reference_solution": ""
    },
    "model_outputs": "To find the acute angle formed by two lines with slopes m1=2 m_1 = 2  and m2=frac13 m_2 = \\frac{1}{3} , we can use the formula for the tangent of the angle theta \\theta  between two lines:\n\n\\[\n\\tan \\theta = \\left| \\frac{m_1 - m_2}{1 + m_1 m_2} \\right|\n\\]\n\nSubstituting the given slopes into the formula:\n\n1. Calculate m1βˆ’m2 m_1 - m_2 :\n   \\[\n   m_1 - m_2 = 2 - \\frac{1}{3} = \\frac{6}{3} - \\frac{1}{3} = \\frac{5}{3}\n   \\]\n\n2. Calculate 1+m1m2 1 + m_1 m_2 :\n   \\[\n   m_1 m_2 = 2 \\cdot \\frac{1}{3} = \\frac{2}{3}\n   \\]\n   Thus,\n   \\[\n   1 + m_1 m_2 = 1 + \\frac{2}{3} = \\frac{3}{3} + \\frac{2}{3} = \\frac{5}{3}\n   \\]\n\nNow substitute back into the formula for tantheta \\tan \\theta :\n\\[\n\\tan \\theta = \\left| \\frac{\\frac{5}{3}}{\\frac{5}{3}} \\right| = 1\n\\]\n\nTo find the angle theta \\theta , we take the arctangent:\n\\[\n\\theta = \\tan^{-1}(1)\n\\]\n\nThis corresponds to:\n\\[\n\\theta = 45^\\circ\n\\]\n\nThus, the acute angle formed by the lines with slopes 2 2  and frac13 \\frac{1}{3}  is:\n\n\\[\n\\boxed{45}\n\\]"
}

Loading the dataset

You can load this dataset using the following code:

from datasets import load_dataset

dataset = load_dataset("mlfoundations-dev/REASONING_evalchemy_8_sharded_gpt-4o-mini", split="default")
Downloads last month
21