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
22.4k
[ { "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 an executable Python function that reads from standard input, checks the arrangement of cards for each test case, and prints whether it's possible to arrange them to "abc" with at most one swap: ```python def can_form_abc(): import sys input = sys.stdin.read data = input().splitlines() 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.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": "" }
Here's a Python function to solve the given problem. This function processes input from standard input (stdin), computes the desired maximum product after adding 1 to exactly one of the digits for each test case, and prints the results. ```python def max_product_with_one_increment(): import sys input = sys.std...
[ { "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’s a Python function that implements the solution to the problem you described. The function will read inputs from standard input, process each test case, and print the minimum number of operations needed to make all cells white. ```python def min_operations_to_white(): import sys input = sys.stdin.read ...
[ { "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": "" }
```python def can_form_palindrome_after_removal(): import sys from collections import Counter input = sys.stdin.read data = input().splitlines() t = int(data[0]) index = 1 results = [] for _ in range(t): n, k = map(int, data[index].split()) s = data[index + 1] ...
[ { "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": "" }
Certainly! Below is a Python function that meets the requirements of your prompt. It reads input from standard input (stdin), processes multiple test cases, and prints the minimum number of operations needed to make the product of all numbers in the array divisible by a given number `k` (where `k` can be between 2 and ...
[ { "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": "" }
To solve the problem, we need to determine if Vanya can guarantee a win within 10 moves when he starts with an integer `n` and both players play optimally. The key observations are: - Vanya wins if he can make `n` divisible by 3 on his turn. - The game consists of 10 total moves, alternating between Vanya and Vova. ...
[ { "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": "" }
Here's a Python function based on the prompt you provided. The function will take input from standard input, process it according to the described logic, and print the output for each test case. ```python def max_weight_difference(): import sys input = sys.stdin.read data = input().splitlines() 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.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 implements the solution to the problem described in your prompt. The function reads input from standard input, processes multiple test cases, and prints the maximum sum of non-empty subarrays with alternating parity for each test case. ```python def max_alternating_subarray_sum(): im...
[ { "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": "" }
Certainly! Here is a Python function that solves the problem as described in the prompt. This function reads the input from standard input and outputs the number of valid pairs for each test case. ```python def count_equal_pairs(): import sys from collections import defaultdict input = sys.stdin.read d...
[ { "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 from the string 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_final_score(nums): score = 0 while nums: max_numbers = [max(row) for row in nums] score += max(max_numbers) nums = [list(filter(lambda x: x != max_value, row)) for row, max_value in zip(nums, max_numbers) if row] return score ```
[ { "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 maximumOr(nums, k): n = len(nums) max_or_value = 0 # Iterate over each number and calculate the possible maximum OR for i in range(n): current_value = nums[i] # Create a temporary array to store the modified values modified_nums = nums[:] # App...
[ { "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): max_product = float('-inf') n = len(nums) # There are 2^n - 1 possible non-empty subsets for i in range(1, 1 << n): product = 1 for j in range(n): # Check if jth element is included in the subset if i & (1 << j): ...
[ { "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_chars(s, dictionary): s_length = len(s) dp = [0] * (s_length + 1) # Create a set of words for O(1) lookups word_set = set(dictionary) for i in range(s_length + 1): # Start with the assumption that all characters up to i are extra dp[i] = 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 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 buy_chocolates(prices, money): n = len(prices) min_spent = float('inf') for i in range(n): for j in range(i + 1, n): cost = prices[i] + prices[j] if cost <= money: min_spent = min(min_spent, cost) if min_spent == float('inf'): ...
[ { "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 good_integers_count(num1, num2, min_sum, max_sum): MOD = 10**9 + 7 def digit_sum(x): return sum(int(d) for d in x) def count_good_integers(low, high, min_d_sum, max_d_sum): count = 0 for i in range(low, high + 1): x_str = str(i) d_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 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 prefix_set = set() suffix_set = set(nums) for i in range(n): prefix_set.add(nums[i]) suffix_set.discard(nums[i]) 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 def count_adjacent(): count = 0 for j in range(n - 1): if nums[j] == nums[j + 1] and nums[j] != 0: count += 1 return count for index, color in queries: ...
[ { "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) total_power = 0 # Sort the nums array to facilitate grouping sorted_nums = sorted(nums) # Calculate the contribution of each hero in the sorted order for i in range(n): # Each hero can be the max in all subsets t...
[ { "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 index of '1' and 'n' in the array index_of_1 = nums.index(1) index_of_n = nums.index(n) # Count swaps needed to bring '1' to the front swaps_to_front = index_of_1 # Count swaps needed to bring 'n' to ...
[ { "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 left = 0 consecutive_pairs = 0 for right in range(len(s)): if right > 0 and s[right] == s[right - 1]: consecutive_pairs += 1 while consecutive_pairs > 1: if s[left] ==...
[ { "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): seen = set() current = 1 losers = set(range(1, n + 1)) while current not in seen: seen.add(current) losers.discard(current) current = (current + (len(seen) * k) - 1) % n + 1 return sorted(losers) ```
[ { "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 # Only a valid original is [0] if derived[0] is 0 # The sum of elements in 'derived' must be even for a valid original to exist # because each bit contributes to two derived values (except when wra...
[ { "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 minimum_length_after_removals(s: str) -> int: stack = [] for char in s: stack.append(char) while len(stack) >= 2: if stack[-2] == 'A' and stack[-1] == 'B': stack.pop() # Remove 'B' stack.pop() # Remove 'A' elif stack[-2...
[ { "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): def can_partition(s, target): # This function checks if we can partition the string s to sum to target l = len(s) # Generate all possible partitions for i in range(1, l + 1): for j in range(i, l + 1): if int(s[i-1:j]) ==...
[ { "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 minimum_cost_to_paint_walls(cost, time): n = len(cost) total_cost = float('inf') for i in range(n): current_cost = 0 current_time = 0 for j in range(n): if j < i: current_cost += cost[j] current_time += time[j] ...
[ { "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) # Initial cost without any operations total_cost = sum(nums) # If n is 1, we can only buy the one chocolate at its cost if n == 1: return total_cost # Minimum cost after performing operations min_tota...
[ { "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 = 1 while len(result) < n: if (k - current) not in result: result.append(current) current += 1 return sum(result) ```
[ { "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) # Convert the string to a list for mutability left, right = 0, n - 1 while left < right: if s_list[left] != s_list[right]: # Replace the larger character with the smaller one smaller_char...
[ { "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_make_equal(s: str) -> int: n = len(s) # Count the number of 0's and 1's in the string count_0 = s.count('0') count_1 = n - count_0 # If all are already equal, return 0 if count_0 == 0 or count_1 == 0: return 0 # Minimum cost initialization min...
[ { "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: int) -> bool: # Concatenate n, 2*n, and 3*n into a single string concatenated_number = str(n) + str(2 * n) + str(3 * n) # Create a set of the concatenated number's digits digit_set = set(concatenated_number) # Check if the set of digits contains exactly the ...
[ { "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: from collections import defaultdict char_positions = defaultdict(list) # Record the positions of each character for index, char in enumerate(s): char_positions[char].append(index) # To find the minimized length, we can keep track ...
[ { "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 def can_traverse_all_pairs(nums): n = len(nums) if n == 1: return True # Graph to store connections based on GCD graph = defaultdict(list) # Build the graph based on GCD condition for i in range(n): for j in ra...
[ { "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 lexicographically_smallest_string(s: str) -> str: n = len(s) # We will iterate over all characters to find the optimal substring to convert smallest = s # Initialize the smallest string as the original string for i in range(n): # Try to convert from index i to j j = 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. 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 def count_beautiful_pairs(nums): from math import gcd def first_digit(n): while n >= 10: n //= 10 return n def last_digit(n): return n % 10 count = 0 n = len(nums) for i in range(n): for j in range(i + 1, n): if gcd(first_digi...
[ { "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 count = {} max_length = 0 for right in range(len(nums)): count[nums[right]] = count.get(nums[right], 0) + 1 while (right - left + 1) - max(count.values()) > k: count[nums[left]] -= 1 if count[nums[l...
[ { "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_idle_servers(n, logs, x, queries): # Create a dictionary to track the times requests were received by each server from collections import defaultdict server_requests = defaultdict(list) for server_id, time in logs: server_requests[server_id].append(time) # To store ...
[ { "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): # Step 1: Initialize a set with the initial marble positions occupied_positions = set(nums) # Step 2: Process each move for from_pos, to_pos in zip(moveFrom, moveTo): # If the position to move from has marbles, move them to the new position...
[ { "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): if num2 >= 0: return -1 # Calculate the maximum possible value of `2^i + num2` for i in [0, 60] powers = [(1 << i) + num2 for i in range(61)] operations = 0 num1 = -num1 # We'll treat num1 as a negative value to make comparisons si...
[ { "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) answer = [] # Create a list of tuples (sum of nums1 and nums2, nums1, nums2) and sort by the sum combined = [(nums1[i] + nums2[i], nums1[i], nums2[i]) for i in range(n)] combined.sort(reverse=True, key=lambda x: x[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 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 min_partition_value(nums): # Sort the array to facilitate partitioning nums.sort() # Initialize the minimum partition value to a large number min_value = float('inf') # Calculate the minimum partition value by iterating through possible partitions for i in range(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 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_reversed_pairs(words): seen = set() pairs_count = 0 for word in words: reversed_word = word[::-1] if reversed_word in seen: pairs_count += 1 seen.remove(reversed_word) # Remove to ensure each can only pair once else: seen.ad...
[ { "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 special_permutations(nums): from math import factorial from collections import defaultdict MOD = 10**9 + 7 n = len(nums) # Create a graph to check for divisibility graph = defaultdict(list) for i in range(n): for j in range(n): if i != j: i...
[ { "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_count = 0 for i in rang...
[ { "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 maximum_length(x: int, y: int, z: int) -> int: if x > y: x, y = y, x # Make sure x <= y for easier management # Using as many "AA" and "BB" as possible without forming "AAA" or "BBB" max_length = 0 # How many pairs of "AB" can we use min_z_y = min(z, y) remaining_y = y -...
[ { "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(words): n = len(words) # Initialize the length of the resulting string current_length = len(words[0]) # Iterate through the remaining words for i in range(1, n): word = words[i] # Calculate the lengths when joining in both possible ways ...
[ { "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 max_jumps(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] if dp...
[ { "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)) n = len(nums) complete_count = 0 for i in range(n): seen = {} distinct_count = 0 for j in range(i, n): if nums[j] in seen: seen[nums[j]] += 1 else: ...
[ { "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 fuel_used = 0 while mainTank > 0: # Calculate distance with the current fuel in the main tank if mainTank >= 5: # Travel the distance for 5 liters total_distance +...
[ { "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: current_length = 1 for r in range(l + 1, n): if nums[r] % 2 != nums[r - 1] % 2 and nums[r] <= threshold: current_length +...
[ { "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 count_good_subarrays(nums): MOD = 10**9 + 7 last_one = -1 count = 0 result = 1 for i in range(len(nums)): if nums[i] == 1: if last_one != -1: ways = i - last_one result = (result * ways) % MOD last_one = 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. 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 count_continuous_subarrays(nums): n = len(nums) total_count = 0 left = 0 for right in range(n): while nums[right] - nums[left] > 2 or nums[left] - nums[right] > 2: left += 1 total_count += right - left + 1 return total_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) if n == 1: return 1 max_length = 1 current_length = 1 nums3 = [0] * n nums3[0] = nums1[0] for i in range(1, n): # Choose the optimal value for nums3[i] if nums1[i] >= nums3[i-1]: nums3[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. 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_subarray_length(nums): max_length = -1 current_length = 0 for i in range(1, len(nums)): if nums[i] == nums[i - 1] + 1 or (current_length > 0 and nums[i] == nums[i - 1] - 1): current_length += 1 if current_length >= 1: # Ensure we have a sub...
[ { "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 maximum_final_value(nums): total_sum = 0 current_max = 0 for num in nums: if current_max <= num: total_sum += num current_max = num return total_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 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 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_set = set(primes) result ...
[ { "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): return sum(1 for hour in hours if hour >= target) ```
[ { "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_string(a: str, b: str, c: str) -> str: from itertools import permutations def merge_strings(str1: str, str2: str) -> str: max_overlap = 0 # Finds the maximum overlap between suffix of str1 and prefix of str2 for i in range(1, min(len(str1), len(str2)) + 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 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_all_zero(nums, k): max_num = max(nums) if max_num == 0: return True from collections import defaultdict count_map = defaultdict(int) for num in nums: count_map[num] += 1 current_sum = 0 for i in range(max_num + 1): if count_map[i] > 0...
[ { "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_changes_to_semi_palindrome(s: str, k: int) -> int: n = len(s) # Function to calculate the minimum changes to make a substring semi-palindrome def min_changes(sub: str) -> int: length = len(sub) result = 0 # Check every possible divisor of the length of the...
[ { "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_words(words, separator): result = [] for word in words: split_strings = word.split(separator) result.extend(filter(None, split_strings)) 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_unique_power_sums(n: int, x: int) -> int: MOD = 10**9 + 7 # Precompute the powers of integers powers = [i**x for i in range(1, n+1)] # dp[i] will hold the number of ways we can sum up to i using unique integers' powers dp = [0] * (n + 1) dp[0] = 1 # There's one way to sum ...
[ { "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: # Generate all powers of 5 in binary representation that can fit within the length of s beautiful_numbers = [] power = 1 while True: binary_rep = bin(power)[2:] # Get binary representation without '0b' if len(binary_rep) > len(s): ...
[ { "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 start = 0 n = len(word) for end in range(n): for length in range(1, 11): if end - length + 1 >= 0 and word[end - length + 1:end + 1] in forbidden_set: start ...
[ { "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_indices = [] vowel_chars = [] # Collect indices and characters of vowels for i, char in enumerate(s): if char in vowels: vowel_indices.append(i) vowel_chars.append(char) # Sort the vow...
[ { "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 minimum_valid_split(nums): from collections import Counter n = len(nums) count = Counter(nums) dominant_element = max(count, key=count.get) m = n # Check if the dominant element is indeed dominant if count[dominant_element] * 2 <= m: return -1 left_co...
[ { "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 maximum_beauty(nums, k): min_num = min(nums) max_num = max(nums) # Create a frequency map of the range of possible values freq_map = {} for num in nums: start_range = max(0, num - k) end_range = num + k for value in range(start_range, end_range + 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 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 actual_length != expected_length: return False count = [0] * (n + 1) for num in nums: if num > n or num < 1: return False count[num] += 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 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_total_score(nums, x): n = len(nums) dp = [0] * n dp[0] = nums[0] for i in range(1, n): max_score = 0 for j in range(i): score = dp[j] + nums[i] if (nums[i] % 2) != (nums[j] % 2): # Check for different parities score -= x ...
[ { "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 max_sum_pair_with_equal_max_digit(nums): from collections import defaultdict def max_digit(n): return max(int(d) for d in str(n)) # Dictionary to store the maximum number for each max digit max_for_digit = defaultdict(list) for num in nums: max_d = max_digit(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) count = 0 mod_count = {} mod_count[0] = 1 # For empty prefix current_count = 0 for num in nums: if num % modulo == k: current_count += 1 requirement = (current_count - k) % modulo ...
[ { "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_into_n_arrays(nums, m): # Helper function to check if we can split from the given start index to end index def can_split(start, end): total_sum = sum(nums[start:end]) length = end - start # Base case, if we have a single element, it can be its own array ...
End of preview. Expand in Data Studio
Made with Curator

Dataset card for REASONING_evalchemy_1_sharded_gpt-4o-mini

This dataset was made with Curator.

Dataset details

A sample from the dataset:

{
    "context": [
        {
            "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 the following operation at most once: \n\n \n-  Pick two cards, and swap them.  Is it possible that the row becomes $\\texttt{abc}$ after the operation? Output \"YES\" if it is possible, and \"NO\" otherwise.\n\nInput\n\nThe first line contains a single integer $t$ ($1 \\leq t \\leq 6$)\u00a0\u2014 the number of test cases.\n\nThe only line of each test case contains a single string consisting of each of the three characters $\\texttt{a}$, $\\texttt{b}$, and $\\texttt{c}$ exactly once, representing the cards.\n\nOutput\n\nFor each test case, output \"YES\" if you can make the row $\\texttt{abc}$ with at most one operation, or \"NO\" otherwise.\n\nYou can output the answer in any case (for example, the strings \"yEs\", \"yes\", \"Yes\" and \"YES\" will be recognized as a positive answer).Sample Input 1:\n6\n\nabc\n\nacb\n\nbac\n\nbca\n\ncab\n\ncba\n\n\n\nSample Output 1:\n\nYES\nYES\nYES\nNO\nNO\nYES\n\n\nNote\n\nIn the first test case, we don't need to do any operations, since the row is already $\\texttt{abc}$.\n\nIn the second test case, we can swap $\\texttt{c}$ and $\\texttt{b}$: $\\texttt{acb} \\to \\texttt{abc}$.\n\nIn the third test case, we can swap $\\texttt{b}$ and $\\texttt{a}$: $\\texttt{bac} \\to \\texttt{abc}$.\n\nIn the fourth test case, it is impossible to make $\\texttt{abc}$ using at most one operation.",
            "role": "user"
        }
    ],
    "gen_kwargs": {
        "do_sample": false,
        "max_new_tokens": 32768,
        "seed": 0,
        "temperature": 0.7
    },
    "repeat_idx": 0,
    "request_idx": 0,
    "task_name": "LiveCodeBench",
    "metadata": {
        "expected_answer": "",
        "problem_id": "",
        "reference_solution": ""
    },
    "model_outputs": "Here's an executable Python function that reads from standard input, checks the arrangement of cards for each test case, and prints whether it's possible to arrange them to \"abc\" with at most one swap:\n\n```python\ndef can_form_abc():\n    import sys\n    input = sys.stdin.read\n    data = input().splitlines()\n    \n    t = int(data[0])  # Number of test cases\n    results = []\n    \n    for i in range(1, t + 1):\n        cards = data[i].strip()\n        \n        # Check how many characters are in the correct position for 'abc'\n        if cards == \"abc\":\n            results.append(\"YES\")\n        elif (cards[0] == 'a' and cards[1] == 'c' and cards[2] == 'b') or \\\n             (cards[0] == 'b' and cards[1] == 'a' and cards[2] == 'c') or \\\n             (cards[0] == 'c' and cards[1] == 'a' and cards[2] == 'b') or \\\n             (cards[0] == 'b' and cards[1] == 'c' and cards[2] == 'a') or \\\n             (cards[0] == 'c' and cards[1] == 'b' and cards[2] == 'a') or \\\n             (cards[0] == 'c' and cards[1] == 'b' and cards[2] == 'a'):\n            results.append(\"YES\")\n        else:\n            results.append(\"NO\")\n    \n    print(\"\\n\".join(results))\n\n# Call the function to read input and produce output\ncan_form_abc()\n```\n\n### How to Execute the Function:\n1. Copy the code into a Python environment or script file.\n2. Provide input through the standard input stream, adhering to the specified format.\n3. Run the script to see the output.\n\n### Explanation:\n- The function begins by reading all the input at once.\n- The number of test cases is parsed from the first input line.\n- It iterates through each test case, checking if the sequence can be transformed into \"abc\" using at most one swap.\n- If the string matches \"abc\" right away or can be matched by swapping two specific characters, it appends \"YES\" to the results; otherwise, it appends \"NO\".\n- Finally, the results are printed in one go, each on a new line."
}

Loading the dataset

You can load this dataset using the following code:

from datasets import load_dataset

dataset = load_dataset("mlfoundations-dev/REASONING_evalchemy_1_sharded_gpt-4o-mini", split="default")

Evaluation Results

Summary

Metric AIME24 AIME25 AMC23 GPQADiamond MATH500
Accuracy 12.0 10.7 55.0 34.2 71.6

AIME24

  • Average Accuracy: 12.00% ± 2.23%
  • Number of Runs: 5
Run Accuracy Questions Solved Total Questions
1 16.67% 5 30
2 10.00% 3 30
3 16.67% 5 30
4 3.33% 1 30
5 13.33% 4 30

AIME25

  • Average Accuracy: 10.67% ± 1.12%
  • Number of Runs: 5
Run Accuracy Questions Solved Total Questions
1 10.00% 3 30
2 6.67% 2 30
3 13.33% 4 30
4 10.00% 3 30
5 13.33% 4 30

AMC23

  • Average Accuracy: 55.00% ± 2.00%
  • Number of Runs: 5
Run Accuracy Questions Solved Total Questions
1 47.50% 19 40
2 57.50% 23 40
3 60.00% 24 40
4 52.50% 21 40
5 57.50% 23 40

GPQADiamond

  • Average Accuracy: 34.18% ± 3.20%
  • Number of Runs: 3
Run Accuracy Questions Solved Total Questions
1 31.31% 62 198
2 29.29% 58 198
3 41.92% 83 198

MATH500

  • Accuracy: 71.60%
    Accuracy Questions Solved Total Questions
    71.60% 358 500
Downloads last month
14